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:
@@ -204,11 +204,14 @@ public:
|
||||
// the result and returns disassembly text.
|
||||
GlslangResult compileAndLink(
|
||||
const std::string shaderName, const std::string& code,
|
||||
const std::string& entryPointName, EShMessages controls)
|
||||
const std::string& entryPointName, EShMessages controls,
|
||||
bool flattenUniformArrays = false)
|
||||
{
|
||||
const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
|
||||
|
||||
glslang::TShader shader(kind);
|
||||
shader.setFlattenUniformArrays(flattenUniformArrays);
|
||||
|
||||
bool success = compile(&shader, code, entryPointName, controls);
|
||||
|
||||
glslang::TProgram program;
|
||||
@@ -395,6 +398,32 @@ public:
|
||||
expectedOutputFname);
|
||||
}
|
||||
|
||||
void loadFileCompileFlattenUniformsAndCheck(const std::string& testDir,
|
||||
const std::string& testName,
|
||||
Source source,
|
||||
Semantics semantics,
|
||||
Target target,
|
||||
const std::string& entryPointName="")
|
||||
{
|
||||
const std::string inputFname = testDir + "/" + testName;
|
||||
const std::string expectedOutputFname =
|
||||
testDir + "/baseResults/" + testName + ".out";
|
||||
std::string input, expectedOutput;
|
||||
|
||||
tryLoadFile(inputFname, "input", &input);
|
||||
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
|
||||
|
||||
const EShMessages controls = DeriveOptions(source, semantics, target);
|
||||
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, true);
|
||||
|
||||
// Generate the hybrid output in the way of glslangValidator.
|
||||
std::ostringstream stream;
|
||||
outputResultToStream(&stream, result, controls);
|
||||
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
|
||||
expectedOutputFname);
|
||||
}
|
||||
|
||||
void loadFileCompileIoMapAndCheck(const std::string& testDir,
|
||||
const std::string& testName,
|
||||
Source source,
|
||||
|
||||
Reference in New Issue
Block a user