i965: Initialize all member variables of vec4_instruction on construction.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 11 Sep 2013 23:20:18 +0000 (16:20 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 2 Oct 2013 00:30:51 +0000 (17:30 -0700)
The vec4_instruction object relies on the memory allocator zeroing out
its contents before it's initialized, which is quite an unusual
practice in the C++ world because it ties objects to some specific
allocation scheme, and gives unpredictable results when an object is
created with a different allocator -- Stack allocation, array
allocation, or aggregation inside a different object are some of the
useful possibilities that come to my mind.  Initialize all fields from
the constructor and stop using the zeroing allocator.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp

index 689040b933640529c40b2d4b9b815acff95cd1ab..847c75ebcf5a0e841f55f65502fdba54d8ad0821 100644 (file)
@@ -168,7 +168,7 @@ with_writemask(dst_reg const &r, int mask);
 
 class vec4_instruction : public backend_instruction {
 public:
-   DECLARE_RZALLOC_CXX_OPERATORS(vec4_instruction)
+   DECLARE_RALLOC_CXX_OPERATORS(vec4_instruction)
 
    vec4_instruction(vec4_visitor *v, enum opcode opcode,
                    dst_reg dst = dst_reg(),
index 3ff6a610359d6c067f18bf33697b3d785f454fe7..6b9c4c62f662aa9ef843adc4cdbc576b1f2ad197 100644 (file)
@@ -38,7 +38,22 @@ vec4_instruction::vec4_instruction(vec4_visitor *v,
    this->src[0] = src0;
    this->src[1] = src1;
    this->src[2] = src2;
+   this->saturate = false;
+   this->force_writemask_all = false;
+   this->no_dd_clear = false;
+   this->no_dd_check = false;
+   this->conditional_mod = BRW_CONDITIONAL_NONE;
+   this->sampler = 0;
+   this->texture_offset = 0;
+   this->target = 0;
+   this->shadow_compare = false;
    this->ir = v->base_ir;
+   this->urb_write_flags = BRW_URB_WRITE_NO_FLAGS;
+   this->header_present = false;
+   this->mlen = 0;
+   this->base_mrf = 0;
+   this->offset = 0;
+   this->ir = NULL;
    this->annotation = v->current_annotation;
 }