gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 551 forks source link

fill_buffer start has to be 16-byte aligned on DX11 #3718

Closed kvark closed 3 years ago

kvark commented 3 years ago

See https://github.com/gfx-rs/wgpu/issues/1303#issuecomment-813756734 We may need to expose a limit for this. cc @cwfitzgerald

kvark commented 3 years ago

@cwfitzgerald It occurred to me that DX11 backend can hide this limitation internally. It can basically create a 16-byte buffer with this data and issue a buffer-buffer copy for the unaligned part.

cwfitzgerald commented 3 years ago

I'd be quite worried about the performance of this. Maybe expose a "performance only" limit so that wgpu can always properly align it, and if the value is unaligned we can fall back to this workaround.

kvark commented 3 years ago

I mean, there is clearly a naive path here. We can do better by making a pool of, say 256 byte buffers that are re-used, in which case the major cost - allocating a new buffer - goes away. The point is that it's possible to implement, and similar workarounds are already employed in other places (unfortunately, I suppose?).

Maybe when we finally change the direction to #2249, we can remove the workarounds.