summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-01-29 20:46:48 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-01-29 20:46:48 +0900
commit5022344c656c0e004222a0a77c98838e8ae0a1ac (patch)
tree9624d02d6098a4c4b8cb98d1a33c558e190931c4 /src/mesa
parent6f75de06ff2ea899b43b94236dbfbfaee12ba88c (diff)
gallium: Emit constants.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/draw/draw_vf.c10
-rw-r--r--src/mesa/pipe/draw/draw_vf.h22
-rw-r--r--src/mesa/pipe/draw/draw_vf_generic.c42
-rw-r--r--src/mesa/pipe/draw/draw_vf_sse.c4
4 files changed, 62 insertions, 16 deletions
diff --git a/src/mesa/pipe/draw/draw_vf.c b/src/mesa/pipe/draw/draw_vf.c
index 4fc2312ad1..958d31933b 100644
--- a/src/mesa/pipe/draw/draw_vf.c
+++ b/src/mesa/pipe/draw/draw_vf.c
@@ -182,6 +182,9 @@ unsigned draw_vf_set_vertex_attributes( struct draw_vertex_fetch *vf,
vf->attr[j].insert = draw_vf_format_info[format].insert;
vf->attr[j].vertattrsize = draw_vf_format_info[format].attrsize;
vf->attr[j].vertoffset = offset;
+ vf->attr[j].isconst = draw_vf_format_info[format].isconst;
+ if(vf->attr[j].isconst)
+ memcpy(vf->attr[j].data, &map[i].data, vf->attr[j].vertattrsize);
if (DBG)
_mesa_printf("%d: %s, offset %d\n", i,
@@ -240,8 +243,11 @@ void draw_vf_set_data( struct draw_vertex_fetch *vf,
for (j = 0; j < vf->attr_count; j++) {
a[j].inputstride = 0; /* XXX: one-vertex-max ATM */
a[j].inputsize = 4;
- a[j].do_insert = a[j].insert[4 - 1];
- a[j].inputptr = (uint8_t *)&data[a[j].attrib][0];
+ a[j].do_insert = a[j].insert[4 - 1];
+ if(a[j].isconst)
+ a[j].inputptr = a[j].data;
+ else
+ a[j].inputptr = (uint8_t *)&data[a[j].attrib][0];
}
}
diff --git a/src/mesa/pipe/draw/draw_vf.h b/src/mesa/pipe/draw/draw_vf.h
index c0fa063c52..911ea07bdf 100644
--- a/src/mesa/pipe/draw/draw_vf.h
+++ b/src/mesa/pipe/draw/draw_vf.h
@@ -48,14 +48,30 @@ enum draw_vf_attr_format {
DRAW_EMIT_4UB_4F_BGRA, /**< for color */
DRAW_EMIT_4UB_4F_ARGB, /**< for color */
DRAW_EMIT_4UB_4F_ABGR, /**< for color */
+ DRAW_EMIT_1F_CONST,
+ DRAW_EMIT_2F_CONST,
+ DRAW_EMIT_3F_CONST,
+ DRAW_EMIT_4F_CONST,
DRAW_EMIT_PAD, /**< leave a hole of 'offset' bytes */
DRAW_EMIT_MAX
};
-struct draw_vf_attr_map {
+struct draw_vf_attr_map
+{
+ /** Input attribute number */
unsigned attrib;
+
enum draw_vf_attr_format format;
+
unsigned offset;
+
+ /**
+ * Constant data for DRAW_EMIT_*_CONST
+ */
+ union {
+ uint8_t ub[4];
+ float f[4];
+ } data;
};
struct draw_vertex_fetch;
@@ -124,6 +140,9 @@ struct draw_vf_attr
unsigned inputsize;
unsigned inputstride;
unsigned vertoffset; /**< position of the attrib in the vertex struct */
+
+ boolean isconst; /**< read from const data below */
+ uint8_t data[16];
unsigned attrib; /**< which vertex attrib (0=position, etc) */
unsigned vertattrsize; /**< size of the attribute in bytes */
@@ -193,6 +212,7 @@ struct draw_vf_format_info {
const char *name;
draw_vf_insert_func insert[4];
const unsigned attrsize;
+ const boolean isconst;
};
extern const struct draw_vf_format_info
diff --git a/src/mesa/pipe/draw/draw_vf_generic.c b/src/mesa/pipe/draw/draw_vf_generic.c
index a16eb456b7..0caa798396 100644
--- a/src/mesa/pipe/draw/draw_vf_generic.c
+++ b/src/mesa/pipe/draw/draw_vf_generic.c
@@ -387,62 +387,78 @@ const struct draw_vf_format_info draw_vf_format_info[DRAW_EMIT_MAX] =
{
{ "1f",
{ insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 },
- sizeof(float) },
+ sizeof(float), FALSE },
{ "2f",
{ insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 },
- 2 * sizeof(float) },
+ 2 * sizeof(float), FALSE },
{ "3f",
{ insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 },
- 3 * sizeof(float) },
+ 3 * sizeof(float), FALSE },
{ "4f",
{ insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 },
- 4 * sizeof(float) },
+ 4 * sizeof(float), FALSE },
{ "3f_xyw",
{ insert_3f_xyw_err, insert_3f_xyw_err, insert_3f_xyw_err,
insert_3f_xyw_4 },
- 3 * sizeof(float) },
+ 3 * sizeof(float), FALSE },
{ "1ub_1f",
{ insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1 },
- sizeof(uint8_t) },
+ sizeof(uint8_t), FALSE },
{ "3ub_3f_rgb",
{ insert_3ub_3f_rgb_1, insert_3ub_3f_rgb_2, insert_3ub_3f_rgb_3,
insert_3ub_3f_rgb_3 },
- 3 * sizeof(uint8_t) },
+ 3 * sizeof(uint8_t), FALSE },
{ "3ub_3f_bgr",
{ insert_3ub_3f_bgr_1, insert_3ub_3f_bgr_2, insert_3ub_3f_bgr_3,
insert_3ub_3f_bgr_3 },
- 3 * sizeof(uint8_t) },
+ 3 * sizeof(uint8_t), FALSE },
{ "4ub_4f_rgba",
{ insert_4ub_4f_rgba_1, insert_4ub_4f_rgba_2, insert_4ub_4f_rgba_3,
insert_4ub_4f_rgba_4 },
- 4 * sizeof(uint8_t) },
+ 4 * sizeof(uint8_t), FALSE },
{ "4ub_4f_bgra",
{ insert_4ub_4f_bgra_1, insert_4ub_4f_bgra_2, insert_4ub_4f_bgra_3,
insert_4ub_4f_bgra_4 },
- 4 * sizeof(uint8_t) },
+ 4 * sizeof(uint8_t), FALSE },
{ "4ub_4f_argb",
{ insert_4ub_4f_argb_1, insert_4ub_4f_argb_2, insert_4ub_4f_argb_3,
insert_4ub_4f_argb_4 },
- 4 * sizeof(uint8_t) },
+ 4 * sizeof(uint8_t), FALSE },
{ "4ub_4f_abgr",
{ insert_4ub_4f_abgr_1, insert_4ub_4f_abgr_2, insert_4ub_4f_abgr_3,
insert_4ub_4f_abgr_4 },
- 4 * sizeof(uint8_t) },
+ 4 * sizeof(uint8_t), FALSE },
+
+ { "1f_const",
+ { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 },
+ sizeof(float), TRUE },
+
+ { "2f_const",
+ { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 },
+ 2 * sizeof(float), TRUE },
+
+ { "3f_const",
+ { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 },
+ 3 * sizeof(float), TRUE },
+
+ { "4f_const",
+ { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 },
+ 4 * sizeof(float), TRUE },
{ "pad",
{ NULL, NULL, NULL, NULL },
- 0 }
+ 0, FALSE },
};
diff --git a/src/mesa/pipe/draw/draw_vf_sse.c b/src/mesa/pipe/draw/draw_vf_sse.c
index 4036ded1d8..1389e6cfb9 100644
--- a/src/mesa/pipe/draw/draw_vf_sse.c
+++ b/src/mesa/pipe/draw/draw_vf_sse.c
@@ -388,18 +388,21 @@ static boolean build_vertex_emit( struct x86_program *p )
*/
switch (a->format) {
case DRAW_EMIT_1F:
+ case DRAW_EMIT_1F_CONST:
get_src_ptr(p, srcECX, vfESI, a);
emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
emit_store(p, dest, 1, temp);
update_src_ptr(p, srcECX, vfESI, a);
break;
case DRAW_EMIT_2F:
+ case DRAW_EMIT_2F_CONST:
get_src_ptr(p, srcECX, vfESI, a);
emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
emit_store(p, dest, 2, temp);
update_src_ptr(p, srcECX, vfESI, a);
break;
case DRAW_EMIT_3F:
+ case DRAW_EMIT_3F_CONST:
/* Potentially the worst case - hardcode 2+1 copying:
*/
if (0) {
@@ -423,6 +426,7 @@ static boolean build_vertex_emit( struct x86_program *p )
}
break;
case DRAW_EMIT_4F:
+ case DRAW_EMIT_4F_CONST:
get_src_ptr(p, srcECX, vfESI, a);
emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
emit_store(p, dest, 4, temp);