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-09-06 03:46:51 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-06 23:13:06 +0300
commit4ea93029c65fd4cdb8b707494855120c0f792952 (patch)
treea02801daaaf0f0a4e1bb7be84d34e27759b32a36 /source/blender/gpu/opengl/gl_batch.cc
parent84d67bd0a937e842618ee7843958f3147ba6af58 (diff)
GPUIndexBuf: GL backend Isolation
This is part of the Vulkan backend task T68990. There is no real change, only making some code re-organisation. This also make the IndexBuf completely abstract from outside the GPU module.
Diffstat (limited to 'source/blender/gpu/opengl/gl_batch.cc')
-rw-r--r--source/blender/gpu/opengl/gl_batch.cc28
1 files changed, 8 insertions, 20 deletions
diff --git a/source/blender/gpu/opengl/gl_batch.cc b/source/blender/gpu/opengl/gl_batch.cc
index bb7d5654efd..c735d02500b 100644
--- a/source/blender/gpu/opengl/gl_batch.cc
+++ b/source/blender/gpu/opengl/gl_batch.cc
@@ -34,12 +34,14 @@
#include "gpu_batch_private.hh"
#include "gpu_shader_private.hh"
-#include "gl_batch.hh"
#include "gl_context.hh"
#include "gl_debug.hh"
+#include "gl_index_buffer.hh"
#include "gl_primitive.hh"
#include "gl_vertex_array.hh"
+#include "gl_batch.hh"
+
using namespace blender::gpu;
/* -------------------------------------------------------------------- */
@@ -295,14 +297,6 @@ GLBatch::~GLBatch()
/** \name Drawing
* \{ */
-#if GPU_TRACK_INDEX_RANGE
-# define BASE_INDEX(el) ((el)->base_index)
-# define INDEX_TYPE(el) ((el)->gl_index_type)
-#else
-# define BASE_INDEX(el) 0
-# define INDEX_TYPE(el) GL_UNSIGNED_INT
-#endif
-
void GLBatch::bind(int i_first)
{
GPU_context_active_get()->state_manager->apply_state();
@@ -315,7 +309,7 @@ void GLBatch::bind(int i_first)
#if GPU_TRACK_INDEX_RANGE
/* Can be removed if GL 4.3 is required. */
if (!GLEW_ARB_ES3_compatibility && (elem != NULL)) {
- glPrimitiveRestartIndex((elem->index_type == GPU_INDEX_U16) ? 0xFFFFu : 0xFFFFFFFFu);
+ glPrimitiveRestartIndex(this->gl_elem()->restart_index());
}
#endif
@@ -340,16 +334,10 @@ void GLBatch::draw(int v_first, int v_count, int i_first, int i_count)
GLenum gl_type = to_gl(prim_type);
if (elem) {
- const GPUIndexBuf *el = elem;
- GLenum index_type = INDEX_TYPE(el);
- GLint base_index = BASE_INDEX(el);
- void *v_first_ofs = (GLuint *)0 + v_first + el->index_start;
-
-#if GPU_TRACK_INDEX_RANGE
- if (el->index_type == GPU_INDEX_U16) {
- v_first_ofs = (GLushort *)0 + v_first + el->index_start;
- }
-#endif
+ const GLIndexBuf *el = this->gl_elem();
+ GLenum index_type = to_gl(el->index_type_);
+ GLint base_index = el->index_base_;
+ void *v_first_ofs = el->offset_ptr(v_first);
if (GPU_arb_base_instance_is_supported()) {
glDrawElementsInstancedBaseVertexBaseInstance(