@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,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {assert, ResourceProps, TextureFormat} from '@luma.gl/core';
|
|
@@ -6,7 +7,10 @@ import {GL} from '@luma.gl/constants';
|
|
|
6
7
|
import {WebGLDevice} from '../webgl-device';
|
|
7
8
|
import {WebGLResource} from './webgl-resource';
|
|
8
9
|
import {isRenderbufferFormatSupported} from '../converters/texture-formats';
|
|
9
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
convertTextureFormatToGL,
|
|
12
|
+
getTextureFormatBytesPerPixel
|
|
13
|
+
} from '../converters/texture-formats';
|
|
10
14
|
|
|
11
15
|
export type RenderbufferProps = ResourceProps & {
|
|
12
16
|
format: TextureFormat;
|
|
@@ -32,23 +36,35 @@ export class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
|
|
|
32
36
|
userData: undefined,
|
|
33
37
|
format: undefined, // 'depth16unorm'
|
|
34
38
|
width: 1,
|
|
35
|
-
height: 1,
|
|
39
|
+
height: 1,
|
|
36
40
|
samples: 0
|
|
37
|
-
};
|
|
41
|
+
};
|
|
38
42
|
|
|
39
|
-
override get [Symbol.toStringTag](): string {
|
|
43
|
+
override get [Symbol.toStringTag](): string {
|
|
44
|
+
return 'Renderbuffer';
|
|
45
|
+
}
|
|
40
46
|
|
|
41
|
-
get width(): number {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
get
|
|
45
|
-
|
|
47
|
+
get width(): number {
|
|
48
|
+
return this.props.width;
|
|
49
|
+
}
|
|
50
|
+
get height(): number {
|
|
51
|
+
return this.props.height;
|
|
52
|
+
}
|
|
53
|
+
get format(): TextureFormat {
|
|
54
|
+
return this.props.format;
|
|
55
|
+
}
|
|
56
|
+
get samples(): number {
|
|
57
|
+
return this.props.samples;
|
|
58
|
+
}
|
|
59
|
+
get attachment() {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
46
62
|
|
|
47
63
|
/** WebGL format constant */
|
|
48
64
|
glFormat: GL;
|
|
49
65
|
|
|
50
66
|
static isTextureFormatSupported(device: WebGLDevice, format: TextureFormat): boolean {
|
|
51
|
-
return isRenderbufferFormatSupported(device.gl, format);
|
|
67
|
+
return isRenderbufferFormatSupported(device.gl, format, device._extensions);
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
constructor(device: WebGLDevice, props: RenderbufferProps) {
|
|
@@ -61,7 +77,7 @@ export class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
|
|
|
61
77
|
this._initialize(this.props);
|
|
62
78
|
}
|
|
63
79
|
|
|
64
|
-
resize(size: {width: number
|
|
80
|
+
resize(size: {width: number; height: number}): void {
|
|
65
81
|
// Don't resize if width/height haven't changed
|
|
66
82
|
if (size.width !== this.width || size.height !== this.height) {
|
|
67
83
|
Object.assign(this.props, {...size, format: this.format, samples: this.samples});
|
|
@@ -81,7 +97,13 @@ export class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
|
|
|
81
97
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);
|
|
82
98
|
|
|
83
99
|
if (samples !== 0) {
|
|
84
|
-
this.gl.renderbufferStorageMultisample(
|
|
100
|
+
this.gl.renderbufferStorageMultisample(
|
|
101
|
+
GL.RENDERBUFFER,
|
|
102
|
+
samples,
|
|
103
|
+
this.glFormat,
|
|
104
|
+
width,
|
|
105
|
+
height
|
|
106
|
+
);
|
|
85
107
|
} else {
|
|
86
108
|
this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);
|
|
87
109
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
|
-
import {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/core';
|
|
5
5
|
import type {Device, ResourceProps} from '@luma.gl/core';
|
|
6
|
+
import {Resource, uid, stubRemovedMethods} from '@luma.gl/core';
|
|
6
7
|
import {GL} from '@luma.gl/constants';
|
|
7
8
|
import {WebGLDevice} from '../webgl-device';
|
|
8
9
|
|
|
9
|
-
// Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?
|
|
10
|
-
import {getKeyValue} from './constants-to-keys';
|
|
11
|
-
|
|
12
10
|
const ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';
|
|
13
11
|
|
|
14
12
|
/**
|
|
@@ -30,10 +28,10 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
|
|
|
30
28
|
this.device = WebGLDevice.attach(device);
|
|
31
29
|
const gl = this.device.gl;
|
|
32
30
|
|
|
33
|
-
// extends
|
|
31
|
+
// extends
|
|
34
32
|
const {id} = props || {};
|
|
35
33
|
this.gl = gl;
|
|
36
|
-
this.gl2 = gl
|
|
34
|
+
this.gl2 = gl;
|
|
37
35
|
this.id = id || uid(this.constructor.name);
|
|
38
36
|
|
|
39
37
|
// Set the handle
|
|
@@ -81,7 +79,7 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
|
|
|
81
79
|
// @ts-expect-error
|
|
82
80
|
if (children && deleteChildren) {
|
|
83
81
|
// @ts-expect-error
|
|
84
|
-
children.filter(Boolean).forEach(
|
|
82
|
+
children.filter(Boolean).forEach(child => child.destroy());
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
return this;
|
|
@@ -114,122 +112,6 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
|
|
|
114
112
|
this.bind(null);
|
|
115
113
|
}
|
|
116
114
|
|
|
117
|
-
/**
|
|
118
|
-
* Query a Resource parameter
|
|
119
|
-
*
|
|
120
|
-
* @param name
|
|
121
|
-
* @return param
|
|
122
|
-
*/
|
|
123
|
-
getParameter(pname: number, props: any = {}): any {
|
|
124
|
-
pname = getKeyValue(this.gl, pname);
|
|
125
|
-
assert(pname);
|
|
126
|
-
|
|
127
|
-
// @ts-expect-error
|
|
128
|
-
const parameters = this.constructor.PARAMETERS || {};
|
|
129
|
-
|
|
130
|
-
// Use parameter definitions to handle unsupported parameters
|
|
131
|
-
const parameter = parameters[pname];
|
|
132
|
-
if (parameter) {
|
|
133
|
-
// Check if we can query for this parameter
|
|
134
|
-
const parameterAvailable =
|
|
135
|
-
(!('extension' in parameter) || this.gl.getExtension(parameter.extension));
|
|
136
|
-
|
|
137
|
-
if (!parameterAvailable) {
|
|
138
|
-
return parameter.webgl2;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// If unknown parameter - Could be a valid parameter not covered by PARAMS
|
|
143
|
-
// Attempt to query for it and let WebGL report errors
|
|
144
|
-
return this._getParameter(pname, props);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Many resources support a getParameter call -
|
|
148
|
-
// getParameters will get all parameters - slow but useful for debugging
|
|
149
|
-
// eslint-disable-next-line complexity
|
|
150
|
-
getParameters(options: {parameters?: any, keys?: any} = {}) {
|
|
151
|
-
const {parameters, keys} = options;
|
|
152
|
-
|
|
153
|
-
// Get parameter definitions for this Resource
|
|
154
|
-
// @ts-expect-error
|
|
155
|
-
const PARAMETERS = this.constructor.PARAMETERS || {};
|
|
156
|
-
|
|
157
|
-
const values: Record<string, any> = {};
|
|
158
|
-
|
|
159
|
-
// Query all parameters if no list provided
|
|
160
|
-
const parameterKeys = parameters || Object.keys(PARAMETERS);
|
|
161
|
-
|
|
162
|
-
// WEBGL limits
|
|
163
|
-
for (const pname of parameterKeys) {
|
|
164
|
-
const parameter = PARAMETERS[pname];
|
|
165
|
-
|
|
166
|
-
// Check if this parameter is available on this platform
|
|
167
|
-
const parameterAvailable =
|
|
168
|
-
parameter &&
|
|
169
|
-
(!('extension' in parameter) || this.gl.getExtension(parameter.extension));
|
|
170
|
-
|
|
171
|
-
if (parameterAvailable) {
|
|
172
|
-
const key = keys ? this.device.getGLKey(pname) : pname;
|
|
173
|
-
values[key] = this.getParameter(pname, options);
|
|
174
|
-
if (keys && parameter.type === 'GLenum') {
|
|
175
|
-
values[key] = this.device.getGLKey(values[key]);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return values;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Update a Resource setting
|
|
185
|
-
*
|
|
186
|
-
* @todo - cache parameter to avoid issuing WebGL calls?
|
|
187
|
-
*
|
|
188
|
-
* @param pname - parameter (GL constant, value or key)
|
|
189
|
-
* @param value {GLint|GLfloat|GLenum}
|
|
190
|
-
* @return returns self to enable chaining
|
|
191
|
-
*/
|
|
192
|
-
setParameter(pname: GL | string, value: any): this {
|
|
193
|
-
pname = getKeyValue(this.gl, pname);
|
|
194
|
-
assert(pname);
|
|
195
|
-
|
|
196
|
-
// @ts-expect-error
|
|
197
|
-
const parameters = this.constructor.PARAMETERS || {};
|
|
198
|
-
|
|
199
|
-
const parameter = parameters[pname];
|
|
200
|
-
if (parameter) {
|
|
201
|
-
// Check if this parameter is available on this platform
|
|
202
|
-
const parameterAvailable =
|
|
203
|
-
(!('extension' in parameter) || this.gl.getExtension(parameter.extension));
|
|
204
|
-
|
|
205
|
-
if (!parameterAvailable) {
|
|
206
|
-
throw new Error('Parameter not available on this platform');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Handle string keys
|
|
210
|
-
if (parameter.type === 'GLenum') {
|
|
211
|
-
// @ts-expect-error
|
|
212
|
-
value = getKeyValue(value);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// If unknown parameter - Could be a valid parameter not covered by PARAMS
|
|
217
|
-
// attempt to set it and let WebGL report errors
|
|
218
|
-
this._setParameter(pname, value);
|
|
219
|
-
return this;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/*
|
|
223
|
-
* Batch update resource parameters
|
|
224
|
-
* Assumes the subclass supports a setParameter call
|
|
225
|
-
*/
|
|
226
|
-
setParameters(parameters: Record<GL, any>) {
|
|
227
|
-
for (const pname in parameters) {
|
|
228
|
-
this.setParameter(pname, parameters[pname]);
|
|
229
|
-
}
|
|
230
|
-
return this;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
115
|
// Install stubs for removed methods
|
|
234
116
|
stubRemovedMethods(className: string, version: string, methodNames: string[]) {
|
|
235
117
|
return stubRemovedMethods(this, className, version, methodNames);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {BufferProps} from '@luma.gl/core';
|
|
@@ -166,9 +167,9 @@ export class WEBGLBuffer extends Buffer {
|
|
|
166
167
|
* static STORAGE = 0x0080;
|
|
167
168
|
* static INDIRECT = 0x0100;
|
|
168
169
|
* static QUERY_RESOLVE = 0x0200;
|
|
169
|
-
*
|
|
170
|
+
*
|
|
170
171
|
* @returns WebGL buffer targe
|
|
171
|
-
*
|
|
172
|
+
*
|
|
172
173
|
* Buffer bind points in WebGL2
|
|
173
174
|
* gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.
|
|
174
175
|
* gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {
|
|
@@ -156,7 +157,7 @@ function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferO
|
|
|
156
157
|
const webglBuffer = destination as WEBGLBuffer;
|
|
157
158
|
const sourceWidth = width || framebuffer.width;
|
|
158
159
|
const sourceHeight = height || framebuffer.height;
|
|
159
|
-
const sourceParams = getWebGLTextureParameters(framebuffer.texture.format);
|
|
160
|
+
const sourceParams = getWebGLTextureParameters(framebuffer.texture.props.format);
|
|
160
161
|
const sourceFormat = sourceParams.dataFormat;
|
|
161
162
|
const sourceType = sourceParams.type;
|
|
162
163
|
|
|
@@ -225,19 +226,18 @@ function _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextur
|
|
|
225
226
|
origin = [0, 0],
|
|
226
227
|
|
|
227
228
|
/** Texture to copy to/from. */
|
|
228
|
-
destination
|
|
229
|
+
destination
|
|
229
230
|
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
230
231
|
// destinationMipLevel = options.mipLevel,
|
|
231
232
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
232
233
|
// destinationOrigin = [0, 0],
|
|
233
234
|
/** Defines which aspects of the texture to copy to/from. */
|
|
234
235
|
// destinationAspect = options.aspect,
|
|
235
|
-
|
|
236
236
|
} = options;
|
|
237
237
|
|
|
238
238
|
let {
|
|
239
239
|
width = options.destination.width,
|
|
240
|
-
height = options.destination.width
|
|
240
|
+
height = options.destination.width
|
|
241
241
|
// depthOrArrayLayers = 0
|
|
242
242
|
} = options;
|
|
243
243
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {CommandEncoder, CommandEncoderProps} from '@luma.gl/core';
|
|
@@ -6,7 +7,9 @@ import type {
|
|
|
6
7
|
CopyBufferToBufferOptions,
|
|
7
8
|
CopyBufferToTextureOptions,
|
|
8
9
|
CopyTextureToBufferOptions,
|
|
9
|
-
CopyTextureToTextureOptions
|
|
10
|
+
CopyTextureToTextureOptions,
|
|
11
|
+
QuerySet,
|
|
12
|
+
Buffer
|
|
10
13
|
} from '@luma.gl/core';
|
|
11
14
|
|
|
12
15
|
import {WEBGLCommandBuffer} from './webgl-command-buffer';
|
|
@@ -54,13 +57,13 @@ export class WEBGLCommandEncoder extends CommandEncoder {
|
|
|
54
57
|
|
|
55
58
|
override insertDebugMarker(markerLabel: string): void {}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
override resolveQuerySet(
|
|
61
|
+
querySet: QuerySet,
|
|
62
|
+
destination: Buffer,
|
|
63
|
+
options?: {
|
|
64
|
+
firstQuery?: number;
|
|
65
|
+
queryCount?: number;
|
|
66
|
+
destinationOffset?: number;
|
|
67
|
+
}
|
|
68
|
+
): void {}
|
|
66
69
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {FramebufferProps, TextureFormat} from '@luma.gl/core';
|
|
@@ -6,11 +7,11 @@ import {Framebuffer, Texture, assert} from '@luma.gl/core';
|
|
|
6
7
|
import {GL} from '@luma.gl/constants';
|
|
7
8
|
import {WebGLDevice} from '../webgl-device';
|
|
8
9
|
import {WEBGLTexture} from './webgl-texture';
|
|
10
|
+
import {WEBGLTextureView} from './webgl-texture-view';
|
|
9
11
|
import {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';
|
|
10
12
|
import {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';
|
|
11
13
|
|
|
12
|
-
export type
|
|
13
|
-
export type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;
|
|
14
|
+
export type Attachment = WEBGLTextureView | WEBGLTexture | WEBGLRenderbuffer;
|
|
14
15
|
|
|
15
16
|
/** luma.gl Framebuffer, WebGL implementation */
|
|
16
17
|
export class WEBGLFramebuffer extends Framebuffer {
|
|
@@ -45,26 +46,30 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
45
46
|
|
|
46
47
|
// Walk the attachments
|
|
47
48
|
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
48
|
-
const attachment = this.colorAttachments[i];
|
|
49
|
+
const attachment = this.colorAttachments[i] as WEBGLTextureView;
|
|
49
50
|
const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;
|
|
50
51
|
if (attachment) {
|
|
51
|
-
this._attachOne(attachmentPoint, attachment
|
|
52
|
+
this._attachOne(attachmentPoint, attachment);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
if (this.depthStencilAttachment) {
|
|
56
57
|
this._attachOne(
|
|
57
|
-
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),
|
|
58
|
-
this.depthStencilAttachment as
|
|
58
|
+
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format),
|
|
59
|
+
this.depthStencilAttachment as WEBGLTextureView
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
/** Check the status */
|
|
64
|
+
// @ts-expect-error
|
|
65
|
+
if (props.check !== false) {
|
|
66
|
+
const status = this.gl.checkFramebufferStatus(GL.FRAMEBUFFER) as GL;
|
|
67
|
+
if (status !== GL.FRAMEBUFFER_COMPLETE) {
|
|
68
|
+
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
if (props.check !== false) {
|
|
67
|
-
this._checkStatus();
|
|
72
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
|
|
@@ -79,18 +84,6 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
79
84
|
|
|
80
85
|
// PRIVATE
|
|
81
86
|
|
|
82
|
-
/** Check the status */
|
|
83
|
-
protected _checkStatus(): void {
|
|
84
|
-
const {gl} = this;
|
|
85
|
-
// TODO - should we really rely on this trick?
|
|
86
|
-
const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle) as unknown as WebGLFramebuffer;
|
|
87
|
-
const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);
|
|
88
|
-
gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
89
|
-
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
90
|
-
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
87
|
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
95
88
|
protected override createDepthStencilTexture(format: TextureFormat): Texture {
|
|
96
89
|
return new WEBGLRenderbuffer(this.device, {
|
|
@@ -103,8 +96,8 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
103
96
|
}) as unknown as WEBGLTexture;
|
|
104
97
|
}
|
|
105
98
|
|
|
106
|
-
/**
|
|
107
|
-
* Attachment resize is expected to be a noop if size is same
|
|
99
|
+
/**
|
|
100
|
+
* Attachment resize is expected to be a noop if size is same
|
|
108
101
|
*/
|
|
109
102
|
protected override resizeAttachments(width: number, height: number): this {
|
|
110
103
|
// for default framebuffer, just update the stored size
|
|
@@ -125,10 +118,10 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
125
118
|
// TODO Not clear that this is better than default destroy/create implementation
|
|
126
119
|
|
|
127
120
|
for (const colorAttachment of this.colorAttachments) {
|
|
128
|
-
(colorAttachment as WEBGLTexture).resize({width, height});
|
|
121
|
+
(colorAttachment.texture as WEBGLTexture).resize({width, height});
|
|
129
122
|
}
|
|
130
123
|
if (this.depthStencilAttachment) {
|
|
131
|
-
(this.depthStencilAttachment as WEBGLTexture).resize({width, height});
|
|
124
|
+
(this.depthStencilAttachment.texture as WEBGLTexture).resize({width, height});
|
|
132
125
|
}
|
|
133
126
|
return this;
|
|
134
127
|
}
|
|
@@ -148,6 +141,15 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
148
141
|
} else if (attachment instanceof WEBGLTexture) {
|
|
149
142
|
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
150
143
|
return attachment;
|
|
144
|
+
} else if (attachment instanceof WEBGLTextureView) {
|
|
145
|
+
const textureView = attachment;
|
|
146
|
+
this._attachTexture(
|
|
147
|
+
attachmentPoint,
|
|
148
|
+
textureView.texture,
|
|
149
|
+
textureView.props.baseMipLevel,
|
|
150
|
+
textureView.props.baseArrayLayer
|
|
151
|
+
);
|
|
152
|
+
return attachment.texture;
|
|
151
153
|
}
|
|
152
154
|
throw new Error('attach');
|
|
153
155
|
}
|
|
@@ -174,6 +176,7 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
174
176
|
level: number
|
|
175
177
|
): void {
|
|
176
178
|
const {gl} = this.device;
|
|
179
|
+
|
|
177
180
|
gl.bindTexture(texture.target, texture.handle);
|
|
178
181
|
|
|
179
182
|
switch (texture.target) {
|
|
@@ -206,7 +209,9 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
206
209
|
function mapIndexToCubeMapFace(layer: number | GL): GL {
|
|
207
210
|
// TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)
|
|
208
211
|
// if smaller assume layer is index, otherwise assume it is already a cube map face constant
|
|
209
|
-
return layer < (GL.TEXTURE_CUBE_MAP_POSITIVE_X as number)
|
|
212
|
+
return layer < (GL.TEXTURE_CUBE_MAP_POSITIVE_X as number)
|
|
213
|
+
? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X
|
|
214
|
+
: layer;
|
|
210
215
|
}
|
|
211
216
|
|
|
212
217
|
// Helper METHODS
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// WebGL2 Query (also handles disjoint timer extensions)
|
|
2
|
+
import {QuerySet, QuerySetProps} from '@luma.gl/core';
|
|
3
|
+
import {GL} from '@luma.gl/constants';
|
|
4
|
+
import {WebGLDevice} from '../webgl-device';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Asynchronous queries for different kinds of information
|
|
8
|
+
*/
|
|
9
|
+
export class WEBGLQuerySet extends QuerySet {
|
|
10
|
+
device: WebGLDevice;
|
|
11
|
+
handle: WebGLQuery;
|
|
12
|
+
|
|
13
|
+
target: number | null = null;
|
|
14
|
+
_queryPending = false;
|
|
15
|
+
_pollingPromise: Promise<any> | null = null;
|
|
16
|
+
|
|
17
|
+
override get [Symbol.toStringTag](): string {
|
|
18
|
+
return 'Query';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Create a query class
|
|
22
|
+
constructor(device: WebGLDevice, props: QuerySetProps) {
|
|
23
|
+
super(device, props);
|
|
24
|
+
this.device = device;
|
|
25
|
+
|
|
26
|
+
if (props.count > 1) {
|
|
27
|
+
throw new Error('WebGL QuerySet can only have one value');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.handle = this.device.gl.createQuery();
|
|
31
|
+
Object.seal(this);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override destroy() {
|
|
35
|
+
this.device.gl.deleteQuery(this.handle);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// FOR RENDER PASS AND COMMAND ENCODER
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Shortcut for timer query (dependent on extension in both WebGL1 and 2)
|
|
42
|
+
* Measures GPU time delta between this call and a matching `end` call in the
|
|
43
|
+
* GPU instruction stream.
|
|
44
|
+
*/
|
|
45
|
+
beginTimestampQuery(): void {
|
|
46
|
+
return this._begin(GL.TIME_ELAPSED_EXT);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
endTimestampQuery(): void {
|
|
50
|
+
this._end();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Shortcut for occlusion queries
|
|
54
|
+
beginOcclusionQuery(options?: {conservative?: boolean}): void {
|
|
55
|
+
return this._begin(
|
|
56
|
+
options?.conservative ? GL.ANY_SAMPLES_PASSED_CONSERVATIVE : GL.ANY_SAMPLES_PASSED
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
endOcclusionQuery() {
|
|
61
|
+
this._end();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Shortcut for transformFeedbackQuery
|
|
65
|
+
beginTransformFeedbackQuery(): void {
|
|
66
|
+
return this._begin(GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
endTransformFeedbackQuery(): void {
|
|
70
|
+
this._end();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async resolveQuery(): Promise<bigint[]> {
|
|
74
|
+
const value = await this.pollQuery();
|
|
75
|
+
return [value];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// PRIVATE METHODS
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Due to OpenGL API limitations, after calling `begin()` on one Query
|
|
82
|
+
* instance, `end()` must be called on that same instance before
|
|
83
|
+
* calling `begin()` on another query. While there can be multiple
|
|
84
|
+
* outstanding queries representing disjoint `begin()`/`end()` intervals.
|
|
85
|
+
* It is not possible to interleave or overlap `begin` and `end` calls.
|
|
86
|
+
*/
|
|
87
|
+
protected _begin(target: number): void {
|
|
88
|
+
// Don't start a new query if one is already active.
|
|
89
|
+
if (this._queryPending) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this.target = target;
|
|
94
|
+
this.device.gl.beginQuery(this.target, this.handle);
|
|
95
|
+
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ends the current query
|
|
100
|
+
protected _end(): void {
|
|
101
|
+
// Can't end a new query if the last one hasn't been resolved.
|
|
102
|
+
if (this._queryPending) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (this.target) {
|
|
107
|
+
this.device.gl.endQuery(this.target);
|
|
108
|
+
this.target = null;
|
|
109
|
+
this._queryPending = true;
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Returns true if the query result is available
|
|
115
|
+
isResultAvailable(): boolean {
|
|
116
|
+
if (!this._queryPending) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const resultAvailable = this.device.gl.getQueryParameter(
|
|
121
|
+
this.handle,
|
|
122
|
+
GL.QUERY_RESULT_AVAILABLE
|
|
123
|
+
);
|
|
124
|
+
if (resultAvailable) {
|
|
125
|
+
this._queryPending = false;
|
|
126
|
+
}
|
|
127
|
+
return resultAvailable;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Timing query is disjoint, i.e. results are invalid
|
|
131
|
+
isTimerDisjoint(): boolean {
|
|
132
|
+
return this.device.gl.getParameter(GL.GPU_DISJOINT_EXT);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Returns query result.
|
|
136
|
+
getResult(): any {
|
|
137
|
+
return this.device.gl.getQueryParameter(this.handle, GL.QUERY_RESULT);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Returns the query result, converted to milliseconds to match JavaScript conventions.
|
|
141
|
+
getTimerMilliseconds() {
|
|
142
|
+
return this.getResult() / 1e6;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Polls the query
|
|
146
|
+
pollQuery(limit: number = Number.POSITIVE_INFINITY): Promise<any> {
|
|
147
|
+
if (this._pollingPromise) {
|
|
148
|
+
return this._pollingPromise;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let counter = 0;
|
|
152
|
+
|
|
153
|
+
this._pollingPromise = new Promise((resolve, reject) => {
|
|
154
|
+
const poll = () => {
|
|
155
|
+
if (this.isResultAvailable()) {
|
|
156
|
+
resolve(this.getResult());
|
|
157
|
+
this._pollingPromise = null;
|
|
158
|
+
} else if (counter++ > limit) {
|
|
159
|
+
reject('Timed out');
|
|
160
|
+
this._pollingPromise = null;
|
|
161
|
+
} else {
|
|
162
|
+
requestAnimationFrame(poll);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
requestAnimationFrame(poll);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return this._pollingPromise;
|
|
170
|
+
}
|
|
171
|
+
}
|