1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 13:24:20 +01:00

[d3d9] StretchRect: Allow using an offscreen surface as dst when stretching

This commit is contained in:
Robin Kertels 2024-07-09 14:32:44 +02:00 committed by Joshie
parent cc87870be1
commit d456d0b437

View File

@ -1245,6 +1245,7 @@ namespace dxvk {
bool stretch = srcCopyExtent != dstCopyExtent; bool stretch = srcCopyExtent != dstCopyExtent;
bool dstHasRTUsage = (dstTextureInfo->Desc()->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0; bool dstHasRTUsage = (dstTextureInfo->Desc()->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0;
bool dstIsSurface = dstTextureInfo->GetType() == D3DRTYPE_SURFACE;
if (stretch) { if (stretch) {
if (unlikely(pSourceSurface == pDestSurface)) if (unlikely(pSourceSurface == pDestSurface))
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
@ -1252,12 +1253,13 @@ namespace dxvk {
if (unlikely(dstIsDepth)) if (unlikely(dstIsDepth))
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
// Stretching is only allowed if the destination is either a render target surface or a render target texture // The docs say that stretching is only allowed if the destination is either a render target surface or a render target texture.
if (unlikely(!dstHasRTUsage)) // 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; return D3DERR_INVALIDCALL;
} else { } else {
bool srcIsSurface = srcTextureInfo->GetType() == D3DRTYPE_SURFACE; bool srcIsSurface = srcTextureInfo->GetType() == D3DRTYPE_SURFACE;
bool dstIsSurface = dstTextureInfo->GetType() == D3DRTYPE_SURFACE;
bool srcHasRTUsage = (srcTextureInfo->Desc()->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0; bool srcHasRTUsage = (srcTextureInfo->Desc()->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0;
// Non-stretching copies are only allowed if: // Non-stretching copies are only allowed if:
// - the destination is either a render target surface or a render target texture // - the destination is either a render target surface or a render target texture