diff options
author | Jason Ekstrand <[email protected]> | 2019-10-09 13:21:21 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-10-09 22:28:01 +0000 |
commit | c7e5d24d8f5281a85d9f6646e4d7601f947d6f7d (patch) | |
tree | 0da8d8efe3c499cef216ae62d2b8485eaa345ae9 | |
parent | b2f6fda542d2eb868409fbd03564b63ae2c666bb (diff) |
anv/pipeline: Capture serialized NIR
This allows the serialized NIR to be displayed in RenderDoc and similar
tools.
Reviewed-by: Lionel Landwerlin <[email protected]>
-rw-r--r-- | src/intel/vulkan/anv_pipeline.c | 32 | ||||
-rw-r--r-- | src/intel/vulkan/anv_private.h | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 14343260882..5460bcca01a 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -1073,6 +1073,26 @@ anv_pipeline_add_executable(struct anv_pipeline *pipeline, struct brw_compile_stats *stats, uint32_t code_offset) { + char *nir = NULL; + if (stage->nir && + (pipeline->flags & + VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR)) { + char *stream_data = NULL; + size_t stream_size = 0; + FILE *stream = open_memstream(&stream_data, &stream_size); + + nir_print_shader(stage->nir, stream); + + fclose(stream); + + /* Copy it to a ralloc'd thing */ + nir = ralloc_size(pipeline->mem_ctx, stream_size + 1); + memcpy(nir, stream_data, stream_size); + nir[stream_size] = 0; + + free(stream_data); + } + char *disasm = NULL; if (stage->code && (pipeline->flags & @@ -1102,6 +1122,7 @@ anv_pipeline_add_executable(struct anv_pipeline *pipeline, (struct anv_pipeline_executable) { .stage = stage->stage, .stats = *stats, + .nir = nir, .disasm = disasm, }; } @@ -2166,6 +2187,17 @@ VkResult anv_GetPipelineExecutableInternalRepresentationsKHR( const struct anv_pipeline_executable *exe = &pipeline->executables[pExecutableInfo->executableIndex]; + if (exe->nir) { + vk_outarray_append(&out, ir) { + WRITE_STR(ir->name, "Final NIR"); + WRITE_STR(ir->description, + "Final NIR before going into the back-end compiler"); + + if (!write_ir_text(ir, exe->nir)) + incomplete_text = true; + } + } + if (exe->disasm) { vk_outarray_append(&out, ir) { WRITE_STR(ir->name, "GEN Assembly"); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index ab35f127970..3aa6d1922f9 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -2820,6 +2820,7 @@ struct anv_pipeline_executable { struct brw_compile_stats stats; + char *nir; char *disasm; }; |