mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Chore] (MG_State/ProgramState): some renames
This commit is contained in:
@@ -473,16 +473,16 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
(result == SPVC_ERROR_INVALID_SPIRV ? ". Probably no global UBO?" : ""));
|
(result == SPVC_ERROR_INVALID_SPIRV ? ". Probably no global UBO?" : ""));
|
||||||
m_uniformSizesInBytes.clear();
|
m_uniformSizesInBytes.clear();
|
||||||
m_uniformOffsets.clear();
|
m_uniformOffsets.clear();
|
||||||
m_uboScratch.clear();
|
m_globalUboScratch.clear();
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
auto& meta = session.GetMetadata();
|
auto& meta = session.GetMetadata();
|
||||||
auto size = meta.uboSize;
|
auto size = meta.globalUboSize;
|
||||||
MGLOG_D("ProgramObject %u: GenerateBinary - SPIR-V meta: uboSize=%zu plainUniformCount=%zu "
|
MGLOG_D("ProgramObject %u: GenerateBinary - SPIR-V meta: uboSize=%zu plainUniformCount=%zu "
|
||||||
"plainUniformOffsets=%zu",
|
"plainUniformOffsets=%zu",
|
||||||
m_externalIndex, meta.uboSize, meta.plainUniformMemberSizesInBytes.size(),
|
m_externalIndex, meta.globalUboSize, meta.plainUniformMemberSizesInBytes.size(),
|
||||||
meta.plainUniformOffsetsInUBO.size());
|
meta.plainUniformOffsetsInUBO.size());
|
||||||
m_uboScratch.resize(size);
|
m_globalUboScratch.resize(size);
|
||||||
m_uniformOffsets.resize(m_maxUniformLocation + 1);
|
m_uniformOffsets.resize(m_maxUniformLocation + 1);
|
||||||
for (const auto& [name, offset] : meta.plainUniformOffsetsInUBO) {
|
for (const auto& [name, offset] : meta.plainUniformOffsetsInUBO) {
|
||||||
if (m_uniformLocations.find(name) != m_uniformLocations.end()) {
|
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]; }
|
GLenum GetAttribType(Uint index) const { return m_attribTypes[index]; }
|
||||||
const String& GetAttribName(Uint index) const { return m_attribs[index]; }
|
const String& GetAttribName(Uint index) const { return m_attribs[index]; }
|
||||||
void* MapUBO() { return m_uboScratch.data(); }
|
void* MapUBO() { return m_globalUboScratch.data(); }
|
||||||
const void* GetUBOData() const { return m_uboScratch.data(); }
|
const void* GetUBOData() const { return m_globalUboScratch.data(); }
|
||||||
Uint GetUBOSize() const { return static_cast<Uint>(m_uboScratch.size()); }
|
Uint GetUBOSize() const { return static_cast<Uint>(m_globalUboScratch.size()); }
|
||||||
|
|
||||||
void SetUniformSamplerOrImageUnitIndex(Uint location, Int unit) {
|
void SetUniformSamplerOrImageUnitIndex(Uint location, Int unit) {
|
||||||
m_uniformSamplerOrImageUnitIndex[location] = unit;
|
m_uniformSamplerOrImageUnitIndex[location] = unit;
|
||||||
@@ -121,9 +121,6 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
|
|
||||||
Uint GetExternalIndex() const { return m_externalIndex; }
|
Uint GetExternalIndex() const { return m_externalIndex; }
|
||||||
|
|
||||||
// const UnorderedMap<String, Uint>& GetAttribLocationMap() const { return
|
|
||||||
// m_attribLocation; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DoReflection();
|
void DoReflection();
|
||||||
void GenerateBinary();
|
void GenerateBinary();
|
||||||
@@ -142,8 +139,6 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
UnorderedMap<String, Uint> m_explicitAttribLocations;
|
UnorderedMap<String, Uint> m_explicitAttribLocations;
|
||||||
Vector<String> m_attribs;
|
Vector<String> m_attribs;
|
||||||
Vector<GLenum> m_attribTypes;
|
Vector<GLenum> m_attribTypes;
|
||||||
// For SpvcSession::SetVertexAttribLocation()
|
|
||||||
// UnorderedMap<String, Uint> m_attribLocation;
|
|
||||||
|
|
||||||
// FragData (Frag out)
|
// FragData (Frag out)
|
||||||
UnorderedMap<String, Uint> m_explicitFragDataLocation;
|
UnorderedMap<String, Uint> m_explicitFragDataLocation;
|
||||||
@@ -162,13 +157,15 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
// Let's define UniformBlockIndex == the order at glslang getUniformBlock()
|
// Let's define UniformBlockIndex == the order at glslang getUniformBlock()
|
||||||
// aka `i = glGetUniformBlockIndex(prog, "BlockName")` implies:
|
// aka `i = glGetUniformBlockIndex(prog, "BlockName")` implies:
|
||||||
// `prog->getUniformBlock(i) == "BlockName"`
|
// `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;
|
UnorderedMap<String, Uint> m_uniformBlockIndexByName;
|
||||||
Vector<Int> m_uniformBlockBinding;
|
Vector<Int> m_uniformBlockBinding;
|
||||||
|
|
||||||
// Need to be reflected after linking of SPIR-V binary
|
// Need to be reflected after linking of SPIR-V binary
|
||||||
Vector<Uint> m_uniformOffsets;
|
Vector<Uint> m_uniformOffsets;
|
||||||
Vector<Uint> m_uniformSizesInBytes;
|
Vector<Uint> m_uniformSizesInBytes;
|
||||||
Vector<Uint8> m_uboScratch;
|
Vector<Uint8> m_globalUboScratch;
|
||||||
|
|
||||||
Uint m_activeUniformCount = 0;
|
Uint m_activeUniformCount = 0;
|
||||||
Uint m_maxUniformLocation = 0;
|
Uint m_maxUniformLocation = 0;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace MobileGL {
|
|||||||
|
|
||||||
if (strcmp(list[i].name, GLOBAL_UBO_NAME) == 0) {
|
if (strcmp(list[i].name, GLOBAL_UBO_NAME) == 0) {
|
||||||
spvc_type type = spvc_compiler_get_type_handle(compiler, list[i].base_type_id);
|
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);
|
size_t num_members = spvc_type_get_num_member_types(type);
|
||||||
for (size_t j = 0; j < num_members; ++j) {
|
for (size_t j = 0; j < num_members; ++j) {
|
||||||
const char* memberName = spvc_compiler_get_member_name(compiler, list[i].base_type_id, 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, unsigned> plainUniformOffsetsInUBO;
|
||||||
UnorderedMap<String, SizeT> plainUniformMemberSizesInBytes;
|
UnorderedMap<String, SizeT> plainUniformMemberSizesInBytes;
|
||||||
UnorderedMap<String, SpvcType> plainUniformMemberTypes;
|
UnorderedMap<String, SpvcType> plainUniformMemberTypes;
|
||||||
SizeT uboSize = 0;
|
SizeT globalUboSize = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpvcSession {
|
class SpvcSession {
|
||||||
|
|||||||
Reference in New Issue
Block a user