You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This wording gives the impression that you can drop an Instance and create a new one elsewhere without side effects. However, that is not entirely correct in practice.
For example:
let instance_1 = wgpu::Instance::new(...);
let surface = instance_1.create_surface(window); // ex: winit window
let instance_2 = wgpu::Instance::new(...);
let adapter = instance_2.request_adapter(
&wgpu::RequestAdapterOptions {
compatible_surface: Some(&surface),
...
}
);
The reason is that Surfaces are tied to the Instance that created them. Internally, wgpu uses per-instance ID/epoch bookkeeping, so different instances cannot share surfaces.
Current docs do not make this restriction clear and might give the impression that instances are interchangeable.
PS: I'm opening this as a Q&A because I'm not sure if this counts as a bug (behavior is likely intended but the documentation could better explain this limitation)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The docs for wgpu::Instance state:
This wording gives the impression that you can drop an Instance and create a new one elsewhere without side effects. However, that is not entirely correct in practice.
For example:
The last call panics with:
(from wgpu-core storage)
The reason is that Surfaces are tied to the Instance that created them. Internally, wgpu uses per-instance ID/epoch bookkeeping, so different instances cannot share surfaces.
Current docs do not make this restriction clear and might give the impression that instances are interchangeable.
PS: I'm opening this as a Q&A because I'm not sure if this counts as a bug (behavior is likely intended but the documentation could better explain this limitation)
Beta Was this translation helpful? Give feedback.
All reactions