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

Commit

Permalink
Merge #360
Browse files Browse the repository at this point in the history
360: Implement TEXTURE_BINDING_ARRAY extension r=kvark a=cwfitzgerald

This extends gfx-rs/wgpu#711 into wgpu-rs.

Notable changes: 
- Added an example showing off both this extension and the future descriptor indexing extension.
- Changed the framework so there is a static function showing what extensions you need. This is provided by the trait,, which defaults to no extensions, so existing examples and new ones don't have to care about extensions.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
  • Loading branch information
bors[bot] and cwfitzgerald committed Jun 11, 2020
2 parents ddaea7d + f8be38c commit 7b887f1
Show file tree
Hide file tree
Showing 16 changed files with 419 additions and 190 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ vulkan = ["wgc/gfx-backend-vulkan"]
package = "wgpu-core"
version = "0.5"
git = "https://github.com/gfx-rs/wgpu"
rev = "eaf8f4af87237373105b016832662e7943b3899c"
rev = "64ae59072db443eb1e47ee14d77370eec9f4b012"
features = ["raw-window-handle"]

[dependencies.wgt]
package = "wgpu-types"
version = "0.5"
git = "https://github.com/gfx-rs/wgpu"
rev = "eaf8f4af87237373105b016832662e7943b3899c"
rev = "64ae59072db443eb1e47ee14d77370eec9f4b012"

[dependencies]
arrayvec = "0.5"
futures = "0.3"
smallvec = "1"
typed-arena = "2.0.1"
raw-window-handle = "0.3"
parking_lot = "0.10"

Expand Down Expand Up @@ -72,6 +73,7 @@ test = true
#gfx-backend-vulkan = { version = "0.5.0", path = "../gfx/src/backend/vulkan" }
#gfx-backend-dx12 = { version = "0.5.0", path = "../gfx/src/backend/dx12" }
#gfx-backend-dx11 = { version = "0.5.0", path = "../gfx/src/backend/dx11" }
#gfx-backend-metal = { version = "0.5.0", path = "../gfx/src/backend/dx11" }
#gfx-descriptor = { version = "0.1.0", path = "../gfx-extras/gfx-descriptor" }
#gfx-memory = { version = "0.1.0", path = "../gfx-extras/gfx-memory" }

Expand Down
3 changes: 3 additions & 0 deletions examples/boids/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl framework::Example for Example {
binding: 0,
visibility: wgpu::ShaderStage::COMPUTE,
ty: wgpu::BindingType::UniformBuffer { dynamic: false },
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 1,
Expand All @@ -65,6 +66,7 @@ impl framework::Example for Example {
dynamic: false,
readonly: false,
},
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 2,
Expand All @@ -73,6 +75,7 @@ impl framework::Example for Example {
dynamic: false,
readonly: false,
},
..Default::default()
},
],
label: None,
Expand Down
3 changes: 3 additions & 0 deletions examples/cube/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl framework::Example for Example {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX,
ty: wgpu::BindingType::UniformBuffer { dynamic: false },
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 1,
Expand All @@ -148,11 +149,13 @@ impl framework::Example for Example {
component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2,
},
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 2,
visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false },
..Default::default()
},
],
});
Expand Down
11 changes: 9 additions & 2 deletions examples/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub enum ShaderStage {
}

pub trait Example: 'static + Sized {
fn needed_extensions() -> (wgt::Extensions, wgt::UnsafeExtensions) {
(wgpu::Extensions::empty(), wgt::UnsafeExtensions::disallow())
}
fn init(
sc_desc: &wgpu::SwapChainDescriptor,
device: &wgpu::Device,
Expand Down Expand Up @@ -60,23 +63,27 @@ async fn run_async<E: Example>(event_loop: EventLoop<()>, window: Window) {
(size, surface)
};

let (needed_extensions, unsafe_extensions) = E::needed_extensions();

let adapter = instance
.request_adapter(
&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::Default,
compatible_surface: Some(&surface),
},
wgpu::UnsafeExtensions::disallow(),
unsafe_extensions,
wgpu::BackendBit::PRIMARY,
)
.await
.unwrap();

let adapter_extensions = adapter.extensions();

let trace_dir = std::env::var("WGPU_TRACE");
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
extensions: wgpu::Extensions::empty(),
extensions: adapter_extensions & needed_extensions,
limits: wgpu::Limits::default(),
shader_validation: true,
},
Expand Down
1 change: 1 addition & 0 deletions examples/hello-compute/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async fn execute_gpu(numbers: Vec<u32>) -> Vec<u32> {
dynamic: false,
readonly: false,
},
..Default::default()
}],
});

Expand Down
5 changes: 5 additions & 0 deletions examples/mipmap/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ impl Example {
component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2,
},
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false },
..Default::default()
},
],
label: None,
Expand Down Expand Up @@ -231,6 +233,7 @@ impl framework::Example for Example {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX,
ty: wgpu::BindingType::UniformBuffer { dynamic: false },
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 1,
Expand All @@ -240,11 +243,13 @@ impl framework::Example for Example {
multisampled: false,
dimension: wgpu::TextureViewDimension::D2,
},
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 2,
visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false },
..Default::default()
},
],
label: None,
Expand Down
6 changes: 6 additions & 0 deletions examples/shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ impl framework::Example for Example {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer { dynamic: false },
..Default::default()
}],
label: None,
});
Expand Down Expand Up @@ -430,6 +431,7 @@ impl framework::Example for Example {
binding: 0, // global
visibility: wgpu::ShaderStage::VERTEX,
ty: wgpu::BindingType::UniformBuffer { dynamic: false },
..Default::default()
}],
label: None,
});
Expand Down Expand Up @@ -518,11 +520,13 @@ impl framework::Example for Example {
binding: 0, // global
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer { dynamic: false },
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 1, // lights
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer { dynamic: false },
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 2,
Expand All @@ -532,11 +536,13 @@ impl framework::Example for Example {
component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2Array,
},
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 3,
visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: true },
..Default::default()
},
],
label: None,
Expand Down
3 changes: 3 additions & 0 deletions examples/skybox/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl framework::Example for Skybox {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer { dynamic: false },
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 1,
Expand All @@ -55,11 +56,13 @@ impl framework::Example for Skybox {
multisampled: false,
dimension: wgpu::TextureViewDimension::Cube,
},
..Default::default()
},
wgpu::BindGroupLayoutEntry {
binding: 2,
visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false },
..Default::default()
},
],
label: None,
Expand Down
Loading

0 comments on commit 7b887f1

Please sign in to comment.