Title
Without any logical reason, the for-loop is being removed from the SPIR-V code
Functional impact
The behavior of the shader is changed.
Minimal repro steps
-
Download the following pixel shader:
BlurFilter_hlsl.txt
-
Compile it using dxc by executing: dxc.exe -spirv -Vd .\BlurFilter.hlsl -T ps_5_0 -E PS_BlurFil
ter_Box1 (I even tried to drop optimization)
Generated SPIR-V can be found here:
BlurFilterSPIRv.txt
Expected result
Get the for-loop in SPIR-V code.
Actual result
The HLSL code has the following for-loop:
for(i=-cBlurFilterSize.x;
i<=cBlurFilterSize.x;
i++)
{
color+=GetTexture2DLod(texScaleformInput0,ssScaleformInput0,IN.tex0+i*cBlurFilterScale,0.f);
}
but the generated SPIR-V code for the shader is as follows:
%PS_BlurFilter_Box1 = OpFunction %void None %26
%54 = OpLabel
%55 = OpAccessChain %_ptr_Uniform_v3float %var_ScaleformRenderParameters %int_6
%56 = OpAccessChain %_ptr_Uniform_float %55 %int_2
%57 = OpLoad %float %56
%58 = OpVectorTimesScalar %v4float %45 %57
%59 = OpAccessChain %_ptr_Uniform_mat2v4float %var_ScaleformRenderParameters %int_0
%60 = OpAccessChain %_ptr_Uniform_v4float %59 %uint_0
%61 = OpLoad %v4float %60
%62 = OpFMul %v4float %58 %61
%63 = OpAccessChain %_ptr_Uniform_v4float %59 %uint_1
%64 = OpLoad %v4float %63
%65 = OpCompositeExtract %float %58 3
%66 = OpVectorTimesScalar %v4float %64 %65
%67 = OpFAdd %v4float %62 %66
OpStore %out_var_SV_Target %67
OpReturn
OpFunctionEnd
Apparently, there are no texture reads in the SPIR-V code.
Title
Without any logical reason, the for-loop is being removed from the SPIR-V code
Functional impact
The behavior of the shader is changed.
Minimal repro steps
Download the following pixel shader:
BlurFilter_hlsl.txt
Compile it using dxc by executing: dxc.exe -spirv -Vd .\BlurFilter.hlsl -T ps_5_0 -E PS_BlurFil
ter_Box1 (I even tried to drop optimization)
Generated SPIR-V can be found here:
BlurFilterSPIRv.txt
Expected result
Get the for-loop in SPIR-V code.
Actual result
The HLSL code has the following for-loop:
for(i=-cBlurFilterSize.x;
i<=cBlurFilterSize.x;
i++)
{
color+=GetTexture2DLod(texScaleformInput0,ssScaleformInput0,IN.tex0+i*cBlurFilterScale,0.f);
}
but the generated SPIR-V code for the shader is as follows:
%PS_BlurFilter_Box1 = OpFunction %void None %26
%54 = OpLabel
%55 = OpAccessChain %_ptr_Uniform_v3float %var_ScaleformRenderParameters %int_6
%56 = OpAccessChain %_ptr_Uniform_float %55 %int_2
%57 = OpLoad %float %56
%58 = OpVectorTimesScalar %v4float %45 %57
%59 = OpAccessChain %_ptr_Uniform_mat2v4float %var_ScaleformRenderParameters %int_0
%60 = OpAccessChain %_ptr_Uniform_v4float %59 %uint_0
%61 = OpLoad %v4float %60
%62 = OpFMul %v4float %58 %61
%63 = OpAccessChain %_ptr_Uniform_v4float %59 %uint_1
%64 = OpLoad %v4float %63
%65 = OpCompositeExtract %float %58 3
%66 = OpVectorTimesScalar %v4float %64 %65
%67 = OpFAdd %v4float %62 %66
OpStore %out_var_SV_Target %67
OpReturn
OpFunctionEnd
Apparently, there are no texture reads in the SPIR-V code.