So it could be used by the GLSL and NIR linker. --- src/compiler/glsl/linker.cpp | 36 ------------------------------------ src/compiler/linker_util.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/compiler/linker_util.h | 5 +++++ 3 files changed, 42 insertions(+), 36 deletions(-)
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 09488cbd4d2..4371fc071d6 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -3586,42 +3586,6 @@ should_add_buffer_variable(struct gl_shader_program *shProg, return false; } -static bool -add_program_resource(struct gl_shader_program *prog, - struct set *resource_set, - GLenum type, const void *data, uint8_t stages) -{ - assert(data); - - /* If resource already exists, do not add it again. */ - if (_mesa_set_search(resource_set, data)) - return true; - - prog->data->ProgramResourceList = - reralloc(prog->data, - prog->data->ProgramResourceList, - gl_program_resource, - prog->data->NumProgramResourceList + 1); - - if (!prog->data->ProgramResourceList) { - linker_error(prog, "Out of memory during linking.\n"); - return false; - } - - struct gl_program_resource *res = - &prog->data->ProgramResourceList[prog->data->NumProgramResourceList]; - - res->Type = type; - res->Data = data; - res->StageReferences = stages; - - prog->data->NumProgramResourceList++; - - _mesa_set_add(resource_set, data); - - return true; -} - /* Function checks if a variable var is a packed varying and * if given name is part of packed varying's list. * diff --git a/src/compiler/linker_util.cpp b/src/compiler/linker_util.cpp index c7d26616245..c47e4dc75da 100644 --- a/src/compiler/linker_util.cpp +++ b/src/compiler/linker_util.cpp @@ -23,6 +23,7 @@ */ #include "main/mtypes.h" #include "linker_util.h" +#include "util/set.h" void linker_error(struct gl_shader_program *prog, const char *fmt, ...) @@ -49,3 +50,39 @@ linker_warning(struct gl_shader_program *prog, const char *fmt, ...) va_end(ap); } + +bool +add_program_resource(struct gl_shader_program *prog, + struct set *resource_set, + GLenum type, const void *data, uint8_t stages) +{ + assert(data); + + /* If resource already exists, do not add it again. */ + if (_mesa_set_search(resource_set, data)) + return true; + + prog->data->ProgramResourceList = + reralloc(prog->data, + prog->data->ProgramResourceList, + gl_program_resource, + prog->data->NumProgramResourceList + 1); + + if (!prog->data->ProgramResourceList) { + linker_error(prog, "Out of memory during linking.\n"); + return false; + } + + struct gl_program_resource *res = + &prog->data->ProgramResourceList[prog->data->NumProgramResourceList]; + + res->Type = type; + res->Data = data; + res->StageReferences = stages; + + prog->data->NumProgramResourceList++; + + _mesa_set_add(resource_set, data); + + return true; +} diff --git a/src/compiler/linker_util.h b/src/compiler/linker_util.h index 162db3e532f..8fc1785a041 100644 --- a/src/compiler/linker_util.h +++ b/src/compiler/linker_util.h @@ -36,6 +36,11 @@ linker_error(struct gl_shader_program *prog, const char *fmt, ...); void linker_warning(struct gl_shader_program *prog, const char *fmt, ...); +bool +add_program_resource(struct gl_shader_program *prog, + struct set *resource_set, + GLenum type, const void *data, uint8_t stages); + #ifdef __cplusplus } #endif -- 2.14.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev