rsx: Improvements to the video out passes

- Use shared VS for vulkan as well as GL
- Simplify binding model and give control back to the cpp side
This commit is contained in:
kd-11 2024-02-01 03:47:02 +03:00 committed by Megamouse
parent bb22afb7f1
commit 1808a4373b
4 changed files with 48 additions and 37 deletions

View file

@ -2,10 +2,21 @@ R"(
#version 420
layout(location=0) out vec2 tc0;
#ifdef VULKAN
#define gl_VertexID gl_VertexIndex
#endif
void main()
{
vec2 positions[] = {vec2(-1., -1.), vec2(1., -1.), vec2(-1., 1.), vec2(1., 1.)};
#ifdef VULKAN
// Origin at top left
vec2 coords[] = {vec2(0., 0.), vec2(1., 0.), vec2(0., 1.), vec2(1., 1.)};
#else
// Origin at bottom left. Flip Y coordinate.
vec2 coords[] = {vec2(0., 1.), vec2(1., 1.), vec2(0., 0.), vec2(1., 0.)};
#endif
tc0 = coords[gl_VertexID % 4];
vec2 pos = positions[gl_VertexID % 4];
gl_Position = vec4(pos, 0., 1.);

View file

@ -1,13 +1,10 @@
R"(
#version 420
#version 440
#ifdef VULKAN
layout(set=0, binding=1) uniform sampler2D fs0;
layout(set=0, binding=2) uniform sampler2D fs1;
#else
layout(binding=31) uniform sampler2D fs0;
layout(binding=30) uniform sampler2D fs1;
#endif
#define SAMPLER_BINDING(x) %sampler_binding
layout(%set_decorator, binding=SAMPLER_BINDING(0)) uniform sampler2D fs0;
layout(%set_decorator, binding=SAMPLER_BINDING(1)) uniform sampler2D fs1;
layout(location=0) in vec2 tc0;
layout(location=0) out vec4 ocol;
@ -77,7 +74,10 @@ vec4 anaglyph_stereo_image()
vec4 read_source()
{
if (stereo_display_mode == STEREO_MODE_DISABLED) return texture(fs0, tc0);
if (stereo_display_mode == STEREO_MODE_DISABLED)
{
return texture(fs0, tc0);
}
if (stereo_image_count == 1)
{
@ -106,7 +106,8 @@ vec4 read_source()
return texture(fs0, tc0);
}
}
else if (stereo_image_count == 2)
if (stereo_image_count == 2)
{
switch (stereo_display_mode)
{
@ -133,23 +134,17 @@ vec4 read_source()
return texture(fs0, tc0);
}
}
else
{
vec2 coord_left = tc0 * left_single_matrix;
vec2 coord_right = coord_left + right_single_matrix;
vec4 left = texture(fs0, coord_left);
vec4 right = texture(fs0, coord_right);
return vec4(left.r, right.g, right.b, 1.);
}
// Unreachable. Return debug color fill
return vec4(1., 0., 0., 1.);
}
void main()
{
vec4 color = read_source();
color.rgb = pow(color.rgb, vec3(gamma));
if (limit_range > 0)
ocol = ((color * 220.) + 16.) / 255.;
else
ocol = color;
ocol = (limit_range == 0)
? ocol = color
: ((color * 220.) + 16.) / 255.;
}
)"