Invalid float4 to float assignment in codegen when using arrays of scalars (int[], float[]) in constant buffer #1455
Labels
bug
Feature which should work in SPIRV-Cross does not for some reason.
in progress
Issue is being actively worked on
Hi,
I'm seeing a consistent code generation issue for this HLSL source snippet.
The generated MSL doesn't add the
.x
when assigning a float array element to a vector variable's member (other targets beside MSL are affected as well e.g. glsl)can reproduce the issue by compiling with either glslangValidator (SPIR-V generated locally with
glslangValidator -D -e frag issueShader.txt -V -H --spirv-dis -S frag
):SPIRV-Cross generates the following MSL (taken from the shader-playground link above):
The issue is the
_81.x = _8._BorderWidths[2];
line, as this is invalid MSL. Getting errors similar to the following from themetal
compiler (snippet has been simplified since then so names don't match):DXC reproduction SPIR-V looks like this (
dxc.exe -T ps_6_0 -E frag issueShader.txt -spirv
):Using DXC without optimisations however produces valid MSL when passed through SPIRV-Cross, this is source SPIR-V (generated with
dxc.exe -T ps_6_0 -E frag issueShader.txt -spirv -O0
):SPIRV-Cross generates valid MSL in this case:
This SPIRV-Cross output is from shader playground but I'm seeing metal compilation errors with a few week old SPIRV-Cross build.
Also, note that the issue seems to disappear when the
if
conditional is removed or when the type ofresult
is changed to a scalar.The text was updated successfully, but these errors were encountered: