[gtk+] vulkan: Generate clip shaders from same source
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] vulkan: Generate clip shaders from same source
- Date: Tue, 17 Jan 2017 05:20:16 +0000 (UTC)
commit 6bec7aae89fecb97c42d83ecee70b6888f699d4b
Author: Benjamin Otte <otte redhat com>
Date: Tue Jan 17 06:15:03 2017 +0100
vulkan: Generate clip shaders from same source
Instead of having 3 different shaders for the different clipping
versions, just have one shader and use a preprocessor define to use
different clip functions.
That preprocessor define is set in the Makefile.
Also use foo.frag and foo.vert as the file extensions instead of using
foo.frag.glsl and foo.vert.glsl, as that's what glslc suggests as
extension.
gsk/Makefile.am | 75 ++++++++-------
gsk/resources/vulkan/blend-clip.frag.glsl | 12 ---
gsk/resources/vulkan/blend-clip.frag.spv | Bin 632 -> 1328 bytes
gsk/resources/vulkan/blend-clip.vert.glsl | 32 ------
gsk/resources/vulkan/blend-clip.vert.spv | Bin 4788 -> 4868 bytes
.../{blend-clip-rounded.frag.glsl => blend.frag} | 1 -
gsk/resources/vulkan/blend.frag.spv | Bin 632 -> 1328 bytes
.../{blend-clip-rounded.vert.glsl => blend.vert} | 1 -
gsk/resources/vulkan/blend.vert.spv | Bin 1964 -> 3136 bytes
gsk/resources/vulkan/border-clip-rounded.frag.spv | Bin 10080 -> 10212 bytes
gsk/resources/vulkan/border-clip-rounded.vert.glsl | 103 --------------------
gsk/resources/vulkan/border-clip.frag.glsl | 23 -----
gsk/resources/vulkan/border-clip.frag.spv | Bin 9008 -> 9560 bytes
.../{border-clip-rounded.frag.glsl => border.frag} | 12 +--
gsk/resources/vulkan/border.frag.spv | Bin 9008 -> 9560 bytes
.../vulkan/{border-clip.vert.glsl => border.vert} | 1 -
gsk/resources/vulkan/border.vert.spv | Bin 7216 -> 7428 bytes
gsk/resources/vulkan/color-clip.frag.glsl | 10 --
gsk/resources/vulkan/color-clip.frag.spv | Bin 720 -> 1448 bytes
gsk/resources/vulkan/color-clip.vert.glsl | 28 ------
gsk/resources/vulkan/color-clip.vert.spv | Bin 3772 -> 3880 bytes
gsk/resources/vulkan/color-matrix-clip.frag.glsl | 31 ------
gsk/resources/vulkan/color-matrix-clip.frag.spv | Bin 2160 -> 2824 bytes
gsk/resources/vulkan/color-matrix-clip.vert.glsl | 38 -------
gsk/resources/vulkan/color-matrix-clip.vert.spv | Bin 5140 -> 5220 bytes
...ix-clip-rounded.frag.glsl => color-matrix.frag} | 1 -
gsk/resources/vulkan/color-matrix.frag.spv | Bin 2160 -> 2824 bytes
...ix-clip-rounded.vert.glsl => color-matrix.vert} | 1 -
gsk/resources/vulkan/color-matrix.vert.spv | Bin 2316 -> 3488 bytes
.../{color-clip-rounded.frag.glsl => color.frag} | 1 -
gsk/resources/vulkan/color.frag.spv | Bin 720 -> 1448 bytes
.../{color-clip-rounded.vert.glsl => color.vert} | 1 -
gsk/resources/vulkan/color.vert.spv | Bin 1780 -> 2148 bytes
gsk/resources/vulkan/linear-clip.frag.glsl | 33 ------
gsk/resources/vulkan/linear-clip.frag.spv | Bin 2320 -> 3032 bytes
gsk/resources/vulkan/linear-clip.vert.glsl | 75 --------------
gsk/resources/vulkan/linear-clip.vert.spv | Bin 7832 -> 7928 bytes
.../{linear-clip-rounded.frag.glsl => linear.frag} | 1 -
gsk/resources/vulkan/linear.frag.spv | Bin 2320 -> 3032 bytes
.../{linear-clip-rounded.vert.glsl => linear.vert} | 1 -
gsk/resources/vulkan/linear.vert.spv | Bin 6116 -> 6212 bytes
41 files changed, 42 insertions(+), 439 deletions(-)
---
diff --git a/gsk/Makefile.am b/gsk/Makefile.am
index 06ed18e..9d13253 100644
--- a/gsk/Makefile.am
+++ b/gsk/Makefile.am
@@ -62,39 +62,28 @@ gsk_private_vulkan_include_shaders = \
resources/vulkan/clip.vert.glsl \
resources/vulkan/constants.glsl \
resources/vulkan/rounded-rect.glsl
+gsk_private_vulkan_fragment_shaders = \
+ resources/vulkan/blend.frag \
+ resources/vulkan/border.frag \
+ resources/vulkan/color.frag \
+ resources/vulkan/color-matrix.frag \
+ resources/vulkan/linear.frag
+gsk_private_vulkan_vertex_shaders = \
+ resources/vulkan/blend.vert \
+ resources/vulkan/border.vert \
+ resources/vulkan/color.vert \
+ resources/vulkan/color-matrix.vert \
+ resources/vulkan/linear.vert
gsk_private_vulkan_shaders = \
- resources/vulkan/blend-clip.frag.glsl \
- resources/vulkan/blend-clip-rounded.frag.glsl \
- resources/vulkan/blend-clip-rounded.vert.glsl \
- resources/vulkan/blend-clip.vert.glsl \
- resources/vulkan/blend.frag.glsl \
- resources/vulkan/blend.vert.glsl \
- resources/vulkan/border-clip.frag.glsl \
- resources/vulkan/border-clip.vert.glsl \
- resources/vulkan/border-clip-rounded.frag.glsl \
- resources/vulkan/border-clip-rounded.vert.glsl \
- resources/vulkan/border.frag.glsl \
- resources/vulkan/border.vert.glsl \
- resources/vulkan/color-clip.frag.glsl \
- resources/vulkan/color-clip-rounded.frag.glsl \
- resources/vulkan/color-clip-rounded.vert.glsl \
- resources/vulkan/color-clip.vert.glsl \
- resources/vulkan/color.frag.glsl \
- resources/vulkan/color.vert.glsl \
- resources/vulkan/color-matrix-clip.frag.glsl \
- resources/vulkan/color-matrix-clip-rounded.frag.glsl \
- resources/vulkan/color-matrix-clip-rounded.vert.glsl \
- resources/vulkan/color-matrix-clip.vert.glsl \
- resources/vulkan/color-matrix.frag.glsl \
- resources/vulkan/color-matrix.vert.glsl \
- resources/vulkan/linear-clip.frag.glsl \
- resources/vulkan/linear-clip-rounded.frag.glsl \
- resources/vulkan/linear-clip-rounded.vert.glsl \
- resources/vulkan/linear-clip.vert.glsl \
- resources/vulkan/linear.frag.glsl \
- resources/vulkan/linear.vert.glsl
+ $(gsk_private_vulkan_fragment_shaders) \
+ $(gsk_private_vulkan_vertex_shaders)
gsk_private_vulkan_compiled_shaders = \
- $(gsk_private_vulkan_shaders:.glsl=.spv)
+ $(gsk_private_vulkan_fragment_shaders:.frag=.frag.spv) \
+ $(gsk_private_vulkan_vertex_shaders:.vert=.vert.spv) \
+ $(gsk_private_vulkan_fragment_shaders:.frag=-clip.frag.spv) \
+ $(gsk_private_vulkan_vertex_shaders:.vert=-clip.vert.spv) \
+ $(gsk_private_vulkan_fragment_shaders:.frag=-clip-rounded.frag.spv) \
+ $(gsk_private_vulkan_vertex_shaders:.vert=-clip-rounded.vert.spv)
endif
gsk_public_source_h = \
@@ -180,13 +169,29 @@ resource_files = \
$(gsk_private_vulkan_compiled_shaders) \
$(gsk_private_vulkan_shaders)
-resources/vulkan/%.frag.spv: resources/vulkan/%.frag.glsl
+resources/vulkan/%-clip-rounded.frag.spv: resources/vulkan/%.frag
@if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
- $(AM_V_GEN) $(GLSLC) -fshader-stage=fragment -o $@.tmp $< && mv $@.tmp $@
+ $(AM_V_GEN) $(GLSLC) -fshader-stage=fragment -DCLIP_ROUNDED_RECT -o $@.tmp $< && mv $@.tmp $@
-resources/vulkan/%.vert.spv: resources/vulkan/%.vert.glsl
+resources/vulkan/%-clip-rounded.vert.spv: resources/vulkan/%.vert
@if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
- $(AM_V_GEN) $(GLSLC) -fshader-stage=vertex -o $@.tmp $< && mv $@.tmp $@
+ $(AM_V_GEN) $(GLSLC) -fshader-stage=vertex -DCLIP_ROUNDED_RECT -o $@.tmp $< && mv $@.tmp $@
+
+resources/vulkan/%-clip.frag.spv: resources/vulkan/%.frag
+ @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
+ $(AM_V_GEN) $(GLSLC) -fshader-stage=fragment -DCLIP_RECT -o $@.tmp $< && mv $@.tmp $@
+
+resources/vulkan/%-clip.vert.spv: resources/vulkan/%.vert
+ @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
+ $(AM_V_GEN) $(GLSLC) -fshader-stage=vertex -DCLIP_RECT -o $@.tmp $< && mv $@.tmp $@
+
+resources/vulkan/%.frag.spv: resources/vulkan/%.frag
+ @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
+ $(AM_V_GEN) $(GLSLC) -fshader-stage=fragment -DCLIP_NONE -o $@.tmp $< && mv $@.tmp $@
+
+resources/vulkan/%.vert.spv: resources/vulkan/%.vert
+ @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
+ $(AM_V_GEN) $(GLSLC) -fshader-stage=vertex -DCLIP_NONE -o $@.tmp $< && mv $@.tmp $@
gsk.resources.xml: Makefile.am
$(AM_V_GEN) echo "<?xml version='1.0' encoding='UTF-8'?>" > $@; \
diff --git a/gsk/resources/vulkan/blend-clip.frag.spv b/gsk/resources/vulkan/blend-clip.frag.spv
index ef5dc6b..9d337c7 100644
Binary files a/gsk/resources/vulkan/blend-clip.frag.spv and b/gsk/resources/vulkan/blend-clip.frag.spv differ
diff --git a/gsk/resources/vulkan/blend-clip.vert.spv b/gsk/resources/vulkan/blend-clip.vert.spv
index c8840cd..cb6a9da 100644
Binary files a/gsk/resources/vulkan/blend-clip.vert.spv and b/gsk/resources/vulkan/blend-clip.vert.spv differ
diff --git a/gsk/resources/vulkan/blend-clip-rounded.frag.glsl b/gsk/resources/vulkan/blend.frag
similarity index 91%
rename from gsk/resources/vulkan/blend-clip-rounded.frag.glsl
rename to gsk/resources/vulkan/blend.frag
index 81bd003..ee9eb45 100644
--- a/gsk/resources/vulkan/blend-clip-rounded.frag.glsl
+++ b/gsk/resources/vulkan/blend.frag
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_ROUNDED_RECT
#include "clip.frag.glsl"
layout(location = 0) in vec2 inPos;
diff --git a/gsk/resources/vulkan/blend.frag.spv b/gsk/resources/vulkan/blend.frag.spv
index 9dcff6d..9d337c7 100644
Binary files a/gsk/resources/vulkan/blend.frag.spv and b/gsk/resources/vulkan/blend.frag.spv differ
diff --git a/gsk/resources/vulkan/blend-clip-rounded.vert.glsl b/gsk/resources/vulkan/blend.vert
similarity index 97%
rename from gsk/resources/vulkan/blend-clip-rounded.vert.glsl
rename to gsk/resources/vulkan/blend.vert
index fadf4b9..c9bbb40 100644
--- a/gsk/resources/vulkan/blend-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/blend.vert
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_ROUNDED_RECT
#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
diff --git a/gsk/resources/vulkan/blend.vert.spv b/gsk/resources/vulkan/blend.vert.spv
index 962a1b4..e814653 100644
Binary files a/gsk/resources/vulkan/blend.vert.spv and b/gsk/resources/vulkan/blend.vert.spv differ
diff --git a/gsk/resources/vulkan/border-clip-rounded.frag.spv
b/gsk/resources/vulkan/border-clip-rounded.frag.spv
index 3be5443..690c02b 100644
Binary files a/gsk/resources/vulkan/border-clip-rounded.frag.spv and
b/gsk/resources/vulkan/border-clip-rounded.frag.spv differ
diff --git a/gsk/resources/vulkan/border-clip.frag.spv b/gsk/resources/vulkan/border-clip.frag.spv
index ab43d3d..1a3fda7 100644
Binary files a/gsk/resources/vulkan/border-clip.frag.spv and b/gsk/resources/vulkan/border-clip.frag.spv
differ
diff --git a/gsk/resources/vulkan/border-clip-rounded.frag.glsl b/gsk/resources/vulkan/border.frag
similarity index 72%
rename from gsk/resources/vulkan/border-clip-rounded.frag.glsl
rename to gsk/resources/vulkan/border.frag
index d31718a..988b1f6 100644
--- a/gsk/resources/vulkan/border-clip-rounded.frag.glsl
+++ b/gsk/resources/vulkan/border.frag
@@ -1,6 +1,6 @@
#version 420 core
-#include "constants.glsl"
+#include "clip.frag.glsl"
#include "rounded-rect.glsl"
layout(location = 0) in vec2 inPos;
@@ -12,14 +12,6 @@ layout(location = 5) in vec4 inBorderWidths;
layout(location = 0) out vec4 color;
-vec4
-clip (vec4 color)
-{
- RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw),
push.clip_widths, push.clip_heights);
-
- return color * rounded_rect_coverage (r, inPos);
-}
-
void main()
{
RoundedRect routside = RoundedRect (vec4(inRect.xy, inRect.xy + inRect.zw), inCornerWidths,
inCornerHeights);
@@ -28,5 +20,5 @@ void main()
float alpha = clamp (rounded_rect_coverage (routside, inPos) -
rounded_rect_coverage (rinside, inPos),
0.0, 1.0);
- color = clip (inColor);
+ color = clip (inPos, inColor * alpha);
}
diff --git a/gsk/resources/vulkan/border.frag.spv b/gsk/resources/vulkan/border.frag.spv
index ab43d3d..1a3fda7 100644
Binary files a/gsk/resources/vulkan/border.frag.spv and b/gsk/resources/vulkan/border.frag.spv differ
diff --git a/gsk/resources/vulkan/border-clip.vert.glsl b/gsk/resources/vulkan/border.vert
similarity index 99%
rename from gsk/resources/vulkan/border-clip.vert.glsl
rename to gsk/resources/vulkan/border.vert
index 8e0fc83..b37ea9e 100644
--- a/gsk/resources/vulkan/border-clip.vert.glsl
+++ b/gsk/resources/vulkan/border.vert
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_RECT
#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
diff --git a/gsk/resources/vulkan/border.vert.spv b/gsk/resources/vulkan/border.vert.spv
index 6a6cf93..dfa95f1 100644
Binary files a/gsk/resources/vulkan/border.vert.spv and b/gsk/resources/vulkan/border.vert.spv differ
diff --git a/gsk/resources/vulkan/color-clip.frag.spv b/gsk/resources/vulkan/color-clip.frag.spv
index 29bbae9..d3ef64e 100644
Binary files a/gsk/resources/vulkan/color-clip.frag.spv and b/gsk/resources/vulkan/color-clip.frag.spv differ
diff --git a/gsk/resources/vulkan/color-clip.vert.spv b/gsk/resources/vulkan/color-clip.vert.spv
index 0b2711b..daaf33a 100644
Binary files a/gsk/resources/vulkan/color-clip.vert.spv and b/gsk/resources/vulkan/color-clip.vert.spv differ
diff --git a/gsk/resources/vulkan/color-matrix-clip.frag.spv b/gsk/resources/vulkan/color-matrix-clip.frag.spv
index 266c877..ec29f26 100644
Binary files a/gsk/resources/vulkan/color-matrix-clip.frag.spv and
b/gsk/resources/vulkan/color-matrix-clip.frag.spv differ
diff --git a/gsk/resources/vulkan/color-matrix-clip.vert.spv b/gsk/resources/vulkan/color-matrix-clip.vert.spv
index 20b615e..f4951f6 100644
Binary files a/gsk/resources/vulkan/color-matrix-clip.vert.spv and
b/gsk/resources/vulkan/color-matrix-clip.vert.spv differ
diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl b/gsk/resources/vulkan/color-matrix.frag
similarity index 96%
rename from gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl
rename to gsk/resources/vulkan/color-matrix.frag
index 88057c7..00b7947 100644
--- a/gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl
+++ b/gsk/resources/vulkan/color-matrix.frag
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_ROUNDED_RECT
#include "clip.frag.glsl"
layout(location = 0) in vec2 inPos;
diff --git a/gsk/resources/vulkan/color-matrix.frag.spv b/gsk/resources/vulkan/color-matrix.frag.spv
index 266c877..ec29f26 100644
Binary files a/gsk/resources/vulkan/color-matrix.frag.spv and b/gsk/resources/vulkan/color-matrix.frag.spv
differ
diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl b/gsk/resources/vulkan/color-matrix.vert
similarity index 97%
rename from gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl
rename to gsk/resources/vulkan/color-matrix.vert
index 3888b7e..eb3f4fa 100644
--- a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/color-matrix.vert
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_ROUNDED_RECT
#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
diff --git a/gsk/resources/vulkan/color-matrix.vert.spv b/gsk/resources/vulkan/color-matrix.vert.spv
index fa89276..89176d4 100644
Binary files a/gsk/resources/vulkan/color-matrix.vert.spv and b/gsk/resources/vulkan/color-matrix.vert.spv
differ
diff --git a/gsk/resources/vulkan/color-clip-rounded.frag.glsl b/gsk/resources/vulkan/color.frag
similarity index 90%
rename from gsk/resources/vulkan/color-clip-rounded.frag.glsl
rename to gsk/resources/vulkan/color.frag
index b66001c..6b299df 100644
--- a/gsk/resources/vulkan/color-clip-rounded.frag.glsl
+++ b/gsk/resources/vulkan/color.frag
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_ROUNDED_RECT
#include "clip.frag.glsl"
layout(location = 0) in vec2 inPos;
diff --git a/gsk/resources/vulkan/color.frag.spv b/gsk/resources/vulkan/color.frag.spv
index 29bbae9..d3ef64e 100644
Binary files a/gsk/resources/vulkan/color.frag.spv and b/gsk/resources/vulkan/color.frag.spv differ
diff --git a/gsk/resources/vulkan/color-clip-rounded.vert.glsl b/gsk/resources/vulkan/color.vert
similarity index 96%
rename from gsk/resources/vulkan/color-clip-rounded.vert.glsl
rename to gsk/resources/vulkan/color.vert
index 7f7a1e9..ce85ea7 100644
--- a/gsk/resources/vulkan/color-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/color.vert
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_ROUNDED_RECT
#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
diff --git a/gsk/resources/vulkan/color.vert.spv b/gsk/resources/vulkan/color.vert.spv
index 05d74a6..4a0b396 100644
Binary files a/gsk/resources/vulkan/color.vert.spv and b/gsk/resources/vulkan/color.vert.spv differ
diff --git a/gsk/resources/vulkan/linear-clip.frag.spv b/gsk/resources/vulkan/linear-clip.frag.spv
index a95b58f..86f9ea0 100644
Binary files a/gsk/resources/vulkan/linear-clip.frag.spv and b/gsk/resources/vulkan/linear-clip.frag.spv
differ
diff --git a/gsk/resources/vulkan/linear-clip.vert.spv b/gsk/resources/vulkan/linear-clip.vert.spv
index 74b8230..9124ffb 100644
Binary files a/gsk/resources/vulkan/linear-clip.vert.spv and b/gsk/resources/vulkan/linear-clip.vert.spv
differ
diff --git a/gsk/resources/vulkan/linear-clip-rounded.frag.glsl b/gsk/resources/vulkan/linear.frag
similarity index 97%
rename from gsk/resources/vulkan/linear-clip-rounded.frag.glsl
rename to gsk/resources/vulkan/linear.frag
index 1fbf095..cb7727f 100644
--- a/gsk/resources/vulkan/linear-clip-rounded.frag.glsl
+++ b/gsk/resources/vulkan/linear.frag
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_ROUNDED_RECT
#include "clip.frag.glsl"
struct ColorStop {
diff --git a/gsk/resources/vulkan/linear.frag.spv b/gsk/resources/vulkan/linear.frag.spv
index a95b58f..86f9ea0 100644
Binary files a/gsk/resources/vulkan/linear.frag.spv and b/gsk/resources/vulkan/linear.frag.spv differ
diff --git a/gsk/resources/vulkan/linear-clip-rounded.vert.glsl b/gsk/resources/vulkan/linear.vert
similarity index 98%
rename from gsk/resources/vulkan/linear-clip-rounded.vert.glsl
rename to gsk/resources/vulkan/linear.vert
index b574def..f9fd57c 100644
--- a/gsk/resources/vulkan/linear-clip-rounded.vert.glsl
+++ b/gsk/resources/vulkan/linear.vert
@@ -1,6 +1,5 @@
#version 420 core
-#define CLIP_ROUNDED_RECT
#include "clip.vert.glsl"
struct ColorStop {
diff --git a/gsk/resources/vulkan/linear.vert.spv b/gsk/resources/vulkan/linear.vert.spv
index 8a40b6d..bcc3fcf 100644
Binary files a/gsk/resources/vulkan/linear.vert.spv and b/gsk/resources/vulkan/linear.vert.spv differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]