[Mesa-dev] [PATCH] st/mesa: expose 0 shader binary formats for compat profiles for Qt

Marek Olšák maraeo at gmail.com
Fri Feb 23 19:47:53 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

Bugzilla: https://bugreports.qt.io/browse/QTBUG-66420
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105065
Cc: "18.0" <mesa-stable at lists.freedesktop.org>
---
 src/mesa/state_tracker/st_context.c    |  2 +-
 src/mesa/state_tracker/st_extensions.c | 14 +++++++++++---
 src/mesa/state_tracker/st_extensions.h |  3 ++-
 src/mesa/state_tracker/st_manager.c    |  2 +-
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index e23f9fd..dfdd92f 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -461,21 +461,21 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
       screen->get_param(screen, PIPE_CAP_TGSI_PACK_HALF_FLOAT);
    st->has_multi_draw_indirect =
       screen->get_param(screen, PIPE_CAP_MULTI_DRAW_INDIRECT);
 
    st->has_hw_atomics =
       screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
                                PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS)
       ? true : false;
 
    /* GL limits and extensions */
-   st_init_limits(pipe->screen, &ctx->Const, &ctx->Extensions);
+   st_init_limits(pipe->screen, &ctx->Const, &ctx->Extensions, ctx->API);
    st_init_extensions(pipe->screen, &ctx->Const,
                       &ctx->Extensions, &st->options, ctx->API);
 
    if (st_have_perfmon(st)) {
       ctx->Extensions.AMD_performance_monitor = GL_TRUE;
    }
 
    /* Enable shader-based fallbacks for ARB_color_buffer_float if needed. */
    if (screen->get_param(screen, PIPE_CAP_VERTEX_COLOR_UNCLAMPED)) {
       if (!screen->get_param(screen, PIPE_CAP_VERTEX_COLOR_CLAMPED)) {
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 42d53cb..4bd5404 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -68,21 +68,22 @@ static int _clamp(int a, int min, int max)
    else
       return a;
 }
 
 
 /**
  * Query driver to get implementation limits.
  * Note that we have to limit/clamp against Mesa's internal limits too.
  */
 void st_init_limits(struct pipe_screen *screen,
-                    struct gl_constants *c, struct gl_extensions *extensions)
+                    struct gl_constants *c, struct gl_extensions *extensions,
+                    gl_api api)
 {
    int supported_irs;
    unsigned sh;
    boolean can_ubo = TRUE;
    int temp;
    bool ssbo_atomic = true;
 
    c->MaxTextureLevels
       = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
             MAX_TEXTURE_LEVELS);
@@ -430,22 +431,29 @@ void st_init_limits(struct pipe_screen *screen,
          c->Program[MESA_SHADER_FRAGMENT].MaxUniformBlocks +
          c->Program[MESA_SHADER_COMPUTE].MaxUniformBlocks;
       assert(c->MaxCombinedUniformBlocks <= MAX_COMBINED_UNIFORM_BUFFERS);
    }
 
    c->GLSLFragCoordIsSysVal =
       screen->get_param(screen, PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL);
    c->GLSLFrontFacingIsSysVal =
       screen->get_param(screen, PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL);
 
-   /* GL_ARB_get_program_binary */
-   if (screen->get_disk_shader_cache && screen->get_disk_shader_cache(screen))
+   /* GL_ARB_get_program_binary
+    *
+    * The QT framework has a bug in their shader program cache, which is built
+    * on GL_ARB_get_program_binary. In an effort to allow them to fix the bug
+    * we don't enable more than 1 binary format for compatibility profiles.
+    * This is only being done on the 18.0 release branch.
+    */
+   if (api != API_OPENGL_COMPAT &&
+       screen->get_disk_shader_cache && screen->get_disk_shader_cache(screen))
       c->NumProgramBinaryFormats = 1;
 
    c->MaxAtomicBufferBindings =
           c->Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers;
 
    if (!ssbo_atomic) {
       /* for separate atomic buffers - there atomic buffer size will be
          limited */
       c->MaxAtomicBufferSize = c->Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters * ATOMIC_COUNTER_SIZE;
       /* on all HW with separate atomic (evergreen) the following
diff --git a/src/mesa/state_tracker/st_extensions.h b/src/mesa/state_tracker/st_extensions.h
index 7bf1aa8..fdfac7e 100644
--- a/src/mesa/state_tracker/st_extensions.h
+++ b/src/mesa/state_tracker/st_extensions.h
@@ -28,20 +28,21 @@
 
 #ifndef ST_EXTENSIONS_H
 #define ST_EXTENSIONS_H
 
 
 struct st_context;
 struct pipe_screen;
 
 extern void st_init_limits(struct pipe_screen *screen,
                            struct gl_constants *c,
-                           struct gl_extensions *extensions);
+                           struct gl_extensions *extensions,
+                           gl_api api);
 
 extern void st_init_extensions(struct pipe_screen *screen,
                                struct gl_constants *consts,
                                struct gl_extensions *extensions,
                                struct st_config_options *options,
                                gl_api api);
 
 
 #endif /* ST_EXTENSIONS_H */
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index d6aa3e7..d6901c9 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -1200,21 +1200,21 @@ get_version(struct pipe_screen *screen,
    struct gl_extensions extensions = {0};
    GLuint version;
 
    if (_mesa_override_gl_version_contextless(&consts, &api, &version)) {
       return version;
    }
 
    _mesa_init_constants(&consts, api);
    _mesa_init_extensions(&extensions);
 
-   st_init_limits(screen, &consts, &extensions);
+   st_init_limits(screen, &consts, &extensions, api);
    st_init_extensions(screen, &consts, &extensions, options, api);
 
    return _mesa_get_version(&extensions, &consts, api);
 }
 
 
 static void
 st_api_query_versions(struct st_api *stapi, struct st_manager *sm,
                       struct st_config_options *options,
                       int *gl_core_version,
-- 
2.7.4



More information about the mesa-dev mailing list