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

WebGPUAttributeUtils: Fix i16a/u16a patch #30264

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/renderers/webgpu/utils/WebGPUAttributeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,27 @@ class WebGPUAttributeUtils {
let array = bufferAttribute.array;

// patch for INT16 and UINT16
if ( attribute.normalized === false && ( array.constructor === Int16Array || array.constructor === Uint16Array ) ) {
if ( attribute.normalized === false ) {

const tempArray = new Uint32Array( array.length );
for ( let i = 0; i < array.length; i ++ ) {
if ( array.constructor === Int16Array ) {

tempArray[ i ] = array[ i ];
array = new Int32Array( array );

}
} else if ( array.constructor === Uint16Array ) {

array = new Uint32Array( array );

if ( usage & GPUBufferUsage.INDEX ) {

for ( let i = 0; i < array.length; i ++ ) {

array = tempArray;
if ( array[ i ] === 0xffff ) array[ i ] = 0xffffffff; // use correct primitive restart index

}

}

}

}

Expand Down
Loading