From 7338848589649ad2ebc4cfad823c6bc5a0f9d33c Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Fri, 11 Nov 2022 19:33:31 +0000 Subject: [PATCH] dawn: ouput DXBC literals as hex when dump_shaders is enabled The DXBC asm listing attempts to be helpful when display literals by making them human readable,but when it displays values as floats, they will only have a precision of 6. For example, 0x09909909 ends up getting displayed as 0.000000 because as a float, this value is 3.48106525683e-33. FXC has an option to output literals as hex values, so let's use that. Change-Id: I2b3017bd834eac89248fe01cae85ba1bb4033e59 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109582 Kokoro: Kokoro Reviewed-by: Austin Eng Commit-Queue: Antonio Maiorano Reviewed-by: Austin Eng --- src/dawn/native/d3d12/ShaderModuleD3D12.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp index 19a665e76d..18e50eb030 100644 --- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp @@ -618,8 +618,12 @@ ResultOrError ShaderModule::Compile(const ProgrammableStage& pro dumpedMsg << "/* Dumped disassembled DXBC */" << std::endl; ComPtr disassembly; D3D12_SHADER_BYTECODE code = compiledShader->GetD3D12ShaderBytecode(); + UINT flags = + // Some literals are printed as floats with precision(6) which is not enough + // precision for values very close to 0, so always print literals as hex values. + D3D_DISASM_PRINT_HEX_LITERALS; if (FAILED(device->GetFunctions()->d3dDisassemble( - code.pShaderBytecode, code.BytecodeLength, 0, nullptr, &disassembly))) { + code.pShaderBytecode, code.BytecodeLength, flags, nullptr, &disassembly))) { dumpedMsg << "D3D disassemble failed" << std::endl; } else { dumpedMsg << std::string_view(