From 5259a89138b2b5053c5f215585842791ffc4af88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Mon, 6 May 2019 14:47:37 +0200 Subject: [PATCH] vkd3d: Use VK_SHARING_MODE_CONCURRENT only when queue family count > 1. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Vulkan spec states: If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1. Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d/resource.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 5bb76bf0..36e470bd 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -536,9 +536,18 @@ HRESULT vkd3d_create_buffer(struct d3d12_device *device, return E_INVALIDARG; } - buffer_info.sharingMode = VK_SHARING_MODE_CONCURRENT; - buffer_info.queueFamilyIndexCount = device->queue_family_count; - buffer_info.pQueueFamilyIndices = device->queue_family_indices; + if (device->queue_family_count > 1) + { + buffer_info.sharingMode = VK_SHARING_MODE_CONCURRENT; + buffer_info.queueFamilyIndexCount = device->queue_family_count; + buffer_info.pQueueFamilyIndices = device->queue_family_indices; + } + else + { + buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + buffer_info.queueFamilyIndexCount = 0; + buffer_info.pQueueFamilyIndices = NULL; + } if ((vr = VK_CALL(vkCreateBuffer(device->vk_device, &buffer_info, NULL, vk_buffer))) < 0) { @@ -626,7 +635,7 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device, if (!(desc->Flags & D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE)) image_info.usage |= VK_IMAGE_USAGE_SAMPLED_BIT; - if (desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS) + if ((desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS) && device->queue_family_count > 1) { TRACE("Creating image with VK_SHARING_MODE_CONCURRENT.\n"); image_info.sharingMode = VK_SHARING_MODE_CONCURRENT;