Skip to content

Commit f75a042

Browse files
adrian17Wumpf
andcommitted
[RUFFLE BACKPORT] Lower max_color_attachments limit for GL to 4 (gfx-rs#6994)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
1 parent f6a4834 commit f75a042

File tree

6 files changed

+9
-4
lines changed

6 files changed

+9
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Bottom level categories:
4747
* 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).
4848
* Implement `Clone` on `ShaderModule`. By @a1phyr in [#6937](https://github.com/gfx-rs/wgpu/pull/6937).
4949
- Fix `CopyExternalImageDestInfo` not exported on `wgpu`. By @wumpf in [#6962](https://github.com/gfx-rs/wgpu/pull/6962).
50+
- 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).
5051

5152
## v24.0.0 (2025-01-15)
5253

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ wgpu = { version = "24.0.1", path = "./wgpu", default-features = false, features
140140
"dx12",
141141
"metal",
142142
"static-dxc",
143+
"webgl",
143144
] }
144145
wgpu-core = { version = "24.0.0", path = "./wgpu-core" }
145146
wgpu-macros = { version = "24.0.1", path = "./wgpu-macros" }

wgpu-hal/src/gles/adapter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ impl super::Adapter {
824824
private_caps,
825825
workarounds,
826826
features,
827+
limits: limits.clone(),
827828
shading_language_version,
828829
next_shader_id: Default::default(),
829830
program_cache: Default::default(),

wgpu-hal/src/gles/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ struct AdapterShared {
271271
context: AdapterContext,
272272
private_caps: PrivateCapabilities,
273273
features: wgt::Features,
274+
limits: wgt::Limits,
274275
workarounds: Workarounds,
275276
shading_language_version: naga::back::glsl::Version,
276277
next_shader_id: AtomicU32,

wgpu-hal/src/gles/queue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1078,8 +1078,8 @@ impl super::Queue {
10781078
0,
10791079
)
10801080
};
1081-
for i in 0..crate::MAX_COLOR_ATTACHMENTS {
1082-
let target = glow::COLOR_ATTACHMENT0 + i as u32;
1081+
for i in 0..self.shared.limits.max_color_attachments {
1082+
let target = glow::COLOR_ATTACHMENT0 + i;
10831083
unsafe {
10841084
gl.framebuffer_texture_2d(
10851085
glow::DRAW_FRAMEBUFFER,

wgpu-types/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ impl Limits {
13241324
/// min_uniform_buffer_offset_alignment: 256,
13251325
/// min_storage_buffer_offset_alignment: 256,
13261326
/// max_inter_stage_shader_components: 60,
1327-
/// max_color_attachments: 8,
1327+
/// max_color_attachments: 4,
13281328
/// max_color_attachment_bytes_per_sample: 32,
13291329
/// max_compute_workgroup_storage_size: 16352, // *
13301330
/// max_compute_invocations_per_workgroup: 256,
@@ -1344,6 +1344,7 @@ impl Limits {
13441344
max_texture_dimension_3d: 256,
13451345
max_storage_buffers_per_shader_stage: 4,
13461346
max_uniform_buffer_binding_size: 16 << 10, // (16 KiB)
1347+
max_color_attachments: 4,
13471348
// see: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=7
13481349
max_compute_workgroup_storage_size: 16352,
13491350
..Self::defaults()
@@ -1381,7 +1382,7 @@ impl Limits {
13811382
/// min_uniform_buffer_offset_alignment: 256,
13821383
/// min_storage_buffer_offset_alignment: 256,
13831384
/// max_inter_stage_shader_components: 31,
1384-
/// max_color_attachments: 8,
1385+
/// max_color_attachments: 4,
13851386
/// max_color_attachment_bytes_per_sample: 32,
13861387
/// max_compute_workgroup_storage_size: 0, // +
13871388
/// max_compute_invocations_per_workgroup: 0, // +

0 commit comments

Comments
 (0)