aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-08-30 15:12:20 +0200
committerSamuel Pitoiset <[email protected]>2017-09-01 09:41:54 +0200
commitad42e2abb8507dd85f07e5aad539154b0d5c78ea (patch)
treeee3d314099e77179f70231136b8ae2d06659197d /src/amd
parentf1f2f00f6ac3eb8ccdae4ad4aedfce354ae01e41 (diff)
radv: move RADV_TRACE_FILE functions to radv_debug.c
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 <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/vulkan/Makefile.sources1
-rw-r--r--src/amd/vulkan/radv_debug.c64
-rw-r--r--src/amd/vulkan/radv_debug.h9
-rw-r--r--src/amd/vulkan/radv_device.c24
-rw-r--r--src/amd/vulkan/radv_image.c1
-rw-r--r--src/amd/vulkan/radv_meta_clear.c1
-rw-r--r--src/amd/vulkan/radv_pipeline.c1
-rw-r--r--src/amd/vulkan/radv_pipeline_cache.c1
-rw-r--r--src/amd/vulkan/radv_private.h1
9 files changed, 80 insertions, 23 deletions
diff --git a/src/amd/vulkan/Makefile.sources b/src/amd/vulkan/Makefile.sources
index d3e0c81e9a3..96399a246e2 100644
--- a/src/amd/vulkan/Makefile.sources
+++ b/src/amd/vulkan/Makefile.sources
@@ -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
index 00000000000..2c3f01526f4
--- /dev/null
+++ b/src/amd/vulkan/radv_debug.c
@@ -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);
+}
diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h
index c345d040c5d..cbb095f747b 100644
--- a/src/amd/vulkan/radv_debug.h
+++ b/src/amd/vulkan/radv_debug.h
@@ -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
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 1e3148a0432..aae34883183 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -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,
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index e915d675fdf..c9e8bb3d430 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -25,6 +25,7 @@
* IN THE SOFTWARE.
*/
+#include "radv_debug.h"
#include "radv_private.h"
#include "vk_format.h"
#include "vk_util.h"
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 28c16c5672e..b3eb3893d89 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -21,6 +21,7 @@
* IN THE SOFTWARE.
*/
+#include "radv_debug.h"
#include "radv_meta.h"
#include "radv_private.h"
#include "nir/nir_builder.h"
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index e3a8dff9920..ef5c646317d 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -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"
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index beed35b53a0..ef1f513f369 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -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"
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index cf5c8532789..73f7bdbe8a0 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -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>