radv: add debug flags for syncing shaders after every draw call
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 11 Sep 2017 13:00:41 +0000 (15:00 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 14 Sep 2017 08:37:57 +0000 (10:37 +0200)
To improve GPU hangs detection when shaders are stucked.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c

index bf6d157bf9a7a7f9ec3be72a83a0c7fa935565af..2f72b2bbcea80538f9f795a13fcea06d825cb48c 100644 (file)
@@ -32,6 +32,7 @@
 #include "sid.h"
 #include "gfx9d.h"
 #include "vk_format.h"
+#include "radv_debug.h"
 #include "radv_meta.h"
 
 #include "ac_debug.h"
@@ -368,6 +369,20 @@ void radv_cmd_buffer_trace_emit(struct radv_cmd_buffer *cmd_buffer)
 static void
 radv_cmd_buffer_after_draw(struct radv_cmd_buffer *cmd_buffer)
 {
+       if (cmd_buffer->device->debug_flags & RADV_DEBUG_SYNC_SHADERS) {
+               enum radv_cmd_flush_bits flags;
+
+               /* Force wait for graphics/compute engines to be idle. */
+               flags = RADV_CMD_FLAG_PS_PARTIAL_FLUSH |
+                       RADV_CMD_FLAG_CS_PARTIAL_FLUSH;
+
+               si_cs_emit_cache_flush(cmd_buffer->cs, false,
+                                      cmd_buffer->device->physical_device->rad_info.chip_class,
+                                      NULL, 0,
+                                      radv_cmd_buffer_uses_mec(cmd_buffer),
+                                      flags);
+       }
+
        radv_cmd_buffer_trace_emit(cmd_buffer);
 }
 
index e45c987e6a3e6f215aa8dfa51e38c1bdcdf38c2b..5c9cbade47c7d59b9a9ca764f8512d93750b7573 100644 (file)
@@ -40,6 +40,7 @@ enum {
        RADV_DEBUG_DUMP_SPIRV        = 0x400,
        RADV_DEBUG_VM_FAULTS         = 0x800,
        RADV_DEBUG_ZERO_VRAM         = 0x1000,
+       RADV_DEBUG_SYNC_SHADERS      = 0x2000,
 };
 
 enum {
index 3c512bd263b770ac54a2eb9e639ef6978a6e31d2..8de1bb3b0c1af948d9351eead2a9b8fd30589a5d 100644 (file)
@@ -413,6 +413,7 @@ static const struct debug_control radv_debug_options[] = {
        {"spirv", RADV_DEBUG_DUMP_SPIRV},
        {"vmfaults", RADV_DEBUG_VM_FAULTS},
        {"zerovram", RADV_DEBUG_ZERO_VRAM},
+       {"syncshaders", RADV_DEBUG_SYNC_SHADERS},
        {NULL, 0}
 };