Mesa (master): i965/fs: Store the number of sources an fs_inst has.

Matt Turner mattst88 at kemper.freedesktop.org
Sun Jun 1 20:26:20 UTC 2014


Module: Mesa
Branch: master
Commit: 27e12a8ea933e2f978e0ce9286422e6025c7377d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=27e12a8ea933e2f978e0ce9286422e6025c7377d

Author: Matt Turner <mattst88 at gmail.com>
Date:   Thu Feb 20 08:18:22 2014 -0800

i965/fs: Store the number of sources an fs_inst has.

Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_fs.cpp |   21 +++++++++++----------
 src/mesa/drivers/dri/i965/brw_fs.h   |    3 ++-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 4823108..5a7e270 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -52,11 +52,12 @@ extern "C" {
 #include "glsl/glsl_types.h"
 
 void
-fs_inst::init()
+fs_inst::init(int sources)
 {
    memset(this, 0, sizeof(*this));
 
-   this->src = ralloc_array(this, fs_reg, 3);
+   this->sources = sources;
+   this->src = ralloc_array(this, fs_reg, sources);
 
    this->conditional_mod = BRW_CONDITIONAL_NONE;
 
@@ -73,19 +74,19 @@ fs_inst::init()
 
 fs_inst::fs_inst()
 {
-   init();
+   init(3);
    this->opcode = BRW_OPCODE_NOP;
 }
 
 fs_inst::fs_inst(enum opcode opcode)
 {
-   init();
+   init(3);
    this->opcode = opcode;
 }
 
 fs_inst::fs_inst(enum opcode opcode, fs_reg dst)
 {
-   init();
+   init(3);
    this->opcode = opcode;
    this->dst = dst;
 
@@ -95,7 +96,7 @@ fs_inst::fs_inst(enum opcode opcode, fs_reg dst)
 
 fs_inst::fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0)
 {
-   init();
+   init(3);
    this->opcode = opcode;
    this->dst = dst;
    this->src[0] = src0;
@@ -108,7 +109,7 @@ fs_inst::fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0)
 
 fs_inst::fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0, fs_reg src1)
 {
-   init();
+   init(3);
    this->opcode = opcode;
    this->dst = dst;
    this->src[0] = src0;
@@ -125,7 +126,7 @@ fs_inst::fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0, fs_reg src1)
 fs_inst::fs_inst(enum opcode opcode, fs_reg dst,
 		 fs_reg src0, fs_reg src1, fs_reg src2)
 {
-   init();
+   init(3);
    this->opcode = opcode;
    this->dst = dst;
    this->src[0] = src0;
@@ -146,9 +147,9 @@ fs_inst::fs_inst(const fs_inst &that)
 {
    memcpy(this, &that, sizeof(that));
 
-   this->src = ralloc_array(this, fs_reg, 3);
+   this->src = ralloc_array(this, fs_reg, that.sources);
 
-   for (int i = 0; i < 3; i++)
+   for (int i = 0; i < that.sources; i++)
       this->src[i] = that.src[i];
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 11a5c7c..4f8a2b2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -190,7 +190,7 @@ class fs_inst : public backend_instruction {
 public:
    DECLARE_RALLOC_CXX_OPERATORS(fs_inst)
 
-   void init();
+   void init(int sources);
 
    fs_inst();
    fs_inst(enum opcode opcode);
@@ -216,6 +216,7 @@ public:
    uint32_t texture_offset; /**< Texture offset bitfield */
    uint32_t offset; /* spill/unspill offset */
 
+   uint8_t sources; /**< Number of fs_reg sources. */
    uint8_t conditional_mod; /**< BRW_CONDITIONAL_* */
 
    /* Chooses which flag subregister (f0.0 or f0.1) is used for conditional




More information about the mesa-commit mailing list