Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sotrh committed Apr 27, 2024
1 parent 09c1024 commit ce95722
Show file tree
Hide file tree
Showing 37 changed files with 172 additions and 178 deletions.
4 changes: 2 additions & 2 deletions code/beginner/tutorial2-surface/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial2-surface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial3-pipeline/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial3-pipeline/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial4-buffer/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial4-buffer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial5-textures/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial5-textures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial6-uniforms/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial6-uniforms/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial7-instancing/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial7-instancing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial8-depth/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial8-depth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down
5 changes: 3 additions & 2 deletions code/beginner/tutorial8-depth/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ impl Texture {
device: &wgpu::Device,
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {let size = wgpu::Extent3d {
) -> Self {
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
Expand Down Expand Up @@ -58,7 +59,7 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
Expand Down
5 changes: 2 additions & 3 deletions code/beginner/tutorial9-models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ impl<'a> State<'a> {
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
log::warn!("WGPU setup");
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down Expand Up @@ -312,7 +312,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};


let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
Expand Down
5 changes: 2 additions & 3 deletions code/intermediate/tutorial10-lighting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down Expand Up @@ -403,7 +403,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};


let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
Expand Down
2 changes: 1 addition & 1 deletion code/intermediate/tutorial10-lighting/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
Expand Down
5 changes: 2 additions & 3 deletions code/intermediate/tutorial11-normals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down Expand Up @@ -403,7 +403,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};


let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
Expand Down
2 changes: 1 addition & 1 deletion code/intermediate/tutorial11-normals/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
Expand Down
5 changes: 2 additions & 3 deletions code/intermediate/tutorial12-camera/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down Expand Up @@ -283,7 +283,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};


let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
Expand Down
13 changes: 5 additions & 8 deletions code/intermediate/tutorial13-hdr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl<'a> State<'a> {
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
// UPDATED
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::BROWSER_WEBGPU,
Expand Down Expand Up @@ -300,7 +300,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};


let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
Expand Down Expand Up @@ -713,12 +712,10 @@ impl<'a> State<'a> {

fn render(&mut self) -> Result<(), wgpu::SurfaceError> {
let output = self.surface.get_current_texture()?;
let view = output
.texture
.create_view(&wgpu::TextureViewDescriptor {
format: Some(self.config.format.add_srgb_suffix()),
..Default::default()
});
let view = output.texture.create_view(&wgpu::TextureViewDescriptor {
format: Some(self.config.format.add_srgb_suffix()),
..Default::default()
});

let mut encoder = self
.device
Expand Down
9 changes: 5 additions & 4 deletions code/intermediate/tutorial13-hdr/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ impl HdrLoader {
) -> anyhow::Result<texture::CubeTexture> {
let hdr_decoder = HdrDecoder::new(Cursor::new(data))?;
let meta = hdr_decoder.metadata();
#[cfg(not(target_arch="wasm32"))]

#[cfg(not(target_arch = "wasm32"))]
let pixels = {
let mut pixels = vec![[0.0, 0.0, 0.0, 0.0]; meta.width as usize * meta.height as usize];
hdr_decoder.read_image_transform(
Expand All @@ -299,8 +299,9 @@ impl HdrLoader {
)?;
pixels
};
#[cfg(target_arch="wasm32")]
let pixels = hdr_decoder.read_image_native()?
#[cfg(target_arch = "wasm32")]
let pixels = hdr_decoder
.read_image_native()?
.into_iter()
.map(|pix| {
let rgb = pix.to_hdr();
Expand Down
2 changes: 1 addition & 1 deletion code/intermediate/tutorial13-hdr/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
Expand Down
5 changes: 2 additions & 3 deletions code/intermediate/wip-terrain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down Expand Up @@ -284,7 +284,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};


let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
Expand Down
2 changes: 1 addition & 1 deletion code/intermediate/wip-terrain/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
Expand Down
5 changes: 2 additions & 3 deletions code/showcase/compute/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
Expand Down Expand Up @@ -222,7 +222,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};


let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
Expand Down
Loading

0 comments on commit ce95722

Please sign in to comment.