mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 23:41:01 +01:00
refactor(metal): Allow zeros in vertex_buffer_size_map
(cherry picked from commit d2ad891087)
This commit is contained in:
1 parent
9b585b2291
commit
ee84090cc4
2 files changed
+11
-14
No files matched your search
@@ -434,12 +434,13 @@ impl super::CommandState {
|
||||
.unwrap_or_default()
|
||||
}));
|
||||
|
||||
// Extend with the sizes of the mapped vertex buffers, in the order
|
||||
// they were added to the map.
|
||||
// Extend with the sizes of the mapped vertex buffers, in the order they were added
|
||||
// to the map. Note that zeros in the sizes buffer can be for either an unused
|
||||
// binding index (no entry in map) or a zero-size binding (map entry that is zero).
|
||||
result_sizes.extend(stage_info.vertex_buffer_mappings.iter().map(|vbm| {
|
||||
self.vertex_buffer_size_map
|
||||
.get(&vbm.id)
|
||||
.map(|size| u32::try_from(size.get()).unwrap_or(u32::MAX))
|
||||
.map(|&size| u32::try_from(size).unwrap_or(u32::MAX))
|
||||
.unwrap_or_default()
|
||||
}));
|
||||
|
||||
@@ -1391,16 +1392,9 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
)
|
||||
};
|
||||
|
||||
// The size map uses `NonZeroU64` mostly because it did so in the past when
|
||||
// `hal::BufferBinding` tried to disallow zero-length bindings. Zero-length bindings
|
||||
// are valid for vertex buffers, so there isn't really a significance of a
|
||||
// zero-length buffer being removed from the map (vs. the map storing `u64`).
|
||||
if let Some(size) = NonZeroU64::new(binding.size) {
|
||||
self.state.vertex_buffer_size_map.insert(buffer_index, size);
|
||||
} else {
|
||||
// `make_sizes_buffer_update` uses zero for buffers that are not in the map.
|
||||
self.state.vertex_buffer_size_map.remove(&buffer_index);
|
||||
}
|
||||
self.state
|
||||
.vertex_buffer_size_map
|
||||
.insert(buffer_index, binding.size);
|
||||
|
||||
if let Some((index, sizes)) = self
|
||||
.state
|
||||
|
||||
@@ -1103,7 +1103,10 @@ struct CommandState {
|
||||
/// [`ResourceBinding`]: naga::ResourceBinding
|
||||
storage_buffer_length_map: FastHashMap<naga::ResourceBinding, wgt::BufferSize>,
|
||||
|
||||
vertex_buffer_size_map: FastHashMap<u32, wgt::BufferSize>,
|
||||
/// Sizes of currently bound vertex buffers.
|
||||
///
|
||||
/// Unlike storage buffer bindings, these may have size zero.
|
||||
vertex_buffer_size_map: FastHashMap<u32, wgt::BufferAddress>,
|
||||
|
||||
immediates: Vec<u32>,
|
||||
|
||||
|
||||
Reference in new issue
Block a user