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

Pad the cache update buffer to 256 bytes so that textures display in Chrome Canary #36

Closed
wants to merge 3 commits into from

Conversation

expenses
Copy link
Contributor

Now that gfx-rs/wgpu-rs#193 has landed, it'd be great to get wgpu_glyph to work in-browser! At the moment, the only browser that WebGPU works okay-ish on is Chrome Canary.

Chrome Canary has a stricter implementation of WebGPU than wgpu, and requires that all textures have a row pitch that is a multiple of 256 bytes. This PR checks the width of the data that the cache is updated with, and allocated a new vector with the correct padding if the width is not a multiple of 256.

@hecrj
Copy link
Owner

hecrj commented Apr 26, 2020

Hey, thanks!

Does this limitation only apply to Chrome Canary? In that case, it may be a good idea to enable the new code only when targetting Wasm.

@hecrj hecrj added the bug Something isn't working label Apr 26, 2020
@hecrj hecrj added this to the 0.8.1 milestone Apr 26, 2020
Comment on lines +7 to +11
if value % 256 == 0 {
value
} else {
(value / 256 + 1) * 256
}
Copy link

Choose a reason for hiding this comment

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

This simplifies to ((value + 255) / 256) * 256.

@rukai
Copy link
Contributor

rukai commented Jun 8, 2020

This restriction has now been implemented in wgpu, so it should be always enabled. (its part of the webgpu spec)

You might find this change to the capture example useful to refer to https://github.com/gfx-rs/wgpu-rs/pull/348/files

@hecrj hecrj modified the milestones: 0.8.1, 0.10.0 Aug 21, 2020
@rukai rukai mentioned this pull request Aug 21, 2020
@hecrj hecrj closed this in #44 Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants