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 <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
parent
ad42e2abb8
commit
f14020c15f
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
};
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue