radv: move RADV_TRACE_FILE functions to radv_debug.c
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 30 Aug 2017 13:12:20 +0000 (15:12 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 1 Sep 2017 07:41:54 +0000 (09:41 +0200)
At the moment, debugging radv is not really easy because the
driver doesn't report enough information when it hangs. This
new file will be the main location for all debug tools.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/Makefile.sources
src/amd/vulkan/radv_debug.c [new file with mode: 0644]
src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_image.c
src/amd/vulkan/radv_meta_clear.c
src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_pipeline_cache.c
src/amd/vulkan/radv_private.h

index d3e0c81e9a3a36f4038e3b552be0d36fd207c71f..96399a246e25d788fd1fdea5152f7c931c3ae538 100644 (file)
@@ -33,6 +33,7 @@ RADV_WS_AMDGPU_FILES := \
 VULKAN_FILES := \
        radv_cmd_buffer.c \
        radv_cs.h \
+       radv_debug.c \
        radv_debug.h \
        radv_device.c \
        radv_descriptor_set.c \
diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c
new file mode 100644 (file)
index 0000000..2c3f015
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2016 Red Hat.
+ * Copyright © 2016 Bas Nieuwenhuizen
+ *
+ * based in part on anv driver which is:
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "radv_debug.h"
+
+bool
+radv_init_trace(struct radv_device *device)
+{
+       struct radeon_winsys *ws = device->ws;
+
+       device->trace_bo = ws->buffer_create(ws, 4096, 8, RADEON_DOMAIN_VRAM,
+                                            RADEON_FLAG_CPU_ACCESS);
+       if (!device->trace_bo)
+               return false;
+
+       device->trace_id_ptr = ws->buffer_map(device->trace_bo);
+       if (!device->trace_id_ptr)
+               return false;
+
+       return true;
+}
+
+void
+radv_dump_trace(struct radv_device *device, struct radeon_winsys_cs *cs)
+{
+       const char *filename = getenv("RADV_TRACE_FILE");
+       FILE *f = fopen(filename, "w");
+
+       if (!f) {
+               fprintf(stderr, "Failed to write trace dump to %s\n", filename);
+               return;
+       }
+
+       fprintf(f, "Trace ID: %x\n", *device->trace_id_ptr);
+       device->ws->cs_dump(cs, f, (const int*)device->trace_id_ptr, 2);
+       fclose(f);
+}
index c345d040c5d1e0bf5189c6745f89559f22e7ad23..cbb095f747b10b564d42ab357b3c268f81921a18 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef RADV_DEBUG_H
 #define RADV_DEBUG_H
 
+#include "radv_private.h"
+
 enum {
        RADV_DEBUG_NO_FAST_CLEARS    =   0x1,
        RADV_DEBUG_NO_DCC            =   0x2,
@@ -41,4 +43,11 @@ enum {
        RADV_PERFTEST_BATCHCHAIN     =   0x1,
        RADV_PERFTEST_SISCHED        =   0x2,
 };
+
+bool
+radv_init_trace(struct radv_device *device);
+
+void
+radv_dump_trace(struct radv_device *device, struct radeon_winsys_cs *cs);
+
 #endif
index 1e3148a0432daebbf5642833a2278623b929bb55..aae3488318390d51b1719fccaf943d3af474a712 100644 (file)
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include "radv_debug.h"
 #include "radv_private.h"
 #include "radv_cs.h"
 #include "util/disk_cache.h"
@@ -1214,13 +1215,7 @@ VkResult radv_CreateDevice(
        }
 
        if (getenv("RADV_TRACE_FILE")) {
-               device->trace_bo = device->ws->buffer_create(device->ws, 4096, 8,
-                                                            RADEON_DOMAIN_VRAM, RADEON_FLAG_CPU_ACCESS);
-               if (!device->trace_bo)
-                       goto fail;
-
-               device->trace_id_ptr = device->ws->buffer_map(device->trace_bo);
-               if (!device->trace_id_ptr)
+               if (!radv_init_trace(device))
                        goto fail;
        }
 
@@ -1378,21 +1373,6 @@ void radv_GetDeviceQueue(
        *pQueue = radv_queue_to_handle(&device->queues[queueFamilyIndex][queueIndex]);
 }
 
-static void radv_dump_trace(struct radv_device *device,
-                           struct radeon_winsys_cs *cs)
-{
-       const char *filename = getenv("RADV_TRACE_FILE");
-       FILE *f = fopen(filename, "w");
-       if (!f) {
-               fprintf(stderr, "Failed to write trace dump to %s\n", filename);
-               return;
-       }
-
-       fprintf(f, "Trace ID: %x\n", *device->trace_id_ptr);
-       device->ws->cs_dump(cs, f, (const int*)device->trace_id_ptr, 2);
-       fclose(f);
-}
-
 static void
 fill_geom_tess_rings(struct radv_queue *queue,
                     uint32_t *map,
index e915d675fdf65d16283267d3d10115d291332172..c9e8bb3d430122484ffae2e1de1614eab1ac1d8b 100644 (file)
@@ -25,6 +25,7 @@
  * IN THE SOFTWARE.
  */
 
+#include "radv_debug.h"
 #include "radv_private.h"
 #include "vk_format.h"
 #include "vk_util.h"
index 28c16c5672e0a72a3e4d538446b2e01e07872590..b3eb3893d893715fb5e1f46cc1191cad6ac66a73 100644 (file)
@@ -21,6 +21,7 @@
  * IN THE SOFTWARE.
  */
 
+#include "radv_debug.h"
 #include "radv_meta.h"
 #include "radv_private.h"
 #include "nir/nir_builder.h"
index e3a8dff99204ba7de5294c930e760eadef4a23e0..ef5c646317d3968d7c3af0592b67508ec2a5c8f0 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "util/mesa-sha1.h"
 #include "util/u_atomic.h"
+#include "radv_debug.h"
 #include "radv_private.h"
 #include "nir/nir.h"
 #include "nir/nir_builder.h"
index beed35b53a0c390d81334133a67b032cca24a41d..ef1f513f369cdd69cca263a43023f156a9a1ec45 100644 (file)
@@ -24,6 +24,7 @@
 #include "util/mesa-sha1.h"
 #include "util/debug.h"
 #include "util/u_atomic.h"
+#include "radv_debug.h"
 #include "radv_private.h"
 
 #include "ac_nir_to_llvm.h"
index cf5c8532789924fd5983e6ab664770f80ff6f1e0..73f7bdbe8a0ec192a924e0219c7a74965b2c5814 100644 (file)
@@ -55,7 +55,6 @@
 #include "ac_nir_to_llvm.h"
 #include "ac_gpu_info.h"
 #include "ac_surface.h"
-#include "radv_debug.h"
 #include "radv_descriptor_set.h"
 
 #include <llvm-c/TargetMachine.h>