29 if (async_read_buffer_) {
30 MEM_delete(async_read_buffer_);
31 async_read_buffer_ =
nullptr;
39 if (!buffer_.is_allocated()) {
41 "Unable to upload data to storage buffer as the storage buffer could not be "
64 "Unable to upload data to storage buffer via a staging buffer as the staging buffer "
65 "could not be allocated. Storage buffer will be filled with on zeros to reduce "
66 "drawing artifacts due to read from uninitialized memory.");
67 buffer_.clear(context, 0u);
73 if (!buffer_.is_allocated()) {
78void VKStorageBuffer::allocate()
80 const VkBufferUsageFlags buffer_usage_flags = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT |
81 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
82 VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
83 VK_BUFFER_USAGE_TRANSFER_DST_BIT;
86 VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
87 VmaAllocationCreateFlags(0),
97 context.state_manager_get().storage_buffer_bind(
105 context->state_manager_get().storage_buffer_unbind(
this);
113 buffer_.clear(context, clear_value);
121 src_vertex_buffer.
upload();
126 copy_buffer.
region.srcOffset = src_offset;
127 copy_buffer.
region.dstOffset = dst_offset;
128 copy_buffer.
region.size = copy_size;
131 context.render_graph().add_node(copy_buffer);
136 if (async_read_buffer_ !=
nullptr) {
142 async_read_buffer_ = MEM_new<VKStagingBuffer>(
144 async_read_buffer_->copy_from_device(context);
145 async_read_buffer_->host_buffer_get().async_flush_to_host(context);
150 if (async_read_buffer_ ==
nullptr) {
155 async_read_buffer_->host_buffer_get().read_async(context,
data);
156 MEM_delete(async_read_buffer_);
157 async_read_buffer_ =
nullptr;
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
StorageBuf(size_t size, const char *name)
size_t usage_size_in_bytes_
char name_[DEBUG_NAME_LEN]
void update_immediately(const void *data) const
bool is_allocated() const
VkBuffer vk_handle() const
bool create(size_t size, VkBufferUsageFlags buffer_usage, VmaMemoryUsage vma_memory_usage, VmaAllocationCreateFlags vma_allocation_flags, float priority, bool export_memory=false)
const VkPhysicalDeviceProperties & physical_device_properties_get() const
VKBuffer & host_buffer_get()
void copy_to_device(VKContext &context)
void update(const void *data) override
VkBuffer vk_handle() const
void async_flush_to_host() override
void clear(uint32_t clear_value) override
void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size) override
void read(void *data) override
VKStorageBuffer(size_t size, GPUUsageType usage, const char *name)
void bind(int slot) override
VkDeviceSize update(VKContext &context, const void *data, size_t data_size)
VkBuffer vk_handle() const
VKCopyBufferData CreateInfo
void object_label(GLenum type, GLuint object, const char *name)
static Context * unwrap(GPUContext *ctx)