From 43866092a5916c1fa4438c656ffb781d1b2224d4 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Fri, 28 Dec 2018 14:12:09 +0300 Subject: [PATCH] [D3D12] Update some comments about numeric formats --- src/xenia/gpu/dxbc_shader_translator_memexport.cc | 2 -- src/xenia/gpu/dxbc_shader_translator_om.cc | 13 +++++++------ src/xenia/gpu/xenos.h | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/xenia/gpu/dxbc_shader_translator_memexport.cc b/src/xenia/gpu/dxbc_shader_translator_memexport.cc index a4a7a0e80..5dcd83009 100644 --- a/src/xenia/gpu/dxbc_shader_translator_memexport.cc +++ b/src/xenia/gpu/dxbc_shader_translator_memexport.cc @@ -447,8 +447,6 @@ void DxbcShaderTranslator::ExportToMemory() { uint32_t format_param_temp = PushSystemTemp(); // Denormalize, clamp and convert to integer. - // TODO(Triang3l): Really clamp? It's GPUSURFACENUMBER_UREPEAT, not clamp, - // but need to verify since not clamping doesn't look very safe. // A lot of the code is similar for both signed and unsigned. Start by // checking the signedness. shader_code_.push_back(ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_IF) | diff --git a/src/xenia/gpu/dxbc_shader_translator_om.cc b/src/xenia/gpu/dxbc_shader_translator_om.cc index 2a7b3460f..9549d9884 100644 --- a/src/xenia/gpu/dxbc_shader_translator_om.cc +++ b/src/xenia/gpu/dxbc_shader_translator_om.cc @@ -729,10 +729,10 @@ void DxbcShaderTranslator::CompletePixelShader_DepthTo24Bit( ++stat_.instruction_count; ++stat_.float_instruction_count; - // Round to the nearest integer. This is the correct way of rounding, rounding - // towards zero gives 0xFF instead of 0x100 in clear shaders in, for instance, - // Halo 3. - // https://docs.microsoft.com/en-us/windows/desktop/direct3d10/d3d10-graphics-programming-guide-resources-data-conversion + // Round to the nearest even integer. This seems to be the correct way: + // rounding towards zero gives 0xFF instead of 0x100 in clear shaders in, for + // instance, Halo 3, but other clear shaders in it are also broken if 0.5 is + // added before ftou instead of round_ne. shader_code_.push_back(ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_ROUND_NE) | ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(5)); shader_code_.push_back( @@ -3646,8 +3646,9 @@ void DxbcShaderTranslator::CompletePixelShader_WriteToROV_PackColor( ++stat_.instruction_count; ++stat_.float_instruction_count; - // Convert to fixed-point, rounding to the nearest integer. - // https://docs.microsoft.com/en-us/windows/desktop/direct3d10/d3d10-graphics-programming-guide-resources-data-conversion + // Convert to fixed-point, rounding towards the nearest even integer. + // Rounding towards the nearest (adding +-0.5 before truncating) is giving + // incorrect results for depth, so better to use round_ne here too. uint32_t fixed_temp = PushSystemTemp(); shader_code_.push_back(ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_ROUND_NE) | ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(5)); diff --git a/src/xenia/gpu/xenos.h b/src/xenia/gpu/xenos.h index 628a04d2a..e1beab9e4 100644 --- a/src/xenia/gpu/xenos.h +++ b/src/xenia/gpu/xenos.h @@ -156,7 +156,8 @@ enum class IndexFormat : uint32_t { kInt32, }; -// GPUSURFACENUMBER from a game .pdb. +// GPUSURFACENUMBER from a game .pdb. "Repeat" means repeating fraction, it's +// what ATI calls normalized. enum class SurfaceNumFormat : uint32_t { kUnsignedRepeat = 0, kSignedRepeat = 1,