Skip to content

Commit fb210ab

Browse files
authored
Pass InstanceDescriptor by reference and make it clonable (#6849)
1 parent 74f3a2f commit fb210ab

File tree

21 files changed

+39
-26
lines changed

21 files changed

+39
-26
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ There are some limitations to keep in mind with this new functionality:
125125

126126
By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148](https://github.com/gfx-rs/wgpu/pull/6148), [#6533](https://github.com/gfx-rs/wgpu/pull/6533), [#6353](https://github.com/gfx-rs/wgpu/pull/6353), [#6537](https://github.com/gfx-rs/wgpu/pull/6537).
127127

128+
#### `wgpu::Instance::new` now takes `InstanceDescriptor` by reference
129+
130+
Previously `wgpu::Instance::new` took `InstanceDescriptor` by value (which is overall fairly uncommon in wgpu).
131+
Furthermore, `InstanceDescriptor` is now cloneable.
132+
133+
```diff
134+
- let instance = wgpu::Instance::new(instance_desc);
135+
+ let instance = wgpu::Instance::new(&instance_desc);
136+
```
137+
138+
By @wumpf in [#6849](https://github.com/gfx-rs/wgpu/pull/6849).
139+
128140
#### New Features
129141

130142
##### Naga

benches/benches/root.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl DeviceState {
2525
wgpu::Backends::all()
2626
};
2727

28-
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
28+
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
2929
backends: wgpu::util::backend_bits_from_env().unwrap_or(base_backend),
3030
flags: wgpu::InstanceFlags::empty(),
3131
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env()

deno_webgpu/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ pub fn op_webgpu_request_adapter(
388388
} else {
389389
state.put(std::sync::Arc::new(wgpu_core::global::Global::new(
390390
"webgpu",
391-
wgpu_types::InstanceDescriptor {
391+
&wgpu_types::InstanceDescriptor {
392392
backends,
393393
flags: wgpu_types::InstanceFlags::from_build_config(),
394394
dx12_shader_compiler: wgpu_types::Dx12Compiler::Fxc,

examples/src/framework.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl ExampleContext {
268268
async fn init_async<E: Example>(surface: &mut SurfaceWrapper, window: Arc<Window>) -> Self {
269269
log::info!("Initializing wgpu...");
270270

271-
let instance = wgpu::Instance::new(wgpu::util::instance_descriptor_from_env());
271+
let instance = wgpu::Instance::new(&wgpu::util::instance_descriptor_from_env());
272272
surface.pre_adapter(&instance, window);
273273

274274
let adapter = get_adapter_with_capabilities_or_from_env(

examples/src/hello_triangle/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
1010
size.width = size.width.max(1);
1111
size.height = size.height.max(1);
1212

13-
let instance = wgpu::Instance::new(wgpu::util::instance_descriptor_from_env());
13+
let instance = wgpu::Instance::new(&wgpu::util::instance_descriptor_from_env());
1414

1515
let surface = instance.create_surface(&window).unwrap();
1616
let adapter = instance

examples/src/timestamp_queries/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl Queries {
181181
async fn run() {
182182
// Instantiates instance of wgpu
183183
let backends = wgpu::util::backend_bits_from_env().unwrap_or_default();
184-
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
184+
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
185185
backends,
186186
flags: wgpu::InstanceFlags::from_build_config().with_env(),
187187
dx12_shader_compiler: wgpu::Dx12Compiler::default(),

player/src/bin/play.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn main() {
4848
.build(&event_loop)
4949
.unwrap();
5050

51-
let global = wgc::global::Global::new("player", wgt::InstanceDescriptor::default());
51+
let global = wgc::global::Global::new("player", &wgt::InstanceDescriptor::default());
5252
let mut command_buffer_id_manager = wgc::identity::IdentityManager::new();
5353

5454
#[cfg(feature = "winit")]

player/tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl Corpus {
201201

202202
let global = wgc::global::Global::new(
203203
"test",
204-
wgt::InstanceDescriptor {
204+
&wgt::InstanceDescriptor {
205205
backends: backend.into(),
206206
flags: wgt::InstanceFlags::debugging(),
207207
dx12_shader_compiler: wgt::Dx12Compiler::Fxc,

tests/compile_tests/fail/cpass_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// See #6145 for more info.
55

66
fn main() {
7-
let instance = wgpu::Instance::new(Default::default());
7+
let instance = wgpu::Instance::default();
88
let adapter = pollster::block_on(instance.request_adapter(&Default::default())).unwrap();
99
let (device, queue) =
1010
pollster::block_on(adapter.request_device(&Default::default(), None)).unwrap();

tests/compile_tests/fail/rpass_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// See #6145 for more info.
55

66
fn main() {
7-
let instance = wgpu::Instance::new(Default::default());
7+
let instance = wgpu::Instance::default();
88
let adapter = pollster::block_on(instance.request_adapter(&Default::default())).unwrap();
99
let (device, queue) =
1010
pollster::block_on(adapter.request_device(&Default::default(), None)).unwrap();

0 commit comments

Comments
 (0)