port: GrpDetector verbatim 40250 over a host IDirect3D8 (Direct3DCreate8); GrpDevice::Create verbatim

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-30 15:02:12 +09:00
co-authored by Claude Opus 5.5
parent 65c43a84cd
commit fd4d9a39df
12 changed files with 1127 additions and 173 deletions
+25 -9
View File
@@ -508,6 +508,9 @@ typedef enum _D3DVERTEXBLENDFLAGS {
// d3d8.h device-lost results (MAKE_D3DHRESULT(2152), (2153)).
#define D3DERR_DEVICELOST ((HRESULT)0x88760868L)
#define D3DERR_DEVICENOTRESET ((HRESULT)0x88760869L)
#define D3DERR_NOTAVAILABLE ((HRESULT)0x8876086AL)
#define D3DERR_OUTOFVIDEOMEMORY ((HRESULT)0x8876017CL)
#define D3DERR_INVALIDCALL ((HRESULT)0x8876086CL)
// d3d8types.h vertex shader declaration tokens
typedef enum _D3DVSD_TOKENTYPE
@@ -692,6 +695,8 @@ typedef struct _D3DCAPS8
} D3DCAPS8;
#define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000L
#define D3DDEVCAPS_PUREDEVICE 0x00100000L
#define D3DCAPS2_CANRENDERWINDOWED 0x00080000L
#define D3DCAPS2_FULLSCREENGAMMA 0x00020000L
typedef struct _D3DGAMMARAMP
@@ -726,15 +731,6 @@ typedef struct _D3DGAMMARAMP
// upcasts 40250 relies on (texture -> base texture) compile; of the resources only the buffers carry
#define D3DENUM_NO_WHQL_LEVEL 0x00000002L
struct IDirect3D8
{
virtual ~IDirect3D8() = default;
virtual ULONG Release() { return 0; }
virtual HRESULT GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier) = 0;
virtual HRESULT GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) = 0;
virtual UINT GetAdapterModeCount(UINT Adapter) = 0;
virtual HRESULT EnumAdapterModes(UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) = 0;
};
typedef enum _D3DRESOURCETYPE
{
D3DRTYPE_SURFACE = 1,
@@ -747,6 +743,26 @@ typedef enum _D3DRESOURCETYPE
D3DRTYPE_FORCE_DWORD = 0x7fffffff
} D3DRESOURCETYPE;
struct IDirect3DDevice8;
struct IDirect3D8
{
virtual ~IDirect3D8() = default;
virtual ULONG Release() = 0;
virtual UINT GetAdapterCount() = 0;
virtual HRESULT GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier) = 0;
virtual UINT GetAdapterModeCount(UINT Adapter) = 0;
virtual HRESULT EnumAdapterModes(UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) = 0;
virtual HRESULT GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) = 0;
virtual HRESULT CheckDeviceType(UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed) = 0;
virtual HRESULT CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) = 0;
virtual HRESULT CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) = 0;
virtual HRESULT GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) = 0;
virtual HRESULT CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice8** ppReturnedDeviceInterface) = 0;
};
// d3d8.h; platform/EterLib/RecordingDevice.cpp implements the one host adapter.
#define D3D_SDK_VERSION 220
IDirect3D8* Direct3DCreate8(UINT SDKVersion);
typedef struct _D3DLOCKED_RECT
{
INT Pitch;
-2
View File
@@ -103,8 +103,6 @@ uintptr_t _beginthreadex(void* security, unsigned stack_size, unsigned (*start_a
#define MB_TOPMOST 0x00040000L
#define IDOK 1
int MessageBox(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
// user32 ReleaseDC: the host owns the window and hands out no DC, so there is none to release.
inline int ReleaseDC(HWND, HDC) { return 1; }
// winmm `timeGetTime`: milliseconds since system start, wrapping at 2^32.
DWORD timeGetTime();
+8
View File
@@ -30,6 +30,14 @@ typedef WORD ATOM;
#define SWP_NOSIZE 0x0001
#define SWP_NOMOVE 0x0002
#define SWP_NOZORDER 0x0004
#define SWP_SHOWWINDOW 0x0040
#define HWND_TOP ((HWND)0)
#define HWND_TOPMOST ((HWND)-1)
// GetDC/ReleaseDC: the host draws the window, so there is no GDI device context to hand out.
inline HDC GetDC(HWND) { return NULL; }
inline int ReleaseDC(HWND, HDC) { return 1; }
#define PM_NOREMOVE 0x0000
#define PM_REMOVE 0x0001