Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,6 @@ impl Default for MeshCullingDataBuffer {
fn default() -> Self {
Self(AtomicSparseBufferVec::new(
BufferUsages::STORAGE,
8,
Arc::from("mesh culling data buffer"),
))
}
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_render/src/batching/gpu_preprocessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ where
InstanceInputUniformBuffer {
buffer: AtomicSparseBufferVec::new(
BufferUsages::STORAGE,
8,
Arc::from("instance input uniform buffer"),
),
free_uniform_indices: vec![],
Expand Down
20 changes: 6 additions & 14 deletions crates/bevy_render/src/render_resource/sparse_buffer_update.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
struct SparseBufferUpdateMetadata {
// The size of a single element in words.
element_size: u32,
// The total number of pages to be updated.
updated_page_count: u32,
// The base-2 logarithm of the page size.
page_size_log2: u32,
// The total number of elements to be updated.
updated_element_count: u32,
};

// The buffer we're copying to.
Expand All @@ -34,8 +32,7 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
// Calculate which word we are. Remember that this shader executes with one
// thread per word.
let invocation_index = global_id.x;
let total_word_count = (metadata.updated_page_count << metadata.page_size_log2) *
metadata.element_size;
let total_word_count = metadata.updated_element_count * metadata.element_size;
if (invocation_index >= total_word_count) {
return;
}
Expand All @@ -44,16 +41,11 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
let element_index = invocation_index / metadata.element_size;
// Calculate which word *within* that element we're looking at.
let word_index = invocation_index % metadata.element_size;
// Calculate which page we're copying.
let update_index = element_index >> metadata.page_size_log2;
// Determine which element we're copying within that page.
let element_index_in_page = element_index & ((1u << metadata.page_size_log2) - 1u);

// Look up our destination page.
let page_index = indices[update_index];
// Look up our destination element.
let dest_element_index = indices[element_index];
// Calculate where we should write our word.
let dest_index = ((page_index << metadata.page_size_log2) + element_index_in_page) *
metadata.element_size + word_index;
let dest_index = dest_element_index * metadata.element_size + word_index;
if (dest_index >= arrayLength(&dest_buffer)) {
return;
}
Expand Down
Loading
Loading