glsl_to_tgsi: each reladdr object should have only one parent
authorMarek Olšák <marek.olsak@amd.com>
Fri, 29 Sep 2017 00:38:53 +0000 (02:38 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 6 Oct 2017 00:56:11 +0000 (02:56 +0200)
required by rename_temp_registers.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp
src/mesa/state_tracker/st_glsl_to_tgsi_private.h

index 0075ae86766a2063467498ab08b380bc14f42b45..b664fa7ec3ffe2c6456c52d41b754fdd1ee8ca45 100644 (file)
@@ -44,6 +44,22 @@ static int swizzle_for_type(const glsl_type *type, int component = 0)
    return swizzle;
 }
 
+static st_src_reg *
+dup_reladdr(const st_src_reg *input)
+{
+   if (!input)
+      return NULL;
+
+   st_src_reg *reg = ralloc(input, st_src_reg);
+   if (!reg) {
+      assert(!"can't create reladdr, expect shader breakage");
+      return NULL;
+   }
+
+   *reg = *input;
+   return reg;
+}
+
 st_src_reg::st_src_reg(gl_register_file file, int index, const glsl_type *type,
                        int component, unsigned array_id)
 {
@@ -116,6 +132,28 @@ st_src_reg::st_src_reg()
    this->is_double_vertex_input = false;
 }
 
+st_src_reg::st_src_reg(const st_src_reg &reg)
+{
+   *this = reg;
+}
+
+void st_src_reg::operator=(const st_src_reg &reg)
+{
+   this->type = reg.type;
+   this->file = reg.file;
+   this->index = reg.index;
+   this->index2D = reg.index2D;
+   this->swizzle = reg.swizzle;
+   this->negate = reg.negate;
+   this->abs = reg.abs;
+   this->reladdr = dup_reladdr(reg.reladdr);
+   this->reladdr2 = dup_reladdr(reg.reladdr2);
+   this->has_index2 = reg.has_index2;
+   this->double_reg2 = reg.double_reg2;
+   this->array_id = reg.array_id;
+   this->is_double_vertex_input = reg.is_double_vertex_input;
+}
+
 st_src_reg::st_src_reg(st_dst_reg reg)
 {
    this->type = reg.type;
@@ -124,9 +162,9 @@ st_src_reg::st_src_reg(st_dst_reg reg)
    this->swizzle = SWIZZLE_XYZW;
    this->negate = 0;
    this->abs = 0;
-   this->reladdr = reg.reladdr;
+   this->reladdr = dup_reladdr(reg.reladdr);
    this->index2D = reg.index2D;
-   this->reladdr2 = reg.reladdr2;
+   this->reladdr2 = dup_reladdr(reg.reladdr2);
    this->has_index2 = reg.has_index2;
    this->double_reg2 = false;
    this->array_id = reg.array_id;
@@ -147,9 +185,9 @@ st_dst_reg::st_dst_reg(st_src_reg reg)
    this->file = reg.file;
    this->index = reg.index;
    this->writemask = WRITEMASK_XYZW;
-   this->reladdr = reg.reladdr;
+   this->reladdr = dup_reladdr(reg.reladdr);
    this->index2D = reg.index2D;
-   this->reladdr2 = reg.reladdr2;
+   this->reladdr2 = dup_reladdr(reg.reladdr2);
    this->has_index2 = reg.has_index2;
    this->array_id = reg.array_id;
 }
@@ -193,4 +231,22 @@ st_dst_reg::st_dst_reg()
    this->reladdr2 = NULL;
    this->has_index2 = false;
    this->array_id = 0;
-}
\ No newline at end of file
+}
+
+st_dst_reg::st_dst_reg(const st_dst_reg &reg)
+{
+   *this = reg;
+}
+
+void st_dst_reg::operator=(const st_dst_reg &reg)
+{
+   this->type = reg.type;
+   this->file = reg.file;
+   this->index = reg.index;
+   this->writemask = reg.writemask;
+   this->reladdr = dup_reladdr(reg.reladdr);
+   this->index2D = reg.index2D;
+   this->reladdr2 = dup_reladdr(reg.reladdr2);
+   this->has_index2 = reg.has_index2;
+   this->array_id = reg.array_id;
+}
index c92d96cf6c360230b0595304dc541252178e3b42..b9112e5e030526f00f086aa9642eb4840e100070 100644 (file)
@@ -47,6 +47,8 @@ public:
    st_src_reg(gl_register_file file, int index, enum glsl_base_type type, int index2D);
 
    st_src_reg();
+   st_src_reg(const st_src_reg &reg);
+   void operator=(const st_src_reg &reg);
 
    explicit st_src_reg(st_dst_reg reg);
 
@@ -81,6 +83,8 @@ public:
    st_dst_reg(gl_register_file file, int writemask, enum glsl_base_type type);
 
    st_dst_reg();
+   st_dst_reg(const st_dst_reg &reg);
+   void operator=(const st_dst_reg &reg);
 
    explicit st_dst_reg(st_src_reg reg);