From ca2618f4b632bf4b357a539a8fb7dafc99b35976 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Oct 2010 21:17:41 -0600 Subject: mesa: implement integer-valued vertex attribute functions The integers still get converted to floats. That'll have to change someday. --- src/mesa/vbo/vbo_attrib_tmp.h | 201 ++++++++++++++++++++++++++++++++++++++++++ src/mesa/vbo/vbo_exec_api.c | 18 ++++ src/mesa/vbo/vbo_save_api.c | 18 ++++ 3 files changed, 237 insertions(+) (limited to 'src/mesa/vbo') diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h index e680631383..3c235accf3 100644 --- a/src/mesa/vbo/vbo_attrib_tmp.h +++ b/src/mesa/vbo/vbo_attrib_tmp.h @@ -25,6 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ +/* float */ #define ATTR1FV( A, V ) ATTR( A, 1, (V)[0], 0, 0, 1 ) #define ATTR2FV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3FV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) @@ -35,6 +36,27 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define ATTR3F( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) #define ATTR4F( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) +/* int */ +#define ATTR2IV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) +#define ATTR3IV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) +#define ATTR4IV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) + +#define ATTR1I( A, X ) ATTR( A, 1, X, 0, 0, 1 ) +#define ATTR2I( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 ) +#define ATTR3I( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) +#define ATTR4I( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) + + +/* uint */ +#define ATTR2UIV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) +#define ATTR3UIV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) +#define ATTR4UIV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) + +#define ATTR1UI( A, X ) ATTR( A, 1, X, 0, 0, 1 ) +#define ATTR2UI( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 ) +#define ATTR3UI( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) +#define ATTR4UI( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) + #define MAT_ATTR( A, N, V ) ATTR( A, N, (V)[0], (V)[1], (V)[2], (V)[3] ) @@ -407,6 +429,185 @@ TAG(VertexAttrib4fvARB)(GLuint index, const GLfloat * v) } + +/* Integer-valued generic attributes. + * XXX: the integers just get converted to floats at this time + */ +static void GLAPIENTRY +TAG(VertexAttribI1i)(GLuint index, GLint x) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR1I(0, x); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR1I(VBO_ATTRIB_GENERIC0 + index, x); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI2i)(GLuint index, GLint x, GLint y) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR2I(0, x, y); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR2I(VBO_ATTRIB_GENERIC0 + index, x, y); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR3I(0, x, y, z); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR3I(VBO_ATTRIB_GENERIC0 + index, x, y, z); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR4I(0, x, y, z, w); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR4I(VBO_ATTRIB_GENERIC0 + index, x, y, z, w); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI2iv)(GLuint index, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR2IV(0, v); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR2IV(VBO_ATTRIB_GENERIC0 + index, v); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI3iv)(GLuint index, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR3IV(0, v); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR3IV(VBO_ATTRIB_GENERIC0 + index, v); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI4iv)(GLuint index, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR4IV(0, v); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR4IV(VBO_ATTRIB_GENERIC0 + index, v); + else + ERROR(); +} + + + +/* Unsigned integer-valued generic attributes. + * XXX: the integers just get converted to floats at this time + */ +static void GLAPIENTRY +TAG(VertexAttribI1ui)(GLuint index, GLuint x) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR1UI(0, x); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR1UI(VBO_ATTRIB_GENERIC0 + index, x); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI2ui)(GLuint index, GLuint x, GLuint y) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR2UI(0, x, y); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR2UI(VBO_ATTRIB_GENERIC0 + index, x, y); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR3UI(0, x, y, z); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR3UI(VBO_ATTRIB_GENERIC0 + index, x, y, z); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR4UI(0, x, y, z, w); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR4UI(VBO_ATTRIB_GENERIC0 + index, x, y, z, w); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI2uiv)(GLuint index, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR2UIV(0, v); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR2UIV(VBO_ATTRIB_GENERIC0 + index, v); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI3uiv)(GLuint index, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR3UIV(0, v); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR3UIV(VBO_ATTRIB_GENERIC0 + index, v); + else + ERROR(); +} + +static void GLAPIENTRY +TAG(VertexAttribI4uiv)(GLuint index, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + if (index == 0) + ATTR4UIV(0, v); + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR4UIV(VBO_ATTRIB_GENERIC0 + index, v); + else + ERROR(); +} + + + /* In addition to supporting NV_vertex_program, these entrypoints are * used by the display list and other code specifically because of * their property of aliasing with other attributes. (See diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 1ef4917419..4988c51d44 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -658,6 +658,24 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) vfmt->VertexAttrib4fNV = vbo_VertexAttrib4fNV; vfmt->VertexAttrib4fvNV = vbo_VertexAttrib4fvNV; + /* integer-valued */ + vfmt->VertexAttribI1i = vbo_VertexAttribI1i; + vfmt->VertexAttribI2i = vbo_VertexAttribI2i; + vfmt->VertexAttribI3i = vbo_VertexAttribI3i; + vfmt->VertexAttribI4i = vbo_VertexAttribI4i; + vfmt->VertexAttribI2iv = vbo_VertexAttribI2iv; + vfmt->VertexAttribI3iv = vbo_VertexAttribI3iv; + vfmt->VertexAttribI4iv = vbo_VertexAttribI4iv; + + /* unsigned integer-valued */ + vfmt->VertexAttribI1ui = vbo_VertexAttribI1ui; + vfmt->VertexAttribI2ui = vbo_VertexAttribI2ui; + vfmt->VertexAttribI3ui = vbo_VertexAttribI3ui; + vfmt->VertexAttribI4ui = vbo_VertexAttribI4ui; + vfmt->VertexAttribI2uiv = vbo_VertexAttribI2uiv; + vfmt->VertexAttribI3uiv = vbo_VertexAttribI3uiv; + vfmt->VertexAttribI4uiv = vbo_VertexAttribI4uiv; + vfmt->Materialfv = vbo_Materialfv; vfmt->EdgeFlag = vbo_EdgeFlag; diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 19c4b15d5f..cb0d9fc8f0 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1065,6 +1065,24 @@ static void _save_vtxfmt_init( struct gl_context *ctx ) vfmt->VertexAttrib4fNV = _save_VertexAttrib4fNV; vfmt->VertexAttrib4fvNV = _save_VertexAttrib4fvNV; + /* integer-valued */ + vfmt->VertexAttribI1i = _save_VertexAttribI1i; + vfmt->VertexAttribI2i = _save_VertexAttribI2i; + vfmt->VertexAttribI3i = _save_VertexAttribI3i; + vfmt->VertexAttribI4i = _save_VertexAttribI4i; + vfmt->VertexAttribI2iv = _save_VertexAttribI2iv; + vfmt->VertexAttribI3iv = _save_VertexAttribI3iv; + vfmt->VertexAttribI4iv = _save_VertexAttribI4iv; + + /* unsigned integer-valued */ + vfmt->VertexAttribI1ui = _save_VertexAttribI1ui; + vfmt->VertexAttribI2ui = _save_VertexAttribI2ui; + vfmt->VertexAttribI3ui = _save_VertexAttribI3ui; + vfmt->VertexAttribI4ui = _save_VertexAttribI4ui; + vfmt->VertexAttribI2uiv = _save_VertexAttribI2uiv; + vfmt->VertexAttribI3uiv = _save_VertexAttribI3uiv; + vfmt->VertexAttribI4uiv = _save_VertexAttribI4uiv; + /* This will all require us to fallback to saving the list as opcodes: */ _MESA_INIT_DLIST_VTXFMT(vfmt, _save_); /* inside begin/end */ -- cgit v1.2.3