renderer_vulkan: Disable dynamic index conditionally (#20)

This commit is contained in:
GPUCode
2024-03-07 13:12:21 +02:00
committed by PabloMK7
parent 277570f7c7
commit 7ac37da6e3
7 changed files with 68 additions and 13 deletions

View File

@@ -20,6 +20,21 @@ layout (push_constant, std140) uniform DrawInfo {
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
void main() {
color = texture(screen_textures[screen_id_l], frag_tex_coord);
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
}
void main() {
color = GetScreen(screen_id_l);
}

View File

@@ -32,8 +32,23 @@ layout (push_constant, std140) uniform DrawInfo {
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
}
void main() {
vec4 color_tex_l = texture(screen_textures[screen_id_l], frag_tex_coord);
vec4 color_tex_r = texture(screen_textures[screen_id_r], frag_tex_coord);
vec4 color_tex_l = GetScreen(screen_id_l);
vec4 color_tex_r = GetScreen(screen_id_r);
color = vec4(color_tex_l.rgb*l+color_tex_r.rgb*r, color_tex_l.a);
}

View File

@@ -20,10 +20,25 @@ layout (push_constant, std140) uniform DrawInfo {
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
}
void main() {
float screen_row = o_resolution.x * frag_tex_coord.x;
if (int(screen_row) % 2 == reverse_interlaced)
color = texture(screen_textures[screen_id_l], frag_tex_coord);
color = GetScreen(screen_id_l);
else
color = texture(screen_textures[screen_id_r], frag_tex_coord);
color = GetScreen(screen_id_r);
}