From 3a45984d8e4921e519824fb2714504ef7c14b90d Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Fri, 13 Jun 2003 19:21:10 +0000 Subject: [PATCH] Tentative --- Source/Win32/CxbxKrnl/EmuD3D8.cpp | 154 +++++++++++++++++++++++++----- 1 file changed, 130 insertions(+), 24 deletions(-) diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index 4ee93489c..b8a00742b 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -437,7 +437,6 @@ HRESULT WINAPI xd3d8::EmuIDirect3D8_CreateDevice pPresentationParameters->BackBufferFormat = D3DDisplayMode.Format; pPresentationParameters->FullScreen_RefreshRateInHz = 0; - pPresentationParameters->hDeviceWindow = hFocusWindow; } else { @@ -1068,6 +1067,53 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_SetTexture return hRet; } +// ****************************************************************** +// * func: EmuIDirect3DDevice8_SwitchTexture +// ****************************************************************** +VOID __fastcall xd3d8::EmuIDirect3DDevice8_SwitchTexture +( + DWORD Method, + DWORD Data, + DWORD Format +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SwitchTexture\n" + "(\n" + " Method : 0x%.08X\n" + " Data : 0x%.08X\n" + " Format : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), Method, Data, Format); + } + #endif + + EmuCleanup("EmuIDirect3DDevice8_SwitchTexture is not implemented!"); +/*** + IDirect3DBaseTexture8 *pBaseTexture8 = pTexture->EmuBaseTexture8; + IDirect3DBaseTexture8 *pPrevTexture8 = NULL; + + // Xbox SwitchTexture does not decrement the reference count on the + // old texture, but SetTexture does, so we need to pre-increment + g_pD3DDevice8->GetTexture(Stage, &pPrevTexture8); + + HRESULT hRet = g_pD3DDevice8->SetTexture(Stage, pBaseTexture8); + + // Xbox SwitchTexture does not increment reference count, but the + // above SetTexture does, so we need to remove it. + pBaseTexture8->Release(); +***/ + EmuSwapFS(); // XBox FS + + return; +} + // ****************************************************************** // * func: EmuIDirect3DDevice8_GetDisplayMode // ****************************************************************** @@ -1972,31 +2018,11 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_SetVertexShader } // ****************************************************************** -// * func: EmuIDirect3DDevice8_DrawVertices +// * func: EmuUpdateDeferredStates // ****************************************************************** -HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVertices -( - D3DPRIMITIVETYPE PrimitiveType, - UINT StartVertex, - UINT VertexCount -) +static void EmuUpdateDeferredStates() { - EmuSwapFS(); // Win2k/XP FS - - // ****************************************************************** - // * debug trace - // ****************************************************************** - #ifdef _DEBUG_TRACE - { - printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_DrawVertices\n" - "(\n" - " PrimitiveType : 0x%.08X\n" - " StartVertex : 0x%.08X\n" - " VertexCount : 0x%.08X\n" - ");\n", - GetCurrentThreadId(), PrimitiveType, StartVertex, VertexCount); - } - #endif + using namespace xd3d8; // Certain D3DRS values need to be checked on each Draw[Indexed]Vertices if(xd3d8::EmuD3DDeferredRenderState != 0) @@ -2026,6 +2052,36 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVertices g_pD3DDevice8->SetTextureStageState(v, D3DTSS_ALPHAOP, pCur[16]); } } +} + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_DrawVertices +// ****************************************************************** +HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVertices +( + D3DPRIMITIVETYPE PrimitiveType, + UINT StartVertex, + UINT VertexCount +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_DrawVertices\n" + "(\n" + " PrimitiveType : 0x%.08X\n" + " StartVertex : 0x%.08X\n" + " VertexCount : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), PrimitiveType, StartVertex, VertexCount); + } + #endif + + EmuUpdateDeferredStates(); UINT PrimitiveCount = D3DVertex2PrimitiveCount(PrimitiveType, VertexCount); @@ -2044,6 +2100,56 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVertices return hRet; } +// ****************************************************************** +// * func: EmuIDirect3DDevice8_DrawVerticesUP +// ****************************************************************** +HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVerticesUP +( + D3DPRIMITIVETYPE PrimitiveType, + UINT VertexCount, + CONST PVOID pVertexStreamZeroData, + UINT VertexStreamZeroStride +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_DrawVerticesUP\n" + "(\n" + " PrimitiveType : 0x%.08X\n" + " VertexCount : 0x%.08X\n" + " pVertexStreamZeroData : 0x%.08X\n" + " VertexStreamZeroStride : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), PrimitiveType, VertexCount, pVertexStreamZeroData, + VertexStreamZeroStride); + } + #endif + + EmuUpdateDeferredStates(); + + UINT PrimitiveCount = D3DVertex2PrimitiveCount(PrimitiveType, VertexCount); + + // Convert from Xbox to PC enumeration + PrimitiveType = EmuPrimitiveType(PrimitiveType); + + HRESULT hRet = g_pD3DDevice8->DrawPrimitiveUP + ( + PrimitiveType, + PrimitiveCount, + pVertexStreamZeroData, + VertexStreamZeroStride + ); + + EmuSwapFS(); // XBox FS + + return hRet; +} + // ****************************************************************** // * func: EmuIDirect3DDevice8_SetLight // ******************************************************************