Allow non-filtering integer texture sampling (#3362)

* Allow non-filtering integer texture sampling

* Add changelog entry
This commit is contained in:
JMS55 2023-01-09 05:08:14 -05:00 committed by GitHub
parent a06ef71fd7
commit ad4dac87fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 23 deletions

View File

@ -173,6 +173,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non
- Check for invalid bitflag bits in wgpu-core and allow them to be captured/replayed by @nical in (#3229)[https://github.com/gfx-rs/wgpu/pull/3229] - Check for invalid bitflag bits in wgpu-core and allow them to be captured/replayed by @nical in (#3229)[https://github.com/gfx-rs/wgpu/pull/3229]
- Evaluate `gfx_select!`'s `#[cfg]` conditions at the right time. By @jimblandy in [#3253](https://github.com/gfx-rs/wgpu/pull/3253) - Evaluate `gfx_select!`'s `#[cfg]` conditions at the right time. By @jimblandy in [#3253](https://github.com/gfx-rs/wgpu/pull/3253)
- Improve error messages when binding bind group with dynamic offsets. By @cwfitzgerald in [#3294](https://github.com/gfx-rs/wgpu/pull/3294) - Improve error messages when binding bind group with dynamic offsets. By @cwfitzgerald in [#3294](https://github.com/gfx-rs/wgpu/pull/3294)
- Allow non-filtering sampling of integer textures. By @JMS55 in [#3362](https://github.com/gfx-rs/wgpu/pull/3362).
#### Metal #### Metal
- Fix texture view creation with full-resource views when using an explicit `mip_level_count` or `array_layer_count`. By @cwfitzgerald in [#3323](https://github.com/gfx-rs/wgpu/pull/3323) - Fix texture view creation with full-resource views when using an explicit `mip_level_count` or `array_layer_count`. By @cwfitzgerald in [#3323](https://github.com/gfx-rs/wgpu/pull/3323)

View File

@ -212,10 +212,10 @@ pub enum BindingError {
#[derive(Clone, Debug, Error)] #[derive(Clone, Debug, Error)]
pub enum FilteringError { pub enum FilteringError {
#[error("integer textures can't be sampled")] #[error("integer textures can't be sampled with a filtering sampler")]
Integer, Integer,
#[error("non-filterable float texture")] #[error("non-filterable float textures can't be sampled with a filtering sampler")]
NonFilterable, Float,
} }
#[derive(Clone, Debug, Error)] #[derive(Clone, Debug, Error)]
@ -1049,27 +1049,22 @@ impl Interface {
assert!(texture_layout.visibility.contains(stage_bit)); assert!(texture_layout.visibility.contains(stage_bit));
assert!(sampler_layout.visibility.contains(stage_bit)); assert!(sampler_layout.visibility.contains(stage_bit));
let error = match texture_layout.ty { let sampler_filtering = matches!(
wgt::BindingType::Texture { sampler_layout.ty,
sample_type: wgt::TextureSampleType::Float { filterable }, wgt::BindingType::Sampler(wgt::SamplerBindingType::Filtering)
.. );
} => match sampler_layout.ty { let texture_sample_type = match texture_layout.ty {
wgt::BindingType::Sampler(wgt::SamplerBindingType::Filtering) BindingType::Texture { sample_type, .. } => sample_type,
if !filterable => _ => unreachable!(),
{ };
Some(FilteringError::NonFilterable)
} let error = match (sampler_filtering, texture_sample_type) {
_ => None, (true, wgt::TextureSampleType::Float { filterable: false }) => {
}, Some(FilteringError::Float)
wgt::BindingType::Texture {
sample_type: wgt::TextureSampleType::Sint,
..
} }
| wgt::BindingType::Texture { (true, wgt::TextureSampleType::Sint) => Some(FilteringError::Integer),
sample_type: wgt::TextureSampleType::Uint, (true, wgt::TextureSampleType::Uint) => Some(FilteringError::Integer),
.. _ => None,
} => Some(FilteringError::Integer),
_ => None, // unreachable, really
}; };
if let Some(error) = error { if let Some(error) = error {