Revert "[Fix] (MG_State/Program): use vector to save uniforms instead"

This reverts commit bfb62872c9.
This commit is contained in:
2025-08-13 17:05:21 +08:00
parent bfb62872c9
commit 09d1e035ed
3 changed files with 7 additions and 17 deletions
@@ -67,12 +67,7 @@ namespace MobileGL {
root->traverse(&traverser);
auto& symbols = traverser.GetCollectedSymbols();
for (const auto& symbol : symbols) {
auto layoutLoc = symbol->getQualifier().layoutLocation;
if (layoutLoc >= m_uniforms.size()) {
m_uniforms.reserve(std::bit_ceil(layoutLoc));
m_uniforms.resize(layoutLoc + 1);
}
m_uniforms[layoutLoc] = symbol->getName().c_str();
m_uniforms[symbol->getName().c_str()] = symbol->getQualifier().layoutLocation;
}
return true;
@@ -73,7 +73,7 @@ namespace MobileGL {
const ShaderStage m_stage;
String m_source;
SharedPtr<glslang::TShader> m_shader;
Vector<String> m_uniforms;
UnorderedMap<String, Int> m_uniforms;
String m_infoLog;
Bool m_deleteStatus = false;
+5 -10
View File
@@ -199,7 +199,7 @@ TEST_F(ProgramUtilTest, CompileVertexShaderWithLocation) {
ASSERT_NE(res.error().errc, 0);
FAIL() << "errc: " << res.error().errc << "\nlog: " << res.error().log;
}
Vector<String> uniforms;
UnorderedMap<String, Int> uniforms;
auto pShader = res.value();
auto root = pShader->getIntermediate()->getTreeRoot();
@@ -207,17 +207,12 @@ TEST_F(ProgramUtilTest, CompileVertexShaderWithLocation) {
root->traverse(&traverser);
auto& symbols = traverser.GetCollectedSymbols();
for (const auto& symbol : symbols) {
auto layoutLoc = symbol->getQualifier().layoutLocation;
if (layoutLoc >= uniforms.size()) {
uniforms.reserve(std::bit_ceil(layoutLoc));
uniforms.resize(layoutLoc + 1);
}
uniforms[layoutLoc] = symbol->getName().c_str();
uniforms[symbol->getName().c_str()] = symbol->getQualifier().layoutLocation;
}
EXPECT_EQ(uniforms[1], "ProjMat");
EXPECT_EQ(uniforms[20], "InSize");
EXPECT_EQ(uniforms[4095], "OutSize");
EXPECT_EQ(uniforms["ProjMat"], 1);
EXPECT_EQ(uniforms["InSize"], 20);
EXPECT_EQ(uniforms["OutSize"], 4095);
}
TEST_F(ProgramUtilTest, CompileAndLinkProgram) {