GPRT Host API Complete Reference

This toolkit has two sets of API, one for the “host” (typically referring to the CPU) and another for the “device” (normally the GPU, but really whatever is tracing the actual rays). This file contains a complete list of all of the host-side functions provided by the toolkit.

Core Functions

GPRTContext gprtContextCreate(int32_t requestedDevice)

Creates a context on one usable GPU.

GPRT_VISIBLE_DEVICES optionally specifies comma-separated Vulkan device ordinals in preference order. An empty value or -1 hides all devices; malformed and out-of-range ordinals are errors. Duplicate ordinals are ignored with a warning, preserving the order of their first occurrence. Rejected device selection uses LOG_ERROR and returns null if the error handler returns.

requestedDevice indexes the usable devices after this filtering and defaults to 0, the first usable device. The selected GPU is device 0 in subsequent GPRT calls. For example, GPRT_VISIBLE_DEVICES=1,0 makes gprtContextCreate(0) select Vulkan device 1 if that device is usable.

For multiple GPUs, call gprtContextCreate(requestedDevice) once per device. Pass the corresponding context as the first argument to operations that take a context. Synchronization between contexts is planned; current synchronization operations apply within one context.

void gprtContextDestroy(GPRTContext context)
GPRTModule gprtModuleCreate(GPRTContext context, GPRTProgram spvCode)
void gprtModuleDestroy(GPRTModule module)

Warning

doxygenfunction: Cannot find function “gprtBuildPipeline” in doxygen xml output for project “gprt” from directory: ../../build/xml/

void gprtBuildShaderBindingTable(GPRTContext context, GPRTBuildSBTFlags flags)
void gprtBeginProfile(GPRTContext context)
float gprtEndProfile(GPRTContext context)

Buffer Functions

Warning

doxygenfunction: Unable to resolve function “gprtHostBufferCreate” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- GPRTBuffer gprtHostBufferCreate(GPRTContext context, size_t size, size_t count = 1, const void *init = nullptr, size_t alignment = 16)
- template<typename T> GPRTBufferOf<T> gprtHostBufferCreate(GPRTContext context, size_t count = 1, const T *init = nullptr, size_t alignment = 16)

Warning

doxygenfunction: Unable to resolve function “gprtDeviceBufferCreate” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- GPRTBuffer gprtDeviceBufferCreate(GPRTContext context, size_t size, size_t count = 1, const void *init = nullptr, size_t alignment = 16)
- template<typename T> GPRTBufferOf<T> gprtDeviceBufferCreate(GPRTContext context, size_t count = 1, const T *init = nullptr, size_t alignment = 16)

Warning

doxygenfunction: Unable to resolve function “gprtSharedBufferCreate” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- GPRTBuffer gprtSharedBufferCreate(GPRTContext context, size_t size, size_t count = 1, const void *init = nullptr, size_t alignment = 16)
- template<typename T> GPRTBufferOf<T> gprtSharedBufferCreate(GPRTContext context, size_t count = 1, const T *init = nullptr, size_t alignment = 16)

Warning

doxygenfunction: Unable to resolve function “gprtBufferDestroy” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtBufferDestroy(GPRTBufferOf<T> buffer)
- void gprtBufferDestroy(GPRTBuffer buffer)

Warning

doxygenfunction: Unable to resolve function “gprtBufferMap” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtBufferMap(GPRTBufferOf<T> buffer, int deviceID)
- void gprtBufferMap(GPRTBuffer buffer, int deviceID)

Warning

doxygenfunction: Unable to resolve function “gprtBufferUnmap” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtBufferUnmap(GPRTBufferOf<T> buffer, int deviceID)
- void gprtBufferUnmap(GPRTBuffer buffer, int deviceID)

Warning

doxygenfunction: Cannot find function “gprtBufferGetPointer” in doxygen xml output for project “gprt” from directory: ../../build/xml/

Ray Generation Core Functions

Warning

doxygenfunction: Unable to resolve function “gprtRayGenCreate” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- GPRTRayGen gprtRayGenCreate(GPRTContext context, GPRTModule module, const char *entrypoint, size_t recordSize)
- template<typename T> GPRTRayGenOf<T> gprtRayGenCreate(GPRTContext context, GPRTModule module, const char *entrypoint)

Warning

doxygenfunction: Unable to resolve function “gprtRayGenDestroy” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtRayGenDestroy(GPRTRayGenOf<T> rayGen)
- void gprtRayGenDestroy(GPRTRayGen rayGen)

Warning

doxygenfunction: Unable to resolve function “gprtRayGenLaunch1D” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename RecordType, typename PushConstantsType> uint64_t gprtRayGenLaunch1D(GPRTContext context, GPRTRayGenOf<RecordType> rayGen, uint32_t dims_x, PushConstantsType pushConstants)
- template<typename RecordType> uint64_t gprtRayGenLaunch1D(GPRTContext context, GPRTRayGenOf<RecordType> rayGen, uint32_t dims_x)
- uint64_t gprtRayGenLaunch1D(GPRTContext context, GPRTRayGen rayGen, uint32_t dims_x, size_t pushConstantsSize, void *pushConstants)

Warning

doxygenfunction: Unable to resolve function “gprtRayGenLaunch2D” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename RecordType, typename PushConstantsType> uint64_t gprtRayGenLaunch2D(GPRTContext context, GPRTRayGenOf<RecordType> rayGen, uint32_t dims_x, uint32_t dims_y, PushConstantsType pushConstants)
- template<typename RecordType> uint64_t gprtRayGenLaunch2D(GPRTContext context, GPRTRayGenOf<RecordType> rayGen, uint32_t dims_x, uint32_t dims_y)
- uint64_t gprtRayGenLaunch2D(GPRTContext context, GPRTRayGen rayGen, uint32_t dims_x, uint32_t dims_y, size_t pushConstantsSize, void *pushConstants)

Warning

doxygenfunction: Unable to resolve function “gprtRayGenLaunch3D” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename RecordType, typename PushConstantsType> uint64_t gprtRayGenLaunch3D(GPRTContext context, GPRTRayGenOf<RecordType> rayGen, uint32_t dims_x, uint32_t dims_y, uint32_t dims_z, PushConstantsType pushConstants)
- template<typename RecordType> uint64_t gprtRayGenLaunch3D(GPRTContext context, GPRTRayGenOf<RecordType> rayGen, uint32_t dims_x, uint32_t dims_y, uint32_t dims_z)
- uint64_t gprtRayGenLaunch3D(GPRTContext context, GPRTRayGen rayGen, uint32_t dims_x, uint32_t dims_y, uint32_t dims_z, size_t pushConstantsSize, void *pushConstants)

Compute Program Core Functions

Warning

doxygenfunction: Unable to resolve function “gprtComputeCreate” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- GPRTCompute gprtComputeCreate(GPRTContext context, GPRTModule module, const char *entrypoint)
- template<typename ...Uniforms> GPRTComputeOf<Uniforms...> gprtComputeCreate(GPRTContext context, GPRTModule module, std::string entrypoint)

Warning

doxygenfunction: Unable to resolve function “gprtComputeDestroy” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename ...Uniforms> void gprtComputeDestroy(GPRTComputeOf<Uniforms...> compute)
- void gprtComputeDestroy(GPRTCompute compute)

Warning

doxygenfunction: Cannot find function “gprtComputeLaunch1D” in doxygen xml output for project “gprt” from directory: ../../build/xml/

Warning

doxygenfunction: Cannot find function “gprtComputeLaunch2D” in doxygen xml output for project “gprt” from directory: ../../build/xml/

Warning

doxygenfunction: Cannot find function “gprtComputeLaunch3D” in doxygen xml output for project “gprt” from directory: ../../build/xml/

Miss Program Core Functions

Warning

doxygenfunction: Unable to resolve function “gprtMissCreate” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- GPRTMiss gprtMissCreate(GPRTContext context, GPRTModule module, const char *entrypoint, size_t recordSize)
- template<typename T> GPRTMissOf<T> gprtMissCreate(GPRTContext context, GPRTModule module, const char *entrypoint)

Warning

doxygenfunction: Unable to resolve function “gprtMissDestroy” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtMissDestroy(GPRTMissOf<T> missProg)
- void gprtMissDestroy(GPRTMiss missProg)

Warning

doxygenfunction: Unable to resolve function “gprtMissSet” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtMissSet(GPRTContext context, int rayType, GPRTMissOf<T> missProgToUse)
- void gprtMissSet(GPRTContext context, int rayType, GPRTMiss missProgToUse)

Hit Group Core Functions

Warning

doxygenfunction: Unable to resolve function “gprtGeomTypeCreate” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- GPRTGeomType gprtGeomTypeCreate(GPRTContext context, GPRTGeomKind kind, size_t recordSize)
- template<typename T> GPRTGeomTypeOf<T> gprtGeomTypeCreate(GPRTContext context, GPRTGeomKind kind)

Warning

doxygenfunction: Unable to resolve function “gprtGeomTypeDestroy” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtGeomTypeDestroy(GPRTGeomTypeOf<T> geomType)
- void gprtGeomTypeDestroy(GPRTGeomType geomType)

Warning

doxygenfunction: Unable to resolve function “gprtGeomTypeSetClosestHitProg” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtGeomTypeSetClosestHitProg(GPRTGeomTypeOf<T> type, int rayType, GPRTModule module, const char *entrypoint)
- void gprtGeomTypeSetClosestHitProg(GPRTGeomType type, int rayType, GPRTModule module, const char *entrypoint)

Warning

doxygenfunction: Unable to resolve function “gprtGeomTypeSetAnyHitProg” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtGeomTypeSetAnyHitProg(GPRTGeomTypeOf<T> type, int rayType, GPRTModule module, const char *entrypoint)
- void gprtGeomTypeSetAnyHitProg(GPRTGeomType type, int rayType, GPRTModule module, const char *entrypoint)

Warning

doxygenfunction: Unable to resolve function “gprtGeomTypeSetIntersectionProg” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtGeomTypeSetIntersectionProg(GPRTGeomTypeOf<T> type, int rayType, GPRTModule module, const char *entrypoint)
- void gprtGeomTypeSetIntersectionProg(GPRTGeomType type, int rayType, GPRTModule module, const char *entrypoint)

Geometry Functions

Warning

doxygenfunction: Unable to resolve function “gprtGeomCreate” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- GPRTGeom gprtGeomCreate(GPRTContext context, GPRTGeomType type)
- template<typename T> GPRTGeomOf<T> gprtGeomCreate(GPRTContext context, GPRTGeomTypeOf<T> type)

Warning

doxygenfunction: Unable to resolve function “gprtGeomDestroy” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T> void gprtGeomDestroy(GPRTGeomOf<T> geometry)
- void gprtGeomDestroy(GPRTGeom geometry)

Warning

doxygenfunction: Unable to resolve function “gprtTrianglesSetVertices” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T1, typename T2> void gprtTrianglesSetVertices(GPRTGeomOf<T1> triangles, GPRTBufferOf<T2> vertices, uint32_t count, uint32_t stride, uint32_t offset)
- void gprtTrianglesSetVertices(GPRTGeom triangles, GPRTBuffer vertices, uint32_t count, uint32_t stride, uint32_t offset)

Warning

doxygenfunction: Unable to resolve function “gprtTrianglesSetIndices” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T1, typename T2> void gprtTrianglesSetIndices(GPRTGeomOf<T1> triangles, GPRTBufferOf<T2> indices, uint32_t count, uint32_t stride, uint32_t offset)
- void gprtTrianglesSetIndices(GPRTGeom triangles, GPRTBuffer indices, uint32_t count, uint32_t stride, uint32_t offset)

Warning

doxygenfunction: Unable to resolve function “gprtAABBsSetPositions” with arguments None in doxygen xml output for project “gprt” from directory: ../../build/xml/. Potential matches:

- template<typename T1, typename T2> void gprtAABBsSetPositions(GPRTGeomOf<T1> aabbs, GPRTBufferOf<T2> positions, uint32_t count, uint32_t stride, uint32_t offset)
- void gprtAABBsSetPositions(GPRTGeom aabbs, GPRTBuffer positions, uint32_t count, uint32_t stride, uint32_t offset)

Acceleration Structure Functions

Warning

doxygenfunction: Cannot find function “gprtTrianglesAccelCreate” in doxygen xml output for project “gprt” from directory: ../../build/xml/

GPRTAccel gprtInstanceAccelCreate(GPRTContext context, uint numInstances, GPRTBufferOf<gprt::Instance> instances)

Creates a new top-level acceleration structure (TLAS) for instances.

This function creates an instance acceleration structure that references bottom-level acceleration structures (BLAS) with transforms, creating a two-level hierarchy. Each instance can have its own transformation matrix and visibility mask.

See also

gprtAccelGetInstance to get instance data from a built BLAS

See also

gprtAccelBuild to build the acceleration structure after creation

Parameters:
  • context – The GPRT context

  • numInstances – Number of instances in this acceleration structure, must be non-zero

  • instances – A buffer containing ‘numInstances’ instance data structures

Returns:

A handle to the created acceleration structure

Warning

doxygenfunction: Cannot find function “gprtInstanceAccelSetTransforms” in doxygen xml output for project “gprt” from directory: ../../build/xml/

void gprtAccelBuild(GPRTContext context, GPRTAccel accel, GPRTBuildParams buildParams)

Builds the given acceleration structure so that it can be used on the device for ray tracing.

Parameters:
  • context – The GPRT context

  • accel – The acceleration structure to build.

  • mode – The build mode to use when constructing the acceleration structure.

    1. GPRT_BUILD_MODE_FAST_BUILD_NO_UPDATE Fastest possible build, but slower trace than 3 or 4. Good for fully-dynamic geometry like particles, destruction, changing prim counts, or moving wildly (explosions) where per-frame rebuild is required.

    2. GPRT_BUILD_MODE_FAST_BUILD_AND_UPDATE Slightly slower build than 1, but allows very fast update. Good for lower level-of-detail dynamic objects that are unlikely to be hit by too many rays but still need to be refitted per frame to be correct.

    3. GPRT_BUILD_MODE_FAST_TRACE_NO_UPDATE Fastest possible trace, but disallows updates. Slower to build than 1 or 2. This is a good default choice for static geometry.

    4. GPRT_BUILD_MODE_FAST_TRACE_AND_UPDATE Fastest trace possible while still allowing for updates. Updates are slightly slower than 2. Trace is a bit slower than 3. Good for high level-of-detail dynamic objects that are expected to be hit by a significant number of rays.

  • allowCompaction – Enables the tree to be compacted with gprtAccelCompact, potentially significantly reducing its memory footprint. Enabling this feature may take more time and memory than a normal build, and so should only be used when the compaction feature is needed.

  • minimizeMemory – Sacrifices build and trace performance to reduce memory consumption. Enable only when an application is under so much memory pressure that ray tracing isn’t feasible without optimizing for memory consumption as much as possible.

Warning

doxygenfunction: Cannot find function “gprtAccelRefit” in doxygen xml output for project “gprt” from directory: ../../build/xml/

void gprtAccelDestroy(GPRTAccel accel)

Shader Record Setters

Warning

doxygenfunction: Cannot find function “gprtRayGenSet3f” in doxygen xml output for project “gprt” from directory: ../../build/xml/

Warning

doxygenfunction: Cannot find function “gprtRayGenSetBuffer” in doxygen xml output for project “gprt” from directory: ../../build/xml/

Warning

doxygenfunction: Cannot find function “gprtRayGenSet2i” in doxygen xml output for project “gprt” from directory: ../../build/xml/