diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index 3b0ab726e8f..1175995e6c1 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -41,7 +41,7 @@ DRI_CONF_SECTION_DEBUG
DRI_CONF_GLTHREAD_NOP_CHECK_FRAMEBUFFER_STATUS(false)
DRI_CONF_FORCE_COMPAT_PROFILE(false)
DRI_CONF_FORCE_COMPAT_SHADERS(false)
- DRI_CONF_FORCE_GL_NAMES_REUSE(false)
+ DRI_CONF_FORCE_GL_NAMES_REUSE()
DRI_CONF_FORCE_GL_MAP_BUFFER_SYNCHRONIZED(false)
DRI_CONF_TRANSCODE_ETC(false)
DRI_CONF_TRANSCODE_ASTC(false)
diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c
index 5be5e9d17dc..ef6ae1c2ed8 100644
--- a/src/gallium/auxiliary/util/u_driconf.c
+++ b/src/gallium/auxiliary/util/u_driconf.c
@@ -67,7 +67,7 @@ u_driconf_fill_st_options(struct st_config_options *options,
query_bool_option(glthread_nop_check_framebuffer_status);
query_bool_option(ignore_map_unsynchronized);
query_bool_option(ignore_discard_framebuffer);
- query_bool_option(force_gl_names_reuse);
+ query_int_option(reuse_gl_names);
query_bool_option(force_gl_map_buffer_synchronized);
query_bool_option(transcode_etc);
query_bool_option(transcode_astc);
diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h
index 25d6b39a67c..26712fe7180 100644
--- a/src/gallium/include/frontend/api.h
+++ b/src/gallium/include/frontend/api.h
@@ -196,7 +196,7 @@ struct st_config_options
bool ignore_map_unsynchronized;
bool ignore_discard_framebuffer;
bool force_integer_tex_nearest;
- bool force_gl_names_reuse;
+ int reuse_gl_names;
bool force_gl_map_buffer_synchronized;
bool transcode_etc;
bool transcode_astc;
diff --git a/src/mesa/main/consts_exts.h b/src/mesa/main/consts_exts.h
index 84af77a7a6d..f11824c512b 100644
--- a/src/mesa/main/consts_exts.h
+++ b/src/mesa/main/consts_exts.h
@@ -666,11 +666,6 @@ struct gl_constants
*/
GLchar GLSLZeroInit;
- /**
- * Force GL names reuse. Needed by SPECviewperf13.
- */
- GLboolean ForceGLNamesReuse;
-
/**
* Treat integer textures using GL_LINEAR filters as GL_NEAREST.
*/
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index e95e371ccff..31e1a6e5ae2 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -976,7 +976,8 @@ _mesa_initialize_context(struct gl_context *ctx,
bool no_error,
const struct gl_config *visual,
struct gl_context *share_list,
- const struct dd_function_table *driverFunctions)
+ const struct dd_function_table *driverFunctions,
+ const struct st_config_options *options)
{
struct gl_shared_state *shared;
int i;
@@ -1032,7 +1033,7 @@ _mesa_initialize_context(struct gl_context *ctx,
}
else {
/* allocate new, unshared state */
- shared = _mesa_alloc_shared_state(ctx);
+ shared = _mesa_alloc_shared_state(ctx, options);
if (!shared)
return GL_FALSE;
}
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 21eda32cf4b..6d68b064789 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -76,7 +76,8 @@ _mesa_initialize_context( struct gl_context *ctx,
bool no_error,
const struct gl_config *visual,
struct gl_context *share_list,
- const struct dd_function_table *driverFunctions);
+ const struct dd_function_table *driverFunctions,
+ const struct st_config_options *options);
extern struct _glapi_table *
_mesa_alloc_dispatch_table(bool glthread);
diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index 45ad84a1eb8..f1daa65b583 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -223,7 +223,7 @@ _mesa_glthread_init(struct gl_context *ctx)
return;
}
- _mesa_InitHashTable(&glthread->VAOs);
+ _mesa_InitHashTable(&glthread->VAOs, ctx->Shared->ReuseGLNames);
_mesa_glthread_reset_vao(&glthread->DefaultVAO);
glthread->CurrentVAO = &glthread->DefaultVAO;
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
index ef6df6eb63c..fa24d337068 100644
--- a/src/mesa/main/hash.c
+++ b/src/mesa/main/hash.c
@@ -45,7 +45,7 @@
* Initialize a hash table.
*/
void
-_mesa_InitHashTable(struct _mesa_HashTable *table)
+_mesa_InitHashTable(struct _mesa_HashTable *table, bool enable_reuse)
{
memset(table, 0, sizeof(*table));
util_sparse_array_init(&table->array, sizeof(void*), 1024);
@@ -53,6 +53,7 @@ _mesa_InitHashTable(struct _mesa_HashTable *table)
/* Mark ID = 0 as used, so that we don't return it. */
util_idalloc_sparse_reserve(&table->id_alloc, 0);
simple_mtx_init(&table->Mutex, mtx_plain);
+ table->alloc_via_idalloc = enable_reuse;
}
/**
@@ -86,14 +87,6 @@ _mesa_DeinitHashTable(struct _mesa_HashTable *table,
simple_mtx_destroy(&table->Mutex);
}
-void
-_mesa_HashEnableNameReuse(struct _mesa_HashTable *table)
-{
- _mesa_HashLockMutex(table);
- table->alloc_via_idalloc = true;
- _mesa_HashUnlockMutex(table);
-}
-
/**
* Insert a key/pointer pair into the hash table without locking the mutex.
* If an entry with this key already exists we'll replace the existing entry.
diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h
index f9f0afeeb3f..265d40bd28a 100644
--- a/src/mesa/main/hash.h
+++ b/src/mesa/main/hash.h
@@ -54,7 +54,7 @@ struct _mesa_HashTable {
};
void
-_mesa_InitHashTable(struct _mesa_HashTable *table);
+_mesa_InitHashTable(struct _mesa_HashTable *table, bool enable_reuse);
void
_mesa_DeinitHashTable(struct _mesa_HashTable *table,
@@ -90,9 +90,6 @@ bool
_mesa_HashFindFreeKeys(struct _mesa_HashTable *table, GLuint* keys,
GLuint numKeys);
-void
-_mesa_HashEnableNameReuse(struct _mesa_HashTable *table);
-
/* Inline functions. */
/**
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 89d55c4ef3d..52a3c36451a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2392,6 +2392,9 @@ struct gl_shared_state
GLint RefCount; /**< Reference count */
bool DisplayListsAffectGLThread;
+ /* Whether the next glGen returns the lowest unused GL ID. */
+ bool ReuseGLNames;
+
struct _mesa_HashTable DisplayList; /**< Display lists hash table */
struct _mesa_HashTable TexObjects; /**< Texture objects hash table */
diff --git a/src/mesa/main/performance_monitor.c b/src/mesa/main/performance_monitor.c
index c184a8bd165..64fa8ad0802 100644
--- a/src/mesa/main/performance_monitor.c
+++ b/src/mesa/main/performance_monitor.c
@@ -57,7 +57,7 @@
void
_mesa_init_performance_monitors(struct gl_context *ctx)
{
- _mesa_InitHashTable(&ctx->PerfMonitor.Monitors);
+ _mesa_InitHashTable(&ctx->PerfMonitor.Monitors, ctx->Shared->ReuseGLNames);
ctx->PerfMonitor.NumGroups = 0;
ctx->PerfMonitor.Groups = NULL;
}
diff --git a/src/mesa/main/performance_query.c b/src/mesa/main/performance_query.c
index a5e2ef25f02..a4efb62a1c5 100644
--- a/src/mesa/main/performance_query.c
+++ b/src/mesa/main/performance_query.c
@@ -44,7 +44,7 @@
void
_mesa_init_performance_queries(struct gl_context *ctx)
{
- _mesa_InitHashTable(&ctx->PerfQuery.Objects);
+ _mesa_InitHashTable(&ctx->PerfQuery.Objects, ctx->Shared->ReuseGLNames);
}
static void
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 8ab83fc72f1..b7e28de3581 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -93,7 +93,7 @@ _mesa_new_pipeline_object(struct gl_context *ctx, GLuint name)
void
_mesa_init_pipeline(struct gl_context *ctx)
{
- _mesa_InitHashTable(&ctx->Pipeline.Objects);
+ _mesa_InitHashTable(&ctx->Pipeline.Objects, ctx->Shared->ReuseGLNames);
ctx->Pipeline.Current = NULL;
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index 31830cf5a70..6e631fa2c8f 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -1342,7 +1342,7 @@ _mesa_init_queryobj(struct gl_context *ctx)
{
struct pipe_screen *screen = ctx->pipe->screen;
- _mesa_InitHashTable(&ctx->Query.QueryObjects);
+ _mesa_InitHashTable(&ctx->Query.QueryObjects, ctx->Shared->ReuseGLNames);
ctx->Query.CurrentOcclusionObject = NULL;
if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY))
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 41e05ed56b9..16eb5dbe083 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -60,7 +60,8 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared);
* failure.
*/
struct gl_shared_state *
-_mesa_alloc_shared_state(struct gl_context *ctx)
+_mesa_alloc_shared_state(struct gl_context *ctx,
+ const struct st_config_options *options)
{
struct gl_shared_state *shared;
GLuint i;
@@ -70,27 +71,28 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
return NULL;
simple_mtx_init(&shared->Mutex, mtx_plain);
+ shared->ReuseGLNames = options->reuse_gl_names == 1;
- _mesa_InitHashTable(&shared->DisplayList);
- _mesa_InitHashTable(&shared->TexObjects);
- _mesa_InitHashTable(&shared->Programs);
+ _mesa_InitHashTable(&shared->DisplayList, shared->ReuseGLNames);
+ _mesa_InitHashTable(&shared->TexObjects, shared->ReuseGLNames);
+ _mesa_InitHashTable(&shared->Programs, shared->ReuseGLNames);
shared->DefaultVertexProgram =
ctx->Driver.NewProgram(ctx, MESA_SHADER_VERTEX, 0, true);
shared->DefaultFragmentProgram =
ctx->Driver.NewProgram(ctx, MESA_SHADER_FRAGMENT, 0, true);
- _mesa_InitHashTable(&shared->ATIShaders);
+ _mesa_InitHashTable(&shared->ATIShaders, shared->ReuseGLNames);
shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0);
- _mesa_InitHashTable(&shared->ShaderObjects);
+ _mesa_InitHashTable(&shared->ShaderObjects, shared->ReuseGLNames);
- _mesa_InitHashTable(&shared->BufferObjects);
+ _mesa_InitHashTable(&shared->BufferObjects, shared->ReuseGLNames);
shared->ZombieBufferObjects = _mesa_set_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
/* GL_ARB_sampler_objects */
- _mesa_InitHashTable(&shared->SamplerObjects);
+ _mesa_InitHashTable(&shared->SamplerObjects, shared->ReuseGLNames);
/* GL_ARB_bindless_texture */
_mesa_init_shared_handles(shared);
@@ -132,14 +134,14 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
simple_mtx_init(&shared->TexMutex, mtx_plain);
shared->TextureStateStamp = 0;
- _mesa_InitHashTable(&shared->FrameBuffers);
- _mesa_InitHashTable(&shared->RenderBuffers);
+ _mesa_InitHashTable(&shared->FrameBuffers, shared->ReuseGLNames);
+ _mesa_InitHashTable(&shared->RenderBuffers, shared->ReuseGLNames);
shared->SyncObjects = _mesa_set_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
- _mesa_InitHashTable(&shared->MemoryObjects);
- _mesa_InitHashTable(&shared->SemaphoreObjects);
+ _mesa_InitHashTable(&shared->MemoryObjects, shared->ReuseGLNames);
+ _mesa_InitHashTable(&shared->SemaphoreObjects, shared->ReuseGLNames);
shared->GLThread.NoLockDuration = ONE_SECOND_IN_NS;
diff --git a/src/mesa/main/shared.h b/src/mesa/main/shared.h
index ce9d90ddd6e..e942567f0c7 100644
--- a/src/mesa/main/shared.h
+++ b/src/mesa/main/shared.h
@@ -34,7 +34,8 @@ _mesa_reference_shared_state(struct gl_context *ctx,
struct gl_shared_state *
-_mesa_alloc_shared_state(struct gl_context *ctx);
+_mesa_alloc_shared_state(struct gl_context *ctx,
+ const struct st_config_options *options);
#endif
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index bc1c25f9e8a..ecb6168a628 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -182,7 +182,7 @@ _mesa_init_transform_feedback(struct gl_context *ctx)
assert(ctx->TransformFeedback.DefaultObject->RefCount == 2);
- _mesa_InitHashTable(&ctx->TransformFeedback.Objects);
+ _mesa_InitHashTable(&ctx->TransformFeedback.Objects, ctx->Shared->ReuseGLNames);
_mesa_reference_buffer_object(ctx,
&ctx->TransformFeedback.CurrentBuffer, NULL);
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index d9365616eb9..9b883e30785 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -4169,7 +4169,7 @@ _mesa_init_varray(struct gl_context *ctx)
_mesa_set_draw_vao(ctx, ctx->Array.VAO);
ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
- _mesa_InitHashTable(&ctx->Array.Objects);
+ _mesa_InitHashTable(&ctx->Array.Objects, ctx->Shared->ReuseGLNames);
}
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index f6641bb1736..22a4b8e963c 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -725,24 +725,6 @@ 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);
- }
- /* SPECviewperf13/sw-04 crashes since a56849ddda6 if Mesa is build with
- * -O3 on gcc 7.5, which doesn't happen with ForceGLNamesReuse, which is
- * the default setting for SPECviewperf because it simulates glGen behavior
- * of closed source drivers.
- */
- if (ctx->Const.ForceGLNamesReuse)
- _mesa_HashEnableNameReuse(&ctx->Query.QueryObjects);
-
_mesa_override_extensions(ctx);
_mesa_compute_version(ctx);
@@ -844,7 +826,8 @@ st_create_context(gl_api api, struct pipe_context *pipe,
ctx->pipe = pipe;
ctx->screen = pipe->screen;
- if (!_mesa_initialize_context(ctx, api, no_error, visual, shareCtx, &funcs)) {
+ if (!_mesa_initialize_context(ctx, api, no_error, visual, shareCtx, &funcs,
+ options)) {
align_free(ctx);
return NULL;
}
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 9b60ce8a1c2..949082b08b5 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1320,8 +1320,6 @@ 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;
diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index 7b6e9bec501..4950d8dbee7 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -383,7 +383,7 @@ TODO: document the other workarounds.
-
+
@@ -888,7 +888,7 @@ TODO: document the other workarounds.
small enough to fit in the static array).
-->
-
+
diff --git a/src/util/driconf.h b/src/util/driconf.h
index 5191daf7750..e724c1ccff3 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -269,8 +269,8 @@
DRI_CONF_OPT_I(override_vram_size, -1, -1, 2147483647, \
"Override the VRAM size advertised to the application in MiB (-1 = default)")
-#define DRI_CONF_FORCE_GL_NAMES_REUSE(def) \
- DRI_CONF_OPT_B(force_gl_names_reuse, def, "Force GL names reuse")
+#define DRI_CONF_FORCE_GL_NAMES_REUSE() \
+ DRI_CONF_OPT_I(reuse_gl_names, -1, -1, 1, "GL names reuse: 1=enable, 0=disable, -1=default")
#define DRI_CONF_FORCE_GL_MAP_BUFFER_SYNCHRONIZED(def) \
DRI_CONF_OPT_B(force_gl_map_buffer_synchronized, def, "Override GL_MAP_UNSYNCHRONIZED_BIT.")