mesa: Replace the EmitNoIfs compiler flag with a MaxIfDepth flag.
authorBryan Cain <bryancain3@gmail.com>
Wed, 31 Aug 2011 22:28:53 +0000 (17:28 -0500)
committerBryan Cain <bryancain3@gmail.com>
Thu, 1 Sep 2011 02:49:26 +0000 (21:49 -0500)
This is a better, more fine-grained way of lowering if statements.  Fixes the
game And Yet It Moves on nv50.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i915/i915_context.c
src/mesa/main/mtypes.h
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 11bee140ab6e70f91ae597fb53c62862f916c010..e807281041adda1f2a5504b1847635301291091b 100644 (file)
@@ -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->MaxIfDepth = 0;
    fs_options->EmitNoNoise = GL_TRUE;
    fs_options->EmitNoPow = GL_TRUE;
    fs_options->EmitNoMainReturn = GL_TRUE;
index f2eb889feb4c22080725a962aca8bb5b04ff1f6e..44ebf0a5351a8c51206c2d51814458a211f2e949 100644 (file)
@@ -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 MaxIfDepth;               /**< Maximum nested IF blocks */
    GLuint MaxUnrollIterations;
 
    struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
index dd154db8b039ec43255b887513f04e30b006cc8b..9813c4ae8a5bd01e137a719c1621f789431f0de3 100644 (file)
@@ -3119,7 +3119,7 @@ get_mesa_program(struct gl_context *ctx,
 
       switch (mesa_inst->Opcode) {
       case OPCODE_IF:
-        if (options->EmitNoIfs) {
+        if (options->MaxIfDepth == 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->MaxIfDepth == 0)
            progress = lower_discard(ir) || progress;
-           progress = lower_if_to_cond_assign(ir) || progress;
-        }
+
+        progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
 
         if (options->EmitNoNoise)
            progress = lower_noise(ir) || progress;
index 8e900934054ed6a9e4d23f36751d0e64fa8d902a..322dbbfd51d37e8fe8d6e2463aa7fc1ab384af55 100644 (file)
@@ -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->MaxIfDepth = 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);
index 98bea69b9596ad12e15bbda550e400d326744772..e2857edf390517485cf7987071bcbc4587c6a38b 100644 (file)
@@ -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->MaxIfDepth == 0)
             progress = lower_discard(ir) || progress;
-            progress = lower_if_to_cond_assign(ir) || progress;
-         }
+
+         progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
 
          if (options->EmitNoNoise)
             progress = lower_noise(ir) || progress;