Skip to content

Commit 951e612

Browse files
Light Scattering FX: fixed Vulkan image format mismatch warnings
1 parent b48648d commit 951e612

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

PostProcess/EpipolarLightScattering/src/EpipolarLightScattering.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,13 @@ void EpipolarLightScattering::PrecomputeScatteringLUT(IRenderDevice* pDevice, IR
637637
ShaderMacroHelper Macros;
638638
DefineMacros(Macros);
639639
Macros.AddShaderMacro("THREAD_GROUP_SIZE", ThreadGroupSize);
640+
// Vulkan requires image format to be specified in the shader, but glslang does not support
641+
// the [[vk::image_format]] attribute (https://github.com/KhronosGroup/glslang/issues/3790).
642+
// So we have to convert HLSL to GLSL so that the converter can add the attribute from the
643+
// /*format=...*/ comment.
640644
RefCntAutoPtr<IShader> pPrecomputeSingleSctrCS =
641645
CreateShader(pDevice, pStateCache, "PrecomputeSingleScattering.fx", "PrecomputeSingleScatteringCS",
642-
SHADER_TYPE_COMPUTE, m_ShaderFlags, Macros);
646+
SHADER_TYPE_COMPUTE, m_ShaderFlags | SHADER_COMPILE_FLAG_HLSL_TO_SPIRV_VIA_GLSL, Macros);
643647
PipelineResourceLayoutDesc ResourceLayout;
644648
ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC;
645649
PrecomputeSingleSctrTech.InitializeComputeTechnique(pDevice, pStateCache, "PrecomputeSingleScattering", pPrecomputeSingleSctrCS, ResourceLayout);
@@ -683,9 +687,13 @@ void EpipolarLightScattering::PrecomputeScatteringLUT(IRenderDevice* pDevice, IR
683687
ShaderMacroHelper Macros;
684688
DefineMacros(Macros);
685689
Macros.AddShaderMacro("THREAD_GROUP_SIZE", ThreadGroupSize);
690+
// Vulkan requires image format to be specified in the shader, but glslang does not support
691+
// the [[vk::image_format]] attribute (https://github.com/KhronosGroup/glslang/issues/3790).
692+
// So we have to convert HLSL to GLSL so that the converter can add the attribute from the
693+
// /*format=...*/ comment.
686694
RefCntAutoPtr<IShader> pInitHighOrderScatteringCS =
687695
CreateShader(pDevice, pStateCache, "InitHighOrderScattering.fx", "InitHighOrderScatteringCS",
688-
SHADER_TYPE_COMPUTE, m_ShaderFlags, Macros);
696+
SHADER_TYPE_COMPUTE, m_ShaderFlags | SHADER_COMPILE_FLAG_HLSL_TO_SPIRV_VIA_GLSL, Macros);
689697
PipelineResourceLayoutDesc ResourceLayout;
690698
ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC;
691699
InitHighOrderScatteringTech.InitializeComputeTechnique(pDevice, pStateCache, "InitHighOrderScattering", pInitHighOrderScatteringCS, ResourceLayout);
@@ -698,9 +706,13 @@ void EpipolarLightScattering::PrecomputeScatteringLUT(IRenderDevice* pDevice, IR
698706
ShaderMacroHelper Macros;
699707
DefineMacros(Macros);
700708
Macros.AddShaderMacro("THREAD_GROUP_SIZE", ThreadGroupSize);
709+
// Vulkan requires image format to be specified in the shader, but glslang does not support
710+
// the [[vk::image_format]] attribute (https://github.com/KhronosGroup/glslang/issues/3790).
711+
// So we have to convert HLSL to GLSL so that the converter can add the attribute from the
712+
// /*format=...*/ comment.
701713
RefCntAutoPtr<IShader> pUpdateHighOrderScatteringCS =
702714
CreateShader(pDevice, pStateCache, "UpdateHighOrderScattering.fx", "UpdateHighOrderScatteringCS",
703-
SHADER_TYPE_COMPUTE, m_ShaderFlags, Macros);
715+
SHADER_TYPE_COMPUTE, m_ShaderFlags | SHADER_COMPILE_FLAG_HLSL_TO_SPIRV_VIA_GLSL, Macros);
704716
PipelineResourceLayoutDesc ResourceLayout;
705717
ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC;
706718
UpdateHighOrderScatteringTech.InitializeComputeTechnique(pDevice, pStateCache, "UpdateHighOrderScattering", pUpdateHighOrderScatteringCS, ResourceLayout);
@@ -713,9 +725,13 @@ void EpipolarLightScattering::PrecomputeScatteringLUT(IRenderDevice* pDevice, IR
713725
ShaderMacroHelper Macros;
714726
DefineMacros(Macros);
715727
Macros.AddShaderMacro("THREAD_GROUP_SIZE", ThreadGroupSize);
728+
// Vulkan requires image format to be specified in the shader, but glslang does not support
729+
// the [[vk::image_format]] attribute (https://github.com/KhronosGroup/glslang/issues/3790).
730+
// So we have to convert HLSL to GLSL so that the converter can add the attribute from the
731+
// /*format=...*/ comment.
716732
RefCntAutoPtr<IShader> pCombineScatteringOrdersCS =
717733
CreateShader(pDevice, pStateCache, "CombineScatteringOrders.fx", "CombineScatteringOrdersCS",
718-
SHADER_TYPE_COMPUTE, m_ShaderFlags, Macros);
734+
SHADER_TYPE_COMPUTE, m_ShaderFlags | SHADER_COMPILE_FLAG_HLSL_TO_SPIRV_VIA_GLSL, Macros);
719735
PipelineResourceLayoutDesc ResourceLayout;
720736
ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC;
721737
CombineScatteringOrdersTech.InitializeComputeTechnique(pDevice, pStateCache, "CombineScatteringOrders", pCombineScatteringOrdersCS, ResourceLayout);

0 commit comments

Comments
 (0)