vbo: pass only either uint32_t or uint64_t into ATTR_UNION

This makes the next commit possible.

Reviewed-by: Mathias Fröhlich <mathias.froehlich@web.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3766>
This commit is contained in:
Marek Olšák
2020-01-24 22:17:09 -05:00
committed by Marge Bot
parent afa7f1984a
commit cd7241c4f8
3 changed files with 23 additions and 8 deletions
+14
View File
@@ -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.
*
+8 -7
View File
@@ -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)
+1 -1
View File
@@ -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) \