Skip to content

Radient: zero-sized vertex-pool elements for sparse buffer slots #263

Description

@TheMostDiligent

RadientMeshAssetManager.cpp creates an element for every slot up to GetVertexBufferCount():

for (Uint32 BufferIndex = 0; BufferIndex < VertexBufferCount; ++BufferIndex)
    LayoutKey.Elements.emplace_back(
        VertexSource.GetVertexStride(BufferIndex),
        BIND_VERTEX_BUFFER);

But the vertex source intentionally permits inactive gaps. Inactive buffers keep stride and data size zero.

This is not just an exotic custom-layout case. Diligent’s default layout uses:

Buffer 0: POSITION, NORMAL, TEXCOORD_0
Buffer 1: JOINTS_0, WEIGHTS_0
Buffer 2: TEXCOORD_1
Buffer 3: COLOR_0
Buffer 4: TANGENT

Therefore, an ordinary static mesh containing POSITION + COLOR_0 produces logical slots:

{nonzero, 0, 0, nonzero}

Likewise, POSITION + TEXCOORD_1 produces:

{nonzero, 0, nonzero}

The default slot assignment is visible in Diligent’s official DefaultVertexAttributes.

A zero element size is invalid for VertexPool. Its allocation path computes buffer capacity by dividing a buffer size by m_Elements[i].Size, so a zero-sized element can become a release-build division by zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions