Vulkan compute shader ray tracing backend. More...
#include <VulkanComputeBackend.h>
Public Member Functions | |
| VulkanComputeBackend (VulkanDevice *external_device) | |
| Constructor for test mode with shared device. | |
| void | initialize () override |
| Initialize the ray tracing backend. | |
| void | shutdown () override |
| Shutdown the ray tracing backend. | |
| void | updateGeometry (const RayTracingGeometry &geometry) override |
| Update geometry data in the ray tracing backend. | |
| void | buildAccelerationStructure () override |
| Build or rebuild the acceleration structure. | |
| void | updateMaterials (const RayTracingMaterial &materials) override |
| Update material properties (reflectivity, transmissivity, specular) | |
| void | updateSources (const std::vector< RayTracingSource > &sources) override |
| Update radiation source definitions. | |
| void | updateDiffuseRadiation (const std::vector< float > &flux, const std::vector< float > &extinction, const std::vector< helios::vec3 > &peak_dir, const std::vector< float > &dist_norm, const std::vector< float > &sky_energy) override |
| Update diffuse (ambient) radiation parameters. | |
| void | updateSkyModel (const std::vector< helios::vec4 > &sky_radiance_params, const std::vector< float > &camera_sky_radiance, const helios::vec3 &sun_direction, const std::vector< float > &solar_disk_radiance, float solar_disk_cos_angle) override |
| Update sky radiance model parameters (for camera rendering) | |
| void | launchDirectRays (const RayTracingLaunchParams ¶ms) override |
| Launch direct (unscattered) rays to radiation sources. | |
| void | launchDiffuseRays (const RayTracingLaunchParams ¶ms) override |
| Launch diffuse (hemispherically-distributed) rays. | |
| void | launchCameraRays (const RayTracingLaunchParams ¶ms) override |
| Launch camera rays for image rendering. | |
| void | launchPixelLabelRays (const RayTracingLaunchParams ¶ms) override |
| Launch pixel labeling rays (for primitive identification in images) | |
| void | getRadiationResults (RayTracingResults &results) override |
| Get radiation simulation results. | |
| void | getCameraResults (std::vector< float > &pixel_data, std::vector< uint > &pixel_labels, std::vector< float > &pixel_depths, uint camera_id, const helios::int2 &resolution) override |
| Get camera rendering results. | |
| void | zeroRadiationBuffers (size_t launch_band_count) override |
| Zero all radiation result buffers (radiation_in, radiation_out, radiation_specular) | |
| void | zeroScatterBuffers () override |
| Zero scatter buffers (scatter_buff_top, scatter_buff_bottom) | |
| void | zeroCameraPixelBuffers (const helios::int2 &resolution) override |
| Zero camera pixel label and depth buffers. | |
| void | copyScatterToRadiation () override |
| Copy scatter buffer contents to radiation buffers. | |
| void | uploadRadiationOut (const std::vector< float > &radiation_out_top, const std::vector< float > &radiation_out_bottom) override |
| Upload radiation_out buffers directly (without launching rays) | |
| void | uploadCameraScatterBuffers (const std::vector< float > &scatter_top_cam, const std::vector< float > &scatter_bottom_cam) override |
| Upload camera scatter buffers. | |
| void | zeroCameraScatterBuffers (size_t launch_band_count) override |
| Zero camera scatter buffers (scatter_buff_top_cam, scatter_buff_bottom_cam) | |
| void | uploadSourceFluxes (const std::vector< float > &fluxes) override |
| Upload source flux values for launched bands. | |
| void | uploadSourceFluxesCam (const std::vector< float > &fluxes_cam) override |
| Upload camera-weighted source flux values for specular reflection. | |
| void | queryGPUMemory () const override |
| Query and report GPU memory usage. | |
| std::string | getBackendName () const override |
| Get the name of the backend implementation. | |
Static Public Member Functions | |
| static bool | probe () noexcept |
| Probe whether Vulkan compute is available. | |
Static Public Member Functions inherited from helios::RayTracingBackend | |
| static std::unique_ptr< RayTracingBackend > | create (const std::string &backend_type) |
| Create a ray tracing backend instance. | |
Vulkan compute shader ray tracing backend.
Uses software BVH traversal in compute shaders (no VK_KHR_ray_tracing required). Supports AMD, Intel, and Apple Silicon GPUs via Vulkan or MoltenVK.
Performance target: 5-10x slower than OptiX (hardware RT).
Definition at line 47 of file VulkanComputeBackend.h.
| helios::VulkanComputeBackend::VulkanComputeBackend | ( | ) |
Definition at line 34 of file VulkanComputeBackend.cpp.
|
explicit |
Constructor for test mode with shared device.
| external_device | Non-owning pointer to shared VulkanDevice (must be pre-initialized) |
INTERNAL TEST-ONLY CONSTRUCTOR Used by test suite to share single VulkanDevice across all test cases. Precondition: external_device must outlive this backend (satisfied by static singleton).
Definition at line 38 of file VulkanComputeBackend.cpp.
|
override |
Definition at line 45 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Build or rebuild the acceleration structure.
Constructs the BVH or other acceleration structure for efficient ray traversal. Should be called after updateGeometry() or when geometry changes.
Implements helios::RayTracingBackend.
Definition at line 564 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Copy scatter buffer contents to radiation buffers.
Used for multi-bounce radiation: scattering iteration results are accumulated into the main radiation buffers.
Implements helios::RayTracingBackend.
Definition at line 1933 of file VulkanComputeBackend.cpp.
|
inlineoverridevirtual |
Get the name of the backend implementation.
Implements helios::RayTracingBackend.
Definition at line 116 of file VulkanComputeBackend.h.
|
overridevirtual |
Get camera rendering results.
| [out] | pixel_data | Flattened pixel values [band][pixel_y][pixel_x] |
| [out] | pixel_labels | Primitive UUID for each pixel (0 if sky/miss) |
| [out] | pixel_depths | Depth value for each pixel |
| [in] | camera_id | Camera identifier |
| [in] | resolution | Camera resolution (width, height) |
Implements helios::RayTracingBackend.
Definition at line 1760 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Get radiation simulation results.
| [out] | results | Structure containing radiation_in, radiation_out, scatter buffers, etc. |
Retrieves absorbed and emitted radiation for all primitives and bands.
Implements helios::RayTracingBackend.
Definition at line 1646 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Initialize the ray tracing backend.
Creates the ray tracing context, allocates buffers, compiles/loads programs, and sets up the acceleration structure.
Implements helios::RayTracingBackend.
Definition at line 52 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Launch camera rays for image rendering.
| [in] | params | Launch parameters including camera position, direction, FOV, etc. |
Implements helios::RayTracingBackend.
Definition at line 1332 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Launch diffuse (hemispherically-distributed) rays.
| [in] | params | Launch parameters including diffuse distribution parameters |
Implements helios::RayTracingBackend.
Definition at line 972 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Launch direct (unscattered) rays to radiation sources.
| [in] | params | Launch parameters (dimensions, seed, band config, etc.) |
Implements helios::RayTracingBackend.
Definition at line 743 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Launch pixel labeling rays (for primitive identification in images)
| [in] | params | Launch parameters with camera configuration |
Implements helios::RayTracingBackend.
Definition at line 1499 of file VulkanComputeBackend.cpp.
|
staticnoexcept |
Probe whether Vulkan compute is available.
Creates a temporary VulkanDevice (which includes compute capability probing), then destroys it. All resources are cleaned up before returning.
Definition at line 23 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Query and report GPU memory usage.
Implements helios::RayTracingBackend.
Definition at line 2151 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Shutdown the ray tracing backend.
Destroys the context, frees all buffers and resources.
Implements helios::RayTracingBackend.
Definition at line 87 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Update diffuse (ambient) radiation parameters.
| [in] | flux | Diffuse flux per band |
| [in] | extinction | Extinction coefficient per band |
| [in] | peak_dir | Peak direction for diffuse distribution per band |
| [in] | dist_norm | Distribution normalization factor per band |
| [in] | sky_energy | Energy absorbed by sky per band |
Implements helios::RayTracingBackend.
Definition at line 690 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Update geometry data in the ray tracing backend.
| [in] | geometry | Geometry data for all primitive types |
This uploads vertex data, transform matrices, UUIDs, texture masks, and all other geometry-related data to the GPU.
Implements helios::RayTracingBackend.
Definition at line 189 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Update material properties (reflectivity, transmissivity, specular)
| [in] | materials | Material data for all primitives, sources, and bands |
Implements helios::RayTracingBackend.
Definition at line 568 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Update sky radiance model parameters (for camera rendering)
| [in] | sky_radiance_params | Prague sky model parameters per band (vec4) |
| [in] | camera_sky_radiance | Sky radiance for cameras per band |
| [in] | sun_direction | Direction to the sun |
| [in] | solar_disk_radiance | Solar disk radiance per band |
| [in] | solar_disk_cos_angle | Cosine of solar disk angular radius |
Implements helios::RayTracingBackend.
Definition at line 697 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Update radiation source definitions.
| [in] | sources | Vector of radiation sources (collimated, sphere, sun, rectangle, disk) |
Implements helios::RayTracingBackend.
Definition at line 636 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Upload camera scatter buffers.
| [in] | scatter_top_cam | Scattered radiation for cameras (top surface) indexed by [primitive * Nbands_launch + band] |
| [in] | scatter_bottom_cam | Scattered radiation for cameras (bottom surface) |
Used to upload emission energy that cameras should see before scatter iterations.
Implements helios::RayTracingBackend.
Definition at line 2040 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Upload radiation_out buffers directly (without launching rays)
| [in] | radiation_out_top | Top-face outgoing radiation [Nprims * Nbands] |
| [in] | radiation_out_bottom | Bottom-face outgoing radiation [Nprims * Nbands] |
Used to set outgoing radiation for scattering iterations.
Implements helios::RayTracingBackend.
Definition at line 1992 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Upload source flux values for launched bands.
| [in] | fluxes | Source flux values indexed by [source * Nbands_launch + band] |
Used to set per-band source fluxes before direct ray launch.
Implements helios::RayTracingBackend.
Definition at line 2104 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Upload camera-weighted source flux values for specular reflection.
| [in] | fluxes_cam | Camera spectral response weights indexed by [source * Nbands_launch + band] |
Uploads per-camera spectral response weights used for specular reflection in camera rendering. The weights represent ∫(source_spectrum × camera_response) / ∫(source_spectrum) for each source/band combination. Called before each camera render with the current camera's weights.
Implements helios::RayTracingBackend.
Definition at line 2130 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Zero camera pixel label and depth buffers.
| [in] | resolution | Full camera resolution (width, height) |
Must be called before launching pixel label rays for multiple tiles. Each tile launch accumulates results without zeroing, so this must be called once before the tile loop to initialize the buffers.
Implements helios::RayTracingBackend.
Definition at line 1900 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Zero camera scatter buffers (scatter_buff_top_cam, scatter_buff_bottom_cam)
| [in] | launch_band_count | Number of bands being launched in current iteration |
Buffers are sized by launch_band_count to prevent double-counting when accumulating camera scatter across multiple ray launches.
Implements helios::RayTracingBackend.
Definition at line 2072 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Zero all radiation result buffers (radiation_in, radiation_out, radiation_specular)
| [in] | launch_band_count | Number of bands being launched in current iteration |
Camera scatter buffers are sized by launch_band_count (not global band count) to match per-launch accumulation semantics. All other buffers use the global band count.
Implements helios::RayTracingBackend.
Definition at line 1817 of file VulkanComputeBackend.cpp.
|
overridevirtual |
Zero scatter buffers (scatter_buff_top, scatter_buff_bottom)
Implements helios::RayTracingBackend.
Definition at line 1868 of file VulkanComputeBackend.cpp.