From 8a18e13906477255d87e6e7a6e3a2e7f66ab18a8 Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Sat, 25 May 2024 21:28:34 +0300 Subject: [PATCH] [d3d8] Return S_FALSE if VCache queries are unsupported --- src/d3d8/d3d8_device.cpp | 16 ++++++++++++++-- src/d3d8/d3d8_include.h | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/d3d8/d3d8_device.cpp b/src/d3d8/d3d8_device.cpp index ea856f2657a..765cdfa24b4 100644 --- a/src/d3d8/d3d8_device.cpp +++ b/src/d3d8/d3d8_device.cpp @@ -88,9 +88,21 @@ namespace dxvk { return E_FAIL; case D3DDEVINFOID_VCACHE: - // Docs say response should be S_FALSE, but we'll let D9VK - // decide based on the value of supportVCache. D3DX8 calls this. + // The query will return D3D_OK on Nvidia and D3DERR_NOTAVAILABLE on AMD/Intel + // in D3D9, however in the case of the latter we'll need to return a + // zeroed out query result and S_FALSE. This behavior has been observed both + // on modern native AMD drivers and D3D8-era native ATI drivers. res = GetD3D9()->CreateQuery(d3d9::D3DQUERYTYPE_VCACHE, &pQuery); + + if(FAILED(res)) { + if (DevInfoStructSize != sizeof(D3DDEVINFO_VCACHE)) + return D3DERR_INVALIDCALL; + + D3DDEVINFO_VCACHE vCacheDevInfo = {0}; + memcpy(pDevInfoStruct, &vCacheDevInfo, DevInfoStructSize); + return S_FALSE; + } + break; case D3DDEVINFOID_RESOURCEMANAGER: // May not be implemented by D9VK. diff --git a/src/d3d8/d3d8_include.h b/src/d3d8/d3d8_include.h index 78d7dcd16d2..ab5e1d77c87 100644 --- a/src/d3d8/d3d8_include.h +++ b/src/d3d8/d3d8_include.h @@ -179,6 +179,13 @@ namespace d3d9 { #define D3DDEVINFOID_VCACHE 4 #endif +typedef struct D3DDEVINFO_VCACHE { + DWORD Pattern; + DWORD OptMethod; + DWORD CacheSize; + DWORD MagicNumber; +} D3DDEVINFO_VCACHE; + // MinGW headers are broken. Who'dve guessed? #ifndef _MSC_VER