Skip to content

Commit

Permalink
WebGL 2: Add workaround for new Safari bug that breaks noclip
Browse files Browse the repository at this point in the history
Also remove workaround for EXT_clip_control now that Chrome has fixed its issues.
  • Loading branch information
magcius committed Oct 12, 2024
1 parent 2a8fbb9 commit a5d9025
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/gfx/platform/GfxPlatformWebGL2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ class GfxImplP_GL implements GfxSwapChain, GfxDevice {

// GfxLimits
private _uniformBufferMaxPageByteSize: number;
private _invalidateFramebufferBroken: boolean = false;
public uniformBufferWordAlignment: number;
public uniformBufferMaxPageWordSize: number;
public supportedSampleCounts: number[];
Expand All @@ -503,9 +504,7 @@ class GfxImplP_GL implements GfxSwapChain, GfxDevice {

this._WEBGL_compressed_texture_s3tc = gl.getExtension('WEBGL_compressed_texture_s3tc');
this._WEBGL_compressed_texture_s3tc_srgb = gl.getExtension('WEBGL_compressed_texture_s3tc_srgb');
// https://github.com/magcius/noclip.website/issues/683
// https://issues.chromium.org/issues/347197920
// this._EXT_clip_control = gl.getExtension('EXT_clip_control');
this._EXT_clip_control = gl.getExtension('EXT_clip_control');
this._EXT_texture_compression_rgtc = gl.getExtension('EXT_texture_compression_rgtc');
this._EXT_texture_filter_anisotropic = gl.getExtension('EXT_texture_filter_anisotropic');
this._EXT_texture_norm16 = gl.getExtension('EXT_texture_norm16');
Expand Down Expand Up @@ -605,12 +604,22 @@ class GfxImplP_GL implements GfxSwapChain, GfxDevice {
}

private _checkForBugQuirks(): void {
const gl = this.gl;

if (navigator.userAgent.includes('Firefox')) {
// TODO(jstpierre): File Bugzilla bug, check Firefox version.
// getQueryParameter on Firefox causes a full GL command buffer sync
// (verified with private correspondence with Kelsey Gilbert).
this.occlusionQueriesRecommended = false;
}

const WEBGL_debug_renderer_info = gl.getExtension('WEBGL_debug_renderer_info');
if (WEBGL_debug_renderer_info !== null) {
const vendor = gl.getParameter(WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL);
// https://bugs.webkit.org/show_bug.cgi?id=280799
if (vendor === "Apple Inc.")
this._invalidateFramebufferBroken = true;
}
}

//#region GfxSwapChain
Expand Down Expand Up @@ -2392,7 +2401,7 @@ class GfxImplP_GL implements GfxSwapChain, GfxDevice {
gl.blitFramebuffer(0, 0, colorResolveFrom.width, colorResolveFrom.height, 0, 0, colorResolveTo.width, colorResolveTo.height, gl.COLOR_BUFFER_BIT, gl.LINEAR);
}

if (!colorStore)
if (!colorStore && !this._invalidateFramebufferBroken)
gl.invalidateFramebuffer(gl.READ_FRAMEBUFFER, [gl.COLOR_ATTACHMENT0]);

if (boundReadFB)
Expand Down Expand Up @@ -2426,7 +2435,7 @@ class GfxImplP_GL implements GfxSwapChain, GfxDevice {
gl.blitFramebuffer(0, 0, depthStencilResolveFrom.width, depthStencilResolveFrom.height, 0, 0, depthStencilResolveTo.width, depthStencilResolveTo.height, gl.DEPTH_BUFFER_BIT, gl.NEAREST);
}

if (!depthStencilStore)
if (!depthStencilStore && !this._invalidateFramebufferBroken)
gl.invalidateFramebuffer(gl.READ_FRAMEBUFFER, [gl.DEPTH_STENCIL_ATTACHMENT]);

if (boundReadFB)
Expand Down

0 comments on commit a5d9025

Please sign in to comment.