From: Mikko Rasa Date: Sun, 7 Nov 2021 17:07:34 +0000 (+0200) Subject: Rearrange shader reflection calls X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0757f7d3e514836ca85954708c41a1accac0574b;p=libs%2Fgl.git Rearrange shader reflection calls The OpenGL-specific query calls are now done from the OpenGL backend. --- diff --git a/source/backends/opengl/program_backend.cpp b/source/backends/opengl/program_backend.cpp index 76781180..d78a5b42 100644 --- a/source/backends/opengl/program_backend.cpp +++ b/source/backends/opengl/program_backend.cpp @@ -211,7 +211,7 @@ void OpenGLProgram::add_spirv_stages(const SpirVModule &mod, const mapname.c_str(), spec_id_array.size(), &spec_id_array[0], &spec_value_array[0]); } -void OpenGLProgram::finalize(const Module &mod) +void OpenGLProgram::finalize(const Module &mod, TransientData &transient) { glLinkProgram(id); int status = 0; @@ -232,6 +232,13 @@ void OpenGLProgram::finalize(const Module &mod) if(!info_log.empty()) IO::print("Program link info log:\n%s", info_log); #endif + + if(mod.get_format()==Module::GLSL) + { + query_uniforms(); + query_attributes(); + apply_bindings(transient); + } } void OpenGLProgram::query_uniforms() diff --git a/source/backends/opengl/program_backend.h b/source/backends/opengl/program_backend.h index 95df9891..8fa68102 100644 --- a/source/backends/opengl/program_backend.h +++ b/source/backends/opengl/program_backend.h @@ -55,7 +55,7 @@ protected: void compile_glsl_stage(const GlslModule &, unsigned); void add_spirv_stages(const SpirVModule &, const std::map &, TransientData &); - void finalize(const Module &); + void finalize(const Module &, TransientData &); void query_uniforms(); void query_uniform_blocks(const std::vector &); void query_attributes(); diff --git a/source/core/program.cpp b/source/core/program.cpp index 1a7ac17b..6013e7e8 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -32,15 +32,9 @@ void Program::add_stages(const Module &mod, const map &spec_values) throw invalid_argument("Program::add_stages"); } - finalize(mod); + finalize(mod, transient); - if(mod.get_format()==Module::GLSL) - { - query_uniforms(); - query_attributes(); - apply_bindings(transient); - } - else if(mod.get_format()==Module::SPIR_V) + if(mod.get_format()==Module::SPIR_V) { collect_uniforms(static_cast(mod), transient.spec_values); collect_attributes(static_cast(mod));