From 86a4810b09097714942bf2b889e6c62357bba931 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 9 Nov 2007 14:46:59 +0100 Subject: [PATCH] alias ProgramEnvParameter4xyARB and ProgramParameter4xyNV (bug #12935) these should be the same functions (as per spec). --- src/mesa/glapi/gl_API.xml | 14 +-- src/mesa/main/config.h | 39 +++---- src/mesa/main/dlist.c | 205 +++++++++++++---------------------- src/mesa/main/state.c | 8 +- src/mesa/shader/arbprogram.c | 29 ++++- src/mesa/shader/nvprogram.c | 69 ------------ src/mesa/shader/nvprogram.h | 12 -- 7 files changed, 132 insertions(+), 244 deletions(-) diff --git a/src/mesa/glapi/gl_API.xml b/src/mesa/glapi/gl_API.xml index 3d47e6f2cef..ef4a309cd6b 100644 --- a/src/mesa/glapi/gl_API.xml +++ b/src/mesa/glapi/gl_API.xml @@ -11275,7 +11275,7 @@ - + @@ -11284,14 +11284,13 @@ - + - - + - + @@ -11300,11 +11299,10 @@ - + - - + diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index cebef1c3832..8eb02beb4c2 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -163,25 +163,6 @@ /** For GL_EXT_texture_lod_bias (typically MAX_TEXTURE_LEVELS - 1) */ #define MAX_TEXTURE_LOD_BIAS 11.0 -/** For GL_NV_vertex_program */ -/*@{*/ -#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128 -#define MAX_NV_VERTEX_PROGRAM_TEMPS 12 -#define MAX_NV_VERTEX_PROGRAM_PARAMS 128 /* KW: power of two */ -#define MAX_NV_VERTEX_PROGRAM_INPUTS 16 -#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15 -/*@}*/ - -/** For GL_NV_fragment_program */ -/*@{*/ -#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */ -#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96 -#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64 -#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12 -#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3 -#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2 -/*@}*/ - /** For GL_ARB_vertex_program */ /*@{*/ #define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1 @@ -209,6 +190,26 @@ #define MAX_VARYING 8 /*@}*/ +/** For GL_NV_vertex_program */ +/*@{*/ +#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128 +#define MAX_NV_VERTEX_PROGRAM_TEMPS 12 +#define MAX_NV_VERTEX_PROGRAM_PARAMS MAX_PROGRAM_ENV_PARAMS +#define MAX_NV_VERTEX_PROGRAM_INPUTS 16 +#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15 +/*@}*/ + +/** For GL_NV_fragment_program */ +/*@{*/ +#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */ +#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96 +#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64 +#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12 +#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3 +#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2 +/*@}*/ + + /** For GL_ARB_vertex_shader */ /*@{*/ #define MAX_VERTEX_ATTRIBS 16 diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index b881b12ff35..a421d049578 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -303,7 +303,6 @@ typedef enum OPCODE_EXECUTE_PROGRAM_NV, OPCODE_REQUEST_RESIDENT_PROGRAMS_NV, OPCODE_LOAD_PROGRAM_NV, - OPCODE_PROGRAM_PARAMETER4F_NV, OPCODE_TRACK_MATRIX_NV, /* GL_NV_fragment_program */ OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, @@ -4247,77 +4246,111 @@ save_BindProgramNV(GLenum target, GLuint id) CALL_BindProgramNV(ctx->Exec, (target, id)); } } -#endif /* FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ -#if FEATURE_NV_vertex_program static void GLAPIENTRY -save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) +save_ProgramEnvParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) { GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = ALLOC_INSTRUCTION(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); + n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); if (n) { n[1].e = target; - n[2].ui = id; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; + n[2].ui = index; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; } if (ctx->ExecuteFlag) { - CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); + CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); } } static void GLAPIENTRY -save_ProgramParameter4fNV(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) +save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + save_ProgramEnvParameter4fARB(target, index, params[0], params[1], + params[2], params[3]); +} + + +static void GLAPIENTRY +save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, + const GLfloat * params) { GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_PARAMETER4F_NV, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; + + if (count > 0) { + GLint i; + const GLfloat * p = params; + + for (i = 0 ; i < count ; i++) { + n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = p[0]; + n[4].f = p[1]; + n[5].f = p[2]; + n[6].f = p[3]; + p += 4; + } + } } + if (ctx->ExecuteFlag) { - CALL_ProgramParameter4fNV(ctx->Exec, (target, index, x, y, z, w)); + CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); } } static void GLAPIENTRY -save_ProgramParameter4fvNV(GLenum target, GLuint index, - const GLfloat *params) +save_ProgramEnvParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) { - save_ProgramParameter4fNV(target, index, params[0], params[1], - params[2], params[3]); + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) x, + (GLfloat) y, (GLfloat) z, (GLfloat) w); } static void GLAPIENTRY -save_ProgramParameter4dNV(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) +save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) { - save_ProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y, - (GLfloat) z, (GLfloat) w); + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) params[0], + (GLfloat) params[1], + (GLfloat) params[2], (GLfloat) params[3]); } +#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */ +#if FEATURE_NV_vertex_program static void GLAPIENTRY -save_ProgramParameter4dvNV(GLenum target, GLuint index, - const GLdouble *params) +save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) { - save_ProgramParameter4fNV(target, index, (GLfloat) params[0], - (GLfloat) params[1], (GLfloat) params[2], - (GLfloat) params[3]); + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = ALLOC_INSTRUCTION(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); + if (n) { + n[1].e = target; + n[2].ui = id; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); + } } @@ -4327,7 +4360,7 @@ save_ProgramParameters4dvNV(GLenum target, GLuint index, { GLuint i; for (i = 0; i < num; i++) { - save_ProgramParameter4dvNV(target, index + i, params + 4 * i); + save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i); } } @@ -4338,7 +4371,7 @@ save_ProgramParameters4fvNV(GLenum target, GLuint index, { GLuint i; for (i = 0; i < num; i++) { - save_ProgramParameter4fvNV(target, index + i, params + 4 * i); + save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i); } } @@ -4666,90 +4699,6 @@ save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, } } - -static void GLAPIENTRY -save_ProgramEnvParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - save_ProgramEnvParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); -} - - -static void GLAPIENTRY -save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat * params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) x, - (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) params[0], - (GLfloat) params[1], - (GLfloat) params[2], (GLfloat) params[3]); -} - #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ @@ -6429,10 +6378,6 @@ execute_list(GLcontext *ctx, GLuint list) CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i, (const GLubyte *) n[4].data)); break; - case OPCODE_PROGRAM_PARAMETER4F_NV: - CALL_ProgramParameter4fNV(ctx->Exec, (n[1].e, n[2].ui, n[3].f, - n[4].f, n[5].f, n[6].f)); - break; case OPCODE_TRACK_MATRIX_NV: CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e)); break; @@ -6463,6 +6408,8 @@ execute_list(GLcontext *ctx, GLuint list) CALL_ProgramStringARB(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].data)); break; +#endif +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program case OPCODE_PROGRAM_ENV_PARAMETER_ARB: CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f, n[4].f, n[5].f, @@ -8018,10 +7965,10 @@ _mesa_init_dlist_table(struct _glapi_table *table) SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); SET_IsProgramNV(table, _mesa_IsProgramARB); SET_LoadProgramNV(table, save_LoadProgramNV); - SET_ProgramParameter4dNV(table, save_ProgramParameter4dNV); - SET_ProgramParameter4dvNV(table, save_ProgramParameter4dvNV); - SET_ProgramParameter4fNV(table, save_ProgramParameter4fNV); - SET_ProgramParameter4fvNV(table, save_ProgramParameter4fvNV); + SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV); SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV); SET_TrackMatrixNV(table, save_TrackMatrixNV); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index cabc3d8a44a..a42c4fd805f 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -535,10 +535,10 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV); SET_IsProgramNV(exec, _mesa_IsProgramARB); SET_LoadProgramNV(exec, _mesa_LoadProgramNV); - SET_ProgramParameter4dNV(exec, _mesa_ProgramParameter4dNV); - SET_ProgramParameter4dvNV(exec, _mesa_ProgramParameter4dvNV); - SET_ProgramParameter4fNV(exec, _mesa_ProgramParameter4fNV); - SET_ProgramParameter4fvNV(exec, _mesa_ProgramParameter4fvNV); + SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */ + SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); /* alias to ProgramParameter4dvNV */ + SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); /* alias to ProgramParameter4fNV */ + SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); /* alias to ProgramParameter4fvNV */ SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV); SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV); SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV); diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index 4b5f63ef920..a293dd2829b 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -247,6 +247,12 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, } +/** + * Set a program env parameter register. + * \note Called from the GL API dispatcher. + * Note, this function is also used by the GL_NV_vertex_program extension + * (alias to ProgramParameterdNV) + */ void GLAPIENTRY _mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) @@ -256,6 +262,12 @@ _mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index, } +/** + * Set a program env parameter register. + * \note Called from the GL API dispatcher. + * Note, this function is also used by the GL_NV_vertex_program extension + * (alias to ProgramParameterdvNV) + */ void GLAPIENTRY _mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index, const GLdouble *params) @@ -266,6 +278,12 @@ _mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index, } +/** + * Set a program env parameter register. + * \note Called from the GL API dispatcher. + * Note, this function is also used by the GL_NV_vertex_program extension + * (alias to ProgramParameterfNV) + */ void GLAPIENTRY _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) @@ -283,8 +301,8 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, } ASSIGN_4V(ctx->FragmentProgram.Parameters[index], x, y, z, w); } - else if (target == GL_VERTEX_PROGRAM_ARB - && ctx->Extensions.ARB_vertex_program) { + else if (target == GL_VERTEX_PROGRAM_ARB /* == GL_VERTEX_PROGRAM_NV */ + && (ctx->Extensions.ARB_vertex_program || ctx->Extensions.NV_vertex_program)) { if (index >= ctx->Const.VertexProgram.MaxEnvParams) { _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)"); return; @@ -297,7 +315,12 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, } } - +/** + * Set a program env parameter register. + * \note Called from the GL API dispatcher. + * Note, this function is also used by the GL_NV_vertex_program extension + * (alias to ProgramParameterfvNV) + */ void GLAPIENTRY _mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index, const GLfloat *params) diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c index 337784bfe25..409c61cdc11 100644 --- a/src/mesa/shader/nvprogram.c +++ b/src/mesa/shader/nvprogram.c @@ -575,75 +575,6 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, -/** - * Set a program parameter register. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ProgramParameter4dNV(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - _mesa_ProgramParameter4fNV(target, index, - (GLfloat)x, (GLfloat)y, (GLfloat)z, (GLfloat)w); -} - - -/** - * Set a program parameter register. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ProgramParameter4dvNV(GLenum target, GLuint index, - const GLdouble *params) -{ - _mesa_ProgramParameter4fNV(target, index, - (GLfloat)params[0], (GLfloat)params[1], - (GLfloat)params[2], (GLfloat)params[3]); -} - - -/** - * Set a program parameter register. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ProgramParameter4fNV(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { - if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) { - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ASSIGN_4V(ctx->VertexProgram.Parameters[index], x, y, z, w); - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameterNV(index)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameterNV"); - return; - } -} - - -/** - * Set a program parameter register. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ProgramParameter4fvNV(GLenum target, GLuint index, - const GLfloat *params) -{ - _mesa_ProgramParameter4fNV(target, index, - params[0], params[1], params[2], params[3]); -} - - - /** * Set a sequence of program parameter registers. * \note Called from the GL API dispatcher. diff --git a/src/mesa/shader/nvprogram.h b/src/mesa/shader/nvprogram.h index dcea7727e04..bfac165b5ed 100644 --- a/src/mesa/shader/nvprogram.h +++ b/src/mesa/shader/nvprogram.h @@ -69,18 +69,6 @@ _mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer); extern void GLAPIENTRY _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *program); -extern void GLAPIENTRY -_mesa_ProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); - -extern void GLAPIENTRY -_mesa_ProgramParameter4dvNV(GLenum target, GLuint index, const GLdouble *params); - -extern void GLAPIENTRY -_mesa_ProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - -extern void GLAPIENTRY -_mesa_ProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat *params); - extern void GLAPIENTRY _mesa_ProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble *params); -- 2.30.2