Commit Graph

70 Commits

Author SHA1 Message Date
Philip Rebohle 2be0d6842e [dxvk] Add option to limit memory chunk size 2023-03-01 11:53:18 +01:00
Philip Rebohle 1c2df54bdf [dxvk] Improve logging in case of memory errors 2023-01-14 03:39:55 +01:00
Philip Rebohle 2922b780c1 [dxvk] Properly handle bufferImageGranularity for images
Fixes validation errors about dedicated allocations being
bigger than the image's memory requirement on Nvidia.
2023-01-14 03:39:55 +01:00
Philip Rebohle 8052347a22 [dxvk] Keep more empty system memory chunks alive 2023-01-10 03:42:37 +01:00
Philip Rebohle 0b9f785bc5 [dxvk] Remove broken memory budget logic for UMA systems
All heaps on an UMA systems are by definition device-local, so this
just leads to unnecessary issues.
2022-11-01 12:48:03 +01:00
Philip Rebohle f1f8d45fcd [dxvk] Rework allocation logic for large resources
This may reduce internal fragmentation with very large resources.

We previously changed behaviour to not do this in order to reduce memory
pressure in the average case, however by trying to suballocate from existing
chunks and falling back to a dedicated allocation on failure, rather than
allocating a new chunk, we can mostly avoid that situation.
2022-09-24 17:06:00 +02:00
Philip Rebohle 15588004b4 [dxvk] Bump memory chunk size to 256 MiB. 2022-09-24 17:06:00 +02:00
Philip Rebohle 51e0a56243 [dxvk] Use new pseudo-features where applicable 2022-09-04 18:28:27 +02:00
Philip Rebohle f9db4921e0 [dxvk] Implement sparse memory allocator 2022-08-26 05:53:03 +02:00
Philip Rebohle a2a21cb4d3 [dxvk] Clean up internal memory allocation API 2022-08-25 18:23:02 +02:00
Philip Rebohle 67f937111d
[dxvk] Remove shrinkNvidiaHVVHeap workaround
No longer needed.
2022-08-10 16:39:58 +02:00
Philip Rebohle a76b5693f3
[dxvk] Clean up remaining object creation code 2022-07-18 14:52:12 +02:00
Philip Rebohle 81b89cf31d
[dxvk] Simplify Nvidia HVV workaround
We no longer support 465 series drivers, so the check was obsolete.
2022-07-14 21:21:34 +02:00
Philip Rebohle 131af0d677
[dxvk] Replace VK_KHR_driver_properties with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle 425fce9200
[dxvk] Introduce transient memory flag for staging buffers
Potentially reduces fragmentation by putting short-lived staging buffers
and sysmem resources created by the application into different memory pools.
2022-02-13 02:08:20 +01:00
Philip Rebohle 9d4be00fa7
[dxvk] Allow large sysmem allocations on 64-bit platforms again
Since we frequently discard staging buffers now, having larger chunks
is actually beneficial again.
2022-02-13 02:08:20 +01:00
Philip Rebohle a268de51e3
[dxvk] Don't shrink HVV heap if it's the main video memory heap
May fix issues on RBAR-enabled Nvidia systems.
2022-01-16 02:47:51 +01:00
Philip Rebohle db2e32ede6
[dxvk] Be smarter about which chunks to free
Freeing all empty chunks immediately may cause issues if an app constantly
allocates and frees a small number of resources that don't fit into any
existing chunk, so try to keep one around. Aggressively free everything
under memory pressure if necessary.
2022-01-13 18:39:31 +01:00
Philip Rebohle 15ab07ab94
[dxvk] Replace allocation priority with allocation flags 2022-01-13 18:39:31 +01:00
Philip Rebohle d34bbdb58e
[dxvk] Free empty memory chunks 2022-01-13 18:22:44 +01:00
Philip Rebohle 778aee0372
[dxvk] Rework Nvidia HVV option 2021-11-02 00:52:25 +01:00
Philip Rebohle aa4b7c9f92
[dxvk] Rework 32-bit check 2021-10-01 14:18:42 +02:00
Philip Rebohle cd8a2bcfcd [dxvk] Use custom sync primitives 2021-06-29 00:51:20 +02:00
Liam Middlebrook 1c2edabbcb [dxvk] Disable NVIDIA HVV bug workaround on fixed drivers
Reviewed-by: Arthur Huillet <ahuillet@nvidia.com>
2021-03-05 11:21:50 +01:00
Liam Middlebrook b25d6ba615 [dxvk] Add option to disable workaround for NVIDIA HVV bug
Adds a new dxvk.halveNvidiaHVVHeap option.

Reviewed-by: Arthur Huillet <ahuillet@nvidia.com>
2021-03-05 11:21:50 +01:00
Philip Rebohle 16a51f3c03 [dxvk] Only use half of the DEVICE_LOCAL | HOST_VISIBLE heap on Nvidia
Seems to help with random crashes in FFXIV and potentially
other games on 450 series drivers.
2020-08-22 11:51:56 +02:00
Philip Rebohle e435e071e0 [dxvk] Introduce memory heap budget
Allows more fine-grained control of memory allocations for specific
heaps. For now, target 80% for device-local heaps on UMA devices.
2020-08-22 11:50:37 +02:00
Philip Rebohle 48777c8fcf
[dxvk] Remove optional memory property flags one by one
We don't always want to remove HOST_CACHED if no DEVICE_LOCAL
type exists, so iterate over the bits one by one.
2020-08-13 18:47:52 +02:00
Philip Rebohle ca4c03284f [dxvk] Don't oversubscribe memory heaps on UMA devices
Otherwise, we seem to suffer a major performance penalty
on setups with insufficient dedicated system memory.
2020-01-28 16:31:34 +00:00
Philip Rebohle 60145f0167 [dxvk] Don't enable VK_KHR_dedicated_allocation, VK_KHR_get_memory_requirements2
Core in Vulkan 1.1.
2020-01-17 17:46:59 +01:00
Philip Rebohle 7a18cb1227
[dxvk] Remove unused memory stat counters 2019-12-13 12:08:36 +01:00
Philip Rebohle 493b55b073
[dxvk] Compute memory chunk size per memory type rather than per heap 2019-07-16 09:59:44 +02:00
Philip Rebohle 6936da17d9
[dxvk] Try harder to allocate memory from a given memory type
Before failing, see if we can't allocate a smaller chunk size.
2019-07-16 09:59:44 +02:00
Philip Rebohle 18aada29ef
[dxvk] Don't put large resources into their own memory allocations
This approach currently has two issues:
- We might fail to allocate the resource on the desired memory type
  even if there is a chunk available that it would tif in
- With 128MB chunks, this no longer seems to be beneficial anyway
2019-07-16 09:24:55 +02:00
Philip Rebohle e116ff49e6
[dxvk] Rename memoryAvailable -> memoryBudget 2019-07-13 19:04:33 +02:00
Philip Rebohle 3b1376b2fe
[dxvk] Increase memory chunk size to 128 MiB
Nvidia drivers apparently don't like smaller chunks very much.
May increase overall memory consumption and fragmentation.
2019-07-04 16:11:13 +02:00
Philip Rebohle 3b128179ab
[dxvk] Print VK_EXT_memory_budget stats on allocation failure
Based on PR #1112, but using a cleaner method to check
support for the VK_EXT_memory_budget extension.

Suggested-by: Liam Middlebrook <lmiddlebrook@nvidia.com>
2019-07-03 11:11:12 +02:00
Philip Rebohle cb806a5d56
[dxvk] Free memory if vkMapMemory fails
Otherwise, we leak the allocated memory chunk and make the
problem even worse than it already is.
2019-07-02 01:26:54 +02:00
Philip Rebohle 138dde6c3d
[dxvk] Prefer VRAM allocation over dedicated sysmem allocation
May in some cases improve performance when under memory pressure:
If a dedicated allocation is preferred, but the alloaction fails,
try to allocate memory from an already allocated chunk instead
of falling back to system memory right away.
2019-06-20 10:34:54 +02:00
Philip Rebohle 0a35ae6fca
[dxvk] Log memory utilization per heap on memory allocation failures 2019-06-19 14:47:09 +02:00
Philip Rebohle f272071d8d
[dxvk] Don't enforce HOST_CACHED flag when allocating memory
The better fix would be to support non-coherent memory properly,
but this will have to do for now. Fixes #947.
2019-03-14 16:47:17 +01:00
Philip Rebohle c360a196fb
[dxvk] Restore dedicated allocation behaviour
Whoops.
2019-01-30 15:49:06 +01:00
Philip Rebohle b76f470c5f
[dxvk] Remove dxvk.allowMemoryOvercommit option
The default behaviour is now to allow overallocation by default,
which makes sense especially when VK_EXT_memory_priority is used.

Does not seem to affect Nvidia drivers.
2019-01-30 13:52:43 +01:00
Philip Rebohle dfa8524e73
[dxvk] Wire up memory priority to device memory allocations 2019-01-30 13:52:43 +01:00
Philip Rebohle 03b488772d
[dxvk] Store device instead of adapter in memory allocator 2019-01-30 13:52:43 +01:00
Philip Rebohle 134613375d
[dxvk] Introduce concept of priorities to device-local memory allocations
The priority defines the importance of any given allocation being
resident in device-local memory rather than system memory, with
values between 0 (low) and 1 (high).

Suballocations will only work on chunks with the requested priority.
This ensures that high-priority allocations are reserved solely for
high-priority resources, and that high-priority resources will be
allocated from a high-priority memory chunk.
2019-01-30 13:52:43 +01:00
Philip Rebohle 1af96347e1
[dxvk] Forward memory allocation statistics to the adapter 2018-11-15 17:08:05 +01:00
Philip Rebohle eac86fab15
[dxvk] Do not map allocations that don't need a HOST_VISIBLE memory type
Should reduce the amount of virtual memory used on systems without
dedicated VRAM. Refs #640.
2018-09-17 09:08:00 +02:00
Philip Rebohle b2c4855490
[dxvk] Use global user config for backend options 2018-08-07 16:59:49 +02:00
Philip Rebohle 43cbe42ea8
[dxvk] Pick memory chunk size dynamically
Reduces the number of Vulkan memory allocations, and
can lead to lower CPU overhead in certain situations.
Improves Shadow Warrior 2 by ~2% on RADV.
2018-07-09 19:18:39 +02:00