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

Lower max_color_attachments limit for GL to 4 #6994

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

adrian17
Copy link

Connections
#6986

Description
Wgpu 23 broke support for older devices that only supported GLES and max_color_attachments == 4 (which is the minimum mandated by 3.1 spec). The limit technically used to be 8 for much longer, but according to @cwfitzgerald it wasn't enforced before. This change aims to revert this regression.
Only downlevel limits are changed, not default limits.

Note that I can't prove that this is the only thing that needs changing to make wgpu work on such old devices again, because I'm only relying on user reports and can't check it myself.

Testing
Ran cargo test --doc only.

Only tested manually with a hack, since I don't have access to such a device:

        let max_color_attachments = unsafe {
            gl.get_parameter_i32(glow::MAX_COLOR_ATTACHMENTS)
                .min(gl.get_parameter_i32(glow::MAX_DRAW_BUFFERS))
                .min(crate::MAX_COLOR_ATTACHMENTS as i32) as u32
        };
+       let max_color_attachments = 4;

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@adrian17 adrian17 requested a review from a team as a code owner January 26, 2025 15:34
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference: https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glGet.xhtml also says the minimum value is 4 for GLES 3.0, so this change makes sense in any case! 👍

@Wumpf
Copy link
Member

Wumpf commented Jan 26, 2025

@adrian17 Please add a line to the changelog under bugfixes

@colin-i
Copy link

colin-i commented Jan 26, 2025

I tested this on a device that had this problem (Raspberry Pi 4). The error is gone and the program (ruffle) is starting with no more errors.

@adrian17 adrian17 force-pushed the lower-max-color-attachments-for-gles branch from 597c900 to efb65e7 Compare January 26, 2025 22:32
@adrian17
Copy link
Author

Added changelog.

Should I assume that the wasm CI failures are expected? Looking at logs, they didn't seem related to my changes.

@cwfitzgerald cwfitzgerald enabled auto-merge (squash) January 26, 2025 22:34
@cwfitzgerald
Copy link
Member

So Wasm is failing, but apparently the logging config we're using casues there to be 41MB of logs...

I'll take a look at this on monday

CHANGELOG.md Outdated Show resolved Hide resolved
@Wumpf Wumpf disabled auto-merge January 27, 2025 09:18
@Wumpf Wumpf enabled auto-merge (squash) January 27, 2025 22:39
@torokati44

This comment was marked as resolved.

@ErichDonGubler

This comment was marked as resolved.

@adrian17
Copy link
Author

adrian17 commented Jan 28, 2025

It's still failing somehow on wasm :c

Here's the first relevant part of the CI logs, I think?

    info output:
        Testing using adapter: AdapterInfo {
            name: \"ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)\",
            vendor: 0,
            device: 0,
            device_type: Cpu,
            driver: \"\",
            driver_info: \"WebGL 2.0 (OpenGL ES 3.0 Chromium)\",
            backend: Gl,
        }
        TEST: srgb-blend-linear
    
    error output:
        Validation Error: *no message*
        panicked at /home/runner/work/wgpu/wgpu/tests/src/run.rs:120:9:
        examples/features/src/framework.rs:507:9: test \"srgb-blend-linear\" did not behave as expected

@cwfitzgerald
Copy link
Member

Yeah this means gl.GetError is returning something - you unfortunately need to run the tests in the browser to get the full error. I can do this if it's a bother.

@adrian17
Copy link
Author

I just ran the suite locally and they passed :(

test srgb_blend::test_linear_webgl ... ok
test srgb_blend::test_srgb_webgl ... ok

I also tried with again pretending that gl.getParameter(MAX_COLOR_ATTACHMENTS) returns 4, and they still work.

I don't understand how this test can be failing now; if the entire CI environment had max_color_attachments==4, then the test would have been failing before too, for a different reason, right?

My best guess is that this has something to do with this hardcoded constant, which I didn't know whether I should have updated or not:

https://github.com/gfx-rs/wgpu/blob/trunk/wgpu-hal/src/lib.rs#L298

@cwfitzgerald cwfitzgerald self-assigned this Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wgpu 23 (GLES) no longer works on devices with max_color_attachments == 4.
6 participants