@@ -218,6 +218,8 @@ struct SharedConstants
218218 float halfPixelOffsetX{};
219219 float halfPixelOffsetY{};
220220 float alphaThreshold{};
221+ bool clipPlaneEnabled{};
222+ float clipPlane[4 ]{};
221223};
222224
223225// Depth bias values here are only used when the render device has
@@ -1386,6 +1388,11 @@ static void ProcSetRenderState(const RenderCommand& cmd)
13861388 g_dirtyStates.renderTargetAndDepthStencil |= g_dirtyStates.pipelineState ;
13871389 break ;
13881390 }
1391+ case D3DRS_CLIPPLANEENABLE :
1392+ {
1393+ // HACK: Only check for clip pane 0
1394+ SetDirtyValue (g_dirtyStates.sharedConstants , g_sharedConstants.clipPlaneEnabled , (value & 1 ) == 1 );
1395+ }
13891396 }
13901397}
13911398
@@ -1420,7 +1427,8 @@ static const std::pair<GuestRenderState, PPCFunc*> g_setRenderStateFunctions[] =
14201427 { D3DRS_CCW_STENCILFAIL , HostToGuestFunction<SetRenderState<D3DRS_CCW_STENCILFAIL >> },
14211428 { D3DRS_CCW_STENCILZFAIL , HostToGuestFunction<SetRenderState<D3DRS_CCW_STENCILZFAIL >> },
14221429 { D3DRS_CCW_STENCILPASS , HostToGuestFunction<SetRenderState<D3DRS_CCW_STENCILPASS >> },
1423- { D3DRS_CCW_STENCILFUNC , HostToGuestFunction<SetRenderState<D3DRS_CCW_STENCILFUNC >> }
1430+ { D3DRS_CCW_STENCILFUNC , HostToGuestFunction<SetRenderState<D3DRS_CCW_STENCILFUNC >> },
1431+ { D3DRS_CLIPPLANEENABLE , HostToGuestFunction<SetRenderState<D3DRS_CLIPPLANEENABLE >> }
14241432};
14251433
14261434static std::unique_ptr<RenderShader> g_copyShader;
@@ -5564,6 +5572,17 @@ static void ProcSetPixelShader(const RenderCommand& cmd)
55645572 SetDirtyValue (g_dirtyStates.pipelineState , g_pipelineState.pixelShader , shader);
55655573}
55665574
5575+ static void SetClipPlane (GuestDevice* device, uint32_t index, const be<float >* plane)
5576+ {
5577+ if (index != 0 )
5578+ return ;
5579+
5580+ SetDirtyValue (g_dirtyStates.sharedConstants , g_sharedConstants.clipPlane [0 ], plane[0 ].get ());
5581+ SetDirtyValue (g_dirtyStates.sharedConstants , g_sharedConstants.clipPlane [1 ], plane[1 ].get ());
5582+ SetDirtyValue (g_dirtyStates.sharedConstants , g_sharedConstants.clipPlane [2 ], plane[2 ].get ());
5583+ SetDirtyValue (g_dirtyStates.sharedConstants , g_sharedConstants.clipPlane [3 ], plane[3 ].get ());
5584+ }
5585+
55675586static std::thread g_renderThread ([]
55685587 {
55695588#ifdef _WIN32
@@ -8209,6 +8228,8 @@ GUEST_FUNCTION_HOOK(sub_82546BD8, SetPixelShader);
82098228
82108229GUEST_FUNCTION_HOOK (sub_8253B760, IsSet);
82118230
8231+ GUEST_FUNCTION_HOOK (sub_82543CF0, SetClipPlane); // replaced
8232+
82128233GUEST_FUNCTION_HOOK (sub_82541A78, SetRenderState<D3DRS_ZENABLE >);
82138234GUEST_FUNCTION_HOOK (sub_82541AC0, SetRenderState<D3DRS_ZWRITEENABLE >);
82148235GUEST_FUNCTION_HOOK (sub_82541460, SetRenderState<D3DRS_ALPHATESTENABLE >);
@@ -8239,6 +8260,7 @@ GUEST_FUNCTION_HOOK(sub_82541CC8, SetRenderState<D3DRS_CCW_STENCILFAIL>);
82398260GUEST_FUNCTION_HOOK (sub_82541D08, SetRenderState<D3DRS_CCW_STENCILZFAIL >);
82408261GUEST_FUNCTION_HOOK (sub_82541D48, SetRenderState<D3DRS_CCW_STENCILPASS >);
82418262GUEST_FUNCTION_HOOK (sub_82541C98, SetRenderState<D3DRS_CCW_STENCILFUNC >);
8263+ GUEST_FUNCTION_HOOK (sub_82541E38, SetRenderState<D3DRS_CLIPPLANEENABLE >);
82428264
82438265int GetType (GuestResource* resource) {
82448266 if (resource->type == ResourceType::Texture) return 3 ;
0 commit comments