From a155d14d81d0029c4949e2680cae04ef63038580 Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Wed, 6 Mar 2024 01:12:43 +0200 Subject: [PATCH] [d3d8] Use D3DPOOL_SCRATCH in CreateImageSurface --- src/d3d8/d3d8_device.cpp | 5 +++-- src/d3d8/d3d8_format.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/d3d8/d3d8_device.cpp b/src/d3d8/d3d8_device.cpp index c3ad13965589..dd8f55cc42b8 100644 --- a/src/d3d8/d3d8_device.cpp +++ b/src/d3d8/d3d8_device.cpp @@ -436,14 +436,15 @@ namespace dxvk { } HRESULT STDMETHODCALLTYPE D3D8Device::CreateImageSurface(UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) { + // TODO: Use D3DPOOL_SCRATCH globally, not only for unsupported surface formats (depends on CopyRects support) + d3d9::D3DPOOL pool = isUnsupportedSurfaceFormat(Format) ? d3d9::D3DPOOL_SCRATCH : d3d9::D3DPOOL_SYSTEMMEM; Com pSurf = nullptr; HRESULT res = GetD3D9()->CreateOffscreenPlainSurface( Width, Height, d3d9::D3DFORMAT(Format), - // FIXME: D3DPOOL_SCRATCH is said to be dx8 compatible, but currently won't work with CopyRects - d3d9::D3DPOOL_SYSTEMMEM, + pool, &pSurf, NULL); diff --git a/src/d3d8/d3d8_format.h b/src/d3d8/d3d8_format.h index 6bc2c8b487ac..b7525b6ff51d 100644 --- a/src/d3d8/d3d8_format.h +++ b/src/d3d8/d3d8_format.h @@ -15,6 +15,17 @@ namespace dxvk { return isDXT(D3DFORMAT(fmt)); } + inline constexpr bool isUnsupportedSurfaceFormat(D3DFORMAT fmt) { + // mirror what dxvk doesn't support in terms of d3d9 surface formats + return fmt == D3DFMT_R8G8B8 + || fmt == D3DFMT_R3G3B2 + || fmt == D3DFMT_A8R3G3B2 + || fmt == D3DFMT_A8P8 + || fmt == D3DFMT_P8; + // not included in the d3d8 spec + //|| fmt == D3DFMT_CXV8U8; + } + inline constexpr bool isSupportedDepthStencilFormat(D3DFORMAT fmt) { // native d3d8 doesn't support D3DFMT_D32, D3DFMT_D15S1 or D3DFMT_D24X4S4 return fmt == D3DFMT_D16_LOCKABLE