Mesa (main): gallium: add PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 29 08:20:49 UTC 2022


Module: Mesa
Branch: main
Commit: bd88bed8556aff109a5a9cdb9b8d63073ade9df6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd88bed8556aff109a5a9cdb9b8d63073ade9df6

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Mon Apr 25 14:19:02 2022 +0200

gallium: add PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER

This way we can make allow_draw_out_of_order true by default for all
apps, iff the driver allows it.

And allow_draw_out_of_order=false can still be used in drirc, for
apps that need this optim to be turned off.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16139>

---

 docs/gallium/screen.rst                             | 1 +
 src/gallium/auxiliary/pipe-loader/driinfo_gallium.h | 2 +-
 src/gallium/auxiliary/util/u_screen.c               | 1 +
 src/gallium/include/pipe/p_defines.h                | 1 +
 src/mesa/main/state.c                               | 4 +++-
 src/mesa/state_tracker/st_extensions.c              | 5 ++++-
 src/util/00-mesa-defaults.conf                      | 1 -
 7 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst
index 274b16e2bf7..a4475df2c24 100644
--- a/docs/gallium/screen.rst
+++ b/docs/gallium/screen.rst
@@ -641,6 +641,7 @@ The integer capabilities:
 * ``PIPE_CAP_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS``: TRUE if there are no restrictions on the allocation of mipmaps in sparse textures and FALSE otherwise. See SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB description in ARB_sparse_texture extension spec.
 * ``PIPE_CAP_QUERY_SPARSE_TEXTURE_RESIDENCY``: TRUE if shader sparse texture sample instruction could also return the residency information.
 * ``PIPE_CAP_CLAMP_SPARSE_TEXTURE_LOD``: TRUE if shader sparse texture sample instruction support clamp the minimal lod to prevent read from un-committed pages.
+* ``PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER``: TRUE if the driver allows the "draw out of order" optimization to be enabled. See _mesa_update_allow_draw_out_of_order for more details.
 
 .. _pipe_capf:
 
diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index 067348a3733..b5e4c1a6c03 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -32,7 +32,7 @@ DRI_CONF_SECTION_DEBUG
    DRI_CONF_FORCE_GLSL_ABS_SQRT(false)
    DRI_CONF_GLSL_CORRECT_DERIVATIVES_AFTER_DISCARD(false)
    DRI_CONF_GLSL_IGNORE_WRITE_TO_READONLY_VAR(false)
-   DRI_CONF_ALLOW_DRAW_OUT_OF_ORDER(false)
+   DRI_CONF_ALLOW_DRAW_OUT_OF_ORDER(true)
    DRI_CONF_GLTHREAD_NOP_CHECK_FRAMEBUFFER_STATUS(false)
    DRI_CONF_FORCE_COMPAT_PROFILE(false)
    DRI_CONF_FORCE_COMPAT_SHADERS(false)
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c
index 6ab60a639e7..52db3a840fc 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -372,6 +372,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
    case PIPE_CAP_IMAGE_ATOMIC_INC_WRAP:
    case PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE:
    case PIPE_CAP_GLSL_ZERO_INIT:
+   case PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER:
       return 0;
 
    case PIPE_CAP_MAX_GS_INVOCATIONS:
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 50e0404a1e9..4a8ce7e5be5 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -1009,6 +1009,7 @@ enum pipe_cap
    PIPE_CAP_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS,
    PIPE_CAP_QUERY_SPARSE_TEXTURE_RESIDENCY,
    PIPE_CAP_CLAMP_SPARSE_TEXTURE_LOD,
+   PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER,
 
    PIPE_CAP_LAST,
    /* XXX do not add caps after PIPE_CAP_LAST! */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 1f76539ecaa..43440bc638b 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -90,9 +90,11 @@ _mesa_update_allow_draw_out_of_order(struct gl_context *ctx)
     * for driver-internal reasons.
     */
    /* Only the compatibility profile with immediate mode needs this. */
-   if (ctx->API != API_OPENGL_COMPAT || !ctx->Const.AllowDrawOutOfOrder)
+   if (!ctx->Const.AllowDrawOutOfOrder)
       return;
 
+   assert(ctx->API == API_OPENGL_COMPAT);
+
    /* If all of these are NULL, GLSL is disabled. */
    struct gl_program *vs =
       ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index f076f3843fe..11e686b1f79 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1812,7 +1812,10 @@ void st_init_extensions(struct pipe_screen *screen,
       _mesa_fill_supported_spirv_extensions(consts->SpirVExtensions, spirv_caps);
    }
 
-   consts->AllowDrawOutOfOrder = options->allow_draw_out_of_order;
+   consts->AllowDrawOutOfOrder =
+      api == API_OPENGL_COMPAT &&
+      options->allow_draw_out_of_order &&
+      screen->get_param(screen, PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER);
    consts->GLThreadNopCheckFramebufferStatus = options->glthread_nop_check_framebuffer_status;
 
    bool prefer_nir = PIPE_SHADER_IR_NIR ==
diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index 088b78e8ca2..ca8e23e55bc 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -334,7 +334,6 @@ TODO: document the other workarounds.
             <option name="force_gl_vendor" value="NVIDIA Corporation" />
             <!-- creo-02 doesn't enable GL_EXT_shader_image_load_store in GLSL -->
             <option name="force_glsl_extensions_warn" value="true" />
-            <option name="allow_draw_out_of_order" value="true" />
             <option name="mesa_glthread" value="true" />
             <option name="mesa_no_error" value="true" />
             <!-- Creating 10-bit pbuffers fails in the X server and returns BadAlloc. -->



More information about the mesa-commit mailing list