Skip to content

Specify aliasing and address space for vk::BufferPointer#53

Merged
llvm-beanz merged 4 commits into
microsoft:mainfrom
greg-lunarg:bp4
Sep 1, 2023
Merged

Specify aliasing and address space for vk::BufferPointer#53
llvm-beanz merged 4 commits into
microsoft:mainfrom
greg-lunarg:bp4

Conversation

@greg-lunarg
Copy link
Copy Markdown
Contributor

Fixes #42.

Copy link
Copy Markdown
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.

Comment thread proposals/0010-vk-buffer-ref.md Outdated

### 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@llvm-beanz Anything else needed here?

Comment thread 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.
Copy link
Copy Markdown
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
Copy Markdown
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
llvm-beanz pushed a commit to llvm-beanz/hlsl-specs that referenced this pull request Feb 9, 2025
* Specify aliasing and address space for vk::BufferPointer

Fixes microsoft#42.

* Refer to C99 for definition of restrict pointer.

* Explicitly specify buffer pointers point into host memory address space.
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