From cd7241c4f8082dbd07f0bcd268741c527512c66b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 24 Jan 2020 22:17:09 -0500 Subject: [PATCH] vbo: pass only either uint32_t or uint64_t into ATTR_UNION MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This makes the next commit possible. Reviewed-by: Mathias Fröhlich Part-of: --- src/mesa/main/macros.h | 14 ++++++++++++++ src/mesa/vbo/vbo_attrib_tmp.h | 15 ++++++++------- src/mesa/vbo/vbo_exec_api.c | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 03a228b4474..8b09e7b20e9 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -194,6 +194,20 @@ static inline fi_type FLOAT_AS_UNION(GLfloat f) return tmp; } +static inline uint64_t DOUBLE_AS_UINT64(double d) +{ + union { + double d; + uint64_t u64; + } tmp; + tmp.d = d; + return tmp.u64; +} + +/* First sign-extend x, then return uint32_t. */ +#define INT_AS_UINT(x) ((uint32_t)((int32_t)(x))) +#define FLOAT_AS_UINT(x) (FLOAT_AS_UNION(x).u) + /** * Convert a floating point value to an unsigned fixed point value. * diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h index ff3304b8458..b2dd82e7482 100644 --- a/src/mesa/vbo/vbo_attrib_tmp.h +++ b/src/mesa/vbo/vbo_attrib_tmp.h @@ -32,16 +32,17 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* ATTR */ #define ATTRI( A, N, V0, V1, V2, V3 ) \ - ATTR_UNION(A, N, GL_INT, fi_type, INT_AS_UNION(V0), INT_AS_UNION(V1), \ - INT_AS_UNION(V2), INT_AS_UNION(V3)) + ATTR_UNION(A, N, GL_INT, uint32_t, INT_AS_UINT(V0), INT_AS_UINT(V1), \ + INT_AS_UINT(V2), INT_AS_UINT(V3)) #define ATTRUI( A, N, V0, V1, V2, V3 ) \ - ATTR_UNION(A, N, GL_UNSIGNED_INT, fi_type, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \ - UINT_AS_UNION(V2), UINT_AS_UNION(V3)) + ATTR_UNION(A, N, GL_UNSIGNED_INT, uint32_t, (uint32_t)(V0), (uint32_t)(V1), \ + (uint32_t)(V2), (uint32_t)(V3)) #define ATTRF( A, N, V0, V1, V2, V3 ) \ - ATTR_UNION(A, N, GL_FLOAT, fi_type, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\ - FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3)) + ATTR_UNION(A, N, GL_FLOAT, uint32_t, FLOAT_AS_UINT(V0), FLOAT_AS_UINT(V1),\ + FLOAT_AS_UINT(V2), FLOAT_AS_UINT(V3)) #define ATTRD( A, N, V0, V1, V2, V3 ) \ - ATTR_UNION(A, N, GL_DOUBLE, double, V0, V1, V2, V3) + ATTR_UNION(A, N, GL_DOUBLE, uint64_t, DOUBLE_AS_UINT64(V0), \ + DOUBLE_AS_UINT64(V1), DOUBLE_AS_UINT64(V2), DOUBLE_AS_UINT64(V3)) #define ATTRUI64( A, N, V0, V1, V2, V3 ) \ ATTR_UNION(A, N, GL_UNSIGNED_INT64_ARB, uint64_t, V0, V1, V2, V3) diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 0361546972d..59408c06819 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -460,7 +460,7 @@ is_vertex_position(const struct gl_context *ctx, GLuint index) * \param A VBO_ATTRIB_x attribute index * \param N attribute size (1..4) * \param T type (GL_FLOAT, GL_DOUBLE, GL_INT, GL_UNSIGNED_INT) - * \param C cast type (fi_type or double) + * \param C cast type (uint32_t or uint64_t) * \param V0, V1, v2, V3 attribute value */ #define ATTR_UNION(A, N, T, C, V0, V1, V2, V3) \ -- 2.30.2