Expand description
GPU acceleration backends for the OxiPhysics engine.
This crate provides a GPU compute abstraction layer that can work with any backend, with a CPU fallback as the default implementation. No heavy GPU dependencies (such as wgpu) are required.
Re-exports§
pub use compute::BufferHandle;pub use compute::ComputeBackend;pub use compute::ComputeKernel;pub use compute::CpuBackend;pub use neural_compute::*;pub use particle_system::*;pub use sparse_gpu::*;
Modules§
- bvh
- CPU BVH (Bounding Volume Hierarchy) tree for broad-phase acceleration.
- cell_
list - Auto-generated module structure
- collision_
gpu - Auto-generated module structure
- compute
- Auto-generated module structure
- compute_
pipeline - CPU-side simulation of a wgpu compute pipeline abstraction.
- deformable_
gpu - Deformable GPU simulation module.
- fluid_
gpu - GPU fluid simulation: Navier-Stokes, LBM kernels, SPH kernels, vortex confinement, and shallow-water equations — CPU mock backend.
- fluid_
sim_ gpu - Auto-generated module structure
- flux_
compute - CPU-side parallel flux and advection compute kernels.
- gpu_
cloth - GPU-accelerated cloth simulation (CPU mock implementation).
- gpu_
collision_ detection - GPU-accelerated collision detection (CPU mock backend via Rayon).
- gpu_
collision_ ext - GPU collision detection extensions (CPU mock backend).
- gpu_
fem_ assembly - GPU-accelerated FEM matrix assembly (CPU mock implementation).
- gpu_
fluid - GPU-accelerated fluid simulation using a MAC (Marker-and-Cell) grid.
- gpu_
fluid_ euler - GPU Eulerian fluid simulation on a staggered MAC grid (CPU mock backend).
- gpu_lbm
- GPU-accelerated Lattice Boltzmann Method (D2Q9) — CPU mock backend.
- gpu_
md_ solver - GPU-side molecular dynamics (MD) solver — CPU mock backend.
- gpu_
mesh_ processing - GPU triangle mesh processing (CPU mock implementation).
- gpu_
neural_ solver - GPU neural network solver for physics (CPU mock backend).
- gpu_nn
- GPU-accelerated neural network compute (CPU mock backend).
- gpu_
particle_ system - GPU-accelerated particle system (CPU mock implementation).
- gpu_
particles - GPU-style particle system simulated on the CPU.
- gpu_
ray_ tracing - GPU ray tracing (CPU mock implementation).
- gpu_
reduction - GPU reduction and scan operations (CPU mock implementation).
- gpu_
rigid - GPU-accelerated rigid body batch simulation (CPU mock).
- gpu_sdf
- GPU-accelerated Signed Distance Field (SDF) computation (CPU mock).
- gpu_
sort - GPU-style parallel sorting algorithms (CPU simulation).
- gpu_
sparse_ solver - GPU sparse linear system solver (CPU mock implementation).
- gpu_
sph_ density - GPU-accelerated SPH density computation (CPU mock implementation).
- gpu_
sph_ pressure - GPU SPH pressure solver (CPU mock backend).
- gpu_
sph_ solver - GPU-side SPH solver — CPU mock backend.
- gpu_
thermal - GPU-accelerated thermal computation (CPU mock backend via Rayon).
- gpu_
voxel - GPU voxel grid operations (CPU mock implementation).
- grid_
reduce - GPU-style grid-based reduction and aggregation kernels.
- kernels
- GPU/CPU compute kernels for physics simulation.
- memory
- GPU memory management abstractions.
- neural_
compute - Auto-generated module structure
- neural_
physics - Neural network-based physics acceleration (CPU mock).
- parallel
- Auto-generated module structure
- parallel_
sort - Parallel sorting and reduction utilities (CPU-side, rayon-based).
- particle_
system - Auto-generated module structure
- path_
tracer - CPU path tracer using GPU-style algorithms.
- pipeline
- Auto-generated module structure
- ray_
marching - Ray marching and Signed Distance Field (SDF) rendering utilities.
- ray_
tracing_ gpu - GPU ray tracing with f32 precision (CPU mock).
- raytracing
- Auto-generated module structure
- scheduler
- GPU workload scheduler.
- sdf_
compute - Auto-generated module structure
- shader_
registry - Auto-generated module structure
- shaders
- Auto-generated module structure
- sparse_
gpu - GPU-ready sparse matrix formats and iterative solvers with data-oriented layouts.
Structs§
- Annotated
Error - An error annotated with severity and an optional kernel name.
- Dispatch
Timer - A simple timer utility for profiling GPU-like dispatches.
- Pipeline
Stage Error - A pipeline-stage error: carries the stage name plus the underlying cause.
Enums§
- Error
- Main error type for the gpu module.
- Error
Severity - Severity level for a GPU error.
Functions§
- aligned_
size - Compute the padded buffer size to meet alignment requirements.
- alloc_
err - Build a
Error::BufferAllocationFailederror. - arg_
mismatch_ err - Build a
Error::KernelArgCountMismatcherror. - bandwidth_
gb_ s - Estimate memory bandwidth in GB/s.
- buffer_
size_ 2d - Compute the 2-D buffer size (rows × pitch) for a texture-like allocation.
- check
- Check a boolean condition; return
Err(Error::General(msg))if false. - clamp_
f64 - Clamp
vto[lo, hi]. - collect_
errors - Collect multiple errors from a batch dispatch. Returns
Ok(())if the vec is empty, orErrcontaining the first error otherwise. - cross3
- Compute the cross product of two 3-element arrays.
- dispatch_
count - Compute the optimal work group size for a given total work item count.
- dispatch_
limit_ err - Build a
Error::DispatchLimitExceedederror. - dot3
- Compute the dot product of two 3-element arrays.
- elements_
in_ budget - Compute the number of elements that fit in a given memory budget.
- exclusive_
scan - Parallel prefix sum (scan) on a slice of f64 values.
- grid_
oob_ err - Build a
Error::GridIndexOutOfBoundserror. - inclusive_
scan - Inclusive scan:
result[i] = sum(data[0..=i]). - index_
3d_ from_ linear - Convert a linear index back to 3D coordinates.
- inv_
lerp - Inverse lerp: returns
tsuch thatlerp(a, b, t) == v, or0ifa==b. - is_
power_ of_ two - True when
valueis a power of two (including 1). - length3
- Length of a 3-D vector.
- lerp
- Linear interpolation:
a + t*(b-a). - linear_
index_ 3d - Flatten a 3D dispatch (x, y, z) into a linear index, given grid dimensions.
- log2_
pow2 - Log2 of a power-of-two value. Panics in debug mode if
vis not a power of two. - next_
power_ of_ two - Round
valueup to the next power of two. - normalize3
- Normalise a 3-D vector. Returns the zero vector if the length is < eps.
- reduce_
max - Parallel reduce: compute the maximum of all elements.
- reduce_
min - Parallel reduce: compute the minimum of all elements.
- reduce_
sum - Parallel reduce: compute the sum of all elements.
- reflect3
- Reflect vector
dabout normaln(both assumed normalised). - row_
pitch - Stride (in bytes) of a row in a 2-D buffer, given the element count per row and the required alignment.
- safe_
recip - Safe reciprocal: returns
1/xwhen|x| > eps, else0. - safe_
sqrt - Safe square root: clamps negative values to 0 before taking sqrt.
- shader_
err - Build a
Error::ShaderCompilationError. - smootherstep
- Smoother-step (Ken Perlin’s quintic):
6t⁵ − 15t⁴ + 10t³. - smoothstep
- Smooth-step function:
3t² - 2t³witht = (v - lo) / (hi - lo). - tile_
count_ 2d - Divides a 2-D problem of
(width × height)into tiles of(tw × th)and returns(tiles_x, tiles_y). - tile_
index_ to_ 2d - Convert a flat tile index back to
(tile_x, tile_y)for a grid withtiles_xcolumns. - total_
tiles_ 2d - Total number of tiles for a 2-D problem.
- unsupported_
err - Build an
Error::UnsupportedFeature. - wrap_
angle - Wrap an angle in radians to
(-π, π].
Type Aliases§
- Result
- Result type alias