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

Remove support for OES_element_index_uint on WebGL1 #6320

Merged
merged 1 commit into from
Apr 30, 2024
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
18 changes: 1 addition & 17 deletions src/framework/parsers/glb-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,24 +809,8 @@ const createMesh = (device, gltfMesh, accessors, bufferViews, flipV, vertexBuffe
indexFormat = INDEXFORMAT_UINT32;
}

// 32bit index buffer is used but not supported
if (indexFormat === INDEXFORMAT_UINT32 && !device.extUintElement) {

// #if _DEBUG
if (vertexBuffer.numVertices > 0xFFFF) {
console.warn('Glb file contains 32bit index buffer but these are not supported by this device - it may be rendered incorrectly.');
}
// #endif

// convert to 16bit
indexFormat = INDEXFORMAT_UINT16;
indices = new Uint16Array(indices);
}

if (indexFormat === INDEXFORMAT_UINT8 && device.isWebGPU) {
Debug.warn('Glb file contains 8bit index buffer but these are not supported by WebGPU - converting to 16bit.');

// convert to 16bit
// silently convert to 16bit
indexFormat = INDEXFORMAT_UINT16;
indices = new Uint16Array(indices);
}
Expand Down
2 changes: 1 addition & 1 deletion src/framework/parsers/json-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class JsonModelParser {
maxVerts = Math.max(maxVerts, vertexBuffers[i].numVertices);
}
if (numIndices > 0) {
if (maxVerts > 0xFFFF && this._device.extUintElement) {
if (maxVerts > 0xFFFF) {
indexBuffer = new IndexBuffer(this._device, INDEXFORMAT_UINT32, numIndices);
indexData = new Uint32Array(indexBuffer.lock());
} else {
Expand Down
1 change: 0 additions & 1 deletion src/platform/graphics/null/null-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class NullGraphicsDevice extends GraphicsDevice {
this.supportsAreaLights = true;
this.supportsGpuParticles = false;
this.supportsMrt = true;
this.extUintElement = true;
this.extTextureFloat = true;
this.textureFloatRenderable = true;
this.extTextureHalfFloat = true;
Expand Down
5 changes: 2 additions & 3 deletions src/platform/graphics/webgl/webgl-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,8 @@ class WebglGraphicsDevice extends GraphicsDevice {
this.supportedExtensions = gl.getSupportedExtensions() ?? [];
this._extDisjointTimerQuery = null;

this.textureRG11B10Renderable = true;

if (this.isWebGL2) {
this.extBlendMinmax = true;
this.extDrawBuffers = true;
Expand All @@ -953,18 +955,15 @@ class WebglGraphicsDevice extends GraphicsDevice {
this.extTextureHalfFloat = true;
this.textureHalfFloatFilterable = true;
this.extTextureLod = true;
this.extUintElement = true;
this.extColorBufferFloat = this.getExtension('EXT_color_buffer_float');
this.extDepthTexture = true;
this.textureRG11B10Renderable = true;
} else {
this.extBlendMinmax = this.getExtension("EXT_blend_minmax");
this.extDrawBuffers = this.getExtension('WEBGL_draw_buffers');
this.drawBuffers = this.extDrawBuffers?.drawBuffersWEBGL.bind(this.extDrawBuffers);

this.extTextureFloat = this.getExtension("OES_texture_float");
this.extTextureLod = this.getExtension('EXT_shader_texture_lod');
this.extUintElement = this.getExtension("OES_element_index_uint");
this.extColorBufferFloat = null;
this.extDepthTexture = gl.getExtension('WEBGL_depth_texture');

Expand Down
1 change: 0 additions & 1 deletion src/platform/graphics/webgpu/webgpu-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
this.supportsGpuParticles = true;
this.supportsMrt = true;
this.supportsCompute = true;
this.extUintElement = true;
this.extTextureFloat = true;
this.textureFloatRenderable = true;
this.textureHalfFloatFilterable = true;
Expand Down
4 changes: 2 additions & 2 deletions src/scene/batching/batch-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ class BatchManager {
const halfMaxAabbSize = maxAabbSize * 0.5;
const maxInstanceCount = this.device.supportsBoneTextures ? 1024 : this.device.boneLimit;

// maximum number of vertices that can be used in batch depends on 32bit index buffer support (do this for non-indexed as well,
// maximum number of vertices that can be used in batch (do this for non-indexed as well,
// as in some cases (UI elements) non-indexed geometry gets batched into indexed)
const maxNumVertices = this.device.extUintElement ? 0xffffffff : 0xffff;
const maxNumVertices = 0xffffffff;

const aabb = new BoundingBox();
const testAabb = new BoundingBox();
Expand Down