webgpu: Update wgpu to 0.19 (#31995)

* Update wgpu to 32e70bc163 (0.19)

* Update expect only good

* reexpect

* remove dbg stuff

* Remove all occurrences of dx11_hub
This commit is contained in:
Samson 2024-04-26 09:04:15 +02:00 committed by GitHub
parent 81c4f2ae7a
commit 4af413cd04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 3422 additions and 9526 deletions

View file

@ -3,6 +3,10 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use smallvec::SmallVec;
use webgpu::wgpu::id::markers::{
Adapter, BindGroup, BindGroupLayout, Buffer, CommandEncoder, ComputePipeline, Device,
PipelineLayout, RenderBundle, RenderPipeline, Sampler, ShaderModule, Texture, TextureView,
};
use webgpu::wgpu::id::{
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId,
DeviceId, PipelineLayoutId, RenderBundleId, RenderPipelineId, SamplerId, ShaderModuleId,
@ -11,47 +15,75 @@ use webgpu::wgpu::id::{
use webgpu::wgpu::identity::IdentityManager;
use webgpu::wgt::Backend;
#[derive(Debug, Default)]
#[derive(Debug)]
pub struct IdentityHub {
adapters: IdentityManager,
devices: IdentityManager,
buffers: IdentityManager,
bind_groups: IdentityManager,
bind_group_layouts: IdentityManager,
compute_pipelines: IdentityManager,
pipeline_layouts: IdentityManager,
shader_modules: IdentityManager,
command_encoders: IdentityManager,
textures: IdentityManager,
texture_views: IdentityManager,
samplers: IdentityManager,
render_pipelines: IdentityManager,
render_bundles: IdentityManager,
adapters: IdentityManager<Adapter>,
devices: IdentityManager<Device>,
buffers: IdentityManager<Buffer>,
bind_groups: IdentityManager<BindGroup>,
bind_group_layouts: IdentityManager<BindGroupLayout>,
compute_pipelines: IdentityManager<ComputePipeline>,
pipeline_layouts: IdentityManager<PipelineLayout>,
shader_modules: IdentityManager<ShaderModule>,
command_encoders: IdentityManager<CommandEncoder>,
textures: IdentityManager<Texture>,
texture_views: IdentityManager<TextureView>,
samplers: IdentityManager<Sampler>,
render_pipelines: IdentityManager<RenderPipeline>,
render_bundles: IdentityManager<RenderBundle>,
}
#[derive(Debug, Default)]
impl IdentityHub {
fn new() -> Self {
IdentityHub {
adapters: IdentityManager::new(),
devices: IdentityManager::new(),
buffers: IdentityManager::new(),
bind_groups: IdentityManager::new(),
bind_group_layouts: IdentityManager::new(),
compute_pipelines: IdentityManager::new(),
pipeline_layouts: IdentityManager::new(),
shader_modules: IdentityManager::new(),
command_encoders: IdentityManager::new(),
textures: IdentityManager::new(),
texture_views: IdentityManager::new(),
samplers: IdentityManager::new(),
render_pipelines: IdentityManager::new(),
render_bundles: IdentityManager::new(),
}
}
}
#[derive(Debug)]
pub struct Identities {
_surface: IdentityManager,
#[cfg(any(target_os = "linux", target_os = "windows"))]
vk_hub: IdentityHub,
#[cfg(target_os = "windows")]
dx12_hub: IdentityHub,
#[cfg(target_os = "windows")]
dx11_hub: IdentityHub,
#[cfg(any(target_os = "ios", target_os = "macos"))]
metal_hub: IdentityHub,
dummy_hub: IdentityHub,
}
impl Identities {
pub fn new() -> Self {
Identities {
#[cfg(any(target_os = "linux", target_os = "windows"))]
vk_hub: IdentityHub::new(),
#[cfg(target_os = "windows")]
dx12_hub: IdentityHub::new(),
#[cfg(any(target_os = "ios", target_os = "macos"))]
metal_hub: IdentityHub::new(),
dummy_hub: IdentityHub::new(),
}
}
fn select(&mut self, backend: Backend) -> &mut IdentityHub {
match backend {
#[cfg(any(target_os = "linux", target_os = "windows"))]
Backend::Vulkan => &mut self.vk_hub,
#[cfg(target_os = "windows")]
Backend::Dx12 => &mut self.dx12_hub,
#[cfg(target_os = "windows")]
Backend::Dx11 => &mut self.dx11_hub,
#[cfg(any(target_os = "ios", target_os = "macos"))]
Backend::Metal => &mut self.metal_hub,
_ => &mut self.dummy_hub,
@ -64,8 +96,6 @@ impl Identities {
(&mut self.vk_hub, Backend::Vulkan),
#[cfg(target_os = "windows")]
(&mut self.dx12_hub, Backend::Dx12),
#[cfg(target_os = "windows")]
(&mut self.dx11_hub, Backend::Dx11),
#[cfg(any(target_os = "ios", target_os = "macos"))]
(&mut self.metal_hub, Backend::Metal),
(&mut self.dummy_hub, Backend::Empty),
@ -73,7 +103,7 @@ impl Identities {
}
pub fn create_device_id(&mut self, backend: Backend) -> DeviceId {
self.select(backend).devices.alloc(backend)
self.select(backend).devices.process(backend)
}
pub fn kill_device_id(&mut self, id: DeviceId) {
@ -83,7 +113,7 @@ impl Identities {
pub fn create_adapter_ids(&mut self) -> SmallVec<[AdapterId; 4]> {
let mut ids = SmallVec::new();
for hubs in self.hubs() {
ids.push(hubs.0.adapters.alloc(hubs.1));
ids.push(hubs.0.adapters.process(hubs.1));
}
ids
}
@ -93,7 +123,7 @@ impl Identities {
}
pub fn create_buffer_id(&mut self, backend: Backend) -> BufferId {
self.select(backend).buffers.alloc(backend)
self.select(backend).buffers.process(backend)
}
pub fn kill_buffer_id(&mut self, id: BufferId) {
@ -101,7 +131,7 @@ impl Identities {
}
pub fn create_bind_group_id(&mut self, backend: Backend) -> BindGroupId {
self.select(backend).bind_groups.alloc(backend)
self.select(backend).bind_groups.process(backend)
}
pub fn kill_bind_group_id(&mut self, id: BindGroupId) {
@ -109,7 +139,7 @@ impl Identities {
}
pub fn create_bind_group_layout_id(&mut self, backend: Backend) -> BindGroupLayoutId {
self.select(backend).bind_group_layouts.alloc(backend)
self.select(backend).bind_group_layouts.process(backend)
}
pub fn kill_bind_group_layout_id(&mut self, id: BindGroupLayoutId) {
@ -117,7 +147,7 @@ impl Identities {
}
pub fn create_compute_pipeline_id(&mut self, backend: Backend) -> ComputePipelineId {
self.select(backend).compute_pipelines.alloc(backend)
self.select(backend).compute_pipelines.process(backend)
}
pub fn kill_compute_pipeline_id(&mut self, id: ComputePipelineId) {
@ -125,7 +155,7 @@ impl Identities {
}
pub fn create_pipeline_layout_id(&mut self, backend: Backend) -> PipelineLayoutId {
self.select(backend).pipeline_layouts.alloc(backend)
self.select(backend).pipeline_layouts.process(backend)
}
pub fn kill_pipeline_layout_id(&mut self, id: PipelineLayoutId) {
@ -133,7 +163,7 @@ impl Identities {
}
pub fn create_shader_module_id(&mut self, backend: Backend) -> ShaderModuleId {
self.select(backend).shader_modules.alloc(backend)
self.select(backend).shader_modules.process(backend)
}
pub fn kill_shader_module_id(&mut self, id: ShaderModuleId) {
@ -141,7 +171,7 @@ impl Identities {
}
pub fn create_command_encoder_id(&mut self, backend: Backend) -> CommandEncoderId {
self.select(backend).command_encoders.alloc(backend)
self.select(backend).command_encoders.process(backend)
}
pub fn kill_command_buffer_id(&mut self, id: CommandEncoderId) {
@ -149,7 +179,7 @@ impl Identities {
}
pub fn create_sampler_id(&mut self, backend: Backend) -> SamplerId {
self.select(backend).samplers.alloc(backend)
self.select(backend).samplers.process(backend)
}
pub fn kill_sampler_id(&mut self, id: SamplerId) {
@ -157,7 +187,7 @@ impl Identities {
}
pub fn create_render_pipeline_id(&mut self, backend: Backend) -> RenderPipelineId {
self.select(backend).render_pipelines.alloc(backend)
self.select(backend).render_pipelines.process(backend)
}
pub fn kill_render_pipeline_id(&mut self, id: RenderPipelineId) {
@ -165,7 +195,7 @@ impl Identities {
}
pub fn create_texture_id(&mut self, backend: Backend) -> TextureId {
self.select(backend).textures.alloc(backend)
self.select(backend).textures.process(backend)
}
pub fn kill_texture_id(&mut self, id: TextureId) {
@ -173,7 +203,7 @@ impl Identities {
}
pub fn create_texture_view_id(&mut self, backend: Backend) -> TextureViewId {
self.select(backend).texture_views.alloc(backend)
self.select(backend).texture_views.process(backend)
}
pub fn kill_texture_view_id(&mut self, id: TextureViewId) {
@ -181,7 +211,7 @@ impl Identities {
}
pub fn create_render_bundle_id(&mut self, backend: Backend) -> RenderBundleId {
self.select(backend).render_bundles.alloc(backend)
self.select(backend).render_bundles.process(backend)
}
pub fn kill_render_bundle_id(&mut self, id: RenderBundleId) {