diff --git a/src/d3d8/d3d8_device.cpp b/src/d3d8/d3d8_device.cpp index f0315d8c0..3ae328bdb 100644 --- a/src/d3d8/d3d8_device.cpp +++ b/src/d3d8/d3d8_device.cpp @@ -309,6 +309,11 @@ namespace dxvk { D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8** ppTexture) { + // D3D8 returns D3DERR_INVALIDCALL for D3DFMT_UNKNOWN + // before clearing the content of ppTexture. + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppTexture); if (unlikely(ppTexture == nullptr)) @@ -344,6 +349,11 @@ namespace dxvk { D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture) { + // D3D8 returns D3DERR_INVALIDCALL for D3DFMT_UNKNOWN + // before clearing the content of ppVolumeTexture. + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppVolumeTexture); if (unlikely(ppVolumeTexture == nullptr)) @@ -371,6 +381,11 @@ namespace dxvk { D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8** ppCubeTexture) { + // D3D8 returns D3DERR_INVALIDCALL for D3DFMT_UNKNOWN + // before clearing the content of ppCubeTexture. + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppCubeTexture); if (unlikely(ppCubeTexture == nullptr)) @@ -444,6 +459,11 @@ namespace dxvk { D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) { + // D3D8 returns D3DERR_INVALIDCALL for D3DFMT_UNKNOWN + // before clearing the content of ppSurface. + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppSurface); if (unlikely(ppSurface == nullptr)) @@ -472,6 +492,11 @@ namespace dxvk { D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) { + // D3D8 returns D3DERR_INVALIDCALL for D3DFMT_UNKNOWN + // before clearing the content of ppSurface. + if (unlikely(Format == D3DFMT_UNKNOWN)) + return D3DERR_INVALIDCALL; + InitReturnPtr(ppSurface); if (unlikely(ppSurface == nullptr)) @@ -499,8 +524,13 @@ namespace dxvk { UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) { + // Only D3D8 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;