Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[glTF] Support accessors with UNSIGNED_BYTE 5121 componentType #453

Open
footballhead opened this issue Apr 12, 2024 · 1 comment · May be fixed by #482
Open

[glTF] Support accessors with UNSIGNED_BYTE 5121 componentType #453

footballhead opened this issue Apr 12, 2024 · 1 comment · May be fixed by #482
Assignees
Labels
enhancement New feature or request

Comments

@footballhead
Copy link
Collaborator

footballhead commented Apr 12, 2024

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 footballhead added the enhancement New feature or request label Apr 12, 2024
@footballhead footballhead changed the title [glTF] Add support for accessors with UNSIGNED_BYTE componentType [glTF] Support accessors with UNSIGNED_BYTE componentType Apr 12, 2024
@footballhead footballhead changed the title [glTF] Support accessors with UNSIGNED_BYTE componentType [glTF] Support accessors with UNSIGNED_BYTE 5121 componentType May 31, 2024
@footballhead footballhead self-assigned this Jun 4, 2024
footballhead added a commit to footballhead/bigwheels that referenced this issue Jun 11, 2024
While glTF supports specifying indices in UINT8, Vulkan only supports
UINT16 and UINT32 index buffers (without extensions). If we detect a
UINT8 index buffer (componentType = 5121) then we repack it into the
next best thing: a UINT16 buffer. This increases the size of the indices
in the resulting repacked GPU buffer but allows us to support these
scenes without extensions.

This allows us to load more Khronos glTF-Sample-Assets like
TextureCoordinateTest.

Fixes google#453
footballhead added a commit to footballhead/bigwheels that referenced this issue Jun 11, 2024
Without extensions, Vulkan only supports UINT16 and UINT32 index
buffers. However, glTF allows UINT8 index buffers. We can support scenes
with UINT8 indices by repacking them into a UINT16 buffer instead. This
comes at the cost of a larger GPU buffer.

This allows us to load more Khronos glTF-Sample-Assets like
TextureCoordinateTest.

Fixes google#453
@footballhead footballhead linked a pull request Jun 11, 2024 that will close this issue
footballhead added a commit to footballhead/bigwheels that referenced this issue Jun 11, 2024
Without extensions, Vulkan only supports UINT16 and UINT32 index
buffers. However, glTF allows UINT8 index buffers. We can support scenes
with UINT8 indices by repacking them into a UINT16 buffer instead. This
comes at the cost of a larger GPU buffer.

This allows us to load more Khronos glTF-Sample-Assets like
TextureCoordinateTest.

Fixes google#453
@footballhead
Copy link
Collaborator Author

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.

Keenuts pushed a commit that referenced this issue Jul 3, 2024
For Vulkan, we must ask for the VK_EXT_index_type_uint8 device extension
and enable the indexTypeUint8 feature.

For DX12, the docs claim that there is no support:
https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-0-formats

This is required to load uint8 index buffers from glTF files more
efficiently. See #453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant