63 void GLVaoCache::init()
67 is_dynamic_vao_count =
false;
72 vao_base_instance_ = 0;
81 if (!is_dynamic_vao_count) {
102 is_dynamic_vao_count =
true;
112 if (is_dynamic_vao_count) {
142 for (
int i = 0; i <
count; i++) {
160 if (context_ ==
nullptr) {
164 if (context_ == ctx) {
165 glDeleteVertexArrays(
count, vaos);
166 glDeleteVertexArrays(1, &vao_base_instance_);
170 for (
int i = 0; i <
count; i++) {
173 context_->
vao_free(vao_base_instance_);
176 for (
int i = 0; i <
count; i++) {
182 if (is_dynamic_vao_count) {
200 for (
int i = 0; i <
count; i++) {
210 void GLVaoCache::context_check()
215 if (context_ != ctx) {
216 if (context_ !=
nullptr) {
229 this->context_check();
233 if (interface_ != interface) {
243 glDeleteVertexArrays(1, &vao_base_instance_);
244 vao_base_instance_ = 0;
248 if (vao_base_instance_ == 0) {
249 glGenVertexArrays(1, &vao_base_instance_);
252 if (base_instance_ != i_first) {
253 base_instance_ = i_first;
256 return vao_base_instance_;
261 this->context_check();
265 if (interface_ != interface) {
266 interface_ = interface;
267 vao_id_ = this->
lookup(interface_);
271 glGenVertexArrays(1, &vao_id_);
272 this->
insert(interface_, vao_id_);
294 #if GPU_TRACK_INDEX_RANGE
297 glPrimitiveRestartIndex(this->
elem_()->restart_index());
318 GLenum gl_type =
to_gl(prim_type);
327 glDrawElementsInstancedBaseVertexBaseInstance(
328 gl_type, v_count, index_type, v_first_ofs, i_count, base_index, i_first);
331 glDrawElementsInstancedBaseVertex(
332 gl_type, v_count, index_type, v_first_ofs, i_count, base_index);
340 glDrawArraysInstancedBaseInstance(gl_type, v_first, v_count, i_count, i_first);
343 glDrawArraysInstanced(gl_type, v_first, v_count, i_count);
#define GPU_BATCH_VAO_DYN_ALLOC_COUNT
#define MEM_recallocN(vmemh, len)
StateManager * state_manager
void draw(int v_first, int v_count, int i_first, int i_count) override
GLIndexBuf * elem_(void) const
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::@645::@647 static_vaos
struct blender::gpu::GLVaoCache::@645::@648 dynamic_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)
void remove(const GLShaderInterface *interface)
GPUIndexBufType index_type_
virtual void apply_state(void)=0
#define GPU_VAO_STATIC_LEN
#define GL_CHECK_RESOURCES(info)
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
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, const int base_instance)
static GLenum to_gl(const GPUAttachmentType type)