You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's currently not possible to check if a type T: ShaderType is runtime sized or not. This makes it difficult, in generic code, to tell if one can assume that the T::min_size can be used to accurately estimate how large a preallocated buffer needs to be to fit N elements of T. This mandates the use of dynamic allocation
The motivation here is to support use cases that directly use wgpu::Queue::write_buffer_with to avoid extra copies, but it requires a preallocated non-expandable buffer. To preallocate, a maximum capacity for the buffer must be known, and this requires summing the size of all elements (padding for alignment), or computing the capacity assuming the size is fixed. This is doable in non-generic contexts where we know a type is not runtime sized, but not possible in generic contexts without T::is_runtime_sized or something similar.
The text was updated successfully, but these errors were encountered:
Although I imagine it would be tricky to use in a generic context since it's only implemented for runtime-sized arrays.
ShaderType::max_size(nr_of_el) sounds like something that would be nice to have but I don't know how it should behave for things that are not runtime-sized arrays. Does it just ignore the arg?
It's currently not possible to check if a type
T: ShaderType
is runtime sized or not. This makes it difficult, in generic code, to tell if one can assume that theT::min_size
can be used to accurately estimate how large a preallocated buffer needs to be to fit N elements of T. This mandates the use of dynamic allocationThe motivation here is to support use cases that directly use
wgpu::Queue::write_buffer_with
to avoid extra copies, but it requires a preallocated non-expandable buffer. To preallocate, a maximum capacity for the buffer must be known, and this requires summing the size of all elements (padding for alignment), or computing the capacity assuming the size is fixed. This is doable in non-generic contexts where we know a type is not runtime sized, but not possible in generic contexts withoutT::is_runtime_sized
or something similar.The text was updated successfully, but these errors were encountered: