From b586294e29407a60bda1d406864017dfd8ab7437 Mon Sep 17 00:00:00 2001
From: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Date: Mon, 13 Jan 2025 00:16:08 +0100
Subject: [PATCH] [d3d11] Set color space for swap chain image

---
 src/d3d11/d3d11_swapchain.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp
index df3e99879..aceb2055f 100644
--- a/src/d3d11/d3d11_swapchain.cpp
+++ b/src/d3d11/d3d11_swapchain.cpp
@@ -421,6 +421,14 @@ namespace dxvk {
       cColorSpace     = m_colorSpace,
       cFrameId        = m_frameId
     ] (DxvkContext* ctx) {
+      // Update back buffer color space as necessary
+      if (cSwapImage->image()->info().colorSpace != cColorSpace) {
+        DxvkImageUsageInfo usage = { };
+        usage.colorSpace = cColorSpace;
+
+        ctx->ensureImageCompatibility(cSwapImage->image(), usage);
+      }
+
       // Blit the D3D back buffer onto the actual Vulkan
       // swap chain and render the HUD if we have one.
       auto contextObjects = ctx->beginExternalRendering();