1647: Check for blendable flag in filtering r=cwfitzgerald a=kvark

**Connections**
Discussion on the matrix.

**Description**
The validation is written in a way that considers "filterable" to be responsible for both linear sampling and rendering.
But we didn't take blending into account when determining this filtering flag.

**Testing**
Untested


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot]
2021-07-13 20:10:45 +00:00
committed by GitHub

View File

@@ -212,36 +212,34 @@ impl<A: HalApi> Adapter<A> {
&self,
format: wgt::TextureFormat,
) -> wgt::TextureFormatFeatures {
let caps = unsafe { self.raw.adapter.texture_format_capabilities(format) };
use hal::TextureFormatCapabilities as Tfc;
let caps = unsafe { self.raw.adapter.texture_format_capabilities(format) };
let mut allowed_usages = format.describe().guaranteed_format_features.allowed_usages;
allowed_usages.set(
wgt::TextureUsages::SAMPLED,
caps.contains(hal::TextureFormatCapabilities::SAMPLED),
);
allowed_usages.set(
wgt::TextureUsages::STORAGE,
caps.contains(hal::TextureFormatCapabilities::STORAGE),
);
allowed_usages.set(wgt::TextureUsages::SAMPLED, caps.contains(Tfc::SAMPLED));
allowed_usages.set(wgt::TextureUsages::STORAGE, caps.contains(Tfc::STORAGE));
allowed_usages.set(
wgt::TextureUsages::RENDER_ATTACHMENT,
caps.intersects(
hal::TextureFormatCapabilities::COLOR_ATTACHMENT
| hal::TextureFormatCapabilities::DEPTH_STENCIL_ATTACHMENT,
),
caps.intersects(Tfc::COLOR_ATTACHMENT | Tfc::DEPTH_STENCIL_ATTACHMENT),
);
let mut flags = wgt::TextureFormatFeatureFlags::empty();
flags.set(
wgt::TextureFormatFeatureFlags::STORAGE_ATOMICS,
caps.contains(hal::TextureFormatCapabilities::STORAGE_ATOMIC),
caps.contains(Tfc::STORAGE_ATOMIC),
);
flags.set(
wgt::TextureFormatFeatureFlags::STORAGE_READ_WRITE,
caps.contains(hal::TextureFormatCapabilities::STORAGE_READ_WRITE),
caps.contains(Tfc::STORAGE_READ_WRITE),
);
let filterable = caps.contains(hal::TextureFormatCapabilities::SAMPLED_LINEAR);
// We are currently taking the filtering and blending together,
// but we may reconsider this in the future if there are formats
// in the wild for which these two capabilities do not match.
let filterable = caps.contains(Tfc::SAMPLED_LINEAR)
&& (!caps.contains(Tfc::COLOR_ATTACHMENT)
|| caps.contains(Tfc::COLOR_ATTACHMENT_BLEND));
wgt::TextureFormatFeatures {
allowed_usages,