diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp index 11e5ed62..877cf5cc 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp @@ -473,16 +473,16 @@ namespace MobileGL::MG_State::GLState { (result == SPVC_ERROR_INVALID_SPIRV ? ". Probably no global UBO?" : "")); m_uniformSizesInBytes.clear(); m_uniformOffsets.clear(); - m_uboScratch.clear(); + m_globalUboScratch.clear(); continue; } else { auto& meta = session.GetMetadata(); - auto size = meta.uboSize; + auto size = meta.globalUboSize; MGLOG_D("ProgramObject %u: GenerateBinary - SPIR-V meta: uboSize=%zu plainUniformCount=%zu " "plainUniformOffsets=%zu", - m_externalIndex, meta.uboSize, meta.plainUniformMemberSizesInBytes.size(), + m_externalIndex, meta.globalUboSize, meta.plainUniformMemberSizesInBytes.size(), meta.plainUniformOffsetsInUBO.size()); - m_uboScratch.resize(size); + m_globalUboScratch.resize(size); m_uniformOffsets.resize(m_maxUniformLocation + 1); for (const auto& [name, offset] : meta.plainUniformOffsetsInUBO) { if (m_uniformLocations.find(name) != m_uniformLocations.end()) { diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h index 2a97f653..26f22bd9 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h @@ -65,9 +65,9 @@ namespace MobileGL::MG_State::GLState { } GLenum GetAttribType(Uint index) const { return m_attribTypes[index]; } const String& GetAttribName(Uint index) const { return m_attribs[index]; } - void* MapUBO() { return m_uboScratch.data(); } - const void* GetUBOData() const { return m_uboScratch.data(); } - Uint GetUBOSize() const { return static_cast(m_uboScratch.size()); } + void* MapUBO() { return m_globalUboScratch.data(); } + const void* GetUBOData() const { return m_globalUboScratch.data(); } + Uint GetUBOSize() const { return static_cast(m_globalUboScratch.size()); } void SetUniformSamplerOrImageUnitIndex(Uint location, Int unit) { m_uniformSamplerOrImageUnitIndex[location] = unit; @@ -121,9 +121,6 @@ namespace MobileGL::MG_State::GLState { Uint GetExternalIndex() const { return m_externalIndex; } - // const UnorderedMap& GetAttribLocationMap() const { return - // m_attribLocation; } - private: void DoReflection(); void GenerateBinary(); @@ -142,8 +139,6 @@ namespace MobileGL::MG_State::GLState { UnorderedMap m_explicitAttribLocations; Vector m_attribs; Vector m_attribTypes; - // For SpvcSession::SetVertexAttribLocation() - // UnorderedMap m_attribLocation; // FragData (Frag out) UnorderedMap m_explicitFragDataLocation; @@ -162,13 +157,15 @@ namespace MobileGL::MG_State::GLState { // Let's define UniformBlockIndex == the order at glslang getUniformBlock() // aka `i = glGetUniformBlockIndex(prog, "BlockName")` implies: // `prog->getUniformBlock(i) == "BlockName"` + // These stuff are present for GL semantics, not for backend inspection + // These may change after-link (because GL spec decided to have `glUniformBlockBinding`) UnorderedMap m_uniformBlockIndexByName; Vector m_uniformBlockBinding; // Need to be reflected after linking of SPIR-V binary Vector m_uniformOffsets; Vector m_uniformSizesInBytes; - Vector m_uboScratch; + Vector m_globalUboScratch; Uint m_activeUniformCount = 0; Uint m_maxUniformLocation = 0; diff --git a/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp b/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp index 6caa19ad..5b27265e 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp +++ b/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp @@ -112,7 +112,7 @@ namespace MobileGL { if (strcmp(list[i].name, GLOBAL_UBO_NAME) == 0) { spvc_type type = spvc_compiler_get_type_handle(compiler, list[i].base_type_id); - spvc_compiler_get_declared_struct_size(compiler, type, &metadata.uboSize); + spvc_compiler_get_declared_struct_size(compiler, type, &metadata.globalUboSize); size_t num_members = spvc_type_get_num_member_types(type); for (size_t j = 0; j < num_members; ++j) { const char* memberName = spvc_compiler_get_member_name(compiler, list[i].base_type_id, j); diff --git a/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.h b/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.h index a552b291..7696c8b2 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.h +++ b/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.h @@ -59,7 +59,7 @@ namespace MobileGL { UnorderedMap plainUniformOffsetsInUBO; UnorderedMap plainUniformMemberSizesInBytes; UnorderedMap plainUniformMemberTypes; - SizeT uboSize = 0; + SizeT globalUboSize = 0; }; class SpvcSession {