diff options
author | Timothy Arceri <[email protected]> | 2019-08-15 14:34:39 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2019-11-20 05:05:55 +0000 |
commit | 06f33d82caffa71d40eb0189967b3183f0ff2eed (patch) | |
tree | ddffe57ff672fbac38aa3616a14be8bc7780296a /src/mesa/main/shaderapi.c | |
parent | 35108caa71d4da02303335ee52a0833fe650d85a (diff) |
mesa: add ARB_shading_language_include infrastructure to gl_shared_state
Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Witold Baryluk <[email protected]>
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r-- | src/mesa/main/shaderapi.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 7781609bc57..760d046dcde 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -3138,6 +3138,61 @@ _mesa_GetProgramStageiv(GLuint program, GLenum shadertype, } } +/* 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) |