[Bf-blender-cvs] [7419656] blender2.8: Gawain: new immSkipAttrib function
Mike Erwin
noreply at git.blender.org
Sun Oct 16 08:09:46 CEST 2016
Commit: 741965615dfc5a56c1e35fa5e50c3ef228471352
Author: Mike Erwin
Date: Sun Oct 16 01:58:26 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB741965615dfc5a56c1e35fa5e50c3ef228471352
Gawain: new immSkipAttrib function
Now you can explicitly skip a vertex attribute -- you don't give it a value and it won't get a copy of the previous vert's value. Useful for flat interpolated per-primitive values.
This is an advanced feature. Expect garbage in the empty spaces, and copies of garbage if you rely on the attrib copy behavior after skipping.
===================================================================
M source/blender/gpu/gawain/immediate.c
M source/blender/gpu/gawain/immediate.h
===================================================================
diff --git a/source/blender/gpu/gawain/immediate.c b/source/blender/gpu/gawain/immediate.c
index 6c4f3f0..f8d851e 100644
--- a/source/blender/gpu/gawain/immediate.c
+++ b/source/blender/gpu/gawain/immediate.c
@@ -592,6 +592,17 @@ void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4])
immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]);
}
+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
+#endif
+
+ setAttribValueBit(attrib_id);
+ }
+
static void immEndVertex(void) // and move on to the next vertex
{
#if TRUST_NO_ONE
@@ -619,6 +630,7 @@ static void immEndVertex(void) // and move on to the next vertex
GLubyte* data = imm.vertex_data + a->offset;
memcpy(data, data - imm.vertex_format.stride, a->sz);
+ // TODO: consolidate copy of adjacent attributes
}
}
}
diff --git a/source/blender/gpu/gawain/immediate.h b/source/blender/gpu/gawain/immediate.h
index d71532b..e0764dc 100644
--- a/source/blender/gpu/gawain/immediate.h
+++ b/source/blender/gpu/gawain/immediate.h
@@ -54,6 +54,10 @@ void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned
void immAttrib3ubv(unsigned attrib_id, const unsigned char data[4]);
void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]);
+// explicitly skip an attribute
+// this advanced option kills automatic value copying for this attrib_id
+void immSkipAttrib(unsigned attrib_id);
+
// provide one last attribute value & end the current vertex
// this is most often used for 2D or 3D position (similar to glVertex)
More information about the Bf-blender-cvs
mailing list