Skip to content

Commit

Permalink
[d3d9] Don't use memory tracking to determine resource creation failu…
Browse files Browse the repository at this point in the history
…re by default

This allows us to use more than 4GB of VRAM in games.

This behaviour changed in the Fall Creators update (https://www.neowin.net/news/windows-10-fall-creators-update-fixes-the-directx-9-memory-allocation-bug)
But lets keep it around in case some game depend on the old behaviour! (It's D3D9 after all...)

May impact #93, #170, #383 and #438
  • Loading branch information
misyltoad committed Oct 29, 2019
1 parent 1c55003 commit eccc5c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ namespace dxvk {
// Clamp to megabyte range, as per spec.
constexpr UINT range = 0xfff00000;

UINT memory = UINT(m_availableMemory.load());
return memory & range;
// Can't have negative memory!
int64_t memory = std::max(m_availableMemory.load(), 0ll);

return UINT(memory) & range;
}


Expand Down
2 changes: 1 addition & 1 deletion src/d3d9/d3d9_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ namespace dxvk {
bool ChangeReportedMemory(int64_t delta) {
m_availableMemory += delta;

return m_availableMemory > 0;
return !m_d3d9Options.memoryTrackTest || m_availableMemory > 0;
}

void ResolveZ();
Expand Down
1 change: 1 addition & 0 deletions src/d3d9/d3d9_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace dxvk {
this->swvpBoolCount = config.getOption<uint32_t>("d3d9.swvpBoolCount", caps::MaxOtherConstantsSoftware);
this->disableA8RT = config.getOption<bool> ("d3d9.disableA8RT", false);
this->invariantPosition = config.getOption<bool> ("d3d9.invariantPosition", false);
this->memoryTrackTest = config.getOption<bool> ("d3d9.memoryTrackTest", 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);
Expand Down
4 changes: 4 additions & 0 deletions src/d3d9/d3d9_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ namespace dxvk {
/// Work around a NV driver quirk
/// Fixes flickering/z-fighting in some games.
bool invariantPosition;

/// Whether or not to respect memory tracking for
/// failing resource allocation.
bool memoryTrackTest;
};

}

0 comments on commit eccc5c9

Please sign in to comment.