Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,11 @@ impl Device {
});
}

if desc.size.depth_or_array_layers != 1 {
if desc.size.depth_or_array_layers != 1
&& !format_features
.flags
.contains(wgt::TextureFormatFeatureFlags::MULTISAMPLE_ARRAY)
{
return Err(CreateTextureError::InvalidDimension(
TextureDimensionError::MultisampledDepthOrArrayLayer(
desc.size.depth_or_array_layers,
Expand Down Expand Up @@ -1736,11 +1740,19 @@ impl Device {

// check if multisampled texture is seen as anything but 2D
if texture.desc.sample_count > 1 && resolved_dimension != TextureViewDimension::D2 {
return Err(
resource::CreateTextureViewError::InvalidMultisampledTextureViewDimension(
resolved_dimension,
),
);
// Multisample is allowed on 2D arrays, only if explicitly supported
let multisample_array_exception = resolved_dimension == TextureViewDimension::D2Array
&& format_features
.flags
.contains(wgt::TextureFormatFeatureFlags::MULTISAMPLE_ARRAY);

if !multisample_array_exception {
return Err(
resource::CreateTextureViewError::InvalidMultisampledTextureViewDimension(
resolved_dimension,
),
);
}
}

// check if the dimension is compatible with the texture
Expand Down
5 changes: 5 additions & 0 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,11 @@ impl Adapter {
caps.contains(Tfc::MULTISAMPLE_RESOLVE),
);

flags.set(
wgt::TextureFormatFeatureFlags::MULTISAMPLE_ARRAY,
caps.contains(Tfc::MULTISAMPLE_ARRAY),
);

wgt::TextureFormatFeatures {
allowed_usages,
flags,
Expand Down
3 changes: 3 additions & 0 deletions wgpu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,9 @@ bitflags!(
const COPY_SRC = 1 << 15;
/// Format can be copied to.
const COPY_DST = 1 << 16;

/// Format can be used with both multisample and array at the same time.
const MULTISAMPLE_ARRAY = 1 << 17;
}
);

Expand Down
3 changes: 3 additions & 0 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2616,6 +2616,9 @@ impl crate::Adapter for super::Adapter {
// Vulkan is very permissive about MSAA
flags.set(Tfc::MULTISAMPLE_RESOLVE, !format.is_compressed());

// Unless we're on a portability subset, this is always allowed
flags.set(Tfc::MULTISAMPLE_ARRAY, true);

// get the supported sample counts
let format_aspect = crate::FormatAspects::from(format);
let limits = self.phd_capabilities.properties.limits;
Expand Down
3 changes: 3 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,9 @@ bitflags::bitflags! {
const STORAGE_ATOMIC = 1 << 9;
/// If not present, the texture can't be blended into the render target.
const BLENDABLE = 1 << 10;
/// Allows a 2D texture of this format to have a `sample_count` higher than 1, and more
/// than 1 array layer at the same time.
const MULTISAMPLE_ARRAY = 1 << 11;
}
}

Expand Down
Loading