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/intern/gpu_shader_interface.cc
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/intern/gpu_shader_interface.cc')
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/gpu/intern/gpu_shader_interface.cc b/source/blender/gpu/intern/gpu_shader_interface.cc
index d825dde7e10..ef90dde1877 100644
--- a/source/blender/gpu/intern/gpu_shader_interface.cc
+++ b/source/blender/gpu/intern/gpu_shader_interface.cc
@@ -35,6 +35,8 @@
#include "gpu_batch_private.hh"
#include "gpu_context_private.hh"
+#include "gl_batch.hh"
+
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -45,6 +47,8 @@
# include <stdio.h>
#endif
+using namespace blender::gpu;
+
static const char *BuiltinUniform_name(GPUUniformBuiltin u)
{
switch (u) {
@@ -400,8 +404,8 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program)
/* Batches ref buffer */
shaderface->batches_len = GPU_SHADERINTERFACE_REF_ALLOC_COUNT;
- shaderface->batches = (GPUBatch **)MEM_callocN(shaderface->batches_len * sizeof(GPUBatch *),
- "GPUShaderInterface batches");
+ shaderface->batches = (void **)MEM_callocN(shaderface->batches_len * sizeof(GPUBatch *),
+ "GPUShaderInterface batches");
MEM_freeN(uniforms_from_blocks);
MEM_freeN(inputs_tmp);
@@ -468,7 +472,8 @@ void GPU_shaderinterface_discard(GPUShaderInterface *shaderface)
/* Remove this interface from all linked Batches vao cache. */
for (int i = 0; i < shaderface->batches_len; i++) {
if (shaderface->batches[i] != NULL) {
- gpu_batch_remove_interface_ref(shaderface->batches[i], shaderface);
+ /* XXX GL specific. to be removed during refactor. */
+ reinterpret_cast<GLVaoCache *>(shaderface->batches[i])->remove(shaderface);
}
}
MEM_freeN(shaderface->batches);
@@ -511,7 +516,7 @@ int32_t GPU_shaderinterface_block_builtin(const GPUShaderInterface *shaderface,
return shaderface->builtin_blocks[builtin];
}
-void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *shaderface, GPUBatch *batch)
+void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *shaderface, void *batch)
{
int i; /* find first unused slot */
for (i = 0; i < shaderface->batches_len; i++) {
@@ -523,13 +528,14 @@ void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *shaderface, GPUBatch
/* Not enough place, realloc the array. */
i = shaderface->batches_len;
shaderface->batches_len += GPU_SHADERINTERFACE_REF_ALLOC_COUNT;
- shaderface->batches = (GPUBatch **)MEM_recallocN(shaderface->batches,
- sizeof(GPUBatch *) * shaderface->batches_len);
+ shaderface->batches = (void **)MEM_recallocN(shaderface->batches,
+ sizeof(void *) * shaderface->batches_len);
}
- shaderface->batches[i] = batch;
+ /** XXX todo cleanup. */
+ shaderface->batches[i] = reinterpret_cast<void *>(batch);
}
-void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface *shaderface, GPUBatch *batch)
+void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface *shaderface, void *batch)
{
for (int i = 0; i < shaderface->batches_len; i++) {
if (shaderface->batches[i] == batch) {