@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.7
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 +128 -71
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +20 -19
- 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 +16 -11
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +224 -205
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +22 -21
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +89 -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 +22 -19
- 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 +47 -46
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +35 -34
- 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 +42 -41
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
- 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 +30 -17
- 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 -101
- 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 +16 -15
- 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 +32 -31
- 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 +6 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +60 -53
- 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 +20 -12
- 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 +52 -61
- 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 +5 -4
- 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 +15 -9
- 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 +6 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +39 -32
- 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 +10 -10
- 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 +10 -9
- 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 +35 -30
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +110 -109
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +8 -7
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +5 -4
- 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 +19 -19
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +16 -15
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +20 -19
- 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/{context → helpers}/create-browser-context.d.ts.map +1 -1
- package/dist/context/{context → helpers}/create-browser-context.js +2 -1
- package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
- 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 +3 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +7 -11
- package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +302 -295
- 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 +2 -3
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -8
- package/dist/dist.dev.js +1635 -1387
- package/dist/index.cjs +1766 -1534
- 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 +6 -6
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +114 -27
- 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 +138 -114
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
- 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 +36 -14
- package/src/adapter/objects/webgl-resource.ts +7 -125
- 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 +6 -5
- package/src/adapter/resources/webgl-framebuffer.ts +61 -53
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +20 -11
- package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
- 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 +14 -3
- 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 +116 -107
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +14 -8
- 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 +6 -17
- 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 +8 -8
- package/src/index.ts +7 -6
- package/src/types.ts +2 -1
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js +0 -87
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/src/context/context/context-data.ts +0 -44
- /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
|
@@ -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
|
/**
|
|
@@ -27,13 +25,13 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
|
|
|
27
25
|
constructor(device: Device, props: Props, defaultProps: Required<Props>) {
|
|
28
26
|
super(device, props, defaultProps);
|
|
29
27
|
|
|
30
|
-
this.device = WebGLDevice
|
|
28
|
+
this.device = device as WebGLDevice;
|
|
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
|
/*
|
|
@@ -52,12 +53,12 @@ export class WEBGLExternalTexture extends WEBGLTexture {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
// eslint-disable-next-line max-statements
|
|
55
|
-
constructor(device: Device
|
|
56
|
-
super(WebGLDevice
|
|
56
|
+
constructor(device: Device , props: TextureProps) {
|
|
57
|
+
super(device as WebGLDevice, {id: uid('texture'), ...props});
|
|
57
58
|
|
|
58
59
|
this.glTarget = getWebGLTextureTarget(props);
|
|
59
60
|
|
|
60
|
-
this.device = WebGLDevice
|
|
61
|
+
this.device = device as WebGLDevice;
|
|
61
62
|
this.gl = this.device.gl;
|
|
62
63
|
this.gl2 = this.device.gl2;
|
|
63
64
|
this.handle = this.props.handle || this.gl.createTexture();
|
|
@@ -91,4 +92,4 @@ export class WEBGLExternalTexture extends WEBGLTexture {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
|
|
94
|
-
*/
|
|
95
|
+
*/
|
|
@@ -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,13 @@ 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';
|
|
9
|
-
import {
|
|
10
|
+
import {WEBGLTextureView} from './webgl-texture-view';
|
|
10
11
|
import {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
// TODO - for now we don't see a usage for renderbuffers in WebGL 2.
|
|
14
|
+
// import {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';
|
|
15
|
+
|
|
16
|
+
export type Attachment = WEBGLTextureView | WEBGLTexture; // | WEBGLRenderbuffer;
|
|
14
17
|
|
|
15
18
|
/** luma.gl Framebuffer, WebGL implementation */
|
|
16
19
|
export class WEBGLFramebuffer extends Framebuffer {
|
|
@@ -45,26 +48,30 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
45
48
|
|
|
46
49
|
// Walk the attachments
|
|
47
50
|
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
48
|
-
const attachment = this.colorAttachments[i];
|
|
51
|
+
const attachment = this.colorAttachments[i] as WEBGLTextureView;
|
|
49
52
|
const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;
|
|
50
53
|
if (attachment) {
|
|
51
|
-
this._attachOne(attachmentPoint, attachment
|
|
54
|
+
this._attachOne(attachmentPoint, attachment);
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
if (this.depthStencilAttachment) {
|
|
56
59
|
this._attachOne(
|
|
57
|
-
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),
|
|
58
|
-
this.depthStencilAttachment as
|
|
60
|
+
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format),
|
|
61
|
+
this.depthStencilAttachment as WEBGLTextureView
|
|
59
62
|
);
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
/** Check the status */
|
|
66
|
+
// @ts-expect-error
|
|
67
|
+
if (props.check !== false) {
|
|
68
|
+
const status = this.gl.checkFramebufferStatus(GL.FRAMEBUFFER) as GL;
|
|
69
|
+
if (status !== GL.FRAMEBUFFER_COMPLETE) {
|
|
70
|
+
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
if (props.check !== false) {
|
|
67
|
-
this._checkStatus();
|
|
74
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
77
|
|
|
@@ -79,32 +86,20 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
79
86
|
|
|
80
87
|
// PRIVATE
|
|
81
88
|
|
|
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
89
|
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
95
90
|
protected override createDepthStencilTexture(format: TextureFormat): Texture {
|
|
96
|
-
return new WEBGLRenderbuffer(this.device, {
|
|
97
|
-
|
|
91
|
+
// return new WEBGLRenderbuffer(this.device, {
|
|
92
|
+
return new WEBGLTexture(this.device, {
|
|
93
|
+
id: `${this.id}-depth-stencil`,
|
|
98
94
|
format,
|
|
99
|
-
// dataFormat: GL.DEPTH_STENCIL,
|
|
100
|
-
// type: GL.UNSIGNED_INT_24_8,
|
|
101
95
|
width: this.width,
|
|
102
|
-
height: this.height
|
|
103
|
-
|
|
96
|
+
height: this.height,
|
|
97
|
+
mipmaps: false
|
|
98
|
+
});
|
|
104
99
|
}
|
|
105
100
|
|
|
106
|
-
/**
|
|
107
|
-
* Attachment resize is expected to be a noop if size is same
|
|
101
|
+
/**
|
|
102
|
+
* Attachment resize is expected to be a noop if size is same
|
|
108
103
|
*/
|
|
109
104
|
protected override resizeAttachments(width: number, height: number): this {
|
|
110
105
|
// for default framebuffer, just update the stored size
|
|
@@ -125,41 +120,51 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
125
120
|
// TODO Not clear that this is better than default destroy/create implementation
|
|
126
121
|
|
|
127
122
|
for (const colorAttachment of this.colorAttachments) {
|
|
128
|
-
(colorAttachment as WEBGLTexture).resize({width, height});
|
|
123
|
+
(colorAttachment.texture as WEBGLTexture).resize({width, height});
|
|
129
124
|
}
|
|
130
125
|
if (this.depthStencilAttachment) {
|
|
131
|
-
(this.depthStencilAttachment as WEBGLTexture).resize({width, height});
|
|
126
|
+
(this.depthStencilAttachment.texture as WEBGLTexture).resize({width, height});
|
|
132
127
|
}
|
|
133
128
|
return this;
|
|
134
129
|
}
|
|
135
130
|
|
|
136
131
|
/** Attach one attachment */
|
|
137
|
-
protected _attachOne(
|
|
138
|
-
|
|
139
|
-
attachment
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return attachment;
|
|
144
|
-
} else if (Array.isArray(attachment)) {
|
|
132
|
+
protected _attachOne(attachmentPoint: GL, attachment: Attachment): WEBGLTexture {
|
|
133
|
+
// if (attachment instanceof WEBGLRenderbuffer) {
|
|
134
|
+
// this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
135
|
+
// return attachment;
|
|
136
|
+
// }
|
|
137
|
+
if (Array.isArray(attachment)) {
|
|
145
138
|
const [texture, layer = 0, level = 0] = attachment;
|
|
146
139
|
this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);
|
|
147
140
|
return texture as unknown as WEBGLTexture;
|
|
148
|
-
}
|
|
141
|
+
}
|
|
142
|
+
if (attachment instanceof WEBGLTexture) {
|
|
149
143
|
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
150
144
|
return attachment;
|
|
151
145
|
}
|
|
146
|
+
if (attachment instanceof WEBGLTextureView) {
|
|
147
|
+
const textureView = attachment;
|
|
148
|
+
this._attachTexture(
|
|
149
|
+
attachmentPoint,
|
|
150
|
+
textureView.texture,
|
|
151
|
+
textureView.props.baseMipLevel,
|
|
152
|
+
textureView.props.baseArrayLayer
|
|
153
|
+
);
|
|
154
|
+
return attachment.texture;
|
|
155
|
+
}
|
|
152
156
|
throw new Error('attach');
|
|
153
157
|
}
|
|
154
158
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
// TODO - we do not seem to need render buffers in WebGL 2
|
|
160
|
+
// protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {
|
|
161
|
+
// this.gl.framebufferRenderbuffer(
|
|
162
|
+
// GL.FRAMEBUFFER,
|
|
163
|
+
// attachment,
|
|
164
|
+
// GL.RENDERBUFFER,
|
|
165
|
+
// renderbuffer.handle
|
|
166
|
+
// );
|
|
167
|
+
// }
|
|
163
168
|
|
|
164
169
|
/**
|
|
165
170
|
* @param attachment
|
|
@@ -174,6 +179,7 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
174
179
|
level: number
|
|
175
180
|
): void {
|
|
176
181
|
const {gl} = this.device;
|
|
182
|
+
|
|
177
183
|
gl.bindTexture(texture.target, texture.handle);
|
|
178
184
|
|
|
179
185
|
switch (texture.target) {
|
|
@@ -206,7 +212,9 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
206
212
|
function mapIndexToCubeMapFace(layer: number | GL): GL {
|
|
207
213
|
// TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)
|
|
208
214
|
// 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)
|
|
215
|
+
return layer < (GL.TEXTURE_CUBE_MAP_POSITIVE_X as number)
|
|
216
|
+
? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X
|
|
217
|
+
: layer;
|
|
210
218
|
}
|
|
211
219
|
|
|
212
220
|
// 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
|
+
}
|