mesa: Move the mvp_with_dp4 flag to ShaderCompilerOptions.

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@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Kenneth Graunke
2013-04-17 17:30:23 -07:00
parent b765740a66
commit bbf029f7cf
8 changed files with 11 additions and 28 deletions

View File

@@ -351,7 +351,7 @@ GLboolean r200CreateContext( gl_api api,
ctx->Const.MaxDrawBuffers = 1; ctx->Const.MaxDrawBuffers = 1;
ctx->Const.MaxColorAttachments = 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: /* Install the customized pipeline:
*/ */

View File

@@ -314,7 +314,7 @@ r100CreateContext( gl_api api,
ctx->Const.MaxColorAttachments = 1; ctx->Const.MaxColorAttachments = 1;
ctx->Const.MaxRenderbufferSize = 2048; ctx->Const.MaxRenderbufferSize = 2048;
_mesa_set_mvp_with_dp4( ctx, GL_TRUE ); ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4 = true;
/* Install the customized pipeline: /* Install the customized pipeline:
*/ */

View File

@@ -1720,18 +1720,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 * ARB_blend_func_extended - ERRORS section
* "The error INVALID_OPERATION is generated by Begin or any procedure that * "The error INVALID_OPERATION is generated by Begin or any procedure that

View File

@@ -155,11 +155,6 @@ extern struct _glapi_table *
_mesa_get_dispatch(struct gl_context *ctx); _mesa_get_dispatch(struct gl_context *ctx);
void
_mesa_set_mvp_with_dp4( struct gl_context *ctx,
GLboolean flag );
extern GLboolean extern GLboolean
_mesa_valid_to_render(struct gl_context *ctx, const char *where); _mesa_valid_to_render(struct gl_context *ctx, const char *where);

View File

@@ -1674,7 +1674,7 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
return NULL; return NULL;
create_new_program( &key, prog, create_new_program( &key, prog,
ctx->mvp_with_dp4, ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4,
ctx->Const.VertexProgram.MaxTemps ); ctx->Const.VertexProgram.MaxTemps );
#if 0 #if 0

View File

@@ -2433,6 +2433,12 @@ struct gl_shader_compiler_options
GLuint MaxIfDepth; /**< Maximum nested IF blocks */ GLuint MaxIfDepth; /**< Maximum nested IF blocks */
GLuint MaxUnrollIterations; 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 */ struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
}; };
@@ -3574,12 +3580,6 @@ struct gl_context
GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
/**
* Use dp4 (rather than mul/mad) instructions for position
* transformation?
*/
GLboolean mvp_with_dp4;
GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
/** /**

View File

@@ -219,7 +219,7 @@ _mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_vertex_program *vpro
void void
_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog) _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 ); _mesa_insert_mvp_dp4_code( ctx, vprog );
else else
_mesa_insert_mvp_mad_code( ctx, vprog ); _mesa_insert_mvp_mad_code( ctx, vprog );

View File

@@ -240,7 +240,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
* driver prefers DP4 or MUL/MAD for vertex transformation. * driver prefers DP4 or MUL/MAD for vertex transformation.
*/ */
if (debug_get_option_mesa_mvp_dp4()) 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); return st_create_context_priv(ctx, pipe, options);
} }