[Mesa-dev] [PATCH 2/2] st/glsl_to_tgsi: fix block copies of arrays of structs

Marek Olšák maraeo at gmail.com
Tue Oct 18 16:55:28 UTC 2016


For the series:

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Mon, Oct 17, 2016 at 7:25 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Use a full writemask in this case. This is relevant e.g. when a function
> has an inout argument which is an array of structs.
> ---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 1662f7f..b91ebaf 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -2964,24 +2964,26 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
>
>           if (variable->data.location == FRAG_RESULT_DEPTH)
>              l.writemask = WRITEMASK_Z;
>           else {
>              assert(variable->data.location == FRAG_RESULT_STENCIL);
>              l.writemask = WRITEMASK_Y;
>           }
>        } else if (ir->write_mask == 0) {
>           assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector());
>
> -         if (ir->lhs->type->is_array() || ir->lhs->type->is_matrix()) {
> -            unsigned num_elements = ir->lhs->type->without_array()->vector_elements;
> +         unsigned num_elements = ir->lhs->type->without_array()->vector_elements;
> +
> +         if (num_elements) {
>              l.writemask = u_bit_consecutive(0, num_elements);
>           } else {
> +            // The type is a struct or an array of (array of) structs.
>              l.writemask = WRITEMASK_XYZW;
>           }
>        } else {
>           l.writemask = ir->write_mask;
>        }
>
>        for (int i = 0; i < 4; i++) {
>           if (l.writemask & (1 << i)) {
>              first_enabled_chan = GET_SWZ(r.swizzle, i);
>              break;
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list