1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-21 04:54:15 +01:00

[d3d9] Add additional ValidateBufferProperties validations

This commit is contained in:
WinterSnowfall 2024-10-14 13:48:50 +03:00 committed by Robin Kertels
parent 931796d1c2
commit 88be8256e6

View File

@ -46,7 +46,20 @@ namespace dxvk {
HRESULT D3D9CommonBuffer::ValidateBufferProperties(const D3D9_BUFFER_DESC* pDesc) {
if (pDesc->Size == 0)
if (unlikely(pDesc->Size == 0))
return D3DERR_INVALIDCALL;
// Neither vertex nor index buffers can be created in D3DPOOL_SCRATCH
// or in D3DPOOL_MANAGED with D3DUSAGE_DYNAMIC.
if (unlikely(pDesc->Pool == D3DPOOL_SCRATCH
|| (pDesc->Pool == D3DPOOL_MANAGED && (pDesc->Usage & D3DUSAGE_DYNAMIC))))
return D3DERR_INVALIDCALL;
// D3DUSAGE_AUTOGENMIPMAP, D3DUSAGE_DEPTHSTENCIL and D3DUSAGE_RENDERTARGET
// are not permitted on index or vertex buffers.
if (unlikely((pDesc->Usage & D3DUSAGE_AUTOGENMIPMAP)
|| (pDesc->Usage & D3DUSAGE_DEPTHSTENCIL)
|| (pDesc->Usage & D3DUSAGE_RENDERTARGET)))
return D3DERR_INVALIDCALL;
return D3D_OK;