aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-02-28 23:37:40 -0300
committergdkchan <gab.dark.100@gmail.com>2018-02-28 23:37:40 -0300
commit5d8a615c21eff7888ff4e36c122123560bcb0886 (patch)
treeab86f9cd27bf0c876763bf159f5959b8d7c931ae /Ryujinx.Graphics
parenteacd432387677dc0513255f8c3661f5c3ef05d65 (diff)
Enable hardware frame buffer texture scaling
Diffstat (limited to 'Ryujinx.Graphics')
-rw-r--r--Ryujinx.Graphics/Gal/IGalRenderer.cs13
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/FbVtxShader.glsl6
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs6
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs15
4 files changed, 31 insertions, 9 deletions
diff --git a/Ryujinx.Graphics/Gal/IGalRenderer.cs b/Ryujinx.Graphics/Gal/IGalRenderer.cs
index 5854c54a..83d2c699 100644
--- a/Ryujinx.Graphics/Gal/IGalRenderer.cs
+++ b/Ryujinx.Graphics/Gal/IGalRenderer.cs
@@ -10,9 +10,20 @@ namespace Ryujinx.Graphics.Gal
void InitializeFrameBuffer();
void Render();
void SetWindowSize(int Width, int Height);
- void SetFrameBuffer(byte* Fb, int Width, int Height, float SX, float SY, float R);
+ void SetFrameBuffer(
+ byte* Fb,
+ int Width,
+ int Height,
+ float ScaleX,
+ float ScaleY,
+ float OffsX,
+ float OffsY,
+ float Rotate);
+
void SendVertexBuffer(int Index, byte[] Buffer, int Stride, GalVertexAttrib[] Attribs);
+
void SendR8G8B8A8Texture(int Index, byte[] Buffer, int Width, int Height);
+
void BindTexture(int Index);
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Gal/OpenGL/FbVtxShader.glsl b/Ryujinx.Graphics/Gal/OpenGL/FbVtxShader.glsl
index 933fa6aa..35d560c0 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/FbVtxShader.glsl
+++ b/Ryujinx.Graphics/Gal/OpenGL/FbVtxShader.glsl
@@ -2,8 +2,9 @@
precision highp float;
-uniform vec2 window_size;
uniform mat2 transform;
+uniform vec2 window_size;
+uniform vec2 offset;
layout(location = 0) in vec2 in_position;
layout(location = 1) in vec2 in_tex_coord;
@@ -22,5 +23,6 @@ vec2 get_scale_ratio(void) {
void main(void) {
tex_coord = in_tex_coord;
- gl_Position = vec4((transform * in_position) * get_scale_ratio(), 0, 1);
+ vec2 t_pos = (transform * in_position) + offset;
+ gl_Position = vec4(t_pos * get_scale_ratio(), 0, 1);
} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs b/Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs
index c66c0cb7..7dc4bffe 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs
@@ -135,7 +135,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.BindVertexArray(0);
}
- public unsafe void Set(byte* Fb, int Width, int Height, Matrix2 Transform)
+ public unsafe void Set(byte* Fb, int Width, int Height, Matrix2 Transform, Vector2 Offs)
{
if (Fb == null)
{
@@ -172,6 +172,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
int WindowSizeUniformLocation = GL.GetUniformLocation(PrgShaderHandle, "window_size");
GL.Uniform2(WindowSizeUniformLocation, new Vector2(WindowWidth, WindowHeight));
+
+ int OffsetUniformLocation = GL.GetUniformLocation(PrgShaderHandle, "offset");
+
+ GL.Uniform2(OffsetUniformLocation, Offs);
}
public void Render()
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
index 5ae5e225..bdedfc1a 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
@@ -1,6 +1,7 @@
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
namespace Ryujinx.Graphics.Gal.OpenGL
@@ -24,7 +25,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
private Texture[] Textures;
- private Queue<Action> ActionsQueue;
+ private ConcurrentQueue<Action> ActionsQueue;
private FrameBuffer FbRenderer;
@@ -34,7 +35,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Textures = new Texture[8];
- ActionsQueue = new Queue<Action>();
+ ActionsQueue = new ConcurrentQueue<Action>();
}
public void InitializeFrameBuffer()
@@ -51,9 +52,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
int Count = ActionsQueue.Count;
- while (Count-- > 0)
+ while (Count-- > 0 && ActionsQueue.TryDequeue(out Action RenderAction))
{
- ActionsQueue.Dequeue()();
+ RenderAction();
}
}
@@ -86,6 +87,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
int Height,
float ScaleX,
float ScaleY,
+ float OffsX,
+ float OffsY,
float Rotate)
{
Matrix2 Transform;
@@ -93,7 +96,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Transform = Matrix2.CreateScale(ScaleX, ScaleY);
Transform *= Matrix2.CreateRotation(Rotate);
- FbRenderer.Set(Fb, Width, Height, Transform);
+ Vector2 Offs = new Vector2(OffsX, OffsY);
+
+ FbRenderer.Set(Fb, Width, Height, Transform, Offs);
}
public void SendVertexBuffer(int Index, byte[] Buffer, int Stride, GalVertexAttrib[] Attribs)