mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Fix] (MG_State/Program): use vector to save uniforms instead
This commit is contained in:
@@ -67,7 +67,12 @@ namespace MobileGL {
|
|||||||
root->traverse(&traverser);
|
root->traverse(&traverser);
|
||||||
auto& symbols = traverser.GetCollectedSymbols();
|
auto& symbols = traverser.GetCollectedSymbols();
|
||||||
for (const auto& symbol : symbols) {
|
for (const auto& symbol : symbols) {
|
||||||
m_uniforms[symbol->getName().c_str()] = symbol->getQualifier().layoutLocation;
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace MobileGL {
|
|||||||
const ShaderStage m_stage;
|
const ShaderStage m_stage;
|
||||||
String m_source;
|
String m_source;
|
||||||
SharedPtr<glslang::TShader> m_shader;
|
SharedPtr<glslang::TShader> m_shader;
|
||||||
UnorderedMap<String, Int> m_uniforms;
|
Vector<String> m_uniforms;
|
||||||
|
|
||||||
String m_infoLog;
|
String m_infoLog;
|
||||||
Bool m_deleteStatus = false;
|
Bool m_deleteStatus = false;
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ TEST_F(ProgramUtilTest, CompileVertexShaderWithLocation) {
|
|||||||
ASSERT_NE(res.error().errc, 0);
|
ASSERT_NE(res.error().errc, 0);
|
||||||
FAIL() << "errc: " << res.error().errc << "\nlog: " << res.error().log;
|
FAIL() << "errc: " << res.error().errc << "\nlog: " << res.error().log;
|
||||||
}
|
}
|
||||||
UnorderedMap<String, Int> uniforms;
|
Vector<String> uniforms;
|
||||||
|
|
||||||
auto pShader = res.value();
|
auto pShader = res.value();
|
||||||
auto root = pShader->getIntermediate()->getTreeRoot();
|
auto root = pShader->getIntermediate()->getTreeRoot();
|
||||||
@@ -207,12 +207,17 @@ TEST_F(ProgramUtilTest, CompileVertexShaderWithLocation) {
|
|||||||
root->traverse(&traverser);
|
root->traverse(&traverser);
|
||||||
auto& symbols = traverser.GetCollectedSymbols();
|
auto& symbols = traverser.GetCollectedSymbols();
|
||||||
for (const auto& symbol : symbols) {
|
for (const auto& symbol : symbols) {
|
||||||
uniforms[symbol->getName().c_str()] = symbol->getQualifier().layoutLocation;
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(uniforms["ProjMat"], 1);
|
EXPECT_EQ(uniforms[1], "ProjMat");
|
||||||
EXPECT_EQ(uniforms["InSize"], 20);
|
EXPECT_EQ(uniforms[20], "InSize");
|
||||||
EXPECT_EQ(uniforms["OutSize"], 4095);
|
EXPECT_EQ(uniforms[4095], "OutSize");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProgramUtilTest, CompileAndLinkProgram) {
|
TEST_F(ProgramUtilTest, CompileAndLinkProgram) {
|
||||||
|
|||||||
Reference in New Issue
Block a user