Skip to content

Commit

Permalink
Implement Direct3DDevice8::GetInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Sep 22, 2024
1 parent ac41b09 commit cd8a803
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 5 deletions.
67 changes: 62 additions & 5 deletions source/d3d8to9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,15 +971,72 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::ValidateDevice(DWORD *pNumPasses)
}
HRESULT STDMETHODCALLTYPE Direct3DDevice8::GetInfo(DWORD DevInfoID, void *pDevInfoStruct, DWORD DevInfoStructSize)
{
UNREFERENCED_PARAMETER(DevInfoID);
UNREFERENCED_PARAMETER(pDevInfoStruct);
UNREFERENCED_PARAMETER(DevInfoStructSize);

#ifndef D3D8TO9NOLOG
LOG << "Redirecting '" << "IDirect3DDevice8::GetInfo" << "(" << this << ", " << DevInfoID << ", " << pDevInfoStruct << ", " << DevInfoStructSize << ")' ..." << std::endl;
#endif

return S_FALSE;
if (pDevInfoStruct == nullptr || DevInfoStructSize == 0)
return D3DERR_INVALIDCALL;

HRESULT hr;
IDirect3DQuery9 *pQuery = nullptr;

switch (DevInfoID)
{
case 0:
case D3DDEVINFOID_TEXTUREMANAGER:
case D3DDEVINFOID_D3DTEXTUREMANAGER:
case D3DDEVINFOID_TEXTURING:
return E_FAIL; // Unsupported query IDs

case D3DDEVINFOID_VCACHE:
hr = ProxyInterface->CreateQuery(D3DQUERYTYPE_VCACHE, &pQuery);

if (FAILED(hr))
{
if (DevInfoStructSize != sizeof(D3DDEVINFO_VCACHE))
return D3DERR_INVALIDCALL;

// The contents of pDevInfoStruct are zeroed before return
memset(pDevInfoStruct, 0, sizeof(D3DDEVINFO_VCACHE));
return S_FALSE;
}

break;

case D3DDEVINFOID_RESOURCEMANAGER:
hr = ProxyInterface->CreateQuery(D3DQUERYTYPE_RESOURCEMANAGER, &pQuery);
break;

case D3DDEVINFOID_VERTEXSTATS:
hr = ProxyInterface->CreateQuery(D3DQUERYTYPE_VERTEXSTATS, &pQuery);
break;

default: // D3DDEVINFOID_UNKNOWN
return E_FAIL;
}

if ((FAILED(hr)))
{
if (hr == D3DERR_NOTAVAILABLE)
{
return E_FAIL;
}
else
{
return S_FALSE;
}
}

if (pQuery != nullptr)
{
pQuery->Issue(D3DISSUE_END);
hr = pQuery->GetData(pDevInfoStruct, DevInfoStructSize, D3DGETDATA_FLUSH);

pQuery->Release();
}

return hr;
}
HRESULT STDMETHODCALLTYPE Direct3DDevice8::SetPaletteEntries(UINT PaletteNumber, const PALETTEENTRY *pEntries)
{
Expand Down
20 changes: 20 additions & 0 deletions source/d3d8types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ struct IUnknown;
#endif
#define D3DPRASTERCAPS_ZBIAS 0x00004000L

// These aren't typically included in any of the MSVC headers
#ifndef D3DDEVINFOID_TEXTUREMANAGER
#define D3DDEVINFOID_TEXTUREMANAGER 1
#endif
#ifndef D3DDEVINFOID_D3DTEXTUREMANAGER
#define D3DDEVINFOID_D3DTEXTUREMANAGER 2
#endif
#ifndef D3DDEVINFOID_TEXTURING
#define D3DDEVINFOID_TEXTURING 3
#endif
#ifndef D3DDEVINFOID_VCACHE
#define D3DDEVINFOID_VCACHE 4
#endif
#ifndef D3DDEVINFOID_RESOURCEMANAGER
#define D3DDEVINFOID_RESOURCEMANAGER 5
#endif
#ifndef D3DDEVINFOID_VERTEXSTATS
#define D3DDEVINFOID_VERTEXSTATS 6
#endif

typedef D3DLIGHT9 D3DLIGHT8;
typedef D3DMATERIAL9 D3DMATERIAL8;
typedef D3DVIEWPORT9 D3DVIEWPORT8;
Expand Down

0 comments on commit cd8a803

Please sign in to comment.