diff options
author | Eric Engestrom <[email protected]> | 2018-10-28 17:50:47 +0000 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2018-10-30 18:10:59 +0000 |
commit | 6000895e2dd20f8f737a7429db09ab6576301c86 (patch) | |
tree | 7a883626abec5f5abdefe80494d1e2bf4719ff34 /src/mesa | |
parent | 69eb6d58e86d2e0d3c074cc9e608713f3842a6a6 (diff) |
mesa: fix memcpy() and memset(0) of non-trivial structs
Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 11 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp | 7 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi_private.h | 1 |
3 files changed, 12 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index dea91c7a189..a61d4ddaf14 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2084,7 +2084,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op) emit_asm(ir, TGSI_OPCODE_USHR, st_dst_reg(index_reg), offset, st_src_reg_for_int(4)); cbuf.reladdr = ralloc(mem_ctx, st_src_reg); - memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg)); + *cbuf.reladdr = index_reg; } if (const_uniform_block) { @@ -2093,7 +2093,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op) } else { /* Relative/variable constant buffer */ cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg); - memcpy(cbuf.reladdr2, &op[0], sizeof(st_src_reg)); + *cbuf.reladdr2 = op[0]; } cbuf.has_index2 = true; @@ -2804,12 +2804,12 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir) if (is_2D) { src.reladdr2 = ralloc(mem_ctx, st_src_reg); - memcpy(src.reladdr2, &index_reg, sizeof(index_reg)); + *src.reladdr2 = index_reg; src.index2D = 0; src.has_index2 = true; } else { src.reladdr = ralloc(mem_ctx, st_src_reg); - memcpy(src.reladdr, &index_reg, sizeof(index_reg)); + *src.reladdr = index_reg; } } @@ -4146,8 +4146,7 @@ glsl_to_tgsi_visitor::get_deref_offsets(ir_dereference *ir, unsigned location = 0; ir_variable *var = ir->variable_referenced(); - memset(reladdr, 0, sizeof(*reladdr)); - reladdr->file = PROGRAM_UNDEFINED; + reladdr->reset(); *base = 0; *array_size = 1; 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 dabb0362a77..fd3941b3cc3 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp @@ -116,7 +116,7 @@ st_src_reg::st_src_reg(gl_register_file file, int index, enum glsl_base_type typ this->is_double_vertex_input = false; } -st_src_reg::st_src_reg() +void st_src_reg::reset() { this->type = GLSL_TYPE_ERROR; this->file = PROGRAM_UNDEFINED; @@ -133,6 +133,11 @@ st_src_reg::st_src_reg() this->is_double_vertex_input = false; } +st_src_reg::st_src_reg() +{ + reset(); +} + st_src_reg::st_src_reg(const st_src_reg ®) { *this = reg; 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 356d029f470..c82de951427 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h @@ -51,6 +51,7 @@ public: st_src_reg(); st_src_reg(const st_src_reg ®); void operator=(const st_src_reg ®); + void reset(); explicit st_src_reg(st_dst_reg reg); |