-
Notifications
You must be signed in to change notification settings - Fork 33
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
Specify aliasing and address space for vk::BufferPointer #53
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.
I think this needs to be expanded a little. As stated, it would be nearly impossible to write a vaild program because any copy of a buffer pointer breaks the rules.
proposals/0010-vk-buffer-ref.md
Outdated
@@ -163,6 +163,16 @@ A vk::BufferPointer can otherwise be used whereever the HLSL spec does not other | |||
|
|||
Applying HLSL semantic annotations to objects of type vk::BufferPointer is disallowed. | |||
|
|||
### Buffer Pointers and Aliasing | |||
|
|||
All buffer pointers are considered restricted pointers. In other words, given two different objects of buffer pointer type, it is assumed that their pointees do not overlap by default. |
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.
In other words, given two different objects of buffer pointer type, it is assumed that their pointees do not overlap by default.
This definition is too general. I think you need to define something like the "base", as you mentioned in #42 (comment).
The WGSL spec does this well. The call it the "root identifier" instead.
Don't try to stick too close to the spir-v aliasing rules. They need to be updated: https://gitlab.khronos.org/spirv/SPIR-V/-/issues/731
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.
You might also simply reference the C standard for the definition of restrict to make it more precise.
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.
Firstly, sorry for the delayed response. I will try to respond in a more timely fashion going forward.
I think this needs to be expanded a little. As stated, it would be nearly impossible to write a valid program because any copy of a buffer pointer breaks the rules.
It is not having copies of pointers that breaks the rules. It is dereferencing the copies in a way that depends on them overlapping that breaks the rules.
So my question is: is there a useful graphics shader that cannot be written when disallowing aliasing between "different" pointer values?
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.
If we decide that allowing aliasing between "different" pointer values is necessary, then I would allow aliasing only in the following cases:
-
Dereferences from the same named pointer variable or member of a named buffer.
-
Dereferences from a cast of the same named uint64_t variable or member of a named buffer to the same buffer pointer type.
-
Create an attribute vk::aliased which can be applied to a variable or member. Any dereferences from such pointers are assumed to be aliased.
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 think we are talking past each other. In general, I think we agree on what should happen, we just disagree that the current wording captures what you want. I find the single sentence
In other words, given two different objects of buffer pointer type, it is assumed that their pointees do not overlap by default.
to simplistic to capture a concept that the C standard felt needed to be must more involved. See https://en.cppreference.com/w/c/language/restrict.
I would suggest you ignore my first comment in this thread, and do the second one. Reference the C99 standard of the restrict type qualifier to define restrict.
Something like
By default, buffer pointers are assumed to be restrict pointers as defined by the C99 standard.
should be good enough.
@llvm-beanz Anything else needed here? |
proposals/0010-vk-buffer-ref.md
Outdated
|
||
### Buffer Pointers and Address Space | ||
|
||
All buffer pointers are presumed to point into the same address space. No new address space attributes are proposed. |
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.
Which address space? The default address space in HLSL is thread-local memory, which I assume isn't where these are expected to refer. I assume these are host memory, so we should state that explicitly.
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.
Done. @llvm-beanz PTAL
Fixes #42.