vulkan: Compile example shaders at runtime

Added naga to example crate deps for shader compilation.
This commit is contained in:
Hanna Weiß 2025-07-03 14:54:58 +02:00
parent 04b8a0cf71
commit 7ede19222e
No known key found for this signature in database
5 changed files with 224 additions and 337 deletions

161
Cargo.lock generated
View file

@ -54,6 +54,12 @@ version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
[[package]]
name = "as-raw-xcb-connection"
version = "1.0.1"
@ -105,6 +111,21 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "bit-set"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
[[package]]
name = "bitflags"
version = "1.3.2"
@ -289,6 +310,17 @@ dependencies = [
"objc",
]
[[package]]
name = "codespan-reporting"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81"
dependencies = [
"serde",
"termcolor",
"unicode-width",
]
[[package]]
name = "combine"
version = "4.6.7"
@ -397,6 +429,12 @@ version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crunchy"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "cursor-icon"
version = "1.2.0"
@ -550,6 +588,7 @@ dependencies = [
"image",
"memfd",
"memmap2",
"naga",
"objc",
"pango",
"pangocairo",
@ -586,6 +625,12 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "foreign-types"
version = "0.5.0"
@ -1625,7 +1670,7 @@ dependencies = [
[[package]]
name = "gstreamer-vulkan"
version = "0.23.0"
version = "0.25.0"
dependencies = [
"gir-format-check",
"glib",
@ -1641,7 +1686,7 @@ dependencies = [
[[package]]
name = "gstreamer-vulkan-sys"
version = "0.23.0"
version = "0.25.0"
dependencies = [
"ash",
"glib-sys",
@ -1657,7 +1702,7 @@ dependencies = [
[[package]]
name = "gstreamer-vulkan-wayland"
version = "0.23.0"
version = "0.25.0"
dependencies = [
"gir-format-check",
"glib",
@ -1669,7 +1714,7 @@ dependencies = [
[[package]]
name = "gstreamer-vulkan-wayland-sys"
version = "0.23.0"
version = "0.25.0"
dependencies = [
"glib-sys",
"gstreamer-vulkan-sys",
@ -1681,7 +1726,7 @@ dependencies = [
[[package]]
name = "gstreamer-vulkan-xcb"
version = "0.23.0"
version = "0.25.0"
dependencies = [
"gir-format-check",
"glib",
@ -1693,7 +1738,7 @@ dependencies = [
[[package]]
name = "gstreamer-vulkan-xcb-sys"
version = "0.23.0"
version = "0.25.0"
dependencies = [
"glib-sys",
"gstreamer-vulkan-sys",
@ -1728,11 +1773,25 @@ dependencies = [
"tempfile",
]
[[package]]
name = "half"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9"
dependencies = [
"cfg-if",
"crunchy",
"num-traits",
]
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"foldhash",
]
[[package]]
name = "heck"
@ -1746,6 +1805,12 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
[[package]]
name = "hexf-parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "image"
version = "0.25.6"
@ -1858,6 +1923,12 @@ dependencies = [
"windows-targets 0.53.3",
]
[[package]]
name = "libm"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
[[package]]
name = "libredox"
version = "0.1.9"
@ -1936,6 +2007,31 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0"
[[package]]
name = "naga"
version = "25.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b977c445f26e49757f9aca3631c3b8b836942cb278d69a92e7b80d3b24da632"
dependencies = [
"arrayvec",
"bit-set",
"bitflags 2.9.1",
"cfg_aliases",
"codespan-reporting",
"half",
"hashbrown",
"hexf-parse",
"indexmap",
"log",
"num-traits",
"once_cell",
"rustc-hash",
"spirv",
"strum",
"thiserror 2.0.12",
"unicode-ident",
]
[[package]]
name = "ndk"
version = "0.9.0"
@ -1993,6 +2089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
"libm",
]
[[package]]
@ -2516,6 +2613,12 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"
version = "0.38.44"
@ -2683,12 +2786,43 @@ dependencies = [
"serde",
]
[[package]]
name = "spirv"
version = "0.3.0+sdk-1.3.268.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844"
dependencies = [
"bitflags 2.9.1",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strum"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck",
"proc-macro2",
"quote",
"rustversion",
"syn",
]
[[package]]
name = "syn"
version = "2.0.104"
@ -2732,6 +2866,15 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "termion"
version = "4.0.5"
@ -2875,6 +3018,12 @@ version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "unicode-width"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c"
[[package]]
name = "unicode-xid"
version = "0.2.6"

View file

@ -47,6 +47,7 @@ uds = { version = "0.4", optional = true }
winit = { version = "0.30", optional = true, default-features = false } #, features = ["rwh_05"] }
atomic_refcell = "0.1"
data-encoding = "2.0"
naga = { version = "25.0.1", optional = true, features = ["wgsl-in", "spv-out"] }
[target.'cfg(windows)'.dependencies]
windows = { version = "0.61", features=["Win32_Graphics_Direct3D11",
@ -84,7 +85,7 @@ gst-gl-egl = ["dep:gst-gl-egl", "glutin-winit?/egl", "glutin-winit?/x11", "gluti
allocators = ["gst-allocators", "memmap2", "memfd", "uds"]
windows = ["dep:windows"]
d3d12 = ["dep:gst-d3d12", "windows"]
vulkan = ["dep:gst-vulkan", "gst-vulkan/v1_26"]
vulkan = ["dep:gst-vulkan", "gst-vulkan/v1_26", "dep:naga"]
gst-vulkan-xcb = ["vulkan", "dep:gst-vulkan-xcb"]
gst-vulkan-wayland = ["vulkan", "dep:gst-vulkan-wayland"]

View file

@ -0,0 +1,18 @@
@group(0) @binding(0) var samp: sampler;
@group(0) @binding(1) var tex: texture_2d<f32>;
struct VertexOutput {
@builtin(position) pos: vec4<f32>,
@location(0) uv: vec2<f32>,
}
@fragment
fn main(vertex: VertexOutput) -> @location(0) vec4<f32> {
var uv = vertex.uv;
uv.y = 1. - uv.y; // convert to vulkan coordinates
if uv.x > 0.5 { // sample from left half if in right half
uv.x = 1. - uv.x;
}
return textureSample(tex, samp, uv);
}

View file

@ -44,335 +44,37 @@ mod mirror {
use std::sync::{Arc, Mutex};
static FRAGMENT_SPIRV: [u8; 2240] = [
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x0d, 0x00, 0x23, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73,
0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x05, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 0x00,
0x2e, 0x2e, 0x2f, 0x73, 0x75, 0x62, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73,
0x2f, 0x67, 0x73, 0x74, 0x2d, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x2d, 0x62,
0x61, 0x64, 0x2f, 0x65, 0x78, 0x74, 0x2f, 0x76, 0x75, 0x6c, 0x6b, 0x61, 0x6e, 0x2f,
0x73, 0x68, 0x61, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x6d, 0x69, 0x72, 0x72, 0x6f, 0x72,
0x2e, 0x66, 0x72, 0x61, 0x67, 0x00, 0x00, 0x00, 0x03, 0x00, 0x44, 0x01, 0x02, 0x00,
0x00, 0x00, 0xc2, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2f, 0x2f, 0x20, 0x4f,
0x70, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73,
0x65, 0x64, 0x20, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x2d, 0x70, 0x6f, 0x69, 0x6e, 0x74,
0x20, 0x6d, 0x61, 0x69, 0x6e, 0x0a, 0x2f, 0x2f, 0x20, 0x4f, 0x70, 0x4d, 0x6f, 0x64,
0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x63,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x76, 0x75, 0x6c, 0x6b, 0x61, 0x6e, 0x31, 0x30,
0x30, 0x0a, 0x2f, 0x2f, 0x20, 0x4f, 0x70, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50,
0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x61, 0x72, 0x67, 0x65,
0x74, 0x2d, 0x65, 0x6e, 0x76, 0x20, 0x76, 0x75, 0x6c, 0x6b, 0x61, 0x6e, 0x31, 0x2e,
0x30, 0x0a, 0x2f, 0x2f, 0x20, 0x4f, 0x70, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50,
0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x65, 0x6e, 0x74, 0x72, 0x79,
0x2d, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x0a, 0x23, 0x6c,
0x69, 0x6e, 0x65, 0x20, 0x31, 0x0a, 0x2f, 0x2a, 0x20, 0x47, 0x53, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x65, 0x72, 0x0a, 0x20, 0x2a, 0x20, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69,
0x67, 0x68, 0x74, 0x20, 0x28, 0x43, 0x29, 0x20, 0x32, 0x30, 0x32, 0x30, 0x20, 0x4d,
0x61, 0x74, 0x74, 0x68, 0x65, 0x77, 0x20, 0x57, 0x61, 0x74, 0x65, 0x72, 0x73, 0x20,
0x3c, 0x6d, 0x61, 0x74, 0x74, 0x68, 0x65, 0x77, 0x40, 0x63, 0x65, 0x6e, 0x74, 0x72,
0x69, 0x63, 0x75, 0x6c, 0x61, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x3e, 0x0a, 0x20, 0x2a,
0x0a, 0x20, 0x2a, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61,
0x72, 0x79, 0x20, 0x69, 0x73, 0x20, 0x66, 0x72, 0x65, 0x65, 0x20, 0x73, 0x6f, 0x66,
0x74, 0x77, 0x61, 0x72, 0x65, 0x3b, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x63, 0x61, 0x6e,
0x20, 0x72, 0x65, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20,
0x69, 0x74, 0x20, 0x61, 0x6e, 0x64, 0x2f, 0x6f, 0x72, 0x0a, 0x20, 0x2a, 0x20, 0x6d,
0x6f, 0x64, 0x69, 0x66, 0x79, 0x20, 0x69, 0x74, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72,
0x20, 0x74, 0x68, 0x65, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x20, 0x6f, 0x66, 0x20,
0x74, 0x68, 0x65, 0x20, 0x47, 0x4e, 0x55, 0x20, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72,
0x79, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62, 0x6c,
0x69, 0x63, 0x0a, 0x20, 0x2a, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20,
0x61, 0x73, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x20, 0x62,
0x79, 0x20, 0x74, 0x68, 0x65, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20, 0x53, 0x6f, 0x66,
0x74, 0x77, 0x61, 0x72, 0x65, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x3b, 0x20, 0x65, 0x69, 0x74, 0x68, 0x65, 0x72, 0x0a, 0x20, 0x2a, 0x20,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x32, 0x20, 0x6f, 0x66, 0x20, 0x74,
0x68, 0x65, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x2c, 0x20, 0x6f, 0x72,
0x20, 0x28, 0x61, 0x74, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x70, 0x74, 0x69,
0x6f, 0x6e, 0x29, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x6c, 0x61, 0x74, 0x65, 0x72, 0x20,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x2a, 0x0a, 0x20, 0x2a,
0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x20,
0x69, 0x73, 0x20, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64,
0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x68, 0x6f, 0x70, 0x65, 0x20, 0x74,
0x68, 0x61, 0x74, 0x20, 0x69, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65,
0x20, 0x75, 0x73, 0x65, 0x66, 0x75, 0x6c, 0x2c, 0x0a, 0x20, 0x2a, 0x20, 0x62, 0x75,
0x74, 0x20, 0x57, 0x49, 0x54, 0x48, 0x4f, 0x55, 0x54, 0x20, 0x41, 0x4e, 0x59, 0x20,
0x57, 0x41, 0x52, 0x52, 0x41, 0x4e, 0x54, 0x59, 0x3b, 0x20, 0x77, 0x69, 0x74, 0x68,
0x6f, 0x75, 0x74, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69,
0x6d, 0x70, 0x6c, 0x69, 0x65, 0x64, 0x20, 0x77, 0x61, 0x72, 0x72, 0x61, 0x6e, 0x74,
0x79, 0x20, 0x6f, 0x66, 0x0a, 0x20, 0x2a, 0x20, 0x4d, 0x45, 0x52, 0x43, 0x48, 0x41,
0x4e, 0x54, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x20, 0x6f, 0x72, 0x20, 0x46,
0x49, 0x54, 0x4e, 0x45, 0x53, 0x53, 0x20, 0x46, 0x4f, 0x52, 0x20, 0x41, 0x20, 0x50,
0x41, 0x52, 0x54, 0x49, 0x43, 0x55, 0x4c, 0x41, 0x52, 0x20, 0x50, 0x55, 0x52, 0x50,
0x4f, 0x53, 0x45, 0x2e, 0x20, 0x20, 0x53, 0x65, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20,
0x47, 0x4e, 0x55, 0x0a, 0x20, 0x2a, 0x20, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79,
0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69,
0x63, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20,
0x6d, 0x6f, 0x72, 0x65, 0x20, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x0a,
0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x59, 0x6f, 0x75, 0x20, 0x73, 0x68, 0x6f, 0x75,
0x6c, 0x64, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76,
0x65, 0x64, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x6f, 0x66, 0x20, 0x74,
0x68, 0x65, 0x20, 0x47, 0x4e, 0x55, 0x20, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79,
0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69,
0x63, 0x0a, 0x20, 0x2a, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x61,
0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x68, 0x69, 0x73,
0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x3b, 0x20, 0x69, 0x66, 0x20, 0x6e,
0x6f, 0x74, 0x2c, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74,
0x68, 0x65, 0x0a, 0x20, 0x2a, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20, 0x53, 0x6f, 0x66,
0x74, 0x77, 0x61, 0x72, 0x65, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x2c, 0x20, 0x35, 0x39, 0x20, 0x54,
0x65, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x50, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x2d, 0x20,
0x53, 0x75, 0x69, 0x74, 0x65, 0x20, 0x33, 0x33, 0x30, 0x2c, 0x0a, 0x20, 0x2a, 0x20,
0x42, 0x6f, 0x73, 0x74, 0x6f, 0x6e, 0x2c, 0x20, 0x4d, 0x41, 0x20, 0x30, 0x32, 0x31,
0x31, 0x31, 0x2d, 0x31, 0x33, 0x30, 0x37, 0x2c, 0x20, 0x55, 0x53, 0x41, 0x2e, 0x0a,
0x20, 0x2a, 0x2f, 0x0a, 0x0a, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20,
0x34, 0x35, 0x30, 0x20, 0x63, 0x6f, 0x72, 0x65, 0x0a, 0x0a, 0x6c, 0x61, 0x79, 0x6f,
0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20,
0x30, 0x29, 0x20, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x69, 0x6e, 0x54,
0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x0a, 0x6c, 0x61, 0x79, 0x6f,
0x75, 0x74, 0x28, 0x73, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2c, 0x20, 0x62, 0x69,
0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x31, 0x29, 0x20, 0x75, 0x6e, 0x69,
0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44,
0x20, 0x69, 0x6e, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x3b, 0x0a, 0x0a,
0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x20, 0x3d, 0x20, 0x30, 0x29, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63,
0x34, 0x20, 0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x0a,
0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b, 0x0a,
0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72,
0x64, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x61, 0x62, 0x73, 0x28, 0x69,
0x6e, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x78, 0x20, 0x2d, 0x20,
0x30, 0x2e, 0x35, 0x29, 0x2c, 0x20, 0x69, 0x6e, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f,
0x72, 0x64, 0x2e, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x43, 0x6f,
0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x28, 0x69, 0x6e, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x74,
0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x00, 0x00,
0x00, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x47, 0x4c, 0x5f, 0x47, 0x4f, 0x4f, 0x47, 0x4c,
0x45, 0x5f, 0x63, 0x70, 0x70, 0x5f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x5f, 0x6c, 0x69,
0x6e, 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x00, 0x00,
0x04, 0x00, 0x08, 0x00, 0x47, 0x4c, 0x5f, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x5f,
0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74,
0x69, 0x76, 0x65, 0x00, 0x05, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6d, 0x61,
0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x69, 0x6e, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x00, 0x05, 0x00,
0x05, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x69, 0x6e,
0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00,
0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x47, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x21, 0x00,
0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00,
0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00,
0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x15, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00,
0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x0d, 0x00,
0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00,
0x19, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00,
0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00,
0x3b, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00,
0x1d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x36, 0x00, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00,
0x08, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00,
0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00,
0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x12, 0x00,
0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x41, 0x00,
0x05, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x15, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x17, 0x00,
0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x08, 0x00,
0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3d, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1f, 0x00,
0x00, 0x00, 0x57, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1b, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00,
];
// Uses the naga crate to transform wgsl shader code to SPIR-V
fn compile_shader(wgsl_source: &str) -> Result<Vec<u8>, gst::ErrorMessage> {
use naga::valid::*;
static VERTEX_SPIRV: [u8; 2292] = [
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x0d, 0x00, 0x1c, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73,
0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1a, 0x00,
0x00, 0x00, 0x07, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x2e, 0x2f, 0x73,
0x75, 0x62, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x67, 0x73, 0x74,
0x2d, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x2d, 0x62, 0x61, 0x64, 0x2f, 0x65,
0x78, 0x74, 0x2f, 0x76, 0x75, 0x6c, 0x6b, 0x61, 0x6e, 0x2f, 0x73, 0x68, 0x61, 0x64,
0x65, 0x72, 0x73, 0x2f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x76,
0x65, 0x72, 0x74, 0x00, 0x03, 0x00, 0x31, 0x01, 0x02, 0x00, 0x00, 0x00, 0xc2, 0x01,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2f, 0x2f, 0x20, 0x4f, 0x70, 0x4d, 0x6f, 0x64,
0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x65,
0x6e, 0x74, 0x72, 0x79, 0x2d, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69,
0x6e, 0x0a, 0x2f, 0x2f, 0x20, 0x4f, 0x70, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50,
0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x20, 0x76, 0x75, 0x6c, 0x6b, 0x61, 0x6e, 0x31, 0x30, 0x30, 0x0a, 0x2f, 0x2f,
0x20, 0x4f, 0x70, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x63, 0x65,
0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2d, 0x65, 0x6e,
0x76, 0x20, 0x76, 0x75, 0x6c, 0x6b, 0x61, 0x6e, 0x31, 0x2e, 0x30, 0x0a, 0x2f, 0x2f,
0x20, 0x4f, 0x70, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x63, 0x65,
0x73, 0x73, 0x65, 0x64, 0x20, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x2d, 0x70, 0x6f, 0x69,
0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x0a, 0x23, 0x6c, 0x69, 0x6e, 0x65, 0x20,
0x31, 0x0a, 0x2f, 0x2a, 0x20, 0x47, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72,
0x0a, 0x20, 0x2a, 0x20, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20,
0x28, 0x43, 0x29, 0x20, 0x32, 0x30, 0x32, 0x30, 0x20, 0x4d, 0x61, 0x74, 0x74, 0x68,
0x65, 0x77, 0x20, 0x57, 0x61, 0x74, 0x65, 0x72, 0x73, 0x20, 0x3c, 0x6d, 0x61, 0x74,
0x74, 0x68, 0x65, 0x77, 0x40, 0x63, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x63, 0x75, 0x6c,
0x61, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x3e, 0x0a, 0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20,
0x54, 0x68, 0x69, 0x73, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x20, 0x69,
0x73, 0x20, 0x66, 0x72, 0x65, 0x65, 0x20, 0x73, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72,
0x65, 0x3b, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x72, 0x65, 0x64,
0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x69, 0x74, 0x20, 0x61,
0x6e, 0x64, 0x2f, 0x6f, 0x72, 0x0a, 0x20, 0x2a, 0x20, 0x6d, 0x6f, 0x64, 0x69, 0x66,
0x79, 0x20, 0x69, 0x74, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65,
0x20, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20,
0x47, 0x4e, 0x55, 0x20, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x20, 0x47, 0x65,
0x6e, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x0a, 0x20,
0x2a, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x61, 0x73, 0x20, 0x70,
0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68,
0x65, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72,
0x65, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x20,
0x65, 0x69, 0x74, 0x68, 0x65, 0x72, 0x0a, 0x20, 0x2a, 0x20, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x20, 0x32, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4c,
0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x28, 0x61, 0x74,
0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x29, 0x20,
0x61, 0x6e, 0x79, 0x20, 0x6c, 0x61, 0x74, 0x65, 0x72, 0x20, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x54, 0x68, 0x69,
0x73, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x20, 0x69, 0x73, 0x20, 0x64,
0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20,
0x74, 0x68, 0x65, 0x20, 0x68, 0x6f, 0x70, 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20,
0x69, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20, 0x75, 0x73, 0x65,
0x66, 0x75, 0x6c, 0x2c, 0x0a, 0x20, 0x2a, 0x20, 0x62, 0x75, 0x74, 0x20, 0x57, 0x49,
0x54, 0x48, 0x4f, 0x55, 0x54, 0x20, 0x41, 0x4e, 0x59, 0x20, 0x57, 0x41, 0x52, 0x52,
0x41, 0x4e, 0x54, 0x59, 0x3b, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20,
0x65, 0x76, 0x65, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x69,
0x65, 0x64, 0x20, 0x77, 0x61, 0x72, 0x72, 0x61, 0x6e, 0x74, 0x79, 0x20, 0x6f, 0x66,
0x0a, 0x20, 0x2a, 0x20, 0x4d, 0x45, 0x52, 0x43, 0x48, 0x41, 0x4e, 0x54, 0x41, 0x42,
0x49, 0x4c, 0x49, 0x54, 0x59, 0x20, 0x6f, 0x72, 0x20, 0x46, 0x49, 0x54, 0x4e, 0x45,
0x53, 0x53, 0x20, 0x46, 0x4f, 0x52, 0x20, 0x41, 0x20, 0x50, 0x41, 0x52, 0x54, 0x49,
0x43, 0x55, 0x4c, 0x41, 0x52, 0x20, 0x50, 0x55, 0x52, 0x50, 0x4f, 0x53, 0x45, 0x2e,
0x20, 0x20, 0x53, 0x65, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x47, 0x4e, 0x55, 0x0a,
0x20, 0x2a, 0x20, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x20, 0x47, 0x65, 0x6e,
0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x4c, 0x69,
0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x6d, 0x6f, 0x72, 0x65,
0x20, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x0a, 0x20, 0x2a, 0x0a, 0x20,
0x2a, 0x20, 0x59, 0x6f, 0x75, 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x68,
0x61, 0x76, 0x65, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x20, 0x61,
0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x47,
0x4e, 0x55, 0x20, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x20, 0x47, 0x65, 0x6e,
0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x0a, 0x20, 0x2a,
0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x61, 0x6c, 0x6f, 0x6e, 0x67,
0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6c, 0x69, 0x62,
0x72, 0x61, 0x72, 0x79, 0x3b, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x2c, 0x20,
0x77, 0x72, 0x69, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x20,
0x2a, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72,
0x65, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20,
0x49, 0x6e, 0x63, 0x2e, 0x2c, 0x20, 0x35, 0x39, 0x20, 0x54, 0x65, 0x6d, 0x70, 0x6c,
0x65, 0x20, 0x50, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x2d, 0x20, 0x53, 0x75, 0x69, 0x74,
0x65, 0x20, 0x33, 0x33, 0x30, 0x2c, 0x0a, 0x20, 0x2a, 0x20, 0x42, 0x6f, 0x73, 0x74,
0x6f, 0x6e, 0x2c, 0x20, 0x4d, 0x41, 0x20, 0x30, 0x32, 0x31, 0x31, 0x31, 0x2d, 0x31,
0x33, 0x30, 0x37, 0x2c, 0x20, 0x55, 0x53, 0x41, 0x2e, 0x0a, 0x20, 0x2a, 0x2f, 0x0a,
0x0a, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x34, 0x35, 0x30, 0x20,
0x63, 0x6f, 0x72, 0x65, 0x0a, 0x0a, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c,
0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x30, 0x29, 0x20, 0x69,
0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x3b, 0x0a,
0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x20, 0x3d, 0x20, 0x31, 0x29, 0x20, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32,
0x20, 0x69, 0x6e, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x0a,
0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x20, 0x3d, 0x20, 0x30, 0x29, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63,
0x32, 0x20, 0x6f, 0x75, 0x74, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b,
0x0a, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x20,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69,
0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x6f, 0x75, 0x74, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x3d,
0x20, 0x69, 0x6e, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x7d,
0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x47, 0x4c, 0x5f, 0x47,
0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x5f, 0x63, 0x70, 0x70, 0x5f, 0x73, 0x74, 0x79, 0x6c,
0x65, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69,
0x76, 0x65, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x47, 0x4c, 0x5f, 0x47, 0x4f, 0x4f,
0x47, 0x4c, 0x45, 0x5f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x69,
0x72, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x00, 0x05, 0x00, 0x04, 0x00, 0x05, 0x00,
0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74,
0x65, 0x78, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x67, 0x6c, 0x5f, 0x43, 0x6c, 0x69, 0x70, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63,
0x65, 0x00, 0x06, 0x00, 0x07, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x67, 0x6c, 0x5f, 0x43, 0x75, 0x6c, 0x6c, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63,
0x65, 0x00, 0x05, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x00,
0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x54,
0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x05, 0x00, 0x05, 0x00, 0x1a, 0x00,
0x00, 0x00, 0x69, 0x6e, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x00,
0x48, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x12, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
0x18, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00,
0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x13, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x04, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x09, 0x00,
0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00,
0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1e, 0x00,
0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
0x0d, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x15, 0x00,
0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x2b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x12, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x16, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
0x17, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x3b, 0x00,
0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x20, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x16, 0x00,
0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1b, 0x00,
0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xf8, 0x00,
0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00,
0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x15, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
0x08, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00,
0x1a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1b, 0x00,
0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00,
];
let module = naga::front::wgsl::parse_str(wgsl_source).map_err(|e| {
gst::error_msg!(
gst::ResourceError::Failed,
("Shader compilation error: {e:#?}")
)
})?;
let info = Validator::new(ValidationFlags::all(), Capabilities::all())
.validate(&module)
.map_err(|e| {
gst::error_msg!(
gst::ResourceError::Failed,
("Shader validation error: {e:#?}")
)
})?;
let mut words = Vec::<u32>::new();
naga::back::spv::Writer::new(&naga::back::spv::Options::default())
.unwrap()
.write(&module, &info, None, &None, &mut words)
.unwrap();
Ok(words
.into_iter()
.flat_map(u32::to_be_bytes)
.collect::<Vec<_>>())
}
/// Private data consists of the transformation shader which is compiled
/// in advance to running the actual filter.
@ -441,6 +143,9 @@ mod mirror {
fn start(&self) -> Result<(), gst::ErrorMessage> {
self.parent_start()?;
let vertex_spirv = compile_shader(include_str!("vulkanfilter.vert.wgsl"))?;
let fragment_spirv = compile_shader(include_str!("vulkanfilter.frag.wgsl"))?;
let queue = self.obj().queue().ok_or_else(|| {
gst::error_msg!(gst::ResourceError::NotFound, ("No Vulkan Queue!"))
})?;
@ -448,13 +153,13 @@ mod mirror {
gst::error_msg!(gst::ResourceError::NotFound, ("No Vulkan Device!"))
})?;
let render = gst_vulkan::VulkanFullScreenQuad::new(&queue);
let vertex = device.create_shader(VERTEX_SPIRV).map_err(|e| {
let vertex = device.create_shader(&vertex_spirv).map_err(|e| {
gst::error_msg!(
gst::ResourceError::NotFound,
("Vertex shader creation failed {e:?}")
)
})?;
let fragment = device.create_shader(FRAGMENT_SPIRV).map_err(|e| {
let fragment = device.create_shader(&fragment_spirv).map_err(|e| {
gst::error_msg!(
gst::ResourceError::NotFound,
("Fragment shader creation failed {e:?}")

View file

@ -0,0 +1,14 @@
struct VertexInput {
@location(0) pos: vec3<f32>,
@location(1) uv: vec2<f32>,
}
struct VertexOutput {
@builtin(position) pos: vec4<f32>,
@location(0) uv: vec2<f32>,
}
@vertex
fn main(vertex: VertexInput) -> VertexOutput {
return VertexOutput(vec4(vertex.pos, 1.), vertex.uv);
}