mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-13 16:08:50 +01:00
[dxvk] Clean up image and image view creation code
Someone was dunk while setting pNext to VK_NULL_HANDLE instead of nullptr.
This commit is contained in:
parent
8d1b9eca5d
commit
0b11995dea
@ -22,15 +22,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
// If defined, we should provide a format list, which
|
// If defined, we should provide a format list, which
|
||||||
// allows some drivers to enable image compression
|
// allows some drivers to enable image compression
|
||||||
VkImageFormatListCreateInfo formatList;
|
VkImageFormatListCreateInfo formatList = { VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO };
|
||||||
formatList.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO;
|
|
||||||
formatList.pNext = nullptr;
|
|
||||||
formatList.viewFormatCount = createInfo.viewFormatCount;
|
formatList.viewFormatCount = createInfo.viewFormatCount;
|
||||||
formatList.pViewFormats = createInfo.viewFormats;
|
formatList.pViewFormats = createInfo.viewFormats;
|
||||||
|
|
||||||
VkImageCreateInfo info;
|
VkImageCreateInfo info = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, &formatList };
|
||||||
info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
|
||||||
info.pNext = &formatList;
|
|
||||||
info.flags = createInfo.flags;
|
info.flags = createInfo.flags;
|
||||||
info.imageType = createInfo.type;
|
info.imageType = createInfo.type;
|
||||||
info.format = createInfo.format;
|
info.format = createInfo.format;
|
||||||
@ -41,8 +37,6 @@ namespace dxvk {
|
|||||||
info.tiling = createInfo.tiling;
|
info.tiling = createInfo.tiling;
|
||||||
info.usage = createInfo.usage;
|
info.usage = createInfo.usage;
|
||||||
info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
info.queueFamilyIndexCount = 0;
|
|
||||||
info.pQueueFamilyIndices = nullptr;
|
|
||||||
info.initialLayout = createInfo.initialLayout;
|
info.initialLayout = createInfo.initialLayout;
|
||||||
|
|
||||||
m_shared = canShareImage(info, createInfo.sharing);
|
m_shared = canShareImage(info, createInfo.sharing);
|
||||||
@ -76,46 +70,27 @@ namespace dxvk {
|
|||||||
// alignment on non-linear images in order not to violate the
|
// alignment on non-linear images in order not to violate the
|
||||||
// bufferImageGranularity limit, which may be greater than the
|
// bufferImageGranularity limit, which may be greater than the
|
||||||
// required resource memory alignment on some GPUs.
|
// required resource memory alignment on some GPUs.
|
||||||
VkMemoryDedicatedRequirements dedicatedRequirements;
|
VkMemoryDedicatedRequirements dedicatedRequirements = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS };
|
||||||
dedicatedRequirements.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS;
|
VkMemoryRequirements2 memReq = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2, &dedicatedRequirements };
|
||||||
dedicatedRequirements.pNext = VK_NULL_HANDLE;
|
|
||||||
dedicatedRequirements.prefersDedicatedAllocation = VK_FALSE;
|
|
||||||
dedicatedRequirements.requiresDedicatedAllocation = VK_FALSE;
|
|
||||||
|
|
||||||
VkMemoryRequirements2 memReq;
|
VkImageMemoryRequirementsInfo2 memReqInfo = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2 };
|
||||||
memReq.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
|
|
||||||
memReq.pNext = &dedicatedRequirements;
|
|
||||||
|
|
||||||
VkImageMemoryRequirementsInfo2 memReqInfo;
|
|
||||||
memReqInfo.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2;
|
|
||||||
memReqInfo.image = m_image.image;
|
memReqInfo.image = m_image.image;
|
||||||
memReqInfo.pNext = VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
VkMemoryDedicatedAllocateInfo dedMemoryAllocInfo;
|
VkMemoryDedicatedAllocateInfo dedMemoryAllocInfo = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO };
|
||||||
dedMemoryAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO;
|
|
||||||
dedMemoryAllocInfo.pNext = VK_NULL_HANDLE;
|
|
||||||
dedMemoryAllocInfo.buffer = VK_NULL_HANDLE;
|
|
||||||
dedMemoryAllocInfo.image = m_image.image;
|
dedMemoryAllocInfo.image = m_image.image;
|
||||||
|
|
||||||
VkExportMemoryAllocateInfo exportInfo;
|
VkExportMemoryAllocateInfo exportInfo = { VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO };
|
||||||
if (m_shared && createInfo.sharing.mode == DxvkSharedHandleMode::Export) {
|
if (m_shared && createInfo.sharing.mode == DxvkSharedHandleMode::Export) {
|
||||||
exportInfo.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO;
|
exportInfo.pNext = std::exchange(dedMemoryAllocInfo.pNext, &exportInfo);
|
||||||
exportInfo.pNext = nullptr;
|
|
||||||
exportInfo.handleTypes = createInfo.sharing.type;
|
exportInfo.handleTypes = createInfo.sharing.type;
|
||||||
|
|
||||||
dedMemoryAllocInfo.pNext = &exportInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
VkImportMemoryWin32HandleInfoKHR importInfo;
|
VkImportMemoryWin32HandleInfoKHR importInfo = { VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR };
|
||||||
if (m_shared && createInfo.sharing.mode == DxvkSharedHandleMode::Import) {
|
if (m_shared && createInfo.sharing.mode == DxvkSharedHandleMode::Import) {
|
||||||
importInfo.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR;
|
importInfo.pNext = std::exchange(dedMemoryAllocInfo.pNext, &importInfo);
|
||||||
importInfo.pNext = nullptr;
|
|
||||||
importInfo.handleType = createInfo.sharing.type;
|
importInfo.handleType = createInfo.sharing.type;
|
||||||
importInfo.handle = createInfo.sharing.handle;
|
importInfo.handle = createInfo.sharing.handle;
|
||||||
importInfo.name = nullptr;
|
|
||||||
|
|
||||||
dedMemoryAllocInfo.pNext = &importInfo;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -186,29 +161,18 @@ namespace dxvk {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPhysicalDeviceExternalImageFormatInfo externalImageFormatInfo;
|
VkPhysicalDeviceExternalImageFormatInfo externalImageFormatInfo = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO };
|
||||||
externalImageFormatInfo.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO;
|
|
||||||
externalImageFormatInfo.pNext = VK_NULL_HANDLE;
|
|
||||||
externalImageFormatInfo.handleType = sharingInfo.type;
|
externalImageFormatInfo.handleType = sharingInfo.type;
|
||||||
|
|
||||||
VkPhysicalDeviceImageFormatInfo2 imageFormatInfo;
|
VkPhysicalDeviceImageFormatInfo2 imageFormatInfo = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2, &externalImageFormatInfo };
|
||||||
imageFormatInfo.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2;
|
|
||||||
imageFormatInfo.pNext = &externalImageFormatInfo;
|
|
||||||
imageFormatInfo.format = createInfo.format;
|
imageFormatInfo.format = createInfo.format;
|
||||||
imageFormatInfo.type = createInfo.imageType;
|
imageFormatInfo.type = createInfo.imageType;
|
||||||
imageFormatInfo.tiling = createInfo.tiling;
|
imageFormatInfo.tiling = createInfo.tiling;
|
||||||
imageFormatInfo.usage = createInfo.usage;
|
imageFormatInfo.usage = createInfo.usage;
|
||||||
imageFormatInfo.flags = createInfo.flags;
|
imageFormatInfo.flags = createInfo.flags;
|
||||||
|
|
||||||
VkExternalImageFormatProperties externalImageFormatProperties;
|
VkExternalImageFormatProperties externalImageFormatProperties = { VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES };
|
||||||
externalImageFormatProperties.sType = VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES;
|
VkImageFormatProperties2 imageFormatProperties = { VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2, &externalImageFormatProperties };
|
||||||
externalImageFormatProperties.pNext = nullptr;
|
|
||||||
externalImageFormatProperties.externalMemoryProperties = {};
|
|
||||||
|
|
||||||
VkImageFormatProperties2 imageFormatProperties;
|
|
||||||
imageFormatProperties.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
|
|
||||||
imageFormatProperties.pNext = &externalImageFormatProperties;
|
|
||||||
imageFormatProperties.imageFormatProperties = {};
|
|
||||||
|
|
||||||
VkResult vr = m_device->adapter()->vki()->vkGetPhysicalDeviceImageFormatProperties2(
|
VkResult vr = m_device->adapter()->vki()->vkGetPhysicalDeviceImageFormatProperties2(
|
||||||
m_device->adapter()->handle(), &imageFormatInfo, &imageFormatProperties);
|
m_device->adapter()->handle(), &imageFormatInfo, &imageFormatProperties);
|
||||||
@ -243,9 +207,7 @@ namespace dxvk {
|
|||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
VkMemoryGetWin32HandleInfoKHR handleInfo;
|
VkMemoryGetWin32HandleInfoKHR handleInfo = { VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR };
|
||||||
handleInfo.sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR;
|
|
||||||
handleInfo.pNext = nullptr;
|
|
||||||
handleInfo.handleType = m_info.sharing.type;
|
handleInfo.handleType = m_info.sharing.type;
|
||||||
handleInfo.memory = m_image.memory.memory();
|
handleInfo.memory = m_image.memory.memory();
|
||||||
if (m_vkd->vkGetMemoryWin32HandleKHR(m_vkd->device(), &handleInfo, &handle) != VK_SUCCESS)
|
if (m_vkd->vkGetMemoryWin32HandleKHR(m_vkd->device(), &handleInfo, &handle) != VK_SUCCESS)
|
||||||
@ -319,15 +281,10 @@ namespace dxvk {
|
|||||||
subresourceRange.baseArrayLayer = m_info.minLayer;
|
subresourceRange.baseArrayLayer = m_info.minLayer;
|
||||||
subresourceRange.layerCount = numLayers;
|
subresourceRange.layerCount = numLayers;
|
||||||
|
|
||||||
VkImageViewUsageCreateInfo viewUsage;
|
VkImageViewUsageCreateInfo viewUsage = { VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO };
|
||||||
viewUsage.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO;
|
|
||||||
viewUsage.pNext = nullptr;
|
|
||||||
viewUsage.usage = m_info.usage;
|
viewUsage.usage = m_info.usage;
|
||||||
|
|
||||||
VkImageViewCreateInfo viewInfo;
|
VkImageViewCreateInfo viewInfo = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, &viewUsage };
|
||||||
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
|
||||||
viewInfo.pNext = &viewUsage;
|
|
||||||
viewInfo.flags = 0;
|
|
||||||
viewInfo.image = m_image->handle();
|
viewInfo.image = m_image->handle();
|
||||||
viewInfo.viewType = type;
|
viewInfo.viewType = type;
|
||||||
viewInfo.format = m_info.format;
|
viewInfo.format = m_info.format;
|
||||||
|
Loading…
Reference in New Issue
Block a user