mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-08-03 00:27:12 +02:00
Enable hardware frame buffer texture scaling
This commit is contained in:
parent
eacd432387
commit
5d8a615c21
5 changed files with 75 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue