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

Split Blendability and Filterability into Two Different TextureFormatFeatureFlags #2943

Closed
geertbleyen opened this issue Aug 5, 2022 · 7 comments
Labels
area: api Issues related to API surface help required We need community help to make this happen. type: enhancement New feature or request

Comments

@geertbleyen
Copy link
Contributor

Description
After updating to wgpu 0.13.2, coming from 0.12.5, we are getting validation errors, saying that format Rg32Float is not blendable.
According to Apple docs, Rg32Float is blendable on all gpu families (see docs at: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf)
The validation error is thrown because rg32float must be filterable according to specs described at https://gpuweb.github.io/gpuweb/#fragment-state but isn't according to specs described at https://gpuweb.github.io/gpuweb/#plain-color-formats.

However, in version 0.12.5, this limitation wasn't in place, the pipeline could be created without this validation error.

error:

Caused by:
    In Device::create_render_pipeline
      note: label = `AO shadow map occlusion`
    color state [0] is invalid
    format Rg32Float is not blendable

', /Users/geertbleyen/repos/wgpu/wgpu/src/backend/direct.rs:2391:5
stack backtrace:
   0:        0x109f21910 - std::backtrace_rs::backtrace::trace_unsynchronized::h90c7a6c58d54ae6a
   1:        0x109e68214 - std::sys_common::backtrace::_print_fmt::h5ba483b9351760cb
   2:        0x109e67ffc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h261811dcc41ec1e1
   3:        0x109b842ec - core::fmt::write::hd8c6ce423a553a5d
   4:        0x109e93400 - std::io::Write::write_fmt::hca5c997ff94e99c3
   5:        0x109e67fb8 - std::sys_common::backtrace::_print::h5ef78d6a5bf27ef3
   6:        0x109e67eec - std::sys_common::backtrace::print::h808330083d8a446e
   7:        0x109e90c4c - std::panicking::default_hook::{{closure}}::h67995fd472cda925
   8:        0x109e908e8 - std::panicking::default_hook::h369f25642f37b044
   9:        0x109e91540 - std::panicking::rust_panic_with_hook::hb9285b5e6c2c933e
  10:        0x109e911ac - std::panicking::begin_panic_handler::{{closure}}::h280415e48d2df7fe
  11:        0x109e688f4 - std::sys_common::backtrace::__rust_end_short_backtrace::h20d9ff7db5b1d6ac
  12:        0x109e90df8 - _rust_begin_unwind
  13:        0x10a1d9d68 - core::panicking::panic_fmt::h618b16cbff66cabc
  14:        0x109fd9880 - wgpu::backend::direct::default_error_handler::h54950a97d2f0865e
  15:        0x109f34b90 - core::ops::function::Fn::call::h5cff03215e896474
  16:        0x109f7e2c4 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd1467e70c8309e19
  17:        0x109fd95bc - wgpu::backend::direct::ErrorSinkRaw::handle_error::h179fa51d1fcb9d79
  18:        0x10a0d0b6c - wgpu::backend::direct::Context::handle_error::h732f5195d96ec67f
  19:        0x109fd6170 - <wgpu::backend::direct::Context as wgpu::Context>::device_create_render_pipeline::h4711831212edb49a
  20:        0x109f6ccfc - wgpu::Device::create_render_pipeline::ha9221d51ae031f00
  21:        0x109c3b72c - gpu::pipeline::mesh_ao::ambient_occlusion::shadow_map_consumption::create_render_pipeline::he63e24d6c4afc1b0
  22:        0x109c3ba08 - gpu::pipeline::mesh_ao::ambient_occlusion::shadow_map_consumption::get_render_pipeline::h713cc37b82844c39
  23:        0x109c3bf0c - gpu::pipeline::mesh_ao::ambient_occlusion::shadow_map_consumption::use_shadow_map::h23c753a76fa1a5f6
  24:        0x109c27d7c - gpu::pipeline::mesh_ao::ambient_occlusion::add_samples::add_ambient_occlusion_samples::h74b2b53dea3f8727
  25:        0x109c06814 - gpu::pipeline::mesh_ao::MeshAO::calculate_ao_map::h261b6c1955389d10
  26:        0x109e20068 - plugin_gpu::calculatemeshao::calculate_mesh_ao::hfc1198ffdf7d6283

Expected vs observed behavior
Make the format's blendability adhere to device features, or be seperately treated from the format's filterability.

Platform
wgpu: 0.13.2, backend = Metal
iOS: 15.6 (both real device and simulator)
device: iPad Pro 2021 12.9"

@cwfitzgerald
Copy link
Member

You should be able to filter (and blend) this format if you enable the https://docs.rs/wgpu/latest/wgpu/struct.Features.html#associatedconstant.TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES feature on your device. This will expand the allowed usages to what your device allows, not just what webgpu does.

@cwfitzgerald cwfitzgerald closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2022
@kwillemsen
Copy link
Contributor

It seems enabling TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES does not fix the issue. So I think the problem is in the filterable and blendable properties being treated as one single propery. This corresponds to the WebGPU spec:

If colorState.blend is not undefined the colorState.format must
be filterable according to the §25.1.1 Plain color formats table

The validation in create_render_pipeline checks for a filterable texture format when blending is not None.
The metal backend correctly reports that RG32Float is blendable, but not filterable (page 10 of 13, Ordinary 64-bit pixel formats).

So even though a RG32Float surface can be rendered to with blending enabled, this is prevented because the format is not filterable.

@geertbleyen
Copy link
Contributor Author

@cwfitzgerald , can this issue be reopened, as the root cause doesn't seem to be a missing feature flag, but the wgpu spec tying blendability with filterability and the metal backend following this concept when setting device capabilities.

@cwfitzgerald
Copy link
Member

So this is a feature request to split up filter-ability and blend-ability in our texture format feature flags? Alright

@cwfitzgerald cwfitzgerald reopened this Aug 8, 2022
@cwfitzgerald cwfitzgerald added type: enhancement New feature or request help required We need community help to make this happen. area: api Issues related to API surface labels Aug 8, 2022
@cwfitzgerald cwfitzgerald changed the title [Metal] Rg32Float is not blendable in 0.13.2, but is in 0.12.5 Split Blendability and Filterability into Two Different TextureFormatFeatureFlags Aug 8, 2022
@geertbleyen
Copy link
Contributor Author

Yes, that's right.

@geertbleyen
Copy link
Contributor Author

@cwfitzgerald, a PR has been created for this.

@teoxoy
Copy link
Member

teoxoy commented Dec 5, 2022

Fixed by #3012

@teoxoy teoxoy closed this as completed Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface help required We need community help to make this happen. type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants