Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Clifton <pcjc2@cam.ac.uk>
To: Intel <intel-gfx@lists.freedesktop.org>
Subject: [PATCH] Encorage dead-code elimination for unused interpolation channels
Date: Wed, 17 Nov 2010 04:25:25 +0000	[thread overview]
Message-ID: <1289967925.30171.1.camel@pcjc2lap> (raw)

[-- 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

             reply	other threads:[~2010-11-17  4:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-17  4:25 Peter Clifton [this message]
2010-11-18  3:21 ` [PATCH] Encorage dead-code elimination for unused interpolation channels Eric Anholt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1289967925.30171.1.camel@pcjc2lap \
    --to=pcjc2@cam.ac.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox