radv: Centralize enabling thread trace.
[mesa.git] / src / amd / vulkan / radv_device.c
index ba71cf3023e33bdf970786d79b377f3f5c17a39f..e2a5727f934c2c8621622343a69a71058aa71b14 100644 (file)
@@ -1645,7 +1645,7 @@ radv_get_physical_device_properties_1_2(struct radv_physical_device *pdevice,
        p->conformanceVersion = (VkConformanceVersion) {
                .major = 1,
                .minor = 2,
-               .subminor = 0,
+               .subminor = 3,
                .patch = 0,
        };
 
@@ -2486,15 +2486,19 @@ radv_get_int_debug_option(const char *name, int default_value)
        return result;
 }
 
+static bool radv_thread_trace_enabled()
+{
+       return radv_get_int_debug_option("RADV_THREAD_TRACE", -1) >= 0;
+}
+
 static void
 radv_device_init_dispatch(struct radv_device *device)
 {
        const struct radv_instance *instance = device->physical_device->instance;
        const struct radv_device_dispatch_table *dispatch_table_layer = NULL;
        bool unchecked = instance->debug_flags & RADV_DEBUG_ALL_ENTRYPOINTS;
-       int radv_thread_trace = radv_get_int_debug_option("RADV_THREAD_TRACE", -1);
 
-       if (radv_thread_trace >= 0) {
+       if (radv_thread_trace_enabled()) {
                /* Use device entrypoints from the SQTT layer if enabled. */
                dispatch_table_layer = &sqtt_device_dispatch_table;
        }
@@ -2792,11 +2796,16 @@ VkResult radv_CreateDevice(
                fprintf(stderr, "*****************************************************************************\n");
 
                fprintf(stderr, "Trace file will be dumped to %s\n", filename);
+
+               /* Wait for idle after every draw/dispatch to identify the
+                * first bad call.
+                */
+               device->instance->debug_flags |= RADV_DEBUG_SYNC_SHADERS;
+
                radv_dump_enabled_options(device, stderr);
        }
 
-       int radv_thread_trace = radv_get_int_debug_option("RADV_THREAD_TRACE", -1);
-       if (radv_thread_trace >= 0) {
+       if (radv_thread_trace_enabled()) {
                fprintf(stderr, "*************************************************\n");
                fprintf(stderr, "* WARNING: Thread trace support is experimental *\n");
                fprintf(stderr, "*************************************************\n");
@@ -2811,7 +2820,7 @@ VkResult radv_CreateDevice(
                /* Default buffer size set to 1MB per SE. */
                device->thread_trace_buffer_size =
                        radv_get_int_debug_option("RADV_THREAD_TRACE_BUFFER_SIZE", 1024 * 1024);
-               device->thread_trace_start_frame = radv_thread_trace;
+               device->thread_trace_start_frame = radv_get_int_debug_option("RADV_THREAD_TRACE", -1);
 
                if (!radv_thread_trace_init(device))
                        goto fail;
@@ -2821,6 +2830,10 @@ VkResult radv_CreateDevice(
                /* TODO: Add support for more hardware. */
                assert(device->physical_device->rad_info.chip_class == GFX8);
 
+               fprintf(stderr, "**********************************************************************\n");
+               fprintf(stderr, "* WARNING: RADV_TRAP_HANDLER is experimental and only for debugging! *\n");
+               fprintf(stderr, "**********************************************************************\n");
+
                /* To get the disassembly of the faulty shaders, we have to
                 * keep some shader info around.
                 */
@@ -3271,8 +3284,8 @@ radv_get_hs_offchip_param(struct radv_device *device, uint32_t *max_offchip_buff
                if (device->physical_device->rad_info.chip_class >= GFX8)
                        --max_offchip_buffers;
                hs_offchip_param =
-                       S_03093C_OFFCHIP_BUFFERING(max_offchip_buffers) |
-                       S_03093C_OFFCHIP_GRANULARITY(offchip_granularity);
+                       S_03093C_OFFCHIP_BUFFERING_GFX7(max_offchip_buffers) |
+                       S_03093C_OFFCHIP_GRANULARITY_GFX7(offchip_granularity);
        } else {
                hs_offchip_param =
                        S_0089B0_OFFCHIP_BUFFERING(max_offchip_buffers);
@@ -7409,7 +7422,7 @@ radv_init_sampler(struct radv_device *device,
                sampler->state[2] |=
                        S_008F38_DISABLE_LSB_CEIL(device->physical_device->rad_info.chip_class <= GFX8) |
                        S_008F38_FILTER_PREC_FIX(1) |
-                       S_008F38_ANISO_OVERRIDE_GFX6(device->physical_device->rad_info.chip_class >= GFX8);
+                       S_008F38_ANISO_OVERRIDE_GFX8(device->physical_device->rad_info.chip_class >= GFX8);
        }
 }