[client] egl: rework post process filters and add AMD FXR

This commit is contained in:
Geoffrey McRae
2021-08-10 13:08:54 +10:00
parent 3b751a2017
commit dc0b3a8d45
14 changed files with 2441 additions and 235 deletions

View File

@@ -0,0 +1,32 @@
#if __VERSION__ == 300
vec4 textureGather(sampler2D tex, vec2 uv, int comp)
{
vec4 c0 = textureOffset(tex, uv, ivec2(0,1));
vec4 c1 = textureOffset(tex, uv, ivec2(1,1));
vec4 c2 = textureOffset(tex, uv, ivec2(1,0));
vec4 c3 = textureOffset(tex, uv, ivec2(0,0));
return vec4(c0[comp], c1[comp], c2[comp],c3[comp]);
}
#elif __VERSION__ < 300
vec4 textureGather(sampler2D tex, vec2 uv, int comp)
{
vec4 c3 = texture2D(tex, uv);
return vec4(c3[comp], c3[comp], c3[comp],c3[comp]);
}
#endif
#if __VERSION__ < 310
uint bitfieldExtract(uint val, int off, int size)
{
uint mask = uint((1 << size) - 1);
return uint(val >> off) & mask;
}
uint bitfieldInsert(uint a, uint b, int c, int d)
{
uint mask = ~(0xffffffffu << d) << c;
mask = ~mask;
a &= mask;
return a | (b << c);
}
#endif

View File

@@ -3,11 +3,11 @@
layout(location = 0) in vec2 vertex;
out highp vec2 uv;
uniform highp vec2 size;
uniform highp vec2 desktopSize;
uniform mat3x2 transform;
void main()
{
gl_Position = vec4(transform * vec3(vertex, 1.0), 0.0, 1.0);
uv = vertex / size;
uv = vertex / desktopSize;
}

View File

@@ -13,8 +13,7 @@ out highp vec4 color;
uniform sampler2D sampler1;
uniform int scaleAlgo;
uniform highp vec2 size;
uniform highp float textureScale;
uniform highp ivec2 textureSize;
uniform highp float nvGain;
uniform int cbMode;
@@ -24,7 +23,7 @@ void main()
switch (scaleAlgo)
{
case EGL_SCALE_NEAREST:
color = texelFetch(sampler1, ivec2(uv * size * textureScale), 0);
color = texelFetch(sampler1, ivec2(uv * vec2(textureSize)), 0);
break;
case EGL_SCALE_LINEAR:

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,8 @@
#version 300 es
precision mediump float;
#include "compat.h"
in vec2 iFragCoord;
out vec4 fragColor;
@@ -10,22 +11,6 @@ uniform uvec2 uInRes[8];
uniform uvec2 uOutRes;
uniform float uSharpness;
// the following are not available until verion 400 or later
// so we implement our own versions of them
uint bitfieldExtract(uint val, int off, int size)
{
uint mask = uint((1 << size) - 1);
return uint(val >> off) & mask;
}
uint bitfieldInsert(uint a, uint b, int c, int d)
{
uint mask = ~(0xffffffffu << d) << c;
mask = ~mask;
a &= mask;
return a | (b << c);
}
#define A_GPU 1
#define A_GLSL 1

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
#version 300 es
precision mediump float;
#include "compat.h"
in vec2 iFragCoord;
out vec4 fragColor;
uniform sampler2D iChannel0;
uniform uvec2 uInRes[8];
uniform uvec2 uOutRes;
#define A_GPU 1
#define A_GLSL 1
#define A_FULL 1
#include "ffx_a.h"
#define FSR_EASU_F 1
#define FSR_RCAS_F 1
AF4 FsrEasuRF(AF2 p){return AF4(textureGather(iChannel0, p, 0));}
AF4 FsrEasuGF(AF2 p){return AF4(textureGather(iChannel0, p, 1));}
AF4 FsrEasuBF(AF2 p){return AF4(textureGather(iChannel0, p, 2));}
#include "ffx_fsr1.h"
void main()
{
AU4 con0, con1, con2, con3;
vec2 inRes = vec2(uInRes[0]);
vec2 outRes = vec2(uOutRes);
FsrEasuCon(
con0,
con1,
con2,
con3,
inRes.x , inRes.y,
inRes.x , inRes.y,
outRes.x, outRes.y
);
vec3 color;
uvec2 point = uvec2(iFragCoord * outRes);
FsrEasuF(color, point, con0, con1, con2, con3);
fragColor = vec4(color.xyz, 1);
}

View File

@@ -0,0 +1,36 @@
#version 300 es
precision mediump float;
#include "compat.h"
in vec2 iFragCoord;
out vec4 fragColor;
uniform sampler2D iChannel0;
uniform uvec2 uInRes[8];
uniform float uSharpness;
#define A_GPU 1
#define A_GLSL 1
#define A_FULL 1
#include "ffx_a.h"
AF4 FsrRcasLoadF(ASU2 p) { return texelFetch(iChannel0, ASU2(p), 0); }
void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {}
#define FSR_RCAS_F 1
#define FSR_RCAS_DENOISE 1
#include "ffx_fsr1.h"
void main()
{
vec2 inRes = vec2(uInRes[0]);
uvec2 point = uvec2(iFragCoord * inRes);
uvec4 const0;
FsrRcasCon(const0, 1.0f - uSharpness);
FsrRcasF(fragColor.r, fragColor.g, fragColor.b, point, const0);
fragColor.a = 1.0f;
}