From kde-commits Fri Feb 16 17:01:48 2018 From: =?utf-8?q?Fredrik_H=C3=B6glund?= Date: Fri, 16 Feb 2018 17:01:48 +0000 To: kde-commits Subject: [kwin/fredrik/vulkan] /: Add Vulkan versions of the core shaders Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=151880053408144 Git commit 4697de4c766ed17af2d31cc692245692069958b6 by Fredrik H=C3=B6glund. 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 @@ shaders/1.10/lanczos-fragment.glsl = shaders/1.40/lanczos-fragment.glsl + + shaders/vulkan/color_vert.spv + shaders/vulkan/texture_vert.spv + shaders/vulkan/crossfade_vert.spv + shaders/vulkan/updatedecoration_vert.spv + shaders/vulkan/color_frag.spv + shaders/vulkan/texture_frag.spv + shaders/vulkan/modulate_frag.spv + shaders/vulkan/desaturate_frag.spv + shaders/vulkan/crossfade_frag.spv + shaders/vulkan/updatedecoration_frag.spv + 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 =3D glslc +GLSLFLAGS =3D -std=3D460core --target-env=3Dvulkan + +TARGETS =3D $(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_f= rag.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_v= ert.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_fra= g.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 =3D 0) out vec4 fragColor; + +layout (set =3D 0, binding =3D 0) uniform UBO { + mat4 modelViewProjectionMatrix; + vec4 color; +}; + +void main(void) +{ + fragColor =3D 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 =3D 0) in vec4 position; + +out gl_PerVertex { + vec4 gl_Position; +}; + +layout (set =3D 0, binding =3D 0) uniform UBO { + mat4 modelViewProjectionMatrix; + vec4 color; +}; + +void main(void) +{ + gl_Position =3D modelViewProjectionMatrix * position; +} diff --git a/shaders/vulkan/source/crossfade.frag b/shaders/vulkan/source/c= rossfade.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 =3D 0, binding =3D 0) uniform texture2D tex[2]; +layout (set =3D 0, binding =3D 1) uniform sampler samp; + +layout (set =3D 0, binding =3D 2) uniform UBO { + mat4 modelViewProjectionMatrix; + vec4 modulation; + float saturation; + float crossFadeProgress; +}; + +layout (location =3D 0) in vec2 texcoord0; +layout (location =3D 1) in vec2 texcoord1; + +layout (location =3D 0) out vec4 fragColor; + +void main(void) +{ + vec4 texel0 =3D texture(sampler2D(tex[0], samp), texcoord0); + vec4 texel1 =3D texture(sampler2D(tex[1], samp), texcoord1); + + fragColor =3D mix(texel0, texel1, crossFadeProgress); +} diff --git a/shaders/vulkan/source/crossfade.vert b/shaders/vulkan/source/c= rossfade.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 =3D 0) in vec4 position; +layout (location =3D 1) in vec2 texcoord0; +layout (location =3D 2) in vec2 texcoord1; + +out gl_PerVertex { + vec4 gl_Position; +}; + +layout (location =3D 0) out vec2 out_texcoord0; +layout (location =3D 1) out vec2 out_texcoord1; + +layout (set =3D 0, binding =3D 2) uniform UBO { + mat4 modelViewProjectionMatrix; + vec4 modulation; + float saturation; + float crossFadeProgress; +}; + +void main(void) +{ + out_texcoord0 =3D texcoord0; + out_texcoord1 =3D texcoord1; + gl_Position =3D 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 =3D 0, binding =3D 0) uniform sampler2D tex; + +layout (set =3D 0, binding =3D 1) uniform UBO { + mat4 modelViewProjectionMatrix; + vec4 modulation; + vec4 color; + float saturation; + float crossFadeProgress; +}; + +layout (location =3D 0) in vec2 texcoord; +layout (location =3D 0) out vec4 fragColor; + +void main(void) +{ + vec4 texel =3D texture(tex, texcoord) * modulation; + texel.rgb =3D mix(vec3(dot(texel.rgb, vec3(0.2126, 0.7152, 0.0722))), = texel.rgb, saturation); + + fragColor =3D texel; +} diff --git a/shaders/vulkan/source/modulate.frag b/shaders/vulkan/source/mo= dulate.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 =3D 0, binding =3D 0) uniform sampler2D tex; + +layout (set =3D 0, binding =3D 1) uniform UBO { + mat4 modelViewProjectionMatrix; + vec4 modulation; + float saturation; + float crossFadeProgress; +}; + +layout (location =3D 0) in vec2 texcoord; +layout (location =3D 0) out vec4 fragColor; + +void main(void) +{ + fragColor =3D texture(tex, texcoord) * modulation; +} diff --git a/shaders/vulkan/source/texture.frag b/shaders/vulkan/source/tex= ture.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 =3D 0, binding =3D 0) uniform sampler2D tex; + +layout (set =3D 0, binding =3D 1) uniform UBO { + mat4 modelViewProjectionMatrix; + vec4 modulation; + float saturation; + float crossFadeProgress; +}; + +layout (location =3D 0) in vec2 texcoord; +layout (location =3D 0) out vec4 fragColor; + +void main(void) +{ + fragColor =3D texture(tex, texcoord); +} diff --git a/shaders/vulkan/source/texture.vert b/shaders/vulkan/source/tex= ture.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 =3D 0) in vec4 position; +layout (location =3D 1) in vec2 texcoord; + +out gl_PerVertex { + vec4 gl_Position; +}; + +layout (location =3D 0) out vec2 out_texcoord; + +layout (set =3D 0, binding =3D 1) uniform UBO { + mat4 modelViewProjectionMatrix; + vec4 modulation; + vec4 color; + float saturation; + float crossFadeProgress; +}; + +void main(void) +{ + out_texcoord =3D texcoord; + gl_Position =3D modelViewProjectionMatrix * position; +} diff --git a/shaders/vulkan/source/updatedecoration.frag b/shaders/vulkan/s= ource/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 =3D 0, binding =3D 0) uniform texture2D tex[4]; +layout (set =3D 0, binding =3D 1) uniform sampler samp; = + +layout (location =3D 0) in vec2 texcoord; +layout (location =3D 0) out vec4 fragColor; + +layout (push_constant) uniform TextureIndex { + uint index; +}; + +void main(void) +{ + fragColor =3D texture(sampler2D(tex[index], samp), texcoord); +} diff --git a/shaders/vulkan/source/updatedecoration.vert b/shaders/vulkan/s= ource/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 =3D 0) in vec4 position; +layout (location =3D 1) in vec2 in_texcoord; + +out gl_PerVertex { + vec4 gl_Position; +}; + +layout (location =3D 0) out vec2 out_texcoord; + +void main(void) +{ + out_texcoord =3D in_texcoord; + gl_Position =3D 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/upda= tedecoration_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/upda= tedecoration_vert.spv new file mode 100644 index 000000000..da3b0462c Binary files /dev/null and b/shaders/vulkan/updatedecoration_vert.spv differ