-
Concept: VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT
-
What It Is
- A Vulkan buffer usage flag that enables GPU-side pointer access
- Allows shaders to access buffer data via a raw 64-bit GPU address
- Required for: Shader Binding Table, AS input buffers, AS scratch buffers
- Extension:
VK_KHR_buffer_device_address (core in Vulkan 1.2)
-
Why It’s Needed for Ray Tracing
- Acceleration structure build inputs must be specified as device addresses
- SBT entries contain shader handles accessed via device address
- Allows the GPU to follow pointers — enables complex data structures on GPU
- Without it: can’t build BLAS/TLAS or create SBT
-
How to Use
- Buffer creation
- Memory allocation — must enable device address feature
- Getting the device address
- Using in AS build
-
Device Address in Shaders
- GLSL: use
uint64_t or buffer reference extension
GL_EXT_buffer_reference — typed pointer to buffer
- This is how NVPathtracer accesses per-instance vertex data in closest-hit shader
-
Common Mistakes
- Forgetting
VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT on memory allocation
- Buffer creation succeeds but
vkGetBufferDeviceAddress returns 0
- Not enabling
bufferDeviceAddress feature in VkPhysicalDeviceVulkan12Features
- Using device address after buffer is destroyed
- Address becomes invalid — GPU will read garbage or crash