summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/vulkan/radv_debug.c31
-rw-r--r--src/amd/vulkan/radv_debug.h4
-rw-r--r--src/amd/vulkan/radv_device.c1
-rw-r--r--src/amd/vulkan/radv_pipeline.c3
4 files changed, 39 insertions, 0 deletions
diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c
index 2c3f01526f4..9913c06ec23 100644
--- a/src/amd/vulkan/radv_debug.c
+++ b/src/amd/vulkan/radv_debug.c
@@ -62,3 +62,34 @@ radv_dump_trace(struct radv_device *device, struct radeon_winsys_cs *cs)
device->ws->cs_dump(cs, f, (const int*)device->trace_id_ptr, 2);
fclose(f);
}
+
+void
+radv_print_spirv(struct radv_shader_module *module, FILE *fp)
+{
+ char path[] = "/tmp/fileXXXXXX";
+ char line[2048], command[128];
+ FILE *p;
+ int fd;
+
+ /* Dump the binary into a temporary file. */
+ fd = mkstemp(path);
+ if (fd < 0)
+ return;
+
+ if (write(fd, module->data, module->size) == -1)
+ goto fail;
+
+ sprintf(command, "spirv-dis %s", path);
+
+ /* Disassemble using spirv-dis if installed. */
+ p = popen(command, "r");
+ if (p) {
+ while (fgets(line, sizeof(line), p))
+ fprintf(fp, "%s", line);
+ pclose(p);
+ }
+
+fail:
+ close(fd);
+ unlink(path);
+}
diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h
index cbb095f747b..c5e83347279 100644
--- a/src/amd/vulkan/radv_debug.h
+++ b/src/amd/vulkan/radv_debug.h
@@ -37,6 +37,7 @@ enum {
RADV_DEBUG_UNSAFE_MATH = 0x80,
RADV_DEBUG_ALL_BOS = 0x100,
RADV_DEBUG_NO_IBS = 0x200,
+ RADV_DEBUG_DUMP_SPIRV = 0x400,
};
enum {
@@ -50,4 +51,7 @@ radv_init_trace(struct radv_device *device);
void
radv_dump_trace(struct radv_device *device, struct radeon_winsys_cs *cs);
+void
+radv_print_spirv(struct radv_shader_module *module, FILE *fp);
+
#endif
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index aae34883183..cbba04a5d6f 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -409,6 +409,7 @@ static const struct debug_control radv_debug_options[] = {
{"unsafemath", RADV_DEBUG_UNSAFE_MATH},
{"allbos", RADV_DEBUG_ALL_BOS},
{"noibs", RADV_DEBUG_NO_IBS},
+ {"spirv", RADV_DEBUG_DUMP_SPIRV},
{NULL, 0}
};
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index ef5c646317d..f2d1b491b70 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -207,6 +207,9 @@ radv_shader_compile_to_nir(struct radv_device *device,
uint32_t *spirv = (uint32_t *) module->data;
assert(module->size % 4 == 0);
+ if (device->debug_flags & RADV_DEBUG_DUMP_SPIRV)
+ radv_print_spirv(module, stderr);
+
uint32_t num_spec_entries = 0;
struct nir_spirv_specialization *spec_entries = NULL;
if (spec_info && spec_info->mapEntryCount > 0) {