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>
This commit is contained in:
Antonio Maiorano 2022-11-11 19:33:31 +00:00 committed by Dawn LUCI CQ
parent 7adcf1655a
commit 7338848589
1 changed files with 5 additions and 1 deletions

View File

@ -618,8 +618,12 @@ ResultOrError<CompiledShader> ShaderModule::Compile(const ProgrammableStage& pro
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(