diff options
Diffstat (limited to 'source/blender/gpu/opengl/gl_batch.hh')
-rw-r--r-- | source/blender/gpu/opengl/gl_batch.hh | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/gpu/opengl/gl_batch.hh b/source/blender/gpu/opengl/gl_batch.hh index 704b6471dd5..a2b5f8fc15e 100644 --- a/source/blender/gpu/opengl/gl_batch.hh +++ b/source/blender/gpu/opengl/gl_batch.hh @@ -43,9 +43,11 @@ class GLShaderInterface; #define GPU_VAO_STATIC_LEN 3 -/* VAO management: remembers all geometry state (vertex attribute bindings & element buffer) - * for each shader interface. Start with a static number of vaos and fallback to dynamic count - * if necessary. Once a batch goes dynamic it does not go back. */ +/** + * 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. + */ class GLVaoCache { private: /** Context for which the vao_cache_ was generated. */ @@ -80,13 +82,23 @@ class GLVaoCache { GLuint vao_get(GPUBatch *batch); GLuint base_instance_vao_get(GPUBatch *batch, int i_first); + /** + * Return 0 on cache miss (invalid VAO). + */ GLuint lookup(const GLShaderInterface *interface); + /** + * Create a new VAO object and store it in the cache. + */ void insert(const GLShaderInterface *interface, GLuint vao_id); void remove(const GLShaderInterface *interface); void clear(void); private: void init(void); + /** + * The #GLVaoCache object is only valid for one #GLContext. + * Reset the cache if trying to draw in another context;. + */ void context_check(void); }; @@ -100,6 +112,7 @@ class GLBatch : public Batch { void bind(int i_first); /* Convenience getters. */ + GLIndexBuf *elem_(void) const { return static_cast<GLIndexBuf *>(unwrap(elem)); |