aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw/draw_vertex.h
diff options
context:
space:
mode:
authorJakob Bornecrantz <[email protected]>2010-03-25 00:18:30 +0100
committerJakob Bornecrantz <[email protected]>2010-03-26 01:21:52 +0100
commit84a8347b9f6ef0c1b2519e9bd5fef2ce3c85afb7 (patch)
tree69faa69e239d4295b7f058475b625be9764ef6f9 /src/gallium/auxiliary/draw/draw_vertex.h
parentbc88c95990f871a206a8fe93e7541f1f41841f7e (diff)
draw: Use translate function instead of switch cases
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_vertex.h')
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/draw/draw_vertex.h
index 8c3c7befbc7..24c5a48b2ef 100644
--- a/src/gallium/auxiliary/draw/draw_vertex.h
+++ b/src/gallium/auxiliary/draw/draw_vertex.h
@@ -141,9 +141,11 @@ void draw_dump_emitted_vertex(const struct vertex_info *vinfo,
const uint8_t *data);
-static INLINE unsigned draw_translate_vinfo_format(unsigned format )
+static INLINE unsigned draw_translate_vinfo_format(enum attrib_emit emit)
{
- switch (format) {
+ switch (emit) {
+ case EMIT_OMIT:
+ return PIPE_FORMAT_NONE;
case EMIT_1F:
case EMIT_1F_PSIZE:
return PIPE_FORMAT_R32_FLOAT;
@@ -156,9 +158,31 @@ static INLINE unsigned draw_translate_vinfo_format(unsigned format )
case EMIT_4UB:
return PIPE_FORMAT_R8G8B8A8_UNORM;
default:
+ assert(!"unexpected format");
return PIPE_FORMAT_NONE;
}
}
+static INLINE unsigned draw_translate_vinfo_size(enum attrib_emit emit)
+{
+ switch (emit) {
+ case EMIT_OMIT:
+ return 0;
+ case EMIT_1F:
+ case EMIT_1F_PSIZE:
+ return 1 * sizeof(float);
+ case EMIT_2F:
+ return 2 * sizeof(float);
+ case EMIT_3F:
+ return 3 * sizeof(float);
+ case EMIT_4F:
+ return 4 * sizeof(float);
+ case EMIT_4UB:
+ return 4 * sizeof(unsigned char);
+ default:
+ assert(!"unexpected format");
+ return 0;
+ }
+}
#endif /* DRAW_VERTEX_H */