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

BatchedMesh: Add fallback for when the multi draw extension is not supported #27178

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
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: 14 additions & 9 deletions src/renderers/webgl/WebGLBufferRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,26 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
const extension = extensions.get( 'WEBGL_multi_draw' );
if ( extension === null ) {

console.error( 'THREE.WebGLBufferRenderer: using THREE.BatchedMesh but hardware does not support extension WEBGL_multi_draw.' );
return;
for ( let i = 0; i < drawCount; i ++ ) {

}
this.render( starts[ i ], counts[ i ] );

extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
}

let elementCount = 0;
for ( let i = 0; i < drawCount; i ++ ) {
} else {

elementCount += counts[ i ];
extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );

}
let elementCount = 0;
for ( let i = 0; i < drawCount; i ++ ) {

elementCount += counts[ i ];

info.update( elementCount, mode, 1 );
}

info.update( elementCount, mode, 1 );

}

}

Expand Down
23 changes: 14 additions & 9 deletions src/renderers/webgl/WebGLIndexedBufferRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,26 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
const extension = extensions.get( 'WEBGL_multi_draw' );
if ( extension === null ) {

console.error( 'THREE.WebGLBufferRenderer: using THREE.BatchedMesh but hardware does not support extension WEBGL_multi_draw.' );
return;
for ( let i = 0; i < drawCount; i ++ ) {

}
this.render( starts[ i ] / bytesPerElement, counts[ i ] );

extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
}

let elementCount = 0;
for ( let i = 0; i < drawCount; i ++ ) {
} else {

elementCount += counts[ i ];
extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );

}
let elementCount = 0;
for ( let i = 0; i < drawCount; i ++ ) {

elementCount += counts[ i ];

info.update( elementCount, mode, 1 );
}

info.update( elementCount, mode, 1 );

}

}

Expand Down