From: Conor McCarthy cmccarthy@codeweavers.com
Dumps DXIL disassembly when shaders are compiled with dxcompiler. --- tests/shader_runner.c | 19 ++++++++++++++++++- tests/utils.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 51e3b5323..ae78ed361 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -837,8 +837,8 @@ HRESULT dxcompiler_compile_shader(enum shader_type type, const char *hlsl, ID3D1 { DxcBuffer src_buf = {hlsl, strlen(hlsl), 65001}; DxcCreateInstanceProc create_instance; + IDxcBlobUtf8 *errors, *disassembly; IDxcCompiler3 *compiler; - IDxcBlobUtf8 *errors; IDxcResult *result; IDxcBlob *blob; HRESULT hr; @@ -910,6 +910,23 @@ HRESULT dxcompiler_compile_shader(enum shader_type type, const char *hlsl, ID3D1 if (FAILED(hr)) goto compiler_release;
+ if (test_options.dump_dxil) + { + src_buf.Ptr = IDxcBlob_GetBufferPointer(blob); + src_buf.Size = IDxcBlob_GetBufferSize(blob); + src_buf.Encoding = 0; + + if (SUCCEEDED(hr = IDxcCompiler3_Disassemble(compiler, &src_buf, &IID_IDxcResult, (void **)&result))) + { + if (SUCCEEDED(hr = IDxcResult_GetOutput(result, DXC_OUT_DISASSEMBLY, &IID_IDxcBlobUtf8, (void **)&disassembly, NULL))) + { + trace("dxcompiler disassembly:\n%s\n", IDxcBlobUtf8_GetStringPointer(disassembly)); + IDxcBlobUtf8_Release(disassembly); + } + IDxcResult_Release(result); + } + } + IDxcCompiler3_Release(compiler); *blob_out = (ID3D10Blob *)blob; return S_OK; diff --git a/tests/utils.h b/tests/utils.h index 670941905..8de930bd2 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -215,6 +215,7 @@ struct test_options bool enable_debug_layer; bool enable_gpu_based_validation; const char *filename; + bool dump_dxil; };
extern struct test_options test_options; @@ -233,6 +234,8 @@ static inline void parse_args(int argc, char **argv) test_options.enable_debug_layer = true; else if (!strcmp(argv[i], "--gbv")) test_options.enable_gpu_based_validation = true; + else if (!strcmp(argv[i], "--dump-dxil")) + test_options.dump_dxil = true; else if (argv[i][0] != '-') test_options.filename = argv[i]; }