summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2021-05-06 16:48:45 +0200
committerGitHub <noreply@github.com>2021-05-06 16:48:45 +0200
commitf208e6a26f3c21c25dbfcfe29491a6f5660c999d (patch)
tree65dbbd45b2f36faab8ae585eb0d270356bcba33e /cli
parentce76f8c3a97529c86d49c39c6d9a250f978b5430 (diff)
chore: update wgpu and realign to spec (#9760)
Diffstat (limited to 'cli')
-rw-r--r--cli/main.rs3
-rw-r--r--cli/tests/unit/webgpu_test.ts29
-rw-r--r--cli/tests/webgpu_computepass_shader.wgsl12
-rw-r--r--cli/tests/webgpu_hellotriangle_shader.wgsl21
4 files changed, 19 insertions, 46 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 6b5c5da27..ba3abc43d 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -967,7 +967,8 @@ fn init_logger(maybe_level: Option<Level>) {
)
// https://github.com/denoland/deno/issues/6641
.filter_module("rustyline", LevelFilter::Off)
- // wgpu backend crates (gfx_backend), have a lot of useless INFO and WARN logs
+ // wgpu crates (gfx_backend), have a lot of useless INFO and WARN logs
+ .filter_module("wgpu", LevelFilter::Error)
.filter_module("gfx", LevelFilter::Error)
.format(|buf, record| {
let mut target = record.target().to_string();
diff --git a/cli/tests/unit/webgpu_test.ts b/cli/tests/unit/webgpu_test.ts
index 7b761ee3c..4fbbd5cde 100644
--- a/cli/tests/unit/webgpu_test.ts
+++ b/cli/tests/unit/webgpu_test.ts
@@ -49,18 +49,13 @@ unitTest({
storageBuffer.unmap();
- const bindGroupLayout = device.createBindGroupLayout({
- entries: [
- {
- binding: 0,
- visibility: 4,
- buffer: {
- type: "storage",
- minBindingSize: 4,
- },
- },
- ],
+ const computePipeline = device.createComputePipeline({
+ compute: {
+ module: shaderModule,
+ entryPoint: "main",
+ },
});
+ const bindGroupLayout = computePipeline.getBindGroupLayout(0);
const bindGroup = device.createBindGroup({
layout: bindGroupLayout,
@@ -74,18 +69,6 @@ unitTest({
],
});
- const pipelineLayout = device.createPipelineLayout({
- bindGroupLayouts: [bindGroupLayout],
- });
-
- const computePipeline = device.createComputePipeline({
- layout: pipelineLayout,
- compute: {
- module: shaderModule,
- entryPoint: "main",
- },
- });
-
const encoder = device.createCommandEncoder();
const computePass = encoder.beginComputePass();
diff --git a/cli/tests/webgpu_computepass_shader.wgsl b/cli/tests/webgpu_computepass_shader.wgsl
index 2433f3243..7d4748e2a 100644
--- a/cli/tests/webgpu_computepass_shader.wgsl
+++ b/cli/tests/webgpu_computepass_shader.wgsl
@@ -1,14 +1,9 @@
-[[builtin(global_invocation_id)]]
-var global_id: vec3<u32>;
-
[[block]]
struct PrimeIndices {
data: [[stride(4)]] array<u32>;
}; // this is used as both input and output for convenience
-
[[group(0), binding(0)]]
var<storage> v_indices: [[access(read_write)]] PrimeIndices;
-
// The Collatz Conjecture states that for any integer n:
// If n is even, n = n/2
// If n is odd, n = 3n+1
@@ -26,14 +21,17 @@ fn collatz_iterations(n_base: u32) -> u32{
n = n / 2u;
}
else {
+ // Overflow? (i.e. 3*n + 1 > 0xffffffffu?)
+ if (n >= 1431655765u) { // 0x55555555u
+ return 4294967295u; // 0xffffffffu
+ }
n = 3u * n + 1u;
}
i = i + 1u;
}
return i;
}
-
[[stage(compute), workgroup_size(1)]]
-fn main() {
+fn main([[builtin(global_invocation_id)]] global_id: vec3<u32>) {
v_indices.data[global_id.x] = collatz_iterations(v_indices.data[global_id.x]);
}
diff --git a/cli/tests/webgpu_hellotriangle_shader.wgsl b/cli/tests/webgpu_hellotriangle_shader.wgsl
index 71934415b..b8b2b69fc 100644
--- a/cli/tests/webgpu_hellotriangle_shader.wgsl
+++ b/cli/tests/webgpu_hellotriangle_shader.wgsl
@@ -1,19 +1,10 @@
-[[builtin(vertex_index)]]
-var<in> in_vertex_index: u32;
-[[builtin(position)]]
-var<out> out_pos: vec4<f32>;
-
[[stage(vertex)]]
-fn vs_main() {
- var x: f32 = f32(i32(in_vertex_index) - 1);
- var y: f32 = f32(i32(in_vertex_index & 1) * 2 - 1);
- out_pos = vec4<f32>(x, y, 0.0, 1.0);
+fn vs_main([[builtin(vertex_index)]] in_vertex_index: u32) -> [[builtin(position)]] vec4<f32> {
+ let x = f32(i32(in_vertex_index) - 1);
+ let y = f32(i32(in_vertex_index & 1u) * 2 - 1);
+ return vec4<f32>(x, y, 0.0, 1.0);
}
-
-[[location(0)]]
-var<out> out_color: vec4<f32>;
-
[[stage(fragment)]]
-fn fs_main() {
- out_color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
+fn fs_main() -> [[location(0)]] vec4<f32> {
+ return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}