Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MULTISAMPLE_X16 texture format feature flag #3454

Merged
merged 1 commit into from
Feb 6, 2023
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Bottom level categories:

### Changes

#### General

- Added `TextureFormatFeatureFlags::MULTISAMPLE_X16`. By @Dinnerbone in [#3454](https://github.com/gfx-rs/wgpu/pull/3454)

#### WebGPU

- Implement `CommandEncoder::clear_buffer`. By @raphlinus in [#3426](https://github.com/gfx-rs/wgpu/pull/3426)
Expand Down
3 changes: 2 additions & 1 deletion wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,8 @@ impl<A: HalApi> Device<A> {
if !format_features.flags.intersects(
wgt::TextureFormatFeatureFlags::MULTISAMPLE_X4
| wgt::TextureFormatFeatureFlags::MULTISAMPLE_X2
| wgt::TextureFormatFeatureFlags::MULTISAMPLE_X8,
| wgt::TextureFormatFeatureFlags::MULTISAMPLE_X8
| wgt::TextureFormatFeatureFlags::MULTISAMPLE_X16,
) {
return Err(CreateTextureError::InvalidMultisampledFormat(desc.format));
}
Expand Down
4 changes: 4 additions & 0 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ impl<A: HalApi> Adapter<A> {
wgt::TextureFormatFeatureFlags::MULTISAMPLE_X8,
caps.contains(Tfc::MULTISAMPLE_X8),
);
flags.set(
wgt::TextureFormatFeatureFlags::MULTISAMPLE_X16,
caps.contains(Tfc::MULTISAMPLE_X16),
);

flags.set(
wgt::TextureFormatFeatureFlags::MULTISAMPLE_RESOLVE,
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/dx12/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
set_sample_count(2, Tfc::MULTISAMPLE_X2);
set_sample_count(4, Tfc::MULTISAMPLE_X4);
set_sample_count(8, Tfc::MULTISAMPLE_X8);
set_sample_count(16, Tfc::MULTISAMPLE_X16);

caps
}
Expand Down
7 changes: 6 additions & 1 deletion wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,12 @@ impl crate::Adapter<super::Api> for super::Adapter {
.lock()
.get_parameter_i32(glow::MAX_SAMPLES)
};
if max_samples >= 8 {
if max_samples >= 16 {
Tfc::MULTISAMPLE_X2
| Tfc::MULTISAMPLE_X4
| Tfc::MULTISAMPLE_X8
| Tfc::MULTISAMPLE_X16
} else if max_samples >= 8 {
Tfc::MULTISAMPLE_X2 | Tfc::MULTISAMPLE_X4 | Tfc::MULTISAMPLE_X8
} else if max_samples >= 4 {
Tfc::MULTISAMPLE_X2 | Tfc::MULTISAMPLE_X4
Expand Down
8 changes: 5 additions & 3 deletions wgpu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,16 @@ bitflags!(
const MULTISAMPLE_X4 = 1 << 10;
/// Format can be multisampled by x8.
const MULTISAMPLE_X8 = 1 << 11;
/// Format can be multisampled by x16.
const MULTISAMPLE_X16 = 1 << 12;

/// Format can be used for render pass resolve targets.
const MULTISAMPLE_RESOLVE = 1 << 12;
const MULTISAMPLE_RESOLVE = 1 << 13;

/// Format can be copied from.
const COPY_SRC = 1 << 13;
const COPY_SRC = 1 << 14;
/// Format can be copied to.
const COPY_DST = 1 << 14;
const COPY_DST = 1 << 15;
}
);

Expand Down
3 changes: 3 additions & 0 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ impl super::PrivateCapabilities {
if device.supports_texture_sample_count(8) {
sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X8;
}
if device.supports_texture_sample_count(16) {
sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X16;
}

let rw_texture_tier = if version.at_least((10, 13), (11, 0)) {
device.read_write_texture_support()
Expand Down
4 changes: 4 additions & 0 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,10 @@ impl crate::Adapter<super::Api> for super::Adapter {
Tfc::MULTISAMPLE_X8,
sample_flags.contains(vk::SampleCountFlags::TYPE_8),
);
flags.set(
Tfc::MULTISAMPLE_X16,
sample_flags.contains(vk::SampleCountFlags::TYPE_16),
);

flags
}
Expand Down
11 changes: 7 additions & 4 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1716,17 +1716,19 @@ bitflags::bitflags! {
const MULTISAMPLE_X4 = 1 << 2 ;
/// Allows [`TextureDescriptor::sample_count`] to be `8`.
const MULTISAMPLE_X8 = 1 << 3 ;
/// Allows [`TextureDescriptor::sample_count`] to be `16`.
const MULTISAMPLE_X16 = 1 << 4;
/// Allows a texture of this format to back a view passed as `resolve_target`
/// to a render pass for an automatic driver-implemented resolve.
const MULTISAMPLE_RESOLVE = 1 << 4;
const MULTISAMPLE_RESOLVE = 1 << 5;
/// When used as a STORAGE texture, then a texture with this format can be bound with
/// [`StorageTextureAccess::ReadOnly`] or [`StorageTextureAccess::ReadWrite`].
const STORAGE_READ_WRITE = 1 << 5;
const STORAGE_READ_WRITE = 1 << 6;
/// When used as a STORAGE texture, then a texture with this format can be written to with atomics.
// TODO: No access flag exposed as of writing
const STORAGE_ATOMICS = 1 << 6;
const STORAGE_ATOMICS = 1 << 7;
/// If not present, the texture can't be blended into the render target.
const BLENDABLE = 1 << 7;
const BLENDABLE = 1 << 8;
}
}

Expand All @@ -1742,6 +1744,7 @@ impl TextureFormatFeatureFlags {
2 => self.contains(tfsc::MULTISAMPLE_X2),
4 => self.contains(tfsc::MULTISAMPLE_X4),
8 => self.contains(tfsc::MULTISAMPLE_X8),
16 => self.contains(tfsc::MULTISAMPLE_X16),
_ => false,
}
}
Expand Down
4 changes: 3 additions & 1 deletion wgpu/examples/msaa-line/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ impl framework::Example for Example {
let sample_flags = _adapter.get_texture_format_features(config.format).flags;

let max_sample_count = {
if sample_flags.contains(wgpu::TextureFormatFeatureFlags::MULTISAMPLE_X8) {
if sample_flags.contains(wgpu::TextureFormatFeatureFlags::MULTISAMPLE_X16) {
16
} else if sample_flags.contains(wgpu::TextureFormatFeatureFlags::MULTISAMPLE_X8) {
8
} else if sample_flags.contains(wgpu::TextureFormatFeatureFlags::MULTISAMPLE_X4) {
4
Expand Down