[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin/fredrik/vulkan] /: Add Vulkan versions of the core shaders
From:       Fredrik_Höglund <null () kde ! org>
Date:       2018-02-16 17:01:48
Message-ID: E1emjOO-0004Yx-BO () code ! kde ! org
[Download RAW message or body]

Git commit 4697de4c766ed17af2d31cc692245692069958b6 by Fredrik Höglund.
Committed on 16/02/2018 at 16:58.
Pushed by fredrik into branch 'fredrik/vulkan'.

Add Vulkan versions of the core shaders

The SPIR-V binaries are committed to the respository along with the
source files to avoid having a compile time dependency on an external
shader compiler.

M  +12   -0    resources.qrc
A  +16   -0    shaders/vulkan/Makefile
A  +-    --    shaders/vulkan/color_frag.spv
A  +-    --    shaders/vulkan/color_vert.spv
A  +-    --    shaders/vulkan/crossfade_frag.spv
A  +-    --    shaders/vulkan/crossfade_vert.spv
A  +-    --    shaders/vulkan/desaturate_frag.spv
A  +-    --    shaders/vulkan/modulate_frag.spv
A  +13   -0    shaders/vulkan/source/color.frag
A  +17   -0    shaders/vulkan/source/color.vert
A  +24   -0    shaders/vulkan/source/crossfade.frag
A  +26   -0    shaders/vulkan/source/crossfade.vert
A  +22   -0    shaders/vulkan/source/desaturate.frag
A  +18   -0    shaders/vulkan/source/modulate.frag
A  +18   -0    shaders/vulkan/source/texture.frag
A  +24   -0    shaders/vulkan/source/texture.vert
A  +16   -0    shaders/vulkan/source/updatedecoration.frag
A  +16   -0    shaders/vulkan/source/updatedecoration.vert
A  +-    --    shaders/vulkan/texture_frag.spv
A  +-    --    shaders/vulkan/texture_vert.spv
A  +-    --    shaders/vulkan/updatedecoration_frag.spv
A  +-    --    shaders/vulkan/updatedecoration_vert.spv

https://commits.kde.org/kwin/4697de4c766ed17af2d31cc692245692069958b6

diff --git a/resources.qrc b/resources.qrc
index 11616caf0..c5fbe18d2 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -3,5 +3,17 @@
   <file>shaders/1.10/lanczos-fragment.glsl</file>
 
   <file>shaders/1.40/lanczos-fragment.glsl</file>
+
+  <file>shaders/vulkan/color_vert.spv</file>
+  <file>shaders/vulkan/texture_vert.spv</file>
+  <file>shaders/vulkan/crossfade_vert.spv</file>
+  <file>shaders/vulkan/updatedecoration_vert.spv</file>
+  <file>shaders/vulkan/color_frag.spv</file>
+  <file>shaders/vulkan/texture_frag.spv</file>
+  <file>shaders/vulkan/modulate_frag.spv</file>
+  <file>shaders/vulkan/desaturate_frag.spv</file>
+  <file>shaders/vulkan/crossfade_frag.spv</file>
+  <file>shaders/vulkan/updatedecoration_frag.spv</file>
+
   </qresource>
 </RCC>
diff --git a/shaders/vulkan/Makefile b/shaders/vulkan/Makefile
new file mode 100644
index 000000000..89ed9f3c5
--- /dev/null
+++ b/shaders/vulkan/Makefile
@@ -0,0 +1,16 @@
+GLSLC = glslc
+GLSLFLAGS = -std=460core --target-env=vulkan
+
+TARGETS = $(patsubst source/%.vert,%_vert.spv,$(wildcard source/*.vert)) \
+          $(patsubst source/%.frag,%_frag.spv,$(wildcard source/*.frag))
+
+all: ${TARGETS}
+
+%_vert.spv: source/%.vert
+	${GLSLC} ${GLSLFLAGS} $< -o $@
+
+%_frag.spv: source/%.frag
+	${GLSLC} ${GLSLFLAGS} $< -o $@
+
+clean:
+	rm *.spv
diff --git a/shaders/vulkan/color_frag.spv b/shaders/vulkan/color_frag.spv
new file mode 100644
index 000000000..1aa1f6423
Binary files /dev/null and b/shaders/vulkan/color_frag.spv differ
diff --git a/shaders/vulkan/color_vert.spv b/shaders/vulkan/color_vert.spv
new file mode 100644
index 000000000..d86d76f1f
Binary files /dev/null and b/shaders/vulkan/color_vert.spv differ
diff --git a/shaders/vulkan/crossfade_frag.spv b/shaders/vulkan/crossfade_frag.spv
new file mode 100644
index 000000000..5bf8e6102
Binary files /dev/null and b/shaders/vulkan/crossfade_frag.spv differ
diff --git a/shaders/vulkan/crossfade_vert.spv b/shaders/vulkan/crossfade_vert.spv
new file mode 100644
index 000000000..1dc0e3e68
Binary files /dev/null and b/shaders/vulkan/crossfade_vert.spv differ
diff --git a/shaders/vulkan/desaturate_frag.spv b/shaders/vulkan/desaturate_frag.spv
new file mode 100644
index 000000000..fa763453f
Binary files /dev/null and b/shaders/vulkan/desaturate_frag.spv differ
diff --git a/shaders/vulkan/modulate_frag.spv b/shaders/vulkan/modulate_frag.spv
new file mode 100644
index 000000000..1355437ae
Binary files /dev/null and b/shaders/vulkan/modulate_frag.spv differ
diff --git a/shaders/vulkan/source/color.frag b/shaders/vulkan/source/color.frag
new file mode 100644
index 000000000..f97ce2ce3
--- /dev/null
+++ b/shaders/vulkan/source/color.frag
@@ -0,0 +1,13 @@
+#version 460 core
+
+layout (location = 0) out vec4 fragColor;
+
+layout (set = 0, binding = 0) uniform UBO {
+    mat4 modelViewProjectionMatrix;
+    vec4 color;
+};
+
+void main(void)
+{
+    fragColor = color;
+}
diff --git a/shaders/vulkan/source/color.vert b/shaders/vulkan/source/color.vert
new file mode 100644
index 000000000..733231e43
--- /dev/null
+++ b/shaders/vulkan/source/color.vert
@@ -0,0 +1,17 @@
+#version 460 core
+
+layout (location = 0) in vec4 position;
+
+out gl_PerVertex {
+    vec4 gl_Position;
+};
+
+layout (set = 0, binding = 0) uniform UBO {
+    mat4 modelViewProjectionMatrix;
+    vec4 color;
+};
+
+void main(void)
+{
+    gl_Position = modelViewProjectionMatrix * position;
+}
diff --git a/shaders/vulkan/source/crossfade.frag b/shaders/vulkan/source/crossfade.frag
new file mode 100644
index 000000000..f1cfc7824
--- /dev/null
+++ b/shaders/vulkan/source/crossfade.frag
@@ -0,0 +1,24 @@
+#version 460 core
+
+layout (set = 0, binding = 0) uniform texture2D tex[2];
+layout (set = 0, binding = 1) uniform sampler samp;
+
+layout (set = 0, binding = 2) uniform UBO {
+    mat4 modelViewProjectionMatrix;
+    vec4 modulation;
+    float saturation;
+    float crossFadeProgress;
+};
+
+layout (location = 0) in vec2 texcoord0;
+layout (location = 1) in vec2 texcoord1;
+
+layout (location = 0) out vec4 fragColor;
+
+void main(void)
+{
+    vec4 texel0 = texture(sampler2D(tex[0], samp), texcoord0);
+    vec4 texel1 = texture(sampler2D(tex[1], samp), texcoord1);
+
+    fragColor = mix(texel0, texel1, crossFadeProgress);
+}
diff --git a/shaders/vulkan/source/crossfade.vert b/shaders/vulkan/source/crossfade.vert
new file mode 100644
index 000000000..b229ad275
--- /dev/null
+++ b/shaders/vulkan/source/crossfade.vert
@@ -0,0 +1,26 @@
+#version 460 core
+
+layout (location = 0) in vec4 position;
+layout (location = 1) in vec2 texcoord0;
+layout (location = 2) in vec2 texcoord1;
+
+out gl_PerVertex {
+    vec4 gl_Position;
+};
+
+layout (location = 0) out vec2 out_texcoord0;
+layout (location = 1) out vec2 out_texcoord1;
+
+layout (set = 0, binding = 2) uniform UBO {
+    mat4 modelViewProjectionMatrix;
+    vec4 modulation;
+    float saturation;
+    float crossFadeProgress;
+};
+
+void main(void)
+{
+    out_texcoord0 = texcoord0;
+    out_texcoord1 = texcoord1;
+    gl_Position = modelViewProjectionMatrix * position;
+}
diff --git a/shaders/vulkan/source/desaturate.frag b/shaders/vulkan/source/desaturate.frag
new file mode 100644
index 000000000..1986f4e65
--- /dev/null
+++ b/shaders/vulkan/source/desaturate.frag
@@ -0,0 +1,22 @@
+#version 460 core
+
+layout (set = 0, binding = 0) uniform sampler2D tex;
+
+layout (set = 0, binding = 1) uniform UBO {
+    mat4 modelViewProjectionMatrix;
+    vec4 modulation;
+    vec4 color;
+    float saturation;
+    float crossFadeProgress;
+};
+
+layout (location = 0) in vec2 texcoord;
+layout (location = 0) out vec4 fragColor;
+
+void main(void)
+{
+    vec4 texel = texture(tex, texcoord) * modulation;
+    texel.rgb = mix(vec3(dot(texel.rgb, vec3(0.2126, 0.7152, 0.0722))), texel.rgb, saturation);
+
+    fragColor = texel;
+}
diff --git a/shaders/vulkan/source/modulate.frag b/shaders/vulkan/source/modulate.frag
new file mode 100644
index 000000000..d717ae116
--- /dev/null
+++ b/shaders/vulkan/source/modulate.frag
@@ -0,0 +1,18 @@
+#version 460 core
+
+layout (set = 0, binding = 0) uniform sampler2D tex;
+
+layout (set = 0, binding = 1) uniform UBO {
+    mat4 modelViewProjectionMatrix;
+    vec4 modulation;
+    float saturation;
+    float crossFadeProgress;
+};
+
+layout (location = 0) in vec2 texcoord;
+layout (location = 0) out vec4 fragColor;
+
+void main(void)
+{
+    fragColor = texture(tex, texcoord) * modulation;
+}
diff --git a/shaders/vulkan/source/texture.frag b/shaders/vulkan/source/texture.frag
new file mode 100644
index 000000000..f7dbb789d
--- /dev/null
+++ b/shaders/vulkan/source/texture.frag
@@ -0,0 +1,18 @@
+#version 460 core
+
+layout (set = 0, binding = 0) uniform sampler2D tex;
+
+layout (set = 0, binding = 1) uniform UBO {
+    mat4 modelViewProjectionMatrix;
+    vec4 modulation;
+    float saturation;
+    float crossFadeProgress;
+};
+
+layout (location = 0) in vec2 texcoord;
+layout (location = 0) out vec4 fragColor;
+
+void main(void)
+{
+    fragColor = texture(tex, texcoord);
+}
diff --git a/shaders/vulkan/source/texture.vert b/shaders/vulkan/source/texture.vert
new file mode 100644
index 000000000..45b79d5e1
--- /dev/null
+++ b/shaders/vulkan/source/texture.vert
@@ -0,0 +1,24 @@
+#version 460 core
+
+layout (location = 0) in vec4 position;
+layout (location = 1) in vec2 texcoord;
+
+out gl_PerVertex {
+    vec4 gl_Position;
+};
+
+layout (location = 0) out vec2 out_texcoord;
+
+layout (set = 0, binding = 1) uniform UBO {
+    mat4 modelViewProjectionMatrix;
+    vec4 modulation;
+    vec4 color;
+    float saturation;
+    float crossFadeProgress;
+};
+
+void main(void)
+{
+    out_texcoord = texcoord;
+    gl_Position = modelViewProjectionMatrix * position;
+}
diff --git a/shaders/vulkan/source/updatedecoration.frag b/shaders/vulkan/source/updatedecoration.frag
new file mode 100644
index 000000000..cbcb17a9a
--- /dev/null
+++ b/shaders/vulkan/source/updatedecoration.frag
@@ -0,0 +1,16 @@
+#version 460 core
+
+layout (set = 0, binding = 0) uniform texture2D tex[4];
+layout (set = 0, binding = 1) uniform sampler samp; 
+
+layout (location = 0) in vec2 texcoord;
+layout (location = 0) out vec4 fragColor;
+
+layout (push_constant) uniform TextureIndex {
+    uint index;
+};
+
+void main(void)
+{
+    fragColor = texture(sampler2D(tex[index], samp), texcoord);
+}
diff --git a/shaders/vulkan/source/updatedecoration.vert b/shaders/vulkan/source/updatedecoration.vert
new file mode 100644
index 000000000..45e6af501
--- /dev/null
+++ b/shaders/vulkan/source/updatedecoration.vert
@@ -0,0 +1,16 @@
+#version 460 core
+
+layout (location = 0) in vec4 position;
+layout (location = 1) in vec2 in_texcoord;
+
+out gl_PerVertex {
+    vec4 gl_Position;
+};
+
+layout (location = 0) out vec2 out_texcoord;
+
+void main(void)
+{
+    out_texcoord = in_texcoord;
+    gl_Position = position;
+}
diff --git a/shaders/vulkan/texture_frag.spv b/shaders/vulkan/texture_frag.spv
new file mode 100644
index 000000000..3bdd9d071
Binary files /dev/null and b/shaders/vulkan/texture_frag.spv differ
diff --git a/shaders/vulkan/texture_vert.spv b/shaders/vulkan/texture_vert.spv
new file mode 100644
index 000000000..ea2f494e2
Binary files /dev/null and b/shaders/vulkan/texture_vert.spv differ
diff --git a/shaders/vulkan/updatedecoration_frag.spv b/shaders/vulkan/updatedecoration_frag.spv
new file mode 100644
index 000000000..1226bd47e
Binary files /dev/null and b/shaders/vulkan/updatedecoration_frag.spv differ
diff --git a/shaders/vulkan/updatedecoration_vert.spv b/shaders/vulkan/updatedecoration_vert.spv
new file mode 100644
index 000000000..da3b0462c
Binary files /dev/null and b/shaders/vulkan/updatedecoration_vert.spv differ

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic