From 6cd2d55a7bee289f20670cb97258d73911dac781 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 13 Aug 2011 15:30:38 +0100 Subject: [PATCH] mesa/varray: add interface support for ARB_vertex_type_2_10_10_10_rev (v2) This just adds all the API check for vertex arrays using 2101010 types. 2101010 is also useable with GL_BGRA. v2: fix whitespace. Signed-off-by: Dave Airlie Reviewed-by: Eric Anholt --- src/mesa/main/varray.c | 45 +++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 29a345f9425..9c9d0d66ea9 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -59,6 +59,8 @@ #define DOUBLE_BIT 0x200 #define FIXED_ES_BIT 0x400 #define FIXED_GL_BIT 0x800 +#define UNSIGNED_INT_2_10_10_10_REV_BIT 0x1000 +#define INT_2_10_10_10_REV_BIT 0x2000 /** Convert GL datatype enum into a _BIT value seen above */ @@ -91,6 +93,10 @@ type_to_bit(const struct gl_context *ctx, GLenum type) return DOUBLE_BIT; case GL_FIXED: return ctx->API == API_OPENGL ? FIXED_GL_BIT : FIXED_ES_BIT; + case GL_UNSIGNED_INT_2_10_10_10_REV: + return UNSIGNED_INT_2_10_10_10_REV_BIT; + case GL_INT_2_10_10_10_REV: + return INT_2_10_10_10_REV_BIT; default: return 0; } @@ -135,6 +141,10 @@ update_array(struct gl_context *ctx, if (!ctx->Extensions.ARB_ES2_compatibility) { legalTypesMask &= ~FIXED_GL_BIT; } + if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) { + legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); + } typeBit = type_to_bit(ctx, type); if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) { @@ -150,7 +160,10 @@ update_array(struct gl_context *ctx, if (ctx->Extensions.EXT_vertex_array_bgra && sizeMax == BGRA_OR_4 && size == GL_BGRA) { - if (type != GL_UNSIGNED_BYTE) { + if (type != GL_UNSIGNED_BYTE && + (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev && + (type != GL_UNSIGNED_INT_2_10_10_10_REV && + type != GL_INT_2_10_10_10_REV))) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(GL_BGRA/GLubyte)", func); return; } @@ -162,6 +175,12 @@ update_array(struct gl_context *ctx, return; } + if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev && + (type == GL_UNSIGNED_INT_2_10_10_10_REV || + type == GL_INT_2_10_10_10_REV) && size != 4) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=%d)", func, size); + } + ASSERT(size <= 4); if (stride < 0) { @@ -201,7 +220,9 @@ void GLAPIENTRY _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { GLbitfield legalTypes = (SHORT_BIT | INT_BIT | FLOAT_BIT | - DOUBLE_BIT | HALF_BIT | FIXED_ES_BIT); + DOUBLE_BIT | HALF_BIT | FIXED_ES_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -220,7 +241,9 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) { const GLbitfield legalTypes = (BYTE_BIT | SHORT_BIT | INT_BIT | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | - FIXED_ES_BIT); + FIXED_ES_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -238,7 +261,9 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) SHORT_BIT | UNSIGNED_SHORT_BIT | INT_BIT | UNSIGNED_INT_BIT | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | - FIXED_ES_BIT); + FIXED_ES_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -285,7 +310,9 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | SHORT_BIT | UNSIGNED_SHORT_BIT | INT_BIT | UNSIGNED_INT_BIT | - HALF_BIT | FLOAT_BIT | DOUBLE_BIT); + HALF_BIT | FLOAT_BIT | DOUBLE_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -302,7 +329,9 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, { GLbitfield legalTypes = (SHORT_BIT | INT_BIT | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | - FIXED_ES_BIT); + FIXED_ES_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); const GLuint unit = ctx->Array.ActiveTexture; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -408,7 +437,9 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, SHORT_BIT | UNSIGNED_SHORT_BIT | INT_BIT | UNSIGNED_INT_BIT | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | - FIXED_ES_BIT | FIXED_GL_BIT); + FIXED_ES_BIT | FIXED_GL_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); -- 2.30.2