Skip to content
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

Merged
merged 4 commits into from
Sep 1, 2023

Conversation

greg-lunarg
Copy link
Contributor

Fixes #42.

Copy link
Collaborator

@s-perron s-perron left a 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.

@@ -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.
Copy link
Collaborator

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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:

  1. Dereferences from the same named pointer variable or member of a named buffer.

  2. Dereferences from a cast of the same named uint64_t variable or member of a named buffer to the same buffer pointer type.

  3. Create an attribute vk::aliased which can be applied to a variable or member. Any dereferences from such pointers are assumed to be aliased.

Copy link
Collaborator

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.

@greg-lunarg
Copy link
Contributor Author

@llvm-beanz Anything else needed here?


### Buffer Pointers and Address Space

All buffer pointers are presumed to point into the same address space. No new address space attributes are proposed.
Copy link
Collaborator

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.

Copy link
Contributor Author

@greg-lunarg greg-lunarg Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. @llvm-beanz PTAL

@llvm-beanz llvm-beanz merged commit cbd3fdb into microsoft:main Sep 1, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[0010] What pointer annotations do we need to expose? (address space, aliasing)
3 participants