Mesa (master): i965: Just use memset() to clear most members in FS constructors.

Eric Anholt anholt at kemper.freedesktop.org
Sat Nov 20 02:58:22 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Nov 19 17:44:35 2010 +0800

i965: Just use memset() to clear most members in FS constructors.

This should make it a lot harder to forget to zero things.

---

 src/mesa/drivers/dri/i965/brw_fs.h |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 9b7fcde..896dc57 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -96,10 +96,7 @@ public:
 
    void init()
    {
-      this->reg = 0;
-      this->reg_offset = 0;
-      this->negate = 0;
-      this->abs = 0;
+      memset(this, 0, sizeof(*this));
       this->hw_reg = -1;
       this->smear = -1;
    }
@@ -174,6 +171,10 @@ public:
    } imm;
 };
 
+static const fs_reg reg_undef;
+static const fs_reg reg_null_f(ARF, BRW_ARF_NULL, BRW_REGISTER_TYPE_F);
+static const fs_reg reg_null_d(ARF, BRW_ARF_NULL, BRW_REGISTER_TYPE_D);
+
 class fs_inst : public exec_node {
 public:
    /* Callers of this talloc-based new need not call delete. It's
@@ -190,18 +191,14 @@ public:
 
    void init()
    {
+      memset(this, 0, sizeof(*this));
       this->opcode = BRW_OPCODE_NOP;
-      this->saturate = false;
       this->conditional_mod = BRW_CONDITIONAL_NONE;
-      this->predicated = false;
-      this->sampler = 0;
-      this->target = 0;
-      this->eot = false;
-      this->header_present = false;
-      this->shadow_compare = false;
-      this->mlen = 0;
-      this->base_mrf = 0;
-      this->offset = 0;
+
+      this->dst = reg_undef;
+      this->src[0] = reg_undef;
+      this->src[1] = reg_undef;
+      this->src[2] = reg_undef;
    }
 
    fs_inst()
@@ -454,9 +451,5 @@ public:
    int grf_used;
 };
 
-static const fs_reg reg_undef;
-static const fs_reg reg_null_f(ARF, BRW_ARF_NULL, BRW_REGISTER_TYPE_F);
-static const fs_reg reg_null_d(ARF, BRW_ARF_NULL, BRW_REGISTER_TYPE_D);
-
 GLboolean brw_do_channel_expressions(struct exec_list *instructions);
 GLboolean brw_do_vector_splitting(struct exec_list *instructions);




More information about the mesa-commit mailing list