Skip to content

Instantly share code, notes, and snippets.

View martty's full-sized avatar
😶‍🌫️

Marcell Kiss martty

😶‍🌫️
View GitHub Profile
@martty
martty / gist:16409bf5215155294571113d928b3493
Last active September 7, 2022 16:13
buffer range / image subresource tagging

PROBLEM: when an application suballocates or reuses VkBuffers or VkImages, then the object itself may have no meaningful identity - but the current debug naming API vkSetDebugUtilsObjectNameEXT and friends can't name subresources or name objects on the device timeline.

PROPOSAL: provide an API way of naming parts of buffers and parts of images, that can eventually be used by validation and debugging tools to help give names that are relevant to the actual use.

SOLUTION SPACE: Buffers/images can be used via 1) API calls (vkCmdBlit), 2) bound to shaders (vkCmdBind...) 3) accessed in shaders via BDA (only buffers). Futhermore descriptorsets can be updated after binding or used via push descriptors.

There are 2 usecases identified which require subresource naming:

  • persistent identity subresources, where the application has suballocated from a buffer/image, but the identity of the subresource is tied to the host timeline. an example is suballocating a large buffer to hold the indices of a specific mesh - in
##
Validation Error: [ SYNC-HAZARD-READ_AFTER_WRITE ] Object 0: handle = 0x1d4aa4a1b60, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x4cb75b2d | vkCmdDrawIndexed: Hazard READ_AFTER_WRITE for vertex VkBuffer 0x1d4aa4a1b60[] in VkCommandBuffer 0x1d4aa737c60[]. Access info (usage: SYNC_VERTEX_ATTRIBUTE_INPUT_VERTEX_ATTRIBUTE_READ, prior_usage: SYNC_COPY_TRANSFER_WRITE, write_barriers: SYNC_INDEX_INPUT_INDEX_READ, command: vkCmdCopyBuffer, seq_no: 3, reset_no: 1).
##
Thread 0, Frame 0, Time 898204 us:
vkCmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions) returns void:
commandBuffer: VkCommandBuffer = 000001148FB44170
srcBuffer: VkBuffer = 00000114FE5F3F50 [Buffer (Pool { TransferSrc | TransferDst | UniformTexelBuffer | StorageTexelBuffer | UniformBuffer | StorageBuffer | IndexBuffer | VertexBuffer | IndirectBuffer | ShaderDeviceAddress })]
dstBuffer: VkBuffer = 00000114FE5F44D0 [Buffer (Pool { TransferSrc | TransferDst
#include <tuple>
#include <boost/config.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/seq/elem.hpp>
#include <boost/preprocessor/tuple/rem.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/repetition/enum.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <brigand/brigand.hpp>