RenderTargetColorMasks
This commit is contained in:
parent
dc01de61cd
commit
1b86360a61
3 changed files with 33 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using SharpMetal.Metal;
|
using SharpMetal.Metal;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
|
@ -64,6 +65,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
// Changes to attachments take recreation!
|
// Changes to attachments take recreation!
|
||||||
public Texture DepthStencil = default;
|
public Texture DepthStencil = default;
|
||||||
public Texture[] RenderTargets = new Texture[Constants.MaxColorAttachments];
|
public Texture[] RenderTargets = new Texture[Constants.MaxColorAttachments];
|
||||||
|
|
||||||
|
public MTLColorWriteMask[] RenderTargetMasks = Enumerable.Repeat(MTLColorWriteMask.All, Constants.MaxColorAttachments).ToArray();
|
||||||
public BlendDescriptor?[] BlendDescriptors = new BlendDescriptor?[Constants.MaxColorAttachments];
|
public BlendDescriptor?[] BlendDescriptors = new BlendDescriptor?[Constants.MaxColorAttachments];
|
||||||
public ColorF BlendColor = new();
|
public ColorF BlendColor = new();
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
pipelineAttachment.DestinationAlphaBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
pipelineAttachment.DestinationAlphaBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
||||||
pipelineAttachment.SourceRGBBlendFactor = MTLBlendFactor.SourceAlpha;
|
pipelineAttachment.SourceRGBBlendFactor = MTLBlendFactor.SourceAlpha;
|
||||||
pipelineAttachment.DestinationRGBBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
pipelineAttachment.DestinationRGBBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
||||||
|
pipelineAttachment.WriteMask = _currentState.RenderTargetMasks[i];
|
||||||
|
|
||||||
if (_currentState.BlendDescriptors[i] != null)
|
if (_currentState.BlendDescriptors[i] != null)
|
||||||
{
|
{
|
||||||
|
@ -349,6 +350,34 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateRenderTargetColorMasks(ReadOnlySpan<uint> componentMask)
|
||||||
|
{
|
||||||
|
_currentState.RenderTargetMasks = new MTLColorWriteMask[Constants.MaxColorAttachments];
|
||||||
|
|
||||||
|
for (int i = 0; i < componentMask.Length; i++)
|
||||||
|
{
|
||||||
|
bool red = (componentMask[i] & (0x1 << 0)) != 0;
|
||||||
|
bool green = (componentMask[i] & (0x1 << 1)) != 0;
|
||||||
|
bool blue = (componentMask[i] & (0x1 << 2)) != 0;
|
||||||
|
bool alpha = (componentMask[i] & (0x1 << 3)) != 0;
|
||||||
|
|
||||||
|
var mask = MTLColorWriteMask.None;
|
||||||
|
|
||||||
|
mask |= red ? MTLColorWriteMask.Red : 0;
|
||||||
|
mask |= green ? MTLColorWriteMask.Green : 0;
|
||||||
|
mask |= blue ? MTLColorWriteMask.Blue : 0;
|
||||||
|
mask |= alpha ? MTLColorWriteMask.Alpha : 0;
|
||||||
|
|
||||||
|
_currentState.RenderTargetMasks[i] = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requires recreating pipeline
|
||||||
|
if (_pipeline.CurrentEncoderType == EncoderType.Render)
|
||||||
|
{
|
||||||
|
_pipeline.EndCurrentPass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
|
public void UpdateVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
|
||||||
{
|
{
|
||||||
_currentState.VertexAttribs = vertexAttribs.ToArray();
|
_currentState.VertexAttribs = vertexAttribs.ToArray();
|
||||||
|
|
|
@ -461,7 +461,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask)
|
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
_encoderStateManager.UpdateRenderTargetColorMasks(componentMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRenderTargets(ITexture[] colors, ITexture depthStencil)
|
public void SetRenderTargets(ITexture[] colors, ITexture depthStencil)
|
||||||
|
|
Loading…
Reference in a new issue