29 if (async_read_buffer_) {
30 MEM_delete(async_read_buffer_);
31 async_read_buffer_ =
nullptr;
48 "Unable to upload data to storage buffer via a staging buffer as the staging buffer "
49 "could not be allocated. Storage buffer will be filled with on zeros to reduce "
50 "drawing artifacts due to read from uninitialized memory.");
51 buffer_.clear(context, 0u);
57 if (!buffer_.is_allocated()) {
62void VKStorageBuffer::allocate()
64 const VkBufferUsageFlags buffer_usage_flags = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT |
65 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
66 VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
67 VK_BUFFER_USAGE_TRANSFER_DST_BIT;
70 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
71 VkMemoryPropertyFlags(0),
72 VmaAllocationCreateFlags(0),
81 context.state_manager_get().storage_buffer_bind(
89 context->state_manager_get().storage_buffer_unbind(
this);
97 buffer_.clear(context, clear_value);
105 src_vertex_buffer.
upload();
110 copy_buffer.
region.srcOffset = src_offset;
111 copy_buffer.
region.dstOffset = dst_offset;
112 copy_buffer.
region.size = copy_size;
115 context.render_graph().add_node(copy_buffer);
120 if (async_read_buffer_ !=
nullptr) {
126 async_read_buffer_ = MEM_new<VKStagingBuffer>(
128 async_read_buffer_->copy_from_device(context);
129 async_read_buffer_->host_buffer_get().async_flush_to_host(context);
134 if (async_read_buffer_ ==
nullptr) {
139 async_read_buffer_->host_buffer_get().read_async(context,
data);
140 MEM_delete(async_read_buffer_);
141 async_read_buffer_ =
nullptr;
#define CLOG_ERROR(clg_ref,...)
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
StorageBuf(size_t size, const char *name)
char name_[DEBUG_NAME_LEN]
void update_immediately(const void *data) const
bool is_allocated() const
bool create(size_t size, VkBufferUsageFlags buffer_usage, VkMemoryPropertyFlags required_flags, VkMemoryPropertyFlags preferred_flags, VmaAllocationCreateFlags vma_allocation_flags, float priority, bool export_memory=false)
VkBuffer vk_handle() 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
VkBuffer vk_handle() const
VKCopyBufferData CreateInfo
void object_label(GLenum type, GLuint object, const char *name)
static Context * unwrap(GPUContext *ctx)