Flatten uniform arrays
This checkin adds a --flatten-uniform-arrays option which can break uniform arrays of samplers, textures, or UBOs up into individual scalars named (e.g) myarray[0], myarray[1], etc. These appear as individual linkage objects. Code notes: - shouldFlatten internally calls shouldFlattenIO, and shouldFlattenUniform, but is the only flattening query directly called. - flattenVariable will handle structs or arrays (but not yet arrayed structs; this is tested an an error is generated). - There's some error checking around unhandled situations. E.g, flattening uniform arrays with initializer lists is not implemented. - This piggybacks on as much of the existing mechanism for struct flattening as it can. E.g, it uses the same flattenMap, and the same flattenAccess() method. - handleAssign() has been generalized to cope with either structs or arrays. - Extended test infrastructure to test flattening ability.
This commit is contained in:
@@ -58,6 +58,7 @@ std::string FileNameAsCustomTestSuffix(
|
||||
}
|
||||
|
||||
using HlslCompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
|
||||
using HlslCompileAndFlattenTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
|
||||
|
||||
// Compiling HLSL to SPIR-V under Vulkan semantics. Expected to successfully
|
||||
// generate both AST and SPIR-V.
|
||||
@@ -68,6 +69,13 @@ TEST_P(HlslCompileTest, FromFile)
|
||||
Target::BothASTAndSpv, GetParam().entryPoint);
|
||||
}
|
||||
|
||||
TEST_P(HlslCompileAndFlattenTest, FromFile)
|
||||
{
|
||||
loadFileCompileFlattenUniformsAndCheck(GLSLANG_TEST_DIRECTORY, GetParam().fileName,
|
||||
Source::HLSL, Semantics::Vulkan,
|
||||
Target::BothASTAndSpv, GetParam().entryPoint);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
ToSpirv, HlslCompileTest,
|
||||
@@ -181,5 +189,15 @@ INSTANTIATE_TEST_CASE_P(
|
||||
);
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
ToSpirv, HlslCompileAndFlattenTest,
|
||||
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
|
||||
{"hlsl.array.flatten.frag", "main"},
|
||||
}),
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
||||
// clang-format on
|
||||
} // anonymous namespace
|
||||
} // namespace glslangtest
|
||||
|
||||
Reference in New Issue
Block a user