[Chore] (MG_State/ProgramState): some renames

This commit is contained in:
2026-03-26 09:49:05 +08:00
parent accfaab720
commit a039ce0987
4 changed files with 12 additions and 15 deletions
@@ -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()) {
@@ -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<Uint>(m_uboScratch.size()); }
void* MapUBO() { return m_globalUboScratch.data(); }
const void* GetUBOData() const { return m_globalUboScratch.data(); }
Uint GetUBOSize() const { return static_cast<Uint>(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<String, Uint>& GetAttribLocationMap() const { return
// m_attribLocation; }
private:
void DoReflection();
void GenerateBinary();
@@ -142,8 +139,6 @@ namespace MobileGL::MG_State::GLState {
UnorderedMap<String, Uint> m_explicitAttribLocations;
Vector<String> m_attribs;
Vector<GLenum> m_attribTypes;
// For SpvcSession::SetVertexAttribLocation()
// UnorderedMap<String, Uint> m_attribLocation;
// FragData (Frag out)
UnorderedMap<String, Uint> 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<String, Uint> m_uniformBlockIndexByName;
Vector<Int> m_uniformBlockBinding;
// Need to be reflected after linking of SPIR-V binary
Vector<Uint> m_uniformOffsets;
Vector<Uint> m_uniformSizesInBytes;
Vector<Uint8> m_uboScratch;
Vector<Uint8> m_globalUboScratch;
Uint m_activeUniformCount = 0;
Uint m_maxUniformLocation = 0;
@@ -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);
@@ -59,7 +59,7 @@ namespace MobileGL {
UnorderedMap<String, unsigned> plainUniformOffsetsInUBO;
UnorderedMap<String, SizeT> plainUniformMemberSizesInBytes;
UnorderedMap<String, SpvcType> plainUniformMemberTypes;
SizeT uboSize = 0;
SizeT globalUboSize = 0;
};
class SpvcSession {