From 993c46c8a2e74f34454daf58fec58e1636e557c5 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Tue, 6 Jul 2021 22:09:38 -0700 Subject: [PATCH] libobs-d3d11: Relax texture format copy check SRGB and non-SRGB formats are compatible for copy. --- libobs-d3d11/d3d11-subsystem.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 4c2b60258..e231c3538 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -1768,6 +1768,20 @@ inline void gs_device::CopyTex(ID3D11Texture2D *dst, uint32_t dst_x, } } +static DXGI_FORMAT get_copy_compare_format(gs_color_format format) +{ + switch (format) { + case GS_RGBA_UNORM: + return DXGI_FORMAT_R8G8B8A8_TYPELESS; + case GS_BGRX_UNORM: + return DXGI_FORMAT_B8G8R8X8_TYPELESS; + case GS_BGRA_UNORM: + return DXGI_FORMAT_B8G8R8A8_TYPELESS; + default: + return ConvertGSTextureFormatResource(format); + } +} + void device_copy_texture_region(gs_device_t *device, gs_texture_t *dst, uint32_t dst_x, uint32_t dst_y, gs_texture_t *src, uint32_t src_x, @@ -1784,7 +1798,8 @@ void device_copy_texture_region(gs_device_t *device, gs_texture_t *dst, if (src->type != GS_TEXTURE_2D || dst->type != GS_TEXTURE_2D) throw "Source and destination textures must be a 2D " "textures"; - if (dst->format != src->format) + if (get_copy_compare_format(dst->format) != + get_copy_compare_format(src->format)) throw "Source and destination formats do not match"; /* apparently casting to the same type that the variable