TECHNOLOGY

Vulkan triangle builds: keep byte strides, index offsets and maxVertex consistent

In this article
THE QUICK TAKE

The acceleration builder reads the declared buffer view; a mesh that renders correctly through a graphics vertex layout can still have a different or invalid build description.

Compare the two consumers of a mesh

A mesh can render correctly through a graphics pipeline while its ray-tracing acceleration build reads the wrong positions. The two paths consume buffer descriptions through different API structures. Check how the builder locates each position rather than assuming it inherits the graphics vertex input. This matters for interleaved assets whose records contain normals, texture coordinates or application attributes between positions and the next vertex.

Declare the actual byte stride and format

The triangle input reference defines vertexStride in bytes and requires a supported vertex format. A stride measured in scalar components is not interchangeable with a byte count. Include record padding when describing interleaved data, and point to the intended position field. Validate the source format against acceleration-build support rather than inferring it from the fact that another graphics stage can read the same allocation.

Resolve indexed range offsets deliberately

The build-range reference distinguishes primitive count, byte offsets and a starting vertex index. For indexed triangles, the starting vertex is added to fetched index values; for non-indexed triangles, the builder consumes vertices from the corresponding vertex-data range. Preserve these units in the importer and submesh description. Treating a byte offset as an element offset can still produce in-bounds memory accesses while selecting unrelated geometry, making the resulting image unusually hard to diagnose.

Set maxVertex from the reachable vertex range

The triangle reference defines maxVertex using a vertex count minus one, and the range contract constrains it against the effective referenced vertices. Do not substitute triangle count or index count. Account for the starting vertex and the actual selected index range. The build-command reference supplies the enclosing geometry and range-array contract. Keep each geometry description paired with its intended build range instead of independently reordering arrays during batching.

Check an asymmetric indexed submesh

Use a mesh with clearly different submeshes and interleaved attributes, then compare ray hits with a trusted geometric reference. Exercise a nonzero submesh offset and a changed starting vertex. The guides to GPU BVH traversal and renderer compatibility provide related context. Accept the importer only when its declared units and ranges explain the geometry actually built; correct graphics display and a successful allocation do not establish a correct acceleration input view.

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.

Explore GPU hosting
← All articles