port: GrpScreen verbatim 40250 (2d draws via UIRender, D3D8 shim device-lost/Present/ID3DXMesh)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-30 14:40:57 +09:00
co-authored by Claude Opus 5.5
parent d73f5ea4bd
commit b5d413afa6
7 changed files with 1125 additions and 323 deletions
File diff suppressed because it is too large Load Diff
+10
View File
@@ -328,6 +328,11 @@ public:
// The caps leave out D3DCAPS2_FULLSCREENGAMMA (the frame goes to a window, where D3D8 ignores the
// ramp too), so 40250 CPythonGraphic::SetGamma returns before it gets here.
void SetGammaRamp(DWORD, const D3DGAMMARAMP*) override {}
// PORT: the host owns the swapchain (Vulkan / canvas): the recorded device is never lost, Reset keeps
// the recording size, and the host presents the recorded frame after CPythonApplication::Process.
HRESULT TestCooperativeLevel() override { return D3D_OK; }
HRESULT Reset(D3DPRESENT_PARAMETERS*) override { return D3D_OK; }
HRESULT Present(const RECT*, const RECT*, HWND, const RGNDATA*) override { return D3D_OK; }
HRESULT BeginScene() override { return S_OK; }
HRESULT EndScene() override { return S_OK; }
@@ -504,6 +509,11 @@ public:
}
// PORT: fixed function only; CGraphicDevice's stream "shaders" are the FVFs they describe.
HRESULT SetVertexShader(DWORD handle) override { m_fvf = handle; return S_OK; }
HRESULT GetVertexShader(DWORD* pHandle) override
{
*pHandle = m_fvf;
return S_OK;
}
HRESULT SetPixelShader(DWORD) override { return S_OK; }
// PORT: no programmable vertex shaders; 40250 falls back to its FVF when creation fails.
HRESULT CreateVertexShader(const DWORD*, const DWORD*, DWORD* pHandle, DWORD) override
+11
View File
@@ -505,6 +505,9 @@ typedef enum _D3DVERTEXBLENDFLAGS {
#define D3DFVF_RESERVED2 0xE000
// d3d8.h
#define D3D_OK S_OK
// d3d8.h device-lost results (MAKE_D3DHRESULT(2152), (2153)).
#define D3DERR_DEVICELOST ((HRESULT)0x88760868L)
#define D3DERR_DEVICENOTRESET ((HRESULT)0x88760869L)
// d3d8types.h vertex shader declaration tokens
typedef enum _D3DVSD_TOKENTYPE
@@ -801,6 +804,10 @@ struct IDirect3DIndexBuffer8 : IDirect3DResource8
virtual HRESULT Unlock() = 0;
};
// wingdi.h region data; Present's dirty region is only ever NULL here.
struct _RGNDATA;
typedef struct _RGNDATA RGNDATA;
// The device methods the ported code calls (CStateManager), with D3D8's signatures. The platform
// implements it (platform/EterLib/RecordingDevice.h) as a device that records draw calls.
struct IDirect3DDevice8
@@ -813,6 +820,9 @@ struct IDirect3DDevice8
virtual HRESULT SetViewport(const D3DVIEWPORT8* pViewport) = 0;
virtual UINT GetAvailableTextureMem() = 0;
virtual void SetGammaRamp(DWORD Flags, const D3DGAMMARAMP* pRamp) = 0;
virtual HRESULT TestCooperativeLevel() = 0;
virtual HRESULT Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) = 0;
virtual HRESULT Present(const RECT* pSourceRect, const RECT* pDestRect, HWND hDestWindowOverride, const RGNDATA* pDirtyRegion) = 0;
virtual HRESULT BeginScene() = 0;
virtual HRESULT EndScene() = 0;
virtual HRESULT SetTransform(D3DTRANSFORMSTATETYPE State, const D3DMATRIX* pMatrix) = 0;
@@ -834,6 +844,7 @@ struct IDirect3DDevice8
virtual HRESULT CreateVertexShader(const DWORD* pDeclaration, const DWORD* pFunction, DWORD* pHandle, DWORD Usage) = 0;
virtual HRESULT DeleteVertexShader(DWORD Handle) = 0;
virtual HRESULT SetVertexShader(DWORD Handle) = 0;
virtual HRESULT GetVertexShader(DWORD* pHandle) = 0;
virtual HRESULT SetPixelShader(DWORD Handle) = 0;
virtual HRESULT SetVertexShaderConstant(DWORD Register, const void* pConstantData, DWORD ConstantCount) = 0;
virtual HRESULT SetPixelShaderConstant(DWORD Register, const void* pConstantData, DWORD ConstantCount) = 0;
+11 -1
View File
@@ -24,7 +24,17 @@ inline HRESULT D3DXAssembleShader(const void*, UINT, DWORD, LPD3DXBUFFER* ppCons
return E_FAIL;
}
struct ID3DXMesh;
// d3dx8mesh.h ID3DXMesh: the members CScreen::RenderD3DXMesh reads.
struct ID3DXMesh
{
virtual ~ID3DXMesh() = default;
virtual ULONG Release() = 0;
virtual DWORD GetNumFaces() = 0;
virtual DWORD GetNumVertices() = 0;
virtual DWORD GetFVF() = 0;
virtual HRESULT GetVertexBuffer(LPDIRECT3DVERTEXBUFFER8* ppVB) = 0;
virtual HRESULT GetIndexBuffer(LPDIRECT3DINDEXBUFFER8* ppIB) = 0;
};
typedef ID3DXMesh* LPD3DXMESH;
struct ID3DXMatrixStack;
typedef ID3DXMatrixStack* LPD3DXMATRIXSTACK;