Skip to content

Commit

Permalink
[0010] Allow casting to uint64_t
Browse files Browse the repository at this point in the history
We have decided to allow casting to uint64_t. It will make create
more opportunities for developers to make mistakes, but they do not
have to use it. The implementation cost does not seem too high.

Fixes microsoft#93
  • Loading branch information
s-perron committed Dec 4, 2023
1 parent 7e3d166 commit 1089a2b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions proposals/0010-vk-buffer-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ This new type will have the following operations
syntax vk::BufferPointer<T,A>(u).
* A buffer pointer can be cast to a bool. If so, it returns FALSE if the
pointer is null, TRUE otherwise.
* A buffer pointer can be cast to a uint64_t. The cast will return the 64-bit
address that the pointer points to.

Note the operations that are not allowed:

Expand All @@ -120,8 +122,12 @@ Note the operations that are not allowed:
* The comparison operators == and != are not supported for buffer pointers.

Most of these restrictions are there for safety. They minimize the possibility
of getting an invalid pointer. If the Get() method is used on a null or invalid
pointer, the behaviour is undefined.
of getting an invalid pointer. If a buffer pointer is cast to and from a
uint64_t, then it is the responsibility of the user to make sure that a valid
pointer is generated, and that aliasing rules are followed.

If the Get() method is used on a null or invalid pointer, the behaviour is
undefined.

When used as a member in a buffer, vk::BufferPointer can be used to pass
physical buffer addresses into a shader, and address and access buffer space
Expand Down

0 comments on commit 1089a2b

Please sign in to comment.