Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Merge #345
Browse files Browse the repository at this point in the history
345: Rustify the example's use of Extensions and SamplerDescriptor r=kvark a=cwfitzgerald

Implements gfx-rs/wgpu#696.

This didn't change any content from #338, just interface, but I tested a couple examples and it seems to work okay.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
  • Loading branch information
bors[bot] and cwfitzgerald authored Jun 3, 2020
2 parents 2370602 + cf9d9d6 commit 38eb981
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 31 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ vulkan = ["wgc/gfx-backend-vulkan"]
package = "wgpu-core"
version = "0.5"
git = "https://github.com/gfx-rs/wgpu"
rev = "9120f0399ce8d8cc48b0b87c26d58c71b2e925be"
rev = "ac9587e9ced5b043abad68e260cb8c9e812cffb5"
features = ["raw-window-handle"]

[dependencies.wgt]
package = "wgpu-types"
version = "0.5"
git = "https://github.com/gfx-rs/wgpu"
rev = "9120f0399ce8d8cc48b0b87c26d58c71b2e925be"
rev = "ac9587e9ced5b043abad68e260cb8c9e812cffb5"

[dependencies]
arrayvec = "0.5"
Expand Down
4 changes: 1 addition & 3 deletions examples/capture/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ async fn run() {
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
extensions: wgpu::Extensions {
anisotropic_filtering: false,
},
extensions: wgpu::Extensions::empty(),
limits: wgpu::Limits::default(),
},
None,
Expand Down
4 changes: 2 additions & 2 deletions examples/cube/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ impl framework::Example for Example {
mipmap_filter: wgpu::FilterMode::Nearest,
lod_min_clamp: 0.0,
lod_max_clamp: 100.0,
compare: wgpu::CompareFunction::Undefined,
anisotropy_clamp: 1,
compare: None,
anisotropy_clamp: None,
});
let mx_total = Self::generate_matrix(sc_desc.width as f32 / sc_desc.height as f32);
let mx_ref: &[f32; 16] = mx_total.as_ref();
Expand Down
4 changes: 1 addition & 3 deletions examples/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ async fn run_async<E: Example>(event_loop: EventLoop<()>, window: Window) {
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
extensions: wgpu::Extensions {
anisotropic_filtering: false,
},
extensions: wgpu::Extensions::empty(),
limits: wgpu::Limits::default(),
},
trace_dir.ok().as_ref().map(std::path::Path::new),
Expand Down
4 changes: 1 addition & 3 deletions examples/hello-compute/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ async fn execute_gpu(numbers: Vec<u32>) -> Vec<u32> {
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
extensions: wgpu::Extensions {
anisotropic_filtering: false,
},
extensions: wgpu::Extensions::empty(),
limits: wgpu::Limits::default(),
},
None,
Expand Down
4 changes: 1 addition & 3 deletions examples/hello-triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu::
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
extensions: wgpu::Extensions {
anisotropic_filtering: false,
},
extensions: wgpu::Extensions::empty(),
limits: wgpu::Limits::default(),
},
None,
Expand Down
8 changes: 4 additions & 4 deletions examples/mipmap/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ impl Example {
mipmap_filter: wgpu::FilterMode::Nearest,
lod_min_clamp: 0.0,
lod_max_clamp: 100.0,
compare: wgpu::CompareFunction::Undefined,
anisotropy_clamp: 1,
compare: None,
anisotropy_clamp: None,
});

let views = (0..mip_count)
Expand Down Expand Up @@ -309,8 +309,8 @@ impl framework::Example for Example {
mipmap_filter: wgpu::FilterMode::Linear,
lod_min_clamp: 0.0,
lod_max_clamp: 100.0,
compare: wgpu::CompareFunction::Undefined,
anisotropy_clamp: 1,
compare: None,
anisotropy_clamp: None,
});
let mx_total = Self::generate_matrix(sc_desc.width as f32 / sc_desc.height as f32);
let mx_ref: &[f32; 16] = mx_total.as_ref();
Expand Down
4 changes: 2 additions & 2 deletions examples/shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ impl framework::Example for Example {
mipmap_filter: wgpu::FilterMode::Nearest,
lod_min_clamp: -100.0,
lod_max_clamp: 100.0,
compare: wgpu::CompareFunction::LessEqual,
anisotropy_clamp: 1,
compare: Some(wgpu::CompareFunction::LessEqual),
anisotropy_clamp: None,
});

let shadow_texture = device.create_texture(&wgpu::TextureDescriptor {
Expand Down
4 changes: 2 additions & 2 deletions examples/skybox/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ impl framework::Example for Skybox {
mipmap_filter: wgpu::FilterMode::Nearest,
lod_min_clamp: 0.0,
lod_max_clamp: 100.0,
compare: wgpu::CompareFunction::Undefined,
anisotropy_clamp: 1,
compare: None,
anisotropy_clamp: None,
});

let paths: [&'static [u8]; 6] = [
Expand Down
10 changes: 3 additions & 7 deletions src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,7 @@ impl crate::Context for Context {

fn adapter_extensions(&self, _adapter: &Self::AdapterId) -> wgt::Extensions {
// TODO: web-sys has no way of getting extensions on adapters
wgt::Extensions {
anisotropic_filtering: false,
}
wgt::Extensions::empty()
}

fn adapter_limits(&self, _adapter: &Self::AdapterId) -> wgt::Limits {
Expand All @@ -715,9 +713,7 @@ impl crate::Context for Context {

fn device_extensions(&self, _device: &Self::DeviceId) -> wgt::Extensions {
// TODO: web-sys has no way of getting extensions on devices
wgt::Extensions {
anisotropic_filtering: false,
}
wgt::Extensions::empty()
}

fn device_limits(&self, _device: &Self::DeviceId) -> wgt::Limits {
Expand Down Expand Up @@ -991,7 +987,7 @@ impl crate::Context for Context {
mapped_desc.address_mode_u(map_address_mode(desc.address_mode_u));
mapped_desc.address_mode_v(map_address_mode(desc.address_mode_v));
mapped_desc.address_mode_w(map_address_mode(desc.address_mode_w));
if let Some(compare) = map_compare_function(desc.compare) {
if let Some(compare) = desc.compare.and_then(map_compare_function) {
mapped_desc.compare(compare);
}
mapped_desc.lod_max_clamp(desc.lod_max_clamp);
Expand Down

0 comments on commit 38eb981

Please sign in to comment.