Closed chaoticbob closed 5 days ago
Slang does not support this behavior AFAIK, just filing this for documentation purposes.
The shader below contains variables that use their own components for initialization during their declarations:
float4 main(float4 a : A) : SV_Target { float2 v = float2(a.x, v.x); float2 v2 = float2(v2.y, v.x); float2x2 m = float2x2(v.x, m._m00, a.x, a.z); float2x2 m2 = float2x2(m._m01, v2.x, a.x, a.z); return float4(m._m00, m._m01, m2._m10, m2._m11) + float4(v + v2, 0, 0); }
DXC/DXIL errors out when compiling this shader but DXC/SPIR-V has no problem compiling it. Thankfully, Slang also errors out when compiling it:
shader.hlsl(8): error 30015: undefined identifier 'v'. float2 v = float2(a.x, v.x); ^ shader.hlsl(9): error 30015: undefined identifier 'v2'. float2 v2 = float2(v2.y, v.x); ^~ shader.hlsl(11): error 30015: undefined identifier 'm'. float2x2 m = float2x2(v.x, m._m00, a.x, a.z);
I can't think of a practical case where this would be useful. Besides looking scary, it also promotes bad practice.
Reference: https://github.com/microsoft/DirectXShaderCompiler/issues/6719
Slang does not support this behavior AFAIK, just filing this for documentation purposes.
The shader below contains variables that use their own components for initialization during their declarations:
DXC/DXIL errors out when compiling this shader but DXC/SPIR-V has no problem compiling it. Thankfully, Slang also errors out when compiling it:
I can't think of a practical case where this would be useful. Besides looking scary, it also promotes bad practice.
Reference: https://github.com/microsoft/DirectXShaderCompiler/issues/6719