From bbd05fe8aaae112bd2016c297a9941dcf3d5b453 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Mon, 21 Jul 2025 17:51:06 +0800 Subject: [PATCH] [Chore] (MG_Util/Program): test uniform linkage across stages --- MobileGL/MG_Test/Program/ProgramTest.cpp | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/MobileGL/MG_Test/Program/ProgramTest.cpp b/MobileGL/MG_Test/Program/ProgramTest.cpp index 3798616b..728a5ceb 100644 --- a/MobileGL/MG_Test/Program/ProgramTest.cpp +++ b/MobileGL/MG_Test/Program/ProgramTest.cpp @@ -238,4 +238,34 @@ TEST_F(ProgramTest, DecompProgram) { for (size_t i = 0; i < vs_outputs.size(); ++i) { EXPECT_EQ(vs_outputs[i].location, fs_inputs[i].location); } + + auto vs_uniforms = GetShaderInterface(spirvs[0], SPVC_RESOURCE_TYPE_GL_PLAIN_UNIFORM); + auto fs_uniforms = GetShaderInterface(spirvs[1], SPVC_RESOURCE_TYPE_GL_PLAIN_UNIFORM); + + std::unordered_map uniform_locations; + for (const auto& uniform : vs_uniforms) { + uniform_locations[uniform.name] = uniform.location; + } + + for (const auto& uniform : fs_uniforms) { + auto it = uniform_locations.find(uniform.name); + if (it != uniform_locations.end()) { + EXPECT_EQ(it->second, uniform.location); + } + } + + auto vs_samplers = GetShaderInterface(spirvs[0], SPVC_RESOURCE_TYPE_SAMPLED_IMAGE); + auto fs_samplers = GetShaderInterface(spirvs[1], SPVC_RESOURCE_TYPE_SAMPLED_IMAGE); + + std::unordered_map sampler_locations; + for (const auto& uniform : vs_uniforms) { + sampler_locations[uniform.name] = uniform.location; + } + + for (const auto& uniform : fs_uniforms) { + auto it = sampler_locations.find(uniform.name); + if (it != sampler_locations.end()) { + EXPECT_EQ(it->second, uniform.location); + } + } }