[Mesa-dev] [PATCH 18/19] i965/fs: Store the number of sources an fs_inst has.

Matt Turner mattst88 at gmail.com
Thu Feb 20 13:41:31 PST 2014


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

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 4d13446..997b411 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -54,12 +54,13 @@ extern "C" {
 __thread void *fs_inst::mem_ctx;
 
 void
-fs_inst::init()
+fs_inst::init(int sources)
 {
    memset(this, 0, sizeof(*this));
    assert(fs_inst::mem_ctx != NULL);
 
-   this->src = rzalloc_array(mem_ctx, fs_reg, 3);
+   this->sources = sources;
+   this->src = rzalloc_array(mem_ctx, fs_reg, sources);
 
    /* This will be the case for almost all instructions. */
    this->regs_written = 1;
@@ -67,7 +68,7 @@ fs_inst::init()
 
 fs_inst::fs_inst()
 {
-   init();
+   init(3);
    this->opcode = BRW_OPCODE_NOP;
 }
 
@@ -81,7 +82,7 @@ fs_inst::fs_inst(enum opcode opcode, const fs_reg &dst,
    if (&src1 == &reg_undef)
       assert(&src2 == &reg_undef);
 
-   init();
+   init(3);
 
    if (&src2 != &reg_undef) {
       goto src2;
@@ -117,9 +118,9 @@ fs_inst::fs_inst(const fs_inst &that)
 {
    memcpy(this, &that, sizeof(that));
 
-   this->src = ralloc_array(mem_ctx, fs_reg, 3);
+   this->src = ralloc_array(mem_ctx, 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 3623000..6929a26 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -173,7 +173,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, const fs_reg &dst = reg_undef,
@@ -204,6 +204,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
-- 
1.8.3.2



More information about the mesa-dev mailing list