From 013b6891531b37e0f882b8b88d404feb63370617 Mon Sep 17 00:00:00 2001 From: Feng Chen Date: Thu, 5 Jan 2023 12:28:48 +0800 Subject: video_core: Implement opengl/vulkan draw_texture --- src/video_core/host_shaders/full_screen_triangle.vert | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/video_core/host_shaders/full_screen_triangle.vert') diff --git a/src/video_core/host_shaders/full_screen_triangle.vert b/src/video_core/host_shaders/full_screen_triangle.vert index 2c976b19f..8ac936efd 100644 --- a/src/video_core/host_shaders/full_screen_triangle.vert +++ b/src/video_core/host_shaders/full_screen_triangle.vert @@ -4,13 +4,20 @@ #version 450 #ifdef VULKAN +#define VERTEX_ID gl_VertexIndex #define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants { #define END_PUSH_CONSTANTS }; #define UNIFORM(n) +#define FLIPY 1 #else // ^^^ Vulkan ^^^ // vvv OpenGL vvv +#define VERTEX_ID gl_VertexID #define BEGIN_PUSH_CONSTANTS #define END_PUSH_CONSTANTS +#define FLIPY -1 #define UNIFORM(n) layout (location = n) uniform +out gl_PerVertex { + vec4 gl_Position; +}; #endif BEGIN_PUSH_CONSTANTS @@ -21,8 +28,8 @@ END_PUSH_CONSTANTS layout(location = 0) out vec2 texcoord; void main() { - float x = float((gl_VertexIndex & 1) << 2); - float y = float((gl_VertexIndex & 2) << 1); - gl_Position = vec4(x - 1.0, y - 1.0, 0.0, 1.0); + float x = float((VERTEX_ID & 1) << 2); + float y = float((VERTEX_ID & 2) << 1); + gl_Position = vec4(x - 1.0, FLIPY * (y - 1.0), 0.0, 1.0); texcoord = fma(vec2(x, y) / 2.0, tex_scale, tex_offset); -} +} \ No newline at end of file -- cgit v1.2.3 From 9fc7ca1731862354ef70bfaf34d2c807a904a27b Mon Sep 17 00:00:00 2001 From: Feng Chen Date: Wed, 11 Jan 2023 11:10:48 +0800 Subject: Address feedback --- src/video_core/host_shaders/full_screen_triangle.vert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/video_core/host_shaders/full_screen_triangle.vert') diff --git a/src/video_core/host_shaders/full_screen_triangle.vert b/src/video_core/host_shaders/full_screen_triangle.vert index 8ac936efd..d16d98995 100644 --- a/src/video_core/host_shaders/full_screen_triangle.vert +++ b/src/video_core/host_shaders/full_screen_triangle.vert @@ -32,4 +32,4 @@ void main() { float y = float((VERTEX_ID & 2) << 1); gl_Position = vec4(x - 1.0, FLIPY * (y - 1.0), 0.0, 1.0); texcoord = fma(vec2(x, y) / 2.0, tex_scale, tex_offset); -} \ No newline at end of file +} -- cgit v1.2.3