Skip to content

Commit

Permalink
[d3d8] Return S_FALSE if VCache queries are unsupported
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed May 25, 2024
1 parent 1a039a4 commit f0f45f3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/d3d8/d3d8_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace dxvk {

HRESULT res;
d3d9::IDirect3DQuery9* pQuery = nullptr;
D3DDEVINFO_VCACHE vCacheDevInfo = {0};

switch (DevInfoID) {
// pre-D3D8 queries
Expand All @@ -90,9 +91,13 @@ 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))
goto vcache;
break;
case D3DDEVINFOID_RESOURCEMANAGER:
// May not be implemented by D9VK.
Expand Down Expand Up @@ -120,6 +125,16 @@ namespace dxvk {
// TODO: Will immediately issuing the query without doing any API calls
// actually yield meaingful results? And should we flush or let it mellow?
res = pQuery->GetData(pDevInfoStruct, DevInfoStructSize, D3DGETDATA_FLUSH);
goto done;

vcache:
if (DevInfoStructSize != sizeof(D3DDEVINFO_VCACHE))
return D3DERR_INVALIDCALL;

// Return a zeroed out query result and S_FALSE
// in case of failed VCache queries (AMD/Intel)
memcpy(pDevInfoStruct, &vCacheDevInfo, DevInfoStructSize);
return S_FALSE;

done:
if (pQuery != nullptr)
Expand Down
7 changes: 7 additions & 0 deletions src/d3d8/d3d8_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@

namespace dxvk {

typedef struct D3DDEVINFO_VCACHE {
DWORD Pattern;
DWORD OptMethod;
DWORD CacheSize;
DWORD MagicNumber;
} D3DDEVINFO_VCACHE;

class D3D8Interface;

struct D3D8VertexShaderInfo;
Expand Down

0 comments on commit f0f45f3

Please sign in to comment.