From efb65e7cbc6947f41b0ab4dfc5efb7f5b5affe2e Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Sat, 25 Jan 2025 13:24:47 +0100 Subject: [PATCH 1/3] Lower max_color_attachments limit for GL to 4 --- CHANGELOG.md | 1 + wgpu-types/src/lib.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acc67a82f5..f9a9a185ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ By @brodycj in [#6925](https://github.com/gfx-rs/wgpu/pull/6925). - 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 OpenGL competibility. By @adrian17 in [#6994](https://github.com/gfx-rs/wgpu/pull/6994). #### Vulkan diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 4645b4ac19..a08b0ee859 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1324,7 +1324,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, @@ -1344,6 +1344,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() @@ -1381,7 +1382,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, // + From 1b428fb6187c3c98c7bff546867fb5b58193642f Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Mon, 27 Jan 2025 10:17:25 +0100 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9a9a185ce..114b90e108 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,7 +78,7 @@ By @brodycj in [#6925](https://github.com/gfx-rs/wgpu/pull/6925). - 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 OpenGL competibility. By @adrian17 in [#6994](https://github.com/gfx-rs/wgpu/pull/6994). +- 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). #### Vulkan From 0f1de6297453d5d37c16bfcfcc3b3a141bf92824 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Wed, 12 Feb 2025 19:27:36 -0500 Subject: [PATCH 3/3] Try to Fix Issues --- Cargo.toml | 1 + wgpu-hal/src/gles/adapter.rs | 1 + wgpu-hal/src/gles/mod.rs | 1 + wgpu-hal/src/gles/queue.rs | 4 ++-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 01c5f4a77c..5d324b468d 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 85bae59457..c56611da0e 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 478f2c433c..c462d7b2ec 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 1be46ceed2..50126a76c1 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,