[Mesa-dev] [PATCH 1/3] mesa: Don't skip glGetProgramEnvParam4dvARB if there was already an error.
Ian Romanick
idr at freedesktop.org
Wed Jun 29 10:24:49 PDT 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 06/28/2011 04:49 PM, Eric Anholt wrote:
> Fixes a bug caught by oglconform, and now piglit
> ARB_vertex_program/getenv4d-with-error. The wrapping of an existing
> GL function made it so that we couldn't distinguish an error in
> looking up our arguments from an existing error. Instead, make a
> helper function to choose the param, and use it from multiple callers.
> ---
> src/mesa/main/arbprogram.c | 119 ++++++++++++++++++++-----------------------
> 1 files changed, 55 insertions(+), 64 deletions(-)
>
> diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
> index 26d7819..cbc1455 100644
> --- a/src/mesa/main/arbprogram.c
> +++ b/src/mesa/main/arbprogram.c
> @@ -269,6 +269,33 @@ _mesa_IsProgramARB(GLuint id)
> return GL_FALSE;
> }
>
> +static GLboolean
> +get_env_param_pointer(struct gl_context *ctx, const char *func,
> + GLenum target, GLuint index, GLfloat **param)
> +{
> + if (target == GL_FRAGMENT_PROGRAM_ARB
> + && ctx->Extensions.ARB_fragment_program) {
> + if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
> + _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
> + return GL_FALSE;
> + }
> + *param = ctx->FragmentProgram.Parameters[index];
> + return GL_TRUE;
> + }
> + else if (target == GL_VERTEX_PROGRAM_ARB &&
> + (ctx->Extensions.ARB_vertex_program ||
> + ctx->Extensions.NV_vertex_program)) {
> + if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
> + _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
> + return GL_FALSE;
> + }
> + *param = ctx->VertexProgram.Parameters[index];
> + return GL_TRUE;
> + } else {
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);
> + return GL_FALSE;
> + }
> +}
>
> void GLAPIENTRY
> _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
> @@ -383,31 +410,19 @@ void GLAPIENTRY
> _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
> GLfloat x, GLfloat y, GLfloat z, GLfloat w)
> {
> + GLfloat *param;
> +
> GET_CURRENT_CONTEXT(ctx);
> ASSERT_OUTSIDE_BEGIN_END(ctx);
>
> FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
>
> - if (target == GL_FRAGMENT_PROGRAM_ARB
> - && ctx->Extensions.ARB_fragment_program) {
> - if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
> - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
> - return;
> - }
> - ASSIGN_4V(ctx->FragmentProgram.Parameters[index], x, y, z, w);
> - }
> - 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;
> - }
> - ASSIGN_4V(ctx->VertexProgram.Parameters[index], x, y, z, w);
> - }
> - else {
> - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter(target)");
> + if (!get_env_param_pointer(ctx, "glProgramEnvParameter",
> + target, index, ¶m)) {
> return;
> }
> +
> + ASSIGN_4V(param, x, y, z, w);
Could this be:
if (get_env_param_pointer(ctx, "glProgramEnvParameter",
target, index, ¶m)) {
ASSIGN_4V(param, x, y, z, w);
}
> }
>
>
> @@ -422,33 +437,19 @@ void GLAPIENTRY
> _mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
> const GLfloat *params)
> {
> + GLfloat *param;
> +
> GET_CURRENT_CONTEXT(ctx);
> ASSERT_OUTSIDE_BEGIN_END(ctx);
>
> FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
>
> - if (target == GL_FRAGMENT_PROGRAM_ARB
> - && ctx->Extensions.ARB_fragment_program) {
> - if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
> - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)");
> - return;
> - }
> - memcpy(ctx->FragmentProgram.Parameters[index], params,
> - 4 * sizeof(GLfloat));
> - }
> - 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, "glProgramEnvParameter4fv(index)");
> - return;
> - }
> - memcpy(ctx->VertexProgram.Parameters[index], params,
> - 4 * sizeof(GLfloat));
> - }
> - else {
> - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter4fv(target)");
> + if (!get_env_param_pointer(ctx, "glProgramEnvParameter4fv",
> + target, index, ¶m)) {
> return;
> }
> +
> + memcpy(param, params, 4 * sizeof(GLfloat));
> }
>
>
> @@ -496,15 +497,17 @@ _mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index,
> GLdouble *params)
> {
> GET_CURRENT_CONTEXT(ctx);
> - GLfloat fparams[4];
> + GLfloat *fparam;
>
> - _mesa_GetProgramEnvParameterfvARB(target, index, fparams);
> - if (ctx->ErrorValue == GL_NO_ERROR) {
> - params[0] = fparams[0];
> - params[1] = fparams[1];
> - params[2] = fparams[2];
> - params[3] = fparams[3];
> + if (!get_env_param_pointer(ctx, "glGetProgramEnvParameterdv",
> + target, index, &fparam)) {
> + return;
> }
> +
> + params[0] = fparam[0];
> + params[1] = fparam[1];
> + params[2] = fparam[2];
> + params[3] = fparam[3];
> }
>
>
> @@ -512,30 +515,18 @@ void GLAPIENTRY
> _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
> GLfloat *params)
> {
> + GLfloat *param;
> +
> GET_CURRENT_CONTEXT(ctx);
>
> ASSERT_OUTSIDE_BEGIN_END(ctx);
>
> - if (target == GL_FRAGMENT_PROGRAM_ARB
> - && ctx->Extensions.ARB_fragment_program) {
> - if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
> - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
> - return;
> - }
> - COPY_4V(params, ctx->FragmentProgram.Parameters[index]);
> - }
> - else if (target == GL_VERTEX_PROGRAM_ARB
> - && ctx->Extensions.ARB_vertex_program) {
> - if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
> - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
> - return;
> - }
> - COPY_4V(params, ctx->VertexProgram.Parameters[index]);
> - }
> - else {
> - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramEnvParameter(target)");
> + if (!get_env_param_pointer(ctx, "glGetProgramEnvParameterfv",
> + target, index, ¶m)) {
> return;
> }
> +
> + COPY_4V(params, param);
> }
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAk4LX+AACgkQX1gOwKyEAw89mQCfdx8XavUsytewvCCpOmA2mgil
bYIAmwVn8iW02CIqwktCyV0/G0snmjdH
=MBl5
-----END PGP SIGNATURE-----
More information about the mesa-dev
mailing list