In this article
A shader record combines an opaque program header with application data; both the record layout and table addressing must match the API contract.
Separate program selection from application data
An OptiX shader binding table connects a launch’s shader programs with their associated resources. A record is not simply an arbitrary material struct copied to device memory. It includes a program header and an application-defined data region. Keep these roles separate when designing a renderer’s material binding, since an error in record layout can look like a shading or geometry bug even though the selected shader receives the wrong data.
Construct headers through the API
The host API declarations provide the record-header packing operation for a program group. Use the supported packing mechanism instead of inventing or copying opaque header bytes from an unrelated pipeline configuration. Preserve which program group each record belongs to. Rebuilding shader programs can require rebuilding associated records even if the application’s material values and array dimensions remain unchanged between launches.
Validate both base and stride alignment
The type declarations specify record-header size, record alignment and shader-table fields. Alignment applies to relevant base addresses and strides, not only to the first host allocation. Use the SDK constants and inspect the actual compiled struct layout, including padding introduced by application fields. A correctly aligned buffer base cannot compensate for a record stride that places later records at invalid addresses or does not match the table descriptor.
Match the device’s data interpretation
The device API describes the pointer returned for the active record’s data region, past the header. Match its interpretation to the exact host-side data layout. Keep pointer fields valid for the relevant device and launch lifetime, and distinguish record addressing from application object identity. A material index in scene data needs an explicit mapping to the record chosen by traversal; similar integer values do not establish that relationship.
Diagnose with distinguishable records
Create a small scene where each shader record produces an unmistakable diagnostic result and carries easily checked data. Exercise multiple records rather than only the first one. The guides to GPU BVH traversal and renderer compatibility describe neighboring concerns. Validate header association, stride, count and data offsets before debugging complex lighting, allowing a binding-table error to be isolated from the renderer’s actual material or transport computation.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.