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:
authorClément Foucault <foucault.clem@gmail.com>2020-08-11 02:31:40 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-08-13 15:20:24 +0300
commitefc97b3919ea4fd46b9d2e931ca3fea27e7ea31c (patch)
tree125e4239c90902a967487f44d5aca1696d49be68 /source/blender/gpu/opengl/gl_batch.hh
parent47bfb0f7ad2f70017585fe55a68e49ae09f1150c (diff)
GPUBatch: GL backend isolation
This changes the drawing paradigm a bit. The VAO configuration is done JIT-style and depends on context active shader. This is to allow more flexibility for implementations to do optimization at lower level. The vao cache is now its own class to isolate the concept. It is this class that is reference by the GLContext for ownership of the containing VAO ids.
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");
};