Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split up FMA for Red Faction #3972

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dxvk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@
# Supported values:
# - True/False

# d3d11.longMad = False
# d3d9.longMad = False

# Device Local Constant Buffers
Expand Down
1 change: 1 addition & 0 deletions src/d3d11/d3d11_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace dxvk {
this->maxFrameLatency = config.getOption<int32_t>("dxgi.maxFrameLatency", 0);
this->maxFrameRate = config.getOption<int32_t>("dxgi.maxFrameRate", 0);
this->exposeDriverCommandLists = config.getOption<bool>("d3d11.exposeDriverCommandLists", true);
this->longMad = config.getOption<bool>("d3d11.longMad", false);

// Clamp LOD bias so that people don't abuse this in unintended ways
this->samplerLodBias = dxvk::fclamp(this->samplerLodBias, -2.0f, 1.0f);
Expand Down
3 changes: 3 additions & 0 deletions src/d3d11/d3d11_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ namespace dxvk {

/// Shader dump path
std::string shaderDumpPath;

/// Should we make our Mads a FFma or do it the long way with an FMul and an FAdd?
bool longMad;
};

}
9 changes: 7 additions & 2 deletions src/dxbc/dxbc_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,8 +1624,13 @@ namespace dxvk {

case DxbcOpcode::Mad:
case DxbcOpcode::DFma:
dst.id = m_module.opFFma(typeId,
src.at(0).id, src.at(1).id, src.at(2).id);
if (likely(!m_moduleInfo.options.longMad)) {
dst.id = m_module.opFFma(typeId,
src.at(0).id, src.at(1).id, src.at(2).id);
} else {
dst.id = m_module.opFMul(typeId, src.at(0).id, src.at(1).id);
dst.id = m_module.opFAdd(typeId, dst.id, src.at(2).id);
}
break;

case DxbcOpcode::Max:
Expand Down
1 change: 1 addition & 0 deletions src/dxbc/dxbc_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace dxvk {
disableMsaa = options.disableMsaa;
forceSampleRateShading = options.forceSampleRateShading;
enableSampleShadingInterlock = device->features().extFragmentShaderInterlock.fragmentShaderSampleInterlock;
longMad = options.longMad;

// Figure out float control flags to match D3D11 rules
if (options.floatControls) {
Expand Down
3 changes: 3 additions & 0 deletions src/dxbc/dxbc_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ namespace dxvk {

/// Minimum storage buffer alignment
VkDeviceSize minSsboAlignment = 0;

/// Should we make our Mads a FFma or do it the long way with an FMul and an FAdd?
bool longMad;
};

}
5 changes: 5 additions & 0 deletions src/util/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ namespace dxvk {
{ "d3d11.exposeDriverCommandLists", "False" },
{ "dxgi.hideNvidiaGpu", "False" },
}} },
/* Red Faction Guerrilla Re-Mars-tered *
* Broken skybox */
{ R"(\\rfg\.exe$)", {{
{ "d3d11.longMad", "True" },
}} },

/**********************************************/
/* D3D9 GAMES */
Expand Down
Loading