From 8fc156ef3fe342f3f23598ce00ae163bd1cc5349 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 7 Dec 2010 21:33:53 +0800 Subject: [PATCH] vbo: Fix GLES2 glVertexAttrib. Attribute 0 has no special meaning in GLES2. Add VertexAttrib4f_nopos for that purpose and make _es_VertexAttrib* call the new function. Rename _vbo_* to _es_* to avoid confusion. --- src/mesa/main/APIspec.xml | 52 ++++++++++++++++++++-------------------- src/mesa/vbo/vbo.h | 26 ++++++++++---------- src/mesa/vbo/vbo_exec_api.c | 56 ++++++++++++++++++++++++++---------------- 3 files changed, 74 insertions(+), 60 deletions(-) diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml index 4dc0b0d..16d0c94 100644 --- a/src/mesa/main/APIspec.xml +++ b/src/mesa/main/APIspec.xml @@ -3536,7 +3536,7 @@ - + @@ -3554,8 +3554,8 @@ - - + + @@ -3650,7 +3650,7 @@ - + @@ -3679,7 +3679,7 @@ - + @@ -3691,14 +3691,14 @@ - - - - - - - - + + + + + + + + @@ -3850,7 +3850,7 @@ - + @@ -3880,8 +3880,8 @@ - - + + @@ -4012,7 +4012,7 @@ - + @@ -4039,7 +4039,7 @@ - + @@ -4227,14 +4227,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 7b8da8e..c1406b2 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -128,42 +128,42 @@ void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func); void GLAPIENTRY -_vbo_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); +_es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); void GLAPIENTRY -_vbo_Normal3f(GLfloat x, GLfloat y, GLfloat z); +_es_Normal3f(GLfloat x, GLfloat y, GLfloat z); void GLAPIENTRY -_vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +_es_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); void GLAPIENTRY -_vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params); +_es_Materialfv(GLenum face, GLenum pname, const GLfloat *params); void GLAPIENTRY -_vbo_Materialf(GLenum face, GLenum pname, GLfloat param); +_es_Materialf(GLenum face, GLenum pname, GLfloat param); void GLAPIENTRY -_vbo_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +_es_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void GLAPIENTRY -_vbo_VertexAttrib1f(GLuint indx, GLfloat x); +_es_VertexAttrib1f(GLuint indx, GLfloat x); void GLAPIENTRY -_vbo_VertexAttrib1fv(GLuint indx, const GLfloat* values); +_es_VertexAttrib1fv(GLuint indx, const GLfloat* values); void GLAPIENTRY -_vbo_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); +_es_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); void GLAPIENTRY -_vbo_VertexAttrib2fv(GLuint indx, const GLfloat* values); +_es_VertexAttrib2fv(GLuint indx, const GLfloat* values); void GLAPIENTRY -_vbo_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); +_es_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); void GLAPIENTRY -_vbo_VertexAttrib3fv(GLuint indx, const GLfloat* values); +_es_VertexAttrib3fv(GLuint indx, const GLfloat* values); void GLAPIENTRY -_vbo_VertexAttrib4fv(GLuint indx, const GLfloat* values); +_es_VertexAttrib4fv(GLuint indx, const GLfloat* values); #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 29cd425..fb981cc 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -972,35 +972,35 @@ static void reset_attrfv( struct vbo_exec_context *exec ) void GLAPIENTRY -_vbo_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) +_es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { vbo_Color4f(r, g, b, a); } void GLAPIENTRY -_vbo_Normal3f(GLfloat x, GLfloat y, GLfloat z) +_es_Normal3f(GLfloat x, GLfloat y, GLfloat z) { vbo_Normal3f(x, y, z); } void GLAPIENTRY -_vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +_es_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) { vbo_MultiTexCoord4f(target, s, t, r, q); } void GLAPIENTRY -_vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params) +_es_Materialfv(GLenum face, GLenum pname, const GLfloat *params) { vbo_Materialfv(face, pname, params); } void GLAPIENTRY -_vbo_Materialf(GLenum face, GLenum pname, GLfloat param) +_es_Materialf(GLenum face, GLenum pname, GLfloat param) { GLfloat p[4]; p[0] = param; @@ -1009,57 +1009,71 @@ _vbo_Materialf(GLenum face, GLenum pname, GLfloat param) } +/** + * A special version of glVertexAttrib4f that does not treat index 0 as + * VBO_ATTRIB_POS. + */ +static void +VertexAttrib4f_nopos(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + ATTR(VBO_ATTRIB_GENERIC0 + index, 4, x, y, z, w); + else + ERROR(); +} + void GLAPIENTRY -_vbo_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +_es_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - vbo_VertexAttrib4fARB(index, x, y, z, w); + VertexAttrib4f_nopos(index, x, y, z, w); } void GLAPIENTRY -_vbo_VertexAttrib1f(GLuint indx, GLfloat x) +_es_VertexAttrib1f(GLuint indx, GLfloat x) { - vbo_VertexAttrib1fARB(indx, x); + VertexAttrib4f_nopos(indx, x, 0.0f, 0.0f, 1.0f); } void GLAPIENTRY -_vbo_VertexAttrib1fv(GLuint indx, const GLfloat* values) +_es_VertexAttrib1fv(GLuint indx, const GLfloat* values) { - vbo_VertexAttrib1fvARB(indx, values); + VertexAttrib4f_nopos(indx, values[0], 0.0f, 0.0f, 1.0f); } void GLAPIENTRY -_vbo_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) +_es_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) { - vbo_VertexAttrib2fARB(indx, x, y); + VertexAttrib4f_nopos(indx, x, y, 0.0f, 1.0f); } void GLAPIENTRY -_vbo_VertexAttrib2fv(GLuint indx, const GLfloat* values) +_es_VertexAttrib2fv(GLuint indx, const GLfloat* values) { - vbo_VertexAttrib2fvARB(indx, values); + VertexAttrib4f_nopos(indx, values[0], values[1], 0.0f, 1.0f); } void GLAPIENTRY -_vbo_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +_es_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) { - vbo_VertexAttrib3fARB(indx, x, y, z); + VertexAttrib4f_nopos(indx, x, y, z, 1.0f); } void GLAPIENTRY -_vbo_VertexAttrib3fv(GLuint indx, const GLfloat* values) +_es_VertexAttrib3fv(GLuint indx, const GLfloat* values) { - vbo_VertexAttrib3fvARB(indx, values); + VertexAttrib4f_nopos(indx, values[0], values[1], values[2], 1.0f); } void GLAPIENTRY -_vbo_VertexAttrib4fv(GLuint indx, const GLfloat* values) +_es_VertexAttrib4fv(GLuint indx, const GLfloat* values) { - vbo_VertexAttrib4fvARB(indx, values); + VertexAttrib4f_nopos(indx, values[0], values[1], values[2], values[3]); } -- 1.7.2.3