Compute correct Vulkan ray tracing SBT strides from device properties and shader record sizes, then emit machine-checkable output. Use when debugging SBT alignment/stride errors or generating stride values for raygen/miss/hit/callable regions.
vkCmdTraceRaysKHR SBT setup.Extract required limits from device properties
shaderGroupHandleSizeshaderGroupHandleAlignmentshaderGroupBaseAlignmentmaxShaderGroupStrideExtract per-record payload sizes from shader config
raygen, miss, hit, callable, get extra shader record bytes.rawSize = shaderGroupHandleSize + recordDataSize.Apply the correct alignment rule per region
align_up(x, a) = ((x + a - 1) / a) * a.raygen_stride = align_up(raw_raygen, shaderGroupBaseAlignment)miss_stride = align_up(raw_miss, shaderGroupHandleAlignment)hit_stride = align_up(raw_hit, shaderGroupHandleAlignment)callable_stride = align_up(raw_callable, shaderGroupHandleAlignment)Enforce hard validity checks
>= shaderGroupHandleSize.<= maxShaderGroupStride.Emit output in required schema
{
"raygen_stride": <int>,
"miss_stride": <int>,
"hit_stride": <int>,
"callable_stride": <int>
}
Aligning raygen stride to handle alignment instead of base alignment.
Raygen uses stricter base-alignment requirements in typical Vulkan RT setups.
Ignoring shader record payload bytes.
Stride must fit handle + record data, not just handle size.
Computing valid strides but forgetting max stride constraint.
Always compare to maxShaderGroupStride.
Fixing only stride math while leaving region sizing/offset logic inconsistent.
Region size and offsets must stay consistent with computed stride and group counts.
Numerical verification (must pass before any tests)
>= handle size<= maxShaderGroupStrideSchema verification
Harness sanity check (important from observed runs)
IndexError while parsing properties text), inspect test parsing logic before changing stride math.VkStridedDeviceAddressRegionKHR alignment/stride constraints.align_up and SBT layout validation assertions.