From b1e96099eaa3b0192a5257e40f7596a54f856fcf Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Mon, 14 Oct 2024 11:22:11 +0300 Subject: [PATCH] [d3d8] Adjust surface and texture clearing with D3DFMT_UNKNOWN --- src/d3d8/d3d8_device.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/d3d8/d3d8_device.cpp b/src/d3d8/d3d8_device.cpp index 8c4f4f18d91..756ea2ec79c 100644 --- a/src/d3d8/d3d8_device.cpp +++ b/src/d3d8/d3d8_device.cpp @@ -306,6 +306,9 @@ namespace dxvk { D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8** ppTexture) { + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppTexture); if (unlikely(ppTexture == nullptr)) @@ -341,6 +344,9 @@ namespace dxvk { D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture) { + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppVolumeTexture); if (unlikely(ppVolumeTexture == nullptr)) @@ -368,6 +374,9 @@ namespace dxvk { D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8** ppCubeTexture) { + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppCubeTexture); if (unlikely(ppCubeTexture == nullptr)) @@ -441,6 +450,9 @@ namespace dxvk { D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) { + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppSurface); if (unlikely(ppSurface == nullptr)) @@ -469,6 +481,9 @@ namespace dxvk { D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) { + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppSurface); if (unlikely(ppSurface == nullptr)) @@ -496,8 +511,13 @@ namespace dxvk { UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) { + // Only CreateImageSurface clears the content of ppSurface + // before checking if Format is equal to D3DFMT_UNKNOWN. InitReturnPtr(ppSurface); + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + if (unlikely(ppSurface == nullptr)) return D3DERR_INVALIDCALL;