32 if (!buffer_.is_allocated()) {
34 if (!buffer_.is_allocated()) {
35 CLOG_ERROR(&
LOG,
"Unable to allocate index buffer. Most likely an out of memory issue.");
40 if (data_ ==
nullptr) {
44 if (!data_uploaded_ && buffer_.is_mapped()) {
45 buffer_.update_immediately(data_);
46 MEM_SAFE_DELETE_VOID(data_);
57 buffer_.clear(context, 0u);
60 "Unable to upload data to index buffer via a staging buffer as the staging buffer "
61 "could not be allocated. Index buffer will be filled with on zeros to reduce "
62 "drawing artifacts due to read from uninitialized memory.");
63 buffer_.clear(context, 0u);
65 MEM_SAFE_DELETE_VOID(data_);
68 data_uploaded_ =
true;
79 src_->bind_as_ssbo(binding);
98 "Unable to read data from index buffer via a staging buffer as the staging buffer "
99 "could not be allocated. ");
105 if (!buffer_.is_allocated()) {
109 BLI_assert_msg(start +
len <= buffer_.size_in_bytes(),
"Out of bound write to index buffer");
110 if (buffer_.is_mapped()) {
111 buffer_.update_sub_immediately(start,
len,
data);
122 uint source_first_index,
123 uint dest_first_index,
130 "Index type mismatch between source and destination");
132 "Copy source range exceeds the source index buffer bounds");
134 "Copy destination range exceeds the destination index buffer bounds");
135 BLI_assert_msg(buffer_.is_allocated(),
"GPU_indexbuf_use() not called on this buffer");
145 context.render_graph().add_node(copy_buffer);
148void VKIndexBuffer::strip_restart_indices()
153void VKIndexBuffer::allocate()
155 VkBufferUsageFlags vk_buffer_usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
156 VK_BUFFER_USAGE_INDEX_BUFFER_BIT |
157 VK_BUFFER_USAGE_TRANSFER_DST_BIT |
158 VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
160 vk_buffer_usage |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR |
161 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
166 VMA_MEMORY_USAGE_AUTO,
167 VmaAllocationCreateFlags(0),
173const VKBuffer &VKIndexBuffer::buffer_get()
const
177VKBuffer &VKIndexBuffer::buffer_get()
#define CLOG_ERROR(clg_ref,...)
#define BLI_assert_msg(a, msg)
GPUIndexBufType index_type_
void update_immediately(const void *data) const
bool is_allocated() const
void read(VKContext &context, void *data) const
bool create(size_t size, VkBufferUsageFlags buffer_usage, VmaMemoryUsage vma_memory_usage, VmaAllocationCreateFlags vma_allocation_flags, float priority, bool export_memory=false, const char *debug_name="VKBuffer", size_t alignment=0)
const VKResourceWithHandle< VkBuffer > & resource() const
void * mapped_memory_get() const
VKStateManager & state_manager_get() const
void read(uint32_t *data) const override
void update_sub(uint start, uint len, const void *data) override
void copy_sub(IndexBuf &source_buf, uint source_first_index, uint dest_first_index, uint index_len) override
Copy part of source index buffer into this index buffer.
void upload_data() override
void bind_as_ssbo(uint binding) override
void copy_from_device(VKContext &context)
VKBuffer & host_buffer_get()
void copy_to_device(VKContext &context)
void storage_buffer_bind(BindSpaceStorageBuffers::Type resource_type, void *resource, int binding)
VKCopyBufferData CreateInfo
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
BLI_INLINE MTLTexture * unwrap(Texture *tex)
int to_bytesize(const DataFormat format)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
BMesh const char void * data
VKResourceWithHandle< VkBuffer > dst_buffer
VKResourceWithHandle< VkBuffer > src_buffer
#define NOT_YET_IMPLEMENTED