summaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan/radv_debug.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-08-30 15:12:21 +0200
committerSamuel Pitoiset <[email protected]>2017-09-01 09:41:54 +0200
commitf14020c15fee4dd640a9b1e501208479c74c28b0 (patch)
treeb5a93d522fef84106f75e99914cc3eeb39ae7389 /src/amd/vulkan/radv_debug.c
parentad42e2abb8507dd85f07e5aad539154b0d5c78ea (diff)
radv: disassemble SPIR-V binaries with RADV_DEBUG=spirv
This introduces a new separate option because the output can be quite verbose. If spirv-dis is not found in the path, this debug option is useless. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan/radv_debug.c')
-rw-r--r--src/amd/vulkan/radv_debug.c31
1 files changed, 31 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);
+}