Blender
V3.3
|
#include <gl_batch.hh>
VAO Cache | |
Each #GLBatch has a small cache of VAO objects that are used to avoid VAO reconfiguration. TODO(fclem): Could be revisited to avoid so much cross references. | |
GLVaoCache () | |
~GLVaoCache () | |
GLuint | vao_get (GPUBatch *batch) |
GLuint | base_instance_vao_get (GPUBatch *batch, int i_first) |
GLuint | lookup (const GLShaderInterface *interface) |
void | insert (const GLShaderInterface *interface, GLuint vao_id) |
void | remove (const GLShaderInterface *interface) |
void | clear () |
VAO management: remembers all geometry state (vertex attribute bindings & element buffer) for each shader interface. Start with a static number of VAO's and fallback to dynamic count if necessary. Once a batch goes dynamic it does not go back.
Definition at line 35 of file gl_batch.hh.
GLVaoCache::GLVaoCache | ( | ) |
Definition at line 34 of file gl_batch.cc.
GLVaoCache::~GLVaoCache | ( | ) |
Definition at line 39 of file gl_batch.cc.
References clear().
GLuint GLVaoCache::base_instance_vao_get | ( | GPUBatch * | batch, |
int | i_first | ||
) |
There seems to be a nasty bug when drawing using the same VAO reconfiguring (T71147). We just use a throwaway VAO for that. Note that this is likely to degrade performance.
Definition at line 204 of file gl_batch.cc.
References batch, blender::gpu::GLContext::get(), blender::gpu::Shader::interface, blender::gpu::Context::shader, blender::gpu::GLVertArray::update_bindings(), and vao_get().
Referenced by blender::gpu::GLBatch::bind().
void GLVaoCache::clear | ( | ) |
Definition at line 132 of file gl_batch.cc.
References count, dynamic_vaos, blender::gpu::GLContext::get(), GPU_VAO_STATIC_LEN, if(), interfaces, MEM_freeN, static_vaos, blender::gpu::GLContext::vao_cache_unregister(), and blender::gpu::GLContext::vao_free().
Referenced by blender::gpu::GLBatch::bind(), and ~GLVaoCache().
void GLVaoCache::insert | ( | const GLShaderInterface * | interface, |
GLuint | vao_id | ||
) |
Create a new VAO object and store it in the cache.
Definition at line 58 of file gl_batch.cc.
References dynamic_vaos, GPU_BATCH_VAO_DYN_ALLOC_COUNT, GPU_VAO_STATIC_LEN, MEM_callocN, MEM_recallocN, static_vaos, and blender::gpu::GLContext::vao_free().
Referenced by vao_get().
GLuint GLVaoCache::lookup | ( | const GLShaderInterface * | interface | ) |
Return 0 on cache miss (invalid VAO).
Definition at line 174 of file gl_batch.cc.
References count, dynamic_vaos, GPU_VAO_STATIC_LEN, interfaces, and static_vaos.
Referenced by vao_get().
void GLVaoCache::remove | ( | const GLShaderInterface * | interface | ) |
Definition at line 116 of file gl_batch.cc.
References count, dynamic_vaos, GPU_VAO_STATIC_LEN, interfaces, static_vaos, and blender::gpu::GLContext::vao_free().
GLuint GLVaoCache::vao_get | ( | GPUBatch * | batch | ) |
Definition at line 236 of file gl_batch.cc.
References batch, blender::gpu::GLContext::get(), insert(), blender::gpu::Shader::interface, lookup(), blender::gpu::Context::shader, and blender::gpu::GLVertArray::update_bindings().
Referenced by base_instance_vao_get(), and blender::gpu::GLBatch::bind().
uint blender::gpu::GLVaoCache::count |
Definition at line 56 of file gl_batch.hh.
struct { ... } blender::gpu::GLVaoCache::dynamic_vaos |
const GLShaderInterface* blender::gpu::GLVaoCache::interfaces[GPU_VAO_STATIC_LEN] |
Definition at line 51 of file gl_batch.hh.
const GLShaderInterface** blender::gpu::GLVaoCache::interfaces |
Definition at line 57 of file gl_batch.hh.
struct { ... } blender::gpu::GLVaoCache::static_vaos |
GLuint blender::gpu::GLVaoCache::vao_ids[GPU_VAO_STATIC_LEN] |
Definition at line 52 of file gl_batch.hh.
GLuint* blender::gpu::GLVaoCache::vao_ids |
Definition at line 58 of file gl_batch.hh.