1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[dxbc] Reciprocate W component of SV_POSITION in pixel shaders

Fixes the fog effect in Nier:Automata, as well as some major
visual issues in Rise of the Tomb Raider, and potentially
other games.
This commit is contained in:
Philip Rebohle 2018-04-05 20:10:00 +02:00
parent 4d28f765df
commit bd17be472d
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -5002,12 +5002,25 @@ namespace dxvk {
} }
DxbcRegisterPointer ptrIn; DxbcRegisterPointer ptrIn;
ptrIn.type.ctype = DxbcScalarType::Float32; ptrIn.type = { DxbcScalarType::Float32, 4 };
ptrIn.type.ccount = 4;
ptrIn.id = m_ps.builtinFragCoord; ptrIn.id = m_ps.builtinFragCoord;
return emitRegisterExtract( // The X, Y and Z components of the SV_POSITION semantic
emitValueLoad(ptrIn), mask); // are identical to Vulkan's FragCoord builtin, but we
// need to compute the reciprocal of the W component.
DxbcRegisterValue fragCoord = emitValueLoad(ptrIn);
uint32_t componentIndex = 3;
uint32_t t_f32 = m_module.defFloatType(32);
uint32_t v_wComp = m_module.opCompositeExtract(t_f32, fragCoord.id, 1, &componentIndex);
v_wComp = m_module.opFDiv(t_f32, m_module.constf32(1.0f), v_wComp);
fragCoord.id = m_module.opCompositeInsert(
getVectorTypeId(fragCoord.type),
v_wComp, fragCoord.id,
1, &componentIndex);
return emitRegisterExtract(fragCoord, mask);
} break; } break;
case DxbcSystemValue::IsFrontFace: { case DxbcSystemValue::IsFrontFace: {