mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +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:
parent
99f6953e89
commit
bcd5a9235c
@ -212,7 +212,8 @@ namespace dxvk {
|
|||||||
Rc<DxvkDevice> DxvkAdapter::createDevice(DxvkDeviceFeatures enabledFeatures) {
|
Rc<DxvkDevice> DxvkAdapter::createDevice(DxvkDeviceFeatures enabledFeatures) {
|
||||||
DxvkDeviceExtensions devExtensions;
|
DxvkDeviceExtensions devExtensions;
|
||||||
|
|
||||||
std::array<DxvkExt*, 12> devExtensionList = {{
|
std::array<DxvkExt*, 13> devExtensionList = {{
|
||||||
|
&devExtensions.amdMemoryOverallocationBehaviour,
|
||||||
&devExtensions.extShaderViewportIndexLayer,
|
&devExtensions.extShaderViewportIndexLayer,
|
||||||
&devExtensions.extTransformFeedback,
|
&devExtensions.extTransformFeedback,
|
||||||
&devExtensions.extVertexAttributeDivisor,
|
&devExtensions.extVertexAttributeDivisor,
|
||||||
@ -255,6 +256,15 @@ namespace dxvk {
|
|||||||
enabledFeatures.core.pNext = &enabledFeatures.extVertexAttributeDivisor;
|
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
|
// Create one single queue for graphics and present
|
||||||
float queuePriority = 1.0f;
|
float queuePriority = 1.0f;
|
||||||
std::vector<VkDeviceQueueCreateInfo> queueInfos;
|
std::vector<VkDeviceQueueCreateInfo> queueInfos;
|
||||||
@ -289,6 +299,9 @@ namespace dxvk {
|
|||||||
info.ppEnabledExtensionNames = extensionNameList.names();
|
info.ppEnabledExtensionNames = extensionNameList.names();
|
||||||
info.pEnabledFeatures = &enabledFeatures.core.features;
|
info.pEnabledFeatures = &enabledFeatures.core.features;
|
||||||
|
|
||||||
|
if (devExtensions.amdMemoryOverallocationBehaviour)
|
||||||
|
overallocInfo.pNext = std::exchange(info.pNext, &overallocInfo);
|
||||||
|
|
||||||
VkDevice device = VK_NULL_HANDLE;
|
VkDevice device = VK_NULL_HANDLE;
|
||||||
|
|
||||||
if (m_vki->vkCreateDevice(m_handle, &info, nullptr, &device) != VK_SUCCESS)
|
if (m_vki->vkCreateDevice(m_handle, &info, nullptr, &device) != VK_SUCCESS)
|
||||||
|
@ -257,6 +257,7 @@ namespace dxvk {
|
|||||||
* used by DXVK if supported by the implementation.
|
* used by DXVK if supported by the implementation.
|
||||||
*/
|
*/
|
||||||
struct DxvkDeviceExtensions {
|
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 extShaderViewportIndexLayer = { VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, DxvkExtMode::Optional };
|
||||||
DxvkExt extTransformFeedback = { VK_EXT_TRANSFORM_FEEDBACK_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 };
|
DxvkExt extVertexAttributeDivisor = { VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME, DxvkExtMode::Optional };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user