google / bigwheels

BigWheels is a cross-platform, API agnostic framework to build graphics applications.
Apache License 2.0
94 stars 35 forks source link

[glTF] Support accessors with UNSIGNED_BYTE 5121 componentType #453

Open footballhead opened 6 months ago

footballhead commented 6 months ago

Using scene::GltfLoader, some models in glTF-Sample-Assets fail to load because they use index buffers with unsigned byte components (componentType=5121).

Refer to 5.24.2:

When defined, the accessor MUST have SCALAR type and an unsigned integer component type.

Filtering 5.1.3 for that criteria leaves 5121 UNSIGNED_BYTE (unimplemented), 5123 UNSIGNED_SHORT (implemented), and 5125 UNSIGNED_INT (implemented)

This would allow BigWheels to load more models like:

footballhead commented 4 months ago

For Vulkan we can use VK_EXT_index_type_uint8 to load these buffers 1:1. gpuinfo.org claims 62% support.

For DX12, docs claim that DXGI_FORMAT_R8_UINT is "Disallowed or not available." for Input Assembler Index Buffer. Only DXGI_FORMAT_R16_UINT and DXGI_FORMAT_R32_UINT are labelled as "Hardware support is required." https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-0-formats

As a fallback (either the Vulkan extension is not support, or we're on DX12), we can load the data into new 16bit index buffers instead and take a 2x memory hit.