driconf: add option to reuse GL names
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Mon, 17 Aug 2020 14:20:17 +0000 (16:20 +0200)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Thu, 10 Sep 2020 07:09:34 +0000 (09:09 +0200)
Fix apps expecting name recycling.
https://gitlab.freedesktop.org/mesa/mesa/-/issues/3144 is an example
of such issue, SPECviewperf13 has this problem too.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6600>

src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
src/gallium/frontends/dri/dri_screen.c
src/gallium/include/frontend/api.h
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_extensions.c
src/util/00-mesa-defaults.conf
src/util/driconf.h

index 9246f24..d7872b1 100644 (file)
@@ -34,6 +34,7 @@ DRI_CONF_SECTION_DEBUG
    DRI_CONF_ALLOW_GLSL_LAYOUT_QUALIFIER_ON_FUNCTION_PARAMETERS("false")
    DRI_CONF_ALLOW_DRAW_OUT_OF_ORDER("false")
    DRI_CONF_FORCE_COMPAT_PROFILE("false")
+   DRI_CONF_FORCE_GL_NAMES_REUSE("false")
    DRI_CONF_FORCE_GL_VENDOR()
    DRI_CONF_OVERRIDE_VRAM_SIZE()
 DRI_CONF_SECTION_END
index e3bda00..bcdd96b 100644 (file)
@@ -98,6 +98,8 @@ dri_fill_st_options(struct dri_screen *screen)
       driQueryOptionb(optionCache, "allow_glsl_layout_qualifier_on_function_parameters");
    options->allow_draw_out_of_order =
       driQueryOptionb(optionCache, "allow_draw_out_of_order");
+   options->force_gl_names_reuse =
+      driQueryOptionb(optionCache, "force_gl_names_reuse");
 
    char *vendor_str = driQueryOptionstr(optionCache, "force_gl_vendor");
    /* not an empty string */
index effc2cd..9dcabe0 100644 (file)
@@ -233,6 +233,7 @@ struct st_config_options
    bool allow_glsl_layout_qualifier_on_function_parameters;
    bool allow_draw_out_of_order;
    bool force_integer_tex_nearest;
+   bool force_gl_names_reuse;
    char *force_gl_vendor;
    unsigned char config_options_sha1[20];
 };
index 5fb526f..80dff85 100644 (file)
@@ -3891,6 +3891,11 @@ struct gl_constants
    GLchar GLSLZeroInit;
 
    /**
+    * Force GL names reuse. Needed by SPECviewperf13.
+    */
+   GLboolean ForceGLNamesReuse;
+
+   /**
     * Treat integer textures using GL_LINEAR filters as GL_NEAREST.
     */
    GLboolean ForceIntegerTexNearest;
index aaaa615..271c18c 100644 (file)
@@ -815,6 +815,17 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
 
    st->bitmap.cache.empty = true;
 
+   if (ctx->Const.ForceGLNamesReuse && ctx->Shared->RefCount == 1) {
+      _mesa_HashEnableNameReuse(ctx->Shared->TexObjects);
+      _mesa_HashEnableNameReuse(ctx->Shared->ShaderObjects);
+      _mesa_HashEnableNameReuse(ctx->Shared->BufferObjects);
+      _mesa_HashEnableNameReuse(ctx->Shared->SamplerObjects);
+      _mesa_HashEnableNameReuse(ctx->Shared->FrameBuffers);
+      _mesa_HashEnableNameReuse(ctx->Shared->RenderBuffers);
+      _mesa_HashEnableNameReuse(ctx->Shared->MemoryObjects);
+      _mesa_HashEnableNameReuse(ctx->Shared->SemaphoreObjects);
+   }
+
    _mesa_override_extensions(ctx);
    _mesa_compute_version(ctx);
 
index f5443b0..1278ef1 100644 (file)
@@ -1221,6 +1221,8 @@ void st_init_extensions(struct pipe_screen *screen,
       consts->GLSLZeroInit = screen->get_param(screen, PIPE_CAP_GLSL_ZERO_INIT);
    }
 
+   consts->ForceGLNamesReuse = options->force_gl_names_reuse;
+
    consts->ForceIntegerTexNearest = options->force_integer_tex_nearest;
 
    consts->VendorOverride = options->force_gl_vendor;
index c569903..ce0a633 100644 (file)
@@ -286,6 +286,7 @@ TODO: document the other workarounds.
         <application name="SPECviewperf13" executable="viewperf">
             <option name="allow_glsl_extension_directive_midshader" value="true" />
             <option name="allow_glsl_120_subset_in_110" value="true" />
+            <option name="force_gl_names_reuse" value="true" />
         </application>
 
         <!-- The GL thread allowlist is below, workarounds are above.
index 7559aa7..12bfadb 100644 (file)
@@ -227,6 +227,11 @@ DRI_CONF_OPT_BEGIN_V(override_vram_size, int, -1, "-1:2147483647") \
         DRI_CONF_DESC("Override the VRAM size advertised to the application in MiB (-1 = default)") \
 DRI_CONF_OPT_END
 
+#define DRI_CONF_FORCE_GL_NAMES_REUSE(def) \
+DRI_CONF_OPT_BEGIN_B(force_gl_names_reuse, def) \
+        DRI_CONF_DESC("Force GL names reuse") \
+DRI_CONF_OPT_END
+
 /**
  * \brief Image quality-related options
  */