<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 31 May 2018 at 21:15, Bas Nieuwenhuizen <span dir="ltr"><<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank">bas@basnieuwenhuizen.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, May 31, 2018 at 5:44 PM, Alex Smith <<a href="mailto:asmith@feralinteractive.com">asmith@feralinteractive.com</a>> wrote:<br>
> This was not previously handled correctly. For example,<br>
> push_constant_stages might only contain MESA_SHADER_VERTEX because<br>
> only that stage was changed by CmdPushConstants or<br>
> CmdBindDescriptorSets.<br>
><br>
> In that case, if vertex has been merged with tess control, then the<br>
> push constant address wouldn't be updated since<br>
> pipeline->shaders[MESA_SHADER_<wbr>VERTEX] would be NULL.<br>
><br>
> Use radv_get_shader() instead of getting the shader directly so that<br>
> we get the right shader if merged. Also, skip emitting the address<br>
> redundantly - if two merged stages are set in push_constant_stages<br>
> this change would have made the address get emitted twice.<br>
><br>
> Signed-off-by: Alex Smith <<a href="mailto:asmith@feralinteractive.com">asmith@feralinteractive.com</a>><br>
> Cc: "18.1" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
> ---<br>
>  src/amd/vulkan/radv_cmd_<wbr>buffer.c | 9 ++++++++-<br>
>  1 file changed, 8 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/src/amd/vulkan/radv_cmd_<wbr>buffer.c b/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
> index da9591b9a5..c6a2d6c5b9 100644<br>
> --- a/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
> +++ b/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
> @@ -1585,6 +1585,7 @@ radv_flush_constants(struct radv_cmd_buffer *cmd_buffer,<br>
>                                          ? cmd_buffer->state.compute_<wbr>pipeline<br>
>                                          : cmd_buffer->state.pipeline;<br>
>         struct radv_pipeline_layout *layout = pipeline->layout;<br>
> +       struct radv_shader_variant *shader, *prev_shader;<br>
>         unsigned offset;<br>
>         void *ptr;<br>
>         uint64_t va;<br>
> @@ -1609,11 +1610,17 @@ radv_flush_constants(struct radv_cmd_buffer *cmd_buffer,<br>
>         MAYBE_UNUSED unsigned cdw_max = radeon_check_space(cmd_buffer-<wbr>>device->ws,<br>
>                                                            cmd_buffer->cs, MESA_SHADER_STAGES * 4);<br>
><br>
> +       prev_shader = NULL;<br>
>         radv_foreach_stage(stage, stages) {<br>
> -               if (pipeline->shaders[stage]) {<br>
> +               shader = radv_get_shader(pipeline, stage);<br>
> +<br>
> +               /* Avoid redundantly emitting the address for merged stages. */<br>
> +               if (shader && shader != prev_shader) {<br>
>                         radv_emit_userdata_address(<wbr>cmd_buffer, pipeline, stage,<br>
>                                                    AC_UD_PUSH_CONSTANTS, va);<br>
>                 }<br>
> +<br>
> +               prev_shader = shader;<br>
<br>
</div></div>This emits the same shader twice if we have a geometry shader and a<br>
vertex shader but no tessellation shaders in cases were the stage mask<br>
is larger than needed and includes the tessellation stages. On the<br>
iteration for the tess shaders, prev_shader will be reset to NULL, and<br>
hence when we visit the geometry shader we will emit the constants<br>
again.<br>
<br>
I think this should be solved by moving the prev_shader update within<br>
the if statement.<br></blockquote><div><br></div><div>Good point. Fixed, and pushed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
With that, this series is<br>
<br>
Reviewed-by: Bas Nieuwenhuizen <<a href="mailto:bas@basnieuwenhuizen.nl">bas@basnieuwenhuizen.nl</a>><br>
<br>
Thanks a lot!<br>
<span class=""><br>
<br>
>         }<br>
><br>
>         cmd_buffer->push_constant_<wbr>stages &= ~stages;<br>
> --<br>
> 2.14.3<br>
><br>
</span>> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>