GPUOpen-Drivers / gpurt

GPU Ray Tracing Library
MIT License
50 stars 6 forks source link

GPU Ray Tracing Library

The GPU Ray Tracing (GPURT) library is a static library (source deliverable) that provides ray tracing related functionalities for AMD drivers supporting DXR (DirectX 12®) and the Vulkan® RT API. The GPURT library is built on top of AMD's Platform Abstraction Library (PAL). Refer to PAL documentation for information regarding interfaces used by GPURT for various operations including command generation, memory allocation etc.

GPURT uses a C++ interface. The public interface is defined in .../gpurt/gpurt, and clients must only include headers from that directory. The interface is divided into multiple header files based on their dependencies and usage.

The primary functionality provided by GPURT includes the following:

GPURT follows PAL Coding Standards whenever possible.

Acceleration Structure

GPURT interfaces support various acceleration structure operations including:

GPURT supports various algorithms for building efficient acceleration structures. The build algorithm implementations are located in the src/shaders folder.

Traversal Loop

The GPURT library implements various traversal loops for API intrinsics such as DXR's TraceRay() & RayQuery and Vulkan RT's TraceRayKHR & RayQueryKHR. The HLSL implementation of these traversal loops and associated intrinsics is located in the src/shaders folder with the main entry points defined in src/shader/GpuRtLibrary.hlsl

Dependencies

GPURT has a direct dependency on AMD's PAL library as it relies on the Utility library and uses PAL interfaces for command generation, memory allocation etc. Client drivers must already have PAL sources and library specified in their include paths.

How does the shader compilation work?

A CMake script is used to get all the executable dependencies (mainly compilers) and check for file changes. After it gets everything it needs, it invokes the tools/CompileRTShaders.py script, which will do the actual compilation by calling tools such as DirectXShaderCompiler and glslang. This produces a bunch of header files which hardcode the compiled shaders into arrays of 32-bit unsigned integers, as well as a header file g_internal_shaders.h which just has generated includes for all the other headers that were created. After all this is done, proper source files just include g_internal_shaders.h to reference the compiled shaders.