summaryrefslogtreecommitdiffstats
path: root/third_party/rust/naga/test-data
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/naga/test-data')
-rw-r--r--third_party/rust/naga/test-data/boids.param.ron8
-rw-r--r--third_party/rust/naga/test-data/boids.wgsl151
-rw-r--r--third_party/rust/naga/test-data/function.wgsl11
-rw-r--r--third_party/rust/naga/test-data/glsl_constant_expression.vert9
-rw-r--r--third_party/rust/naga/test-data/glsl_if_preprocessor.vert14
-rw-r--r--third_party/rust/naga/test-data/glsl_phong_lighting.frag56
-rw-r--r--third_party/rust/naga/test-data/glsl_preprocessor_abuse.vert11
-rw-r--r--third_party/rust/naga/test-data/glsl_vertex_test_shader.vert29
-rw-r--r--third_party/rust/naga/test-data/quad.param.ron6
-rw-r--r--third_party/rust/naga/test-data/quad.wgsl25
-rw-r--r--third_party/rust/naga/test-data/simple.frag5
-rw-r--r--third_party/rust/naga/test-data/simple.vert8
-rw-r--r--third_party/rust/naga/test-data/simple.wgsl8
-rw-r--r--third_party/rust/naga/test-data/simple/module.ron121
-rw-r--r--third_party/rust/naga/test-data/simple/x.spvbin0 -> 500 bytes
-rw-r--r--third_party/rust/naga/test-data/simple/x.vert10
-rw-r--r--third_party/rust/naga/test-data/simple/x.wgsl10
-rw-r--r--third_party/rust/naga/test-data/spv/cube.frag.spvbin0 -> 1208 bytes
-rw-r--r--third_party/rust/naga/test-data/spv/cube.vert.spvbin0 -> 1124 bytes
19 files changed, 482 insertions, 0 deletions
diff --git a/third_party/rust/naga/test-data/boids.param.ron b/third_party/rust/naga/test-data/boids.param.ron
new file mode 100644
index 0000000000..4de90960bf
--- /dev/null
+++ b/third_party/rust/naga/test-data/boids.param.ron
@@ -0,0 +1,8 @@
+(
+ spv_flow_dump_prefix: "",
+ metal_bindings: {
+ (stage: Compute, group: 0, binding: 0): (buffer: Some(0), mutable: false),
+ (stage: Compute, group: 0, binding: 1): (buffer: Some(1), mutable: true),
+ (stage: Compute, group: 0, binding: 2): (buffer: Some(2), mutable: true),
+ }
+)
diff --git a/third_party/rust/naga/test-data/boids.wgsl b/third_party/rust/naga/test-data/boids.wgsl
new file mode 100644
index 0000000000..9bc98052e9
--- /dev/null
+++ b/third_party/rust/naga/test-data/boids.wgsl
@@ -0,0 +1,151 @@
+# Copyright 2020 The Tint Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import "GLSL.std.450" as std;
+
+# vertex shader
+
+[[location(0)]] var<in> a_particlePos : vec2<f32>;
+[[location(1)]] var<in> a_particleVel : vec2<f32>;
+[[location(2)]] var<in> a_pos : vec2<f32>;
+[[builtin(position)]] var gl_Position : vec4<f32>;
+
+[[stage(vertex)]]
+fn main() -> void {
+ var angle : f32 = -std::atan2(a_particleVel.x, a_particleVel.y);
+ var pos : vec2<f32> = vec2<f32>(
+ (a_pos.x * std::cos(angle)) - (a_pos.y * std::sin(angle)),
+ (a_pos.x * std::sin(angle)) + (a_pos.y * std::cos(angle)));
+ gl_Position = vec4<f32>(pos + a_particlePos, 0.0, 1.0);
+ return;
+}
+
+# fragment shader
+[[location(0)]] var<out> fragColor : vec4<f32>;
+
+[[stage(fragment)]]
+fn main() -> void {
+ fragColor = vec4<f32>(1.0, 1.0, 1.0, 1.0);
+ return;
+}
+
+# compute shader
+type Particle = struct {
+ [[offset(0)]] pos : vec2<f32>;
+ [[offset(8)]] vel : vec2<f32>;
+};
+
+type SimParams = struct {
+ [[offset(0)]] deltaT : f32;
+ [[offset(4)]] rule1Distance : f32;
+ [[offset(8)]] rule2Distance : f32;
+ [[offset(12)]] rule3Distance : f32;
+ [[offset(16)]] rule1Scale : f32;
+ [[offset(20)]] rule2Scale : f32;
+ [[offset(24)]] rule3Scale : f32;
+};
+
+type Particles = struct {
+ [[offset(0)]] particles : [[stride 16]] array<Particle, 5>;
+};
+
+[[group(0), binding(0)]] var<uniform> params : SimParams;
+[[group(0), binding(1)]] var<storage> particlesA : Particles;
+[[group(0), binding(2)]] var<storage> particlesB : Particles;
+
+[[builtin(global_invocation_id)]] var gl_GlobalInvocationID : vec3<u32>;
+
+# https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
+[[stage(compute), workgroup_size(1)]]
+fn main() -> void {
+ var index : u32 = gl_GlobalInvocationID.x;
+ if (index >= u32(5)) {
+ return;
+ }
+
+ var vPos : vec2<f32> = particlesA.particles[index].pos;
+ var vVel : vec2<f32> = particlesA.particles[index].vel;
+
+ var cMass : vec2<f32> = vec2<f32>(0.0, 0.0);
+ var cVel : vec2<f32> = vec2<f32>(0.0, 0.0);
+ var colVel : vec2<f32> = vec2<f32>(0.0, 0.0);
+ var cMassCount : i32 = 0;
+ var cVelCount : i32 = 0;
+
+ var pos : vec2<f32>;
+ var vel : vec2<f32>;
+ var i : u32 = 0;
+ loop {
+ if (i >= u32(5)) {
+ break;
+ }
+ if (i == index) {
+ continue;
+ }
+
+ pos = particlesA.particles[i].pos.xy;
+ vel = particlesA.particles[i].vel.xy;
+
+ if (std::distance(pos, vPos) < params.rule1Distance) {
+ cMass = cMass + pos;
+ cMassCount = cMassCount + 1;
+ }
+ if (std::distance(pos, vPos) < params.rule2Distance) {
+ colVel = colVel - (pos - vPos);
+ }
+ if (std::distance(pos, vPos) < params.rule3Distance) {
+ cVel = cVel + vel;
+ cVelCount = cVelCount + 1;
+ }
+
+ continuing {
+ i = i + u32(1);
+ }
+ }
+ if (cMassCount > 0) {
+ cMass = (cMass / vec2<f32>(cMassCount, cMassCount)) + vPos;
+ }
+ if (cVelCount > 0) {
+ cVel = cVel / vec2<f32>(cVelCount, cVelCount);
+ }
+
+ vVel = vVel + (cMass * params.rule1Scale) + (colVel * params.rule2Scale) +
+ (cVel * params.rule3Scale);
+
+ # clamp velocity for a more pleasing simulation
+ vVel = std::normalize(vVel) * std::fclamp(std::length(vVel), 0.0, 0.1);
+
+ # kinematic update
+ vPos = vPos + (vVel * params.deltaT);
+
+ # Wrap around boundary
+ if (vPos.x < -1.0) {
+ vPos.x = 1.0;
+ }
+ if (vPos.x > 1.0) {
+ vPos.x = -1.0;
+ }
+ if (vPos.y < -1.0) {
+ vPos.y = 1.0;
+ }
+ if (vPos.y > 1.0) {
+ vPos.y = -1.0;
+ }
+
+ # Write back
+ particlesB.particles[index].pos = vPos;
+ particlesB.particles[index].vel = vVel;
+
+ return;
+}
diff --git a/third_party/rust/naga/test-data/function.wgsl b/third_party/rust/naga/test-data/function.wgsl
new file mode 100644
index 0000000000..5a968cadd4
--- /dev/null
+++ b/third_party/rust/naga/test-data/function.wgsl
@@ -0,0 +1,11 @@
+import "GLSL.std.450" as std::glsl;
+
+fn test_function(test: f32) -> f32 {
+ return test;
+}
+
+[[stage(vertex)]]
+fn main() -> void {
+ var foo: f32 = std::glsl::distance(0.0, 1.0);
+ var test: f32 = test_function(1.0);
+}
diff --git a/third_party/rust/naga/test-data/glsl_constant_expression.vert b/third_party/rust/naga/test-data/glsl_constant_expression.vert
new file mode 100644
index 0000000000..3edd419c1f
--- /dev/null
+++ b/third_party/rust/naga/test-data/glsl_constant_expression.vert
@@ -0,0 +1,9 @@
+#version 450 core
+
+const int N = 5;
+
+float foo[2+N];
+
+void main() {
+ gl_Position = vec4(1);
+} \ No newline at end of file
diff --git a/third_party/rust/naga/test-data/glsl_if_preprocessor.vert b/third_party/rust/naga/test-data/glsl_if_preprocessor.vert
new file mode 100644
index 0000000000..752dde3088
--- /dev/null
+++ b/third_party/rust/naga/test-data/glsl_if_preprocessor.vert
@@ -0,0 +1,14 @@
+#version 460 core
+
+#define TEST 3
+#define TEST_EXPR 2 && 2
+
+#if TEST_EXPR - 2 == 0
+#error 0
+#elif TEST_EXPR - 2 == 1
+#error 1
+#elif TEST_EXPR - 2 == 2
+#error 2
+#else
+#error You shouldn't do that
+#endif
diff --git a/third_party/rust/naga/test-data/glsl_phong_lighting.frag b/third_party/rust/naga/test-data/glsl_phong_lighting.frag
new file mode 100644
index 0000000000..6153f2cafe
--- /dev/null
+++ b/third_party/rust/naga/test-data/glsl_phong_lighting.frag
@@ -0,0 +1,56 @@
+#version 450 core
+
+layout(location=0) in vec3 v_position;
+layout(location=1) in vec3 v_color;
+layout(location=2) in vec3 v_normal;
+
+layout(location=0) out vec4 f_color;
+
+layout(set=0, binding=0)
+uniform Globals {
+ mat4 u_view_proj;
+ vec3 u_view_position;
+};
+
+layout(set = 1, binding = 0) uniform Light {
+ vec3 u_position;
+ vec3 u_color;
+};
+
+layout(set=2, binding=0)
+uniform Locals {
+ mat4 u_transform;
+ vec2 u_min_max;
+};
+
+layout (set = 2, binding = 1) uniform texture2D t_color;
+layout (set = 2, binding = 2) uniform sampler s_color;
+
+float invLerp(float from, float to, float value){
+ return (value - from) / (to - from);
+}
+
+void main() {
+ vec3 object_color =
+ texture(sampler2D(t_color,s_color), vec2(invLerp(u_min_max.x,u_min_max.y,length(v_position)),0.0)).xyz;
+
+ float ambient_strength = 0.1;
+ vec3 ambient_color = u_color * ambient_strength;
+
+ vec3 normal = normalize(v_normal);
+ vec3 light_dir = normalize(u_position - v_position);
+
+ float diffuse_strength = max(dot(normal, light_dir), 0.0);
+ vec3 diffuse_color = u_color * diffuse_strength;
+
+ vec3 view_dir = normalize(u_view_position - v_position);
+ vec3 half_dir = normalize(view_dir + light_dir);
+
+ float specular_strength = pow(max(dot(normal, half_dir), 0.0), 32);
+
+ vec3 specular_color = specular_strength * u_color;
+
+ vec3 result = (ambient_color + diffuse_color + specular_color) * object_color;
+
+ f_color = vec4(result, 1.0);
+}
diff --git a/third_party/rust/naga/test-data/glsl_preprocessor_abuse.vert b/third_party/rust/naga/test-data/glsl_preprocessor_abuse.vert
new file mode 100644
index 0000000000..f83cc74c4f
--- /dev/null
+++ b/third_party/rust/naga/test-data/glsl_preprocessor_abuse.vert
@@ -0,0 +1,11 @@
+#version 450 core
+
+#define MAIN void main() {
+#define V_POSITION layout(location=0) in vec4 a_position;
+#define ASSIGN_POSITION gl_Position = a_position;
+
+V_POSITION
+
+MAIN
+ ASSIGN_POSITION
+} \ No newline at end of file
diff --git a/third_party/rust/naga/test-data/glsl_vertex_test_shader.vert b/third_party/rust/naga/test-data/glsl_vertex_test_shader.vert
new file mode 100644
index 0000000000..b82d34f819
--- /dev/null
+++ b/third_party/rust/naga/test-data/glsl_vertex_test_shader.vert
@@ -0,0 +1,29 @@
+#version 450 core
+
+layout(location=0) in vec3 a_position;
+layout(location=1) in vec3 a_color;
+layout(location=2) in vec3 a_normal;
+
+layout(location=0) out vec3 v_position;
+layout(location=1) out vec3 v_color;
+layout(location=2) out vec3 v_normal;
+
+layout(set=0, binding=0)
+uniform Globals {
+ mat4 u_view_proj;
+ vec3 u_view_position;
+};
+
+layout(set=2, binding=0)
+uniform Locals {
+ mat4 u_transform;
+ vec2 U_min_max;
+};
+
+void main() {
+ v_color = a_color;
+ v_normal = a_normal;
+
+ v_position = (u_transform * vec4(a_position, 1.0)).xyz;
+ gl_Position = u_view_proj * u_transform * vec4(a_position, 1.0);
+}
diff --git a/third_party/rust/naga/test-data/quad.param.ron b/third_party/rust/naga/test-data/quad.param.ron
new file mode 100644
index 0000000000..c4245bd185
--- /dev/null
+++ b/third_party/rust/naga/test-data/quad.param.ron
@@ -0,0 +1,6 @@
+(
+ metal_bindings: {
+ (stage: Fragment, group: 0, binding: 0): (texture: Some(0)),
+ (stage: Fragment, group: 0, binding: 1): (sampler: Some(0)),
+ }
+)
diff --git a/third_party/rust/naga/test-data/quad.wgsl b/third_party/rust/naga/test-data/quad.wgsl
new file mode 100644
index 0000000000..16cbd2698a
--- /dev/null
+++ b/third_party/rust/naga/test-data/quad.wgsl
@@ -0,0 +1,25 @@
+# vertex
+const c_scale: f32 = 1.2;
+[[location(0)]] var<in> a_pos : vec2<f32>;
+[[location(1)]] var<in> a_uv : vec2<f32>;
+[[location(0)]] var<out> v_uv : vec2<f32>;
+[[builtin(position)]] var<out> o_position : vec4<f32>;
+
+[[stage(vertex)]]
+fn main() -> void {
+ v_uv = a_uv;
+ o_position = vec4<f32>(c_scale * a_pos, 0.0, 1.0);
+ return;
+}
+
+# fragment
+[[location(0)]] var<in> v_uv : vec2<f32>;
+[[group(0), binding(0)]] var u_texture : texture_sampled_2d<f32>;
+[[group(0), binding(1)]] var u_sampler : sampler;
+[[location(0)]] var<out> o_color : vec4<f32>;
+
+[[stage(fragment)]]
+fn main() -> void {
+ o_color = textureSample(u_texture, u_sampler, v_uv);
+ return;
+}
diff --git a/third_party/rust/naga/test-data/simple.frag b/third_party/rust/naga/test-data/simple.frag
new file mode 100644
index 0000000000..2aea31896a
--- /dev/null
+++ b/third_party/rust/naga/test-data/simple.frag
@@ -0,0 +1,5 @@
+#version 450 core
+
+void main() {
+ gl_FragDepth = 0;
+}
diff --git a/third_party/rust/naga/test-data/simple.vert b/third_party/rust/naga/test-data/simple.vert
new file mode 100644
index 0000000000..3aa56b2e95
--- /dev/null
+++ b/third_party/rust/naga/test-data/simple.vert
@@ -0,0 +1,8 @@
+#version 450 core
+
+layout(location = 0) in vec2 position;
+
+void main() {
+ float w = 1.0;
+ gl_Position = vec4(position, 0.0, w);
+}
diff --git a/third_party/rust/naga/test-data/simple.wgsl b/third_party/rust/naga/test-data/simple.wgsl
new file mode 100644
index 0000000000..35afac0878
--- /dev/null
+++ b/third_party/rust/naga/test-data/simple.wgsl
@@ -0,0 +1,8 @@
+# vertex
+[[builtin position]] var<out> o_position : vec4<f32>;
+
+fn main() -> void {
+ o_position = vec4<f32>(1);
+ return;
+}
+entry_point vertex as "main" = main;
diff --git a/third_party/rust/naga/test-data/simple/module.ron b/third_party/rust/naga/test-data/simple/module.ron
new file mode 100644
index 0000000000..76a4b48574
--- /dev/null
+++ b/third_party/rust/naga/test-data/simple/module.ron
@@ -0,0 +1,121 @@
+(
+ header: (
+ version: (1, 0, 0),
+ generator: 0,
+ ),
+ types: [
+ (
+ name: None,
+ inner: Vector(
+ size: Bi,
+ kind: Float,
+ width: 4,
+ ),
+ ),
+ (
+ name: None,
+ inner: Vector(
+ size: Quad,
+ kind: Float,
+ width: 4,
+ ),
+ ),
+ (
+ name: None,
+ inner: Scalar(
+ kind: Float,
+ width: 4,
+ ),
+ ),
+ ],
+ constants: [
+ (
+ name: None,
+ specialization: None,
+ inner: Float(1),
+ ty: 3,
+ ),
+ (
+ name: None,
+ specialization: None,
+ inner: Float(0),
+ ty: 3,
+ ),
+ ],
+ global_variables: [
+ (
+ name: Some("a_pos"),
+ class: Input,
+ binding: Some(Location(0)),
+ ty: 1,
+ init: None,
+ interpolation: None,
+ storage_access: (
+ bits: 0,
+ ),
+ ),
+ (
+ name: Some("o_pos"),
+ class: Output,
+ binding: Some(Location(0)),
+ ty: 2,
+ init: None,
+ interpolation: None,
+ storage_access: (
+ bits: 0,
+ ),
+ ),
+ ],
+ functions: [],
+ entry_points: {
+ (Vertex, "main"): (
+ early_depth_test: None,
+ workgroup_size: (0, 0, 0),
+ function: (
+ name: Some("main"),
+ arguments: [],
+ return_type: None,
+ global_usage: [
+ (
+ bits: 1,
+ ),
+ (
+ bits: 2,
+ ),
+ ],
+ local_variables: [
+ (
+ name: Some("w"),
+ ty: 3,
+ init: Some(1),
+ ),
+ ],
+ expressions: [
+ GlobalVariable(1),
+ GlobalVariable(2),
+ Constant(1),
+ LocalVariable(1),
+ Constant(2),
+ Compose(
+ ty: 2,
+ components: [
+ 1,
+ 5,
+ 4,
+ ],
+ ),
+ ],
+ body: [
+ Block([]),
+ Store(
+ pointer: 2,
+ value: 6,
+ ),
+ Return(
+ value: None,
+ ),
+ ],
+ ),
+ ),
+ },
+) \ No newline at end of file
diff --git a/third_party/rust/naga/test-data/simple/x.spv b/third_party/rust/naga/test-data/simple/x.spv
new file mode 100644
index 0000000000..924ff447e0
--- /dev/null
+++ b/third_party/rust/naga/test-data/simple/x.spv
Binary files differ
diff --git a/third_party/rust/naga/test-data/simple/x.vert b/third_party/rust/naga/test-data/simple/x.vert
new file mode 100644
index 0000000000..27c9f04061
--- /dev/null
+++ b/third_party/rust/naga/test-data/simple/x.vert
@@ -0,0 +1,10 @@
+#version 450 core
+
+layout(location = 0) in vec2 a_pos;
+layout(location = 0) out vec4 o_pos;
+
+void main() {
+ float w = 1.0;
+ o_pos = vec4(a_pos, 0.0, w);
+ return;
+}
diff --git a/third_party/rust/naga/test-data/simple/x.wgsl b/third_party/rust/naga/test-data/simple/x.wgsl
new file mode 100644
index 0000000000..b35b83b426
--- /dev/null
+++ b/third_party/rust/naga/test-data/simple/x.wgsl
@@ -0,0 +1,10 @@
+# vertex
+[[location(0)]] var<in> a_pos : vec2<f32>;
+[[location(0)]] var<out> o_pos : vec4<f32>;
+
+[[stage(vertex)]]
+fn main() -> void {
+ var w: f32 = 1.0;
+ o_pos = vec4<f32>(a_pos, 0.0, w);
+ return;
+}
diff --git a/third_party/rust/naga/test-data/spv/cube.frag.spv b/third_party/rust/naga/test-data/spv/cube.frag.spv
new file mode 100644
index 0000000000..41358746fd
--- /dev/null
+++ b/third_party/rust/naga/test-data/spv/cube.frag.spv
Binary files differ
diff --git a/third_party/rust/naga/test-data/spv/cube.vert.spv b/third_party/rust/naga/test-data/spv/cube.vert.spv
new file mode 100644
index 0000000000..857da8c814
--- /dev/null
+++ b/third_party/rust/naga/test-data/spv/cube.vert.spv
Binary files differ