Skip to content

Commit 75a98f2

Browse files
authored
Validate that the view dimension of a multisampled texture binding is 2d (#5274)
* Validate that the view dimension of a multisampled texture binding is 2d * typo
1 parent 910fb7c commit 75a98f2

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

wgpu-core/src/binding_model.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub enum BindGroupLayoutEntryError {
3838
ArrayUnsupported,
3939
#[error("Multisampled binding with sample type `TextureSampleType::Float` must have filterable set to false.")]
4040
SampleTypeFloatFilterableBindingMultisampled,
41+
#[error("Multisampled texture binding view dimension must be 2d, got {0:?}")]
42+
Non2DMultisampled(wgt::TextureViewDimension),
4143
#[error(transparent)]
4244
MissingFeatures(#[from] MissingFeatures),
4345
#[error(transparent)]

wgpu-core/src/device/resource.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,10 +1714,23 @@ impl<A: HalApi> Device<A> {
17141714
BindGroupLayoutEntryError::SampleTypeFloatFilterableBindingMultisampled,
17151715
});
17161716
}
1717-
Bt::Texture { .. } => (
1718-
Some(wgt::Features::TEXTURE_BINDING_ARRAY),
1719-
WritableStorage::No,
1720-
),
1717+
Bt::Texture {
1718+
multisampled,
1719+
view_dimension,
1720+
..
1721+
} => {
1722+
if multisampled && view_dimension != TextureViewDimension::D2 {
1723+
return Err(binding_model::CreateBindGroupLayoutError::Entry {
1724+
binding: entry.binding,
1725+
error: BindGroupLayoutEntryError::Non2DMultisampled(view_dimension),
1726+
});
1727+
}
1728+
1729+
(
1730+
Some(wgt::Features::TEXTURE_BINDING_ARRAY),
1731+
WritableStorage::No,
1732+
)
1733+
}
17211734
Bt::StorageTexture {
17221735
access,
17231736
view_dimension,

0 commit comments

Comments
 (0)