mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-08-16 21:58:42 +02:00
Remember bound framebuffer to avoid glGetInteger use. (#1273)
glGetInteger seems to sync with GPU which is less than ideal, and slowing down texture copies.
This commit is contained in:
parent
6416bc1938
commit
d941f4c070
4 changed files with 14 additions and 6 deletions
|
@ -20,9 +20,10 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_colors = new TextureView[8];
|
_colors = new TextureView[8];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Bind()
|
public int Bind()
|
||||||
{
|
{
|
||||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, Handle);
|
GL.BindFramebuffer(FramebufferTarget.Framebuffer, Handle);
|
||||||
|
return Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AttachColor(int index, TextureView color)
|
public void AttachColor(int index, TextureView color)
|
||||||
|
|
|
@ -23,8 +23,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
||||||
Extents2D dstRegion,
|
Extents2D dstRegion,
|
||||||
bool linearFilter)
|
bool linearFilter)
|
||||||
{
|
{
|
||||||
int oldReadFramebufferHandle = GL.GetInteger(GetPName.ReadFramebufferBinding);
|
(int oldDrawFramebufferHandle, int oldReadFramebufferHandle) = ((Pipeline)_renderer.Pipeline).GetBoundFramebuffers();
|
||||||
int oldDrawFramebufferHandle = GL.GetInteger(GetPName.DrawFramebufferBinding);
|
|
||||||
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, GetSrcFramebufferLazy());
|
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, GetSrcFramebufferLazy());
|
||||||
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, GetDstFramebufferLazy());
|
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, GetDstFramebufferLazy());
|
||||||
|
|
|
@ -28,6 +28,9 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
private bool _depthTest;
|
private bool _depthTest;
|
||||||
private bool _hasDepthBuffer;
|
private bool _hasDepthBuffer;
|
||||||
|
|
||||||
|
private int _boundDrawFramebuffer;
|
||||||
|
private int _boundReadFramebuffer;
|
||||||
|
|
||||||
private TextureBase _unit0Texture;
|
private TextureBase _unit0Texture;
|
||||||
|
|
||||||
private ClipOrigin _clipOrigin;
|
private ClipOrigin _clipOrigin;
|
||||||
|
@ -956,12 +959,18 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
_framebuffer = new Framebuffer();
|
_framebuffer = new Framebuffer();
|
||||||
|
|
||||||
_framebuffer.Bind();
|
int boundHandle = _framebuffer.Bind();
|
||||||
|
_boundDrawFramebuffer = _boundReadFramebuffer = boundHandle;
|
||||||
|
|
||||||
GL.Enable(EnableCap.FramebufferSrgb);
|
GL.Enable(EnableCap.FramebufferSrgb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal (int drawHandle, int readHandle) GetBoundFramebuffers()
|
||||||
|
{
|
||||||
|
return (_boundDrawFramebuffer, _boundReadFramebuffer);
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateDepthTest()
|
private void UpdateDepthTest()
|
||||||
{
|
{
|
||||||
// Enabling depth operations is only valid when we have
|
// Enabling depth operations is only valid when we have
|
||||||
|
|
|
@ -44,8 +44,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
bool[] oldFramebufferColorWritemask = new bool[4];
|
bool[] oldFramebufferColorWritemask = new bool[4];
|
||||||
|
|
||||||
int oldReadFramebufferHandle = GL.GetInteger(GetPName.ReadFramebufferBinding);
|
(int oldDrawFramebufferHandle, int oldReadFramebufferHandle) = ((Pipeline)_renderer.Pipeline).GetBoundFramebuffers();
|
||||||
int oldDrawFramebufferHandle = GL.GetInteger(GetPName.DrawFramebufferBinding);
|
|
||||||
|
|
||||||
GL.GetBoolean(GetIndexedPName.ColorWritemask, drawFramebuffer, oldFramebufferColorWritemask);
|
GL.GetBoolean(GetIndexedPName.ColorWritemask, drawFramebuffer, oldFramebufferColorWritemask);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue