Skip to content

Commit

Permalink
Update shader resources to follow expected syntax for Vulkan integration
Browse files Browse the repository at this point in the history
Signed-off-by: Rodrigo Holztrattner <[email protected]>
  • Loading branch information
RodrigoHolztrattner-QuIC committed Dec 13, 2024
1 parent b3fbce4 commit f1bfc4c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 51 deletions.
16 changes: 9 additions & 7 deletions sgsr/v2/include/glsl_2_pass_fs/sgsr2_convert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ precision highp float;
precision highp int;

layout(location = 0) out vec4 MotionDepthClipAlphaBuffer;
in vec2 texCoord;
layout(location = 0) in highp vec2 texCoord;

layout(binding = 1) uniform mediump sampler2D InputDepth;
layout(binding = 2) uniform mediump sampler2D InputVelocity;
layout(set = 0, binding = 1) uniform mediump sampler2D InputDepth;
layout(set = 0, binding = 2) uniform mediump sampler2D InputVelocity;

layout(binding = 0) uniform Params
layout(std140, set = 0, binding = 0) uniform Params
{
vec4 clipToPrevClip[4];
vec2 renderSize;
Expand All @@ -40,7 +40,6 @@ vec2 decodeVelocityFromTexture(vec2 ev) {
return dv;
}


void main()
{
uvec2 InputPos = uvec2(texCoord * params.renderSize);
Expand Down Expand Up @@ -101,8 +100,11 @@ void main()
}
else
{
//vec2 ScreenPos = vec2(2.0f * texCoord.x - 1.0f, 1.0f - 2.0f * texCoord.y);
vec2 ScreenPos = vec2(2.0f * texCoord - 1.0f); // NDC Y+ down from viewport Y+ down
#ifdef REQUEST_NDC_Y_UP
vec2 ScreenPos = vec2(2.0f * texCoord.x - 1.0f, 1.0f - 2.0f * texCoord.y);
#else
vec2 ScreenPos = vec2(2.0f * texCoord - 1.0f);
#endif
vec3 Position = vec3(ScreenPos, btmLeftMax9); //this_clip
vec4 PreClip = params.clipToPrevClip[3] + ((params.clipToPrevClip[2] * Position.z) + ((params.clipToPrevClip[1] * ScreenPos.y) + (params.clipToPrevClip[0] * ScreenPos.x)));
vec2 PreScreen = PreClip.xy / PreClip.w;
Expand Down
33 changes: 12 additions & 21 deletions sgsr/v2/include/glsl_2_pass_fs/sgsr2_upscale.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
precision mediump float;
precision highp int;


float FastLanczos(float base)
{
float y = base - 1.0f;
Expand All @@ -23,23 +22,11 @@ float FastLanczos(float base)
layout(location = 0) out mediump vec4 Output;
layout(location = 0) in highp vec2 texCoord;

layout(binding = 1) uniform mediump sampler2D PrevOutput;
layout(binding = 2) uniform mediump sampler2D MotionDepthClipAlphaBuffer;
layout(binding = 3) uniform mediump sampler2D InputColor;

/*
UBO description
renderSize = {InputResolution.x, InputResolution.y}
outputSize = {OutputResolution.x, OutputResolution.y}
renderSizeRcp = {1.0 / InputResolution.x, 1.0 / InputResolution.y}
outputSizeRcp = {1.0 / OutputResolution.x, 1.0 / OutputResolution.y}
jitterOffset = {jitter.x, jitter.y},
scaleRatio = {OutputResolution.x / InputResolution.x, min(20.0, pow((OutputResolution.x*OutputResolution.y) / (InputResolution.x*InputResolution.y), 3.0)},
angleHor = tan(radians(m_Camera.verticalFOV / 2)) * InputResolution.x / InputResolution.y
MinLerpContribution = sameCameraFrmNum? 0.3: 0.0;
sameCameraFrmNum //the frame number where camera pose is exactly same with previous frame
*/
layout(binding = 0) uniform readonly Params
layout(set = 0, binding = 1) uniform mediump sampler2D PrevOutput;
layout(set = 0, binding = 2) uniform mediump sampler2D MotionDepthClipAlphaBuffer;
layout(set = 0, binding = 3) uniform mediump sampler2D InputColor;

layout(std140, set = 0, binding = 0) uniform readonly Params
{
highp vec4 clipToPrevClip[4];
highp vec2 renderSize;
Expand All @@ -51,7 +38,7 @@ layout(binding = 0) uniform readonly Params
highp float cameraFovAngleHor;
highp float minLerpContribution;
highp float reset;
uint sameCameraFrmNum;
uint bSameCamera;
} params;

void main()
Expand All @@ -65,14 +52,18 @@ void main()
Jitteruv.x = clamp(Hruv.x + (params.jitterOffset.x * params.outputSizeRcp.x), 0.0, 1.0);
Jitteruv.y = clamp(Hruv.y + (params.jitterOffset.y * params.outputSizeRcp.y), 0.0, 1.0);

ivec2 InputPos = ivec2(Jitteruv * params.renderSize);
highp ivec2 InputPos = ivec2(Jitteruv * params.renderSize);

highp vec3 mda = textureLod(MotionDepthClipAlphaBuffer, Jitteruv, 0.0).xyz;
highp vec2 Motion = mda.xy;

highp vec2 PrevUV;
PrevUV.x = clamp(-0.5 * Motion.x + Hruv.x, 0.0, 1.0);
#ifdef REQUEST_NDC_Y_UP
PrevUV.y = clamp(0.5 * Motion.y + Hruv.y, 0.0, 1.0);
#else
PrevUV.y = clamp(-0.5 * Motion.y + Hruv.y, 0.0, 1.0);
#endif

float depthfactor = mda.z;

Expand All @@ -90,7 +81,7 @@ void main()
vec3 rectboxcenter = vec3(0.0);
vec3 rectboxvar = vec3(0.0);
float rectboxweight = 0.0;
highp vec2 srcpos = highp vec2(InputPos) + highp vec2(0.5) - params.jitterOffset;
highp vec2 srcpos = vec2(InputPos) + vec2(0.5) - params.jitterOffset;

kernelbias *= 0.5f;
float kernelbias2 = kernelbias * kernelbias;
Expand Down
17 changes: 10 additions & 7 deletions sgsr/v2/include/glsl_3_pass_cs/sgsr2_activate.comp
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@
//============================================================================================================

#define EPSILON 1.19e-07f

float DecodeColorY(uint sample32)
{
uint x11 = sample32 >> 21u;
return float(x11) * (1.0 / 2047.5);
}

layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout(binding = 4) uniform highp usampler2D PrevLumaHistory;
layout(binding = 5) uniform mediump sampler2D MotionDepthAlphaBuffer;
layout(binding = 6) uniform highp usampler2D YCoCgColor;
layout(binding = 0, rgba16f) uniform writeonly mediump image2D MotionDepthClipAlphaBuffer;
layout(binding = 1, r32ui) uniform writeonly highp uimage2D LumaHistory;
layout(binding = 0) uniform readonly Params

layout(set = 0, binding = 1) uniform highp usampler2D PrevLumaHistory;
layout(set = 0, binding = 2) uniform mediump sampler2D MotionDepthAlphaBuffer;
layout(set = 0, binding = 3) uniform highp usampler2D YCoCgColor;
layout(set = 0, binding = 4, rgba16f) uniform writeonly mediump image2D MotionDepthClipAlphaBuffer;
layout(set = 0, binding = 5, r32ui) uniform writeonly highp uimage2D LumaHistory;

layout(std140, set = 0, binding = 0) uniform readonly Params
{
uvec2 renderSize;
uvec2 displaySize;
vec2 InViewportSizeInverse;
vec2 displaySizeRcp;
vec2 jitterOffset;
vec2 padding1;
vec4 clipToPrevClip[4];
float preExposure;
float cameraFovAngleHor;
Expand All @@ -37,7 +41,6 @@ layout(binding = 0) uniform readonly Params
uint reset;
} params;


void main()
{
ivec2 sampleOffset[4] = ivec2[4](
Expand Down
18 changes: 9 additions & 9 deletions sgsr/v2/include/glsl_3_pass_cs/sgsr2_convert.comp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ vec2 decodeVelocityFromTexture(vec2 ev) {

layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

layout(binding = 0) uniform highp sampler2D InputOpaqueColor;
layout(binding = 1) uniform highp sampler2D InputColor;
layout(binding = 2) uniform highp sampler2D InputDepth;
layout(binding = 3) uniform highp sampler2D InputVelocity;
layout(binding = 0, rgba16f) uniform writeonly mediump image2D MotionDepthAlphaBuffer;
layout(binding = 1, r32ui) uniform writeonly highp uimage2D YCoCgColor;

layout(binding = 0) uniform readonly Params
layout(set = 0, binding = 1) uniform highp sampler2D InputOpaqueColor;
layout(set = 0, binding = 2) uniform highp sampler2D InputColor;
layout(set = 0, binding = 3) uniform highp sampler2D InputDepth;
layout(set = 0, binding = 4) uniform highp sampler2D InputVelocity;
layout(set = 0, binding = 5, r32ui) uniform writeonly highp uimage2D YCoCgColor;
layout(set = 0, binding = 6, rgba16f) uniform writeonly mediump image2D MotionDepthAlphaBuffer;

layout(std140, set = 0, binding = 0) uniform readonly Params
{
uvec2 renderSize;
uvec2 displaySize;
vec2 ViewportSizeInverse;
vec2 displaySizeRcp;
vec2 jitterOffset;
vec2 padding1;
vec4 clipToPrevClip[4];
float preExposure;
float cameraFovAngleHor;
Expand All @@ -41,7 +42,6 @@ layout(binding = 0) uniform readonly Params
uint reset;
} params;


void main()
{
mediump float h0 = params.preExposure;
Expand Down
16 changes: 9 additions & 7 deletions sgsr/v2/include/glsl_3_pass_cs/sgsr2_upscale.comp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,27 @@ vec3 DecodeColor(uint sample32)
}

layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout(binding = 7) uniform highp sampler2D PrevHistoryOutput;
layout(binding = 8) uniform highp sampler2D MotionDepthClipAlphaBuffer;
layout(binding = 9) uniform highp usampler2D YCoCgColor;
layout(binding = 0, rgba16f) uniform writeonly mediump image2D SceneColorOutput;
layout(binding = 1, rgba16f) uniform writeonly mediump image2D HistoryOutput;

layout(binding = 0) uniform readonly Params
layout(set = 0, binding = 1) uniform highp sampler2D PrevHistoryOutput;
layout(set = 0, binding = 2) uniform highp sampler2D MotionDepthClipAlphaBuffer;
layout(set = 0, binding = 3) uniform highp usampler2D YCoCgColor;
layout(set = 0, binding = 4, rgba16f) uniform writeonly mediump image2D HistoryOutput;
layout(set = 0, binding = 5, rgba16f) uniform writeonly mediump image2D SceneColorOutput;

layout(std140, set = 0, binding = 0) uniform readonly Params
{
uvec2 renderSize;
uvec2 displaySize;
vec2 renderSizeRcp;
vec2 displaySizeRcp;
vec2 jitterOffset;
vec2 padding1;
vec4 clipToPrevClip[4];
float preExposure;
float cameraFovAngleHor;
float cameraNear;
float MinLerpContribution;
uint sameCameraFrmNum;
uint bSameCamera;
uint reset;
} params;

Expand Down

0 comments on commit f1bfc4c

Please sign in to comment.