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:
authorMike Erwin <significant.bit@gmail.com>2017-05-22 01:25:30 +0300
committerMike Erwin <significant.bit@gmail.com>2017-05-22 01:25:30 +0300
commit23035cf46fb4dd6a0bf7e688b0f15128030c77d1 (patch)
tree0bb6a50e84ff6a15e0ca53d8ed0f6cc555f36169 /intern/gawain
parent054eb9422ca5bfea460229374cd8986d297f74c8 (diff)
Gawain: remove GLenum from IndexType API
Goal is to make most of the API independent of OpenGL, Vulkan, any other backend. Able to remove default case from ElementList_size because IndexType only covers index types. Not that and *everything else* like GLenum.
Diffstat (limited to 'intern/gawain')
-rw-r--r--intern/gawain/gawain/element.h7
-rw-r--r--intern/gawain/src/batch.c8
-rw-r--r--intern/gawain/src/element.c17
3 files changed, 20 insertions, 12 deletions
diff --git a/intern/gawain/gawain/element.h b/intern/gawain/gawain/element.h
index fde395ce898..0e2ece1d2f1 100644
--- a/intern/gawain/gawain/element.h
+++ b/intern/gawain/gawain/element.h
@@ -16,15 +16,16 @@
#define TRACK_INDEX_RANGE 1
typedef enum {
- INDEX_U8 = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not
- INDEX_U16 = GL_UNSIGNED_SHORT,
- INDEX_U32 = GL_UNSIGNED_INT
+ INDEX_U8, // GL has this, Vulkan does not
+ INDEX_U16,
+ INDEX_U32
} IndexType;
typedef struct {
unsigned index_ct;
#if TRACK_INDEX_RANGE
IndexType index_type;
+ GLenum gl_index_type;
unsigned min_index;
unsigned max_index;
unsigned base_index;
diff --git a/intern/gawain/src/batch.c b/intern/gawain/src/batch.c
index 5067a567f55..059de41ab3e 100644
--- a/intern/gawain/src/batch.c
+++ b/intern/gawain/src/batch.c
@@ -273,9 +273,9 @@ void Batch_draw(Batch* batch)
#if TRACK_INDEX_RANGE
if (el->base_index)
- glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->index_type, 0, el->base_index);
+ glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->gl_index_type, 0, el->base_index);
else
- glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->index_type, 0);
+ glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->gl_index_type, 0);
#else
glDrawElements(batch->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0);
#endif
@@ -310,9 +310,9 @@ void Batch_draw_stupid(Batch* batch)
#if TRACK_INDEX_RANGE
if (el->base_index)
- glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->index_type, 0, el->base_index);
+ glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->gl_index_type, 0, el->base_index);
else
- glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->index_type, 0);
+ glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->gl_index_type, 0);
#else
glDrawElements(batch->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0);
#endif
diff --git a/intern/gawain/src/element.c b/intern/gawain/src/element.c
index f27f3a6c43a..1346be024e3 100644
--- a/intern/gawain/src/element.c
+++ b/intern/gawain/src/element.c
@@ -15,6 +15,16 @@
#define KEEP_SINGLE_COPY 1
+static GLenum convert_index_type_to_gl(IndexType type)
+ {
+ static const GLenum table[] = {
+ [INDEX_U8] = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not
+ [INDEX_U16] = GL_UNSIGNED_SHORT,
+ [INDEX_U32] = GL_UNSIGNED_INT
+ };
+ return table[type];
+ }
+
unsigned ElementList_size(const ElementList* elem)
{
#if TRACK_INDEX_RANGE
@@ -23,11 +33,6 @@ unsigned ElementList_size(const ElementList* elem)
case INDEX_U8: return elem->index_ct * sizeof(GLubyte);
case INDEX_U16: return elem->index_ct * sizeof(GLushort);
case INDEX_U32: return elem->index_ct * sizeof(GLuint);
- default:
- #if TRUST_NO_ONE
- assert(false);
- #endif
- return 0;
}
#else
@@ -252,6 +257,8 @@ void ElementList_build_in_place(ElementListBuilder* builder, ElementList* elem)
elem->data = builder->data;
}
+
+ elem->gl_index_type = convert_index_type_to_gl(elem->index_type);
#else
if (builder->index_ct < builder->max_index_ct)
{