This series is Reviewed-by: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
On Wed, Aug 30, 2017, at 15:12, Samuel Pitoiset wrote: > 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.pitoi...@gmail.com> > --- > src/amd/vulkan/radv_debug.c | 30 ++++++++++++++++++++++++++++++ > src/amd/vulkan/radv_debug.h | 3 +++ > src/amd/vulkan/radv_device.c | 1 + > src/amd/vulkan/radv_pipeline.c | 3 +++ > 4 files changed, 37 insertions(+) > > diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c > index 8105d1f47e..e6bbf21aba 100644 > --- a/src/amd/vulkan/radv_debug.c > +++ b/src/amd/vulkan/radv_debug.c > @@ -60,3 +60,33 @@ void 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 c9d5fcc73f..d2fbe695fc 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 { > @@ -48,4 +49,6 @@ bool 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 aae3488318..cbba04a5d6 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 ef5c646317..f2d1b491b7 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) { > -- > 2.14.1 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev