Skip to content

Commit c60b4f3

Browse files
PipelineStateVk: run legalization pass for HLSL shaders when remapping resources
1 parent 315c2ad commit c60b4f3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -740,7 +740,12 @@ void PipelineStateVkImpl::RemapOrVerifyShaderResources(
740740
// SPIR-V module not valid: DecorateStringGOOGLE requires one of the following extensions: SPV_GOOGLE_decorate_string
741741
// Optimizer also performs validation and may catch problems with the byte code.
742742
// NB: SPIRV offsets become INVALID after this operation.
743-
auto StrippedSPIRV = OptimizeSPIRV(SPIRV, SPV_ENV_MAX, SPIRV_OPTIMIZATION_FLAG_STRIP_REFLECTION);
743+
SPIRV_OPTIMIZATION_FLAGS OptimizationFlags = SPIRV_OPTIMIZATION_FLAG_STRIP_REFLECTION;
744+
if (pShader->GetShaderResources()->IsHLSLSource())
745+
{
746+
OptimizationFlags |= SPIRV_OPTIMIZATION_FLAG_LEGALIZATION;
747+
}
748+
auto StrippedSPIRV = OptimizeSPIRV(SPIRV, SPV_ENV_MAX, OptimizationFlags);
744749
if (!StrippedSPIRV.empty())
745750
SPIRV = std::move(StrippedSPIRV);
746751
else

0 commit comments

Comments
 (0)