-
Notifications
You must be signed in to change notification settings - Fork 713
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
Add specific handling for inline spirv pointer types #6873
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they places where we want to generate 2 distinct types for the same thing in DXC?
If not, why isn't this the default path for pointer type creation?
You should be able to do pointers for storage classes that do not require a layout. So function, private, and workgroup. |
Some other issues might be small bugs that still need to be fixed separately from this one. If you have problems let me know. Do we still have an issue opened for the access chain? I may have lost that issue. |
AFAIK you just closed it, it was wrapped up with #6541 |
Later in #6578 I did some tests with attempting to use Above optimization level O0 (so O1 and above) stuff gets aggressively inlined so the variable never exists in the first place to take a pointer of. P.S. When one uses |
I have opened #6891 to follow up on the access chain issue. There was already an existing issues for the decoration attribute on fields. |
For pointers, I don't think we ever want to generate two distinct types. We might want to generate different types for struts that are the "same" if the user gave them different names:
I believe it is. The code that creates pointers calls DirectXShaderCompiler/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp Lines 225 to 231 in bb3a0c3
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to check something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
285a04c
to
e2ab4d5
Compare
We currently blindly create a new type for all vk::SpirvType* types. This can cause problems when the type is suppose to match another type. In this case, we want a spirv pointer type to match the pointer type of the variable. The OpTypePointer for the variable is implicitly created when declaring the variable, but, if we want to explicitly declare the pointer as a SpirvType, we get two different OpTypePointer instructions in the module. So technically the types do not match. To fix this, I add special handling in the SPIR-V backend to be able to merge the implicit pointer type created and the SpirvType when they match.
Co-authored-by: Nathan Gauër <[email protected]>
9a17c9e
to
c780db8
Compare
am I not understanding something or was this PR supposed to fix issues like needing the |
It should fix the issue with using access chains. It only for storage classes that do not require a layout (Function, Private, workgroup). I don't think we will be able to fix the layout problem in DXC. |
Add specific handling for inline spirv pointer types
We currently blindly create a new type for all vk::SpirvType* types.
This can cause problems when the type is suppose to match another type.
In this case, we want a spirv pointer type to match the pointer type of the
variable. The OpTypePointer for the variable is implicitly created when
declaring the variable, but, if we want to explicitly declare the
pointer as a SpirvType, we get two different OpTypePointer instructions
in the module. So technically the types do not match.
To fix this, I add special handling in the SPIR-V backend to be able to
merge the implicit pointer type created and the SpirvType when they
match.
This implements the SPIR-V Pointers in HLSL spec proposal 0021