[Mesa-dev] [PATCH] mesa: Replace the EmitNoIfs compiler flag with a MaxIfLevel flag.
Ian Romanick
idr at freedesktop.org
Wed Aug 31 17:58:59 PDT 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/31/2011 03:30 PM, Bryan Cain wrote:
> This is a better, more fine-grained way of lowering if statements. Fixes the
> game And Yet It Moves on nv50.
Other than the one comment below,
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/mesa/drivers/dri/i915/i915_context.c | 2 +-
> src/mesa/main/mtypes.h | 6 +-----
> src/mesa/program/ir_to_mesa.cpp | 8 ++++----
> src/mesa/state_tracker/st_extensions.c | 2 +-
> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 +++---
> 5 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
> index 11bee14..7a40ba1 100644
> --- a/src/mesa/drivers/dri/i915/i915_context.c
> +++ b/src/mesa/drivers/dri/i915/i915_context.c
> @@ -189,7 +189,7 @@ i915CreateContext(int api,
>
> struct gl_shader_compiler_options *const fs_options =
> & ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
> - fs_options->EmitNoIfs = GL_TRUE;
> + fs_options->MaxIfLevel = 0;
> fs_options->EmitNoNoise = GL_TRUE;
> fs_options->EmitNoPow = GL_TRUE;
> fs_options->EmitNoMainReturn = GL_TRUE;
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index f2eb889..9f95bcd 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2266,11 +2266,6 @@ struct gl_shader_compiler_options
> /** Driver-selectable options: */
> GLboolean EmitCondCodes; /**< Use condition codes? */
> GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */
> - /**
> - * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't
> - * support control flow.
> - */
> - GLboolean EmitNoIfs;
> GLboolean EmitNoLoops;
> GLboolean EmitNoFunctions;
> GLboolean EmitNoCont; /**< Emit CONT opcode? */
> @@ -2288,6 +2283,7 @@ struct gl_shader_compiler_options
> GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
> /*@}*/
>
> + GLuint MaxIfLevel; /**< Maximum nested IF blocks */
I'd call this MaxIfDepth to match the lower_if_to_cond_assign parameter.
> GLuint MaxUnrollIterations;
>
> struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index dd154db..7fb286e 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -3119,7 +3119,7 @@ get_mesa_program(struct gl_context *ctx,
>
> switch (mesa_inst->Opcode) {
> case OPCODE_IF:
> - if (options->EmitNoIfs) {
> + if (options->MaxIfLevel == 0) {
> linker_warning(shader_program,
> "Couldn't flatten if-statement. "
> "This will likely result in software "
> @@ -3241,10 +3241,10 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
>
> progress = lower_quadop_vector(ir, true) || progress;
>
> - if (options->EmitNoIfs) {
> + if (options->MaxIfLevel == 0)
> progress = lower_discard(ir) || progress;
> - progress = lower_if_to_cond_assign(ir) || progress;
> - }
> +
> + progress = lower_if_to_cond_assign(ir, options->MaxIfLevel) || progress;
>
> if (options->EmitNoNoise)
> progress = lower_noise(ir) || progress;
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index 8e90093..9f429d9 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -173,7 +173,7 @@ void st_init_limits(struct st_context *st)
> options->EmitNoNoise = TRUE;
>
> /* TODO: make these more fine-grained if anyone needs it */
> - options->EmitNoIfs = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
> + options->MaxIfLevel = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
> options->EmitNoLoops = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
> options->EmitNoFunctions = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
> options->EmitNoMainReturn = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 98bea69..f5232af 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -4991,10 +4991,10 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
>
> progress = lower_quadop_vector(ir, false) || progress;
>
> - if (options->EmitNoIfs) {
> + if (options->MaxIfLevel == 0)
> progress = lower_discard(ir) || progress;
> - progress = lower_if_to_cond_assign(ir) || progress;
> - }
> +
> + progress = lower_if_to_cond_assign(ir, options->MaxIfLevel) || progress;
>
> if (options->EmitNoNoise)
> progress = lower_noise(ir) || progress;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAk5e2NMACgkQX1gOwKyEAw8RnQCfa0PDGUegB+6fHQMxSpUOvrOs
lkwAn249dc0O/kfQNqlIs0EPIvuRspkV
=S3v0
-----END PGP SIGNATURE-----
More information about the mesa-dev
mailing list