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 <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
index 19a665e..18e50eb 100644
--- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
@@ -618,8 +618,12 @@
dumpedMsg << "/* Dumped disassembled DXBC */" << std::endl;
ComPtr<ID3DBlob> 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(