Clamp ScissorRect

This commit is contained in:
Isaac Marovitz 2024-05-16 21:06:04 -04:00
parent 271d185861
commit 369476f775
No known key found for this signature in database
GPG Key ID: 97250B2B09A132E1
2 changed files with 5 additions and 5 deletions

View File

@ -539,7 +539,7 @@ namespace Ryujinx.Graphics.Metal
public unsafe void SetScissors(ReadOnlySpan<Rectangle<int>> regions) public unsafe void SetScissors(ReadOnlySpan<Rectangle<int>> regions)
{ {
int maxScissors = Math.Min(regions.Length, _renderEncoderState.ViewportCount); int maxScissors = Math.Min(regions.Length, _renderEncoderState.Viewports.Length);
if (maxScissors == 0) if (maxScissors == 0)
{ {
@ -554,8 +554,8 @@ namespace Ryujinx.Graphics.Metal
mtlScissorRects[i] = new MTLScissorRect mtlScissorRects[i] = new MTLScissorRect
{ {
height = (ulong)region.Height, height = Math.Clamp((ulong)region.Height, 0, (ulong)_renderEncoderState.Viewports[i].height),
width = (ulong)region.Width, width = Math.Clamp((ulong)region.Width, 0, (ulong)_renderEncoderState.Viewports[i].width),
x = (ulong)region.X, x = (ulong)region.X,
y = (ulong)region.Y y = (ulong)region.Y
}; };

View File

@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Metal
private MTLViewport[] _viewports = []; private MTLViewport[] _viewports = [];
private MTLScissorRect[] _scissors = []; private MTLScissorRect[] _scissors = [];
public readonly int ViewportCount => _viewports.Length; public readonly MTLViewport[] Viewports => _viewports;
public RenderEncoderState(MTLFunction vertexFunction, MTLFunction fragmentFunction, MTLDevice device) public RenderEncoderState(MTLFunction vertexFunction, MTLFunction fragmentFunction, MTLDevice device)
{ {
@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Metal
_device = device; _device = device;
} }
public unsafe readonly void SetEncoderState(MTLRenderCommandEncoder renderCommandEncoder, MTLRenderPassDescriptor descriptor, MTLVertexDescriptor vertexDescriptor) public unsafe void SetEncoderState(MTLRenderCommandEncoder renderCommandEncoder, MTLRenderPassDescriptor descriptor, MTLVertexDescriptor vertexDescriptor)
{ {
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor var renderPipelineDescriptor = new MTLRenderPipelineDescriptor
{ {