44 void GLVaoCache::init()
48 is_dynamic_vao_count =
false;
53 vao_base_instance_ = 0;
61 if (!is_dynamic_vao_count) {
82 is_dynamic_vao_count =
true;
92 if (is_dynamic_vao_count) {
122 for (
int i = 0; i <
count; i++) {
140 if (context_ ==
nullptr) {
144 if (context_ == ctx) {
145 glDeleteVertexArrays(
count, vaos);
146 glDeleteVertexArrays(1, &vao_base_instance_);
150 for (
int i = 0; i <
count; i++) {
153 context_->
vao_free(vao_base_instance_);
156 for (
int i = 0; i <
count; i++) {
162 if (is_dynamic_vao_count) {
179 for (
int i = 0; i <
count; i++) {
187 void GLVaoCache::context_check()
192 if (context_ != ctx) {
193 if (context_ !=
nullptr) {
206 this->context_check();
210 if (interface_ != interface) {
220 glDeleteVertexArrays(1, &vao_base_instance_);
221 vao_base_instance_ = 0;
225 if (vao_base_instance_ == 0) {
226 glGenVertexArrays(1, &vao_base_instance_);
229 if (base_instance_ != i_first) {
230 base_instance_ = i_first;
233 return vao_base_instance_;
238 this->context_check();
242 if (interface_ != interface) {
243 interface_ = interface;
244 vao_id_ = this->
lookup(interface_);
248 glGenVertexArrays(1, &vao_id_);
249 this->
insert(interface_, vao_id_);
272 #if GPU_TRACK_INDEX_RANGE
275 glPrimitiveRestartIndex(this->
elem_()->restart_index());
296 GLenum gl_type =
to_gl(prim_type);
305 glDrawElementsInstancedBaseVertexBaseInstance(
306 gl_type, v_count, index_type, v_first_ofs, i_count, base_index, i_first);
309 glDrawElementsInstancedBaseVertex(
310 gl_type, v_count, index_type, v_first_ofs, i_count, base_index);
318 glDrawArraysInstancedBaseInstance(gl_type, v_first, v_count, i_count, i_first);
321 glDrawArraysInstanced(gl_type, v_first, v_count, i_count);
#define 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
static bool base_instance_support
static bool fixed_restart_index_support
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
GLuint base_instance_vao_get(GPUBatch *batch, int i_first)
struct blender::gpu::GLVaoCache::@687::@689 static_vaos
GLuint lookup(const GLShaderInterface *interface)
const GLShaderInterface * interfaces[GPU_VAO_STATIC_LEN]
void insert(const GLShaderInterface *interface, GLuint vao_id)
GLuint vao_get(GPUBatch *batch)
struct blender::gpu::GLVaoCache::@687::@690 dynamic_vaos
void remove(const GLShaderInterface *interface)
GPUIndexBufType index_type_
ShaderInterface * interface
virtual void apply_state()=0
#define GPU_VAO_STATIC_LEN
#define GL_CHECK_RESOURCES(info)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void update_bindings(const GLuint vao, const GPUBatch *batch, const ShaderInterface *interface, int base_instance)
static GLenum to_gl(const GPUAttachmentType type)