Skip to content

Commit

Permalink
[d3d9] Add a modeHeightFilter config option
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Feb 5, 2024
1 parent 0746a3b commit 864263a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dxvk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,19 @@

# d3d9.forceAspectRatio = ""

# Mode Height Filter
#
# Only exposes modes with certain heights, if they are
# also supported by the adapter. Can be used in conjunction
# with forceAspectRatio to further restrict reported modes.
# Useful for titles that break when too many modes are reported,
# e.g., AquaNox, AquaNox 2: Revelation.
#
# Supported values:
# - A list of mode heights, ie. "480,720,1080"

# d3d9.modeHeightFilter = ""

# Enumerate by Displays
#
# Whether we should enumerate D3D9 adapters by display (windows behaviour)
Expand Down
12 changes: 12 additions & 0 deletions src/d3d9/d3d9_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,14 @@ namespace dxvk {
uint32_t modeIndex = 0;

const auto forcedRatio = Ratio<DWORD>(options.forceAspectRatio);

if (!options.modeHeightFilter.empty() && m_forcedHeights.empty()) {
uint32_t forcedHeight;
for (auto height : str::split(options.modeHeightFilter, ",")) {
std::from_chars(height.data(), height.data() + height.size(), forcedHeight);
m_forcedHeights.emplace_back(forcedHeight);
}
}

while (wsi::getDisplayMode(wsi::getDefaultMonitor(), modeIndex++, &devMode)) {
// Skip interlaced modes altogether
Expand All @@ -784,6 +792,10 @@ namespace dxvk {
if (!forcedRatio.undefined() && Ratio<DWORD>(devMode.width, devMode.height) != forcedRatio)
continue;

if (!m_forcedHeights.empty() &&
std::find(m_forcedHeights.begin(), m_forcedHeights.end(), devMode.height) == m_forcedHeights.end())
continue;

D3DDISPLAYMODEEX mode = ConvertDisplayMode(devMode);
// Fix up the D3DFORMAT to match what we are enumerating
mode.Format = static_cast<D3DFORMAT>(Format);
Expand Down
2 changes: 2 additions & 0 deletions src/d3d9/d3d9_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ namespace dxvk {

const D3D9VkFormatTable m_d3d9Formats;

std::vector<uint32_t> m_forcedHeights;

};

}

0 comments on commit 864263a

Please sign in to comment.