hecrj / wgpu_glyph

A fast text renderer for wgpu (https://github.com/gfx-rs/wgpu)
https://docs.rs/wgpu_glyph
MIT License
443 stars 77 forks source link

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

Closed expenses closed 3 years ago

expenses commented 4 years ago

Now that https://github.com/gfx-rs/wgpu-rs/pull/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 commented 4 years ago

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.

rukai commented 4 years ago

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