renderer_vulkan: implement layer stack composition

This commit is contained in:
Liam
2024-01-18 11:44:13 -05:00
parent d4de04584f
commit 9bdf09bd76
22 changed files with 666 additions and 956 deletions

View File

@ -26,21 +26,11 @@
#endif
#ifdef VULKAN
#define BINDING_COLOR_TEXTURE 1
#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv
#define BINDING_COLOR_TEXTURE 0
#endif
layout (location = 0) in vec2 tex_coord;
layout (location = 0) out vec4 frag_color;
layout (binding = BINDING_COLOR_TEXTURE) uniform sampler2D input_texture;
layout (binding = 0) uniform sampler2D input_texture;
const bool ignore_alpha = true;

View File

@ -3,22 +3,12 @@
#version 460 core
#ifdef VULKAN
#define BINDING_COLOR_TEXTURE 1
#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv
#define BINDING_COLOR_TEXTURE 0
#endif
layout (location = 0) in vec2 frag_tex_coord;
layout (location = 0) out vec4 color;
layout (binding = BINDING_COLOR_TEXTURE) uniform sampler2D color_texture;
layout (binding = 0) uniform sampler2D color_texture;
vec4 cubic(float v) {
vec4 n = vec4(1.0, 2.0, 3.0, 4.0) - v;

View File

@ -7,21 +7,11 @@
#version 460 core
#ifdef VULKAN
#define BINDING_COLOR_TEXTURE 1
#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv
#define BINDING_COLOR_TEXTURE 0
#endif
layout(location = 0) in vec2 frag_tex_coord;
layout(location = 0) out vec4 color;
layout(binding = BINDING_COLOR_TEXTURE) uniform sampler2D color_texture;
layout(binding = 0) uniform sampler2D color_texture;
const float offset[3] = float[](0.0, 1.3846153846, 3.2307692308);
const float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703);

View File

@ -7,7 +7,7 @@ layout (location = 0) in vec2 frag_tex_coord;
layout (location = 0) out vec4 color;
layout (binding = 1) uniform sampler2D color_texture;
layout (binding = 0) uniform sampler2D color_texture;
void main() {
color = texture(color_texture, frag_tex_coord);

View File

@ -3,16 +3,37 @@
#version 460 core
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 MatrixBlock {
mat4 modelview_matrix;
struct ScreenRectVertex {
vec2 position;
vec2 tex_coord;
};
void main() {
gl_Position = modelview_matrix * vec4(vert_position, 0.0, 1.0);
frag_tex_coord = vert_tex_coord;
layout (push_constant) uniform PushConstants {
mat4 modelview_matrix;
ScreenRectVertex vertices[4];
};
// Vulkan spec 15.8.1:
// Any member of a push constant block that is declared as an
// array must only be accessed with dynamically uniform indices.
ScreenRectVertex GetVertex(int index) {
switch (index) {
case 0:
default:
return vertices[0];
case 1:
return vertices[1];
case 2:
return vertices[2];
case 3:
return vertices[3];
}
}
void main() {
ScreenRectVertex vertex = GetVertex(gl_VertexIndex);
gl_Position = modelview_matrix * vec4(vertex.position, 0.0, 1.0);
frag_tex_coord = vertex.tex_coord;
}

View File

@ -5,6 +5,7 @@
#extension GL_GOOGLE_include_directive : enable
#define VERSION 1
#define YUZU_USE_FP16
#include "opengl_present_scaleforce.frag"

View File

@ -5,4 +5,6 @@
#extension GL_GOOGLE_include_directive : enable
#define VERSION 1
#include "opengl_present_scaleforce.frag"