Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Encorage dead-code elimination for unused interpolation channels
@ 2010-11-17  4:25 Peter Clifton
  2010-11-18  3:21 ` Eric Anholt
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Clifton @ 2010-11-17  4:25 UTC (permalink / raw)
  To: Intel

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

After some discussion with Eric on IRC, this is what I came up with
(which appears to work!)


-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
Tel: +44 (0)1223 748328 - (Shared lab phone, ask for me)

[-- Attachment #2: 0001-Enable-dead-code-elimination-for-unused-interpolated.patch --]
[-- Type: text/x-patch, Size: 2675 bytes --]

>From 5b20588a1eb4eb08d6762157a39d828015456d8b Mon Sep 17 00:00:00 2001
From: Peter Clifton <pcjc2@cam.ac.uk>
Date: Wed, 17 Nov 2010 04:05:48 +0000
Subject: [PATCH] Enable dead code elimination for unused interpolated channels

Work around limitations in the dead-code eliminator, and use
separate virtual registers for the PLN and MOV results. This
allows the dead-code eliminator to track the usage of the MOV
result and the PLN result separately.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 4648298..b4777aa 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -440,10 +440,13 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir)
 fs_reg *
 fs_visitor::emit_general_interpolation(ir_variable *ir)
 {
-   fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type);
+   fs_reg *reg1 = new(this->mem_ctx) fs_reg(this, ir->type);
+   fs_reg *reg2 = new(this->mem_ctx) fs_reg(this, ir->type);
    /* Interpolation is always in floating point regs. */
-   reg->type = BRW_REGISTER_TYPE_F;
-   fs_reg attr = *reg;
+   reg1->type = BRW_REGISTER_TYPE_F;
+   reg2->type = BRW_REGISTER_TYPE_F;
+   fs_reg attr1 = *reg1;
+   fs_reg attr2 = *reg2;
 
    unsigned int array_elements;
    const glsl_type *type;
@@ -466,7 +469,8 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
 	    /* If there's no incoming setup data for this slot, don't
 	     * emit interpolation for it.
 	     */
-	    attr.reg_offset += type->vector_elements;
+	    attr1.reg_offset += type->vector_elements;
+	    attr2.reg_offset += type->vector_elements;
 	    location++;
 	    continue;
 	 }
@@ -474,28 +478,29 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
 	 for (unsigned int c = 0; c < type->vector_elements; c++) {
 	    struct brw_reg interp = interp_reg(location, c);
 	    emit(fs_inst(FS_OPCODE_LINTERP,
-			 attr,
+			 attr1,
 			 this->delta_x,
 			 this->delta_y,
 			 fs_reg(interp)));
-	    attr.reg_offset++;
+	    attr1.reg_offset++;
 	 }
 
 	 if (intel->gen < 6) {
-	    attr.reg_offset -= type->vector_elements;
+	    attr1.reg_offset -= type->vector_elements;
 	    for (unsigned int c = 0; c < type->vector_elements; c++) {
 	       emit(fs_inst(BRW_OPCODE_MUL,
-			    attr,
-			    attr,
+			    attr2,
+			    attr1,
 			    this->pixel_w));
-	       attr.reg_offset++;
+	       attr1.reg_offset++;
+	       attr2.reg_offset++;
 	    }
 	 }
 	 location++;
       }
    }
 
-   return reg;
+   return reg2;
 }
 
 fs_reg *
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Encorage dead-code elimination for unused interpolation channels
  2010-11-17  4:25 [PATCH] Encorage dead-code elimination for unused interpolation channels Peter Clifton
@ 2010-11-18  3:21 ` Eric Anholt
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Anholt @ 2010-11-18  3:21 UTC (permalink / raw)
  To: Peter Clifton, Intel


[-- Attachment #1.1: Type: text/plain, Size: 446 bytes --]

On Wed, 17 Nov 2010 04:25:25 +0000, Peter Clifton <pcjc2@cam.ac.uk> wrote:
> After some discussion with Eric on IRC, this is what I came up with
> (which appears to work!)

The other way (fix up dead code eliminator) ended up deleting the same
gen code while also deleting C code.  As I thought about it, since at
some point we may want to handle, say, key.linear_color, I think it'll
be easier to not split interpolation into two separate regs.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-18  3:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-17  4:25 [PATCH] Encorage dead-code elimination for unused interpolation channels Peter Clifton
2010-11-18  3:21 ` Eric Anholt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox