clip mode

This commit is contained in:
Samuliak 2024-08-27 14:39:52 +02:00
parent 3439b3259e
commit b7a1adec91
2 changed files with 11 additions and 4 deletions

View File

@ -947,10 +947,6 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
uint32 cullBack = polygonControlReg.get_CULL_BACK(); uint32 cullBack = polygonControlReg.get_CULL_BACK();
uint32 polyOffsetFrontEnable = polygonControlReg.get_OFFSET_FRONT_ENABLED(); uint32 polyOffsetFrontEnable = polygonControlReg.get_OFFSET_FRONT_ENABLED();
// TODO
//cemu_assert_debug(LatteGPUState.contextNew.PA_CL_CLIP_CNTL.get_ZCLIP_NEAR_DISABLE() == LatteGPUState.contextNew.PA_CL_CLIP_CNTL.get_ZCLIP_FAR_DISABLE()); // near or far clipping can be disabled individually
//bool zClipEnable = LatteGPUState.contextNew.PA_CL_CLIP_CNTL.get_ZCLIP_FAR_DISABLE() == false;
if (polyOffsetFrontEnable) if (polyOffsetFrontEnable)
{ {
uint32 frontScaleU32 = LatteGPUState.contextNew.PA_SU_POLY_OFFSET_FRONT_SCALE.getRawValue(); uint32 frontScaleU32 = LatteGPUState.contextNew.PA_SU_POLY_OFFSET_FRONT_SCALE.getRawValue();
@ -984,6 +980,16 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
} }
} }
// Depth clip mode
cemu_assert_debug(LatteGPUState.contextNew.PA_CL_CLIP_CNTL.get_ZCLIP_NEAR_DISABLE() == LatteGPUState.contextNew.PA_CL_CLIP_CNTL.get_ZCLIP_FAR_DISABLE()); // near or far clipping can be disabled individually
bool zClipEnable = LatteGPUState.contextNew.PA_CL_CLIP_CNTL.get_ZCLIP_FAR_DISABLE() == false;
if (zClipEnable != encoderState.m_depthClipEnable)
{
renderCommandEncoder->setDepthClipMode(zClipEnable ? MTL::DepthClipModeClip : MTL::DepthClipModeClamp);
encoderState.m_depthClipEnable = zClipEnable;
}
// todo - how does culling behave with rects? // todo - how does culling behave with rects?
// right now we just assume that their winding is always CW // right now we just assume that their winding is always CW
if (isPrimitiveRect) if (isPrimitiveRect)

View File

@ -98,6 +98,7 @@ struct MetalEncoderState
uint32 m_depthBias = 0; uint32 m_depthBias = 0;
uint32 m_depthSlope = 0; uint32 m_depthSlope = 0;
uint32 m_depthClamp = 0; uint32 m_depthClamp = 0;
bool m_depthClipEnable = true;
struct { struct {
MTL::Buffer* m_buffer; MTL::Buffer* m_buffer;
size_t m_offset; size_t m_offset;