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

Kenneth Graunke kenneth at whitecape.org
Mon Jun 9 00:36:09 PDT 2014


We have this wonderful thing called an optimizer---maybe we should
consider calling it?

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();
-- 
2.0.0



More information about the mesa-dev mailing list