Cache framebuffer attachments
This commit is contained in:
parent
c308158296
commit
93e985e1b1
1 changed files with 54 additions and 42 deletions
|
@ -61,8 +61,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
private int SrcFb;
|
private int SrcFb;
|
||||||
private int DstFb;
|
private int DstFb;
|
||||||
|
|
||||||
|
private int[] ColorAttachments;
|
||||||
|
private int DepthAttachment;
|
||||||
|
private int StencilAttachment;
|
||||||
|
|
||||||
public OGLFrameBuffer(OGLTexture Texture)
|
public OGLFrameBuffer(OGLTexture Texture)
|
||||||
{
|
{
|
||||||
|
ColorAttachments = new int[8];
|
||||||
|
|
||||||
this.Texture = Texture;
|
this.Texture = Texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,11 +78,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
EnsureFrameBuffer();
|
EnsureFrameBuffer();
|
||||||
|
|
||||||
GL.FramebufferTexture(
|
Attach(ref ColorAttachments[Attachment], Tex.Handle, FramebufferAttachment.ColorAttachment0 + Attachment);
|
||||||
FramebufferTarget.DrawFramebuffer,
|
|
||||||
FramebufferAttachment.ColorAttachment0 + Attachment,
|
|
||||||
Tex.Handle,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -88,11 +90,21 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
EnsureFrameBuffer();
|
EnsureFrameBuffer();
|
||||||
|
|
||||||
GL.FramebufferTexture(
|
Attach(ref ColorAttachments[Attachment], 0, FramebufferAttachment.ColorAttachment0 + Attachment);
|
||||||
FramebufferTarget.DrawFramebuffer,
|
}
|
||||||
FramebufferAttachment.ColorAttachment0 + Attachment,
|
|
||||||
0,
|
private void Attach(ref int OldHandle, int NewHandle, FramebufferAttachment FbAttachment)
|
||||||
0);
|
{
|
||||||
|
if (OldHandle != NewHandle)
|
||||||
|
{
|
||||||
|
GL.FramebufferTexture(
|
||||||
|
FramebufferTarget.DrawFramebuffer,
|
||||||
|
FbAttachment,
|
||||||
|
NewHandle,
|
||||||
|
0);
|
||||||
|
|
||||||
|
OldHandle = NewHandle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BindZeta(long Key)
|
public void BindZeta(long Key)
|
||||||
|
@ -103,39 +115,31 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
if (Tex.HasDepth && Tex.HasStencil)
|
if (Tex.HasDepth && Tex.HasStencil)
|
||||||
{
|
{
|
||||||
GL.FramebufferTexture(
|
if (DepthAttachment != Tex.Handle ||
|
||||||
FramebufferTarget.DrawFramebuffer,
|
StencilAttachment != Tex.Handle)
|
||||||
FramebufferAttachment.DepthStencilAttachment,
|
{
|
||||||
Tex.Handle,
|
GL.FramebufferTexture(
|
||||||
0);
|
FramebufferTarget.DrawFramebuffer,
|
||||||
|
FramebufferAttachment.DepthStencilAttachment,
|
||||||
|
Tex.Handle,
|
||||||
|
0);
|
||||||
|
|
||||||
|
DepthAttachment = Tex.Handle;
|
||||||
|
|
||||||
|
StencilAttachment = Tex.Handle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (Tex.HasDepth)
|
else if (Tex.HasDepth)
|
||||||
{
|
{
|
||||||
GL.FramebufferTexture(
|
Attach(ref DepthAttachment, Tex.Handle, FramebufferAttachment.DepthAttachment);
|
||||||
FramebufferTarget.DrawFramebuffer,
|
|
||||||
FramebufferAttachment.DepthAttachment,
|
|
||||||
Tex.Handle,
|
|
||||||
0);
|
|
||||||
|
|
||||||
GL.FramebufferTexture(
|
Attach(ref StencilAttachment, 0, FramebufferAttachment.StencilAttachment);
|
||||||
FramebufferTarget.DrawFramebuffer,
|
|
||||||
FramebufferAttachment.StencilAttachment,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
else if (Tex.HasStencil)
|
else if (Tex.HasStencil)
|
||||||
{
|
{
|
||||||
GL.FramebufferTexture(
|
Attach(ref DepthAttachment, 0, FramebufferAttachment.DepthAttachment);
|
||||||
FramebufferTarget.DrawFramebuffer,
|
|
||||||
FramebufferAttachment.DepthAttachment,
|
|
||||||
Tex.Handle,
|
|
||||||
0);
|
|
||||||
|
|
||||||
GL.FramebufferTexture(
|
Attach(ref StencilAttachment, Tex.Handle, FramebufferAttachment.StencilAttachment);
|
||||||
FramebufferTarget.DrawFramebuffer,
|
|
||||||
FramebufferAttachment.StencilAttachment,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -152,11 +156,19 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
EnsureFrameBuffer();
|
EnsureFrameBuffer();
|
||||||
|
|
||||||
GL.FramebufferTexture(
|
if (DepthAttachment != 0 ||
|
||||||
FramebufferTarget.DrawFramebuffer,
|
StencilAttachment != 0)
|
||||||
FramebufferAttachment.DepthStencilAttachment,
|
{
|
||||||
0,
|
GL.FramebufferTexture(
|
||||||
0);
|
FramebufferTarget.DrawFramebuffer,
|
||||||
|
FramebufferAttachment.DepthStencilAttachment,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
|
DepthAttachment = 0;
|
||||||
|
|
||||||
|
StencilAttachment = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BindTexture(long Key, int Index)
|
public void BindTexture(long Key, int Index)
|
||||||
|
@ -364,8 +376,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureFrameBuffer();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,6 +481,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
DstX0, DstY0, DstX1, DstY1,
|
DstX0, DstY0, DstX1, DstY1,
|
||||||
Mask,
|
Mask,
|
||||||
Color ? BlitFramebufferFilter.Linear : BlitFramebufferFilter.Nearest);
|
Color ? BlitFramebufferFilter.Linear : BlitFramebufferFilter.Nearest);
|
||||||
|
|
||||||
|
EnsureFrameBuffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue