summaryrefslogtreecommitdiff
path: root/gsk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-01-17 05:50:52 +0100
committerBenjamin Otte <otte@redhat.com>2017-01-17 06:17:55 +0100
commit3768c676c6e90daebaf208a0fdbffa78d210fc56 (patch)
tree095e3ace0e76a736c18877999e5843fdbbd028bf /gsk
parentcf65443fb3102e7d128fbb22ce3187feb52b9b2c (diff)
downloadgtk+-3768c676c6e90daebaf208a0fdbffa78d210fc56.tar.gz
vulkan: Add clip.vert.glsl
Implement clipping the same way as in the last commit for the fragment shaders.
Diffstat (limited to 'gsk')
-rw-r--r--gsk/Makefile.am1
-rw-r--r--gsk/resources/vulkan/blend-clip-rounded.vert.glsl15
-rw-r--r--gsk/resources/vulkan/blend-clip-rounded.vert.spvbin4684 -> 4868 bytes
-rw-r--r--gsk/resources/vulkan/blend-clip.vert.glsl15
-rw-r--r--gsk/resources/vulkan/blend-clip.vert.spvbin4604 -> 4788 bytes
-rw-r--r--gsk/resources/vulkan/border-clip-rounded.vert.glsl15
-rw-r--r--gsk/resources/vulkan/border-clip-rounded.vert.spvbin8952 -> 9136 bytes
-rw-r--r--gsk/resources/vulkan/border-clip.vert.glsl15
-rw-r--r--gsk/resources/vulkan/border-clip.vert.spvbin8952 -> 9136 bytes
-rw-r--r--gsk/resources/vulkan/clip.vert.glsl36
-rw-r--r--gsk/resources/vulkan/color-clip-rounded.vert.glsl7
-rw-r--r--gsk/resources/vulkan/color-clip-rounded.vert.spvbin1888 -> 3880 bytes
-rw-r--r--gsk/resources/vulkan/color-clip.vert.glsl15
-rw-r--r--gsk/resources/vulkan/color-clip.vert.spvbin3588 -> 3772 bytes
-rw-r--r--gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl15
-rw-r--r--gsk/resources/vulkan/color-matrix-clip-rounded.vert.spvbin5036 -> 5220 bytes
-rw-r--r--gsk/resources/vulkan/color-matrix-clip.vert.glsl15
-rw-r--r--gsk/resources/vulkan/color-matrix-clip.vert.spvbin4956 -> 5140 bytes
-rw-r--r--gsk/resources/vulkan/linear-clip-rounded.vert.glsl6
-rw-r--r--gsk/resources/vulkan/linear-clip-rounded.vert.spvbin5952 -> 7928 bytes
-rw-r--r--gsk/resources/vulkan/linear-clip.vert.glsl6
-rw-r--r--gsk/resources/vulkan/linear-clip.vert.spvbin5856 -> 7832 bytes
-rw-r--r--gsk/resources/vulkan/linear.vert.glsl15
-rw-r--r--gsk/resources/vulkan/linear.vert.spvbin7648 -> 6116 bytes
24 files changed, 74 insertions, 102 deletions
diff --git a/gsk/Makefile.am b/gsk/Makefile.am
index dd480bfa4e..06ed18e97e 100644
--- a/gsk/Makefile.am
+++ b/gsk/Makefile.am
@@ -59,6 +59,7 @@ gsk_private_vulkan_source_c = \
gskvulkanshader.c
gsk_private_vulkan_include_shaders = \
resources/vulkan/clip.frag.glsl \
+ resources/vulkan/clip.vert.glsl \
resources/vulkan/constants.glsl \
resources/vulkan/rounded-rect.glsl
gsk_private_vulkan_shaders = \
diff --git a/gsk/resources/vulkan/blend-clip-rounded.vert.glsl b/gsk/resources/vulkan/blend-clip-rounded.vert.glsl
index 0a5f31d79c..fadf4b9247 100644
--- a/gsk/resources/vulkan/blend-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/blend-clip-rounded.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
@@ -19,18 +20,8 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
diff --git a/gsk/resources/vulkan/blend-clip-rounded.vert.spv b/gsk/resources/vulkan/blend-clip-rounded.vert.spv
index bc82237ef5..cb6a9dadbb 100644
--- a/gsk/resources/vulkan/blend-clip-rounded.vert.spv
+++ b/gsk/resources/vulkan/blend-clip-rounded.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/blend-clip.vert.glsl b/gsk/resources/vulkan/blend-clip.vert.glsl
index b1c622bea2..88ad7c75e6 100644
--- a/gsk/resources/vulkan/blend-clip.vert.glsl
+++ b/gsk/resources/vulkan/blend-clip.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
@@ -18,18 +19,8 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
diff --git a/gsk/resources/vulkan/blend-clip.vert.spv b/gsk/resources/vulkan/blend-clip.vert.spv
index 494f916537..c8840cd5b8 100644
--- a/gsk/resources/vulkan/blend-clip.vert.spv
+++ b/gsk/resources/vulkan/blend-clip.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/border-clip-rounded.vert.glsl b/gsk/resources/vulkan/border-clip-rounded.vert.glsl
index 8db91a58a4..ed11255ad5 100644
--- a/gsk/resources/vulkan/border-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/border-clip-rounded.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inCornerWidths;
@@ -45,16 +46,6 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
#define SLICE_BOTTOM_LEFT 6
#define SLICE_LEFT 7
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
int slice_index = gl_VertexIndex / 6;
int vert_index = gl_VertexIndex % 6;
@@ -96,7 +87,7 @@ void main() {
break;
}
- rect = intersect (rect, push.clip_bounds);
+ rect = clip (rect);
vec2 pos;
if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
pos = rect.xy + rect.zw * offsets[vert_index];
diff --git a/gsk/resources/vulkan/border-clip-rounded.vert.spv b/gsk/resources/vulkan/border-clip-rounded.vert.spv
index ce5e85e3dc..50ce2a23af 100644
--- a/gsk/resources/vulkan/border-clip-rounded.vert.spv
+++ b/gsk/resources/vulkan/border-clip-rounded.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/border-clip.vert.glsl b/gsk/resources/vulkan/border-clip.vert.glsl
index 8db91a58a4..8e0fc8375e 100644
--- a/gsk/resources/vulkan/border-clip.vert.glsl
+++ b/gsk/resources/vulkan/border-clip.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inCornerWidths;
@@ -45,16 +46,6 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
#define SLICE_BOTTOM_LEFT 6
#define SLICE_LEFT 7
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
int slice_index = gl_VertexIndex / 6;
int vert_index = gl_VertexIndex % 6;
@@ -96,7 +87,7 @@ void main() {
break;
}
- rect = intersect (rect, push.clip_bounds);
+ rect = clip (rect);
vec2 pos;
if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
pos = rect.xy + rect.zw * offsets[vert_index];
diff --git a/gsk/resources/vulkan/border-clip.vert.spv b/gsk/resources/vulkan/border-clip.vert.spv
index ce5e85e3dc..50ce2a23af 100644
--- a/gsk/resources/vulkan/border-clip.vert.spv
+++ b/gsk/resources/vulkan/border-clip.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/clip.vert.glsl b/gsk/resources/vulkan/clip.vert.glsl
new file mode 100644
index 0000000000..0dce1a0fb7
--- /dev/null
+++ b/gsk/resources/vulkan/clip.vert.glsl
@@ -0,0 +1,36 @@
+#include "constants.glsl"
+
+#ifndef _CLIP_
+#define _CLIP_
+
+vec4 intersect(vec4 a, vec4 b)
+{
+ a = vec4(a.xy, a.xy + a.zw);
+ b = vec4(b.xy, b.xy + b.zw);
+ vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
+ if (any (greaterThanEqual (result.xy, result.zw)))
+ return vec4(0.0,0.0,0.0,0.0);
+ return vec4(result.xy, result.zw - result.xy);
+}
+
+#ifdef CLIP_ROUNDED_RECT
+vec4 clip(vec4 rect)
+{
+ /* rounded corner clipping is done in fragment shader */
+ return intersect(rect, push.clip_bounds);
+}
+#elif defined(CLIP_RECT)
+vec4 clip(vec4 rect)
+{
+ return intersect(rect, push.clip_bounds);
+}
+#elif defined(CLIP_NONE)
+vec4 clip(vec4 rect)
+{
+ return rect;
+}
+#else
+#error "No clipping define given. Need CLIP_NONE, CLIP_RECT or CLIP_ROUNDED_RECT"
+#endif
+
+#endif
diff --git a/gsk/resources/vulkan/color-clip-rounded.vert.glsl b/gsk/resources/vulkan/color-clip-rounded.vert.glsl
index 985a174f97..7f7a1e9226 100644
--- a/gsk/resources/vulkan/color-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/color-clip-rounded.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inColor;
@@ -20,7 +21,9 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 1.0) };
void main() {
- vec2 pos = inRect.xy + inRect.zw * offsets[gl_VertexIndex];
+ vec4 rect = clip (inRect);
+
+ vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outColor = inColor;
diff --git a/gsk/resources/vulkan/color-clip-rounded.vert.spv b/gsk/resources/vulkan/color-clip-rounded.vert.spv
index 941189cf44..daaf33aa22 100644
--- a/gsk/resources/vulkan/color-clip-rounded.vert.spv
+++ b/gsk/resources/vulkan/color-clip-rounded.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/color-clip.vert.glsl b/gsk/resources/vulkan/color-clip.vert.glsl
index 724cee1cdd..a869b8a625 100644
--- a/gsk/resources/vulkan/color-clip.vert.glsl
+++ b/gsk/resources/vulkan/color-clip.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inColor;
@@ -18,18 +19,8 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
diff --git a/gsk/resources/vulkan/color-clip.vert.spv b/gsk/resources/vulkan/color-clip.vert.spv
index c07e45f6e3..0b2711b2d1 100644
--- a/gsk/resources/vulkan/color-clip.vert.spv
+++ b/gsk/resources/vulkan/color-clip.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl
index 1c7f0a4342..3888b7e460 100644
--- a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
@@ -23,18 +24,8 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.spv b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.spv
index 14b85f53ee..f4951f6530 100644
--- a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.spv
+++ b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/color-matrix-clip.vert.glsl b/gsk/resources/vulkan/color-matrix-clip.vert.glsl
index 7f9b77840a..6ae0817157 100644
--- a/gsk/resources/vulkan/color-matrix-clip.vert.glsl
+++ b/gsk/resources/vulkan/color-matrix-clip.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
@@ -22,18 +23,8 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
diff --git a/gsk/resources/vulkan/color-matrix-clip.vert.spv b/gsk/resources/vulkan/color-matrix-clip.vert.spv
index 84c384622e..20b615e67b 100644
--- a/gsk/resources/vulkan/color-matrix-clip.vert.spv
+++ b/gsk/resources/vulkan/color-matrix-clip.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/linear-clip-rounded.vert.glsl b/gsk/resources/vulkan/linear-clip-rounded.vert.glsl
index fd50e26f55..b574defc26 100644
--- a/gsk/resources/vulkan/linear-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/linear-clip-rounded.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
struct ColorStop {
float offset;
@@ -50,7 +51,8 @@ get_gradient_pos (vec2 pos)
}
void main() {
- vec2 pos = inRect.xy + inRect.zw * offsets[gl_VertexIndex];
+ vec4 rect = clip (inRect);
+ vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outGradientPos = get_gradient_pos (pos);
diff --git a/gsk/resources/vulkan/linear-clip-rounded.vert.spv b/gsk/resources/vulkan/linear-clip-rounded.vert.spv
index 421516f7ef..9124ffbe41 100644
--- a/gsk/resources/vulkan/linear-clip-rounded.vert.spv
+++ b/gsk/resources/vulkan/linear-clip-rounded.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/linear-clip.vert.glsl b/gsk/resources/vulkan/linear-clip.vert.glsl
index 4ec7f2ead7..117642080e 100644
--- a/gsk/resources/vulkan/linear-clip.vert.glsl
+++ b/gsk/resources/vulkan/linear-clip.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
struct ColorStop {
float offset;
@@ -49,7 +50,8 @@ get_gradient_pos (vec2 pos)
}
void main() {
- vec2 pos = inRect.xy + inRect.zw * offsets[gl_VertexIndex];
+ vec4 rect = clip (inRect);
+ vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outGradientPos = get_gradient_pos (pos);
outRepeating = inRepeating;
diff --git a/gsk/resources/vulkan/linear-clip.vert.spv b/gsk/resources/vulkan/linear-clip.vert.spv
index e7d4cf6dac..74b823059e 100644
--- a/gsk/resources/vulkan/linear-clip.vert.spv
+++ b/gsk/resources/vulkan/linear-clip.vert.spv
Binary files differ
diff --git a/gsk/resources/vulkan/linear.vert.glsl b/gsk/resources/vulkan/linear.vert.glsl
index 7a55c61380..5a7874c2b1 100644
--- a/gsk/resources/vulkan/linear.vert.glsl
+++ b/gsk/resources/vulkan/linear.vert.glsl
@@ -1,6 +1,7 @@
#version 420 core
-#include "constants.glsl"
+#define CLIP_NONE
+#include "clip.vert.glsl"
struct ColorStop {
float offset;
@@ -39,16 +40,6 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
float
get_gradient_pos (vec2 pos)
{
@@ -59,7 +50,7 @@ get_gradient_pos (vec2 pos)
}
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outGradientPos = get_gradient_pos (pos);
diff --git a/gsk/resources/vulkan/linear.vert.spv b/gsk/resources/vulkan/linear.vert.spv
index f2b120f9e6..8a40b6d17d 100644
--- a/gsk/resources/vulkan/linear.vert.spv
+++ b/gsk/resources/vulkan/linear.vert.spv
Binary files differ