Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 2.59 KB

File metadata and controls

41 lines (32 loc) · 2.59 KB

D3D12 Raytracing Hello World sample

D3D12 Raytracing Hello World GUI

This sample demonstrates how to setup a raytracing pipeline and render a triangle in screenspace via raytracing. The sample assumes familiarity with Dx12 programming.

Raytracing Initialization

The initialization of the raytracing pipeline is done in CreateDeviceDependentResources() and includes querying raytracing device and commandlist, creating raytracing acceleration structures, raytracing pipeline state object, shader tables and a 2D texture output resource.

Rendering

Each frame render happens in the sample's OnRender() call and includes executing DispatchRays() with a 2D grid dimensions matching that of backbuffer resolution and copying of the raytraced result to the backbuffer before finally presenting the it to the screen. The sample implements three shaders: ray generation, closest hit and miss shader. The ray generation shader is executed for the whole render target via DispatchRays(). If a ray index corresponding to a pixel is inside a stencil window, it casts a ray into the scene. For ray indices outside the stencil window, the shader outputs color based on the ray's xy dispatch coordinates from top-left. Casted rays that hit the triangle render barycentric coordinates of the ray's hit position within the triangle. Missed rays render black.

Usage

The sample starts with Fallback Layer implementation being used by default. The Fallback Layer will use raytracing driver if available, otherwise it will default to the compute fallback. This default behavior can be overriden via UI controls or input arguments.

D3D12RaytracingHelloWorld.exe [ -FL | -DXR ]

  • [-FL] - select Fallback Layer API with forced compute fallback path.
  • [-DXR] - select DirectX Raytracing API.

Additional arguments:

  • [-forceAdapter <ID>] - create a D3D12 device on an adapter . Defaults to adapter 0.

UI

The title bar of the sample provides runtime information:

  • Name of the sample
  • Raytracing API being active:
    • FL - Fallback Layer with compute fallback being used
    • FL-DXR - Fallback Layer with raytracing driver being used
    • DXR - DirectX Raytracing being used
  • Frames per second
  • Million Primary Rays/s: a number of dispatched rays per second calculated based of FPS.
  • GPU[ID]: name

Controls

  • ALT+ENTER - toggles between windowed and fullscreen modes.
  • 1 - select Fallback Layer API.
  • 2 - select Fallback Layer API with forced compute fallback path.
  • 3 - select DirectX Raytracing API.

Requirements