Skip to content

Meshletize - checklist vector<bool> subscript out of range #235

@vivi168

Description

@vivi168

For some mesh, the checklist vector is not properly sized, thus we get Expression: vector<bool> subscript out of range originating at this line:

if (checklist[adj[i] - startIndex])

In my case, we are short of just one index, (adj[i] - startIndex) == checklist.size()

So as a quick workaround I added +1 to the resize at L261

checklist.resize(subset.second + 1);

I can reproduce this error with BrainStem.gltf available here

After loading the GLTF file in a struct like this:

struct Mesh {
  std::vector<UINT> indices;
  std::vector<Primitive> primitives;

  std::vector<XMFLOAT3> positions;
  std::vector<XMFLOAT3> normals;
  std::vector<XMFLOAT2> uvs;
}

I'm using ComputeMeshlets with subsets.

std::vector<MeshletSubset> subsets;
subsets.reserve(primitives.size());

for (const auto& prim : primitives) {
  subsets.emplace_back(prim.start / 3, prim.count / 3);
}

std::vector<MeshletSubset> meshletSubsets(primitives.size());

constexpr size_t maxPrims = 126;
constexpr size_t maxVerts = 64;
CHECK_HR(ComputeMeshlets(
    indices.data(), indices.size() / 3,
    positions.data(), positions.size(),
    subsets.data(), subsets.size(),
    nullptr,
    meshlets, uniqueVertexIndices, primitiveIndices,
    meshletSubsets.data(),
    maxVerts, maxPrims));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions