don't hardcode render pipeline attachments
This commit is contained in:
parent
a11247b72d
commit
64005ba9ee
4 changed files with 22 additions and 11 deletions
|
@ -137,7 +137,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
|
|
||||||
var renderCommandEncoder = _commandBuffer.RenderCommandEncoder(descriptor);
|
var renderCommandEncoder = _commandBuffer.RenderCommandEncoder(descriptor);
|
||||||
_renderEncoderState.SetEncoderState(renderCommandEncoder, _vertexDescriptor);
|
_renderEncoderState.SetEncoderState(renderCommandEncoder, descriptor, _vertexDescriptor);
|
||||||
|
|
||||||
RebindBuffers(renderCommandEncoder);
|
RebindBuffers(renderCommandEncoder);
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
_helperShaders.BlitShader.VertexFunction,
|
_helperShaders.BlitShader.VertexFunction,
|
||||||
_helperShaders.BlitShader.FragmentFunction,
|
_helperShaders.BlitShader.FragmentFunction,
|
||||||
_device);
|
_device);
|
||||||
_renderEncoderState.SetEncoderState(renderCommandEncoder, _vertexDescriptor);
|
_renderEncoderState.SetEncoderState(renderCommandEncoder, descriptor, _vertexDescriptor);
|
||||||
|
|
||||||
var sampler = _device.NewSamplerState(new MTLSamplerDescriptor
|
var sampler = _device.NewSamplerState(new MTLSamplerDescriptor
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.Gpu, $"Shader linking failed: \n{StringHelper.String(libraryError.LocalizedDescription)}");
|
Logger.Warning?.Print(LogClass.Gpu, $"Shader linking failed: \n{StringHelper.String(libraryError.LocalizedDescription)}");
|
||||||
_status = ProgramLinkStatus.Failure;
|
_status = ProgramLinkStatus.Failure;
|
||||||
|
//Console.WriteLine($"SHADER {index}: {shader.Code}");
|
||||||
|
//throw new NotImplementedException();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
_device = device;
|
_device = device;
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe readonly void SetEncoderState(MTLRenderCommandEncoder renderCommandEncoder, MTLVertexDescriptor vertexDescriptor)
|
public unsafe readonly void SetEncoderState(MTLRenderCommandEncoder renderCommandEncoder, MTLRenderPassDescriptor descriptor, MTLVertexDescriptor vertexDescriptor)
|
||||||
{
|
{
|
||||||
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor
|
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor
|
||||||
{
|
{
|
||||||
|
@ -53,13 +53,21 @@ namespace Ryujinx.Graphics.Metal
|
||||||
renderPipelineDescriptor.FragmentFunction = _fragmentFunction.Value;
|
renderPipelineDescriptor.FragmentFunction = _fragmentFunction.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var attachment = renderPipelineDescriptor.ColorAttachments.Object(0);
|
const int maxColorAttachments = 8;
|
||||||
|
for (int i = 0; i < maxColorAttachments; i++)
|
||||||
|
{
|
||||||
|
var renderAttachment = descriptor.ColorAttachments.Object((ulong)i);
|
||||||
|
if (renderAttachment.Texture != null)
|
||||||
|
{
|
||||||
|
var attachment = renderPipelineDescriptor.ColorAttachments.Object((ulong)i);
|
||||||
attachment.SetBlendingEnabled(true);
|
attachment.SetBlendingEnabled(true);
|
||||||
attachment.PixelFormat = MTLPixelFormat.BGRA8Unorm;
|
attachment.PixelFormat = renderAttachment.Texture.PixelFormat;
|
||||||
attachment.SourceAlphaBlendFactor = MTLBlendFactor.SourceAlpha;
|
attachment.SourceAlphaBlendFactor = MTLBlendFactor.SourceAlpha;
|
||||||
attachment.DestinationAlphaBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
attachment.DestinationAlphaBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
||||||
attachment.SourceRGBBlendFactor = MTLBlendFactor.SourceAlpha;
|
attachment.SourceRGBBlendFactor = MTLBlendFactor.SourceAlpha;
|
||||||
attachment.DestinationRGBBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
attachment.DestinationRGBBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var error = new NSError(IntPtr.Zero);
|
var error = new NSError(IntPtr.Zero);
|
||||||
var pipelineState = _device.NewRenderPipelineState(renderPipelineDescriptor, ref error);
|
var pipelineState = _device.NewRenderPipelineState(renderPipelineDescriptor, ref error);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using SharpMetal.Metal;
|
using SharpMetal.Metal;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
|
@ -23,7 +24,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
LodMinClamp = info.MinLod,
|
LodMinClamp = info.MinLod,
|
||||||
LodMaxClamp = info.MaxLod,
|
LodMaxClamp = info.MaxLod,
|
||||||
LodAverage = false,
|
LodAverage = false,
|
||||||
MaxAnisotropy = (uint)info.MaxAnisotropy,
|
MaxAnisotropy = Math.Max((uint)info.MaxAnisotropy, 1),
|
||||||
SAddressMode = info.AddressU.Convert(),
|
SAddressMode = info.AddressU.Convert(),
|
||||||
TAddressMode = info.AddressV.Convert(),
|
TAddressMode = info.AddressV.Convert(),
|
||||||
RAddressMode = info.AddressP.Convert()
|
RAddressMode = info.AddressP.Convert()
|
||||||
|
|
Loading…
Reference in a new issue