diff options
author | Marius Predut <[email protected]> | 2015-02-25 09:49:45 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2015-02-25 16:35:49 -0700 |
commit | 1a93e7690dc90211164082d6a2d26d93da8127ef (patch) | |
tree | 85dea0aa989370fbd767eec2b243e37c8892b6b5 /src/mesa/vbo/vbo_attrib_tmp.h | |
parent | 47053464630888f819ef8cc44278f1a1220159b9 (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_attrib_tmp.h')
-rw-r--r-- | src/mesa/vbo/vbo_attrib_tmp.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h index 0c44540fc74..b1c3d9842c8 100644 --- a/src/mesa/vbo/vbo_attrib_tmp.h +++ b/src/mesa/vbo/vbo_attrib_tmp.h @@ -28,6 +28,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "util/u_format_r11g11b10f.h" #include "main/varray.h" + +/* ATTR */ +#define ATTR( A, N, T, V0, V1, V2, V3 ) \ + ATTR_##T((A), (N), (T), (V0), (V1), (V2), (V3)) + +#define ATTR_GL_UNSIGNED_INT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \ + UINT_AS_UNION(V2), UINT_AS_UNION(V3)) +#define ATTR_GL_INT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, INT_AS_UNION(V0), INT_AS_UNION(V1), \ + INT_AS_UNION(V2), INT_AS_UNION(V3)) +#define ATTR_GL_FLOAT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\ + FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3)) + + /* float */ #define ATTR1FV( A, V ) ATTR( A, 1, GL_FLOAT, (V)[0], 0, 0, 1 ) #define ATTR2FV( A, V ) ATTR( A, 2, GL_FLOAT, (V)[0], (V)[1], 0, 1 ) @@ -41,8 +57,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* int */ #define ATTRI( A, N, X, Y, Z, W) ATTR( A, N, GL_INT, \ - INT_AS_FLT(X), INT_AS_FLT(Y), \ - INT_AS_FLT(Z), INT_AS_FLT(W) ) + X, Y, Z, W ) #define ATTR2IV( A, V ) ATTRI( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3IV( A, V ) ATTRI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) @@ -56,8 +71,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* uint */ #define ATTRUI( A, N, X, Y, Z, W) ATTR( A, N, GL_UNSIGNED_INT, \ - UINT_AS_FLT(X), UINT_AS_FLT(Y), \ - UINT_AS_FLT(Z), UINT_AS_FLT(W) ) + X, Y, Z, W ) #define ATTR2UIV( A, V ) ATTRUI( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3UIV( A, V ) ATTRUI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) |