mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-11-25 19:45:13 +00:00
Fix error when dual source blend is used (#1610)
* Fix error when dual source blend is used * Ensure framebuffer
This commit is contained in:
parent
e4777717cd
commit
6a51b628f9
2 changed files with 57 additions and 0 deletions
|
@ -13,6 +13,9 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
private readonly TextureView[] _colors;
|
||||
|
||||
private int _colorsCount;
|
||||
private bool _dualSourceBlend;
|
||||
|
||||
public Framebuffer()
|
||||
{
|
||||
Handle = GL.GenFramebuffer();
|
||||
|
@ -97,7 +100,35 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
}
|
||||
}
|
||||
|
||||
public void SetDualSourceBlend(bool enable)
|
||||
{
|
||||
bool oldEnable = _dualSourceBlend;
|
||||
|
||||
_dualSourceBlend = enable;
|
||||
|
||||
// When dual source blend is used,
|
||||
// we can only have one draw buffer.
|
||||
if (enable)
|
||||
{
|
||||
GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
|
||||
}
|
||||
else if (oldEnable)
|
||||
{
|
||||
SetDrawBuffersImpl(_colorsCount);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDrawBuffers(int colorsCount)
|
||||
{
|
||||
if (_colorsCount != colorsCount && !_dualSourceBlend)
|
||||
{
|
||||
SetDrawBuffersImpl(colorsCount);
|
||||
}
|
||||
|
||||
_colorsCount = colorsCount;
|
||||
}
|
||||
|
||||
private void SetDrawBuffersImpl(int colorsCount)
|
||||
{
|
||||
DrawBuffersEnum[] drawBuffers = new DrawBuffersEnum[colorsCount];
|
||||
|
||||
|
|
|
@ -557,6 +557,32 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
(BlendingFactorSrc)blend.AlphaSrcFactor.Convert(),
|
||||
(BlendingFactorDest)blend.AlphaDstFactor.Convert());
|
||||
|
||||
static bool IsDualSource(BlendFactor factor)
|
||||
{
|
||||
switch (factor)
|
||||
{
|
||||
case BlendFactor.Src1Color:
|
||||
case BlendFactor.Src1ColorGl:
|
||||
case BlendFactor.Src1Alpha:
|
||||
case BlendFactor.Src1AlphaGl:
|
||||
case BlendFactor.OneMinusSrc1Color:
|
||||
case BlendFactor.OneMinusSrc1ColorGl:
|
||||
case BlendFactor.OneMinusSrc1Alpha:
|
||||
case BlendFactor.OneMinusSrc1AlphaGl:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
EnsureFramebuffer();
|
||||
|
||||
_framebuffer.SetDualSourceBlend(
|
||||
IsDualSource(blend.ColorSrcFactor) ||
|
||||
IsDualSource(blend.ColorDstFactor) ||
|
||||
IsDualSource(blend.AlphaSrcFactor) ||
|
||||
IsDualSource(blend.AlphaDstFactor));
|
||||
|
||||
if (_blendConstant != blend.BlendConstant)
|
||||
{
|
||||
_blendConstant = blend.BlendConstant;
|
||||
|
|
Loading…
Reference in a new issue