1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-13 19:29:14 +01:00

[dxvk] Make use of VK_AMD_memory_overallocation_behavior

Currently only supported on AMDVLK. Enforces memory limits on a driver
level unless the corresponding dxvk.allowMemoryOvercommit option is enabled.
This commit is contained in:
Philip Rebohle 2018-11-20 15:50:41 +01:00
parent 99f6953e89
commit bcd5a9235c
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 15 additions and 1 deletions

View File

@ -212,7 +212,8 @@ namespace dxvk {
Rc<DxvkDevice> DxvkAdapter::createDevice(DxvkDeviceFeatures enabledFeatures) {
DxvkDeviceExtensions devExtensions;
std::array<DxvkExt*, 12> devExtensionList = {{
std::array<DxvkExt*, 13> devExtensionList = {{
&devExtensions.amdMemoryOverallocationBehaviour,
&devExtensions.extShaderViewportIndexLayer,
&devExtensions.extTransformFeedback,
&devExtensions.extVertexAttributeDivisor,
@ -254,6 +255,15 @@ namespace dxvk {
enabledFeatures.extVertexAttributeDivisor.pNext = enabledFeatures.core.pNext;
enabledFeatures.core.pNext = &enabledFeatures.extVertexAttributeDivisor;
}
// Report the desired overallocation behaviour to the driver
VkDeviceMemoryOverallocationCreateInfoAMD overallocInfo;
overallocInfo.sType = VK_STRUCTURE_TYPE_DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD;
overallocInfo.pNext = nullptr;
overallocInfo.overallocationBehavior = VK_MEMORY_OVERALLOCATION_BEHAVIOR_DISALLOWED_AMD;
if (m_instance->options().allowMemoryOvercommit)
overallocInfo.overallocationBehavior = VK_MEMORY_OVERALLOCATION_BEHAVIOR_ALLOWED_AMD;
// Create one single queue for graphics and present
float queuePriority = 1.0f;
@ -288,6 +298,9 @@ namespace dxvk {
info.enabledExtensionCount = extensionNameList.count();
info.ppEnabledExtensionNames = extensionNameList.names();
info.pEnabledFeatures = &enabledFeatures.core.features;
if (devExtensions.amdMemoryOverallocationBehaviour)
overallocInfo.pNext = std::exchange(info.pNext, &overallocInfo);
VkDevice device = VK_NULL_HANDLE;

View File

@ -257,6 +257,7 @@ namespace dxvk {
* used by DXVK if supported by the implementation.
*/
struct DxvkDeviceExtensions {
DxvkExt amdMemoryOverallocationBehaviour= { VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME, DxvkExtMode::Optional };
DxvkExt extShaderViewportIndexLayer = { VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, DxvkExtMode::Optional };
DxvkExt extTransformFeedback = { VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, DxvkExtMode::Optional };
DxvkExt extVertexAttributeDivisor = { VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME, DxvkExtMode::Optional };