summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo/vbo_exec_eval.c
diff options
context:
space:
mode:
authorMarius Predut <[email protected]>2015-02-25 09:49:45 -0700
committerBrian Paul <[email protected]>2015-02-25 16:35:49 -0700
commit1a93e7690dc90211164082d6a2d26d93da8127ef (patch)
tree85dea0aa989370fbd767eec2b243e37c8892b6b5 /src/mesa/vbo/vbo_exec_eval.c
parent47053464630888f819ef8cc44278f1a1220159b9 (diff)
mesa: use fi_type in vertex attribute code
For 32-bit builds, floating point operations use x86 FPU registers, not SSE registers. If we're actually storing an integer in a float variable, the value might get modified when written to memory. This patch changes the VBO code to use the fi_type (float/int union) to store/copy vertex attributes. Also, this can improve performance on x86 because moving floats with integer registers instead of FP registers is faster. Neil Roberts review: - include changes on all places that are storing attribute values. - check with and without -O3 compiler flag. Brian Paul review: - use fi_type type instead gl_constant_value type - fix a bunch of nit-picks. - fix compiler warnings Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82668 Signed-off-by: Marius Predut <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_exec_eval.c')
-rw-r--r--src/mesa/vbo/vbo_exec_eval.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mesa/vbo/vbo_exec_eval.c b/src/mesa/vbo/vbo_exec_eval.c
index 82f89b95f74..409f31abf88 100644
--- a/src/mesa/vbo/vbo_exec_eval.c
+++ b/src/mesa/vbo/vbo_exec_eval.c
@@ -130,11 +130,12 @@ void vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u)
struct gl_1d_map *map = exec->eval.map1[attr].map;
if (map) {
GLfloat uu = (u - map->u1) * map->du;
- GLfloat data[4];
+ fi_type data[4];
- ASSIGN_4V(data, 0, 0, 0, 1);
+ ASSIGN_4V(data, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0),
+ FLOAT_AS_UNION(0), FLOAT_AS_UNION(1));
- _math_horner_bezier_curve(map->Points, data, uu,
+ _math_horner_bezier_curve(map->Points, &data[0].f, uu,
exec->eval.map1[attr].sz,
map->Order);
@@ -176,12 +177,13 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec,
if (map) {
GLfloat uu = (u - map->u1) * map->du;
GLfloat vv = (v - map->v1) * map->dv;
- GLfloat data[4];
+ fi_type data[4];
- ASSIGN_4V(data, 0, 0, 0, 1);
+ ASSIGN_4V(data, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0),
+ FLOAT_AS_UNION(0), FLOAT_AS_UNION(1));
_math_horner_bezier_surf(map->Points,
- data,
+ &data[0].f,
uu, vv,
exec->eval.map2[attr].sz,
map->Uorder, map->Vorder);
@@ -203,7 +205,7 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec,
ASSIGN_4V(vertex, 0, 0, 0, 1);
if (exec->ctx->Eval.AutoNormal) {
- GLfloat normal[4];
+ fi_type normal[4];
GLfloat du[4], dv[4];
_math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv,
@@ -221,11 +223,11 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec,
}
- CROSS3(normal, du, dv);
- NORMALIZE_3FV(normal);
- normal[3] = 1.0;
+ CROSS3(&normal[0].f, du, dv);
+ NORMALIZE_3FV(&normal[0].f);
+ normal[3] = FLOAT_AS_UNION(1.0);
- COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL],
+ COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL],
exec->vtx.attrsz[VBO_ATTRIB_NORMAL],
normal );