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;
94 if (is_dynamic_vao_count) {
124 for (
int i = 0; i <
count; i++) {
133 if (interface_ == interface) {
134 interface_ =
nullptr;
147 if (context_ ==
nullptr) {
151 if (context_ == ctx) {
152 glDeleteVertexArrays(
count, vaos);
153 glDeleteVertexArrays(1, &vao_base_instance_);
157 for (
int i = 0; i <
count; i++) {
160 context_->
vao_free(vao_base_instance_);
163 for (
int i = 0; i <
count; i++) {
169 if (is_dynamic_vao_count) {
186 for (
int i = 0; i <
count; i++) {
194void GLVaoCache::context_check()
199 if (context_ != ctx) {
200 if (context_ !=
nullptr) {
213 this->context_check();
217 if (interface_ != interface) {
218 interface_ = interface;
219 vao_id_ = this->
lookup(interface_);
223 glGenVertexArrays(1, &vao_id_);
224 this->
insert(interface_, vao_id_);
243 flag &= ~GPU_BATCH_DIRTY;
258 GLenum gl_type =
to_gl(prim_type);
266 glDrawElementsInstancedBaseVertexBaseInstance(
267 gl_type, v_count, index_type, v_first_ofs, i_count, base_index, i_first);
270 glDrawArraysInstancedBaseInstance(gl_type, v_first, v_count, i_count, i_first);
281 GLenum gl_type =
to_gl(prim_type);
285 glDrawElementsIndirect(gl_type, index_type, (GLvoid *)offset);
288 glDrawArraysIndirect(gl_type, (GLvoid *)offset);
291 glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
304 GLenum gl_type =
to_gl(prim_type);
308 glMultiDrawElementsIndirect(gl_type, index_type, (GLvoid *)offset,
count, stride);
311 glMultiDrawArraysIndirect(gl_type, (GLvoid *)offset,
count, stride);
314 glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
#define GPU_BATCH_VAO_DYN_ALLOC_COUNT
#define MEM_recallocN(vmemh, len)
StateManager * state_manager
void multi_draw_indirect(GPUStorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride) override
GLIndexBuf * elem_() const
void draw(int v_first, int v_count, int i_first, int i_count) override
void draw_indirect(GPUStorageBuf *indirect_buf, intptr_t offset) override
void vao_cache_unregister(GLVaoCache *cache)
void vao_free(GLuint vao_id)
void vao_cache_register(GLVaoCache *cache)
void * offset_ptr(uint additional_vertex_offset) const
struct blender::gpu::GLVaoCache::@655::@657 static_vaos
GLuint lookup(const GLShaderInterface *interface)
struct blender::gpu::GLVaoCache::@655::@658 dynamic_vaos
const GLShaderInterface * interfaces[GPU_VAO_STATIC_LEN]
GLuint vao_get(Batch *batch)
void insert(const GLShaderInterface *interface, GLuint vao_id)
void remove(const GLShaderInterface *interface)
GPUIndexBufType index_type_
virtual void apply_state()=0
#define GL_CHECK_RESOURCES(info)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
#define GPU_VAO_STATIC_LEN
void update_bindings(const GLuint vao, const Batch *batch, const ShaderInterface *interface, int base_instance)
static Context * unwrap(GPUContext *ctx)
static GLenum to_gl(const GPUAttachmentType type)