mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-25 08:51:05 +01:00
use reuse checks impl from wgc
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
4689fa4ccb
commit
0acb823f54
2 files changed
+2
-153
No files matched your search
@@ -70,71 +70,7 @@ impl TryFrom<GPUBindGroupLayoutEntry> for wgpu_types::BindGroupLayoutEntry {
|
||||
type Error = wgpu_core::binding_model::CreateBindGroupLayoutError;
|
||||
|
||||
fn try_from(value: GPUBindGroupLayoutEntry) -> Result<Self, Self::Error> {
|
||||
let GPUBindGroupLayoutEntry {
|
||||
binding,
|
||||
visibility,
|
||||
buffer,
|
||||
sampler,
|
||||
texture,
|
||||
storage_texture,
|
||||
external_texture,
|
||||
} = value;
|
||||
|
||||
let mut binding_type = None;
|
||||
if let Some(buffer) = buffer {
|
||||
if binding_type.is_some() {
|
||||
return Err(wgpu_core::binding_model::CreateBindGroupLayoutError::Entry { binding, error: wgpu_core::binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided });
|
||||
}
|
||||
binding_type = Some(wgpu_types::BindingType::Buffer {
|
||||
ty: buffer.r#type.into(),
|
||||
has_dynamic_offset: buffer.has_dynamic_offset,
|
||||
min_binding_size: wgpu_types::BufferSize::new(buffer.min_binding_size),
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(sampler) = sampler {
|
||||
if binding_type.is_some() {
|
||||
return Err(wgpu_core::binding_model::CreateBindGroupLayoutError::Entry { binding, error: wgpu_core::binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided });
|
||||
}
|
||||
binding_type =
|
||||
Some(wgpu_types::BindingType::Sampler(sampler.r#type.into()));
|
||||
}
|
||||
|
||||
if let Some(texture) = texture {
|
||||
if binding_type.is_some() {
|
||||
return Err(wgpu_core::binding_model::CreateBindGroupLayoutError::Entry { binding, error: wgpu_core::binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided });
|
||||
}
|
||||
binding_type = Some(wgpu_types::BindingType::Texture {
|
||||
sample_type: texture.sample_type.into(),
|
||||
view_dimension: texture.view_dimension.into(),
|
||||
multisampled: texture.multisampled,
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(storage_texture) = storage_texture {
|
||||
if binding_type.is_some() {
|
||||
return Err(wgpu_core::binding_model::CreateBindGroupLayoutError::Entry { binding, error: wgpu_core::binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided });
|
||||
}
|
||||
binding_type = Some(wgpu_types::BindingType::StorageTexture {
|
||||
access: storage_texture.access.into(),
|
||||
format: storage_texture.format.into(),
|
||||
view_dimension: storage_texture.view_dimension.into(),
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(GPUExternalTextureBindingLayout {}) = external_texture {
|
||||
if binding_type.is_some() {
|
||||
return Err(wgpu_core::binding_model::CreateBindGroupLayoutError::Entry { binding, error: wgpu_core::binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided });
|
||||
}
|
||||
binding_type = Some(wgpu_types::BindingType::ExternalTexture);
|
||||
}
|
||||
|
||||
Ok(wgpu_types::BindGroupLayoutEntry {
|
||||
binding,
|
||||
visibility: visibility.into(),
|
||||
ty: binding_type.ok_or(wgpu_core::binding_model::CreateBindGroupLayoutError::Entry { binding, error: wgpu_core::binding_model::BindGroupLayoutEntryError::NoBindingTypesProvided })?,
|
||||
count: None, // native-only
|
||||
})
|
||||
wgpu_core::binding_model::BindGroupLayoutEntry::from(value).try_into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -501,94 +501,7 @@ impl Global {
|
||||
fn try_from(
|
||||
value: BindGroupLayoutEntryWrapper,
|
||||
) -> Result<wgt::BindGroupLayoutEntry, Self::Error> {
|
||||
let BindGroupLayoutEntryWrapper(BindGroupLayoutEntry {
|
||||
binding,
|
||||
visibility,
|
||||
buffer,
|
||||
sampler,
|
||||
texture,
|
||||
storage_texture,
|
||||
external_texture,
|
||||
}) = value;
|
||||
let mut binding_ty: Option<wgt::BindingType> = None;
|
||||
if let Some(BufferBindingLayout {
|
||||
ty,
|
||||
has_dynamic_offset,
|
||||
min_binding_size,
|
||||
}) = buffer.to_std()
|
||||
{
|
||||
binding_ty = Some(wgt::BindingType::Buffer {
|
||||
ty,
|
||||
has_dynamic_offset,
|
||||
min_binding_size,
|
||||
});
|
||||
}
|
||||
if let Some(SamplerBindingLayout { ty }) = sampler.to_std() {
|
||||
if binding_ty.is_some() {
|
||||
return Err(binding_model::CreateBindGroupLayoutError::Entry {
|
||||
binding,
|
||||
error: binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided,
|
||||
});
|
||||
}
|
||||
binding_ty = Some(wgt::BindingType::Sampler(ty))
|
||||
}
|
||||
if let Some(TextureBindingLayout {
|
||||
sample_type,
|
||||
view_dimension,
|
||||
multisampled,
|
||||
}) = texture.to_std()
|
||||
{
|
||||
if binding_ty.is_some() {
|
||||
return Err(binding_model::CreateBindGroupLayoutError::Entry {
|
||||
binding,
|
||||
error: binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided,
|
||||
});
|
||||
}
|
||||
binding_ty = Some(wgt::BindingType::Texture {
|
||||
sample_type,
|
||||
view_dimension,
|
||||
multisampled,
|
||||
})
|
||||
}
|
||||
if let Some(StorageTextureBindingLayout {
|
||||
access,
|
||||
format,
|
||||
view_dimension,
|
||||
}) = storage_texture.to_std()
|
||||
{
|
||||
if binding_ty.is_some() {
|
||||
return Err(binding_model::CreateBindGroupLayoutError::Entry {
|
||||
binding,
|
||||
error: binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided,
|
||||
});
|
||||
}
|
||||
binding_ty = Some(wgt::BindingType::StorageTexture {
|
||||
access,
|
||||
format,
|
||||
view_dimension,
|
||||
})
|
||||
}
|
||||
if external_texture {
|
||||
if binding_ty.is_some() {
|
||||
return Err(binding_model::CreateBindGroupLayoutError::Entry {
|
||||
binding,
|
||||
error: binding_model::BindGroupLayoutEntryError::MultipleBindingTypesProvided,
|
||||
});
|
||||
}
|
||||
binding_ty = Some(wgt::BindingType::ExternalTexture)
|
||||
}
|
||||
Ok(wgt::BindGroupLayoutEntry {
|
||||
binding,
|
||||
visibility: wgt::ShaderStages::from_internal_flags(
|
||||
visibility,
|
||||
wgt::ShaderStagesWGPU::empty(),
|
||||
),
|
||||
ty: binding_ty.ok_or(binding_model::CreateBindGroupLayoutError::Entry {
|
||||
binding,
|
||||
error: binding_model::BindGroupLayoutEntryError::NoBindingTypesProvided,
|
||||
})?,
|
||||
count: None,
|
||||
})
|
||||
binding_model::BindGroupLayoutEntry::from(value).try_into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user