[d3d9] Implement d3d9.longMad option

This commit is contained in:
Joshua Ashton 2020-04-08 23:20:57 +01:00
parent 93b4427a13
commit c3cff09c4f
6 changed files with 39 additions and 4 deletions

View File

@ -304,3 +304,14 @@
# d3d9.forceSwapchainMSAA = -1
# Long Mad
#
# Should we make our Mads a FFma or do it the long way with an FMul and an FAdd?
# This solves some rendering bugs in games that have z-pass shaders which
# don't match entirely to the regular vertex shader in this way.
#
# Supported values:
# - True/False
# d3d9.longMad = False

View File

@ -69,6 +69,7 @@ namespace dxvk {
this->allowDoNotWait = config.getOption<bool> ("d3d9.allowDoNotWait", true);
this->allowDiscard = config.getOption<bool> ("d3d9.allowDiscard", true);
this->enumerateByDisplays = config.getOption<bool> ("d3d9.enumerateByDisplays", true);
this->longMad = config.getOption<bool> ("d3d9.longMad", false);
// If we are not Nvidia, enable general hazards.
this->generalHazards = adapter == nullptr || !adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0);

View File

@ -138,6 +138,11 @@ namespace dxvk {
/// Enumerate adapters by displays
bool enumerateByDisplays;
/// Should we make our Mads a FFma or do it the long way with an FMul and an FAdd?
/// This solves some rendering bugs in games that have z-pass shaders which
/// don't match entirely to the regular vertex shader in this way.
bool longMad;
};
}

View File

@ -1774,10 +1774,21 @@ namespace dxvk {
emitRegisterLoad(src[1], mask).id);
break;
case DxsoOpcode::Mad:
result.id = m_module.opFFma(typeId,
emitRegisterLoad(src[0], mask).id,
emitRegisterLoad(src[1], mask).id,
emitRegisterLoad(src[2], mask).id);
if (!m_moduleInfo.options.longMad) {
result.id = m_module.opFFma(typeId,
emitRegisterLoad(src[0], mask).id,
emitRegisterLoad(src[1], mask).id,
emitRegisterLoad(src[2], mask).id);
}
else {
result.id = m_module.opFMul(typeId,
emitRegisterLoad(src[0], mask).id,
emitRegisterLoad(src[1], mask).id);
result.id = m_module.opFAdd(typeId,
result.id,
emitRegisterLoad(src[2], mask).id);
}
break;
case DxsoOpcode::Mul:
result.id = m_module.opFMul(typeId,

View File

@ -45,6 +45,8 @@ namespace dxvk {
forceSamplerTypeSpecConstants = options.forceSamplerTypeSpecConstants;
vertexConstantBufferAsSSBO = pDevice->GetVertexConstantLayout().totalSize() > devInfo.core.properties.limits.maxUniformBufferRange;
longMad = options.longMad;
}
}

View File

@ -45,6 +45,11 @@ namespace dxvk {
/// Should the VS constant buffer be an SSBO (swvp on NV)
bool vertexConstantBufferAsSSBO;
/// Should we make our Mads a FFma or do it the long way with an FMul and an FAdd?
/// This solves some rendering bugs in games that have z-pass shaders which
/// don't match entirely to the regular vertex shader in this way.
bool longMad;
};
}