New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPIR-V] Silent compiler crash when using GetAttributeAtVertex #2955
Comments
Fix a null pointer dereference which can occur when an unimplemented intrinsic is used. The repro shader from issue microsoft#2955 (added as a unit test) now fails with a useful message rather than a silent crash.
Fix a null pointer dereference which can occur when an unimplemented intrinsic is used. The repro shader from issue #2955 (added as a unit test) now fails with a useful message rather than a silent crash.
Closing this issue as the crash is resolved, and opened #3930 to track an actual implementation of the intrinsic in future. |
Seems like this issue is now present again. Also, tried to figure out the actual usages, and turns out the SPIR-V backend generated invalid code in a few cases instead of showing an error, or generating valid code. @ShchchowAMD could you take a look? Seems like you implemented those features IIRC? Another example which yields a validation error: struct S {
float4 a : COLOR;
};
float compute(float4 a) {
return GetAttributeAtVertex(a, 0)[0];
}
float4 main(nointerpolation S s) : SV_TARGET
{
return float4(0, 0, 0, compute(s.a));
}
|
Just to double check I understand correct as I'm not familiar with this case:
I'll try to make a fix for this case if above explanation is expected. Seems like previous implementation missed such case that using array-like bracket indexing to access a channel in vector. |
I believe that is correct. You can see compare |
@ShchchowAMD Thanks for looking into this. |
…ture inputs. (#6041) **Fix for** Fix issue under: #2955 For structure type, when `nointerpolation` is decorated on a structure input, this flag should be broadcast to its members. PR (#6018) also helps to resolve an issue when SPIRV backend generated variable has no AST type. **Test** Please see same case under: #6018 Besides, example as below should be invalid as the first parameter of function `compute` should has only one spirv-type. If its parameter type declaration has been expanded to an array implicitly, it should not accept other interpolated inputs as its input parameter. ``` struct S { float4 a : COLOR; }; float compute(float4 a) { return GetAttributeAtVertex(a, 2)[0]; } float4 main(nointerpolation S s, float4 b : COLOR2) : SV_TARGET //float4 main(nointerpolation S s) : SV_TARGET { return float4(0, 0, compute(b), compute(s.a)); //return float4(0, 0, 0, compute(s.a)); } ``` I added an error report point in this commit and gets following reports: ``` 1.hlsl:12:31: error: Current function could only use noninterpolated variable as input. return float4(0, 0, compute(b), compute(s.a)); ^ fatal error: generated SPIR-V is invalid: OpFunctionCall Argument <id> '37[%param_var_a_0]'s type does not match Function <id> '24[%_ptr_Function_v4float]'s parameter type. %45 = OpFunctionCall %float %compute %param_var_a_0 note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible ``` Any idea to let the error only reported before spirv validator? **Ref**: #2955 #6018 --------- Co-authored-by: Zhou, Shaochi(AMD) <shaozhou@amd.com> Co-authored-by: Natalie Chouinard <sudonatalie@google.com>
Some SPIR-V types are not direct translations of an AST type, hence they don't have an AST type attached to it. The code didn't checked for this possibility when visiting all variables. Fixes microsoft#2955 Signed-off-by: Nathan Gauër <brioche@google.com>
Some SPIR-V types are not direct translations of an AST type, hence they don't have an AST type attached to it. The code didn't checked for this possibility when visiting all variables. Fixes microsoft#2955 Signed-off-by: Nathan Gauër <brioche@google.com>
Some SPIR-V types are not direct translations of an AST type, hence they don't have an AST type attached to it. The code didn't checked for this possibility when visiting all variables. Fixes #2955 Signed-off-by: Nathan Gauër <brioche@google.com>
Title
Silent compiler crash when using GetAttributeAtVertex
Functional impact
Compiler crashes, no result gets printed to stdout.
Minimal repro steps
dxc.exe -E frag -T ps_6_1 repro_shader.txt -spirv
Expected result
The compiler outputs valid SPIR-V
Actual result
DXC crashes on null pointer dereference (see call_stack.txt)
Further technical details
DXC built from changeset 5ebc67c
The text was updated successfully, but these errors were encountered: