mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-23 08:05:47 +00:00
Implement SetBlendState
This commit is contained in:
parent
1db8decd12
commit
f98d9bae24
3 changed files with 32 additions and 2 deletions
|
@ -47,6 +47,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
public MTLTexture DepthStencil = default;
|
public MTLTexture DepthStencil = default;
|
||||||
public MTLTexture[] RenderTargets = new MTLTexture[MaxColorAttachments];
|
public MTLTexture[] RenderTargets = new MTLTexture[MaxColorAttachments];
|
||||||
public MTLVertexDescriptor VertexDescriptor = new();
|
public MTLVertexDescriptor VertexDescriptor = new();
|
||||||
|
public Dictionary<int, BlendDescriptor> BlendDescriptors = new();
|
||||||
|
public ColorF BlendColor = new();
|
||||||
|
|
||||||
public EncoderState() { }
|
public EncoderState() { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,12 +56,22 @@ namespace Ryujinx.Graphics.Metal
|
||||||
passAttachment.LoadAction = MTLLoadAction.Load;
|
passAttachment.LoadAction = MTLLoadAction.Load;
|
||||||
|
|
||||||
var pipelineAttachment = renderPipelineDescriptor.ColorAttachments.Object((ulong)i);
|
var pipelineAttachment = renderPipelineDescriptor.ColorAttachments.Object((ulong)i);
|
||||||
pipelineAttachment.SetBlendingEnabled(true);
|
|
||||||
pipelineAttachment.PixelFormat = _currentState.RenderTargets[i].PixelFormat;
|
pipelineAttachment.PixelFormat = _currentState.RenderTargets[i].PixelFormat;
|
||||||
pipelineAttachment.SourceAlphaBlendFactor = MTLBlendFactor.SourceAlpha;
|
pipelineAttachment.SourceAlphaBlendFactor = MTLBlendFactor.SourceAlpha;
|
||||||
pipelineAttachment.DestinationAlphaBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
pipelineAttachment.DestinationAlphaBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
||||||
pipelineAttachment.SourceRGBBlendFactor = MTLBlendFactor.SourceAlpha;
|
pipelineAttachment.SourceRGBBlendFactor = MTLBlendFactor.SourceAlpha;
|
||||||
pipelineAttachment.DestinationRGBBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
pipelineAttachment.DestinationRGBBlendFactor = MTLBlendFactor.OneMinusSourceAlpha;
|
||||||
|
|
||||||
|
if (_currentState.BlendDescriptors.TryGetValue(i, out BlendDescriptor blendDescriptor))
|
||||||
|
{
|
||||||
|
pipelineAttachment.SetBlendingEnabled(blendDescriptor.Enable);
|
||||||
|
pipelineAttachment.AlphaBlendOperation = blendDescriptor.AlphaOp.Convert();
|
||||||
|
pipelineAttachment.RgbBlendOperation = blendDescriptor.ColorOp.Convert();
|
||||||
|
pipelineAttachment.SourceAlphaBlendFactor = blendDescriptor.AlphaSrcFactor.Convert();
|
||||||
|
pipelineAttachment.DestinationAlphaBlendFactor = blendDescriptor.AlphaDstFactor.Convert();
|
||||||
|
pipelineAttachment.SourceRGBBlendFactor = blendDescriptor.ColorSrcFactor.Convert();
|
||||||
|
pipelineAttachment.DestinationRGBBlendFactor = blendDescriptor.ColorDstFactor.Convert();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +146,12 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
renderCommandEncoder.SetRenderPipelineState(pipelineState);
|
renderCommandEncoder.SetRenderPipelineState(pipelineState);
|
||||||
|
|
||||||
|
renderCommandEncoder.SetBlendColor(
|
||||||
|
_currentState.BlendColor.Red,
|
||||||
|
_currentState.BlendColor.Green,
|
||||||
|
_currentState.BlendColor.Blue,
|
||||||
|
_currentState.BlendColor.Alpha);
|
||||||
|
|
||||||
SetDepthStencilState(renderCommandEncoder, _currentState.DepthStencilState);
|
SetDepthStencilState(renderCommandEncoder, _currentState.DepthStencilState);
|
||||||
SetScissors(renderCommandEncoder, _currentState.Scissors);
|
SetScissors(renderCommandEncoder, _currentState.Scissors);
|
||||||
SetViewports(renderCommandEncoder, _currentState.Viewports);
|
SetViewports(renderCommandEncoder, _currentState.Viewports);
|
||||||
|
@ -236,6 +252,18 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateBlendDescriptors(int index, BlendDescriptor blend)
|
||||||
|
{
|
||||||
|
_currentState.BlendDescriptors.Add(index, blend);
|
||||||
|
_currentState.BlendColor = blend.BlendConstant;
|
||||||
|
|
||||||
|
// Requires recreating pipeline
|
||||||
|
if (_pipeline.CurrentEncoderType == EncoderType.Render)
|
||||||
|
{
|
||||||
|
_pipeline.EndCurrentPass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Inlineable
|
// Inlineable
|
||||||
public void UpdateStencilState(StencilTestDescriptor stencilTest)
|
public void UpdateStencilState(StencilTestDescriptor stencilTest)
|
||||||
{
|
{
|
||||||
|
|
|
@ -311,7 +311,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void SetBlendState(int index, BlendDescriptor blend)
|
public void SetBlendState(int index, BlendDescriptor blend)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
_encoderStateManager.UpdateBlendDescriptors(index, blend);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
||||||
|
|
Loading…
Reference in a new issue