Skip to content

Comments

Core API changes to allow batch queries with XDG (PR 1)#191

Closed
Waqar-ukaea wants to merge 8 commits intoxdg-org:mainfrom
Waqar-ukaea:pr1-batch-query-core
Closed

Core API changes to allow batch queries with XDG (PR 1)#191
Waqar-ukaea wants to merge 8 commits intoxdg-org:mainfrom
Waqar-ukaea:pr1-batch-query-core

Conversation

@Waqar-ukaea
Copy link
Collaborator

@Waqar-ukaea Waqar-ukaea commented Jan 30, 2026

Summary

Note merging of this PR is a prerequisite for the following PRs:

This PR adds core XDG support for batched GPRT ray queries, enabling both ray_fire() and point_in_volume() to run over many rays efficiently.

It introduces three query paths to GPRT ray tracing:

  • Scalar query (single ray) — primarily for debugging / comparison (launching a full RT pipeline for one ray is expensive).
  • Batch query (host → device staging) — accepts arrays of origins/directions and launches the RT pipeline once for the entire batch. Single Volume
  • Prepared / device-only queries — allows external applications to populate XDG’s device ray buffers via a callback, then launch the RT pipeline without host staging. Ray by ray volume specification

To support the prepared workflow, this PR also adds a ray/hit buffer abstraction and the callback plumbing required for external ray population. The required stubs for Embree are in place for compilation but the majority of these functions will only ever work with a GPU capable RT backend.


Public API Changes

GPRTRayTracer (new / overridden)

Point-in-volume

  • point_in_volume(...) — batched PIV over points (optional directions and exclude list).
  • point_in_volume_prepared(...) — run PIV using pre-populated device buffers.

Ray fire

  • ray_fire(...) — batched ray fire over origins/directions (with distance limit, orientation, optional exclude list).
  • ray_fire_prepared(...) — run ray fire using pre-populated device buffers.

Buffer / workflow plumbing

  • check_rayhit_buffer_capacity(...) — ensure device buffers can accommodate N rays.
  • populate_rays_external(...) — callback-based external ray population (device-only path).
  • download_hits(...) — download hits into host-side storage (utility).

GPRT backend accessors

  • context() — access the underlying GPRT context. Currently required since GPRT does not implement VK_EXTERNAL_MEMORY as of yet. So to mock an external application, I use "external" compute shaders attached to the same underlying GPRTContext.

RayTracer interface (new virtuals)

Adds virtual entry points for batched and prepared workflows:

  • point_in_volume(...)
  • ray_fire(...)
  • point_in_volume_prepared(...)
  • ray_fire_prepared(...)
  • check_rayhit_buffer_capacity(...)
  • populate_rays_external(...)

XDG API (new overloads / helpers)

Batched launch

  • ray_fire(...) — volume-level overload for batched ray fire.

Prepared / device-only workflow

  • ray_fire_prepared(...)
  • point_in_volume_prepared(...)
  • populate_rays_external(...)

Host transfer

  • transfer_hits_buffer_to_host(...) — transfer prepared hit buffers back to host.

@Waqar-ukaea Waqar-ukaea added the Ray Tracing Changes made to the core ray tracing interface affecting both Embree and GPRT implementations. label Jan 30, 2026
@Waqar-ukaea
Copy link
Collaborator Author

Closing in favour of the newer PR which has a cleaner code split and includes tests.

@Waqar-ukaea Waqar-ukaea closed this Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ray Tracing Changes made to the core ray tracing interface affecting both Embree and GPRT implementations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant