From 8602c6a32666c1cb1b4f20d2d6efa5a925726d39 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 29 Sep 2017 02:38:53 +0200 Subject: [PATCH] glsl_to_tgsi: each reladdr object should have only one parent MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit required by rename_temp_registers. Reviewed-by: Nicolai Hähnle --- .../state_tracker/st_glsl_to_tgsi_private.cpp | 66 +++++++++++++++++-- .../state_tracker/st_glsl_to_tgsi_private.h | 4 ++ 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp index 0075ae86766..b664fa7ec3f 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp @@ -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 ®) +{ + *this = reg; +} + +void st_src_reg::operator=(const st_src_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 ®) +{ + *this = reg; +} + +void st_dst_reg::operator=(const st_dst_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; +} diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h index c92d96cf6c3..b9112e5e030 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h @@ -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 ®); + void operator=(const st_src_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 ®); + void operator=(const st_dst_reg ®); explicit st_dst_reg(st_src_reg reg); -- 2.30.2