1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-21 03:32:13 +00:00
This commit is contained in:
Isaac Marovitz 2024-05-19 11:05:50 -04:00 committed by Isaac Marovitz
parent 7983bc062b
commit 684e025d61
2 changed files with 95 additions and 91 deletions

View file

@ -16,6 +16,12 @@ namespace Ryujinx.Graphics.Metal
Pipeline = true; Pipeline = true;
DepthStencil = true; DepthStencil = true;
} }
public void Clear()
{
Pipeline = false;
DepthStencil = false;
}
} }
[SupportedOSPlatform("macos")] [SupportedOSPlatform("macos")]

View file

@ -43,9 +43,7 @@ namespace Ryujinx.Graphics.Metal
public MTLRenderCommandEncoder CreateRenderCommandEncoder() public MTLRenderCommandEncoder CreateRenderCommandEncoder()
{ {
// Initialise Pass & State // Initialise Pass & State
var renderPassDescriptor = new MTLRenderPassDescriptor(); var renderPassDescriptor = new MTLRenderPassDescriptor();
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor();
for (int i = 0; i < EncoderState.MaxColorAttachments; i++) for (int i = 0; i < EncoderState.MaxColorAttachments; i++)
{ {
@ -95,7 +93,6 @@ namespace Ryujinx.Graphics.Metal
} }
// Initialise Encoder // Initialise Encoder
var renderCommandEncoder = _pipeline.CommandBuffer.RenderCommandEncoder(renderPassDescriptor); var renderCommandEncoder = _pipeline.CommandBuffer.RenderCommandEncoder(renderPassDescriptor);
// Mark all state as dirty to ensure it is set on the encoder // Mark all state as dirty to ensure it is set on the encoder
@ -117,16 +114,21 @@ namespace Ryujinx.Graphics.Metal
} }
public void RebindState(MTLRenderCommandEncoder renderCommandEncoder) public void RebindState(MTLRenderCommandEncoder renderCommandEncoder)
{
if (_currentState.Dirty.Pipeline)
{ {
SetPipelineState(renderCommandEncoder); SetPipelineState(renderCommandEncoder);
SetDepthStencilState(renderCommandEncoder); }
_currentState.Dirty = new(); if (_currentState.Dirty.DepthStencil)
{
SetDepthStencilState(renderCommandEncoder);
}
_currentState.Dirty.Clear();
} }
private void SetPipelineState(MTLRenderCommandEncoder renderCommandEncoder) { private void SetPipelineState(MTLRenderCommandEncoder renderCommandEncoder) {
if (_currentState.Dirty.Pipeline)
{
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor(); var renderPipelineDescriptor = new MTLRenderPipelineDescriptor();
for (int i = 0; i < EncoderState.MaxColorAttachments; i++) for (int i = 0; i < EncoderState.MaxColorAttachments; i++)
@ -211,7 +213,6 @@ namespace Ryujinx.Graphics.Metal
_currentState.BlendColor.Blue, _currentState.BlendColor.Blue,
_currentState.BlendColor.Alpha); _currentState.BlendColor.Alpha);
} }
}
public void UpdateIndexBuffer(BufferRange buffer, IndexType type) public void UpdateIndexBuffer(BufferRange buffer, IndexType type)
{ {
@ -550,15 +551,12 @@ namespace Ryujinx.Graphics.Metal
} }
private void SetDepthStencilState(MTLRenderCommandEncoder renderCommandEncoder) private void SetDepthStencilState(MTLRenderCommandEncoder renderCommandEncoder)
{
if (_currentState.Dirty.DepthStencil)
{ {
if (_currentState.DepthStencilState != null) if (_currentState.DepthStencilState != null)
{ {
renderCommandEncoder.SetDepthStencilState(_currentState.DepthStencilState.Value); renderCommandEncoder.SetDepthStencilState(_currentState.DepthStencilState.Value);
} }
} }
}
private void SetDepthClamp(MTLRenderCommandEncoder renderCommandEncoder) private void SetDepthClamp(MTLRenderCommandEncoder renderCommandEncoder)
{ {