Fix issue with remapping global uniform blocks

Avoid adding global uniform blocks to stages that don't already have it.
Otherwise multiple stages point to the same block object, and a
remapping that occurs later on will change the mapping on multiple
stages.
This commit is contained in:
Malcolm Bechard
2021-03-17 18:47:13 -04:00
parent 48f08c60e2
commit 5340752190
7 changed files with 332 additions and 6 deletions

View File

@@ -48,6 +48,7 @@ namespace {
struct vkRelaxedData {
std::vector<std::string> fileNames;
std::vector<std::vector<std::string>> resourceSetBindings;
};
using VulkanRelaxedTest = GlslangTest <::testing::TestWithParam<vkRelaxedData>>;
@@ -191,6 +192,7 @@ bool verifyIOMapping(std::string& linkingError, glslang::TProgram& program) {
TEST_P(VulkanRelaxedTest, FromFile)
{
const auto& fileNames = GetParam().fileNames;
const auto& resourceSetBindings = GetParam().resourceSetBindings;
Semantics semantics = Semantics::Vulkan;
const size_t fileCount = fileNames.size();
const EShMessages controls = DeriveOptions(Source::GLSL, semantics, Target::BothASTAndSpv);
@@ -230,6 +232,12 @@ TEST_P(VulkanRelaxedTest, FromFile)
result.linkingOutput = program.getInfoLog();
result.linkingError = program.getInfoDebugLog();
if (!resourceSetBindings.empty()) {
assert(resourceSetBindings.size() == fileNames.size());
for (int i = 0; i < shaders.size(); i++)
shaders[i]->setResourceSetBinding(resourceSetBindings[i]);
}
unsigned int stage = 0;
glslang::TIntermediate* firstIntermediate = nullptr;
while (!program.getIntermediate((EShLanguage)stage) && stage < EShLangCount) { stage++; }
@@ -287,6 +295,7 @@ INSTANTIATE_TEST_SUITE_P(
{{"vk.relaxed.link1.frag", "vk.relaxed.link2.frag"}},
{{"vk.relaxed.stagelink.vert", "vk.relaxed.stagelink.frag"}},
{{"vk.relaxed.errorcheck.vert", "vk.relaxed.errorcheck.frag"}},
{{"vk.relaxed.changeSet.vert", "vk.relaxed.changeSet.frag" }, { {"0"}, {"1"} } },
}))
);
// clang-format on