From 0f5d575ef3cf5e16c8372d0bf5db59be1bb11078 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik <4729533+adrian17@users.noreply.github.com> Date: Thu, 13 Feb 2025 01:37:34 +0100 Subject: [PATCH] Lower max_color_attachments limit for GL to 4 (#6994) Co-authored-by: Andreas Reich --- CHANGELOG.md | 1 + Cargo.toml | 1 + wgpu-hal/src/gles/adapter.rs | 1 + wgpu-hal/src/gles/mod.rs | 1 + wgpu-hal/src/gles/queue.rs | 4 ++-- wgpu-types/src/lib.rs | 5 +++-- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 647bfc87a..b3c5ebdda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,7 @@ By @brodycj in [#6924](https://github.com/gfx-rs/wgpu/pull/6924). - Add Flush to GL Queue::submit. By @cwfitzgerald in [#6941](https://github.com/gfx-rs/wgpu/pull/6941). - Fix `wgpu` not building with `--no-default-features` on when targeting `wasm32-unknown-unknown`. By @wumpf in [#6946](https://github.com/gfx-rs/wgpu/pull/6946). - Fix `CopyExternalImageDestInfo` not exported on `wgpu`. By @wumpf in [#6962](https://github.com/gfx-rs/wgpu/pull/6962). +- Reduce downlevel `max_color_attachments` limit from 8 to 4 for better GLES compatibility. By @adrian17 in [#6994](https://github.com/gfx-rs/wgpu/pull/6994). - Fix drop order in `Surface`. By @ed-2100 in [#6997](https://github.com/gfx-rs/wgpu/pull/6997) - Fix a possible deadlock within `Queue::write_texture`. By @metamuffin in [#7004](https://github.com/gfx-rs/wgpu/pull/7004) - Fix building a BLAS with a transform buffer by adding a flag to indicate usage of the transform buffer. By @Vecvec in diff --git a/Cargo.toml b/Cargo.toml index aba7b5195..2b0a1d350 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,7 @@ wgpu = { version = "24.0.0", path = "./wgpu", default-features = false, features "dx12", "metal", "static-dxc", + "webgl", ] } wgpu-core = { version = "24.0.0", path = "./wgpu-core" } wgpu-hal = { version = "24.0.0", path = "./wgpu-hal" } diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 85bae5945..c56611da0 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -825,6 +825,7 @@ impl super::Adapter { private_caps, workarounds, features, + limits: limits.clone(), options: backend_options, shading_language_version, next_shader_id: Default::default(), diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 478f2c433..c462d7b2e 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -274,6 +274,7 @@ struct AdapterShared { context: AdapterContext, private_caps: PrivateCapabilities, features: wgt::Features, + limits: wgt::Limits, workarounds: Workarounds, options: wgt::GlBackendOptions, shading_language_version: naga::back::glsl::Version, diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 1be46ceed..50126a76c 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -1078,8 +1078,8 @@ impl super::Queue { 0, ) }; - for i in 0..crate::MAX_COLOR_ATTACHMENTS { - let target = glow::COLOR_ATTACHMENT0 + i as u32; + for i in 0..self.shared.limits.max_color_attachments { + let target = glow::COLOR_ATTACHMENT0 + i; unsafe { gl.framebuffer_texture_2d( glow::DRAW_FRAMEBUFFER, diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 2d3914bc1..e71c89c5c 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -506,7 +506,7 @@ impl Limits { /// min_uniform_buffer_offset_alignment: 256, /// min_storage_buffer_offset_alignment: 256, /// max_inter_stage_shader_components: 60, - /// max_color_attachments: 8, + /// max_color_attachments: 4, /// max_color_attachment_bytes_per_sample: 32, /// max_compute_workgroup_storage_size: 16352, // * /// max_compute_invocations_per_workgroup: 256, @@ -526,6 +526,7 @@ impl Limits { max_texture_dimension_3d: 256, max_storage_buffers_per_shader_stage: 4, max_uniform_buffer_binding_size: 16 << 10, // (16 KiB) + max_color_attachments: 4, // see: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=7 max_compute_workgroup_storage_size: 16352, ..Self::defaults() @@ -563,7 +564,7 @@ impl Limits { /// min_uniform_buffer_offset_alignment: 256, /// min_storage_buffer_offset_alignment: 256, /// max_inter_stage_shader_components: 31, - /// max_color_attachments: 8, + /// max_color_attachments: 4, /// max_color_attachment_bytes_per_sample: 32, /// max_compute_workgroup_storage_size: 0, // + /// max_compute_invocations_per_workgroup: 0, // +