diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-07-19 02:30:21 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-19 02:30:21 -0300 |
| commit | 60f2198a1e8e61fe1cfb8da30a6afcd86a672a85 (patch) | |
| tree | be608a9f483e751d6d4bf4d9037048c94d495b0d /Ryujinx.Graphics/Gal/OpenGL | |
| parent | 8b685b12f0b7a901139999dff17b24b049b9084b (diff) | |
Support deswizzle of sparse tiled textures and some frame buffer fixes (#275)
* Attempt to support deswizzle of sparse tiled textures
* Use correct frame buffer and viewport sizes, started to clean up the copy engine
* Correct texture width alignment
* Use Scale/Translate registers to calculate viewport rect
* Allow texture copy between frame buffers
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL')
| -rw-r--r-- | Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs | 82 |
1 files changed, 67 insertions, 15 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs index 305fa37d..cd52762c 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs @@ -78,11 +78,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL public void Create(long Key, int Width, int Height) { - //TODO: We should either use the original frame buffer size, - //or just remove the Width/Height arguments. - Width = Window.Width; - Height = Window.Height; - if (Fbs.TryGetValue(Key, out FrameBuffer Fb)) { if (Fb.Width != Width || @@ -125,8 +120,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.DrawBuffer(DrawBufferMode.ColorAttachment0); - GL.Viewport(0, 0, Width, Height); - Fbs.Add(Key, Fb); } @@ -230,7 +223,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL { Viewport = new Rect(X, Y, Width, Height); - //TODO + SetViewport(Viewport); + } + + private void SetViewport(Rect Viewport) + { + GL.Viewport( + Viewport.X, + Viewport.Y, + Viewport.Width, + Viewport.Height); } public void Render() @@ -300,10 +302,38 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.Enable(EnableCap.Blend); } - //GL.Viewport(0, 0, 1280, 720); + SetViewport(Viewport); } } + public void Copy( + long SrcKey, + long DstKey, + int SrcX0, + int SrcY0, + int SrcX1, + int SrcY1, + int DstX0, + int DstY0, + int DstX1, + int DstY1) + { + if (Fbs.TryGetValue(SrcKey, out FrameBuffer SrcFb) && + Fbs.TryGetValue(DstKey, out FrameBuffer DstFb)) + { + GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, SrcFb.Handle); + GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, DstFb.Handle); + + GL.Clear(ClearBufferMask.ColorBufferBit); + + GL.BlitFramebuffer( + SrcX0, SrcY0, SrcX1, SrcY1, + DstX0, DstY0, DstX1, DstY1, + ClearBufferMask.ColorBufferBit, + BlitFramebufferFilter.Linear); + } +} + public void GetBufferData(long Key, Action<byte[]> Callback) { if (Fbs.TryGetValue(Key, out FrameBuffer Fb)) @@ -329,13 +359,35 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } - private void SetViewport(Rect Viewport) + public void SetBufferData( + long Key, + int Width, + int Height, + GalTextureFormat Format, + byte[] Buffer) { - GL.Viewport( - Viewport.X, - Viewport.Y, - Viewport.Width, - Viewport.Height); + if (Fbs.TryGetValue(Key, out FrameBuffer Fb)) + { + GL.BindTexture(TextureTarget.Texture2D, Fb.TexHandle); + + const int Level = 0; + const int Border = 0; + + const PixelInternalFormat InternalFmt = PixelInternalFormat.Rgba; + + (PixelFormat GlFormat, PixelType Type) = OGLEnumConverter.GetTextureFormat(Format); + + GL.TexImage2D( + TextureTarget.Texture2D, + Level, + InternalFmt, + Width, + Height, + Border, + GlFormat, + Type, + Buffer); + } } private void EnsureInitialized() |
