mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-23 22:46:01 +00:00
Fix invalid depth stencil state when no depth stencil is present
Partially fixes Sonic Frontiers and Castlevania Dominus Collection
This commit is contained in:
parent
6b2bc16dc3
commit
ce23bff285
1 changed files with 12 additions and 2 deletions
|
@ -21,6 +21,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
private readonly BufferManager _bufferManager;
|
private readonly BufferManager _bufferManager;
|
||||||
|
|
||||||
private readonly DepthStencilCache _depthStencilCache;
|
private readonly DepthStencilCache _depthStencilCache;
|
||||||
|
private readonly MTLDepthStencilState _defaultState;
|
||||||
|
|
||||||
private readonly EncoderState _mainState = new();
|
private readonly EncoderState _mainState = new();
|
||||||
private EncoderState _currentState;
|
private EncoderState _currentState;
|
||||||
|
@ -44,6 +45,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
_depthStencilCache = new(device);
|
_depthStencilCache = new(device);
|
||||||
_currentState = _mainState;
|
_currentState = _mainState;
|
||||||
|
|
||||||
|
_defaultState = _depthStencilCache.GetOrCreate(_currentState.DepthStencilUid);
|
||||||
|
|
||||||
// Zero buffer
|
// Zero buffer
|
||||||
byte[] zeros = new byte[ZeroBufferSize];
|
byte[] zeros = new byte[ZeroBufferSize];
|
||||||
fixed (byte* ptr = zeros)
|
fixed (byte* ptr = zeros)
|
||||||
|
@ -952,9 +955,16 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
private readonly void SetDepthStencilState(MTLRenderCommandEncoder renderCommandEncoder)
|
private readonly void SetDepthStencilState(MTLRenderCommandEncoder renderCommandEncoder)
|
||||||
{
|
{
|
||||||
MTLDepthStencilState state = _depthStencilCache.GetOrCreate(_currentState.DepthStencilUid);
|
if (DepthStencil != null)
|
||||||
|
{
|
||||||
|
MTLDepthStencilState state = _depthStencilCache.GetOrCreate(_currentState.DepthStencilUid);
|
||||||
|
|
||||||
renderCommandEncoder.SetDepthStencilState(state);
|
renderCommandEncoder.SetDepthStencilState(state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
renderCommandEncoder.SetDepthStencilState(_defaultState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void SetDepthClamp(MTLRenderCommandEncoder renderCommandEncoder)
|
private readonly void SetDepthClamp(MTLRenderCommandEncoder renderCommandEncoder)
|
||||||
|
|
Loading…
Reference in a new issue