mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +01:00
[remote] ComputePipelineDescriptor
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
0445613f1a
commit
c25604de00
5 files changed
+52
-19
No files matched your search
Generated
+2
-1
@@ -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",
|
||||
]
|
||||
|
||||
@@ -27,3 +27,4 @@ targets = [
|
||||
[dependencies]
|
||||
wgpu-types = { workspace = true, features = ["serde"] }
|
||||
serde = { workspace = true }
|
||||
hashbrown = { workspace = true }
|
||||
@@ -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<Cow<'a, str>>;
|
||||
|
||||
|
||||
@@ -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<Cow<'a, str>>,
|
||||
|
||||
/// 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<String, f64>,
|
||||
}
|
||||
|
||||
/// 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<id::PipelineLayoutId>,
|
||||
/// The compiled compute stage and its entry point.
|
||||
pub stage: ProgrammableStageDescriptor<'a>,
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user