GPU: Add assert on zero sized VBOs

These can create GL errors that are not reported
appropriately.
This commit is contained in:
Clément Foucault
2024-08-07 16:30:46 +02:00
parent e7c20e99df
commit 04ae9ffd7f
2 changed files with 2 additions and 1 deletions

View File

@@ -215,7 +215,6 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
GPU_vertbuf_data_resize(*handle->buf, target_buf_size);
}
GPU_vertbuf_data_len_set(*handle->buf, vert_len);
GPU_vertbuf_use(handle->buf); /* Send data. */
}
}
/* Finish pending instancing batches. */

View File

@@ -93,6 +93,8 @@ void GLVertBuf::bind()
if (flag & GPU_VERTBUF_DATA_DIRTY) {
vbo_size_ = this->size_used_get();
BLI_assert(vbo_size_ != 0);
/* Orphan the vbo to avoid sync then upload data. */
glBufferData(GL_ARRAY_BUFFER, ceil_to_multiple_ul(vbo_size_, 16), nullptr, to_gl(usage_));
/* Do not transfer data from host to device when buffer is device only. */