Skip to content

Conversation

uael
Copy link
Contributor

@uael uael commented Jul 23, 2025

Description
CompositeAlphaMode::PreMultiplied was missing in WebGPU and GLES supported alpha_modes

Testing
Manually for both Android (GLES) and the Web (WebGL and WebGPU)

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@uael uael requested a review from a team as a code owner July 23, 2025 07:46
@cwfitzgerald
Copy link
Member

@grovesNL I'm going away on vacation, could you take a look at this if you have some time?

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

WebGPU is fine, concern about GL

Comment on lines +1235 to +1238
composite_alpha_modes: vec![
wgt::CompositeAlphaMode::Opaque,
wgt::CompositeAlphaMode::PreMultiplied,
], //TODO
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is right - without telling this to the runtime at all we can't know if these modes are actually supported. I'm not sure how this works with the various platforms, but I don't think we can just change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It look like premultipliedAlpha is set to true by default https://registry.khronos.org/webgl/specs/latest/1.0/#5.2 and we do not seem to change it

Copy link
Collaborator

@grovesNL grovesNL Sep 7, 2025

Choose a reason for hiding this comment

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

It looks like supporting multiple modes could be tricky if we want it to be handled at the WebGL context level, because we'd need to create the context (wgpu's Surface) with opaque vs. premultiplied. There seems like a couple options:

  • If we exposed a way to specify whether alpha and premultiplied should be used when creating the initial surface/context, then we could change composite_alpha_modes to return Opaque/PreMultiplied depending on whatever the surface is currently using.
  • If we always use premultiplied on the context, I guess we could at least handle both opaque and premultiplied for srgb presentation by handling it in srgb_present.frag. This wouldn't work for non-srgb though where we blit the framebuffer (unless we went through a shader there for the opaque case).

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.

3 participants