mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-20 13:52:00 +00:00
Fix present
This commit is contained in:
parent
fbe275204b
commit
45b533b23b
4 changed files with 43 additions and 34 deletions
|
@ -8,6 +8,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public struct EncoderState
|
public struct EncoderState
|
||||||
{
|
{
|
||||||
|
public const int MaxColorAttachments = 8;
|
||||||
|
|
||||||
public MTLFunction? VertexFunction = null;
|
public MTLFunction? VertexFunction = null;
|
||||||
public MTLFunction? FragmentFunction = null;
|
public MTLFunction? FragmentFunction = null;
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
// Changes to attachments take recreation!
|
// Changes to attachments take recreation!
|
||||||
public MTLTexture DepthStencil = default;
|
public MTLTexture DepthStencil = default;
|
||||||
public MTLTexture[] RenderTargets = [];
|
public MTLTexture[] RenderTargets = new MTLTexture[MaxColorAttachments];
|
||||||
public MTLVertexDescriptor VertexDescriptor = new();
|
public MTLVertexDescriptor VertexDescriptor = new();
|
||||||
|
|
||||||
public EncoderState() { }
|
public EncoderState() { }
|
||||||
|
|
|
@ -48,8 +48,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
var renderPassDescriptor = new MTLRenderPassDescriptor();
|
var renderPassDescriptor = new MTLRenderPassDescriptor();
|
||||||
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor();
|
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor();
|
||||||
|
|
||||||
const int MaxColorAttachments = 8;
|
for (int i = 0; i < EncoderState.MaxColorAttachments; i++)
|
||||||
for (int i = 0; i < MaxColorAttachments; i++)
|
|
||||||
{
|
{
|
||||||
if (_currentState.RenderTargets[i] != IntPtr.Zero)
|
if (_currentState.RenderTargets[i] != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
|
@ -70,6 +69,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
var depthAttachment = renderPassDescriptor.DepthAttachment;
|
var depthAttachment = renderPassDescriptor.DepthAttachment;
|
||||||
var stencilAttachment = renderPassDescriptor.StencilAttachment;
|
var stencilAttachment = renderPassDescriptor.StencilAttachment;
|
||||||
|
|
||||||
|
if (_currentState.DepthStencil != IntPtr.Zero)
|
||||||
|
{
|
||||||
switch (_currentState.DepthStencil.PixelFormat)
|
switch (_currentState.DepthStencil.PixelFormat)
|
||||||
{
|
{
|
||||||
// Depth Only Attachment
|
// Depth Only Attachment
|
||||||
|
@ -105,6 +106,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
Logger.Error?.PrintMsg(LogClass.Gpu, $"Unsupported Depth/Stencil Format: {_currentState.DepthStencil.PixelFormat}!");
|
Logger.Error?.PrintMsg(LogClass.Gpu, $"Unsupported Depth/Stencil Format: {_currentState.DepthStencil.PixelFormat}!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderPipelineDescriptor.VertexDescriptor = _currentState.VertexDescriptor;
|
renderPipelineDescriptor.VertexDescriptor = _currentState.VertexDescriptor;
|
||||||
|
|
||||||
|
@ -187,7 +189,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void UpdateRenderTargets(ITexture[] colors, ITexture depthStencil)
|
public void UpdateRenderTargets(ITexture[] colors, ITexture depthStencil)
|
||||||
{
|
{
|
||||||
_currentState.RenderTargets = new MTLTexture[colors.Length];
|
_currentState.RenderTargets = new MTLTexture[EncoderState.MaxColorAttachments];
|
||||||
|
|
||||||
for (int i = 0; i < colors.Length; i++)
|
for (int i = 0; i < colors.Length; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
var layer = _getMetalLayer();
|
var layer = _getMetalLayer();
|
||||||
layer.Device = _device;
|
layer.Device = _device;
|
||||||
|
layer.FramebufferOnly = false;
|
||||||
|
|
||||||
_window = new Window(this, layer);
|
_window = new Window(this, layer);
|
||||||
_pipeline = new Pipeline(_device, _queue);
|
_pipeline = new Pipeline(_device, _queue);
|
||||||
|
|
|
@ -158,7 +158,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
_encoderStateManager.SwapStates();
|
_encoderStateManager.SwapStates();
|
||||||
|
|
||||||
// _helperShader.BlitColor(tex, drawable.Texture);
|
// TODO: Clean this up
|
||||||
|
var 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);
|
||||||
|
var dest = new Texture(_device, this, textureInfo, drawable.Texture, 0, 0);
|
||||||
|
|
||||||
|
_helperShader.BlitColor(tex, dest);
|
||||||
|
|
||||||
_commandBuffer.PresentDrawable(drawable);
|
_commandBuffer.PresentDrawable(drawable);
|
||||||
_commandBuffer.Commit();
|
_commandBuffer.Commit();
|
||||||
|
|
Loading…
Reference in a new issue