From 6941510bb3b088297302bd2f3a4f61b784bf4b14 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Fri, 1 Dec 2023 13:51:16 -0500 Subject: [PATCH] [0010] Allow casting to uint64_t 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 https://github.com/microsoft/hlsl-specs/issues/93 --- proposals/0010-vk-buffer-ref.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/proposals/0010-vk-buffer-ref.md b/proposals/0010-vk-buffer-ref.md index cf1536b7..abdba7d2 100644 --- a/proposals/0010-vk-buffer-ref.md +++ b/proposals/0010-vk-buffer-ref.md @@ -109,6 +109,8 @@ This new type will have the following operations syntax vk::BufferPointer(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: @@ -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