Skip to main content

GpuKdTree

Struct GpuKdTree 

Source
pub struct GpuKdTree { /* private fields */ }
Expand description

Immutable runtime-owned KD-tree uploaded explicitly and reused across batches. Construction/partitioning is on CPU; nearest-point traversal is on GPU. No device-to-host transfer is performed by upload, and no CPU search fallback is used. Public methods validate device identity before resource use.

Implementations§

Source§

impl GpuKdTree

Source

pub fn nearest_k_resident( &self, runtime: &WgpuRuntime, queries: &GpuQueryBatch, k: u32, ) -> SpatialResult<GpuNeighborhoods>

Submits up to k nearest neighbors for each explicitly uploaded query. Results stay on GPU, sorted by distance with the CPU KD-tree selection and stable tie order. Supports k=0..=64; includes self/duplicate points. No payload upload/readback or host wait occurs. Unsupported sizes error before allocation. Finite targets/queries are required at upload; GPU f32 rounding/underflow may differ across backends near search boundaries.

Source

pub fn radius_neighbors_resident( &self, runtime: &WgpuRuntime, queries: &GpuQueryBatch, radius: f32, capacity: u32, ) -> SpatialResult<GpuNeighborhoods>

Submits radius search (radius is not squared) with bounded row capacity. All matches are counted on GPU; the first capacity matches are stored in CPU traversal order. Capacity=0 performs count-only search. Negative/ NaN radii produce empty rows; infinite/overflowing radius squares are unbounded. Self/duplicate points are included. No silent truncation: readback complete access rejects overflow, and device consumers must inspect total counts. Target/query payloads are reused without copies.

Source§

impl GpuKdTree

Source

pub fn upload(runtime: &WgpuRuntime, tree: &KdTree) -> SpatialResult<Self>

Uploads a finite CPU KD-tree, preserving its leaf and tie traversal order. The borrowed tree may be dropped afterwards. Upload accounting includes 16 bytes per point and 32 per node, excluding uniform control data.

Source

pub fn upload_with_gpu_gather( runtime: &WgpuRuntime, tree: &KdTree, ) -> SpatialResult<Self>

Explicitly uploads original SoA axes/indices and gathers point records on GPU. CPU partitioning, finite validation and node packing remain. Existing nearest-search device requirements apply; unsupported limits reject. The pass copies integer words, preserving coordinate bits and leaf/tie order. Host upload is 16N + 32M bytes; the gather records 16N device-to-device bytes. There is no download or host completion wait. Two transient inputs use 16N extra device bytes beside the owned output; there is no 16*N host point-packing vector. Submission retains inputs until completion, and later searches on this runtime follow queue ordering.

Source

pub fn upload_and_queries_with_gpu_gather( runtime: &WgpuRuntime, tree: &KdTree, ) -> SpatialResult<(Self, GpuQueryBatch)>

Uploads the tree and generates queries for every point in original input order, sharing the same integer gather pass and uploaded SoA axes/indices. Combined host upload is 16N + 32M bytes, compared with 32N + 32M for separate tree/query uploads. Each returned object records 16N device-to-device output bytes; queries record zero host upload bytes. CPU partitioning, finite validation and node packing remain. No readback or completion wait occurs. Both outputs are owned and reusable; the CPU tree may be dropped. Two transient inputs use 16N extra device bytes; no host point/query packing vectors are created. Device requirements match nearest search, with an additional query dispatch-size check.

Source

pub fn upload_transfers(&self) -> TransferStats

Bytes transferred when this target was explicitly uploaded.

Source

pub fn nearest_one_within_download( &self, runtime: &WgpuRuntime, queries: &[[f32; 3]], bound: f32, ) -> SpatialResult<(Vec<Option<Neighbor>>, TransferStats)>

Explicitly uploads queries and downloads one optional nearest result per query, in input order, using an inclusive squared-distance gate. Negative/NaN gates and nonfinite queries produce None as on CPU; positive infinity is unbounded. Finite target coordinates are required at upload. GPU f32 arithmetic can differ near rounding/underflow boundaries across backends. Equal computed distances retain CPU near-first traversal ties. Accounting is 16 query bytes uploaded and 8 result bytes downloaded per query (uniform controls excluded); empty/invalid-gate calls copy no data. This synchronous API waits for completion, including the readback.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,