[Mesa-dev] [PATCH 06/14] ir_to_mesa, glsl_to_tgsi: Remove try_emit_saturate

Ian Romanick idr at freedesktop.org
Tue Jun 24 10:37:10 PDT 2014


Unless it causes other probmes, patches 6, 9, and 10 should go after the
patches that optimize min(max()) and max(min()) to saturate.  Otherwise
there may be odd performance regressions in bisects.  Generally we don't
want to remove code until after it's no longer used... unless that
causes other problems.

On 06/23/2014 10:27 PM, Abdiel Janulgue wrote:
> Now that sature is implemented natively as instruction,
> we can cut down on uneeded functionality
> 
> Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
> ---
>  src/mesa/program/ir_to_mesa.cpp            | 48 ----------------------------
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 51 ------------------------------
>  2 files changed, 99 deletions(-)
> 
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index 4f32b7d..96dcd14 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -311,7 +311,6 @@ public:
>  			  int mul_operand);
>     bool try_emit_mad_for_and_not(ir_expression *ir,
>  				 int mul_operand);
> -   bool try_emit_sat(ir_expression *ir);
>  
>     void emit_swz(ir_expression *ir);
>  
> @@ -872,50 +871,6 @@ ir_to_mesa_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operand)
>     return true;
>  }
>  
> -bool
> -ir_to_mesa_visitor::try_emit_sat(ir_expression *ir)
> -{
> -   /* Saturates were only introduced to vertex programs in
> -    * NV_vertex_program3, so don't give them to drivers in the VP.
> -    */
> -   if (this->prog->Target == GL_VERTEX_PROGRAM_ARB)
> -      return false;
> -
> -   ir_rvalue *sat_src = ir->as_rvalue_to_saturate();
> -   if (!sat_src)
> -      return false;
> -
> -   sat_src->accept(this);
> -   src_reg src = this->result;
> -
> -   /* If we generated an expression instruction into a temporary in
> -    * processing the saturate's operand, apply the saturate to that
> -    * instruction.  Otherwise, generate a MOV to do the saturate.
> -    *
> -    * Note that we have to be careful to only do this optimization if
> -    * the instruction in question was what generated src->result.  For
> -    * example, ir_dereference_array might generate a MUL instruction
> -    * to create the reladdr, and return us a src reg using that
> -    * reladdr.  That MUL result is not the value we're trying to
> -    * saturate.
> -    */
> -   ir_expression *sat_src_expr = sat_src->as_expression();
> -   ir_to_mesa_instruction *new_inst;
> -   new_inst = (ir_to_mesa_instruction *)this->instructions.get_tail();
> -   if (sat_src_expr && (sat_src_expr->operation == ir_binop_mul ||
> -			sat_src_expr->operation == ir_binop_add ||
> -			sat_src_expr->operation == ir_binop_dot)) {
> -      new_inst->saturate = true;
> -   } else {
> -      this->result = get_temp(ir->type);
> -      ir_to_mesa_instruction *inst;
> -      inst = emit(ir, OPCODE_MOV, dst_reg(this->result), src);
> -      inst->saturate = true;
> -   }
> -
> -   return true;
> -}
> -
>  void
>  ir_to_mesa_visitor::reladdr_to_temp(ir_instruction *ir,
>  				    src_reg *reg, int *num_reladdr)
> @@ -1078,9 +1033,6 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
>  	 return;
>     }
>  
> -   if (try_emit_sat(ir))
> -      return;
> -
>     if (ir->operation == ir_quadop_vector) {
>        this->emit_swz(ir);
>        return;
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 5381abd..886e304 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -445,7 +445,6 @@ public:
>                int mul_operand);
>     bool try_emit_mad_for_and_not(ir_expression *ir,
>                int mul_operand);
> -   bool try_emit_sat(ir_expression *ir);
>  
>     void emit_swz(ir_expression *ir);
>  
> @@ -1276,53 +1275,6 @@ glsl_to_tgsi_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operan
>     return true;
>  }
>  
> -bool
> -glsl_to_tgsi_visitor::try_emit_sat(ir_expression *ir)
> -{
> -   /* Emit saturates in the vertex shader only if SM 3.0 is supported.
> -    */
> -   if (this->prog->Target == GL_VERTEX_PROGRAM_ARB &&
> -       !st_context(this->ctx)->has_shader_model3) {
> -      return false;
> -   }
> -
> -   ir_rvalue *sat_src = ir->as_rvalue_to_saturate();
> -   if (!sat_src)
> -      return false;
> -
> -   sat_src->accept(this);
> -   st_src_reg src = this->result;
> -
> -   /* If we generated an expression instruction into a temporary in
> -    * processing the saturate's operand, apply the saturate to that
> -    * instruction.  Otherwise, generate a MOV to do the saturate.
> -    *
> -    * Note that we have to be careful to only do this optimization if
> -    * the instruction in question was what generated src->result.  For
> -    * example, ir_dereference_array might generate a MUL instruction
> -    * to create the reladdr, and return us a src reg using that
> -    * reladdr.  That MUL result is not the value we're trying to
> -    * saturate.
> -    */
> -   ir_expression *sat_src_expr = sat_src->as_expression();
> -   if (sat_src_expr && (sat_src_expr->operation == ir_binop_mul ||
> -			sat_src_expr->operation == ir_binop_add ||
> -			sat_src_expr->operation == ir_binop_dot)) {
> -      glsl_to_tgsi_instruction *new_inst;
> -      new_inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail();
> -      new_inst->saturate = true;
> -   } else {
> -      this->result = get_temp(ir->type);
> -      st_dst_reg result_dst = st_dst_reg(this->result);
> -      result_dst.writemask = (1 << ir->type->vector_elements) - 1;
> -      glsl_to_tgsi_instruction *inst;
> -      inst = emit(ir, TGSI_OPCODE_MOV, result_dst, src);
> -      inst->saturate = true;
> -   }
> -
> -   return true;
> -}
> -
>  void
>  glsl_to_tgsi_visitor::reladdr_to_temp(ir_instruction *ir,
>          			    st_src_reg *reg, int *num_reladdr)
> @@ -1369,9 +1321,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
>  	 return;
>     }
>  
> -   if (try_emit_sat(ir))
> -      return;
> -
>     if (ir->operation == ir_quadop_vector)
>        assert(!"ir_quadop_vector should have been lowered");
>  
> 



More information about the mesa-dev mailing list