@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.6
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/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +71 -11
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +3 -2
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +10 -7
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +76 -64
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +18 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +77 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +17 -14
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +2 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +6 -5
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +2 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +2 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +24 -11
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -100
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +7 -6
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +3 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -8
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +25 -23
- package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +136 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +15 -7
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +34 -49
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +12 -6
- package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +18 -0
- package/dist/adapter/resources/webgl-texture.d.ts +4 -3
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +12 -7
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +2 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -4
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +3 -2
- package/dist/adapter/webgl-device.d.ts +29 -27
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +90 -94
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +4 -3
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +3 -2
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +5 -4
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +2 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +2 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/helpers/create-browser-context.d.ts +35 -0
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
- package/dist/context/helpers/create-browser-context.js +67 -0
- package/dist/context/helpers/webgl-context-data.d.ts +13 -0
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +21 -0
- package/dist/context/helpers/webgl-extensions.d.ts +4 -0
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +10 -0
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +4 -3
- package/dist/context/parameters/webgl-parameter-tables.d.ts +10 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +29 -16
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +5 -4
- package/dist/dist.dev.js +941 -730
- package/dist/index.cjs +732 -565
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +5 -5
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +105 -16
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +87 -66
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +83 -51
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +35 -13
- package/src/adapter/objects/webgl-resource.ts +6 -124
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +3 -2
- package/src/adapter/resources/webgl-framebuffer.ts +34 -29
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +17 -8
- package/src/adapter/resources/webgl-render-pipeline.ts +41 -48
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +9 -2
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +94 -90
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +12 -6
- package/src/classic/copy-and-blit.ts +11 -4
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- package/src/context/helpers/webgl-context-data.ts +31 -0
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +2 -1
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +3 -2
- package/src/types.ts +2 -1
- package/src/context/context/context-data.ts +0 -44
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { Texture, log, assert, loadImage, isObjectEmpty } from '@luma.gl/core';
|
|
4
5
|
import { GL } from '@luma.gl/constants';
|
|
5
|
-
import { withGLParameters } from
|
|
6
|
-
import { convertTextureFormatToGL, getWebGLTextureParameters, getTextureFormatBytesPerPixel } from
|
|
7
|
-
import { convertSamplerParametersToWebGL } from
|
|
8
|
-
import { WEBGLBuffer } from
|
|
9
|
-
import { WEBGLSampler } from
|
|
6
|
+
import { withGLParameters } from "../../context/state-tracker/with-parameters.js";
|
|
7
|
+
import { convertTextureFormatToGL, getWebGLTextureParameters, getTextureFormatBytesPerPixel } from "../converters/texture-formats.js";
|
|
8
|
+
import { convertSamplerParametersToWebGL } from "../converters/sampler-parameters.js";
|
|
9
|
+
import { WEBGLBuffer } from "./webgl-buffer.js";
|
|
10
|
+
import { WEBGLSampler } from "./webgl-sampler.js";
|
|
11
|
+
import { WEBGLTextureView } from "./webgl-texture-view.js";
|
|
10
12
|
export const DEFAULT_WEBGL_TEXTURE_PROPS = {
|
|
11
13
|
// deprecated
|
|
12
14
|
parameters: {},
|
|
@@ -32,8 +34,9 @@ export class WEBGLTexture extends Texture {
|
|
|
32
34
|
device;
|
|
33
35
|
gl;
|
|
34
36
|
handle;
|
|
35
|
-
|
|
37
|
+
// (TODO - currently unused in WebGL, but WebGL 2 does support sampler objects) */
|
|
36
38
|
sampler = undefined;
|
|
39
|
+
view = undefined;
|
|
37
40
|
// data;
|
|
38
41
|
glFormat = undefined;
|
|
39
42
|
type = undefined;
|
|
@@ -158,6 +161,8 @@ export class WEBGLTexture extends Texture {
|
|
|
158
161
|
// Set texture sampler parameters
|
|
159
162
|
this.setSampler(props.sampler);
|
|
160
163
|
this._setSamplerParameters(parameters);
|
|
164
|
+
// @ts-ignore
|
|
165
|
+
this.view = new WEBGLTextureView(this.device, { ...this.props, texture: this });
|
|
161
166
|
if (mipmaps) {
|
|
162
167
|
this.generateMipmap();
|
|
163
168
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PrimitiveTopology, ShaderLayout, TransformFeedbackProps } from '@luma.gl/core';
|
|
2
2
|
import { TransformFeedback, Buffer, BufferRange } from '@luma.gl/core';
|
|
3
|
-
import { WebGLDevice } from
|
|
3
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
4
4
|
export declare class WEBGLTransformFeedback extends TransformFeedback {
|
|
5
5
|
readonly device: WebGLDevice;
|
|
6
6
|
readonly gl: WebGL2RenderingContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-transform-feedback.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-transform-feedback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,YAAY,EAAE,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAM,iBAAiB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAC,WAAW,EAAC,
|
|
1
|
+
{"version":3,"file":"webgl-transform-feedback.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-transform-feedback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,YAAY,EAAE,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAM,iBAAiB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAC,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AAC,YAAY,IAAI,IAAI;IAO9B,SAAS,CAAC,cAAc,IAAI,IAAI;IAMhC,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,SAAI,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;CAQhG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { log, TransformFeedback } from '@luma.gl/core';
|
|
2
2
|
import { GL } from '@luma.gl/constants';
|
|
3
|
-
import { WEBGLBuffer } from
|
|
4
|
-
import { getGLPrimitive } from
|
|
3
|
+
import { WEBGLBuffer } from "../../index.js";
|
|
4
|
+
import { getGLPrimitive } from "../helpers/webgl-topology-utils.js";
|
|
5
5
|
export class WEBGLTransformFeedback extends TransformFeedback {
|
|
6
6
|
device;
|
|
7
7
|
gl;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Device, Buffer, VertexArrayProps, TypedArray } from '@luma.gl/core';
|
|
2
2
|
import { VertexArray } from '@luma.gl/core';
|
|
3
3
|
import { GL } from '@luma.gl/constants';
|
|
4
|
-
import { WebGLDevice } from
|
|
4
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
5
5
|
/** VertexArrayObject wrapper */
|
|
6
6
|
export declare class WEBGLVertexArray extends VertexArray {
|
|
7
7
|
get [Symbol.toStringTag](): string;
|
|
@@ -24,7 +24,7 @@ export declare class WEBGLVertexArray extends VertexArray {
|
|
|
24
24
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
25
25
|
setBuffer(location: number, attributeBuffer: Buffer): void;
|
|
26
26
|
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
27
|
-
|
|
27
|
+
setConstantWebGL(location: number, value: TypedArray): void;
|
|
28
28
|
init: boolean;
|
|
29
29
|
bindBeforeRender(): void;
|
|
30
30
|
unbindAfterRender(): void;
|
|
@@ -41,7 +41,7 @@ export declare class WEBGLVertexArray extends VertexArray {
|
|
|
41
41
|
*/
|
|
42
42
|
/** Get an accessor from the */
|
|
43
43
|
protected _getAccessor(location: number): {
|
|
44
|
-
size: 1 | 2 |
|
|
44
|
+
size: 1 | 2 | 3 | 4;
|
|
45
45
|
type: GL.BYTE | GL.UNSIGNED_BYTE | GL.SHORT | GL.UNSIGNED_SHORT | GL.INT | GL.UNSIGNED_INT | GL.FLOAT | GL.HALF_FLOAT;
|
|
46
46
|
stride: number;
|
|
47
47
|
offset: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-vertex-array.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-vertex-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAC,WAAW,EAA6B,MAAM,eAAe,CAAC;AACtE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAO5C,gCAAgC;AAChC,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAExC,kCAAkC;IAClC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,WAAW,CAAQ;IAE3B,6EAA6E;IAC7E,MAAM,CAAC,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;gBAKpD,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,gBAAgB;IAMhD,OAAO,IAAI,IAAI;IAexB;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAgBhD,gGAAgG;IAChG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;IA6B1D,2FAA2F;IAClF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAKpE,IAAI,UAAS;IAEJ,gBAAgB,IAAI,IAAI;IAYxB,iBAAiB,IAAI,IAAI;IAUlC;;;;;OAKG;IACH,SAAS,CAAC,wBAAwB,IAAI,IAAI;IAU1C;;;OAGG;IAcH,gCAAgC;IAChC,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;IAsBvC;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,IAAI;IAiBxD;;;;;OAKG;IACH,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM;CA8BnE"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { VertexArray, getScratchArray, fillArray } from '@luma.gl/core';
|
|
4
5
|
import { GL } from '@luma.gl/constants';
|
|
5
6
|
import { getBrowser } from '@probe.gl/env';
|
|
6
|
-
import { getGLFromVertexType } from
|
|
7
|
+
import { getGLFromVertexType } from "../converters/vertex-formats.js";
|
|
7
8
|
// import {AccessorObject} from '../..';
|
|
8
9
|
// import {getGLFromVertexType} from '../converters/vertex-formats';
|
|
9
10
|
/** VertexArrayObject wrapper */
|
|
@@ -85,7 +86,7 @@ export class WEBGLVertexArray extends VertexArray {
|
|
|
85
86
|
this.attributes[location] = buffer;
|
|
86
87
|
}
|
|
87
88
|
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
88
|
-
|
|
89
|
+
setConstantWebGL(location, value) {
|
|
89
90
|
this._enable(location, false);
|
|
90
91
|
this.attributes[location] = value;
|
|
91
92
|
}
|
|
@@ -120,7 +121,7 @@ export class WEBGLVertexArray extends VertexArray {
|
|
|
120
121
|
const constant = this.attributes[location];
|
|
121
122
|
// A typed array means this is a constant
|
|
122
123
|
if (ArrayBuffer.isView(constant)) {
|
|
123
|
-
this.device.
|
|
124
|
+
this.device.setConstantAttributeWebGL(location, constant);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CanvasContextProps } from '@luma.gl/core';
|
|
2
2
|
import { CanvasContext } from '@luma.gl/core';
|
|
3
|
-
import { WebGLDevice } from
|
|
4
|
-
import { WEBGLFramebuffer } from
|
|
3
|
+
import { WebGLDevice } from "./webgl-device.js";
|
|
4
|
+
import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
|
|
5
5
|
/**
|
|
6
6
|
* A WebGL Canvas Context which manages the canvas and handles drawing buffer resizing etc
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-canvas-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-canvas-context.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,0BAAuB;AAC3C,OAAO,EAAC,gBAAgB,EAAC,yCAAsC;AAE/D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;IACnD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,YAAY,CAAiC;gBAEzC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB;IAS1D,qBAAqB,IAAI,gBAAgB;IAOzC,sDAAsD;IACtD,MAAM;IAUN;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;KAAC,GAAG,IAAI;IAW7F,MAAM;CAOP"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { CanvasContext } from '@luma.gl/core';
|
|
4
|
-
import { WEBGLFramebuffer } from
|
|
5
|
+
import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
|
|
5
6
|
/**
|
|
6
7
|
* A WebGL Canvas Context which manages the canvas and handles drawing buffer resizing etc
|
|
7
8
|
*/
|
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
import type { DeviceProps, DeviceInfo,
|
|
1
|
+
import type { DeviceProps, DeviceInfo, CanvasContextProps, TextureFormat, VertexArray, VertexArrayProps, Framebuffer, Buffer, Texture, TypedArray } from '@luma.gl/core';
|
|
2
2
|
import { Device, CanvasContext } from '@luma.gl/core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
3
|
+
import type { GLExtensions } from '@luma.gl/constants';
|
|
4
|
+
import { WebGLDeviceFeatures } from "./device-helpers/webgl-device-features.js";
|
|
5
|
+
import { WebGLDeviceLimits } from "./device-helpers/webgl-device-limits.js";
|
|
6
|
+
import { WebGLCanvasContext } from "./webgl-canvas-context.js";
|
|
7
|
+
import type { BufferProps, ShaderProps, SamplerProps, TextureProps, ExternalTexture, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipeline, ComputePipelineProps, RenderPassProps, ComputePass, ComputePassProps, CommandEncoderProps, TransformFeedbackProps, QuerySetProps } from '@luma.gl/core';
|
|
8
|
+
import { WEBGLBuffer } from "./resources/webgl-buffer.js";
|
|
9
|
+
import { WEBGLShader } from "./resources/webgl-shader.js";
|
|
10
|
+
import { WEBGLSampler } from "./resources/webgl-sampler.js";
|
|
11
|
+
import { WEBGLTexture } from "./resources/webgl-texture.js";
|
|
12
|
+
import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
|
|
13
|
+
import { WEBGLRenderPass } from "./resources/webgl-render-pass.js";
|
|
14
|
+
import { WEBGLRenderPipeline } from "./resources/webgl-render-pipeline.js";
|
|
15
|
+
import { WEBGLCommandEncoder } from "./resources/webgl-command-encoder.js";
|
|
16
|
+
import { WEBGLTransformFeedback } from "./resources/webgl-transform-feedback.js";
|
|
17
|
+
import { WEBGLQuerySet } from "./resources/webgl-query-set.js";
|
|
15
18
|
/** WebGPU style Device API for a WebGL context */
|
|
16
19
|
export declare class WebGLDevice extends Device {
|
|
17
20
|
static type: string;
|
|
18
21
|
static isSupported(): boolean;
|
|
22
|
+
/** The underlying WebGL context */
|
|
23
|
+
readonly handle: WebGL2RenderingContext;
|
|
24
|
+
features: WebGLDeviceFeatures;
|
|
25
|
+
limits: WebGLDeviceLimits;
|
|
19
26
|
readonly info: DeviceInfo;
|
|
20
27
|
readonly canvasContext: WebGLCanvasContext;
|
|
21
|
-
readonly handle: WebGL2RenderingContext;
|
|
22
|
-
get features(): Set<DeviceFeature>;
|
|
23
|
-
get limits(): DeviceLimits;
|
|
24
28
|
readonly lost: Promise<{
|
|
25
29
|
reason: 'destroyed';
|
|
26
30
|
message: string;
|
|
27
31
|
}>;
|
|
28
32
|
private _resolveContextLost?;
|
|
29
|
-
private _features?;
|
|
30
|
-
private _limits?;
|
|
31
33
|
/**
|
|
32
34
|
* Get a device instance from a GL context
|
|
33
35
|
* Creates and instruments the device if not already created
|
|
@@ -39,7 +41,7 @@ export declare class WebGLDevice extends Device {
|
|
|
39
41
|
constructor(props: DeviceProps);
|
|
40
42
|
/**
|
|
41
43
|
* Destroys the context
|
|
42
|
-
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
44
|
+
* @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
|
|
43
45
|
*/
|
|
44
46
|
destroy(): void;
|
|
45
47
|
get isLost(): boolean;
|
|
@@ -54,12 +56,13 @@ export declare class WebGLDevice extends Device {
|
|
|
54
56
|
createSampler(props: SamplerProps): WEBGLSampler;
|
|
55
57
|
createShader(props: ShaderProps): WEBGLShader;
|
|
56
58
|
createFramebuffer(props: FramebufferProps): WEBGLFramebuffer;
|
|
57
|
-
createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline;
|
|
58
59
|
createVertexArray(props: VertexArrayProps): VertexArray;
|
|
60
|
+
createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback;
|
|
61
|
+
createQuerySet(props: QuerySetProps): WEBGLQuerySet;
|
|
62
|
+
createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline;
|
|
59
63
|
beginRenderPass(props: RenderPassProps): WEBGLRenderPass;
|
|
60
64
|
createComputePipeline(props?: ComputePipelineProps): ComputePipeline;
|
|
61
65
|
beginComputePass(props: ComputePassProps): ComputePass;
|
|
62
|
-
createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback;
|
|
63
66
|
private renderPass;
|
|
64
67
|
getDefaultRenderPass(): WEBGLRenderPass;
|
|
65
68
|
createCommandEncoder(props?: CommandEncoderProps): WEBGLCommandEncoder;
|
|
@@ -110,13 +113,10 @@ export declare class WebGLDevice extends Device {
|
|
|
110
113
|
devicePixelRatio: number;
|
|
111
114
|
};
|
|
112
115
|
/** State used by luma.gl classes - TODO - not used? */
|
|
113
|
-
readonly _extensions:
|
|
116
|
+
readonly _extensions: GLExtensions;
|
|
114
117
|
_polyfilled: boolean;
|
|
115
118
|
/** Instance of Spector.js (if initialized) */
|
|
116
|
-
|
|
117
|
-
private _webglLimits?;
|
|
118
|
-
/** Return WebGL specific limits */
|
|
119
|
-
get webglLimits(): WebGLLimits;
|
|
119
|
+
spectorJS: unknown;
|
|
120
120
|
/**
|
|
121
121
|
* Triggers device (or WebGL context) loss.
|
|
122
122
|
* @note primarily intended for testing how application reacts to device loss
|
|
@@ -145,6 +145,8 @@ export declare class WebGLDevice extends Device {
|
|
|
145
145
|
* so they need to be updated before every render
|
|
146
146
|
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
147
147
|
*/
|
|
148
|
-
|
|
148
|
+
setConstantAttributeWebGL(location: number, constant: TypedArray): void;
|
|
149
|
+
/** Ensure extensions are only requested once */
|
|
150
|
+
getExtension(name: keyof GLExtensions): GLExtensions;
|
|
149
151
|
}
|
|
150
152
|
//# sourceMappingURL=webgl-device.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,OAAO,EACP,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAQrD,OAAO,EAAC,mBAAmB,EAAC,kDAA+C;AAC3E,OAAO,EAAC,iBAAiB,EAAC,gDAA6C;AACvE,O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1B,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,OAAO,CAAC,EAAE,GAAG,CAAC;KACf,GAAG,IAAI;IAQR,sBAAsB;IACtB,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAS;IAEhC,iEAAiE;IACjE,QAAQ,CAAC,eAAe;;;;MAA0D;IAElF,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAM;IACxC,WAAW,EAAE,OAAO,CAAS;IAE7B,8CAA8C;IAC9C,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACM,UAAU,IAAI,OAAO;IAgB9B,8DAA8D;IAC9D,SAAS,IAAI,IAAI;IAIjB,8CAA8C;IAC9C,QAAQ,IAAI,IAAI;IAIhB;;;OAGG;IACH,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAMlE;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,sBAAsB,GAAG,MAAM;IAc7D,sBAAsB;IACtB,UAAU,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC;IAElC;;;;;OAKG;IACH,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI;IA2BvE,gDAAgD;IAChD,YAAY,CAAC,IAAI,EAAE,MAAM,YAAY,GAAG,YAAY;CAIrD"}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { Device, CanvasContext, log, uid, assert } from '@luma.gl/core';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { readPixelsToArray, readPixelsToBuffer } from
|
|
25
|
-
import { setGLParameters, getGLParameters } from
|
|
26
|
-
import { withGLParameters } from
|
|
27
|
-
import { clear } from
|
|
5
|
+
import { popContextState, pushContextState, trackContextState } from "../context/state-tracker/track-context-state.js";
|
|
6
|
+
import { createBrowserContext } from "../context/helpers/create-browser-context.js";
|
|
7
|
+
import { getDeviceInfo } from "./device-helpers/webgl-device-info.js";
|
|
8
|
+
import { WebGLDeviceFeatures } from "./device-helpers/webgl-device-features.js";
|
|
9
|
+
import { WebGLDeviceLimits } from "./device-helpers/webgl-device-limits.js";
|
|
10
|
+
import { WebGLCanvasContext } from "./webgl-canvas-context.js";
|
|
11
|
+
import { loadSpectorJS, initializeSpectorJS } from "../context/debug/spector.js";
|
|
12
|
+
import { loadWebGLDeveloperTools, makeDebugContext } from "../context/debug/webgl-developer-tools.js";
|
|
13
|
+
import { isTextureFormatSupported, isTextureFormatRenderable, isTextureFormatFilterable } from "./converters/texture-formats.js";
|
|
14
|
+
import { WEBGLBuffer } from "./resources/webgl-buffer.js";
|
|
15
|
+
import { WEBGLShader } from "./resources/webgl-shader.js";
|
|
16
|
+
import { WEBGLSampler } from "./resources/webgl-sampler.js";
|
|
17
|
+
import { WEBGLTexture } from "./resources/webgl-texture.js";
|
|
18
|
+
import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
|
|
19
|
+
import { WEBGLRenderPass } from "./resources/webgl-render-pass.js";
|
|
20
|
+
import { WEBGLRenderPipeline } from "./resources/webgl-render-pipeline.js";
|
|
21
|
+
import { WEBGLCommandEncoder } from "./resources/webgl-command-encoder.js";
|
|
22
|
+
import { WEBGLVertexArray } from "./resources/webgl-vertex-array.js";
|
|
23
|
+
import { WEBGLTransformFeedback } from "./resources/webgl-transform-feedback.js";
|
|
24
|
+
import { WEBGLQuerySet } from "./resources/webgl-query-set.js";
|
|
25
|
+
import { readPixelsToArray, readPixelsToBuffer } from "../classic/copy-and-blit.js";
|
|
26
|
+
import { setGLParameters, getGLParameters } from "../context/parameters/unified-parameter-api.js";
|
|
27
|
+
import { withGLParameters } from "../context/state-tracker/with-parameters.js";
|
|
28
|
+
import { clear } from "../classic/clear.js";
|
|
29
|
+
import { getWebGLExtension } from "../context/helpers/webgl-extensions.js";
|
|
28
30
|
const LOG_LEVEL = 1;
|
|
29
31
|
/** WebGPU style Device API for a WebGL context */
|
|
30
32
|
export class WebGLDevice extends Device {
|
|
@@ -35,21 +37,14 @@ export class WebGLDevice extends Device {
|
|
|
35
37
|
static isSupported() {
|
|
36
38
|
return typeof WebGL2RenderingContext !== 'undefined';
|
|
37
39
|
}
|
|
40
|
+
/** The underlying WebGL context */
|
|
41
|
+
handle;
|
|
42
|
+
features;
|
|
43
|
+
limits;
|
|
38
44
|
info;
|
|
39
45
|
canvasContext;
|
|
40
|
-
handle;
|
|
41
|
-
get features() {
|
|
42
|
-
this._features = this._features || getDeviceFeatures(this.gl);
|
|
43
|
-
return this._features;
|
|
44
|
-
}
|
|
45
|
-
get limits() {
|
|
46
|
-
this._limits = this._limits || getDeviceLimits(this.gl);
|
|
47
|
-
return this._limits;
|
|
48
|
-
}
|
|
49
46
|
lost;
|
|
50
47
|
_resolveContextLost;
|
|
51
|
-
_features;
|
|
52
|
-
_limits;
|
|
53
48
|
//
|
|
54
49
|
// Static methods, expected to be present by `luma.createDevice()`
|
|
55
50
|
//
|
|
@@ -75,23 +70,25 @@ export class WebGLDevice extends Device {
|
|
|
75
70
|
}
|
|
76
71
|
static async create(props = {}) {
|
|
77
72
|
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
|
|
78
|
-
|
|
79
|
-
// to avoid setting page onload callback unless necessary
|
|
80
|
-
if (typeof props.canvas === 'string') {
|
|
81
|
-
await CanvasContext.pageLoaded;
|
|
82
|
-
}
|
|
73
|
+
const promises = [];
|
|
83
74
|
// Load webgl and spector debug scripts from CDN if requested
|
|
84
|
-
if (
|
|
85
|
-
|
|
75
|
+
if (props.debug) {
|
|
76
|
+
promises.push(loadWebGLDeveloperTools());
|
|
86
77
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
if (props.spector) {
|
|
79
|
+
promises.push(loadSpectorJS());
|
|
80
|
+
}
|
|
81
|
+
// Wait for page to load: if canvas is a string we need to query the DOM for the canvas element.
|
|
82
|
+
// We only wait when props.canvas is string to avoids setting the global page onload callback unless necessary.
|
|
83
|
+
if (typeof props.canvas === 'string') {
|
|
84
|
+
promises.push(CanvasContext.pageLoaded);
|
|
91
85
|
}
|
|
86
|
+
// Wait for all the loads to settle before creating the context.
|
|
87
|
+
// The Device.create() functions are async, so in contrast to the constructor, we can `await` here.
|
|
88
|
+
await Promise.all(promises);
|
|
92
89
|
log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
|
|
93
90
|
// @ts-expect-error
|
|
94
|
-
if (props.gl
|
|
91
|
+
if (props.gl?.device) {
|
|
95
92
|
return WebGLDevice.attach(props.gl);
|
|
96
93
|
}
|
|
97
94
|
const device = new WebGLDevice(props);
|
|
@@ -116,33 +113,31 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
116
113
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
117
114
|
}
|
|
118
115
|
// Create and instrument context
|
|
119
|
-
const canvas = props.canvas || props.
|
|
116
|
+
const canvas = props.gl?.canvas || props.canvas;
|
|
120
117
|
this.canvasContext = new WebGLCanvasContext(this, { ...props, canvas });
|
|
121
118
|
this.lost = new Promise(resolve => {
|
|
122
119
|
this._resolveContextLost = resolve;
|
|
123
120
|
});
|
|
124
|
-
const onContextLost = (event) => this._resolveContextLost?.({
|
|
125
|
-
reason: 'destroyed',
|
|
126
|
-
message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
127
|
-
});
|
|
128
121
|
let gl = props.gl || null;
|
|
129
|
-
gl
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
gl ||= createBrowserContext(this.canvasContext.canvas, {
|
|
123
|
+
...props,
|
|
124
|
+
onContextLost: (event) => this._resolveContextLost?.({
|
|
125
|
+
reason: 'destroyed',
|
|
126
|
+
message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
127
|
+
})
|
|
128
|
+
});
|
|
134
129
|
if (!gl) {
|
|
135
130
|
throw new Error('WebGL context creation failed');
|
|
136
131
|
}
|
|
137
132
|
this.handle = gl;
|
|
138
|
-
this.gl =
|
|
139
|
-
this.
|
|
133
|
+
this.gl = gl;
|
|
134
|
+
this.gl.device = this; // Update GL context: Link webgl context back to device
|
|
135
|
+
this.gl._version = 2; // Update GL context: Store WebGL version field on gl context (HACK to identify debug contexts)
|
|
140
136
|
// luma Device fields
|
|
141
|
-
this.info = getDeviceInfo(this.gl);
|
|
142
|
-
|
|
143
|
-
this.
|
|
144
|
-
|
|
145
|
-
this.gl._version = this.isWebGL2 ? 2 : 1;
|
|
137
|
+
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
138
|
+
this.features = new WebGLDeviceFeatures(this.gl, this._extensions);
|
|
139
|
+
this.limits = new WebGLDeviceLimits(this.gl);
|
|
140
|
+
this.canvasContext.resize();
|
|
146
141
|
// Install context state tracking
|
|
147
142
|
// @ts-expect-error - hidden parameters
|
|
148
143
|
const { enable = true, copyState = false } = props;
|
|
@@ -152,24 +147,21 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
152
147
|
log: (...args) => log.log(1, ...args)()
|
|
153
148
|
});
|
|
154
149
|
// DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1
|
|
155
|
-
if (
|
|
150
|
+
if (props.debug) {
|
|
156
151
|
this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
|
|
157
152
|
this.debug = true;
|
|
158
153
|
log.level = Math.max(log.level, 1);
|
|
159
154
|
log.warn('WebGL debug mode activated. Performance reduced.')();
|
|
160
155
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const canvas = this.handle.canvas || props.canvas;
|
|
164
|
-
this.spector = initializeSpectorJS({ ...this.props, canvas });
|
|
156
|
+
if (props.spector) {
|
|
157
|
+
this.spectorJS = initializeSpectorJS({ ...this.props, canvas: this.handle.canvas });
|
|
165
158
|
}
|
|
166
159
|
}
|
|
167
160
|
/**
|
|
168
161
|
* Destroys the context
|
|
169
|
-
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
162
|
+
* @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
|
|
170
163
|
*/
|
|
171
|
-
destroy() {
|
|
172
|
-
}
|
|
164
|
+
destroy() { }
|
|
173
165
|
get isLost() {
|
|
174
166
|
return this.gl.isContextLost();
|
|
175
167
|
}
|
|
@@ -177,13 +169,13 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
177
169
|
return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];
|
|
178
170
|
}
|
|
179
171
|
isTextureFormatSupported(format) {
|
|
180
|
-
return isTextureFormatSupported(this.gl, format);
|
|
172
|
+
return isTextureFormatSupported(this.gl, format, this._extensions);
|
|
181
173
|
}
|
|
182
174
|
isTextureFormatFilterable(format) {
|
|
183
|
-
return isTextureFormatFilterable(this.gl, format);
|
|
175
|
+
return isTextureFormatFilterable(this.gl, format, this._extensions);
|
|
184
176
|
}
|
|
185
177
|
isTextureFormatRenderable(format) {
|
|
186
|
-
return isTextureFormatRenderable(this.gl, format);
|
|
178
|
+
return isTextureFormatRenderable(this.gl, format, this._extensions);
|
|
187
179
|
}
|
|
188
180
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
189
181
|
createCanvasContext(props) {
|
|
@@ -208,12 +200,18 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
208
200
|
createFramebuffer(props) {
|
|
209
201
|
return new WEBGLFramebuffer(this, props);
|
|
210
202
|
}
|
|
211
|
-
createRenderPipeline(props) {
|
|
212
|
-
return new WEBGLRenderPipeline(this, props);
|
|
213
|
-
}
|
|
214
203
|
createVertexArray(props) {
|
|
215
204
|
return new WEBGLVertexArray(this, props);
|
|
216
205
|
}
|
|
206
|
+
createTransformFeedback(props) {
|
|
207
|
+
return new WEBGLTransformFeedback(this, props);
|
|
208
|
+
}
|
|
209
|
+
createQuerySet(props) {
|
|
210
|
+
return new WEBGLQuerySet(this, props);
|
|
211
|
+
}
|
|
212
|
+
createRenderPipeline(props) {
|
|
213
|
+
return new WEBGLRenderPipeline(this, props);
|
|
214
|
+
}
|
|
217
215
|
beginRenderPass(props) {
|
|
218
216
|
return new WEBGLRenderPass(this, props);
|
|
219
217
|
}
|
|
@@ -223,9 +221,6 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
223
221
|
beginComputePass(props) {
|
|
224
222
|
throw new Error('ComputePass not supported in WebGL');
|
|
225
223
|
}
|
|
226
|
-
createTransformFeedback(props) {
|
|
227
|
-
return new WEBGLTransformFeedback(this, props);
|
|
228
|
-
}
|
|
229
224
|
renderPass = null;
|
|
230
225
|
getDefaultRenderPass() {
|
|
231
226
|
this.renderPass =
|
|
@@ -250,7 +245,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
250
245
|
}
|
|
251
246
|
//
|
|
252
247
|
// TEMPORARY HACKS - will be removed in v9.1
|
|
253
|
-
//
|
|
248
|
+
//
|
|
254
249
|
/** @deprecated - should use command encoder */
|
|
255
250
|
readPixelsToArrayWebGL(source, options) {
|
|
256
251
|
return readPixelsToArray(source, options);
|
|
@@ -283,20 +278,15 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
283
278
|
_extensions = {};
|
|
284
279
|
_polyfilled = false;
|
|
285
280
|
/** Instance of Spector.js (if initialized) */
|
|
286
|
-
|
|
287
|
-
_webglLimits;
|
|
288
|
-
/** Return WebGL specific limits */
|
|
289
|
-
get webglLimits() {
|
|
290
|
-
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
291
|
-
return this._webglLimits;
|
|
292
|
-
}
|
|
281
|
+
spectorJS;
|
|
293
282
|
/**
|
|
294
283
|
* Triggers device (or WebGL context) loss.
|
|
295
284
|
* @note primarily intended for testing how application reacts to device loss
|
|
296
285
|
*/
|
|
297
286
|
loseDevice() {
|
|
298
287
|
let deviceLossTriggered = false;
|
|
299
|
-
const
|
|
288
|
+
const extensions = this.getExtension('WEBGL_lose_context');
|
|
289
|
+
const ext = extensions.WEBGL_lose_context;
|
|
300
290
|
if (ext) {
|
|
301
291
|
deviceLossTriggered = true;
|
|
302
292
|
ext.loseContext();
|
|
@@ -351,11 +341,12 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
351
341
|
* so they need to be updated before every render
|
|
352
342
|
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
353
343
|
*/
|
|
354
|
-
|
|
355
|
-
|
|
344
|
+
setConstantAttributeWebGL(location, constant) {
|
|
345
|
+
const maxVertexAttributes = this.limits.maxVertexAttributes;
|
|
346
|
+
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
356
347
|
const currentConstant = this._constants[location];
|
|
357
348
|
if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {
|
|
358
|
-
log.info(1, `
|
|
349
|
+
log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();
|
|
359
350
|
}
|
|
360
351
|
this._constants[location] = constant;
|
|
361
352
|
switch (constant.constructor) {
|
|
@@ -372,6 +363,11 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
372
363
|
assert(false);
|
|
373
364
|
}
|
|
374
365
|
}
|
|
366
|
+
/** Ensure extensions are only requested once */
|
|
367
|
+
getExtension(name) {
|
|
368
|
+
getWebGLExtension(this.gl, name, this._extensions);
|
|
369
|
+
return this._extensions;
|
|
370
|
+
}
|
|
375
371
|
}
|
|
376
372
|
/** Check if supplied parameter is a WebGL2RenderingContext */
|
|
377
373
|
function isWebGL(gl) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,QAAA,MAAM,uBAAuB;;;;;;;;CAQ5B,CAAC;AASF,qBAAa,QAAS,YAAW,cAAc;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM;IAOtE,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;IAY1D,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,cAAc,EAAE,GAAG,QAAQ;gBAI5C,GAAG,SAAS,EAAE,cAAc,EAAE;IAK1C,QAAQ,IAAI,MAAM;IAOlB,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAKD,OAAO,CAAC,KAAK,GAAE,cAAmB,GAAG,IAAI;CA6E1C;AAGD,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
|