Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/opengl/gl_batch.hh')
-rw-r--r--source/blender/gpu/opengl/gl_batch.hh49
1 files changed, 36 insertions, 13 deletions
diff --git a/source/blender/gpu/opengl/gl_batch.hh b/source/blender/gpu/opengl/gl_batch.hh
index 290c113205a..490c9180a99 100644
--- a/source/blender/gpu/opengl/gl_batch.hh
+++ b/source/blender/gpu/opengl/gl_batch.hh
@@ -37,18 +37,29 @@
namespace blender {
namespace gpu {
-#define GPU_BATCH_VAO_STATIC_LEN 3
+#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. */
class GLVaoCache {
- /* 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. */
+ private:
+ /** Context for which the vao_cache_ was generated. */
+ struct GLContext *context_ = NULL;
+ /** Last interface this batch was drawn with. */
+ GPUShaderInterface *interface_ = NULL;
+ /** Cached vao for the last interface. */
+ GLuint vao_id_ = 0;
+ /** Used whend arb_base_instance is not supported. */
+ GLuint vao_base_instance_ = 0;
+ int base_instance_ = 0;
+
bool is_dynamic_vao_count = false;
union {
/** Static handle count */
struct {
- const GPUShaderInterface *interfaces[GPU_BATCH_VAO_STATIC_LEN];
- GLuint vao_ids[GPU_BATCH_VAO_STATIC_LEN];
+ const GPUShaderInterface *interfaces[GPU_VAO_STATIC_LEN];
+ GLuint vao_ids[GPU_VAO_STATIC_LEN];
} static_vaos;
/** Dynamic handle count */
struct {
@@ -58,18 +69,27 @@ class GLVaoCache {
} dynamic_vaos;
};
- GLuint search(const GPUShaderInterface *interface);
- void insert(GLuint vao_id, const GPUShaderInterface *interface);
+ public:
+ GLVaoCache();
+ ~GLVaoCache();
+
+ GLuint vao_get(GPUBatch *batch);
+ GLuint base_instance_vao_get(GPUBatch *batch, int i_first);
+
+ GLuint lookup(const GPUShaderInterface *interface);
+ void insert(const GPUShaderInterface *interface, GLuint vao_id);
+ void remove(const GPUShaderInterface *interface);
void clear(void);
- void interface_remove(const GPUShaderInterface *interface);
+
+ private:
+ void init(void);
+ void context_check(void);
};
class GLBatch : public Batch {
- private:
- /** Cached values (avoid dereferencing later). */
- GLuint vao_id;
+ public:
/** All vaos corresponding to all the GPUShaderInterface this batch was drawn with. */
- GLVaoCache vaos;
+ GLVaoCache vao_cache_;
public:
GLBatch();
@@ -77,6 +97,9 @@ class GLBatch : public Batch {
void draw(int v_first, int v_count, int i_first, int i_count) override;
+ private:
+ void bind(int i_first);
+
MEM_CXX_CLASS_ALLOC_FUNCS("GLBatch");
};