Alright, so after some experimenting with the hint given by Spektre, I think I have a solution.
I've taken to representing a shape as:
struct Shape {
enum Kind : byte {
LineRect,
FillRect,
...
}
float2 position, extent;
uint color;
Kind kind;
}
The vertex shader takes that struct, and passes the entire thing along with the projection matrix to the geometry shader to generate the vertices. The geometry shader switches on kind
and emits the vertices for the shape, multiplying each vertex by the projection matrix.
This format requires 21 bytes (float
+ float
+ float
+ float
+ uint
+ byte
) to represent rects, circles, isosceles triangles, and possibly ellipses. I have reason to believe that textured rects is also possible, where color
is split into ushort[2]
for uv coordinates.