mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
webgpu: Support pipeline-overridable constants (#33291)
* Impl pipeline constants Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * More relaxed lifetimes Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Replace convert function with `From` implementation Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
a976db3ec0
commit
3c6ca33832
4 changed files with 32 additions and 395 deletions
|
@ -6,8 +6,10 @@ use std::borrow::Cow;
|
|||
use std::num::NonZeroU64;
|
||||
|
||||
use webgpu::wgc::command as wgpu_com;
|
||||
use webgpu::wgc::pipeline::ProgrammableStageDescriptor;
|
||||
use webgpu::wgt::{self, AstcBlock, AstcChannel};
|
||||
|
||||
use super::bindings::codegen::Bindings::WebGPUBinding::GPUProgrammableStage;
|
||||
use super::bindings::error::Error;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
||||
GPUAddressMode, GPUBindGroupLayoutEntry, GPUBlendComponent, GPUBlendFactor, GPUBlendOperation,
|
||||
|
@ -473,7 +475,7 @@ pub fn convert_ic_texture(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn convert_label(parent: &GPUObjectDescriptorBase) -> Option<Cow<'static, str>> {
|
||||
pub fn convert_label<'a>(parent: &GPUObjectDescriptorBase) -> Option<Cow<'a, str>> {
|
||||
if parent.label.is_empty() {
|
||||
None
|
||||
} else {
|
||||
|
@ -579,3 +581,23 @@ pub fn convert_color(color: &GPUColor) -> Fallible<wgt::Color> {
|
|||
}),
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&GPUProgrammableStage> for ProgrammableStageDescriptor<'a> {
|
||||
fn from(stage: &GPUProgrammableStage) -> Self {
|
||||
Self {
|
||||
module: stage.module.id().0,
|
||||
entry_point: stage
|
||||
.entryPoint
|
||||
.as_ref()
|
||||
.map(|ep| Cow::Owned(ep.to_string())),
|
||||
constants: Cow::Owned(
|
||||
stage
|
||||
.constants
|
||||
.as_ref()
|
||||
.map(|records| records.iter().map(|(k, v)| (k.0.clone(), **v)).collect())
|
||||
.unwrap_or_default(),
|
||||
),
|
||||
zero_initialize_workgroup_memory: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue