refactored vulkan shaders

This commit is contained in:
KojoZero 2026-05-25 08:40:34 -07:00
parent b18f8d8b35
commit cb0d14258b
18 changed files with 32 additions and 136 deletions

View file

@ -53,7 +53,7 @@ FXAA_SUBPIX_CAP - Insures fine detail is not completely removed.
layout(location = 0) in vec2 frag_tex_coord;
layout(location = 0) out vec4 color;
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
layout (set = 0, binding = 0) uniform sampler2D color_texture;
layout (push_constant, std140) uniform DrawInfo {
mat4 modelview_matrix;
@ -64,14 +64,8 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
/*
screen_textures[0] = color_texture
*/
#ifndef FXAA_PRESET
#define FXAA_PRESET 5
#endif
@ -263,7 +257,7 @@ vec3 sRGBToLinear(vec3 c) {
void main()
{
vec4 pixel = vec4(FxaaPixelShader(frag_tex_coord, screen_textures[0], vec2(i_resolution.z, i_resolution.w)), 1.0) * 1.0;
vec4 pixel = vec4(FxaaPixelShader(frag_tex_coord, color_texture, vec2(i_resolution.z, i_resolution.w)), 1.0) * 1.0;
if (convert_colors == 1){
pixel = vec4(sRGBToLinear(pixel.rgb), pixel.a);
}

View file

@ -10,18 +10,12 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
layout(location = 0) in vec2 vert_position;
layout(location = 1) in vec2 vert_tex_coord;
layout(location = 0) out vec2 frag_tex_coord;
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
/*
screen_textures[0] = color_texture
*/
void main()
{
gl_Position = vec4(vert_position, 0.0, 1.0);

View file

@ -1,7 +1,7 @@
void main() {
if (SMAA_EDT == 0.0) {
color = vec4(SMAALumaEdgeDetectionPS(frag_tex_coord, offset, screen_textures[0]), 0.0, 0.0);
color = vec4(SMAALumaEdgeDetectionPS(frag_tex_coord, offset, color_texture), 0.0, 0.0);
} else if (SMAA_EDT <= 1.0) {
color = vec4(SMAAColorEdgeDetectionPS(frag_tex_coord, offset, screen_textures[0]), 0.0, 0.0);
color = vec4(SMAAColorEdgeDetectionPS(frag_tex_coord, offset, color_texture), 0.0, 0.0);
}
}

View file

@ -13,9 +13,6 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
@ -27,9 +24,7 @@ layout (push_constant, std140) uniform DrawInfo {
layout(location = 0) in vec2 frag_tex_coord;
layout(location = 1) in vec4 offset[3];
layout(location = 0) out vec4 color;
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
/*
screen_textures[0] = color_texture
*/
layout (set = 0, binding = 0) uniform sampler2D color_texture;
#define SMAA_INCLUDE_VS 0
//#include "SMAA.hlsl"

View file

@ -13,9 +13,6 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)

View file

@ -1,4 +1,4 @@
void main() {
vec4 subsampleIndices = vec4(0.0);
color = SMAABlendingWeightCalculationPS(frag_tex_coord, pixcoord, offset, screen_textures[0], screen_textures[1], screen_textures[2], subsampleIndices);
color = SMAABlendingWeightCalculationPS(frag_tex_coord, pixcoord, offset, color_texture, areaTex, searchTex, subsampleIndices);
}

View file

@ -13,9 +13,6 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
@ -28,11 +25,9 @@ layout(location = 0) in vec2 frag_tex_coord;
layout(location = 1) in vec2 pixcoord;
layout(location = 2) in vec4 offset[3];
layout(location = 0) out vec4 color;
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
/*
screen_textures[0] = color_texture
screen_textures[1] = areaTex;
screen_textures[2] = searchTex;
*/
layout (set = 0, binding = 0) uniform sampler2D color_texture;
layout (set = 0, binding = 1) uniform sampler2D areaTex;
layout (set = 0, binding = 2) uniform sampler2D searchTex;
#define SMAA_INCLUDE_VS 0
//#include "SMAA.hlsl"

View file

@ -13,9 +13,6 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)

View file

@ -3,7 +3,7 @@ vec3 LinearTosRGB(vec3 c) {
}
void main() {
vec4 pixel = SMAANeighborhoodBlendingPS(frag_tex_coord, offset, screen_textures[1], screen_textures[0]);
vec4 pixel = SMAANeighborhoodBlendingPS(frag_tex_coord, offset, SMAA_Input, color_texture);
if (convert_colors == 2){
pixel = vec4(LinearTosRGB(pixel.rgb), pixel.a);
}

View file

@ -13,9 +13,6 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
@ -25,10 +22,8 @@ layout (push_constant, std140) uniform DrawInfo {
layout(location = 0) in vec2 frag_tex_coord;
layout(location = 1) in vec4 offset;
layout(location = 0) out vec4 color;
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
/*
screen_textures[0] = color_texture
screen_textures[1] = SMAA_Input;
*/
layout (set = 0, binding = 0) uniform sampler2D color_texture;
layout (set = 0, binding = 1) uniform sampler2D SMAA_Input;
#define SMAA_INCLUDE_VS 0
//#include "SMAA.hlsl"

View file

@ -13,9 +13,6 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)

View file

@ -2,10 +2,8 @@
layout(location = 0) in vec2 frag_tex_coord;
layout(location = 0) out vec4 color;
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
/*
screen_textures[0] = color_texture
*/
layout (set = 0, binding = 0) uniform sampler2D color_texture;
layout (push_constant, std140) uniform DrawInfo {
mat4 modelview_matrix;
vec4 i_resolution;
@ -15,9 +13,6 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
/***** Area Sampling *****/
@ -97,7 +92,7 @@ vec3 LinearTosRGB(vec3 c) {
}
void main() {
vec4 pixel = AreaSampling(screen_textures[0], frag_tex_coord);
vec4 pixel = AreaSampling(color_texture, frag_tex_coord);
if (convert_colors == 2){
pixel = vec4(LinearTosRGB(pixel.rgb), pixel.a);
}

View file

@ -11,9 +11,6 @@ layout (push_constant, std140) uniform DrawInfo {
int layer;
int reverse_interlaced;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
void main()
{

View file

@ -18,23 +18,8 @@ layout (push_constant, std140) uniform DrawInfo {
int reverse_interlaced;
};
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
vec4 GetScreen(int screen_id) {
#ifdef ARRAY_DYNAMIC_INDEX
return texture(screen_textures[screen_id], frag_tex_coord);
#else
switch (screen_id) {
case 0:
return texture(screen_textures[0], frag_tex_coord);
case 1:
return texture(screen_textures[1], frag_tex_coord);
case 2:
return texture(screen_textures[2], frag_tex_coord);
}
#endif
}
layout (set = 0, binding = 0) uniform sampler2D color_texture;
void main() {
color = GetScreen(screen_id_l);
color = texture(color_texture, frag_tex_coord);
}

View file

@ -30,25 +30,11 @@ layout (push_constant, std140) uniform DrawInfo {
int reverse_interlaced;
};
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
vec4 GetScreen(int screen_id) {
#ifdef ARRAY_DYNAMIC_INDEX
return texture(screen_textures[screen_id], frag_tex_coord);
#else
switch (screen_id) {
case 0:
return texture(screen_textures[0], frag_tex_coord);
case 1:
return texture(screen_textures[1], frag_tex_coord);
case 2:
return texture(screen_textures[2], frag_tex_coord);
}
#endif
}
layout (set = 0, binding = 0) uniform sampler2D color_texture_l;
layout (set = 0, binding = 1) uniform sampler2D color_texture_r;
void main() {
vec4 color_tex_l = GetScreen(screen_id_l);
vec4 color_tex_r = GetScreen(screen_id_r);
vec4 color_tex_l = texture(color_texture_l, frag_tex_coord);
vec4 color_tex_r = texture(color_texture_r, frag_tex_coord);
color = vec4(color_tex_l.rgb*l+color_tex_r.rgb*r, color_tex_l.a);
}

View file

@ -18,27 +18,13 @@ layout (push_constant, std140) uniform DrawInfo {
int reverse_interlaced;
};
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
vec4 GetScreen(int screen_id) {
#ifdef ARRAY_DYNAMIC_INDEX
return texture(screen_textures[screen_id], frag_tex_coord);
#else
switch (screen_id) {
case 0:
return texture(screen_textures[0], frag_tex_coord);
case 1:
return texture(screen_textures[1], frag_tex_coord);
case 2:
return texture(screen_textures[2], frag_tex_coord);
}
#endif
}
layout (set = 0, binding = 0) uniform sampler2D color_texture_l;
layout (set = 0, binding = 1) uniform sampler2D color_texture_r;
void main() {
float screen_row = o_resolution.x * frag_tex_coord.x;
if (int(screen_row) % 2 == reverse_interlaced)
color = GetScreen(screen_id_l);
color = texture(color_texture_l, frag_tex_coord);
else
color = GetScreen(screen_id_r);
color = texture(color_texture_r, frag_tex_coord);
}

View file

@ -19,22 +19,8 @@ layout (push_constant, std140) uniform DrawInfo {
int convert_colors;
};
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
layout (set = 0, binding = 0) uniform sampler2D color_texture;
vec4 GetScreen(int screen_id) {
#ifdef ARRAY_DYNAMIC_INDEX
return texture(screen_textures[screen_id], frag_tex_coord);
#else
switch (screen_id) {
case 0:
return texture(screen_textures[0], frag_tex_coord);
case 1:
return texture(screen_textures[1], frag_tex_coord);
case 2:
return texture(screen_textures[2], frag_tex_coord);
}
#endif
}
vec3 sRGBToLinear(vec3 c) {
return mix(c / 12.92, pow((c + 0.055) / 1.055, vec3(2.4)), step(0.04045, c));
@ -45,7 +31,7 @@ vec3 LinearTosRGB(vec3 c) {
}
void main() {
vec4 pixel = GetScreen(screen_id_l);
vec4 pixel = texture(color_texture, frag_tex_coord);
if (convert_colors == 2){
pixel = vec4(LinearTosRGB(pixel.rgb), pixel.a);
} else if (convert_colors == 1){

View file

@ -63,11 +63,8 @@ struct PresentUniformData {
int layer = 0;
int reverse_interlaced = 0;
int convert_colors;
int areatex;
int searchtex;
int smaa_input;
};
static_assert(sizeof(PresentUniformData) == 128,
static_assert(sizeof(PresentUniformData) == 116,
"PresentUniformData does not structure in shader!");
class RendererVulkan : public VideoCore::RendererBase {