Skip to content

Commit 6543207

Browse files
committed
comment & naming fixes
1 parent 1fba25d commit 6543207

File tree

1 file changed

+7
-5
lines changed
  • crates/re_renderer/src/wgpu_resources

1 file changed

+7
-5
lines changed

crates/re_renderer/src/wgpu_resources/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Texture2DBufferInfo {
162162

163163
/// Removes the padding from a buffer containing gpu texture data.
164164
///
165-
/// The buffer have the expected size for a padded buffer to hold the texture data.
165+
/// The passed in buffer is to be expected to be exactly of size [Texture2DBufferInfo::buffer_size_padded].
166166
///
167167
/// Note that if you're passing in gpu data, there no alignment guarantees on the returned slice,
168168
/// do NOT convert it using [`bytemuck`]. Use [`Texture2DBufferInfo::remove_padding_and_convert`] instead.
@@ -189,7 +189,7 @@ impl Texture2DBufferInfo {
189189

190190
/// Removes the padding from a buffer containing gpu texture data and remove convert to a given type.
191191
///
192-
/// The buffer have the expected size for a padded buffer to hold the texture data.
192+
/// The passed in buffer is to be expected to be exactly of size [Texture2DBufferInfo::buffer_size_padded].
193193
///
194194
/// The unpadded row size is expected to be a multiple of the size of the target type.
195195
/// (Which means that, while uncommon, it technically doesn't need to be as big as a block in the pixel - this can be useful for e.g. packing wide bitfields)
@@ -207,13 +207,15 @@ impl Texture2DBufferInfo {
207207
T::zeroed();
208208
(self.num_rows() * self.bytes_per_row_unpadded / std::mem::size_of::<T>() as u32)
209209
as usize
210-
]; // Consider using unsafe set_len() instead of vec![] to avoid zeroing the memory.
211-
let unpaadded_buffer_u8 = bytemuck::cast_slice_mut(&mut unpadded_buffer);
210+
]; // TODO(andreas): Consider using unsafe set_len() instead of vec![] to avoid zeroing the memory.
211+
212+
// The copy has to happen on a u8 slice, because any other type would assume some alignment that we can't guarantee because of the above.
213+
let unpadded_buffer_u8_view = bytemuck::cast_slice_mut(&mut unpadded_buffer);
212214

213215
for row in 0..self.num_rows() {
214216
let offset_padded = (self.bytes_per_row_padded * row) as usize;
215217
let offset_unpadded = (self.bytes_per_row_unpadded * row) as usize;
216-
unpaadded_buffer_u8
218+
unpadded_buffer_u8_view
217219
[offset_unpadded..(offset_unpadded + self.bytes_per_row_unpadded as usize)]
218220
.copy_from_slice(
219221
&buffer[offset_padded..(offset_padded + self.bytes_per_row_unpadded as usize)],

0 commit comments

Comments
 (0)