1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-24 22:56:02 +00:00

Barry is here mashallah

This commit is contained in:
Isaac Marovitz 2023-08-02 20:32:59 -04:00 committed by Isaac Marovitz
parent aaa140e510
commit 07be20c369
3 changed files with 13 additions and 7 deletions

View file

@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Metal
// TODO: Recreate descriptor and encoder state as needed // TODO: Recreate descriptor and encoder state as needed
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor(); var renderPipelineDescriptor = new MTLRenderPipelineDescriptor();
renderPipelineDescriptor.VertexFunction = vertexFunction; renderPipelineDescriptor.VertexFunction = vertexFunction;
// renderPipelineDescriptor.FragmentFunction = fragmentFunction; renderPipelineDescriptor.FragmentFunction = fragmentFunction;
// TODO: This should not be hardcoded, but a bug in SharpMetal prevents me from doing this correctly // TODO: This should not be hardcoded, but a bug in SharpMetal prevents me from doing this correctly
renderPipelineDescriptor.ColorAttachments.Object(0).PixelFormat = MTLPixelFormat.BGRA8Unorm; renderPipelineDescriptor.ColorAttachments.Object(0).PixelFormat = MTLPixelFormat.BGRA8Unorm;
@ -115,7 +115,7 @@ namespace Ryujinx.Graphics.Metal
return computeCommandEncoder; return computeCommandEncoder;
} }
public void Present(CAMetalDrawable drawable) public void Present(CAMetalDrawable drawable, Texture texture)
{ {
EndCurrentPass(); EndCurrentPass();
@ -128,8 +128,7 @@ namespace Ryujinx.Graphics.Metal
Logger.Warning?.Print(LogClass.Gpu, "Began present"); Logger.Warning?.Print(LogClass.Gpu, "Began present");
_renderEncoderState.SetEncoderState(renderCommandEncoder); _renderEncoderState.SetEncoderState(renderCommandEncoder);
// Barry goes here renderCommandEncoder.SetFragmentTexture(texture.MTLTexture, 0);
// renderCommandEncoder.SetFragmentTexture(_renderTarget, 0);
renderCommandEncoder.DrawPrimitives(MTLPrimitiveType.Triangle, 0, 6); renderCommandEncoder.DrawPrimitives(MTLPrimitiveType.Triangle, 0, 6);
renderCommandEncoder.EndEncoding(); renderCommandEncoder.EndEncoding();

View file

@ -22,6 +22,7 @@ vertex CopyVertexOut vertexMain(unsigned short vid [[vertex_id]]) {
CopyVertexOut out; CopyVertexOut out;
out.position = float4(position, 0, 1); out.position = float4(position, 0, 1);
out.position.y = -out.position.y;
out.uv = position * 0.5f + 0.5f; out.uv = position * 0.5f + 0.5f;
return out; return out;

View file

@ -1,5 +1,8 @@
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using SharpMetal.Metal;
using SharpMetal.ObjectiveCCore;
using SharpMetal.QuartzCore;
using System; using System;
using System.Runtime.Versioning; using System.Runtime.Versioning;
@ -9,17 +12,20 @@ namespace Ryujinx.Graphics.Metal
public class Window : IWindow, IDisposable public class Window : IWindow, IDisposable
{ {
private readonly MetalRenderer _renderer; private readonly MetalRenderer _renderer;
private readonly CAMetalLayer _metalLayer;
public Window(MetalRenderer renderer) public Window(MetalRenderer renderer, CAMetalLayer metalLayer)
{ {
_renderer = renderer; _renderer = renderer;
_metalLayer = metalLayer;
} }
public void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback) public void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback)
{ {
if (_renderer.Pipeline is Pipeline pipeline) if (_renderer.Pipeline is Pipeline pipeline && texture is Texture tex)
{ {
pipeline.Present(); var drawable = new CAMetalDrawable(ObjectiveC.IntPtr_objc_msgSend(_metalLayer, "nextDrawable"));
pipeline.Present(drawable, tex);
} }
} }