[Mesa-dev] [PATCH 13/14] mesa: remove gl_shader_compiler_options::EmitNoMainReturn

Marek Olšák maraeo at gmail.com
Mon Oct 17 13:39:25 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

it's always true
---
 src/mesa/drivers/dri/i915/i915_context.c   | 1 -
 src/mesa/drivers/dri/i965/brw_compiler.c   | 1 -
 src/mesa/main/mtypes.h                     | 1 -
 src/mesa/program/ir_to_mesa.cpp            | 9 ++++-----
 src/mesa/state_tracker/st_extensions.c     | 1 -
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +-
 6 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
index 83aaf9e..a7604a1 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -255,21 +255,20 @@ i915CreateContext(int api,
     * FINISHME: vertex shaders?
     */
    ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoIndirectSampler =
       true;
 
    struct gl_shader_compiler_options *const fs_options =
       & ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
    fs_options->MaxIfDepth = 0;
    fs_options->EmitNoNoise = true;
    fs_options->EmitNoPow = true;
-   fs_options->EmitNoMainReturn = true;
    fs_options->EmitNoIndirectInput = true;
    fs_options->EmitNoIndirectOutput = true;
    fs_options->EmitNoIndirectUniform = true;
    fs_options->EmitNoIndirectTemp = true;
    fs_options->EmitNoIndirectSampler = true;
 
    ctx->Const.MaxDrawBuffers = 1;
    ctx->Const.QueryCounterBits.SamplesPassed = 0;
 
    _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12,
diff --git a/src/mesa/drivers/dri/i965/brw_compiler.c b/src/mesa/drivers/dri/i965/brw_compiler.c
index 86b1eaa..27cbd40 100644
--- a/src/mesa/drivers/dri/i965/brw_compiler.c
+++ b/src/mesa/drivers/dri/i965/brw_compiler.c
@@ -117,21 +117,20 @@ brw_compiler_create(void *mem_ctx, const struct gen_device_info *devinfo)
    compiler->scalar_stage[MESA_SHADER_FRAGMENT] = true;
    compiler->scalar_stage[MESA_SHADER_COMPUTE] = true;
 
    /* We want the GLSL compiler to emit code that uses condition codes */
    for (int i = 0; i < MESA_SHADER_STAGES; i++) {
       compiler->glsl_compiler_options[i].MaxUnrollIterations = 32;
       compiler->glsl_compiler_options[i].MaxIfDepth =
          devinfo->gen < 6 ? 16 : UINT_MAX;
 
       compiler->glsl_compiler_options[i].EmitNoNoise = true;
-      compiler->glsl_compiler_options[i].EmitNoMainReturn = true;
       compiler->glsl_compiler_options[i].EmitNoIndirectInput = true;
       compiler->glsl_compiler_options[i].EmitNoIndirectUniform = false;
       compiler->glsl_compiler_options[i].LowerCombinedClipCullDistance = true;
 
       bool is_scalar = compiler->scalar_stage[i];
 
       compiler->glsl_compiler_options[i].EmitNoIndirectOutput = is_scalar;
       compiler->glsl_compiler_options[i].EmitNoIndirectTemp = is_scalar;
       compiler->glsl_compiler_options[i].OptimizeForAOS = !is_scalar;
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5368440..701f055 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2990,21 +2990,20 @@ struct gl_pipeline_shader_state
 };
 
 /**
  * Compiler options for a single GLSL shaders type
  */
 struct gl_shader_compiler_options
 {
    /** Driver-selectable options: */
    GLboolean EmitNoLoops;
    GLboolean EmitNoCont;                  /**< Emit CONT opcode? */
-   GLboolean EmitNoMainReturn;            /**< Emit CONT/RET opcodes? */
    GLboolean EmitNoNoise;                 /**< Emit NOISE opcodes? */
    GLboolean EmitNoPow;                   /**< Emit POW opcodes? */
    GLboolean EmitNoSat;                   /**< Emit SAT opcodes? */
    GLboolean LowerCombinedClipCullDistance; /** Lower gl_ClipDistance and
                                               * gl_CullDistance together from
                                               * float[8] to vec4[2]
                                               **/
 
    /**
     * \name Forms of indirect addressing the driver cannot do.
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index debc18d..d0e83cc 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2154,25 +2154,24 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
    default:
       assert(!"Should not get here.");
    }
 
    this->result = result_src;
 }
 
 void
 ir_to_mesa_visitor::visit(ir_return *ir)
 {
-   /* Non-void functions should have been inlined.  We may still emit RETs
-    * from main() unless the EmitNoMainReturn option is set.
+   /* Non-void functions should have been inlined and RETs should have been
+    * lowered.
     */
-   assert(!ir->get_value());
-   emit(ir, OPCODE_RET);
+   unreachable("ir_return not supported");
 }
 
 void
 ir_to_mesa_visitor::visit(ir_discard *ir)
 {
    if (!ir->condition)
       ir->condition = new(mem_ctx) ir_constant(true);
 
    ir->condition->accept(this);
    this->result.negate = ~this->result.negate;
@@ -2977,21 +2976,21 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 
       do {
 	 progress = false;
 
 	 /* Lowering */
 	 do_mat_op_to_vec(ir);
 	 lower_instructions(ir, (MOD_TO_FLOOR | DIV_TO_MUL_RCP | EXP_TO_EXP2
 				 | LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP
 				 | ((options->EmitNoPow) ? POW_TO_EXP2 : 0)));
 
-	 progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
+	 progress = do_lower_jumps(ir, true, true, true, options->EmitNoCont, options->EmitNoLoops) || progress;
 
 	 progress = do_common_optimization(ir, true, true,
                                            options, ctx->Const.NativeIntegers)
 	   || progress;
 
 	 progress = lower_quadop_vector(ir, true) || progress;
 
 	 if (options->MaxIfDepth == 0)
 	    progress = lower_discard(ir) || progress;
 
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index ebb5d0a..238e279 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -265,21 +265,20 @@ void st_init_limits(struct pipe_screen *screen,
 
       options->EmitNoNoise = TRUE;
 
       /* TODO: make these more fine-grained if anyone needs it */
       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->EmitNoMainReturn = true;
 
       options->EmitNoCont =
          !screen->get_shader_param(screen, sh,
                                    PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED);
 
       options->EmitNoIndirectInput =
          !screen->get_shader_param(screen, sh,
                                    PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR);
       options->EmitNoIndirectOutput =
          !screen->get_shader_param(screen, sh,
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 65db521..91d87af 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6741,21 +6741,21 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       lower_vector_insert(ir, true);
       lower_quadop_vector(ir, false);
       lower_noise(ir);
       if (options->MaxIfDepth == 0) {
          lower_discard(ir);
       }
 
       do {
          progress = false;
 
-         progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
+         progress = do_lower_jumps(ir, true, true, true, options->EmitNoCont, options->EmitNoLoops) || progress;
 
          progress = do_common_optimization(ir, true, true, options,
                                            ctx->Const.NativeIntegers)
            || progress;
 
          progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
 
       } while (progress);
 
       validate_ir_tree(ir);
-- 
2.7.4



More information about the mesa-dev mailing list