From 95654c371e1b1c1916751d5dcd0d1f3fbfdc12a0 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 27 Oct 2021 15:21:09 -0400 Subject: SPIR-V fixes (#1992) * #include an absolute path didn't work - because paths were taken to always be relative. * Use updated slang-binaries that have SPIR-V diagnostics improvements. * Re-enable nv-ray-tracing-motion-blur, because with SPIR-V diagnostic fixes in glslang - there shouldn't be spurious errors from glslang compilation. * If optimization fails use the SPIR-V we have. * Update SPIR-V headers and generated files. Updated documentation. * Update spirv-headers/tools. Revert slang-binaries. * Remove hack around spir-v optimization as no longer needed. disable nv-ray-tracing-motion-blur.slang --- source/slang-glslang/slang-glslang.cpp | 25 +++++++++++-------------- source/slang/hlsl.meta.slang | 2 ++ 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/slang-glslang/slang-glslang.cpp b/source/slang-glslang/slang-glslang.cpp index e89581740..6cb6db995 100644 --- a/source/slang-glslang/slang-glslang.cpp +++ b/source/slang-glslang/slang-glslang.cpp @@ -399,14 +399,18 @@ static void glslang_optimizeSPIRV(spv_target_env targetEnv, const glslang_Compil spvOptOptions.set_run_validator(false); // Don't run the validator by default - // Put the output optimized spirv into optSpirv - std::vector optSpirv; - - // Optimize - optimizer.Run(ioSpirv.data(), ioSpirv.size(), &optSpirv, spvOptOptions); + { + // Put the output optimized spirv into optSpirv + std::vector optSpirv; - // Make the ioSpirv the optimized spirv - ioSpirv.swap(optSpirv); + // Optimize + if (optimizer.Run(ioSpirv.data(), ioSpirv.size(), &optSpirv, spvOptOptions)) + { + assert(optSpirv.size() > 0); + // Make the ioSpirv the optimized spirv + ioSpirv.swap(optSpirv); + } + } } static glslang::EShTargetLanguageVersion _makeTargetLanguageVersion(int majorVersion, int minorVersion) @@ -636,13 +640,6 @@ static int glslang_compileGLSLToSPIRV(const glslang_CompileRequest_1_1& request) { for (const auto& diag : optDiags) { - // TODO(JS): - // Hack to stop CapabilityRayTracingMotionBlurNV outputting an error - if (diag.level == SPV_MSG_ERROR && diag.message == "Invalid capability operand: 5341") - { - continue; - } - // Count the number of errors optErrorCount += int(diag.level <= SPV_MSG_ERROR); diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 465a7633f..2e1ab33f2 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -4516,6 +4516,8 @@ void TraceRay( // NOTE! // The name of the following functions may change when DXR supports // a feature similar to the `GL_NV_ray_tracing_motion_blur` extension +// +// https://github.com/KhronosGroup/GLSL/blob/master/extensions/nv/GLSL_NV_ray_tracing_motion_blur.txt void TraceMotionRay( RaytracingAccelerationStructure AccelerationStructure, -- cgit v1.2.3