<p dir="ltr"><br>
On Oct 15, 2015 15:17, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br>
><br>
> The scalar VS backend has never handled float[] and vec2[] outputs<br>
> correctly (my original code was broken).  Outputs need to be padded<br>
> out to vec4 slots.<br>
><br>
> In fs_visitor::nir_setup_outputs(), we tried to process each vec4 slot<br>
> by looping from 0 to ALIGN(type_size_scalar(type), 4) / 4.  However,<br>
> this is wrong: type_size_scalar() for a float[2] would return 2, or<br>
> for vec2[2] it would return 4.  This looked like a single slot, even<br>
> though in reality each array element would be stored in separate vec4<br>
> slots.</p>
<p dir="ltr">I thought that looked fishy.</p>
<p dir="ltr">> Because of this bug, outputs[] and output_components[] would not get<br>
> initialized for the second element's VARYING_SLOT, which meant<br>
> emit_urb_writes() would skip writing them.  Nothing used those values,<br>
> and dead code elimination threw a party.</p>
<p dir="ltr">Heh.</p>
<p dir="ltr">> The new type_size_4x() function pads array elements correctly, but<br>
> still counts in scalar components, generating correct indices in<br>
> store_output intrinsics.<br>
><br>
> Not observed to fix any Piglit or dEQP tests, but does fix various<br>
> tcs-input Piglit tests on a branch that implements tessellation shaders.<br>
><br>
> Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.org</a><br>
> Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> ---<br>
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +-<br>
>  src/mesa/drivers/dri/i965/brw_nir.c      | 3 ++-<br>
>  2 files changed, 3 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> index 0e044d0..a290656 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> @@ -93,7 +93,7 @@ fs_visitor::nir_setup_outputs()<br>
><br>
>        switch (stage) {<br>
>        case MESA_SHADER_VERTEX:<br>
> -         for (unsigned int i = 0; i < ALIGN(type_size_scalar(var->type), 4) / 4; i++) {<br>
> +         for (int i = 0; i < type_size_4x(var->type) / 4; i++) {</p>
<p dir="ltr">Why not just type_size_vec4?  I know it makes it match what's below but as long as we define type_size_4x nearby and as Connor said in the other patch, it should he fairly obvious.</p>
<p dir="ltr">For that matter we could just make it a static function defined right above nir_setup_outputs.  If that's the case, probably just squash it into this patch?</p>
<p dir="ltr">>              int output = var->data.location + i;<br>
>              this->outputs[output] = offset(reg, bld, 4 * i);<br>
>              this->output_components[output] = vector_elements;<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c<br>
> index 1b4dace..c7f94a6 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_nir.c<br>
> +++ b/src/mesa/drivers/dri/i965/brw_nir.c<br>
> @@ -117,7 +117,8 @@ brw_nir_lower_outputs(nir_shader *nir, bool is_scalar)<br>
>     case MESA_SHADER_GEOMETRY:<br>
>        if (is_scalar) {<br>
>           nir_assign_var_locations(&nir->outputs, &nir->num_outputs,<br>
> -                                  type_size_scalar);<br>
> +                                  type_size_4x);<br>
> +         nir_lower_io(nir, nir_var_shader_out, type_size_4x);<br>
>        } else {<br>
>           nir_foreach_variable(var, &nir->outputs)<br>
>              var->data.driver_location = var->data.location;<br>
> --<br>
> 2.6.1<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>