Skip to content

Commit

Permalink
Transparency+shadows workaround for Galaxy Note 8 (#3234)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3f49d34)
  • Loading branch information
pmconne authored and mergify-bot committed Feb 18, 2022
1 parent 7a7e7e2 commit 036f841
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/webgl-compatibility",
"comment": "Apply workaround for failure to render shadows and transparency on Mali-G71 MP20 (Samsung Galaxy Note 8).",
"type": "none"
}
],
"packageName": "@itwin/webgl-compatibility"
}
21 changes: 14 additions & 7 deletions core/webgl-compatibility/src/Capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,21 @@ export class Capabilities {
this._maxDrawBuffers = dbExt !== undefined ? gl.getParameter(dbExt.MAX_DRAW_BUFFERS_WEBGL) : 1;
}

const debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
const unmaskedRenderer = debugInfo !== null ? gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) : undefined;
const unmaskedVendor = debugInfo !== null ? gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL) : undefined;

// Determine the maximum color-renderable attachment type.
// Note: iOS>=15 allows full-float rendering. However, it does not actually work on non-M1 devices. Because of this, for now we disallow full float rendering on iOS devices.
// ###TODO: Re-assess this after future iOS updates.
const allowFloatRender = (undefined === disabledExtensions || -1 === disabledExtensions.indexOf("OES_texture_float")) && !ProcessDetector.isIOSBrowser;
const allowFloatRender =
(undefined === disabledExtensions || -1 === disabledExtensions.indexOf("OES_texture_float"))
// iOS>=15 allows full-float rendering. However, it does not actually work on non-M1 devices.
// Because of this, for now we disallow full float rendering on iOS devices.
// ###TODO: Re-assess this after future iOS updates.
&& !ProcessDetector.isIOSBrowser
// Samsung Galaxy Note 8 exhibits same issue as described above for iOS >= 15.
// It uses specifically Mali-G71 MP20 but reports its renderer as follows.
&& unmaskedRenderer !== "Mali-G71";

if (allowFloatRender && undefined !== this.queryExtensionObject("EXT_float_blend") && this.isTextureRenderable(gl, gl.FLOAT)) {
this._maxRenderType = RenderType.TextureFloat;
} else if (this.isWebGL2) {
Expand All @@ -287,10 +298,6 @@ export class Capabilities {
const missingRequiredFeatures = this._findMissingFeatures(Capabilities.requiredFeatures);
const missingOptionalFeatures = this._findMissingFeatures(Capabilities.optionalFeatures);

const debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
const unmaskedRenderer = debugInfo !== null ? gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) : undefined;
const unmaskedVendor = debugInfo !== null ? gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL) : undefined;

this._driverBugs = {};
if (unmaskedRenderer && buggyIntelMatchers.some((x) => x.test(unmaskedRenderer)))
this._driverBugs.fragDepthDoesNotDisableEarlyZ = true;
Expand Down

0 comments on commit 036f841

Please sign in to comment.