Add raw_handle method on vulkan::AccelerationStructure (#10187)

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
Stuart ParmenterandConnor Fitzgerald authored and GitHub committed 2026-08-30 17:30:56 +00:00
1 parent 2828eb3101
commit 786ecb9c4f
2 files changed
+28

No files matched your search

+1
View File
@@ -108,6 +108,7 @@ By @sagudev in [#10115](https://github.com/gfx-rs/wgpu/pull/10115).
- Add `BufferBinding::buffer`, a public read accessor for the bound buffer, which was previously inaccessible to out-of-tree `wgpu_hal::Api` implementations. By @danlehmann in [#9820](https://github.com/gfx-rs/wgpu/pull/9820).
- Allow specifying a queue family ownership transfer when transitioning a texture. `hal::TextureBarrier` gained an optional `queue_family_ownership_transfer` field (honored only by the Vulkan backend) so that images imported from external memory can be acquired from and released back to the queue family of an external or foreign owner, described by the new `hal::QueueFamily` enum. Resolves [#2948](https://github.com/gfx-rs/wgpu/issues/2948). By @alexander-bruun in [#9668](https://github.com/gfx-rs/wgpu/pull/9668).
- Add `wgpu_hal::vulkan::Surface::set_next_present_chain`, which attaches a caller-provided `pNext` chain to the `VkPresentInfoKHR` of the surface's next presentation. With `Adapter::open_with_callback` to enable the device extension, this supports presentation extensions wgpu has no dedicated support for, such as [VK_NV_present_metering](https://registry.khronos.org/vulkan/specs/latest/man/html/VK_NV_present_metering.html) for metering the display timing of frame-generation frames. By @stuartparmenter in [#9847](https://github.com/gfx-rs/wgpu/pull/9847).
- Add `wgpu_hal::vulkan::AccelerationStructure::raw_handle`, which returns the underlying `VkAccelerationStructureKHR`. Use it with `Adapter::open_with_callback` to record acceleration structure commands from extensions wgpu doesn't support, such as [VK_NV_cluster_acceleration_structure](https://registry.khronos.org/vulkan/specs/latest/man/html/VK_NV_cluster_acceleration_structure.html). Mark the result with `CommandEncoder::mark_acceleration_structures_built`. By @stuartparmenter in [#10187](https://github.com/gfx-rs/wgpu/pull/10187).
- Add `wgpu_hal::vulkan::Surface::set_next_swapchain_create_chain` and `wgpu_hal::vulkan::Queue::set_next_submit_chain`. The first attaches a caller-provided `pNext` chain to the `VkSwapchainCreateInfoKHR` of the surface's next configuration. The second attaches one to the `VkSubmitInfo` of the queue's next submission. Together with `set_next_present_chain` and the existing raw-handle accessors, this makes [VK_NV_low_latency2](https://registry.khronos.org/vulkan/specs/latest/man/html/VK_NV_low_latency2.html) usable on a wgpu swapchain. That extension is the Vulkan interface for NVIDIA Reflex. By @stuartparmenter in [#10095](https://github.com/gfx-rs/wgpu/pull/10095).
#### Metal
+27
View File
@@ -904,6 +904,33 @@ pub struct AccelerationStructure {
impl crate::DynAccelerationStructure for AccelerationStructure {}
impl AccelerationStructure {
/// Returns the raw Vulkan acceleration structure handle.
///
/// This allows recording acceleration structure commands that `wgpu-hal` doesn't
/// support. If those commands come from a device extension, enable it with
/// [`Adapter::open_with_callback`].
///
/// For a device address, use
/// [`crate::Device::get_acceleration_structure_device_address`] instead.
///
/// `wgpu` doesn't observe an external build, and rejects an acceleration structure
/// that it never built. Call `wgpu::CommandEncoder::mark_acceleration_structures_built`
/// on the encoder that recorded the build.
///
/// # Safety
///
/// - The acceleration structure handle must not be manually destroyed, or used after
/// the acceleration structure is dropped
/// - External work using the handle must be synchronized against `wgpu`'s own reads
/// and writes, such as compaction
/// - An external build must not write more data than the size the acceleration
/// structure was created with
pub unsafe fn raw_handle(&self) -> vk::AccelerationStructureKHR {
self.raw
}
}
#[derive(Debug)]
pub enum TextureMemory {
// shared memory in GPU allocator (owned by wgpu-hal)