Skip to content

Commit

Permalink
Metal: add better logging for invalid index element size (#8194)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado authored Oct 22, 2024
1 parent edece8f commit eab8490
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion filament/backend/src/metal/MetalEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ constexpr inline MTLIndexType getIndexType(size_t elementSize) noexcept {
} else if (elementSize == 4) {
return MTLIndexTypeUInt32;
}
FILAMENT_CHECK_POSTCONDITION(false) << "Index element size not supported.";
assert_invariant(false);
return MTLIndexTypeUInt16;
}

constexpr inline MTLVertexFormat getMetalFormat(ElementType type, bool normalized) noexcept {
Expand Down
5 changes: 5 additions & 0 deletions filament/src/details/IndexBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ IndexBuffer* IndexBuffer::Builder::build(Engine& engine) {

FIndexBuffer::FIndexBuffer(FEngine& engine, const IndexBuffer::Builder& builder)
: mIndexCount(builder->mIndexCount) {
auto& name = builder.getName();
const char* const tag = name.empty() ? "(no tag)" : name.c_str_safe();
FILAMENT_CHECK_PRECONDITION(
builder->mIndexType == IndexType::UINT || builder->mIndexType == IndexType::USHORT)
<< "Invalid index type " << static_cast<int>(builder->mIndexType) << ", tag=" << tag;
FEngine::DriverApi& driver = engine.getDriverApi();
mHandle = driver.createIndexBuffer(
(backend::ElementType)builder->mIndexType,
Expand Down

0 comments on commit eab8490

Please sign in to comment.