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>2016-11-17 00:03:15 +0300
committerMike Erwin <significant.bit@gmail.com>2016-11-17 00:03:15 +0300
commitb1f700dad36c943c2c2a6f5477a4400cba5803f0 (patch)
tree780749d42f2455cd3f87af27eed4d6e785f0cf64 /source/blender/gpu/gawain/immediate.c
parent36ac979ee01f1a266e944a71272655f94ddcff52 (diff)
Gawain: use PRIM_ and INDEX_ enums instead of GLenum
For a few reasons: - separate enum sets for separate concepts - debug with symbolic names instead of 0x4e72 - prepare for a Vulkan future
Diffstat (limited to 'source/blender/gpu/gawain/immediate.c')
-rw-r--r--source/blender/gpu/gawain/immediate.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/source/blender/gpu/gawain/immediate.c b/source/blender/gpu/gawain/immediate.c
index 38da738dc16..72b1014061d 100644
--- a/source/blender/gpu/gawain/immediate.c
+++ b/source/blender/gpu/gawain/immediate.c
@@ -30,7 +30,7 @@ typedef struct {
unsigned buffer_bytes_mapped;
unsigned vertex_ct;
bool strict_vertex_ct;
- GLenum primitive;
+ PrimitiveType prim_type;
VertexFormat vertex_format;
@@ -70,7 +70,7 @@ void immInit()
glBufferParameteriAPPLE(GL_ARRAY_BUFFER, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE);
#endif
- imm.primitive = PRIM_NONE;
+ imm.prim_type = PRIM_NONE;
imm.strict_vertex_ct = true;
glBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -83,7 +83,7 @@ void immActivate()
{
#if TRUST_NO_ONE
assert(initialized);
- assert(imm.primitive == PRIM_NONE); // make sure we're not between a Begin/End pair
+ assert(imm.prim_type == PRIM_NONE); // make sure we're not between a Begin/End pair
assert(imm.vao_id == 0);
#endif
@@ -94,7 +94,7 @@ void immDeactivate()
{
#if TRUST_NO_ONE
assert(initialized);
- assert(imm.primitive == PRIM_NONE); // make sure we're not between a Begin/End pair
+ assert(imm.prim_type == PRIM_NONE); // make sure we're not between a Begin/End pair
assert(imm.vao_id != 0);
#endif
@@ -143,28 +143,28 @@ void immUnbindProgram()
imm.bound_program = 0;
}
-static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, GLenum primitive)
+static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, PrimitiveType prim_type)
{
// does vertex_ct make sense for this primitive type?
if (vertex_ct == 0)
return false;
- switch (primitive)
+ switch (prim_type)
{
- case GL_POINTS:
+ case PRIM_POINTS:
return true;
- case GL_LINES:
+ case PRIM_LINES:
return vertex_ct % 2 == 0;
- case GL_LINE_STRIP:
- case GL_LINE_LOOP:
+ case PRIM_LINE_STRIP:
+ case PRIM_LINE_LOOP:
return vertex_ct >= 2;
- case GL_TRIANGLES:
+ case PRIM_TRIANGLES:
return vertex_ct % 3 == 0;
- case GL_TRIANGLE_STRIP:
- case GL_TRIANGLE_FAN:
+ case PRIM_TRIANGLE_STRIP:
+ case PRIM_TRIANGLE_FAN:
return vertex_ct >= 3;
#ifdef WITH_GL_PROFILE_COMPAT
- case GL_QUADS:
+ case PRIM_QUADS:
return vertex_ct % 4 == 0;
#endif
default:
@@ -172,15 +172,15 @@ static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, GLenum pr
}
}
-void immBegin(GLenum primitive, unsigned vertex_ct)
+void immBegin(PrimitiveType prim_type, unsigned vertex_ct)
{
#if TRUST_NO_ONE
assert(initialized);
- assert(imm.primitive == PRIM_NONE); // make sure we haven't already begun
- assert(vertex_count_makes_sense_for_primitive(vertex_ct, primitive));
+ assert(imm.prim_type == PRIM_NONE); // make sure we haven't already begun
+ assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type));
#endif
- imm.primitive = primitive;
+ imm.prim_type = prim_type;
imm.vertex_ct = vertex_ct;
imm.vertex_idx = 0;
imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
@@ -232,27 +232,27 @@ void immBegin(GLenum primitive, unsigned vertex_ct)
imm.vertex_data = imm.buffer_data;
}
-void immBeginAtMost(GLenum primitive, unsigned vertex_ct)
+void immBeginAtMost(PrimitiveType prim_type, unsigned vertex_ct)
{
#if TRUST_NO_ONE
assert(vertex_ct > 0);
#endif
imm.strict_vertex_ct = false;
- immBegin(primitive, vertex_ct);
+ immBegin(prim_type, vertex_ct);
}
#if IMM_BATCH_COMBO
-Batch* immBeginBatch(GLenum prim_type, unsigned vertex_ct)
+Batch* immBeginBatch(PrimitiveType prim_type, unsigned vertex_ct)
{
#if TRUST_NO_ONE
assert(initialized);
- assert(imm.primitive == PRIM_NONE); // make sure we haven't already begun
+ assert(imm.prim_type == PRIM_NONE); // make sure we haven't already begun
assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type));
#endif
- imm.primitive = prim_type;
+ imm.prim_type = prim_type;
imm.vertex_ct = vertex_ct;
imm.vertex_idx = 0;
imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
@@ -271,7 +271,7 @@ Batch* immBeginBatch(GLenum prim_type, unsigned vertex_ct)
return imm.batch;
}
-Batch* immBeginBatchAtMost(GLenum prim_type, unsigned vertex_ct)
+Batch* immBeginBatchAtMost(PrimitiveType prim_type, unsigned vertex_ct)
{
imm.strict_vertex_ct = false;
return immBeginBatch(prim_type, vertex_ct);
@@ -341,7 +341,7 @@ static void immDrawSetup(void)
void immEnd()
{
#if TRUST_NO_ONE
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
unsigned buffer_bytes_used;
@@ -365,7 +365,7 @@ void immEnd()
else
{
#if TRUST_NO_ONE
- assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.primitive));
+ assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type));
#endif
imm.vertex_ct = imm.vertex_idx;
buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_ct);
@@ -404,7 +404,7 @@ void immEnd()
if (imm.vertex_ct > 0)
{
immDrawSetup();
- glDrawArrays(imm.primitive, 0, imm.vertex_ct);
+ glDrawArrays(imm.prim_type, 0, imm.vertex_ct);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -415,7 +415,7 @@ void immEnd()
}
// prep for next immBegin
- imm.primitive = PRIM_NONE;
+ imm.prim_type = PRIM_NONE;
imm.strict_vertex_ct = true;
}
@@ -442,7 +442,7 @@ void immAttrib1f(unsigned attrib_id, float x)
assert(attrib->comp_type == COMP_F32);
assert(attrib->comp_ct == 1);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -462,7 +462,7 @@ void immAttrib2f(unsigned attrib_id, float x, float y)
assert(attrib->comp_type == COMP_F32);
assert(attrib->comp_ct == 2);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -483,7 +483,7 @@ void immAttrib3f(unsigned attrib_id, float x, float y, float z)
assert(attrib->comp_type == COMP_F32);
assert(attrib->comp_ct == 3);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -505,7 +505,7 @@ void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w)
assert(attrib->comp_type == COMP_F32);
assert(attrib->comp_ct == 4);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -528,7 +528,7 @@ void immAttrib2i(unsigned attrib_id, int x, int y)
assert(attrib->comp_type == COMP_I32);
assert(attrib->comp_ct == 2);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -548,7 +548,7 @@ void immAttrib2s(unsigned attrib_id, short x, short y)
assert(attrib->comp_type == COMP_I16);
assert(attrib->comp_ct == 2);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -578,7 +578,7 @@ void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned
assert(attrib->comp_type == COMP_U8);
assert(attrib->comp_ct == 3);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -600,7 +600,7 @@ void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned
assert(attrib->comp_type == COMP_U8);
assert(attrib->comp_ct == 4);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -629,7 +629,7 @@ void immSkipAttrib(unsigned attrib_id)
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(imm.vertex_idx < imm.vertex_ct);
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
@@ -638,7 +638,7 @@ void immSkipAttrib(unsigned attrib_id)
static void immEndVertex(void) // and move on to the next vertex
{
#if TRUST_NO_ONE
- assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
+ assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
assert(imm.vertex_idx < imm.vertex_ct);
#endif