[Mesa-dev] [PATCH 15/21] mesa: Enable vertex programs by default, remove checks

Marek Olšák maraeo at gmail.com
Sat Aug 27 05:39:14 PDT 2011


Hi Ian,

I was trying to enable NV_vertex_program without regressions in
st/mesa before, but these piglit tests were always failing and are still
failing with your patch:

nv-add
nv-arl
nv-init-zero-addr
nv-init-zero-reg
nv-mov

r600g just fails or assertion-fails, but softpipe sometimes crashes
(e.g. in nv-init-zero-addr). That's the reason st/mesa doesn't support
NV_vertex_program currently.

Marek

On Sat, Aug 27, 2011 at 9:57 AM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Specifically, the following extensions are enabled:
>
>    GL_ARB_vertex_program
>    GL_EXT_gpu_program_paramaters
>    GL_NV_vertex_program
>
> GL_NV_vertex_program1_1 is *not* enabled because several drivers that
> have vertex shader hardware do not support the RCC opcode.  This would
> be easy enough to add to R200 (which does not support Inf), but it may
> be more complex for others.
>
> Note that this enables GL_NV_vertex_program on r200 where it was not
> previously enabled.  No piglit regressions (or new failures) were
> seen.
>
> Cc: Alex Deucher <alexdeucher at gmail.com>
> Cc: Dave Airlie <airlied at redhat.com>
> ---
>  src/mesa/drivers/common/meta.c |   22 +++++++++-------------
>  src/mesa/main/arbprogram.c     |   36 +++++++++---------------------------
>  src/mesa/main/eval.c           |    9 ---------
>  src/mesa/main/extensions.c     |    3 +++
>  src/mesa/main/getstring.c      |    8 +-------
>  src/mesa/main/matrix.c         |   30 +++++++++---------------------
>  src/mesa/main/nvprogram.c      |   22 ++++++----------------
>  7 files changed, 37 insertions(+), 93 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index 291d912..b9c20ac 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -427,12 +427,10 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
>    }
>
>    if (state & MESA_META_SHADER) {
> -      if (ctx->Extensions.ARB_vertex_program) {
> -         save->VertexProgramEnabled = ctx->VertexProgram.Enabled;
> -         _mesa_reference_vertprog(ctx, &save->VertexProgram,
> -                                 ctx->VertexProgram.Current);
> -         _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE);
> -      }
> +      save->VertexProgramEnabled = ctx->VertexProgram.Enabled;
> +      _mesa_reference_vertprog(ctx, &save->VertexProgram,
> +                              ctx->VertexProgram.Current);
> +      _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE);
>
>       if (ctx->Extensions.ARB_fragment_program) {
>          save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled;
> @@ -697,13 +695,11 @@ _mesa_meta_end(struct gl_context *ctx)
>    }
>
>    if (state & MESA_META_SHADER) {
> -      if (ctx->Extensions.ARB_vertex_program) {
> -         _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB,
> -                          save->VertexProgramEnabled);
> -         _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
> -                                  save->VertexProgram);
> -        _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL);
> -      }
> +      _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB,
> +                      save->VertexProgramEnabled);
> +      _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
> +                              save->VertexProgram);
> +      _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL);
>
>       if (ctx->Extensions.ARB_fragment_program) {
>          _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB,
> diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
> index b83369d..3d40356 100644
> --- a/src/mesa/main/arbprogram.c
> +++ b/src/mesa/main/arbprogram.c
> @@ -77,9 +77,7 @@ _mesa_BindProgram(GLenum target, GLuint id)
>    ASSERT_OUTSIDE_BEGIN_END(ctx);
>
>    /* Error-check target and get curProg */
> -   if ((target == GL_VERTEX_PROGRAM_ARB) && /* == GL_VERTEX_PROGRAM_NV */
> -        (ctx->Extensions.NV_vertex_program ||
> -         ctx->Extensions.ARB_vertex_program)) {
> +   if (target == GL_VERTEX_PROGRAM_ARB) {
>       curProg = &ctx->VertexProgram.Current->Base;
>    }
>    else if ((target == GL_FRAGMENT_PROGRAM_NV
> @@ -276,8 +274,7 @@ get_local_param_pointer(struct gl_context *ctx, const char *func,
>    struct gl_program *prog;
>    GLuint maxParams;
>
> -   if (target == GL_VERTEX_PROGRAM_ARB
> -       && ctx->Extensions.ARB_vertex_program) {
> +   if (target == GL_VERTEX_PROGRAM_ARB) {
>       prog = &(ctx->VertexProgram.Current->Base);
>       maxParams = ctx->Const.VertexProgram.MaxLocalParams;
>    }
> @@ -320,9 +317,7 @@ get_env_param_pointer(struct gl_context *ctx, const char *func,
>       *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)) {
> +   else if (target == GL_VERTEX_PROGRAM_ARB) {
>       if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
>          _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
>          return GL_FALSE;
> @@ -345,12 +340,6 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
>
>    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
>
> -   if (!ctx->Extensions.ARB_vertex_program
> -       && !ctx->Extensions.ARB_fragment_program) {
> -      _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramStringARB()");
> -      return;
> -   }
> -
>    if (format != GL_PROGRAM_FORMAT_ASCII_ARB) {
>       _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(format)");
>       return;
> @@ -361,18 +350,14 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
>     * using the ARB grammar if the string starts with "!!ARB" or if
>     * NV_vertex_program is not supported.
>     */
> -   if (target == GL_VERTEX_PROGRAM_ARB
> -       && ctx->Extensions.ARB_vertex_program
> -       && ((strncmp(string, "!!ARB", 5) == 0)
> -          || !ctx->Extensions.NV_vertex_program)) {
> +   if (target == GL_VERTEX_PROGRAM_ARB && (strncmp(string, "!!ARB", 5) == 0)) {
>       struct gl_vertex_program *prog = ctx->VertexProgram.Current;
>       _mesa_parse_arb_vertex_program(ctx, target, string, len, prog);
>
>       base = & prog->Base;
>    }
> -   else if ((target == GL_VERTEX_PROGRAM_ARB
> -            || target == GL_VERTEX_STATE_PROGRAM_NV)
> -           && ctx->Extensions.NV_vertex_program) {
> +   else if (target == GL_VERTEX_PROGRAM_ARB
> +           || target == GL_VERTEX_STATE_PROGRAM_NV) {
>       struct gl_vertex_program *prog = ctx->VertexProgram.Current;
>       _mesa_parse_nv_vertex_program(ctx, target, string, len, prog);
>
> @@ -509,8 +494,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
>       }
>       dest = ctx->FragmentProgram.Parameters[index];
>    }
> -   else if (target == GL_VERTEX_PROGRAM_ARB
> -       && ctx->Extensions.ARB_vertex_program) {
> +   else if (target == GL_VERTEX_PROGRAM_ARB) {
>       if ((index + count) > ctx->Const.VertexProgram.MaxEnvParams) {
>          _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(index + count)");
>          return;
> @@ -612,8 +596,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
>       }
>       dest = ctx->FragmentProgram.Current->Base.LocalParams[index];
>    }
> -   else if (target == GL_VERTEX_PROGRAM_ARB
> -            && ctx->Extensions.ARB_vertex_program) {
> +   else if (target == GL_VERTEX_PROGRAM_ARB) {
>       if ((index + count) > ctx->Const.VertexProgram.MaxLocalParams) {
>          _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)");
>          return;
> @@ -700,8 +683,7 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
>
>    ASSERT_OUTSIDE_BEGIN_END(ctx);
>
> -   if (target == GL_VERTEX_PROGRAM_ARB
> -       && ctx->Extensions.ARB_vertex_program) {
> +   if (target == GL_VERTEX_PROGRAM_ARB) {
>       prog = &(ctx->VertexProgram.Current->Base);
>       limits = &ctx->Const.VertexProgram;
>    }
> diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
> index e651715..babd1f9 100644
> --- a/src/mesa/main/eval.c
> +++ b/src/mesa/main/eval.c
> @@ -80,11 +80,6 @@ GLuint _mesa_evaluator_components( GLenum target )
>       default:                         break;
>    }
>
> -   /* XXX need to check for the vertex program extension
> -   if (!ctx->Extensions.NV_vertex_program)
> -      return 0;
> -   */
> -
>    if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV &&
>        target <= GL_MAP1_VERTEX_ATTRIB15_4_NV)
>       return 4;
> @@ -138,8 +133,6 @@ get_1d_map( struct gl_context *ctx, GLenum target )
>       case GL_MAP1_VERTEX_ATTRIB13_4_NV:
>       case GL_MAP1_VERTEX_ATTRIB14_4_NV:
>       case GL_MAP1_VERTEX_ATTRIB15_4_NV:
> -         if (!ctx->Extensions.NV_vertex_program)
> -            return NULL;
>          return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV];
>       default:
>          return NULL;
> @@ -188,8 +181,6 @@ get_2d_map( struct gl_context *ctx, GLenum target )
>       case GL_MAP2_VERTEX_ATTRIB13_4_NV:
>       case GL_MAP2_VERTEX_ATTRIB14_4_NV:
>       case GL_MAP2_VERTEX_ATTRIB15_4_NV:
> -         if (!ctx->Extensions.NV_vertex_program)
> -            return NULL;
>          return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV];
>       default:
>          return NULL;
> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
> index 14b0cf9..01bcc62 100644
> --- a/src/mesa/main/extensions.c
> +++ b/src/mesa/main/extensions.c
> @@ -351,6 +351,7 @@ static const size_t default_extensions[] = {
>    o(ARB_texture_compression),
>    o(ARB_transpose_matrix),
>    o(ARB_vertex_buffer_object),
> +   o(ARB_vertex_program),
>    o(ARB_window_pos),
>
>    o(EXT_abgr),
> @@ -358,6 +359,7 @@ static const size_t default_extensions[] = {
>    o(EXT_compiled_vertex_array),
>    o(EXT_copy_texture),
>    o(EXT_draw_range_elements),
> +   o(EXT_gpu_program_parameters),
>    o(EXT_multi_draw_arrays),
>    o(EXT_packed_pixels),
>    o(EXT_polygon_offset),
> @@ -378,6 +380,7 @@ static const size_t default_extensions[] = {
>    o(IBM_rasterpos_clip),
>    o(NV_light_max_exponent),
>    o(NV_texgen_reflection),
> +   o(NV_vertex_program),
>    o(SGIS_generate_mipmap),
>    o(SGIS_texture_edge_clamp),
>    o(SGIS_texture_lod),
> diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
> index c381fb2..726218f 100644
> --- a/src/mesa/main/getstring.c
> +++ b/src/mesa/main/getstring.c
> @@ -121,13 +121,7 @@ _mesa_GetString( GLenum name )
>  #if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
>     FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
>       case GL_PROGRAM_ERROR_STRING_NV:
> -         if (ctx->Extensions.NV_fragment_program ||
> -             ctx->Extensions.ARB_fragment_program ||
> -             ctx->Extensions.NV_vertex_program ||
> -             ctx->Extensions.ARB_vertex_program) {
> -            return (const GLubyte *) ctx->Program.ErrorString;
> -         }
> -         /* FALL-THROUGH */
> +        return (const GLubyte *) ctx->Program.ErrorString;
>  #endif
>       default:
>          _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" );
> diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
> index 5697366..87dabf1 100644
> --- a/src/mesa/main/matrix.c
> +++ b/src/mesa/main/matrix.c
> @@ -187,13 +187,7 @@ _mesa_MatrixMode( GLenum mode )
>    case GL_MATRIX5_NV:
>    case GL_MATRIX6_NV:
>    case GL_MATRIX7_NV:
> -      if (ctx->Extensions.NV_vertex_program) {
> -         ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV];
> -      }
> -      else {
> -         _mesa_error( ctx,  GL_INVALID_ENUM, "glMatrixMode(mode)" );
> -         return;
> -      }
> +      ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV];
>       break;
>    case GL_MATRIX0_ARB:
>    case GL_MATRIX1_ARB:
> @@ -202,22 +196,16 @@ _mesa_MatrixMode( GLenum mode )
>    case GL_MATRIX4_ARB:
>    case GL_MATRIX5_ARB:
>    case GL_MATRIX6_ARB:
> -   case GL_MATRIX7_ARB:
> -      if (ctx->Extensions.ARB_vertex_program ||
> -          ctx->Extensions.ARB_fragment_program) {
> -         const GLuint m = mode - GL_MATRIX0_ARB;
> -         if (m > ctx->Const.MaxProgramMatrices) {
> -            _mesa_error(ctx, GL_INVALID_ENUM,
> -                        "glMatrixMode(GL_MATRIX%d_ARB)", m);
> -            return;
> -         }
> -         ctx->CurrentStack = &ctx->ProgramMatrixStack[m];
> -      }
> -      else {
> -         _mesa_error( ctx,  GL_INVALID_ENUM, "glMatrixMode(mode)" );
> -         return;
> +   case GL_MATRIX7_ARB: {
> +      const GLuint m = mode - GL_MATRIX0_ARB;
> +      if (m > ctx->Const.MaxProgramMatrices) {
> +        _mesa_error(ctx, GL_INVALID_ENUM,
> +                    "glMatrixMode(GL_MATRIX%d_ARB)", m);
> +        return;
>       }
> +      ctx->CurrentStack = &ctx->ProgramMatrixStack[m];
>       break;
> +   }
>    default:
>       _mesa_error( ctx,  GL_INVALID_ENUM, "glMatrixMode(mode)" );
>       return;
> diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c
> index 7ff7645..8aff37a 100644
> --- a/src/mesa/main/nvprogram.c
> +++ b/src/mesa/main/nvprogram.c
> @@ -318,8 +318,7 @@ _mesa_GetTrackMatrixivNV(GLenum target, GLuint address,
>    GET_CURRENT_CONTEXT(ctx);
>    ASSERT_OUTSIDE_BEGIN_END(ctx);
>
> -   if (target == GL_VERTEX_PROGRAM_NV
> -       && ctx->Extensions.NV_vertex_program) {
> +   if (target == GL_VERTEX_PROGRAM_NV) {
>       GLuint i;
>
>       if ((address & 0x3) || address >= MAX_NV_VERTEX_PROGRAM_PARAMS) {
> @@ -599,12 +598,6 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
>    GET_CURRENT_CONTEXT(ctx);
>    ASSERT_OUTSIDE_BEGIN_END(ctx);
>
> -   if (!ctx->Extensions.NV_vertex_program
> -       && !ctx->Extensions.NV_fragment_program) {
> -      _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV()");
> -      return;
> -   }
> -
>    if (id == 0) {
>       _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(id)");
>       return;
> @@ -624,9 +617,7 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
>       return;
>    }
>
> -   if ((target == GL_VERTEX_PROGRAM_NV ||
> -        target == GL_VERTEX_STATE_PROGRAM_NV)
> -       && ctx->Extensions.NV_vertex_program) {
> +   if (target == GL_VERTEX_PROGRAM_NV || target == GL_VERTEX_STATE_PROGRAM_NV) {
>       struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog;
>       if (!vprog || prog == &_mesa_DummyProgram) {
>          vprog = (struct gl_vertex_program *)
> @@ -638,8 +629,7 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
>          _mesa_HashInsert(ctx->Shared->Programs, id, vprog);
>       }
>
> -      if (ctx->Extensions.ARB_vertex_program
> -         && (strncmp((char *) program, "!!ARB", 5) == 0)) {
> +      if (strncmp((char *) program, "!!ARB", 5) == 0) {
>         _mesa_parse_arb_vertex_program(ctx, target, program, len, vprog);
>       } else {
>         _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog);
> @@ -691,7 +681,7 @@ _mesa_ProgramParameters4dvNV(GLenum target, GLuint index,
>    GET_CURRENT_CONTEXT(ctx);
>    ASSERT_OUTSIDE_BEGIN_END(ctx);
>
> -   if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) {
> +   if (target == GL_VERTEX_PROGRAM_NV) {
>       GLint i;
>       if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) {
>          _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4dvNV");
> @@ -723,7 +713,7 @@ _mesa_ProgramParameters4fvNV(GLenum target, GLuint index,
>    GET_CURRENT_CONTEXT(ctx);
>    ASSERT_OUTSIDE_BEGIN_END(ctx);
>
> -   if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) {
> +   if (target == GL_VERTEX_PROGRAM_NV) {
>       GLint i;
>       if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) {
>          _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4fvNV");
> @@ -755,7 +745,7 @@ _mesa_TrackMatrixNV(GLenum target, GLuint address,
>
>    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
>
> -   if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) {
> +   if (target == GL_VERTEX_PROGRAM_NV) {
>       if (address & 0x3) {
>          /* addr must be multiple of four */
>          _mesa_error(ctx, GL_INVALID_VALUE, "glTrackMatrixNV(address)");
> --
> 1.7.4.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>


More information about the mesa-dev mailing list