From 98847cccba5ac9d5c17094c96af24a56203812f2 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Wed, 8 Nov 2023 09:27:20 +0100 Subject: [PATCH] Sorted declaration of X_D3DAPI_ENUM elements and those case's in HLE_API_handle_method() --- src/core/hle/D3D8/Direct3D9/HleInNv2a.h | 28 ++++++++------ src/devices/video/EmuNV2A_PGRAPH.cpp | 49 +++++++++++++------------ 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/HleInNv2a.h b/src/core/hle/D3D8/Direct3D9/HleInNv2a.h index daa6c13f2..45738f7d1 100644 --- a/src/core/hle/D3D8/Direct3D9/HleInNv2a.h +++ b/src/core/hle/D3D8/Direct3D9/HleInNv2a.h @@ -2,9 +2,14 @@ // enum for xbox D3DDevice APIs typedef enum _X_D3DAPI_ENUM { - + // Keep below sorted to ease future edits X_CDevice_SetStateUP, X_CDevice_SetStateVB, + X_D3D_BlockOnTime, + X_D3D_CommonSetRenderTarget, + X_D3D_DestroyResource, + X_D3D_LazySetPointParams, + X_D3D_SetCommonDebugRegisters, X_D3DDevice_ApplyStateBlock, X_D3DDevice_Begin, X_D3DDevice_BeginPush, @@ -59,14 +64,16 @@ typedef enum _X_D3DAPI_ENUM { X_D3DDevice_EndStateBlock, X_D3DDevice_EndVisibilityTest, X_D3DDevice_FlushVertexCache, - X_D3DDevice_GetBackBuffer, X_D3DDevice_GetBackBuffer2, + X_D3DDevice_GetBackBuffer, + X_D3DDevice_GetBackBuffer2, X_D3DDevice_GetBackBufferScale, X_D3DDevice_GetBackMaterial, X_D3DDevice_GetCopyRectsState, X_D3DDevice_GetCreationParameters, X_D3DDevice_GetDebugMarker, X_D3DDevice_GetDepthClipPlanes, - X_D3DDevice_GetDepthStencilSurface, X_D3DDevice_GetDepthStencilSurface2, + X_D3DDevice_GetDepthStencilSurface, + X_D3DDevice_GetDepthStencilSurface2, X_D3DDevice_GetDeviceCaps, X_D3DDevice_GetDirect3D, X_D3DDevice_GetDisplayFieldStatus, @@ -89,7 +96,8 @@ typedef enum _X_D3DAPI_ENUM { X_D3DDevice_GetPushDistance, X_D3DDevice_GetRasterStatus, X_D3DDevice_GetRenderState, - X_D3DDevice_GetRenderTarget, X_D3DDevice_GetRenderTarget2, + X_D3DDevice_GetRenderTarget, + X_D3DDevice_GetRenderTarget2, X_D3DDevice_GetScissors, X_D3DDevice_GetScreenSpaceOffset, X_D3DDevice_GetShaderConstantMode, @@ -165,7 +173,8 @@ typedef enum _X_D3DAPI_ENUM { X_D3DDevice_SetVertexBlendModelView, X_D3DDevice_SetVertexData2f, X_D3DDevice_SetVertexData2s, - X_D3DDevice_SetVertexData4f, X_D3DDevice_SetVertexData4f_16, + X_D3DDevice_SetVertexData4f, + X_D3DDevice_SetVertexData4f_16, X_D3DDevice_SetVertexData4s, X_D3DDevice_SetVertexData4ub, X_D3DDevice_SetVertexDataColor, @@ -180,17 +189,12 @@ typedef enum _X_D3DAPI_ENUM { X_D3DDevice_SwitchTexture, X_D3DDevice_UpdateOverlay, X_D3DResource_BlockUntilNotBusy, - X_D3D_BlockOnTime, - X_D3D_CommonSetRenderTarget, - X_D3D_DestroyResource, - X_D3D_LazySetPointParams, - X_D3D_SetCommonDebugRegisters, X_Direct3D_CreateDevice, + X_EmuKickOffWait, X_Lock2DSurface, X_Lock3DSurface, - X_EmuKickOffWait, + // Keep X_D3DAPI_FORCE_DWORD last to force X_D3DAPI_ENUM into 4 bytes X_D3DAPI_FORCE_DWORD = 0x7fffffff, - } X_D3DAPI_ENUM; // virtual NV2A register for HLE API handler diff --git a/src/devices/video/EmuNV2A_PGRAPH.cpp b/src/devices/video/EmuNV2A_PGRAPH.cpp index b311ea97d..be0b1fe87 100644 --- a/src/devices/video/EmuNV2A_PGRAPH.cpp +++ b/src/devices/video/EmuNV2A_PGRAPH.cpp @@ -1541,12 +1541,27 @@ void HLE_API_handle_method { //case X_CDevice_SetStateUP: break; //case X_CDevice_SetStateVB: break; + case X_D3D_BlockOnTime: break; + case X_D3D_CommonSetRenderTarget: + //todo:this might be redundant because the HLE implementation of this api never set the call level, so this patch will always calls CxbxrImpl_SetRenderTarget(). we might use the fall through directly. + CxbxrImpl_D3D_CommonSetRenderTarget((xbox::X_D3DSurface*)/* pRenderTarget*/argv[1], (xbox::X_D3DSurface*)/* pNewZStencil*/argv[2], (void*)/* unknown*/argv[3]); + // release reference to the surfaces since we add extra references to them in the patched SetRenderTarget() + CxbxrImpl_ReleaseRenderTarget((xbox::X_D3DSurface*)argv[1], (xbox::X_D3DSurface*)argv[2]); + break; + case X_D3D_DestroyResource: + CxbxrImpl_DestroyResource((xbox::X_D3DResource*)argv[1]); + break; + case X_D3D_LazySetPointParams: break; + case X_D3D_SetCommonDebugRegisters: break; case X_D3DDevice_ApplyStateBlock: break; - case X_D3DDevice_Begin: CxbxrImpl_Begin((xbox::X_D3DPRIMITIVETYPE)argv[1]); break; + case X_D3DDevice_Begin: + CxbxrImpl_Begin((xbox::X_D3DPRIMITIVETYPE)argv[1]); + break; case X_D3DDevice_BeginPush: break; case X_D3DDevice_BeginPushBuffer: break; case X_D3DDevice_BeginScene: break; - case X_D3DDevice_BeginState: break; case X_D3DDevice_BeginStateBig: break; + case X_D3DDevice_BeginState: break; + case X_D3DDevice_BeginStateBig: break; case X_D3DDevice_BeginStateBlock: break; case X_D3DDevice_BeginVisibilityTest: *(bool*)argv[1] = false; @@ -1684,14 +1699,11 @@ void HLE_API_handle_method break; case X_D3DDevice_MultiplyTransform: break; case X_D3DDevice_Nop: break; - case X_D3DDevice_PersistDisplay: - *(bool*)argv[1] = false; - break; + case X_D3DDevice_PersistDisplay: *(bool*)argv[1] = false; break; case X_D3DDevice_Present: #define CXBX_SWAP_PRESENT_FORWARD (256 + xbox::X_D3DSWAP_FINISH + xbox::X_D3DSWAP_COPY) // = CxbxPresentForwardMarker + D3DSWAP_FINISH + D3DSWAP_COPY - //CxbxrImpl_Swap(CXBX_SWAP_PRESENT_FORWARD); - * (bool*)argv[1] = false; + *(bool*)argv[1] = false; break; case X_D3DDevice_PrimeVertexCache: break; case X_D3DDevice_Reset: @@ -1821,19 +1833,12 @@ void HLE_API_handle_method break; case X_D3DDevice_UpdateOverlay: break; case X_D3DResource_BlockUntilNotBusy: break; - case X_D3D_BlockOnTime: break; - case X_D3D_CommonSetRenderTarget: - //todo:this might be redundant because the HLE implementation of this api never set the call level, so this patch will always calls CxbxrImpl_SetRenderTarget(). we might use the fall through directly. - CxbxrImpl_D3D_CommonSetRenderTarget((xbox::X_D3DSurface*)/* pRenderTarget*/argv[1], (xbox::X_D3DSurface*)/* pNewZStencil*/argv[2], (void*)/* unknown*/argv[3]); - // release reference to the surfaces since we add extra references to them in the patched SetRenderTarget() - CxbxrImpl_ReleaseRenderTarget((xbox::X_D3DSurface*)argv[1], (xbox::X_D3DSurface*)argv[2]); - break; - case X_D3D_DestroyResource: - CxbxrImpl_DestroyResource((xbox::X_D3DResource*)argv[1]); - break; - case X_D3D_LazySetPointParams: break; - case X_D3D_SetCommonDebugRegisters: break; case X_Direct3D_CreateDevice: break; + case X_EmuKickOffWait: + //argv[2] is the token of the API which calls EmuKickOffWait() + if (argv[1] != 0) + *(DWORD*)argv[1] = 0; + break; case X_Lock2DSurface: //CxbxrImpl_Lock2DSurface((xbox::X_D3DPixelContainer *) /*pPixelContainer*/argv[1], (D3DCUBEMAP_FACES)/* FaceType*/argv[2], (xbox::uint_xt)/* Level*/argv[3], (D3DLOCKED_RECT *)/* pLockedRect*/argv[3], (RECT *)/* pRect*/argv[5], (xbox::dword_xt)/* Flags*/argv[6]); *(bool*)argv[1] = false; @@ -1842,12 +1847,8 @@ void HLE_API_handle_method //CxbxrImpl_Lock3DSurface((xbox::X_D3DPixelContainer*)/* pPixelContainer*/argv[1], (xbox::uint_xt)/*Level*/argv[2], (D3DLOCKED_BOX*)/* pLockedVolume*/argv[3], (D3DBOX*)/* pBox*/argv[4], (xbox::dword_xt)/*Flags*/argv[5]); *(bool*)argv[1] = false; break; - case X_EmuKickOffWait: - //argv[2] is the token of the API which calls EmuKickOffWait() - if (argv[1] != 0) - *(DWORD*)argv[1] = 0; + default: break; - default:break; } }