[Mesa-dev] [PATCH 4/6] mesa: Move the mvp_with_dp4 flag to ShaderCompilerOptions.

Kenneth Graunke kenneth at whitecape.org
Wed Apr 17 17:30:23 PDT 2013


This flag essentially tells the compiler whether it prefers
dot products or multiply/adds for matrix operations.  As such,
ShaderCompilerOptions seems like the right place for it.

This also lets us specify it on a per-stage basis.  This patch makes all
existing users set the flag for the Vertex Shader stage only, as it's
currently only used for fixed-function vertex programs.  That will
change soon, and I wanted to preserve the existing behavior.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/r200/r200_context.c     |  2 +-
 src/mesa/drivers/dri/radeon/radeon_context.c |  2 +-
 src/mesa/main/context.c                      | 12 ------------
 src/mesa/main/context.h                      |  5 -----
 src/mesa/main/ffvertex_prog.c                |  2 +-
 src/mesa/main/mtypes.h                       | 12 ++++++------
 src/mesa/program/programopt.c                |  2 +-
 src/mesa/state_tracker/st_context.c          |  2 +-
 8 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index 4d62bc4..56522d2 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -351,7 +351,7 @@ GLboolean r200CreateContext( gl_api api,
    ctx->Const.MaxDrawBuffers = 1;
    ctx->Const.MaxColorAttachments = 1;
 
-   _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+   ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4 = GL_TRUE;
 
    /* Install the customized pipeline:
     */
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index e1b83a2..adc7df6 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -314,7 +314,7 @@ r100CreateContext( gl_api api,
    ctx->Const.MaxColorAttachments = 1;
    ctx->Const.MaxRenderbufferSize = 2048;
 
-   _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+   ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4 = true;
 
    /* Install the customized pipeline:
     */
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index ce76243..88ff52e 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1725,18 +1725,6 @@ _mesa_Flush(void)
 }
 
 
-/**
- * Set mvp_with_dp4 flag.  If a driver has a preference for DP4 over
- * MUL/MAD, or vice versa, call this function to register that.
- * Otherwise we default to MUL/MAD.
- */
-void
-_mesa_set_mvp_with_dp4( struct gl_context *ctx,
-                        GLboolean flag )
-{
-   ctx->mvp_with_dp4 = flag;
-}
-
 /*
  * ARB_blend_func_extended - ERRORS section
  * "The error INVALID_OPERATION is generated by Begin or any procedure that
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 1b881f3..04172e5 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -154,11 +154,6 @@ extern struct _glapi_table *
 _mesa_get_dispatch(struct gl_context *ctx);
 
 
-void
-_mesa_set_mvp_with_dp4( struct gl_context *ctx,
-                        GLboolean flag );
-
-
 extern GLboolean
 _mesa_valid_to_render(struct gl_context *ctx, const char *where);
 
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 5a1fefe..51c883e 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -1680,7 +1680,7 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
          return NULL;
 
       create_new_program( &key, prog,
-                          ctx->mvp_with_dp4,
+                          ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4,
                           ctx->Const.VertexProgram.MaxTemps );
 
 #if 0
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6108a35..4353e9b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2435,6 +2435,12 @@ struct gl_shader_compiler_options
    GLuint MaxIfDepth;               /**< Maximum nested IF blocks */
    GLuint MaxUnrollIterations;
 
+   /**
+    * Prefer DP4 instructions (rather than MUL/MAD) for matrix * vector
+    * operations, such as position transformation.
+    */
+   GLboolean PreferDP4;
+
    struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
 };
 
@@ -3569,12 +3575,6 @@ struct gl_context
 
    GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
 
-   /** 
-    * Use dp4 (rather than mul/mad) instructions for position
-    * transformation?
-    */
-   GLboolean mvp_with_dp4;
-
    GLboolean RasterDiscard;  /**< GL_RASTERIZER_DISCARD */
 
    /**
diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c
index d40ffd5..636a62f 100644
--- a/src/mesa/program/programopt.c
+++ b/src/mesa/program/programopt.c
@@ -218,7 +218,7 @@ _mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_vertex_program *vpro
 void
 _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog)
 {
-   if (ctx->mvp_with_dp4) 
+   if (ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4)
       _mesa_insert_mvp_dp4_code( ctx, vprog );
    else
       _mesa_insert_mvp_mad_code( ctx, vprog );
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 2042be3..503ca3d 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -234,7 +234,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
     * driver prefers DP4 or MUL/MAD for vertex transformation.
     */
    if (debug_get_option_mesa_mvp_dp4())
-      _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+      ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4 = GL_TRUE;
 
    return st_create_context_priv(ctx, pipe, options);
 }
-- 
1.8.2.1



More information about the mesa-dev mailing list