From b9c60811f88574fd3e5dd331fb5e05c6f0be8a41 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 19 Mar 2021 01:34:19 -0400 Subject: [PATCH] [rs] Shader fixes with binary expressions --- wgpu/examples/boids/compute.wgsl | 2 +- wgpu/examples/conservative-raster/upscale.wgsl | 4 ++-- wgpu/examples/hello-triangle/shader.wgsl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wgpu/examples/boids/compute.wgsl b/wgpu/examples/boids/compute.wgsl index b141c023ae..43c354d266 100644 --- a/wgpu/examples/boids/compute.wgsl +++ b/wgpu/examples/boids/compute.wgsl @@ -1,5 +1,5 @@ // This should match `NUM_PARTICLES` on the Rust side. -const NUM_PARTICLES: u32 = 1500; +const NUM_PARTICLES: u32 = 1500u; [[block]] struct Particle { diff --git a/wgpu/examples/conservative-raster/upscale.wgsl b/wgpu/examples/conservative-raster/upscale.wgsl index ff1c00ebaa..45fc3ff4cc 100644 --- a/wgpu/examples/conservative-raster/upscale.wgsl +++ b/wgpu/examples/conservative-raster/upscale.wgsl @@ -5,8 +5,8 @@ struct VertexOutput { [[stage(vertex)]] fn vs_main([[builtin(vertex_index)]] vertex_index: u32) -> VertexOutput { - const x: f32 = f32(i32(vertex_index & 1) << 2) - 1.0; - const y: f32 = f32(i32(vertex_index & 2) << 1) - 1.0; + const x: f32 = f32(i32(vertex_index & 1u) << 2u) - 1.0; + const y: f32 = f32(i32(vertex_index & 2u) << 1u) - 1.0; var output: VertexOutput; output.position = vec4(x, -y, 0.0, 1.0); output.tex_coords = vec2(x + 1.0, y + 1.0) * 0.5; diff --git a/wgpu/examples/hello-triangle/shader.wgsl b/wgpu/examples/hello-triangle/shader.wgsl index 027aa9473f..8256492b99 100644 --- a/wgpu/examples/hello-triangle/shader.wgsl +++ b/wgpu/examples/hello-triangle/shader.wgsl @@ -1,7 +1,7 @@ [[stage(vertex)]] fn vs_main([[builtin(vertex_index)]] in_vertex_index: u32) -> [[builtin(position)]] vec4 { const x = f32(i32(in_vertex_index) - 1); - const y = f32(i32(in_vertex_index & 1) * 2 - 1); + const y = f32(i32(in_vertex_index & 1u) * 2 - 1); return vec4(x, y, 0.0, 1.0); }