Merge pull request #1794 from jeffbolznv/pre_legalization

Use spvValidatorOptionsSetBeforeHlslLegalization for pre-legalized HLSL
This commit is contained in:
John Kessenich 2019-06-08 04:04:15 -06:00 committed by GitHub
commit 60e774b22f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 5 deletions

View File

@ -8090,11 +8090,14 @@ void GlslangToSpv(const TIntermediate& intermediate, std::vector<unsigned int>&
#if ENABLE_OPT
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// eg. forward and remove memory writes of opaque types.
if ((intermediate.getSource() == EShSourceHlsl || options->optimizeSize) && !options->disableOptimizer)
bool prelegalization = intermediate.getSource() == EShSourceHlsl;
if ((intermediate.getSource() == EShSourceHlsl || options->optimizeSize) && !options->disableOptimizer) {
SpirvToolsLegalize(intermediate, spirv, logger, options);
prelegalization = false;
}
if (options->validate)
SpirvToolsValidate(intermediate, spirv, logger);
SpirvToolsValidate(intermediate, spirv, logger, prelegalization);
if (options->disassemble)
SpirvToolsDisassemble(std::cout, spirv);

View File

@ -103,7 +103,7 @@ void SpirvToolsDisassemble(std::ostream& out, const std::vector<unsigned int>& s
// Apply the SPIRV-Tools validator to generated SPIR-V.
void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
spv::SpvBuildLogger* logger)
spv::SpvBuildLogger* logger, bool prelegalization)
{
// validate
spv_context context = spvContextCreate(MapToSpirvToolsEnv(intermediate.getSpv(), logger));
@ -111,6 +111,7 @@ void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector<
spv_diagnostic diagnostic = nullptr;
spv_validator_options options = spvValidatorOptionsCreate();
spvValidatorOptionsSetRelaxBlockLayout(options, intermediate.usingHlslOffsets());
spvValidatorOptionsSetBeforeHlslLegalization(options, prelegalization);
spvValidateWithOptions(context, options, &binary, &diagnostic);
// report

View File

@ -66,7 +66,7 @@ void SpirvToolsDisassemble(std::ostream& out, const std::vector<unsigned int>& s
// Apply the SPIRV-Tools validator to generated SPIR-V.
void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
spv::SpvBuildLogger*);
spv::SpvBuildLogger*, bool prelegalization);
// Apply the SPIRV-Tools optimizer to generated SPIR-V, for the purpose of
// legalizing HLSL SPIR-V.

View File

@ -135,7 +135,6 @@ local_size = (256, 1, 1)
0:? 'g_output' (layout( binding=1 rg32ui) uniform uimageBuffer)
0:? 'dispatchId' ( in 3-component vector of uint GlobalInvocationID)
Validation failed
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 63