46void GLVaoCache::init()
50 is_dynamic_vao_count =
false;
55 vao_base_instance_ = 0;
63 if (!is_dynamic_vao_count) {
84 is_dynamic_vao_count =
true;
93 if (is_dynamic_vao_count) {
125 context_->vao_free(vaos[
i]);
133 interface_ =
nullptr;
146 if (context_ ==
nullptr) {
150 if (context_ == ctx) {
151 glDeleteVertexArrays(
count, vaos);
152 glDeleteVertexArrays(1, &vao_base_instance_);
157 context_->vao_free(vaos[
i]);
159 context_->vao_free(vao_base_instance_);
168 if (is_dynamic_vao_count) {
174 context_->vao_cache_unregister(
this);
193void GLVaoCache::context_check()
198 if (context_ != ctx) {
199 if (context_ !=
nullptr) {
212 this->context_check();
218 vao_id_ = this->
lookup(interface_);
222 glGenVertexArrays(1, &vao_id_);
223 this->
insert(interface_, vao_id_);
257 GLenum gl_type =
to_gl(prim_type);
265 glDrawElementsInstancedBaseVertexBaseInstance(
266 gl_type, v_count, index_type, v_first_ofs, i_count, base_index, i_first);
269 glDrawArraysInstancedBaseInstance(gl_type, v_first, v_count, i_count, i_first);
278 dynamic_cast<GLStorageBuf *
>(indirect_buf)->bind_as(GL_DRAW_INDIRECT_BUFFER);
280 GLenum gl_type =
to_gl(prim_type);
284 glDrawElementsIndirect(gl_type, index_type, (GLvoid *)offset);
287 glDrawArraysIndirect(gl_type, (GLvoid *)offset);
290 glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
301 dynamic_cast<GLStorageBuf *
>(indirect_buf)->bind_as(GL_DRAW_INDIRECT_BUFFER);
303 GLenum gl_type =
to_gl(prim_type);
307 glMultiDrawElementsIndirect(gl_type, index_type, (GLvoid *)offset,
count, stride);
310 glMultiDrawArraysIndirect(gl_type, (GLvoid *)offset,
count, stride);
313 glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
static constexpr int GPU_BATCH_VAO_DYN_ALLOC_COUNT
#define MEM_recallocN(vmemh, len)
StateManager * state_manager
GLIndexBuf * elem_() const
void draw(int v_first, int v_count, int i_first, int i_count) override
void multi_draw_indirect(StorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride) override
void draw_indirect(StorageBuf *indirect_buf, intptr_t offset) override
void vao_cache_unregister(GLVaoCache *cache)
void vao_cache_register(GLVaoCache *cache)
void * offset_ptr(uint additional_vertex_offset) const
GLuint lookup(const GLShaderInterface *interface)
const GLShaderInterface * interfaces[GPU_VAO_STATIC_LEN]
GLuint vao_get(Batch *batch)
void insert(const GLShaderInterface *interface, GLuint vao_id)
struct blender::gpu::GLVaoCache::@157236110271242160153365376064020364322222010350::@314007012112177177054114203301226370061215216002 static_vaos
struct blender::gpu::GLVaoCache::@157236110271242160153365376064020364322222010350::@162033253374111303027310313277133152141252374306 dynamic_vaos
void remove(const GLShaderInterface *interface)
GPUIndexBufType index_type_
virtual void apply_state()=0
#define GL_CHECK_RESOURCES(info)
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
#define GPU_VAO_STATIC_LEN
void update_bindings(const GLuint vao, const Batch *batch, const ShaderInterface *interface)
static GLenum to_gl(const GPUAttachmentType type)