57 dst->buffer_texture_ =
nullptr;
59 if (
src->vbo_id_ != 0) {
60 dst->vbo_size_ =
src->size_used_get();
62 glGenBuffers(1, &dst->vbo_id_);
63 glBindBuffer(GL_COPY_WRITE_BUFFER, dst->vbo_id_);
64 glBufferData(GL_COPY_WRITE_BUFFER, dst->vbo_size_,
nullptr,
to_gl(dst->
usage_));
66 glBindBuffer(GL_COPY_READ_BUFFER,
src->vbo_id_);
68 glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, dst->vbo_size_);
73 if (
data !=
nullptr) {
88 glGenBuffers(1, &vbo_id_);
91 glBindBuffer(GL_ARRAY_BUFFER, vbo_id_);
96 glBufferData(GL_ARRAY_BUFFER, vbo_size_,
nullptr,
to_gl(
usage_));
99 glBufferSubData(GL_ARRAY_BUFFER, 0, vbo_size_,
data);
115 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, binding, vbo_id_);
122 if (buffer_texture_ ==
nullptr) {
131 void *
result = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
138 memcpy(
result, mapped_data, vbo_size_);
147 vbo_id_ =
static_cast<uint>(handle);
152 bool GLVertBuf::is_active()
const
157 int active_vbo_id = 0;
158 glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &active_vbo_id);
159 return vbo_id_ == active_vbo_id;
164 glBufferSubData(GL_ARRAY_BUFFER, start,
len,
data);
GPUTexture * GPU_texture_create_from_vertbuf(const char *name, struct GPUVertBuf *vert)
#define GPU_TEXTURE_FREE_SAFE(texture)
void GPU_texture_bind(GPUTexture *tex, int unit)
@ GPU_VERTBUF_DATA_UPLOADED
#define MEM_reallocN(vmemh, len)
static void buf_free(GLuint buf_id)
void bind_as_texture(uint binding) override
void upload_data() override
void * unmap(const void *mapped_data) const override
void bind_as_ssbo(uint binding) override
void wrap_handle(uint64_t handle) override
void duplicate_data(VertBuf *dst) override
void resize_data() override
void update_sub(uint start, uint len, const void *data) override
void acquire_data() override
const void * read() const override
void release_data() override
size_t size_used_get() const
size_t size_alloc_get() const
static size_t memory_usage
SyclQueue void void * src
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
static GPUContext * wrap(Context *ctx)
static GLenum to_gl(const GPUAttachmentType type)
unsigned __int64 uint64_t