From d456d0b43748baf4f98477a4e8598841b700f863 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Tue, 9 Jul 2024 14:32:44 +0200 Subject: [PATCH] [d3d9] StretchRect: Allow using an offscreen surface as dst when stretching --- src/d3d9/d3d9_device.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 31afcd45f..48dc9ade9 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -1245,6 +1245,7 @@ namespace dxvk { bool stretch = srcCopyExtent != dstCopyExtent; bool dstHasRTUsage = (dstTextureInfo->Desc()->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0; + bool dstIsSurface = dstTextureInfo->GetType() == D3DRTYPE_SURFACE; if (stretch) { if (unlikely(pSourceSurface == pDestSurface)) return D3DERR_INVALIDCALL; @@ -1252,12 +1253,13 @@ namespace dxvk { if (unlikely(dstIsDepth)) return D3DERR_INVALIDCALL; - // Stretching is only allowed if the destination is either a render target surface or a render target texture - if (unlikely(!dstHasRTUsage)) + // The docs say that stretching is only allowed if the destination is either a render target surface or a render target texture. + // However in practice, using an offscreen plain surface in D3DPOOL_DEFAULT as the destination works fine. + // Using a texture without USAGE_RENDERTARGET as destination however does not. + if (unlikely(!dstIsSurface && !dstHasRTUsage)) return D3DERR_INVALIDCALL; } else { bool srcIsSurface = srcTextureInfo->GetType() == D3DRTYPE_SURFACE; - bool dstIsSurface = dstTextureInfo->GetType() == D3DRTYPE_SURFACE; bool srcHasRTUsage = (srcTextureInfo->Desc()->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0; // Non-stretching copies are only allowed if: // - the destination is either a render target surface or a render target texture