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

Does wgpu::Device need to be borrowed mutably ? #12

Closed carado closed 4 years ago

carado commented 4 years ago

From my own attempts at working with wgpu, it seems like the wgpu::Device only needs to get mutably borrowed for submitting CommandBuffers into the queue.

Indeed, I can run the following line in wgpu_glyph:

sed -i 's/&mut wgpu::Device/\&wgpu::Device/g' $(find src -iname '*.rs')

and the whole crate can still be built without any issue, and its example binary still runs perfectly fine.

hecrj commented 4 years ago

You are right, we do not need it.

However, given that wgpu is still shaping up, asking for a mutable reference is a safe default. If we end up not needing it once the API stabilizes, then we will be able to drop it without affecting our users much.

carado commented 4 years ago

That's fair, thanks for your response.