mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2025-02-23 21:54:37 +01:00
misc: chore: Fix object creation in Metal
This commit is contained in:
parent
e859bd5aa2
commit
d95f724d17
@ -302,7 +302,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
return null;
|
||||
}
|
||||
|
||||
I8ToI16CacheKey key = new I8ToI16CacheKey(_renderer);
|
||||
I8ToI16CacheKey key = new(_renderer);
|
||||
|
||||
if (!_cachedConvertedBuffers.TryGetValue(offset, size, key, out BufferHolder holder))
|
||||
{
|
||||
@ -325,7 +325,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
return null;
|
||||
}
|
||||
|
||||
TopologyConversionCacheKey key = new TopologyConversionCacheKey(_renderer, pattern, indexSize);
|
||||
TopologyConversionCacheKey key = new(_renderer, pattern, indexSize);
|
||||
|
||||
if (!_cachedConvertedBuffers.TryGetValue(offset, size, key, out BufferHolder holder))
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
return BufferHandle.Null;
|
||||
}
|
||||
|
||||
BufferHolder holder = new BufferHolder(_renderer, _pipeline, buffer, size);
|
||||
BufferHolder holder = new(_renderer, _pipeline, buffer, size);
|
||||
|
||||
BufferCount++;
|
||||
|
||||
|
@ -149,7 +149,7 @@ class CommandBufferEncoder
|
||||
{
|
||||
EndCurrentPass();
|
||||
|
||||
using MTLBlitPassDescriptor descriptor = new MTLBlitPassDescriptor();
|
||||
using MTLBlitPassDescriptor descriptor = new();
|
||||
MTLBlitCommandEncoder blitCommandEncoder = _commandBuffer.BlitCommandEncoder(descriptor);
|
||||
|
||||
CurrentEncoder = blitCommandEncoder;
|
||||
|
@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
ref StencilUid frontUid = ref descriptor.FrontFace;
|
||||
|
||||
using MTLStencilDescriptor frontFaceStencil = new MTLStencilDescriptor
|
||||
using MTLStencilDescriptor frontFaceStencil = new()
|
||||
{
|
||||
StencilFailureOperation = frontUid.StencilFailureOperation,
|
||||
DepthFailureOperation = frontUid.DepthFailureOperation,
|
||||
@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
ref StencilUid backUid = ref descriptor.BackFace;
|
||||
|
||||
using MTLStencilDescriptor backFaceStencil = new MTLStencilDescriptor
|
||||
using MTLStencilDescriptor backFaceStencil = new()
|
||||
{
|
||||
StencilFailureOperation = backUid.StencilFailureOperation,
|
||||
DepthFailureOperation = backUid.DepthFailureOperation,
|
||||
@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
WriteMask = backUid.WriteMask
|
||||
};
|
||||
|
||||
MTLDepthStencilDescriptor mtlDescriptor = new MTLDepthStencilDescriptor
|
||||
MTLDepthStencilDescriptor mtlDescriptor = new()
|
||||
{
|
||||
DepthCompareFunction = descriptor.DepthCompareFunction,
|
||||
DepthWriteEnabled = descriptor.DepthWriteEnabled
|
||||
|
@ -165,7 +165,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
// Inherit render target related information without causing a render encoder split.
|
||||
|
||||
RenderTargetCopy oldState = new RenderTargetCopy
|
||||
RenderTargetCopy oldState = new()
|
||||
{
|
||||
Scissors = other.Scissors,
|
||||
RenderTargets = other.RenderTargets,
|
||||
|
@ -125,7 +125,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
public readonly MTLRenderCommandEncoder CreateRenderCommandEncoder()
|
||||
{
|
||||
// Initialise Pass & State
|
||||
using MTLRenderPassDescriptor renderPassDescriptor = new MTLRenderPassDescriptor();
|
||||
using MTLRenderPassDescriptor renderPassDescriptor = new();
|
||||
|
||||
for (int i = 0; i < Constants.MaxColorAttachments; i++)
|
||||
{
|
||||
@ -185,7 +185,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
public readonly MTLComputeCommandEncoder CreateComputeCommandEncoder()
|
||||
{
|
||||
using MTLComputePassDescriptor descriptor = new MTLComputePassDescriptor();
|
||||
using MTLComputePassDescriptor descriptor = new();
|
||||
MTLComputeCommandEncoder computeCommandEncoder = _pipeline.CommandBuffer.ComputeCommandEncoder(descriptor);
|
||||
|
||||
return computeCommandEncoder;
|
||||
|
@ -239,7 +239,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
buffer.Holder.SetDataUnchecked<float>(buffer.Offset, region);
|
||||
_pipeline.SetUniformBuffers([new BufferAssignment(0, buffer.Range)]);
|
||||
|
||||
Rectangle<float> rect = new Rectangle<float>(
|
||||
Rectangle<float> rect = new(
|
||||
MathF.Min(dstRegion.X1, dstRegion.X2),
|
||||
MathF.Min(dstRegion.Y1, dstRegion.Y2),
|
||||
MathF.Abs(dstRegion.X2 - dstRegion.X1),
|
||||
@ -365,7 +365,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
Span<Viewport> viewports = stackalloc Viewport[16];
|
||||
|
||||
Rectangle<float> rect = new Rectangle<float>(
|
||||
Rectangle<float> rect = new(
|
||||
MathF.Min(dstRegion.X1, dstRegion.X2),
|
||||
MathF.Min(dstRegion.Y1, dstRegion.Y2),
|
||||
MathF.Abs(dstRegion.X2 - dstRegion.X1),
|
||||
@ -527,7 +527,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
Span<Viewport> viewports = stackalloc Viewport[16];
|
||||
|
||||
Rectangle<float> rect = new Rectangle<float>(
|
||||
Rectangle<float> rect = new(
|
||||
MathF.Min(dstRegion.X1, dstRegion.X2),
|
||||
MathF.Min(dstRegion.Y1, dstRegion.Y2),
|
||||
MathF.Abs(dstRegion.X2 - dstRegion.X1),
|
||||
|
@ -253,7 +253,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, bool hostReserved)
|
||||
{
|
||||
// https://developer.apple.com/documentation/metal/gpu_counters_and_counter_sample_buffers/creating_a_counter_sample_buffer_to_store_a_gpu_s_counter_data_during_a_pass?language=objc
|
||||
CounterEvent counterEvent = new CounterEvent();
|
||||
CounterEvent counterEvent = new();
|
||||
resultHandler?.Invoke(counterEvent, type == CounterType.SamplesPassed ? (ulong)1 : 0);
|
||||
return counterEvent;
|
||||
}
|
||||
|
@ -149,8 +149,8 @@ namespace Ryujinx.Graphics.Metal
|
||||
public void Present(CAMetalDrawable drawable, Texture src, Extents2D srcRegion, Extents2D dstRegion, bool isLinear)
|
||||
{
|
||||
// TODO: Clean this up
|
||||
TextureCreateInfo textureInfo = new TextureCreateInfo((int)drawable.Texture.Width, (int)drawable.Texture.Height, (int)drawable.Texture.Depth, (int)drawable.Texture.MipmapLevelCount, (int)drawable.Texture.SampleCount, 0, 0, 0, Format.B8G8R8A8Unorm, 0, Target.Texture2D, SwizzleComponent.Red, SwizzleComponent.Green, SwizzleComponent.Blue, SwizzleComponent.Alpha);
|
||||
Texture dst = new Texture(_device, _renderer, this, textureInfo, drawable.Texture, 0, 0);
|
||||
TextureCreateInfo textureInfo = new((int)drawable.Texture.Width, (int)drawable.Texture.Height, (int)drawable.Texture.Depth, (int)drawable.Texture.MipmapLevelCount, (int)drawable.Texture.SampleCount, 0, 0, 0, Format.B8G8R8A8Unorm, 0, Target.Texture2D, SwizzleComponent.Red, SwizzleComponent.Green, SwizzleComponent.Blue, SwizzleComponent.Alpha);
|
||||
Texture dst = new(_device, _renderer, this, textureInfo, drawable.Texture, 0, 0);
|
||||
|
||||
_renderer.HelperShader.BlitColor(Cbs, src, dst, srcRegion, dstRegion, isLinear, true);
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
ShaderSource shader = _shaders[i];
|
||||
|
||||
using MTLCompileOptions compileOptions = new MTLCompileOptions
|
||||
using MTLCompileOptions compileOptions = new()
|
||||
{
|
||||
PreserveInvariance = true,
|
||||
LanguageVersion = MTLLanguageVersion.Version31,
|
||||
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
MTLSamplerBorderColor borderColor = GetConstrainedBorderColor(info.BorderColor, out _);
|
||||
|
||||
using MTLSamplerDescriptor descriptor = new MTLSamplerDescriptor
|
||||
using MTLSamplerDescriptor descriptor = new()
|
||||
{
|
||||
BorderColor = borderColor,
|
||||
MinFilter = minFilter,
|
||||
|
@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
private readonly MTLVertexDescriptor BuildVertexDescriptor()
|
||||
{
|
||||
MTLVertexDescriptor vertexDescriptor = new MTLVertexDescriptor();
|
||||
MTLVertexDescriptor vertexDescriptor = new();
|
||||
|
||||
for (int i = 0; i < VertexAttributeDescriptionsCount; i++)
|
||||
{
|
||||
@ -146,7 +146,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
private MTLRenderPipelineDescriptor CreateRenderDescriptor(Program program)
|
||||
{
|
||||
MTLRenderPipelineDescriptor renderPipelineDescriptor = new MTLRenderPipelineDescriptor();
|
||||
MTLRenderPipelineDescriptor renderPipelineDescriptor = new();
|
||||
|
||||
for (int i = 0; i < Constants.MaxColorAttachments; i++)
|
||||
{
|
||||
@ -217,7 +217,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
using MTLRenderPipelineDescriptor descriptor = CreateRenderDescriptor(program);
|
||||
|
||||
NSError error = new NSError(IntPtr.Zero);
|
||||
NSError error = new(IntPtr.Zero);
|
||||
pipelineState = device.NewRenderPipelineState(descriptor, ref error);
|
||||
if (error != IntPtr.Zero)
|
||||
{
|
||||
@ -240,7 +240,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
throw new InvalidOperationException($"Local thread size for compute cannot be 0 in any dimension.");
|
||||
}
|
||||
|
||||
MTLComputePipelineDescriptor descriptor = new MTLComputePipelineDescriptor
|
||||
MTLComputePipelineDescriptor descriptor = new()
|
||||
{
|
||||
ComputeFunction = program.ComputeFunction,
|
||||
MaxTotalThreadsPerThreadgroup = maxThreads,
|
||||
@ -259,7 +259,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
using MTLComputePipelineDescriptor descriptor = CreateComputeDescriptor(program);
|
||||
|
||||
NSError error = new NSError(IntPtr.Zero);
|
||||
NSError error = new(IntPtr.Zero);
|
||||
pipelineState = device.NewComputePipelineState(descriptor, MTLPipelineOption.None, 0, ref error);
|
||||
if (error != IntPtr.Zero)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
MTLPixelFormat pixelFormat = FormatTable.GetFormat(Info.Format);
|
||||
|
||||
MTLTextureDescriptor descriptor = new MTLTextureDescriptor
|
||||
MTLTextureDescriptor descriptor = new()
|
||||
{
|
||||
PixelFormat = pixelFormat,
|
||||
Usage = MTLTextureUsage.Unknown,
|
||||
|
@ -33,8 +33,8 @@ namespace Ryujinx.Graphics.Metal
|
||||
ulong bytesPerRow = (ulong)BitUtils.AlignUp(blockWidth * info.BytesPerPixel, 4);
|
||||
ulong bytesPerImage = bytesPerRow * (ulong)blockHeight;
|
||||
|
||||
MTLOrigin origin = new MTLOrigin { x = (ulong)x, y = (ulong)y, z = is3D ? (ulong)dstLayer : 0 };
|
||||
MTLSize region = new MTLSize { width = (ulong)width, height = (ulong)height, depth = 1 };
|
||||
MTLOrigin origin = new() { x = (ulong)x, y = (ulong)y, z = is3D ? (ulong)dstLayer : 0 };
|
||||
MTLSize region = new() { width = (ulong)width, height = (ulong)height, depth = 1 };
|
||||
|
||||
uint layer = is3D ? 0 : (uint)dstLayer;
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
if (_requestedWidth != 0 && _requestedHeight != 0)
|
||||
{
|
||||
// TODO: This is actually a CGSize, but there is no overload for that, so fill the first two fields of rect with the size.
|
||||
NSRect rect = new NSRect(_requestedWidth, _requestedHeight, 0, 0);
|
||||
NSRect rect = new(_requestedWidth, _requestedHeight, 0, 0);
|
||||
|
||||
ObjectiveC.objc_msgSend(_metalLayer, "setDrawableSize:", rect);
|
||||
|
||||
@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
ResizeIfNeeded();
|
||||
|
||||
CAMetalDrawable drawable = new CAMetalDrawable(ObjectiveC.IntPtr_objc_msgSend(_metalLayer, "nextDrawable"));
|
||||
CAMetalDrawable drawable = new(ObjectiveC.IntPtr_objc_msgSend(_metalLayer, "nextDrawable"));
|
||||
|
||||
_width = (int)drawable.Texture.Width;
|
||||
_height = (int)drawable.Texture.Height;
|
||||
|
Loading…
x
Reference in New Issue
Block a user