Skip to content

Commit 3212be4

Browse files
ycwMugen87
andauthored
WebGPUAttributeUtils: Fix i16a/u16a patch (#30264)
* fix * Update WebGPUAttributeUtils.js Add comment. --------- Co-authored-by: Michael Herzog <[email protected]>
1 parent eb84f92 commit 3212be4

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/renderers/webgpu/utils/WebGPUAttributeUtils.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,27 @@ class WebGPUAttributeUtils {
6969
let array = bufferAttribute.array;
7070

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

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

77-
tempArray[ i ] = array[ i ];
76+
array = new Int32Array( array );
7877

79-
}
78+
} else if ( array.constructor === Uint16Array ) {
79+
80+
array = new Uint32Array( array );
81+
82+
if ( usage & GPUBufferUsage.INDEX ) {
83+
84+
for ( let i = 0; i < array.length; i ++ ) {
8085

81-
array = tempArray;
86+
if ( array[ i ] === 0xffff ) array[ i ] = 0xffffffff; // use correct primitive restart index
87+
88+
}
89+
90+
}
91+
92+
}
8293

8394
}
8495

0 commit comments

Comments
 (0)