diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index c0c3d92d6..1451226c0 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1517,7 +1517,12 @@ namespace dxvk { // If everything matches already, no need to do anything. Only ensure // that the stable adress bit is respected if set for the first time. if (isUsageAndFormatCompatible && isAccessAndLayoutCompatible) { - if (usageInfo.stableGpuAddress && image->canRelocate()) { + bool needsUpdate = (usageInfo.stableGpuAddress && image->canRelocate()); + + if (usageInfo.colorSpace != VK_COLOR_SPACE_MAX_ENUM_KHR) + needsUpdate |= (usageInfo.colorSpace != image->info().colorSpace); + + if (needsUpdate) { image->assignStorageWithUsage(image->storage(), usageInfo); m_common->memoryManager().lockResourceGpuAddress(image->storage()); } diff --git a/src/dxvk/dxvk_image.cpp b/src/dxvk/dxvk_image.cpp index da216ccf7..4f75a8d5d 100644 --- a/src/dxvk/dxvk_image.cpp +++ b/src/dxvk/dxvk_image.cpp @@ -226,6 +226,9 @@ namespace dxvk { if (usageInfo.layout != VK_IMAGE_LAYOUT_UNDEFINED) m_info.layout = usageInfo.layout; + if (usageInfo.colorSpace != VK_COLOR_SPACE_MAX_ENUM_KHR) + m_info.colorSpace = usageInfo.colorSpace; + for (uint32_t i = 0; i < usageInfo.viewFormatCount; i++) { if (!isViewCompatible(usageInfo.viewFormats[i])) m_viewFormats.push_back(usageInfo.viewFormats[i]); diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index 8647baa19..9a19bfddd 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -55,6 +55,10 @@ namespace dxvk { // Initial image layout VkImageLayout initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + // Color space to interpret image data with. This + // is only meaningful for swap chain back buffers. + VkColorSpaceKHR colorSpace = VK_COLOR_SPACE_MAX_ENUM_KHR; + // Image is used by multiple contexts so it needs // to be in its default layout after each submission VkBool32 shared = VK_FALSE; @@ -89,6 +93,8 @@ namespace dxvk { // New image layout. If undefined, the // default layout will not be changed. VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED; + // Color space to interpret the image in + VkColorSpaceKHR colorSpace = VK_COLOR_SPACE_MAX_ENUM_KHR; // Number of new view formats to add uint32_t viewFormatCount = 0u; // View formats to add to the compatibility list