summaryrefslogtreecommitdiffstats
path: root/third_party/rust/wgpu-hal/examples/halmark/shader.wgsl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/rust/wgpu-hal/examples/halmark/shader.wgsl
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/wgpu-hal/examples/halmark/shader.wgsl')
-rw-r--r--third_party/rust/wgpu-hal/examples/halmark/shader.wgsl50
1 files changed, 50 insertions, 0 deletions
diff --git a/third_party/rust/wgpu-hal/examples/halmark/shader.wgsl b/third_party/rust/wgpu-hal/examples/halmark/shader.wgsl
new file mode 100644
index 0000000000..ffa7264591
--- /dev/null
+++ b/third_party/rust/wgpu-hal/examples/halmark/shader.wgsl
@@ -0,0 +1,50 @@
+struct Globals {
+ mvp: mat4x4<f32>,
+ size: vec2<f32>,
+ _pad0: u32,
+ _pad1: u32,
+};
+
+struct Locals {
+ position: vec2<f32>,
+ velocity: vec2<f32>,
+ color: u32,
+ _pad0: u32,
+ _pad1: u32,
+ _pad2: u32,
+};
+
+@group(0)
+@binding(0)
+var<uniform> globals: Globals;
+
+@group(1)
+@binding(0)
+var<uniform> locals: Locals;
+
+struct VertexOutput {
+ @builtin(position) position: vec4<f32>,
+ @location(0) tex_coords: vec2<f32>,
+ @location(1) color: vec4<f32>,
+};
+
+@vertex
+fn vs_main(@builtin(vertex_index) vi: u32) -> VertexOutput {
+ let tc = vec2<f32>(f32(vi & 1u), 0.5 * f32(vi & 2u));
+ let offset = vec2<f32>(tc.x * globals.size.x, tc.y * globals.size.y);
+ let pos = globals.mvp * vec4<f32>(locals.position + offset, 0.0, 1.0);
+ let color = vec4<f32>((vec4<u32>(locals.color) >> vec4<u32>(0u, 8u, 16u, 24u)) & vec4<u32>(255u)) / 255.0;
+ return VertexOutput(pos, tc, color);
+}
+
+@group(0)
+@binding(1)
+var tex: texture_2d<f32>;
+@group(0)
+@binding(2)
+var sam: sampler;
+
+@fragment
+fn fs_main(vertex: VertexOutput) -> @location(0) vec4<f32> {
+ return vertex.color * textureSampleLevel(tex, sam, vertex.tex_coords, 0.0);
+}