Skip to content

Commit

Permalink
fix: allow non-filterable float on derived BGLs for texture binding u…
Browse files Browse the repository at this point in the history
…sage w/ no sampler
  • Loading branch information
ErichDonGubler committed Nov 12, 2024
1 parent ea75a8c commit 29dbd02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]
#### General

- Handle query set creation failure as an internal error that loses the `Device`, rather than panicking. By @ErichDonGubler in [#6505](https://github.com/gfx-rs/wgpu/pull/6505).
- Allow non-filterable float on texture bindings never used with samplers when using a derived bind group layout. By @ErichDonGubler in [#6531](https://github.com/gfx-rs/wgpu/pull/6531/).

#### Naga

Expand Down
18 changes: 13 additions & 5 deletions wgpu-core/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ impl Resource {
Ok(())
}

fn derive_binding_type(&self) -> Result<BindingType, BindingError> {
fn derive_binding_type(
&self,
is_reffed_by_sampler_in_entrypoint: bool,
) -> Result<BindingType, BindingError> {
Ok(match self.ty {
ResourceType::Buffer { size } => BindingType::Buffer {
ty: match self.class {
Expand Down Expand Up @@ -531,9 +534,9 @@ impl Resource {
match class {
naga::ImageClass::Sampled { multi, kind } => BindingType::Texture {
sample_type: match kind {
naga::ScalarKind::Float => {
wgt::TextureSampleType::Float { filterable: true }
}
naga::ScalarKind::Float => wgt::TextureSampleType::Float {
filterable: is_reffed_by_sampler_in_entrypoint,
},
naga::ScalarKind::Sint => wgt::TextureSampleType::Sint,
naga::ScalarKind::Uint => wgt::TextureSampleType::Uint,
naga::ScalarKind::AbstractInt
Expand Down Expand Up @@ -1009,7 +1012,12 @@ impl Interface {
break 'err Err(BindingError::Missing);
};

let ty = match res.derive_binding_type() {
let ty = match res.derive_binding_type(
entry_point
.sampling_pairs
.iter()
.any(|&(im, _samp)| im == handle),
) {
Ok(ty) => ty,
Err(error) => break 'err Err(error),
};
Expand Down

0 comments on commit 29dbd02

Please sign in to comment.