27 const bool allocate_on_device = ibo_id_ == 0;
28 if (allocate_on_device) {
29 glGenBuffers(1, &ibo_id_);
32 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id_);
34 if (data_ !=
nullptr || allocate_on_device) {
37 glBufferData(GL_ELEMENT_ARRAY_BUFFER,
ceil_to_multiple_ul(size, 16),
nullptr, GL_STATIC_DRAW);
39 if (data_ !=
nullptr) {
41 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, size, data_);
44 MEM_SAFE_DELETE_VOID(data_);
51 src_->bind_as_ssbo(binding);
55 if (ibo_id_ == 0 || data_ !=
nullptr) {
69 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, binding, ibo_id_);
80 const void *buffer = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY);
82 glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
85bool GLIndexBuf::is_active()
const
90 int active_ibo_id = 0;
91 glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &active_ibo_id);
92 return ibo_id_ == active_ibo_id;
102 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, start,
len,
data);
106 uint source_first_index,
107 uint dest_first_index,
114 "Index type mismatch between source and destination");
116 "Copy source range exceeds the source index buffer bounds");
118 "Copy destination range exceeds the destination index buffer bounds");
119 BLI_assert_msg(ibo_id_,
"GPU_indexbuf_use() not called on this buffer");
120 BLI_assert_msg(src.ibo_id_,
"GPU_indexbuf_use() not called on the source buffer");
127 glCopyNamedBufferSubData(src.ibo_id_, ibo_id_, src_offset, dst_offset, copy_size);
130 glBindBuffer(GL_COPY_READ_BUFFER, src.ibo_id_);
131 glBindBuffer(GL_COPY_WRITE_BUFFER, ibo_id_);
133 GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, src_offset, dst_offset, copy_size);
134 glBindBuffer(GL_COPY_READ_BUFFER, 0);
135 glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
#define BLI_assert_msg(a, msg)
uint16_t bound_ssbo_slots
static void buffer_free(GLuint buf_id)
static bool direct_state_access_support
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 bind_as_ssbo(uint binding) override
void update_sub(uint start, uint len, const void *data) override
void upload_data() override
void read(uint32_t *data) const override
GPUIndexBufType index_type_
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
int to_bytesize(const DataFormat format)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE uint64_t ceil_to_multiple_ul(uint64_t a, uint64_t b)
BMesh const char void * data