aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.OpenGL/Pipeline.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-07-26 00:03:40 -0300
committerGitHub <noreply@github.com>2020-07-26 00:03:40 -0300
commit8dbcae1ff88927dc0734d5f0e24fbf8781d68590 (patch)
treed884544af874f385a7a374c8889683db2e4c1ccc /Ryujinx.Graphics.OpenGL/Pipeline.cs
parent2678bf0010166e683364102221b52caebea8747e (diff)
Implement BGRA texture support (#1418)
* Implement BGRA texture support * Missing AppendLine * Remove empty lines * Address PR feedback
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Pipeline.cs')
-rw-r--r--Ryujinx.Graphics.OpenGL/Pipeline.cs71
1 files changed, 43 insertions, 28 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs
index 2016d852..09ba9be0 100644
--- a/Ryujinx.Graphics.OpenGL/Pipeline.cs
+++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs
@@ -31,6 +31,7 @@ namespace Ryujinx.Graphics.OpenGL
private int _boundDrawFramebuffer;
private int _boundReadFramebuffer;
+ private int[] _fpIsBgra = new int[8];
private float[] _fpRenderScale = new float[33];
private float[] _cpRenderScale = new float[32];
@@ -722,12 +723,12 @@ namespace Ryujinx.Graphics.OpenGL
GL.Disable(EnableCap.ProgramPointSize);
}
- GL.PointParameter(origin == Origin.LowerLeft
- ? PointSpriteCoordOriginParameter.LowerLeft
+ GL.PointParameter(origin == Origin.LowerLeft
+ ? PointSpriteCoordOriginParameter.LowerLeft
: PointSpriteCoordOriginParameter.UpperLeft);
// Games seem to set point size to 0 which generates a GL_INVALID_VALUE
- // From the spec, GL_INVALID_VALUE is generated if size is less than or equal to 0.
+ // From the spec, GL_INVALID_VALUE is generated if size is less than or equal to 0.
GL.PointSize(Math.Max(float.Epsilon, size));
}
@@ -765,6 +766,7 @@ namespace Ryujinx.Graphics.OpenGL
_program.Bind();
}
+ UpdateFpIsBgra();
SetRenderTargetScale(_fpRenderScale[0]);
}
@@ -814,12 +816,15 @@ namespace Ryujinx.Graphics.OpenGL
TextureView color = (TextureView)colors[index];
_framebuffer.AttachColor(index, color);
+
+ _fpIsBgra[index] = color != null && color.Format.IsBgra8() ? 1 : 0;
}
+ UpdateFpIsBgra();
+
TextureView depthStencilView = (TextureView)depthStencil;
_framebuffer.AttachDepthStencil(depthStencilView);
-
_framebuffer.SetDrawBuffers(colors.Length);
_hasDepthBuffer = depthStencil != null && depthStencilView.Format != Format.S8Uint;
@@ -938,7 +943,9 @@ namespace Ryujinx.Graphics.OpenGL
if (activeTarget != null && activeTarget.Width / (float)texture.Width == activeTarget.Height / (float)texture.Height)
{
- // If the texture's size is a multiple of the sampler size, enable interpolation using gl_FragCoord. (helps "invent" new integer values between scaled pixels)
+ // If the texture's size is a multiple of the sampler size,
+ // enable interpolation using gl_FragCoord.
+ // (helps "invent" new integer values between scaled pixels)
interpolate = true;
}
}
@@ -1112,6 +1119,14 @@ namespace Ryujinx.Graphics.OpenGL
return (_boundDrawFramebuffer, _boundReadFramebuffer);
}
+ private void UpdateFpIsBgra()
+ {
+ if (_program != null)
+ {
+ GL.Uniform1(_program.FragmentIsBgraUniform, 8, _fpIsBgra);
+ }
+ }
+
private void UpdateDepthTest()
{
// Enabling depth operations is only valid when we have
@@ -1137,6 +1152,29 @@ namespace Ryujinx.Graphics.OpenGL
}
}
+ public void UpdateRenderScale(ShaderStage stage, int textureCount)
+ {
+ if (_program != null)
+ {
+ switch (stage)
+ {
+ case ShaderStage.Fragment:
+ if (_program.FragmentRenderScaleUniform != -1)
+ {
+ GL.Uniform1(_program.FragmentRenderScaleUniform, textureCount + 1, _fpRenderScale);
+ }
+ break;
+
+ case ShaderStage.Compute:
+ if (_program.ComputeRenderScaleUniform != -1)
+ {
+ GL.Uniform1(_program.ComputeRenderScaleUniform, textureCount, _cpRenderScale);
+ }
+ break;
+ }
+ }
+ }
+
private void PrepareForDispatch()
{
if (_unit0Texture != null)
@@ -1230,28 +1268,5 @@ namespace Ryujinx.Graphics.OpenGL
_framebuffer?.Dispose();
_vertexArray?.Dispose();
}
-
- public void UpdateRenderScale(ShaderStage stage, int textureCount)
- {
- if (_program != null)
- {
- switch (stage)
- {
- case ShaderStage.Fragment:
- if (_program.FragmentRenderScaleUniform != -1)
- {
- GL.Uniform1(_program.FragmentRenderScaleUniform, textureCount + 1, _fpRenderScale);
- }
- break;
-
- case ShaderStage.Compute:
- if (_program.ComputeRenderScaleUniform != -1)
- {
- GL.Uniform1(_program.ComputeRenderScaleUniform, textureCount, _cpRenderScale);
- }
- break;
- }
- }
- }
}
}