glsl: Pass ctx->Const.NativeIntegers to do_common_optimization().
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 7 Apr 2014 06:25:00 +0000 (23:25 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 8 Apr 2014 07:02:03 +0000 (00:02 -0700)
The next few patches will introduce an optimization that only works when
integers are not represented as floating point values.

v2: Re-word-wrap a line, as requested by Ian Romanick.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/glsl_parser_extras.cpp
src/glsl/ir_optimization.h
src/glsl/linker.cpp
src/glsl/test_optpass.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/main/ff_fragment_shader.cpp
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 8422ba6f00b7e31805bf4e19b57d4ae95fbcff0c..532b6a5e7c05eca2865cdbac8e203e8cecd31ca4 100644 (file)
@@ -1444,7 +1444,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
       /* Do some optimization at compile time to reduce shader IR size
        * and reduce later work if the same shader is linked multiple times
        */
-      while (do_common_optimization(shader->ir, false, false, 32, options))
+      while (do_common_optimization(shader->ir, false, false, 32, options,
+                                    ctx->Const.NativeIntegers))
          ;
 
       validate_ir_tree(shader->ir);
@@ -1492,7 +1493,8 @@ bool
 do_common_optimization(exec_list *ir, bool linked,
                       bool uniform_locations_assigned,
                       unsigned max_unroll_iterations,
-                       const struct gl_shader_compiler_options *options)
+                       const struct gl_shader_compiler_options *options,
+                       bool native_integers)
 {
    GLboolean progress = GL_FALSE;
 
index 5f4a2f4051ccee4d6b752d840c40d67ec522ce98..9f31826d901c38fbdfd5f8093fd291babfe08894 100644 (file)
@@ -67,7 +67,8 @@ enum lower_packing_builtins_op {
 bool do_common_optimization(exec_list *ir, bool linked,
                            bool uniform_locations_assigned,
                            unsigned max_unroll_iterations,
-                            const struct gl_shader_compiler_options *options);
+                            const struct gl_shader_compiler_options *options,
+                            bool native_integers);
 
 bool do_algebraic(exec_list *instructions);
 bool do_constant_folding(exec_list *instructions);
index 3bf27896523c2dca7956a36ea1b5b230e09d28a1..7c194a26a3687f86e56884af6b92141ef7bd5c6a 100644 (file)
@@ -2298,7 +2298,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
 
       unsigned max_unroll = ctx->ShaderCompilerOptions[i].MaxUnrollIterations;
 
-      while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false, max_unroll, &ctx->ShaderCompilerOptions[i]))
+      while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false,
+                                    max_unroll, &ctx->ShaderCompilerOptions[i],
+                                    ctx->Const.NativeIntegers))
         ;
    }
 
index f1b9579cd3b73104db1e12e55caec3bb5cbbb1ef..6cb902aa2e1cd7bfd4769095e87fa98fdf6d111c 100644 (file)
@@ -64,7 +64,7 @@ do_optimization(struct exec_list *ir, const char *optimization,
 
    if (sscanf(optimization, "do_common_optimization ( %d , %d ) ",
               &int_0, &int_1) == 2) {
-      return do_common_optimization(ir, int_0 != 0, false, int_1, options);
+      return do_common_optimization(ir, int_0 != 0, false, int_1, options, true);
    } else if (strcmp(optimization, "do_algebraic") == 0) {
       return do_algebraic(ir);
    } else if (strcmp(optimization, "do_constant_folding") == 0) {
index ca448d02fb3484213ff88c1d2a4b81936349bf76..d8eecb39403f8e9f6899dc4621bbe5a1936104dc 100644 (file)
@@ -202,7 +202,8 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
                                   ) || progress;
 
         progress = do_common_optimization(shader->base.ir, true, true, 32,
-                                           &ctx->ShaderCompilerOptions[stage])
+                                           &ctx->ShaderCompilerOptions[stage],
+                                           ctx->Const.NativeIntegers)
           || progress;
       } while (progress);
 
index 1d2ad604b5c074f5eeb4339a5930e6a2113abd3f..e41dcefb0c66c5b3ac577f9a610461641157147d 100644 (file)
@@ -1344,7 +1344,8 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
    const struct gl_shader_compiler_options *options =
       &ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
 
-   while (do_common_optimization(p.shader->ir, false, false, 32, options))
+   while (do_common_optimization(p.shader->ir, false, false, 32, options,
+                                 ctx->Const.NativeIntegers))
       ;
    reparent_ir(p.shader->ir, p.shader->ir);
 
index 0923357b1bb20829e322804c35b8f0e4832daf99..675e58e2a9733ebc38c63527778e670ed58d1fdb 100644 (file)
@@ -3008,7 +3008,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 
         progress = do_common_optimization(ir, true, true,
                                           options->MaxUnrollIterations,
-                                           options)
+                                           options, ctx->Const.NativeIntegers)
           || progress;
 
         progress = lower_quadop_vector(ir, true) || progress;
index c3e36eceab40f881b779f788d05187d1854c9b75..28e8f1ecbc592c0916c6a797e1548058f16af9a9 100644 (file)
@@ -5358,7 +5358,9 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
          progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
 
          progress = do_common_optimization(ir, true, true,
-                                          options->MaxUnrollIterations, options)
+                                          options->MaxUnrollIterations,
+                                           options,
+                                           ctx->Const.NativeIntegers)
           || progress;
 
          progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;