it.dumpSpv(spirv);
#if ENABLE_OPT
- SpirvToolsValidate(intermediate, spirv, logger);
+ if (options->validate)
+ SpirvToolsValidate(intermediate, spirv, logger);
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// eg. forward and remove memory writes of opaque types.
struct SpvOptions {
SpvOptions() : generateDebugInfo(false), disableOptimizer(true),
- optimizeSize(false), disassemble(false) { }
+ optimizeSize(false), disassemble(false), validate(false) { }
bool generateDebugInfo;
bool disableOptimizer;
bool optimizeSize;
bool disassemble;
+ bool validate;
};
#if ENABLE_OPT
};
bool targetHlslFunctionality1 = false;
bool SpvToolsDisassembler = false;
+bool SpvToolsValidate = false;
//
// Return codes from main/exit().
break;
} else if (lowerword == "spirv-dis") {
SpvToolsDisassembler = true;
+ } else if (lowerword == "spirv-val") {
+ SpvToolsValidate = true;
} else if (lowerword == "stdin") {
Options |= EOptionStdin;
shaderStageName = argv[1];
spvOptions.disableOptimizer = (Options & EOptionOptimizeDisable) != 0;
spvOptions.optimizeSize = (Options & EOptionOptimizeSize) != 0;
spvOptions.disassemble = SpvToolsDisassembler;
+ spvOptions.validate = SpvToolsValidate;
glslang::GlslangToSpv(*program.getIntermediate((EShLanguage)stage), spirv, &logger, &spvOptions);
// Dump the spv to a file or stdout, etc., but only if not doing
" --shift-cbuffer-binding | --scb synonyms for --shift-UBO-binding\n"
" --spirv-dis output standard-form disassembly; works only\n"
" when a SPIR-V generation option is also used\n"
+ " --spirv-val execute the SPIRV-Tools validator\n"
" --source-entrypoint <name> the given shader source function is\n"
" renamed to be the <name> given in -e\n"
" --sep synonym for --source-entrypoint\n"
# Testing debug information
#
echo Testing SPV Debug Information
-$EXE -g --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf \
+$EXE -g --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf --spirv-val \
-G -H spv.debugInfo.frag --rsb frag 3 > $TARGETDIR/spv.debugInfo.frag.out
diff -b $BASEDIR/spv.debugInfo.frag.out $TARGETDIR/spv.debugInfo.frag.out || HASERROR=1
-$EXE -g -Od --target-env vulkan1.1 --relaxed-errors --suppress-warnings --aml --hlsl-offsets --nsf \
+$EXE -g -Od --target-env vulkan1.1 --relaxed-errors --suppress-warnings --aml --hlsl-offsets --nsf --spirv-val \
-G -H spv.debugInfo.frag --rsb frag 3 > $TARGETDIR/spv.debugInfo.1.1.frag.out
diff -b $BASEDIR/spv.debugInfo.1.1.frag.out $TARGETDIR/spv.debugInfo.1.1.frag.out || HASERROR=1
-$EXE -g -D -Od -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \
+$EXE -g -D -Od -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --spirv-val --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \
--sep origMain -H -Od spv.hlslDebugInfo.vert --rsb vert t0 0 0 > $TARGETDIR/spv.hlslDebugInfo.frag.out
diff -b $BASEDIR/spv.hlslDebugInfo.frag.out $TARGETDIR/spv.hlslDebugInfo.frag.out || HASERROR=1
std::vector<uint32_t> spirv_binary;
glslang::SpvOptions options;
options.disableOptimizer = true;
+ options.validate = true;
glslang::GlslangToSpv(*program.getIntermediate(shaders.front()->getStage()),
spirv_binary, &logger, &options);
std::vector<uint32_t> spirv_binary;
glslang::SpvOptions options;
options.disableOptimizer = !enableOptimizer;
+ options.validate = true;
glslang::GlslangToSpv(*program.getIntermediate(stage),
spirv_binary, &logger, &options);
if (success && (controls & EShMsgSpvRules)) {
std::vector<uint32_t> spirv_binary;
+ glslang::SpvOptions options;
+ options.validate = true;
glslang::GlslangToSpv(*program.getIntermediate(stage),
- spirv_binary, &logger);
+ spirv_binary, &logger, &options);
std::ostringstream disassembly_stream;
spv::Parameterize();
if (success && (controls & EShMsgSpvRules)) {
std::vector<uint32_t> spirv_binary;
+ glslang::SpvOptions options;
+ options.validate = true;
glslang::GlslangToSpv(*program.getIntermediate(stage),
- spirv_binary, &logger);
+ spirv_binary, &logger, &options);
spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions);