Runtime and capabilities (Dr.Jit)
Module-level functions, constants, rays, and ray flags of rayd.drjit - device selection, OptiX probing, capability reports, and the API manifest.
This page covers the module-level API of rayd.drjit: device control, capability reports, constants, and the ray types every query takes.
import rayd.drjit as rdAll arrays are Dr.Jit CUDA arrays from drjit.cuda (detached) or drjit.cuda.ad (differentiable).
Devices#
set_device#
set_device(device: int, initialize_optix: bool = True) -> intSets the current thread's CUDA device for RayD. Call it before you create meshes, scenes, or Dr.Jit arrays that you use with them.
CUDA device index, from 0 to device_count() - 1.
TrueAlso initialize the OptiX device context when OptiX is available. With False, only CUDA-based operation is prepared.
Returns the device index.
Do not reuse scenes or OptiX resources across a device switch in the same process.
device_count#
device_count() -> intReturns the number of Dr.Jit-compatible CUDA devices visible to RayD.
current_device#
current_device() -> intReturns the current thread's active Dr.Jit CUDA device index.
optix_available#
optix_available() -> boolReturns True when a usable OptiX driver is present. It never raises, so it is safe on machines without OptiX. Set the environment variable RAYD_DISABLE_OPTIX=1 to force False and exercise the CUDA fallback on an OptiX-capable machine.
print(rd.optix_available()) # True on a recent NVIDIA driverCapability reports#
backend_capabilities#
backend_capabilities() -> dictReturns a flat mapping of feature names to booleans, for example "intersect", "reflection_trace", "reverse_ad". A True entry means the backend has the feature at all; per-operation AD support is in api_manifest().
api_manifest#
api_manifest() -> dictReturns the classified public API with stability, aliases, typing, and derivative metadata. Top-level keys: version, schema_sha256, backend, typing, naming_conventions, derivative_statuses, derivatives, capabilities, apis, aliases, trace.
derivatives[family][operation] has primal, note, and input_domains, a mapping from input domain to {"vjp": status, "jvp": status}. See Differentiation.
status = rd.api_manifest()["derivatives"]native_launch_audit#
native_launch_audit() -> dict
native_launch_audit_clear() -> Nonenative_launch_audit() returns counters of RayD's native kernel launches, grouped by operation. native_launch_audit_clear() resets them. Use them to check how many launches a piece of code triggers.
Constants#
| Name | Value | Used by |
|---|---|---|
REFLECTION_EXPORT_FULL | 0 | ReflectionTraceOptions.export_mode: all fields (default) |
REFLECTION_EXPORT_MINIMAL | 1 | ReflectionTraceOptions.export_mode: a reduced field set |
REFLECTION_EXPORT_COUNT_ONLY | 2 | ReflectionTraceOptions.export_mode: bounce counts only |
RAYD_DFR_DIRECT | 1 | DfrOptions.strategy_mask, DfrPathOptions.strategy_mask |
RAYD_DFR_KELLER | 2 | DfrOptions.strategy_mask |
RAYD_DFR_SUFFIX_REFL | 4 | DfrOptions.strategy_mask |
RAYD_DFR_HASH | 0 | DfrOptions.sample_sequence: hash-based sample sequence (default) |
RAYD_DFR_SOBOL | 1 | DfrOptions.sample_sequence: Sobol sequence |
RAYD_DFR_MATCHED_ISO | 0 | receiver_model of the diffraction options: matched isotropic receiver (default) |
Ray#
Ray()
Ray(o: drjit.cuda.Array3f, d: drjit.cuda.Array3f, /)A batch of detached rays. Both arguments are positional.
(0, 0, 0)Ray origins, one per lane.
(0, 0, 1)Ray directions. They do not need to be normalized; distances t are measured in units of d.
Attributes o, d, and tmax are writable. tmax (a Float, default inf) limits the search distance. reversed() returns a ray with the direction flipped.
from drjit.cuda import Array3f, Float
ray = rd.Ray(Array3f([0, 0], [0, 0], [1, 1]), Array3f([0, 0], [0, 0], [-1, 1]))
ray.tmax = Float([10.0, 10.0])RayAD#
RayAD()
RayAD(o: drjit.cuda.ad.Array3f, d: drjit.cuda.ad.Array3f, /)The differentiable ray. Same attributes and defaults as Ray, with AD arrays. Passing a RayAD to a query selects the differentiable overload, which returns the ...AD result record.
RayFlags#
class RayFlags(enum.IntFlag)Selects which fields Scene.intersect and MixedScene.intersect compute.
| Member | Fields |
|---|---|
Geometric | t, p, barycentric, ids, geo_n |
ShadingN | n |
UV | uv |
All | all of the above (default) |
None | no optional fields (in 0.8.0 t, p, and the ids are still filled) |
None is a Python keyword, so reach that member as rd.RayFlags["None"] or rd.RayFlags(0). Combine members with |.