-
Notifications
You must be signed in to change notification settings - Fork 717
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] Reapeated SV_DomainLocation semantics don't produce an error and can crash the compiler (works with the DXIL backend) #3737
Comments
Seems like this reproduction code hits 2 issues:
For the first issue, we don't crash today, but we allow it while DXIL doesn't. Seems like this aliasing is the cause of the second issue: some codegen relies on the different variable type, but when we alias, we might end up changing the type of Seems like we should not allow aliasing (to match DXIL behavior). I'll see the cleanest way to handle that. |
Looking a bit at this, I want do add the error. @tex3d: is it allowed or not in HLSL to use the same semantic for an input parameter twice to alias it? |
Or @llvm-beanz maybe?
My opinion is no, we should not allow input alias. |
I think the rules here as implemented in DXC are complicated and inconsistent. For example both the case in this bug and your example with user-defined semantics are invalid (see: Hull Shader & Vertex Shader). We currently only enforce this in the DXIL validator rather than in Sema, which is why the error handling between DXIL and SPIR-V are hard to keep consistent. @bob80905 worked up a feature proposal for moving this into Sema (see: microsoft/hlsl-specs#156), but we decided that wasn't justified for DXC, but we would pursue this approach in Clang. We do also seem to allow duplicate compute shader system values (see: SV_GroupIndex & SV_GroupID). I can't think of a legitimate use case for this, but changing it would likely need to be a language change because we'd almost certainly break users in some cases. |
Right, btw, the validator doesn't seem to catch SV_Position & POSITION alias: Assuming this line of the documentation is right:
Seems like this is just an overlook: the shader has no input, those are grabbed from DXIL builtins, hence probably why this wasn't caught. At least for the SPIR-V side, I'm in favor of disallow any aliasing. As long as we can say that's desirable from the HLSL language point of view. |
Oh! This is actually kinda fascinating. It looks like if you use
Yep, and it is a product of relying on validation for these errors.
I think that's fair, and seems consistent with the intent. |
The MSDN spec is not very clear regarding input parameter aliasing, BUT DXIL & MS agrees (See microsoft#3737) using the same semantic annotation twice should be disallowed. DXIL currently disallows it for most, and due to a bug, allows some compute related semantics to be aliased. SPIR-V did allowed aliasing, but it was a implemented as a hack causing typing issues if the type changed between the 2 parameters using the same semantic annotation. To align more closely with DXIL, and the "spec", we are not disallowing all semantic attribute reuse for input parameters. Signed-off-by: Nathan Gauër <[email protected]>
The MSDN spec is not very clear regarding input parameter aliasing, BUT DXIL & MS agrees (See microsoft#3737) using the same semantic annotation twice should be disallowed. DXIL currently disallows it for most, and due to a bug, allows some compute related semantics to be aliased. SPIR-V did allowed aliasing, but it was a implemented as a hack causing typing issues if the type changed between the 2 parameters using the same semantic annotation. To align more closely with DXIL, and the "spec", we are not disallowing all semantic attribute reuse for input parameters. Fixes microsoft#3737 Signed-off-by: Nathan Gauër <[email protected]>
The MSDN spec is not very clear regarding input parameter aliasing, BUT DXIL & MS agrees (See microsoft#3737) using the same semantic annotation twice should be disallowed. DXIL currently disallows it for most, and due to a bug, allows some compute related semantics to be aliased. SPIR-V did allowed aliasing, but it was a implemented as a hack causing typing issues if the type changed between the 2 parameters using the same semantic annotation. To align more closely with DXIL, and the "spec", we are not disallowing all semantic attribute reuse for input parameters. Fixes microsoft#3737 Signed-off-by: Nathan Gauër <[email protected]>
The MSDN spec is not very clear regarding input parameter aliasing, BUT DXIL & MS agrees (See microsoft#3737) using the same semantic annotation twice should be disallowed. DXIL currently disallows it for most, and due to a bug, allows some compute related semantics to be aliased. SPIR-V did allowed aliasing, but it was a implemented as a hack causing typing issues if the type changed between the 2 parameters using the same semantic annotation. To align more closely with DXIL, and the "spec", we are not disallowing all semantic attribute reuse for input parameters. Fixes microsoft#3737 Signed-off-by: Nathan Gauër <[email protected]>
The MSDN spec is not very clear regarding input parameter aliasing, BUT DXIL & MS agrees (See #3737) using the same semantic annotation twice should be disallowed. DXIL currently disallows it for most, and due to a bug, allows some compute related semantics to be aliased. SPIR-V did allowed aliasing, but it was a implemented as a hack causing typing issues if the type changed between the 2 parameters using the same semantic annotation. To align more closely with DXIL, and the "spec", we are now disallowing all semantic attribute reuse for input parameters. Fixes #3737 Signed-off-by: Nathan Gauër <[email protected]>
|
Title
[SPIR-V] Reapeated
SV_DomainLocation
semantics don't produce an error and can crash the compiler (works with the DXIL backend)Functional impact
Declaring repeated
SV_DomainLocation
input semantics in the same Domain shader entry point does not produce a compiler error and crashes in some cases.Minimal repro steps
dxc.exe -T ds_6_0 -E Domain -spirv repro_shader.txt
repro_shader.txt
Expected result
The SPIR-V backend should produce error similar to that of the DXIL backend:
Actual result
The SPIR-V backend crashes with an access violation exception:
Internal compiler error: access violation. Attempted to read from address 0x0000000000000010
Further technical details
The
repro_shader.txt
in theMinimal repro steps
section crashes the compiler with 3 repeats, if repeating only twice it still compiles, which is still an issue as it should instead produce a compiler error (like the DXIL backend does)Used DXC release v1.6.2104 (e09a454)
The text was updated successfully, but these errors were encountered: