Use transient memory pool for compactable acceleration structures (#10233)

This commit is contained in:
Stuart Parmenter authored and GitHub committed 2026-10-03 00:17:04 +00:00
1 parent 573944a971
commit db0782e398
4 files changed
+12 -1

No files matched your search

+1
View File
@@ -182,6 +182,7 @@ By @sagudev in [#10109](https://github.com/gfx-rs/wgpu/pull/10109).
#### Vulkan
- Sub-allocate `wgpu_hal::MemoryFlags::TRANSIENT` buffers and acceleration structure build scratch from a separate Vulkan memory pool, so short-lived allocations no longer pin memory blocks shared with long-lived resources. By @stuartparmenter in [#10232](https://github.com/gfx-rs/wgpu/pull/10232).
- Allocate acceleration structures created with `AccelerationStructureFlags::ALLOW_COMPACTION` from the transient Vulkan memory pool, since they are usually replaced by their compacted copies. By @stuartparmenter in [#10233](https://github.com/gfx-rs/wgpu/pull/10233).
### Bug Fixes
+2
View File
@@ -3048,6 +3048,8 @@ pub struct AccelerationStructureDescriptor<'a> {
pub label: Label<'a>,
pub size: wgt::BufferAddress,
pub format: AccelerationStructureFormat,
/// Backends may allocate the structure as a short-lived resource, since it is
/// usually replaced by its compacted copy.
pub allow_compaction: bool,
}
+6 -1
View File
@@ -2908,10 +2908,15 @@ impl crate::Device for super::Device {
.label
.unwrap_or("Unlabeled acceleration structure buffer");
let pool = if desc.allow_compaction {
super::MemoryPool::Transient
} else {
super::MemoryPool::General
};
let allocation = self
.mem_allocator
.allocate(
super::MemoryPool::General,
pool,
&gpu_allocator::vulkan::AllocationCreateDesc {
name,
requirements,
+3
View File
@@ -133,6 +133,9 @@ bitflags::bitflags!(
const ALLOW_UPDATE = 1 << 0;
/// Allow the acceleration structure to be compacted in a copy operation
/// (`Blas::prepare_for_compaction`, `CommandEncoder::compact_blas`).
///
/// Some backends allocate structures with this flag from memory meant for
/// short-lived resources. Only set it on structures you compact soon after building.
const ALLOW_COMPACTION = 1 << 1;
/// Optimize for fast ray tracing performance, recommended if the geometry is unlikely
/// to change (e.g. in a game: non-interactive scene geometry)