Enable HLSL legalization

Also added known-good mechanism to fetch latest validated spirv-tools.
Also added -Od and -Os to disable optimizer and optimize for size.

Fetching spirv-tools is optional for both glsl and hlsl. Legalization
of hlsl is done by default if spirv-opt is present at cmake time.
Optimization for glsl is currently done through the option -Os.

Legalization testing is currently only done on four existing shaders.
A separate baseLegalResults directory holds those results. All previous
testing is done with the optimizer disabled.
This commit is contained in:
GregF
2017-09-21 18:40:22 -06:00
parent 44dd6a00c3
commit cd1f169c6a
16 changed files with 536 additions and 23 deletions

View File

@@ -198,7 +198,8 @@ public:
const std::string shaderName, const std::string& code,
const std::string& entryPointName, EShMessages controls,
bool flattenUniformArrays = false,
EShTextureSamplerTransformMode texSampTransMode = EShTexSampTransKeep)
EShTextureSamplerTransformMode texSampTransMode = EShTexSampTransKeep,
bool disableOptimizer = true)
{
const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
@@ -217,8 +218,10 @@ public:
if (success && (controls & EShMsgSpvRules)) {
std::vector<uint32_t> spirv_binary;
glslang::SpvOptions options;
options.disableOptimizer = disableOptimizer;
glslang::GlslangToSpv(*program.getIntermediate(kind),
spirv_binary, &logger);
spirv_binary, &logger, &options);
std::ostringstream disassembly_stream;
spv::Parameterize();
@@ -381,18 +384,20 @@ public:
Source source,
Semantics semantics,
Target target,
const std::string& entryPointName="")
const std::string& entryPointName="",
const std::string& baseDir="/baseResults/",
const bool disableOptimizer = true)
{
const std::string inputFname = testDir + "/" + testName;
const std::string expectedOutputFname =
testDir + "/baseResults/" + testName + ".out";
testDir + baseDir + 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);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false, EShTexSampTransKeep, disableOptimizer);
// Generate the hybrid output in the way of glslangValidator.
std::ostringstream stream;