@itwin/webgl-compatibility 4.10.0-dev.8 → 5.0.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
# Change Log - @itwin/webgl-compatibility
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 22 Oct 2024 20:03:09 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.9.5
|
|
6
|
+
Tue, 22 Oct 2024 20:01:40 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 4.9.4
|
|
11
|
+
Wed, 09 Oct 2024 20:22:04 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 4.9.3
|
|
16
|
+
Thu, 03 Oct 2024 19:15:45 GMT
|
|
17
|
+
|
|
18
|
+
_Version update only_
|
|
19
|
+
|
|
20
|
+
## 4.9.2
|
|
21
|
+
Wed, 02 Oct 2024 15:14:43 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
4
24
|
|
|
5
25
|
## 4.9.1
|
|
6
26
|
Wed, 25 Sep 2024 20:10:58 GMT
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* @module Compatibility
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.WebGLRenderCompatibilityStatus = exports.WebGLFeature = void 0;
|
|
11
|
+
exports.queryRenderCompatibility = queryRenderCompatibility;
|
|
11
12
|
const Capabilities_1 = require("./Capabilities");
|
|
12
13
|
/** Enumerates the required and optional WebGL features used by the [RenderSystem]($frontend).
|
|
13
14
|
* @public
|
|
@@ -115,5 +116,4 @@ function queryRenderCompatibility(useWebGL2, createContext) {
|
|
|
115
116
|
compatibility.status = WebGLRenderCompatibilityStatus.MajorPerformanceCaveat;
|
|
116
117
|
return compatibility;
|
|
117
118
|
}
|
|
118
|
-
exports.queryRenderCompatibility = queryRenderCompatibility;
|
|
119
119
|
//# sourceMappingURL=RenderCompatibility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderCompatibility.js","sourceRoot":"","sources":["../../src/RenderCompatibility.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iDAA8C;AAO9C;;GAEG;AACH,IAAY,YAuBX;AAvBD,WAAY,YAAY;IACtB,2GAA2G;IAC3G,oDAAoC,CAAA;IACpC,wFAAwF;IACxF,oCAAoB,CAAA;IACpB,2FAA2F;IAC3F,uDAAuC,CAAA;IACvC,2JAA2J;IAC3J,kDAAkC,CAAA;IAClC,2FAA2F;IAC3F,8CAA8B,CAAA;IAC9B,gGAAgG;IAChG,yCAAyB,CAAA;IACzB,iHAAiH;IACjH,6DAA6C,CAAA;IAC7C,mGAAmG;IACnG,0CAA0B,CAAA;IAC1B,qIAAqI;IACrI,4CAA4B,CAAA;IAC5B,sIAAsI;IACtI,4DAA4C,CAAA;IAC5C,+DAA+D;IAC/D,8CAA8B,CAAA;AAChC,CAAC,EAvBW,YAAY,4BAAZ,YAAY,QAuBvB;AAED;;GAEG;AACH,IAAY,8BA4BX;AA5BD,WAAY,8BAA8B;IACxC;;;OAGG;IACH,yFAAO,CAAA;IACP;;;OAGG;IACH,yHAAuB,CAAA;IACvB;;;;;OAKG;IACH,uHAAsB,CAAA;IACtB;;;OAGG;IACH,yHAAuB,CAAA;IACvB;;;OAGG;IACH,iHAAmB,CAAA;AACrB,CAAC,EA5BW,8BAA8B,8CAA9B,8BAA8B,QA4BzC;AA2DD,SAAS,oBAAoB,CAAC,MAAyB,EAAE,YAAqB,IAAI,EAAE,UAAmC;IACrH,IAAI,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC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EAAE;gBAC3B,uBAAuB,EAAE,EAAE;gBAC3B,SAAS,EAAE,SAAS,CAAC,SAAS;gBAC9B,mBAAmB,EAAE,YAAY;gBACjC,UAAU,EAAE,EAAE;aACf,CAAC;IACN,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,2BAAY,EAAE,CAAC;IACxC,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC5D,aAAa,CAAC,mBAAmB,GAAG,YAAY,CAAC;IAEjD,IAAI,yBAAyB,IAAI,aAAa,CAAC,MAAM,KAAK,8BAA8B,CAAC,uBAAuB;QAC9G,aAAa,CAAC,MAAM,GAAG,8BAA8B,CAAC,sBAAsB,CAAC;IAE/E,OAAO,aAAa,CAAC;AACvB,CAAC;AArCD,4DAqCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Compatibility\r\n */\r\n\r\nimport { Capabilities } from \"./Capabilities\";\r\n\r\n/** A type describing either a WebGL 1 or WebGL 2 rendering context.\r\n * @public\r\n */\r\nexport type WebGLContext = WebGLRenderingContext | WebGL2RenderingContext;\r\n\r\n/** Enumerates the required and optional WebGL features used by the [RenderSystem]($frontend).\r\n * @public\r\n */\r\nexport enum WebGLFeature {\r\n /** This feature allows transparent geometry to be rendered more efficiently, using 1 pass instead of 2. */\r\n MrtTransparency = \"mrt transparency\",\r\n /** This feature allows picking to occur more efficiently, using 1 pass instead of 3. */\r\n MrtPick = \"mrt pick\",\r\n /** This feature ensures large meshes (with more than 21,845 triangles) can be rendered. */\r\n UintElementIndex = \"uint element index\",\r\n /** This feature allows transparency to achieve the optimal quality. Without this feature, overlapping transparent geometry will \"wash out\" more easily. */\r\n FloatRendering = \"float rendering\",\r\n /** This feature allows for the display of non-3D classification data and solar shadows. */\r\n DepthTexture = \"depth texture\",\r\n /** This feature allows instancing of repeated geometry, which can reduce memory consumption. */\r\n Instancing = \"instancing\",\r\n /** This feature indicates that the system has enough texture units available for the shaders to run properly. */\r\n MinimalTextureUnits = \"minimal texture units\",\r\n /** Indicates that shadow maps are supported. Without this feature, shadows cannot be displayed. */\r\n ShadowMaps = \"shadow maps\",\r\n /** This feature allows a logarithmic depth buffer to be used. Without this feature, z-fighting will be much more likely to occur. */\r\n FragDepth = \"fragment depth\",\r\n /** This feature allows the renderer to achieve accurate contour lines for isoline and stepped delimiter modes of thematic display. */\r\n StandardDerivatives = \"standard derivatives\",\r\n /** This feature allows the renderer to smooth curved lines. */\r\n AntiAliasing = \"anti-aliasing\",\r\n}\r\n\r\n/** An enumeration that describes a general \"compatibility rating\" based on the contents of a [[WebGLRenderCompatibilityInfo]].\r\n * @public\r\n */\r\nexport enum WebGLRenderCompatibilityStatus {\r\n /**\r\n * Signifies that everything is ideal: context created successfully, all required and optional features are available,\r\n * and browser did not signal a major performance caveat.\r\n */\r\n AllOkay,\r\n /**\r\n * Signifies that the base requirements of compatibility are met but at least some optional features are missing.\r\n * Consult the contents of [[WebGLRenderCompatibilityInfo.missingOptionalFeatures]].\r\n */\r\n MissingOptionalFeatures,\r\n /**\r\n * Signifies that the base requirements of compatibility are met but WebGL reported a major performance caveat. The browser\r\n * has likely fallen back to software rendering due to lack of a usable GPU.\r\n * Consult [[WebGLRenderCompatibilityInfo.contextErrorMessage]] for a possible description of what went wrong.\r\n * There could also be some missing optional features; consult the contents of [[WebGLRenderCompatibilityInfo.missingOptionalFeatures]].\r\n */\r\n MajorPerformanceCaveat,\r\n /**\r\n * Signifies that the base requirements of compatibility are not met; rendering cannot occur.\r\n * Consult the contents of [[WebGLRenderCompatibilityInfo.missingRequiredFeatures]].\r\n */\r\n MissingRequiredFeatures,\r\n /**\r\n * Signifies an inability to create either a canvas or a WebGL rendering context; rendering cannot occur. Consult\r\n * [[WebGLRenderCompatibilityInfo.contextErrorMessage]] for a possible description of what went wrong.\r\n */\r\n CannotCreateContext,\r\n}\r\n\r\n/** Known bugs associated with specific graphics drivers for which iTwin.js can apply workarounds to produce correct visualization.\r\n * An instance of this object will exist on the [[WebGLRenderCompatibilityInfo]] object returned by [[queryRenderCompatibility]].\r\n * @see [[WebGLRenderCompatibilityInfo]]\r\n * @public\r\n */\r\nexport interface GraphicsDriverBugs {\r\n /** If true, the graphics driver inappropriately applies the \"early Z\" optimization when a fragment shader writes to the depth buffer.\r\n * Early Z elides execution of the fragment shader if the depth test fails; but if the fragment shader contains code that can alter the depth, it\r\n * must be executed. The primary symptom of this bug is transparent geometry appearing to be behind opaque geometry despite actually being in front of it.\r\n *\r\n * Affects Intel HD/UHD Graphics 620/630.\r\n *\r\n * The workaround for this bug has minimal impact on performance and no impact on visual fidelity.\r\n */\r\n fragDepthDoesNotDisableEarlyZ?: true;\r\n /** If true, the graphics driver will hang when applying MSAA to a viewport.\r\n *\r\n * Known to affect certain mobile Mali chipsets (G71 and G76). May affect more.\r\n *\r\n * The workaround for this bug means MSAA cannot be enabled on those devices.\r\n */\r\n msaaWillHang?: true;\r\n}\r\n\r\n/** Describes the level of compatibility of a client device/browser with the iTwin.js rendering system.\r\n * @public\r\n */\r\nexport interface WebGLRenderCompatibilityInfo {\r\n /** Describes the overall status of rendering compatibility. */\r\n status: WebGLRenderCompatibilityStatus;\r\n /** Features that are required by the rendering system but not supported by the client. */\r\n missingRequiredFeatures: WebGLFeature[];\r\n /** Optional features unsupported by this client that would provide improved performance or quality if present. */\r\n missingOptionalFeatures: WebGLFeature[];\r\n /** Known bugs associated with the client's graphics driver for which iTwin.js can apply workarounds. */\r\n driverBugs: GraphicsDriverBugs;\r\n /** The user agent as reported by the browser. */\r\n userAgent: string;\r\n /** The renderer string reported by this client's graphics driver. */\r\n unmaskedRenderer?: string;\r\n /** The vendor string reported by this client's graphics driver. */\r\n unmaskedVendor?: string;\r\n /** If true, there is a likelihood that integrated graphics are being used. This can be used to warn users on systems with both integrated graphics and dedicated graphics that they should try to switch to their dedicated graphics for better performance.\r\n * @note This property has the possibility of providing false positives and negatives. A user should use this property mainly as a hint and manually verify what graphics chip is being used.\r\n */\r\n usingIntegratedGraphics?: boolean;\r\n /** If WebGL context creation failed, an error message supplied by the browser. */\r\n contextErrorMessage?: string;\r\n /** The WebGL context created by the browser and used to generate the compatibility report. */\r\n createdContext?: WebGLContext;\r\n}\r\n\r\n/** A function that creates and returns a WebGLContext given an HTMLCanvasElement, a boolean specifying whether to use WebGL2, and a WebGLContextAttributes object describing the desired context attributes.\r\n * @public\r\n */\r\nexport type ContextCreator = (canvas: HTMLCanvasElement, useWebGL2: boolean, inputContextAttributes?: WebGLContextAttributes) => WebGLContext | undefined;\r\n\r\nfunction createDefaultContext(canvas: HTMLCanvasElement, useWebGL2: boolean = true, attributes?: WebGLContextAttributes): WebGLContext | undefined {\r\n let context = useWebGL2 ? canvas.getContext(\"webgl2\", attributes) : canvas.getContext(\"webgl\", attributes);\r\n if (context === null && useWebGL2)\r\n context = canvas.getContext(\"webgl\", attributes);\r\n return context ?? undefined;\r\n}\r\n\r\n/** This function returns information about the client system's level of compatibility with the iTwin.js rendering system, describing the client system's support for both optional and required features. It will also report if there is a major issue with the client system such as the browser falling back to software rendering or an inability to create a either a canvas or a WebGL rendering context.\r\n * @param useWebGL2 A boolean which will be passed to the createContext function in order to create the desired type of context; set this to `true` to use WebGL2, `false` to use WebGL1.\r\n * @param createContext A function of type [[ContextCreator]] that returns a WebGLContext. If not specified, this by default uses `canvas.getContext()` to create the WebGLContext.\r\n * @returns A [[WebGLRenderCompatibilityInfo]] object which contains a compatibility summary.\r\n * @see [[WebGLRenderCompatibilityInfo]]\r\n * @public\r\n */\r\nexport function queryRenderCompatibility(useWebGL2: boolean, createContext?: ContextCreator): WebGLRenderCompatibilityInfo {\r\n const canvas = document.createElement(\"canvas\");\r\n if (null === canvas)\r\n return { status: WebGLRenderCompatibilityStatus.CannotCreateContext, missingOptionalFeatures: [], missingRequiredFeatures: [], userAgent: navigator.userAgent, driverBugs: { } };\r\n\r\n let errorMessage: string | undefined;\r\n canvas.addEventListener(\"webglcontextcreationerror\", (event) => {\r\n errorMessage = (event as WebGLContextEvent).statusMessage || \"webglcontextcreationerror was triggered with no error provided\";\r\n }, false);\r\n\r\n if (undefined === createContext)\r\n createContext = createDefaultContext;\r\n\r\n let hasMajorPerformanceCaveat = false;\r\n let context = createContext(canvas, useWebGL2, { failIfMajorPerformanceCaveat: true });\r\n if (undefined === context) {\r\n hasMajorPerformanceCaveat = true;\r\n context = createContext(canvas, useWebGL2); // try to create context without black-listed GPU\r\n if (undefined === context)\r\n return {\r\n status: WebGLRenderCompatibilityStatus.CannotCreateContext,\r\n missingOptionalFeatures: [],\r\n missingRequiredFeatures: [],\r\n userAgent: navigator.userAgent,\r\n contextErrorMessage: errorMessage,\r\n driverBugs: {},\r\n };\r\n }\r\n\r\n const capabilities = new Capabilities();\r\n const compatibility = capabilities.init(context, undefined);\r\n compatibility.contextErrorMessage = errorMessage;\r\n\r\n if (hasMajorPerformanceCaveat && compatibility.status !== WebGLRenderCompatibilityStatus.MissingRequiredFeatures)\r\n compatibility.status = WebGLRenderCompatibilityStatus.MajorPerformanceCaveat;\r\n\r\n return compatibility;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RenderCompatibility.js","sourceRoot":"","sources":["../../src/RenderCompatibility.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA6IH,4DAqCC;AAhLD,iDAA8C;AAO9C;;GAEG;AACH,IAAY,YAuBX;AAvBD,WAAY,YAAY;IACtB,2GAA2G;IAC3G,oDAAoC,CAAA;IACpC,wFAAwF;IACxF,oCAAoB,CAAA;IACpB,2FAA2F;IAC3F,uDAAuC,CAAA;IACvC,2JAA2J;IAC3J,kDAAkC,CAAA;IAClC,2FAA2F;IAC3F,8CAA8B,CAAA;IAC9B,gGAAgG;IAChG,yCAAyB,CAAA;IACzB,iHAAiH;IACjH,6DAA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I,YAAgC,CAAC;IACrC,MAAM,CAAC,gBAAgB,CAAC,2BAA2B,EAAE,CAAC,KAAK,EAAE,EAAE;QAC7D,YAAY,GAAI,KAA2B,CAAC,aAAa,IAAI,gEAAgE,CAAC;IAChI,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,IAAI,SAAS,KAAK,aAAa;QAC7B,aAAa,GAAG,oBAAoB,CAAC;IAEvC,IAAI,yBAAyB,GAAG,KAAK,CAAC;IACtC,IAAI,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,4BAA4B,EAAE,IAAI,EAAE,CAAC,CAAC;IACvF,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QAC1B,yBAAyB,GAAG,IAAI,CAAC;QACjC,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,iDAAiD;QAC7F,IAAI,SAAS,KAAK,OAAO;YACvB,OAAO;gBACL,MAAM,EAAE,8BAA8B,CAAC,mBAAmB;gBAC1D,uBAAuB,EAAE,EAAE;gBAC3B,uBAAuB,EAAE,EAAE;gBAC3B,SAAS,EAAE,SAAS,CAAC,SAAS;gBAC9B,mBAAmB,EAAE,YAAY;gBACjC,UAAU,EAAE,EAAE;aACf,CAAC;IACN,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,2BAAY,EAAE,CAAC;IACxC,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC5D,aAAa,CAAC,mBAAmB,GAAG,YAAY,CAAC;IAEjD,IAAI,yBAAyB,IAAI,aAAa,CAAC,MAAM,KAAK,8BAA8B,CAAC,uBAAuB;QAC9G,aAAa,CAAC,MAAM,GAAG,8BAA8B,CAAC,sBAAsB,CAAC;IAE/E,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Compatibility\r\n */\r\n\r\nimport { Capabilities } from \"./Capabilities\";\r\n\r\n/** A type describing either a WebGL 1 or WebGL 2 rendering context.\r\n * @public\r\n */\r\nexport type WebGLContext = WebGLRenderingContext | WebGL2RenderingContext;\r\n\r\n/** Enumerates the required and optional WebGL features used by the [RenderSystem]($frontend).\r\n * @public\r\n */\r\nexport enum WebGLFeature {\r\n /** This feature allows transparent geometry to be rendered more efficiently, using 1 pass instead of 2. */\r\n MrtTransparency = \"mrt transparency\",\r\n /** This feature allows picking to occur more efficiently, using 1 pass instead of 3. */\r\n MrtPick = \"mrt pick\",\r\n /** This feature ensures large meshes (with more than 21,845 triangles) can be rendered. */\r\n UintElementIndex = \"uint element index\",\r\n /** This feature allows transparency to achieve the optimal quality. Without this feature, overlapping transparent geometry will \"wash out\" more easily. */\r\n FloatRendering = \"float rendering\",\r\n /** This feature allows for the display of non-3D classification data and solar shadows. */\r\n DepthTexture = \"depth texture\",\r\n /** This feature allows instancing of repeated geometry, which can reduce memory consumption. */\r\n Instancing = \"instancing\",\r\n /** This feature indicates that the system has enough texture units available for the shaders to run properly. */\r\n MinimalTextureUnits = \"minimal texture units\",\r\n /** Indicates that shadow maps are supported. Without this feature, shadows cannot be displayed. */\r\n ShadowMaps = \"shadow maps\",\r\n /** This feature allows a logarithmic depth buffer to be used. Without this feature, z-fighting will be much more likely to occur. */\r\n FragDepth = \"fragment depth\",\r\n /** This feature allows the renderer to achieve accurate contour lines for isoline and stepped delimiter modes of thematic display. */\r\n StandardDerivatives = \"standard derivatives\",\r\n /** This feature allows the renderer to smooth curved lines. */\r\n AntiAliasing = \"anti-aliasing\",\r\n}\r\n\r\n/** An enumeration that describes a general \"compatibility rating\" based on the contents of a [[WebGLRenderCompatibilityInfo]].\r\n * @public\r\n */\r\nexport enum WebGLRenderCompatibilityStatus {\r\n /**\r\n * Signifies that everything is ideal: context created successfully, all required and optional features are available,\r\n * and browser did not signal a major performance caveat.\r\n */\r\n AllOkay,\r\n /**\r\n * Signifies that the base requirements of compatibility are met but at least some optional features are missing.\r\n * Consult the contents of [[WebGLRenderCompatibilityInfo.missingOptionalFeatures]].\r\n */\r\n MissingOptionalFeatures,\r\n /**\r\n * Signifies that the base requirements of compatibility are met but WebGL reported a major performance caveat. The browser\r\n * has likely fallen back to software rendering due to lack of a usable GPU.\r\n * Consult [[WebGLRenderCompatibilityInfo.contextErrorMessage]] for a possible description of what went wrong.\r\n * There could also be some missing optional features; consult the contents of [[WebGLRenderCompatibilityInfo.missingOptionalFeatures]].\r\n */\r\n MajorPerformanceCaveat,\r\n /**\r\n * Signifies that the base requirements of compatibility are not met; rendering cannot occur.\r\n * Consult the contents of [[WebGLRenderCompatibilityInfo.missingRequiredFeatures]].\r\n */\r\n MissingRequiredFeatures,\r\n /**\r\n * Signifies an inability to create either a canvas or a WebGL rendering context; rendering cannot occur. Consult\r\n * [[WebGLRenderCompatibilityInfo.contextErrorMessage]] for a possible description of what went wrong.\r\n */\r\n CannotCreateContext,\r\n}\r\n\r\n/** Known bugs associated with specific graphics drivers for which iTwin.js can apply workarounds to produce correct visualization.\r\n * An instance of this object will exist on the [[WebGLRenderCompatibilityInfo]] object returned by [[queryRenderCompatibility]].\r\n * @see [[WebGLRenderCompatibilityInfo]]\r\n * @public\r\n */\r\nexport interface GraphicsDriverBugs {\r\n /** If true, the graphics driver inappropriately applies the \"early Z\" optimization when a fragment shader writes to the depth buffer.\r\n * Early Z elides execution of the fragment shader if the depth test fails; but if the fragment shader contains code that can alter the depth, it\r\n * must be executed. The primary symptom of this bug is transparent geometry appearing to be behind opaque geometry despite actually being in front of it.\r\n *\r\n * Affects Intel HD/UHD Graphics 620/630.\r\n *\r\n * The workaround for this bug has minimal impact on performance and no impact on visual fidelity.\r\n */\r\n fragDepthDoesNotDisableEarlyZ?: true;\r\n /** If true, the graphics driver will hang when applying MSAA to a viewport.\r\n *\r\n * Known to affect certain mobile Mali chipsets (G71 and G76). May affect more.\r\n *\r\n * The workaround for this bug means MSAA cannot be enabled on those devices.\r\n */\r\n msaaWillHang?: true;\r\n}\r\n\r\n/** Describes the level of compatibility of a client device/browser with the iTwin.js rendering system.\r\n * @public\r\n */\r\nexport interface WebGLRenderCompatibilityInfo {\r\n /** Describes the overall status of rendering compatibility. */\r\n status: WebGLRenderCompatibilityStatus;\r\n /** Features that are required by the rendering system but not supported by the client. */\r\n missingRequiredFeatures: WebGLFeature[];\r\n /** Optional features unsupported by this client that would provide improved performance or quality if present. */\r\n missingOptionalFeatures: WebGLFeature[];\r\n /** Known bugs associated with the client's graphics driver for which iTwin.js can apply workarounds. */\r\n driverBugs: GraphicsDriverBugs;\r\n /** The user agent as reported by the browser. */\r\n userAgent: string;\r\n /** The renderer string reported by this client's graphics driver. */\r\n unmaskedRenderer?: string;\r\n /** The vendor string reported by this client's graphics driver. */\r\n unmaskedVendor?: string;\r\n /** If true, there is a likelihood that integrated graphics are being used. This can be used to warn users on systems with both integrated graphics and dedicated graphics that they should try to switch to their dedicated graphics for better performance.\r\n * @note This property has the possibility of providing false positives and negatives. A user should use this property mainly as a hint and manually verify what graphics chip is being used.\r\n */\r\n usingIntegratedGraphics?: boolean;\r\n /** If WebGL context creation failed, an error message supplied by the browser. */\r\n contextErrorMessage?: string;\r\n /** The WebGL context created by the browser and used to generate the compatibility report. */\r\n createdContext?: WebGLContext;\r\n}\r\n\r\n/** A function that creates and returns a WebGLContext given an HTMLCanvasElement, a boolean specifying whether to use WebGL2, and a WebGLContextAttributes object describing the desired context attributes.\r\n * @public\r\n */\r\nexport type ContextCreator = (canvas: HTMLCanvasElement, useWebGL2: boolean, inputContextAttributes?: WebGLContextAttributes) => WebGLContext | undefined;\r\n\r\nfunction createDefaultContext(canvas: HTMLCanvasElement, useWebGL2: boolean = true, attributes?: WebGLContextAttributes): WebGLContext | undefined {\r\n let context = useWebGL2 ? canvas.getContext(\"webgl2\", attributes) : canvas.getContext(\"webgl\", attributes);\r\n if (context === null && useWebGL2)\r\n context = canvas.getContext(\"webgl\", attributes);\r\n return context ?? undefined;\r\n}\r\n\r\n/** This function returns information about the client system's level of compatibility with the iTwin.js rendering system, describing the client system's support for both optional and required features. It will also report if there is a major issue with the client system such as the browser falling back to software rendering or an inability to create a either a canvas or a WebGL rendering context.\r\n * @param useWebGL2 A boolean which will be passed to the createContext function in order to create the desired type of context; set this to `true` to use WebGL2, `false` to use WebGL1.\r\n * @param createContext A function of type [[ContextCreator]] that returns a WebGLContext. If not specified, this by default uses `canvas.getContext()` to create the WebGLContext.\r\n * @returns A [[WebGLRenderCompatibilityInfo]] object which contains a compatibility summary.\r\n * @see [[WebGLRenderCompatibilityInfo]]\r\n * @public\r\n */\r\nexport function queryRenderCompatibility(useWebGL2: boolean, createContext?: ContextCreator): WebGLRenderCompatibilityInfo {\r\n const canvas = document.createElement(\"canvas\");\r\n if (null === canvas)\r\n return { status: WebGLRenderCompatibilityStatus.CannotCreateContext, missingOptionalFeatures: [], missingRequiredFeatures: [], userAgent: navigator.userAgent, driverBugs: { } };\r\n\r\n let errorMessage: string | undefined;\r\n canvas.addEventListener(\"webglcontextcreationerror\", (event) => {\r\n errorMessage = (event as WebGLContextEvent).statusMessage || \"webglcontextcreationerror was triggered with no error provided\";\r\n }, false);\r\n\r\n if (undefined === createContext)\r\n createContext = createDefaultContext;\r\n\r\n let hasMajorPerformanceCaveat = false;\r\n let context = createContext(canvas, useWebGL2, { failIfMajorPerformanceCaveat: true });\r\n if (undefined === context) {\r\n hasMajorPerformanceCaveat = true;\r\n context = createContext(canvas, useWebGL2); // try to create context without black-listed GPU\r\n if (undefined === context)\r\n return {\r\n status: WebGLRenderCompatibilityStatus.CannotCreateContext,\r\n missingOptionalFeatures: [],\r\n missingRequiredFeatures: [],\r\n userAgent: navigator.userAgent,\r\n contextErrorMessage: errorMessage,\r\n driverBugs: {},\r\n };\r\n }\r\n\r\n const capabilities = new Capabilities();\r\n const compatibility = capabilities.init(context, undefined);\r\n compatibility.contextErrorMessage = errorMessage;\r\n\r\n if (hasMajorPerformanceCaveat && compatibility.status !== WebGLRenderCompatibilityStatus.MissingRequiredFeatures)\r\n compatibility.status = WebGLRenderCompatibilityStatus.MajorPerformanceCaveat;\r\n\r\n return compatibility;\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/webgl-compatibility",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-dev.0",
|
|
4
4
|
"description": "APIs for determining the level of compatibility of a browser+device with the iTwin.js rendering system.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/cjs/webgl-compatibility.js",
|
|
@@ -24,24 +24,24 @@
|
|
|
24
24
|
"url": "http://www.bentley.com"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@itwin/core-bentley": "
|
|
27
|
+
"@itwin/core-bentley": "5.0.0-dev.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@itwin/eslint-plugin": "
|
|
30
|
+
"@itwin/eslint-plugin": "5.0.0-dev.1",
|
|
31
31
|
"@types/chai": "4.3.1",
|
|
32
32
|
"@types/mocha": "^10.0.6",
|
|
33
33
|
"babel-loader": "~8.2.5",
|
|
34
34
|
"babel-plugin-istanbul": "~6.1.1",
|
|
35
35
|
"chai": "^4.3.10",
|
|
36
|
-
"eslint": "^
|
|
36
|
+
"eslint": "^9.13.0",
|
|
37
37
|
"glob": "^10.3.12",
|
|
38
38
|
"mocha": "^10.2.0",
|
|
39
39
|
"rimraf": "^3.0.2",
|
|
40
40
|
"source-map-loader": "^4.0.0",
|
|
41
|
-
"typescript": "~5.
|
|
41
|
+
"typescript": "~5.6.2",
|
|
42
42
|
"webpack": "^5.76.0",
|
|
43
|
-
"@itwin/build-tools": "
|
|
44
|
-
"@itwin/certa": "
|
|
43
|
+
"@itwin/build-tools": "5.0.0-dev.0",
|
|
44
|
+
"@itwin/certa": "5.0.0-dev.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"cover": "npm -s test",
|
|
52
52
|
"docs": "betools docs --includes=../../generated-docs/extract --json=../../generated-docs/core/webgl-compatibility/file.json --tsIndexFile=./webgl-compatibility.ts --onlyJson",
|
|
53
53
|
"extract-api": "betools extract-api --entry=webgl-compatibility",
|
|
54
|
-
"lint": "eslint
|
|
54
|
+
"lint": "eslint \"./src/**/*.ts\" 1>&2",
|
|
55
55
|
"test": "npm run -s webpackTests && certa -r chrome",
|
|
56
56
|
"webpackTests": "webpack --config ./src/test/utils/webpack.config.js 1>&2"
|
|
57
57
|
}
|