diff options
author | Timothy Arceri <[email protected]> | 2019-08-23 14:36:53 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2019-11-20 05:05:55 +0000 |
commit | 8acab84f9322118ef18bb2686150d45d40b64ec6 (patch) | |
tree | ae54df327a1c02f083ab0696a0f35f69ea762f0f /src/mesa/main/shaderapi.c | |
parent | 643a533fc277d67d7267bb480b96f521a7bd249a (diff) |
mesa: add _mesa_lookup_shader_include() helper
This will be used both by the glsl compiler and the GL API.
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 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index c7f5ac797e7..7fe3d0d0a0e 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -3275,6 +3275,40 @@ validate_and_tokenise_sh_incl(struct gl_context *ctx, return true; } +const char * +_mesa_lookup_shader_include(struct gl_context *ctx, char *path) +{ + void *mem_ctx = ralloc_context(NULL); + struct sh_incl_path_entry *path_list; + + if (!validate_and_tokenise_sh_incl(ctx, mem_ctx, &path_list, path)) { + ralloc_free(mem_ctx); + return NULL; + } + + struct sh_incl_path_ht_entry *sh_incl_ht_entry = NULL; + struct hash_table *path_ht = + ctx->Shared->ShaderIncludes->shader_include_tree; + + struct sh_incl_path_entry *entry; + foreach(entry, path_list) { + struct hash_entry *ht_entry = + _mesa_hash_table_search(path_ht, entry->path); + + if (!ht_entry) { + return NULL; + } else { + sh_incl_ht_entry = (struct sh_incl_path_ht_entry *) ht_entry->data; + } + + path_ht = sh_incl_ht_entry->path; + } + + ralloc_free(mem_ctx); + + return sh_incl_ht_entry ? sh_incl_ht_entry->shader_source : NULL; +} + GLvoid GLAPIENTRY _mesa_NamedStringARB(GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string) |