diff --git a/Cargo.lock b/Cargo.lock index 74a2a3fa1..798d0b511 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ab_glyph" @@ -4866,6 +4866,7 @@ dependencies = [ name = "wgpu-core-remote-types" version = "30.0.0" dependencies = [ + "hashbrown 0.17.1", "serde", "wgpu-types", ] diff --git a/wgpu-core-remote-types/Cargo.toml b/wgpu-core-remote-types/Cargo.toml index 8dbe2abaa..19f9d2f2b 100644 --- a/wgpu-core-remote-types/Cargo.toml +++ b/wgpu-core-remote-types/Cargo.toml @@ -27,3 +27,4 @@ targets = [ [dependencies] wgpu-types = { workspace = true, features = ["serde"] } serde = { workspace = true } +hashbrown = { workspace = true } diff --git a/wgpu-core-remote-types/src/lib.rs b/wgpu-core-remote-types/src/lib.rs index 295d1d3c7..79dc13ecf 100644 --- a/wgpu-core-remote-types/src/lib.rs +++ b/wgpu-core-remote-types/src/lib.rs @@ -28,6 +28,7 @@ pub mod identity; pub mod binding_model; pub mod encoders; pub mod ffi; +pub mod pipelines; pub type Label<'a> = Option>; diff --git a/wgpu-core-remote-types/src/pipelines.rs b/wgpu-core-remote-types/src/pipelines.rs new file mode 100644 index 000000000..88f0a5e5e --- /dev/null +++ b/wgpu-core-remote-types/src/pipelines.rs @@ -0,0 +1,41 @@ +use crate::{id, Label}; +use alloc::borrow::Cow; +use hashbrown::HashMap; + +/// Describes a programmable pipeline stage. +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +/// cbindgen:ignore +pub struct ProgrammableStageDescriptor<'a> { + /// The compiled shader module for this stage. + pub module: id::ShaderModuleId, + + /// The name of the entry point in `module` that this stage should use. + /// + /// - If this is `Some(name)`, `module` must contain an entry point with the + /// given name. + /// + /// - If this is `None`, `module` must have only one entry point for this + /// stage; we use that one. + pub entry_point: Option>, + + /// Values for pipeline-overridable constants in `module` that this stage + /// should use. + /// + /// If an `@id` attribute was specified on the declaration, + /// the key must be the pipeline constant ID as a decimal ASCII number; if not, + /// the key must be the constant's identifier name. + /// + /// The value may represent any of WGSL's concrete scalar types. + pub constants: HashMap, +} + +/// Describes a compute pipeline. +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +/// cbindgen:ignore +pub struct ComputePipelineDescriptor<'a> { + pub label: Label<'a>, + /// The layout of bind groups for this pipeline. + pub layout: Option, + /// The compiled compute stage and its entry point. + pub stage: ProgrammableStageDescriptor<'a>, +} diff --git a/wgpu-core-remote/src/global/device.rs b/wgpu-core-remote/src/global/device.rs index 4db44c72a..83bb64d2f 100644 --- a/wgpu-core-remote/src/global/device.rs +++ b/wgpu-core-remote/src/global/device.rs @@ -1,6 +1,8 @@ use alloc::{borrow::Cow, boxed::Box, sync::Arc, vec::Vec}; use core::ptr::NonNull; -use wgpu_core_remote_types::encoders::RenderBundleDescriptor; +use wgpu_core_remote_types::{ + encoders::RenderBundleDescriptor, pipelines::ComputePipelineDescriptor, +}; use wgpu_core::{ binding_model::{self}, @@ -28,13 +30,6 @@ use wgt::{error::WebGpuError, BufferAddress}; pub use wgpu_core_remote_types::binding_model::*; -pub type ComputePipelineDescriptor<'a> = pipeline::ComputePipelineDescriptor< - 'a, - id::PipelineLayoutId, - id::ShaderModuleId, - id::PipelineCacheId, ->; - pub type RenderPipelineDescriptor<'a> = pipeline::RenderPipelineDescriptor< 'a, id::PipelineLayoutId, @@ -887,7 +882,6 @@ impl Global { devices, shader_modules, pipeline_layouts, - pipeline_caches, .. } = &mut *hub; @@ -895,22 +889,20 @@ impl Global { let layout = desc.layout.map(|layout| pipeline_layouts.get(layout)); - let cache = desc.cache.map(|cache| pipeline_caches.get(cache)); - let module = shader_modules.get(desc.stage.module); let stage = ProgrammableStageDescriptor { module, entry_point: desc.stage.entry_point.clone(), constants: desc.stage.constants.clone(), - zero_initialize_workgroup_memory: desc.stage.zero_initialize_workgroup_memory, + zero_initialize_workgroup_memory: true, }; let desc = pipeline::ComputePipelineDescriptor { label: desc.label.clone(), layout, stage, - cache, + cache: None, }; let pipeline = device.create_compute_pipeline(desc); @@ -935,7 +927,6 @@ impl Global { devices, shader_modules, pipeline_layouts, - pipeline_caches, .. } = &mut *hub; @@ -943,22 +934,20 @@ impl Global { let layout = desc.layout.map(|layout| pipeline_layouts.get(layout)); - let cache = desc.cache.map(|cache| pipeline_caches.get(cache)); - let module = shader_modules.get(desc.stage.module); let stage = ProgrammableStageDescriptor { module, entry_point: desc.stage.entry_point.clone(), constants: desc.stage.constants.clone(), - zero_initialize_workgroup_memory: desc.stage.zero_initialize_workgroup_memory, + zero_initialize_workgroup_memory: true, }; let desc = pipeline::ComputePipelineDescriptor { label: desc.label.clone(), layout, stage, - cache, + cache: None, }; match device.create_compute_pipeline_or_error(desc) {