From: Benjamin Otte Date: Mon, 15 May 2023 00:25:41 +0000 (+0200) Subject: vulkan: Update texture shader to do AA X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~185^2~21 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a73530f95274fdc394fd7a501841d531f95b8ef7;p=gtk4.git vulkan: Update texture shader to do AA --- diff --git a/gsk/vulkan/resources/texture.frag b/gsk/vulkan/resources/texture.frag index ee9eb459a9..557a63746a 100644 --- a/gsk/vulkan/resources/texture.frag +++ b/gsk/vulkan/resources/texture.frag @@ -1,9 +1,11 @@ #version 420 core #include "clip.frag.glsl" +#include "rect.frag.glsl" layout(location = 0) in vec2 inPos; -layout(location = 1) in vec2 inTexCoord; +layout(location = 1) in Rect inRect; +layout(location = 2) in vec2 inTexCoord; layout(set = 0, binding = 0) uniform sampler2D inTexture; @@ -11,5 +13,6 @@ layout(location = 0) out vec4 color; void main() { - color = clip (inPos, texture (inTexture, inTexCoord)); + float alpha = rect_coverage (inRect, inPos); + color = clip_scaled (inPos, texture (inTexture, inTexCoord) * alpha); } diff --git a/gsk/vulkan/resources/texture.vert b/gsk/vulkan/resources/texture.vert index 443d6ecae9..49d30e2e47 100644 --- a/gsk/vulkan/resources/texture.vert +++ b/gsk/vulkan/resources/texture.vert @@ -1,30 +1,20 @@ #version 420 core -#include "clip.vert.glsl" +#include "common.vert.glsl" +#include "rect.vert.glsl" layout(location = 0) in vec4 inRect; layout(location = 1) in vec4 inTexRect; layout(location = 0) out vec2 outPos; -layout(location = 1) out vec2 outTexCoord; - -vec2 offsets[6] = { vec2(0.0, 0.0), - vec2(1.0, 0.0), - vec2(0.0, 1.0), - vec2(0.0, 1.0), - vec2(1.0, 0.0), - vec2(1.0, 1.0) }; +layout(location = 1) out flat Rect outRect; +layout(location = 2) out vec2 outTexCoord; void main() { - vec4 rect = clip (inRect); - vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex]; - gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0); + Rect r = rect_from_gsk (inRect); + vec2 pos = set_position_from_rect (r); outPos = pos; - - vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw, - rect.zw / inRect.zw); - texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy, - inTexRect.zw * texrect.zw); - outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex]; + outRect = r; + outTexCoord = scale_tex_coord (pos, r, inTexRect); }