[Mesa-dev] [PATCH] i965: Actually use the Mesa IR optimizer.

Ian Romanick idr at freedesktop.org
Tue Jun 10 11:59:46 PDT 2014


On 06/09/2014 12:36 AM, Kenneth Graunke wrote:
> We have this wonderful thing called an optimizer---maybe we should
> consider calling it?

That's really weird.  The *only* place this is called is in ir_to_mesa.
 It seems like the assember should just call it after assembling any
program.  Weird.  Either way, this patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> Slightly improves the vertex shaders in Shadowrun Returns, which uses
> ARB_vertex_program and ARB_fragment_program:
> 
> total instructions in shared programs: 117131 -> 117016 (-0.10%)
> instructions in affected programs:     6771 -> 6656 (-1.70%)
> 
> No fragment programs were helped.  Presumably, we don't see any benefits
> for FS because our FS backend has a much better optimizer than our vec4
> backend.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_fs_fp.cpp   | 2 ++
>  src/mesa/drivers/dri/i965/brw_vec4_vp.cpp | 3 +++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
> index ba5514a..d71c43b 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
> @@ -113,6 +113,8 @@ fs_visitor::emit_fp_scalar_math(enum opcode opcode,
>  void
>  fs_visitor::emit_fragment_program_code()
>  {
> +   _mesa_optimize_program(ctx, prog);
> +
>     setup_fp_regs();
>  
>     fs_reg null = fs_reg(brw_null_reg());
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp b/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp
> index f1000f2..c1b9a2d 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp
> @@ -31,6 +31,7 @@
>  #include "brw_vec4.h"
>  #include "brw_vs.h"
>  extern "C" {
> +#include "program/prog_optimize.h"
>  #include "program/prog_parameter.h"
>  #include "program/prog_print.h"
>  }
> @@ -53,6 +54,8 @@ vec4_visitor::emit_vp_sop(uint32_t conditional_mod,
>  void
>  vec4_vs_visitor::emit_program_code()
>  {
> +   _mesa_optimize_program(ctx, prog);
> +
>     this->need_all_constants_in_pull_buffer = false;
>  
>     setup_vp_regs();
> 



More information about the mesa-dev mailing list