radv: re-emit VGT_INDEX_TYPE because non-indexed draws overwrite it
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 19 Oct 2017 10:35:46 +0000 (12:35 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 20 Oct 2017 08:40:01 +0000 (10:40 +0200)
Only on CIK and later. We should only update VGT_INDEX_TYPE but
it seems easier to re-emit all the index buffer packets.

Fixes: 966d66f28f (radv: do not re-emit the index buffer for every draw call)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c

index 9500e3ccb97a65dd15171a887dc271302c234977..1b6cea95dc7d17a753374003227652e1b63f9261 100644 (file)
@@ -1812,8 +1812,17 @@ radv_cmd_buffer_flush_state(struct radv_cmd_buffer *cmd_buffer,
        if (cmd_buffer->state.dirty & RADV_CMD_DIRTY_FRAMEBUFFER)
                radv_emit_framebuffer_state(cmd_buffer);
 
-       if (cmd_buffer->state.dirty & RADV_CMD_DIRTY_INDEX_BUFFER)
-               radv_emit_index_buffer(cmd_buffer);
+       if (indexed_draw) {
+               if (cmd_buffer->state.dirty & RADV_CMD_DIRTY_INDEX_BUFFER)
+                       radv_emit_index_buffer(cmd_buffer);
+       } else {
+               /* On CI and later, non-indexed draws overwrite VGT_INDEX_TYPE,
+                * so the state must be re-emitted before the next indexed
+                * draw.
+                */
+               if (cmd_buffer->device->physical_device->rad_info.chip_class >= CIK)
+                       cmd_buffer->state.dirty |= RADV_CMD_DIRTY_INDEX_BUFFER;
+       }
 
        ia_multi_vgt_param = si_get_ia_multi_vgt_param(cmd_buffer, instanced_draw, indirect_draw, draw_vertex_count);
        if (cmd_buffer->state.last_ia_multi_vgt_param != ia_multi_vgt_param) {