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

Additional cfg for wasm target for gradients #1524

Merged
merged 1 commit into from
Nov 15, 2022

Conversation

bungoboingo
Copy link
Contributor

Storage buffers aren't supported by wgpu WASM + webgl which gradients currently use. For now I've just added a #cfg around relevant bits of code so WASM targets that don't use gradients will compile as expected.

Not quite sure if there is a preferred way to separate out this code, but I figured writing a separate implementation for WASM which uses a static uniform array like the GL target would be a relatively simple process so it didn't make sense to reorganize the code to reduce the number of target-specific compilation exclusions.

…age buffers, since storage buffers are not supported on wgpu WASM target at the moment.
@tarkah
Copy link
Member

tarkah commented Nov 14, 2022

Since our canvas API is already limited due to the opengl implementation, should we just use fixed # stops / uniform data on wgpu? I think a single implementation that is compatible with all targets is preferable to a bunch of code split. I really don't think it's an issue since hitting the max 16 color stops is such a far out edge case.

We can document the limitation on the canvas API and ensure the builder outputs None if more than limit was added.

@hecrj hecrj added bug Something isn't working rendering labels Nov 15, 2022
@hecrj hecrj added this to the 0.6.0 milestone Nov 15, 2022
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks!

@hecrj hecrj merged commit 5b0dfcd into iced-rs:master Nov 15, 2022
@bungoboingo
Copy link
Contributor Author

Yeah, I could reimplement this for wgpu with a fix number of color stops for a WASM target. As far as I can tell, WebGL cannot (or will not?) support SSBOs, so this will always be a limitation with a WASM target w/ wgpu's WebGL feature. I think instead of returning Err from the builder I would just ignore any stops after the limit with proper documentation.

@bungoboingo bungoboingo deleted the fix/gradients_wasm branch November 16, 2022 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants