From 1916755b6b3f84329c3e3f3e9a4e1b6d2b4e45a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 23 Nov 2020 00:43:59 +0100 Subject: [PATCH] Limit border radius to max dimension in `quad` pipeline --- glow/src/shader/quad.vert | 5 +++++ wgpu/src/shader/quad.vert | 5 +++++ wgpu/src/shader/quad.vert.spv | Bin 3372 -> 3604 bytes 3 files changed, 10 insertions(+) diff --git a/glow/src/shader/quad.vert b/glow/src/shader/quad.vert index d37b5c8d..82417856 100644 --- a/glow/src/shader/quad.vert +++ b/glow/src/shader/quad.vert @@ -29,6 +29,11 @@ void main() { vec2 p_Pos = i_Pos * u_Scale; vec2 p_Scale = i_Scale * u_Scale; + float i_BorderRadius = min( + i_BorderRadius, + min(i_Scale.x, i_Scale.y) / 2.0 + ); + mat4 i_Transform = mat4( vec4(p_Scale.x + 1.0, 0.0, 0.0, 0.0), vec4(0.0, p_Scale.y + 1.0, 0.0, 0.0), diff --git a/wgpu/src/shader/quad.vert b/wgpu/src/shader/quad.vert index 1d9a4fd2..09a278b1 100644 --- a/wgpu/src/shader/quad.vert +++ b/wgpu/src/shader/quad.vert @@ -24,6 +24,11 @@ void main() { vec2 p_Pos = i_Pos * u_Scale; vec2 p_Scale = i_Scale * u_Scale; + float i_BorderRadius = min( + i_BorderRadius, + min(i_Scale.x, i_Scale.y) / 2.0 + ); + mat4 i_Transform = mat4( vec4(p_Scale.x + 1.0, 0.0, 0.0, 0.0), vec4(0.0, p_Scale.y + 1.0, 0.0, 0.0), diff --git a/wgpu/src/shader/quad.vert.spv b/wgpu/src/shader/quad.vert.spv index 7059b51bc4575638f541d299aa07e0a12e4f6599..fa71ba1e0a7ad7b811e3d52bb1c7013051410aa8 100644 GIT binary patch literal 3604 zcmZXVYjYG;5Qc|j6A%!Dgo}!p0A4{r1w;@M5;Rd!13^H%Y&K+pfh7}nH;8zHvaIrx zRr-_sRerI`=b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