From 60e04503a6edc174ca094e6d998f07554f13964f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 12 Aug 2024 18:37:51 +0200 Subject: [PATCH] [d3d11] Enable longMad/longDot behaviour by default And remove the respective config options. --- dxvk.conf | 11 --------- src/d3d11/d3d11_options.cpp | 2 -- src/d3d11/d3d11_options.h | 6 ----- src/dxbc/dxbc_compiler.cpp | 48 ++++++++++++++++--------------------- src/dxbc/dxbc_options.cpp | 2 -- src/dxbc/dxbc_options.h | 6 ----- src/util/config/config.cpp | 23 ------------------ 7 files changed, 20 insertions(+), 78 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index f97f8512f..e13b7e18a 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -526,20 +526,9 @@ # Supported values: # - True/False -# d3d11.longMad = False # d3d9.longMad = False -# Long Dot -# -# Whether to emit dot products as an FMA chain or as a plain SPIR-V dot product. -# -# Supported values: -# - True/False - -# d3d11.longDot = False - - # Device Local Constant Buffers # # Enables using device local, host accessible memory for constant buffers in D3D9. diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index 5d0f1bd2a..0829e1123 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -31,8 +31,6 @@ namespace dxvk { this->numBackBuffers = config.getOption("dxgi.numBackBuffers", 0); this->maxFrameLatency = config.getOption("dxgi.maxFrameLatency", 0); this->exposeDriverCommandLists = config.getOption("d3d11.exposeDriverCommandLists", true); - this->longMad = config.getOption("d3d11.longMad", false); - this->longDot = config.getOption("d3d11.longDot", false); this->reproducibleCommandStream = config.getOption("d3d11.reproducibleCommandStream", false); // Clamp LOD bias so that people don't abuse this in unintended ways diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index f5e756586..aabb93c5b 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -118,12 +118,6 @@ namespace dxvk { /// Shader dump path std::string shaderDumpPath; - /// Translate Mad/Dfma to separate FMul+FAdd - bool longMad; - - /// Translate DpX to a precise FMul+FFma chain - bool longDot; - /// Ensure that for the same D3D commands the output VK commands /// don't change between runs. Useful for comparative benchmarking, /// can negatively affect performance. diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index 3e7046d4b..47b3438bf 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -1623,7 +1623,9 @@ namespace dxvk { case DxbcOpcode::Mad: case DxbcOpcode::DFma: - if (likely(!m_moduleInfo.options.longMad)) { + if (ins.controls.precise()) { + // FXC only emits precise mad if the shader explicitly uses + // the HLSL mad()/fma() intrinsics, let's preserve that. dst.id = m_module.opFFma(typeId, src.at(0).id, src.at(1).id, src.at(2).id); } else { @@ -2046,35 +2048,25 @@ namespace dxvk { dst.type.ccount = 1; dst.id = 0; - if (!m_moduleInfo.options.longDot) { - dst.id = m_module.opDot( - getVectorTypeId(dst.type), - src.at(0).id, - src.at(1).id); + uint32_t componentType = getVectorTypeId(dst.type); + uint32_t componentCount = srcMask.popCount(); - if (ins.controls.precise() || m_precise) - m_module.decorate(dst.id, spv::DecorationNoContraction); - } else { - uint32_t componentType = getVectorTypeId(dst.type); - uint32_t componentCount = srcMask.popCount(); - - for (uint32_t i = 0; i < componentCount; i++) { - if (dst.id) { - dst.id = m_module.opFFma(componentType, - m_module.opCompositeExtract(componentType, src.at(0).id, 1, &i), - m_module.opCompositeExtract(componentType, src.at(1).id, 1, &i), - dst.id); - } else { - dst.id = m_module.opFMul(componentType, - m_module.opCompositeExtract(componentType, src.at(0).id, 1, &i), - m_module.opCompositeExtract(componentType, src.at(1).id, 1, &i)); - } - - // Unconditionally mark as precise since the exact order of operation - // matters for some games, even if the instruction itself is not marked - // as precise. - m_module.decorate(dst.id, spv::DecorationNoContraction); + for (uint32_t i = 0; i < componentCount; i++) { + if (dst.id) { + dst.id = m_module.opFFma(componentType, + m_module.opCompositeExtract(componentType, src.at(0).id, 1, &i), + m_module.opCompositeExtract(componentType, src.at(1).id, 1, &i), + dst.id); + } else { + dst.id = m_module.opFMul(componentType, + m_module.opCompositeExtract(componentType, src.at(0).id, 1, &i), + m_module.opCompositeExtract(componentType, src.at(1).id, 1, &i)); } + + // Unconditionally mark as precise since the exact order of operation + // matters for some games, even if the instruction itself is not marked + // as precise. + m_module.decorate(dst.id, spv::DecorationNoContraction); } dst = emitDstOperandModifiers(dst, ins.modifiers); diff --git a/src/dxbc/dxbc_options.cpp b/src/dxbc/dxbc_options.cpp index 9730366a0..e55a0f945 100644 --- a/src/dxbc/dxbc_options.cpp +++ b/src/dxbc/dxbc_options.cpp @@ -38,8 +38,6 @@ namespace dxvk { disableMsaa = options.disableMsaa; forceSampleRateShading = options.forceSampleRateShading; enableSampleShadingInterlock = device->features().extFragmentShaderInterlock.fragmentShaderSampleInterlock; - longMad = options.longMad; - longDot = options.longDot; // Figure out float control flags to match D3D11 rules if (options.floatControls) { diff --git a/src/dxbc/dxbc_options.h b/src/dxbc/dxbc_options.h index 12b3bb939..27ecca1ff 100644 --- a/src/dxbc/dxbc_options.h +++ b/src/dxbc/dxbc_options.h @@ -54,12 +54,6 @@ namespace dxvk { /// Minimum storage buffer alignment VkDeviceSize minSsboAlignment = 0; - - /// Translate Mad/Dfma to separate FMul+FAdd - bool longMad; - - /// Translate DpX to a precise FMul+FFma chain - bool longDot; }; } \ No newline at end of file diff --git a/src/util/config/config.cpp b/src/util/config/config.cpp index bcbc1a422..97845817a 100644 --- a/src/util/config/config.cpp +++ b/src/util/config/config.cpp @@ -479,35 +479,12 @@ namespace dxvk { { "d3d11.exposeDriverCommandLists", "False" }, { "dxgi.hideNvidiaGpu", "False" }, }} }, - /* Red Faction Guerrilla Re-Mars-tered * - * Broken skybox */ - { R"(\\rfg\.exe$)", {{ - { "d3d11.longMad", "True" }, - }} }, - /* Guild Wars 2 - Fixes invisibility effect * - * flicker when invariantPosition is enabled */ - { R"(\\Gw2-64\.exe$)", {{ - { "d3d11.longMad", "True" }, - }} }, - /* Ghostbusters: The Video Game Remastered * - * Flickering on character faces */ - { R"(\\ghost\.exe$)", {{ - { "d3d11.longMad", "True" }, - }} }, - /* Watch_Dogs series - Some objects flicker */ - { R"(\\watch(_)?dogs(2|Legion)?\.exe$)", {{ - { "d3d11.longMad", "True" }, - }} }, /* Crysis 1/Warhead - Game bug in d3d10 makes * * it select lowest supported refresh rate */ { R"(\\Crysis(64)?\.exe$)", {{ { "d3d9.maxFrameRate", "-1" }, { "dxgi.maxFrameRate", "-1" }, }} }, - /* Kuro no Kiseki - Broken water on NV */ - { R"(\\(kuro|ed9)\.exe$)", {{ - { "d3d11.longDot", "True" }, - }} }, /**********************************************/ /* D3D9 GAMES */