struct gl_program_parameter_list;
struct gl_shader_spirv_data;
struct set;
+struct shader_includes;
struct vbo_context;
/*@}*/
struct hash_table_u64 *ImageHandles;
mtx_t HandlesMutex; /**< For texture/image handles safety */
+ /* GL_ARB_shading_language_include */
+ struct shader_includes *ShaderIncludes;
+ /* glCompileShaderInclude expects ShaderIncludes not to change while it is
+ * in progress.
+ */
+ mtx_t ShaderIncludeMutex;
+
/**
* Some context in this share group was affected by a GPU reset
*
}
}
+/* This is simple list entry that will be used to hold a list of string
+ * tokens of a parsed shader include path.
+ */
+struct sh_incl_path_entry
+{
+ struct sh_incl_path_entry *next;
+ struct sh_incl_path_entry *prev;
+
+ char *path;
+};
+
+/* Nodes of the shader include tree */
+struct sh_incl_path_ht_entry
+{
+ struct hash_table *path;
+ char *shader_source;
+};
+
+struct shader_includes {
+ /* Array to hold include paths given to glCompileShaderIncludeARB() */
+ struct sh_incl_path_entry **include_paths;
+ size_t num_include_paths;
+
+ /* Root hash table holding the shader include tree */
+ struct hash_table *shader_include_tree;
+};
+
+void
+_mesa_init_shader_includes(struct gl_shared_state *shared)
+{
+ shared->ShaderIncludes = calloc(1, sizeof(struct shader_includes));
+ shared->ShaderIncludes->shader_include_tree =
+ _mesa_hash_table_create(NULL, _mesa_hash_string,
+ _mesa_key_string_equal);
+}
+
+static void
+destroy_shader_include(struct hash_entry *entry)
+{
+ struct sh_incl_path_ht_entry *sh_incl_ht_entry =
+ (struct sh_incl_path_ht_entry *) entry->data;
+
+ _mesa_hash_table_destroy(sh_incl_ht_entry->path, destroy_shader_include);
+ free(sh_incl_ht_entry->shader_source);
+ free(sh_incl_ht_entry);
+}
+
+void
+_mesa_destroy_shader_includes(struct gl_shared_state *shared)
+{
+ _mesa_hash_table_destroy(shared->ShaderIncludes->shader_include_tree,
+ destroy_shader_include);
+ free(shared->ShaderIncludes);
+}
+
GLvoid GLAPIENTRY
_mesa_NamedStringARB(GLenum type, GLint namelen, const GLchar *name,
GLint stringlen, const GLchar *string)
/* GL_ARB_bindless_texture */
_mesa_init_shared_handles(shared);
+ /* ARB_shading_language_include */
+ _mesa_init_shader_includes(shared);
+ mtx_init(&shared->ShaderIncludeMutex, mtx_plain);
+
/* Allocate the default buffer object */
shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0);
if (!shared->NullBufferObj)
_mesa_free_shared_handles(shared);
+ /* ARB_shading_language_include */
+ _mesa_destroy_shader_includes(shared);
+ mtx_destroy(&shared->ShaderIncludeMutex);
+
if (shared->MemoryObjects) {
_mesa_HashDeleteAll(shared->MemoryObjects, delete_memory_object_cb, ctx);
_mesa_DeleteHashTable(shared->MemoryObjects);