Sorted declaration of X_D3DAPI_ENUM elements and those case's in HLE_API_handle_method()

This commit is contained in:
PatrickvL 2023-11-08 09:27:20 +01:00
parent b9afc1bf51
commit 98847cccba
2 changed files with 41 additions and 36 deletions

View File

@ -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

View File

@ -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;
}
}