@luma.gl/webgl 9.2.5 → 9.3.0-alpha.10
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 +1 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +4 -1
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/shader-formats.d.ts +1 -64
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +1 -64
- package/dist/adapter/converters/shader-formats.js.map +1 -1
- package/dist/adapter/converters/webgl-shadertypes.d.ts +1 -3
- package/dist/adapter/converters/webgl-shadertypes.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-shadertypes.js +1 -6
- package/dist/adapter/converters/webgl-shadertypes.js.map +1 -1
- package/dist/adapter/converters/webgl-texture-table.d.ts +8 -4
- package/dist/adapter/converters/webgl-texture-table.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-texture-table.js +122 -58
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.d.ts +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.js +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -2
- package/dist/adapter/device-helpers/webgl-device-features.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +6 -1
- package/dist/adapter/device-helpers/webgl-device-info.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js.map +1 -1
- package/dist/adapter/helpers/format-utils.d.ts +1 -1
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/format-utils.js +1 -1
- package/dist/adapter/helpers/format-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js +36 -22
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +20 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +1 -1
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +4 -4
- package/dist/adapter/helpers/webgl-texture-utils.js.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -1
- 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 +21 -5
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +3 -4
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +29 -39
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +6 -5
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +23 -8
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-fence.d.ts +14 -0
- package/dist/adapter/resources/webgl-fence.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-fence.js +49 -0
- package/dist/adapter/resources/webgl-fence.js.map +1 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts +3 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +10 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-query-set.d.ts +37 -31
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-query-set.js +247 -96
- package/dist/adapter/resources/webgl-query-set.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +28 -11
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +17 -21
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +70 -169
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- 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 +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +15 -8
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-shared-render-pipeline.d.ts +24 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.js +155 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgl-texture.d.ts +42 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +286 -62
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +6 -6
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts +2 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -1
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +22 -23
- package/dist/adapter/webgl-adapter.js.map +1 -1
- 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 +16 -6
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +10 -5
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +75 -28
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/adapter/webgl-presentation-context.d.ts +21 -0
- package/dist/adapter/webgl-presentation-context.d.ts.map +1 -0
- package/dist/adapter/webgl-presentation-context.js +64 -0
- package/dist/adapter/webgl-presentation-context.js.map +1 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +5 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/webgl-constants.d.ts +822 -0
- package/dist/constants/webgl-constants.d.ts.map +1 -0
- package/dist/constants/webgl-constants.js +928 -0
- package/dist/constants/webgl-constants.js.map +1 -0
- package/dist/constants/webgl-types.d.ts +480 -0
- package/dist/constants/webgl-types.d.ts.map +1 -0
- package/dist/constants/webgl-types.js +6 -0
- package/dist/constants/webgl-types.js.map +1 -0
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +4 -4
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -7
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +46 -36
- package/dist/context/helpers/create-browser-context.js.map +1 -1
- package/dist/context/helpers/webgl-context-data.d.ts +5 -1
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -1
- package/dist/context/helpers/webgl-context-data.js +9 -10
- package/dist/context/helpers/webgl-context-data.js.map +1 -1
- package/dist/context/helpers/webgl-extensions.d.ts +1 -1
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +2 -2
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +2 -2
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +1 -1
- package/dist/context/polyfills/polyfill-webgl1-extensions.js.map +1 -1
- package/dist/context/state-tracker/webgl-state-tracker.js +2 -2
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -1
- package/dist/dist.dev.js +1897 -999
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +3 -5255
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/fill-array.js +1 -1
- package/dist/utils/fill-array.js.map +1 -1
- package/dist/webgl-constants.d.ts +2 -0
- package/dist/webgl-constants.d.ts.map +1 -0
- package/dist/webgl-constants.js +5 -0
- package/dist/webgl-constants.js.map +1 -0
- package/dist/webgl-types.d.ts +2 -0
- package/dist/webgl-types.d.ts.map +1 -0
- package/dist/{types.js → webgl-types.js} +1 -1
- package/dist/webgl-types.js.map +1 -0
- package/package.json +19 -5
- package/src/adapter/converters/device-parameters.ts +6 -2
- package/src/adapter/converters/sampler-parameters.ts +1 -1
- package/src/adapter/converters/shader-formats.ts +1 -66
- package/src/adapter/converters/webgl-shadertypes.ts +1 -9
- package/src/adapter/converters/webgl-texture-table.ts +160 -68
- package/src/adapter/converters/webgl-vertex-formats.ts +1 -1
- package/src/adapter/device-helpers/webgl-device-features.ts +2 -3
- package/src/adapter/device-helpers/webgl-device-info.ts +7 -1
- package/src/adapter/device-helpers/webgl-device-limits.ts +1 -1
- package/src/adapter/helpers/format-utils.ts +1 -1
- package/src/adapter/helpers/get-shader-layout-from-glsl.ts +44 -24
- package/src/adapter/helpers/parse-shader-compiler-log.ts +23 -1
- package/src/adapter/helpers/set-uniform.ts +1 -1
- package/src/adapter/helpers/webgl-texture-utils.ts +4 -4
- package/src/adapter/helpers/webgl-topology-utils.ts +1 -1
- package/src/adapter/resources/webgl-buffer.ts +18 -5
- package/src/adapter/resources/webgl-command-buffer.ts +44 -48
- package/src/adapter/resources/webgl-command-encoder.ts +28 -11
- package/src/adapter/resources/webgl-fence.ts +55 -0
- package/src/adapter/resources/webgl-framebuffer.ts +12 -1
- package/src/adapter/resources/webgl-query-set.ts +295 -101
- package/src/adapter/resources/webgl-render-pass.ts +30 -13
- package/src/adapter/resources/webgl-render-pipeline.ts +102 -198
- package/src/adapter/resources/webgl-sampler.ts +1 -1
- package/src/adapter/resources/webgl-shader.ts +15 -8
- package/src/adapter/resources/webgl-shared-render-pipeline.ts +211 -0
- package/src/adapter/resources/webgl-texture.ts +455 -81
- package/src/adapter/resources/webgl-transform-feedback.ts +6 -6
- package/src/adapter/resources/webgl-vertex-array.ts +1 -1
- package/src/adapter/webgl-adapter.ts +26 -24
- package/src/adapter/webgl-canvas-context.ts +19 -8
- package/src/adapter/webgl-device.ts +91 -35
- package/src/adapter/webgl-presentation-context.ts +93 -0
- package/src/constants/index.d.ts.map +1 -0
- package/src/constants/index.js.map +1 -0
- package/src/constants/index.ts +31 -0
- package/src/constants/webgl-constants.d.ts.map +1 -0
- package/src/constants/webgl-constants.js.map +1 -0
- package/src/constants/webgl-constants.ts +1051 -0
- package/src/constants/webgl-types.d.ts.map +1 -0
- package/src/constants/webgl-types.js.map +1 -0
- package/src/constants/webgl-types.ts +813 -0
- package/src/context/debug/spector.ts +4 -4
- package/src/context/debug/webgl-developer-tools.ts +16 -7
- package/src/context/helpers/create-browser-context.ts +54 -43
- package/src/context/helpers/webgl-context-data.ts +17 -11
- package/src/context/helpers/webgl-extensions.ts +1 -1
- package/src/context/parameters/unified-parameter-api.ts +3 -3
- package/src/context/parameters/webgl-parameter-tables.ts +1 -1
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +1 -1
- package/src/context/state-tracker/webgl-state-tracker.ts +2 -2
- package/src/index.ts +27 -0
- package/src/utils/fill-array.ts +1 -1
- package/src/webgl-constants.d.ts.map +1 -0
- package/src/webgl-constants.js.map +1 -0
- package/src/webgl-constants.ts +5 -0
- package/src/webgl-types.d.ts.map +1 -0
- package/src/webgl-types.js.map +1 -0
- package/src/webgl-types.ts +29 -0
- package/dist/types.d.ts +0 -11
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/types.ts +0 -14
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Provides a function that enables simple checking of which WebGL features are
|
|
7
7
|
|
|
8
8
|
import {DeviceFeature, DeviceFeatures} from '@luma.gl/core';
|
|
9
|
-
import {GLExtensions} from '@luma.gl/constants';
|
|
9
|
+
import {GLExtensions} from '@luma.gl/webgl/constants';
|
|
10
10
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
11
11
|
import {
|
|
12
12
|
isTextureFeature,
|
|
@@ -21,13 +21,12 @@ import {
|
|
|
21
21
|
const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
|
|
22
22
|
// optional WebGPU features
|
|
23
23
|
'depth-clip-control': 'EXT_depth_clamp', // TODO these seem subtly different
|
|
24
|
-
|
|
24
|
+
'timestamp-query': 'EXT_disjoint_timer_query_webgl2',
|
|
25
25
|
// "indirect-first-instance"
|
|
26
26
|
// Textures are handled by getTextureFeatures()
|
|
27
27
|
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
28
28
|
|
|
29
29
|
// optional WebGL features
|
|
30
|
-
'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',
|
|
31
30
|
'compilation-status-async-webgl': 'KHR_parallel_shader_compile',
|
|
32
31
|
'polygon-mode-webgl': 'WEBGL_polygon_mode',
|
|
33
32
|
'provoking-vertex-webgl': 'WEBGL_provoking_vertex',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {DeviceInfo} from '@luma.gl/core';
|
|
6
|
-
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
6
|
+
import {GL, GLExtensions} from '@luma.gl/webgl/constants';
|
|
7
7
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
8
8
|
|
|
9
9
|
/** @returns strings identifying the GPU vendor and driver. */
|
|
@@ -99,6 +99,8 @@ function identifyGPUType(
|
|
|
99
99
|
|
|
100
100
|
const gpuVendor = identifyGPUVendor(vendor, renderer);
|
|
101
101
|
switch (gpuVendor) {
|
|
102
|
+
case 'apple':
|
|
103
|
+
return isAppleSiliconGPU(vendor, renderer) ? 'integrated' : 'unknown';
|
|
102
104
|
case 'intel':
|
|
103
105
|
return 'integrated';
|
|
104
106
|
case 'software':
|
|
@@ -109,3 +111,7 @@ function identifyGPUType(
|
|
|
109
111
|
return 'discrete';
|
|
110
112
|
}
|
|
111
113
|
}
|
|
114
|
+
|
|
115
|
+
function isAppleSiliconGPU(vendor: string, renderer: string): boolean {
|
|
116
|
+
return /Apple (M\d|A\d|GPU)/i.test(`${vendor} ${renderer}`);
|
|
117
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {GL} from '@luma.gl/constants';
|
|
5
|
+
import {GL} from '@luma.gl/webgl/constants';
|
|
6
6
|
|
|
7
7
|
// Returns number of components in a specific readPixels WebGL format
|
|
8
8
|
export function glFormatToComponents(format: GL): 0 | 1 | 2 | 3 | 4 {
|
|
@@ -10,9 +10,9 @@ import type {
|
|
|
10
10
|
VaryingBinding,
|
|
11
11
|
AttributeShaderType
|
|
12
12
|
} from '@luma.gl/core';
|
|
13
|
-
import {getVariableShaderTypeInfo} from '@luma.gl/core';
|
|
13
|
+
import {getVariableShaderTypeInfo, assertDefined, log} from '@luma.gl/core';
|
|
14
14
|
|
|
15
|
-
import {GL, GLUniformType} from '@luma.gl/constants';
|
|
15
|
+
import {GL, GLUniformType} from '@luma.gl/webgl/constants';
|
|
16
16
|
import {
|
|
17
17
|
isGLSamplerType,
|
|
18
18
|
getTextureBindingFromGLSamplerType,
|
|
@@ -252,23 +252,45 @@ function readUniformBlocks(
|
|
|
252
252
|
// ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.
|
|
253
253
|
// const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
|
|
254
254
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
|
|
255
|
+
const uniformIndex = uniformIndices[i];
|
|
256
|
+
if (uniformIndex !== undefined) {
|
|
257
|
+
const activeInfo = gl.getActiveUniform(program, uniformIndex);
|
|
258
|
+
if (!activeInfo) {
|
|
259
|
+
throw new Error('activeInfo');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const format = convertGLUniformTypeToShaderVariableType(uniformType[i]);
|
|
263
|
+
|
|
264
|
+
blockInfo.uniforms.push({
|
|
265
|
+
name: activeInfo.name,
|
|
266
|
+
format,
|
|
267
|
+
type: uniformType[i],
|
|
268
|
+
arrayLength: uniformArrayLength[i],
|
|
269
|
+
byteOffset: uniformOffset[i],
|
|
270
|
+
byteStride: uniformStride[i]
|
|
271
|
+
// matrixStride: uniformStride[i],
|
|
272
|
+
// rowMajor: uniformRowMajor[i]
|
|
273
|
+
});
|
|
258
274
|
}
|
|
275
|
+
}
|
|
259
276
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
277
|
+
const uniformInstancePrefixes = new Set(
|
|
278
|
+
blockInfo.uniforms
|
|
279
|
+
.map(uniform => uniform.name.split('.')[0])
|
|
280
|
+
.filter((instanceName): instanceName is string => Boolean(instanceName))
|
|
281
|
+
);
|
|
282
|
+
const blockAlias = blockInfo.name.replace(/Uniforms$/, '');
|
|
283
|
+
if (
|
|
284
|
+
uniformInstancePrefixes.size === 1 &&
|
|
285
|
+
!uniformInstancePrefixes.has(blockInfo.name) &&
|
|
286
|
+
!uniformInstancePrefixes.has(blockAlias)
|
|
287
|
+
) {
|
|
288
|
+
const [instanceName] = uniformInstancePrefixes;
|
|
289
|
+
log.warn(
|
|
290
|
+
`Uniform block "${blockInfo.name}" uses GLSL instance "${instanceName}". ` +
|
|
291
|
+
`luma.gl binds uniform buffers by block name ("${blockInfo.name}") and alias ("${blockAlias}"). ` +
|
|
292
|
+
'Prefer matching the instance name to one of those to avoid confusing silent mismatches.'
|
|
293
|
+
)();
|
|
272
294
|
}
|
|
273
295
|
|
|
274
296
|
uniformBlocks.push(blockInfo);
|
|
@@ -314,13 +336,11 @@ function parseUniformName(name: string): {name: string; length: number; isArray:
|
|
|
314
336
|
// if array name then clean the array brackets
|
|
315
337
|
const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
|
|
316
338
|
const matches = UNIFORM_NAME_REGEXP.exec(name);
|
|
317
|
-
|
|
318
|
-
throw new Error(`Failed to parse GLSL uniform name ${name}`);
|
|
319
|
-
}
|
|
320
|
-
|
|
339
|
+
const uniformName = assertDefined(matches?.[1], `Failed to parse GLSL uniform name ${name}`);
|
|
321
340
|
return {
|
|
322
|
-
name:
|
|
323
|
-
|
|
324
|
-
|
|
341
|
+
name: uniformName,
|
|
342
|
+
// TODO - is this a bug, shouldn't we return the value?
|
|
343
|
+
length: matches?.[2] ? 1 : 0,
|
|
344
|
+
isArray: Boolean(matches?.[2])
|
|
325
345
|
};
|
|
326
346
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type
|
|
5
|
+
import {type CompilerMessage} from '@luma.gl/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Parse a WebGL-format GLSL compilation log into an array of WebGPU style message records.
|
|
@@ -20,21 +20,43 @@ export function parseShaderCompilerLog(errLog: string): readonly CompilerMessage
|
|
|
20
20
|
continue; // eslint-disable-line no-continue
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const lineWithTrimmedWhitespace = line.trim();
|
|
24
|
+
|
|
23
25
|
const segments: string[] = line.split(':');
|
|
26
|
+
const trimmedMessageType = segments[0]?.trim();
|
|
24
27
|
|
|
25
28
|
// Check for messages with no line information `ERROR: unsupported shader version`
|
|
26
29
|
if (segments.length === 2) {
|
|
27
30
|
const [messageType, message] = segments;
|
|
31
|
+
if (!messageType || !message) {
|
|
32
|
+
messages.push({
|
|
33
|
+
message: lineWithTrimmedWhitespace,
|
|
34
|
+
type: getMessageType(trimmedMessageType || 'info'),
|
|
35
|
+
lineNum: 0,
|
|
36
|
+
linePos: 0
|
|
37
|
+
});
|
|
38
|
+
continue; // eslint-disable-line no-continue
|
|
39
|
+
}
|
|
28
40
|
messages.push({
|
|
29
41
|
message: message.trim(),
|
|
30
42
|
type: getMessageType(messageType),
|
|
31
43
|
lineNum: 0,
|
|
32
44
|
linePos: 0
|
|
33
45
|
});
|
|
46
|
+
|
|
34
47
|
continue; // eslint-disable-line no-continue
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
const [messageType, linePosition, lineNumber, ...rest] = segments;
|
|
51
|
+
if (!messageType || !linePosition || !lineNumber) {
|
|
52
|
+
messages.push({
|
|
53
|
+
message: segments.slice(1).join(':').trim() || lineWithTrimmedWhitespace,
|
|
54
|
+
type: getMessageType(trimmedMessageType || 'info'),
|
|
55
|
+
lineNum: 0,
|
|
56
|
+
linePos: 0
|
|
57
|
+
});
|
|
58
|
+
continue; // eslint-disable-line no-continue
|
|
59
|
+
}
|
|
38
60
|
|
|
39
61
|
let lineNum = parseInt(lineNumber, 10);
|
|
40
62
|
if (isNaN(lineNum)) {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// Uniforms
|
|
8
8
|
import type {UniformValue} from '@luma.gl/core';
|
|
9
|
-
import {GL, GLUniformType, GLSamplerType} from '@luma.gl/constants';
|
|
9
|
+
import {GL, GLUniformType, GLSamplerType} from '@luma.gl/webgl/constants';
|
|
10
10
|
|
|
11
11
|
/** Set a raw uniform (without type conversion and caching) */
|
|
12
12
|
/* eslint-disable max-len */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// @ts-nocheck This file will be deleted in upcoming refactor
|
|
6
6
|
|
|
7
7
|
import type {Buffer, Texture, FramebufferProps} from '@luma.gl/core';
|
|
8
|
-
import {Framebuffer,
|
|
8
|
+
import {Framebuffer, dataTypeDecoder} from '@luma.gl/core';
|
|
9
9
|
import {
|
|
10
10
|
GL,
|
|
11
11
|
GLTextureTarget,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
GLTexelDataFormat,
|
|
14
14
|
GLPixelType,
|
|
15
15
|
GLDataType
|
|
16
|
-
} from '@luma.gl/constants';
|
|
16
|
+
} from '@luma.gl/webgl/constants';
|
|
17
17
|
|
|
18
18
|
import {convertDataTypeToGLDataType} from '../converters/webgl-shadertypes';
|
|
19
19
|
import {WEBGLFramebuffer} from '../resources/webgl-framebuffer';
|
|
@@ -232,7 +232,7 @@ export function readPixelsToArray(
|
|
|
232
232
|
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
233
233
|
|
|
234
234
|
// Pixel array available, if necessary, deduce type from it.
|
|
235
|
-
const signedType = getDataType(target);
|
|
235
|
+
const signedType = dataTypeDecoder.getDataType(target);
|
|
236
236
|
sourceType = sourceType || convertDataTypeToGLDataType(signedType);
|
|
237
237
|
|
|
238
238
|
// Note: luma.gl overrides bindFramebuffer so that we can reliably restore the previous framebuffer (this is the only function for which we do that)
|
|
@@ -484,7 +484,7 @@ function getPixelArray(
|
|
|
484
484
|
// Allocate pixel array if not already available, using supplied type
|
|
485
485
|
glType ||= GL.UNSIGNED_BYTE;
|
|
486
486
|
const shaderType = convertGLDataTypeToDataType(glType);
|
|
487
|
-
const ArrayType = getTypedArrayConstructor(shaderType);
|
|
487
|
+
const ArrayType = dataTypeDecoder.getTypedArrayConstructor(shaderType);
|
|
488
488
|
const components = glFormatToComponents(glFormat);
|
|
489
489
|
// TODO - check for composite type (components = 1).
|
|
490
490
|
return new ArrayType(width * height * components) as Uint8Array | Uint16Array | Float32Array;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {GL, GLPrimitiveTopology, GLPrimitive} from '@luma.gl/constants';
|
|
5
|
+
import {GL, GLPrimitiveTopology, GLPrimitive} from '@luma.gl/webgl/constants';
|
|
6
6
|
import {PrimitiveTopology} from '@luma.gl/core';
|
|
7
7
|
|
|
8
8
|
// Counts the number of complete primitives given a number of vertices and a drawMode
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {BufferMapCallback, BufferProps} from '@luma.gl/core';
|
|
6
6
|
import {Buffer} from '@luma.gl/core';
|
|
7
|
-
import {GL} from '@luma.gl/constants';
|
|
7
|
+
import {GL} from '@luma.gl/webgl/constants';
|
|
8
8
|
import {WebGLDevice} from '../webgl-device';
|
|
9
9
|
|
|
10
10
|
/** WebGL Buffer interface */
|
|
@@ -42,6 +42,7 @@ export class WEBGLBuffer extends Buffer {
|
|
|
42
42
|
// - In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here
|
|
43
43
|
this.glTarget = getWebGLTarget(this.props.usage);
|
|
44
44
|
this.glUsage = getWebGLUsage(this.props.usage);
|
|
45
|
+
// Note: uint8 indices are converted to uint16 during device normalization for WebGPU compatibility
|
|
45
46
|
this.glIndexType = this.props.indexType === 'uint32' ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;
|
|
46
47
|
|
|
47
48
|
// Set data: (re)initializes the buffer
|
|
@@ -55,8 +56,12 @@ export class WEBGLBuffer extends Buffer {
|
|
|
55
56
|
override destroy(): void {
|
|
56
57
|
if (!this.destroyed && this.handle) {
|
|
57
58
|
this.removeStats();
|
|
58
|
-
this.
|
|
59
|
-
|
|
59
|
+
if (!this.props.handle) {
|
|
60
|
+
this.trackDeallocatedMemory();
|
|
61
|
+
this.gl.deleteBuffer(this.handle);
|
|
62
|
+
} else {
|
|
63
|
+
this.trackDeallocatedReferencedMemory('Buffer');
|
|
64
|
+
}
|
|
60
65
|
this.destroyed = true;
|
|
61
66
|
// @ts-expect-error
|
|
62
67
|
this.handle = null;
|
|
@@ -80,7 +85,11 @@ export class WEBGLBuffer extends Buffer {
|
|
|
80
85
|
this.byteLength = byteLength;
|
|
81
86
|
|
|
82
87
|
this._setDebugData(data, byteOffset, byteLength);
|
|
83
|
-
this.
|
|
88
|
+
if (!this.props.handle) {
|
|
89
|
+
this.trackAllocatedMemory(byteLength);
|
|
90
|
+
} else {
|
|
91
|
+
this.trackReferencedMemory(byteLength, 'Buffer');
|
|
92
|
+
}
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
// Allocate a GPU buffer of specified size.
|
|
@@ -106,7 +115,11 @@ export class WEBGLBuffer extends Buffer {
|
|
|
106
115
|
this.byteLength = byteLength;
|
|
107
116
|
|
|
108
117
|
this._setDebugData(null, 0, byteLength);
|
|
109
|
-
this.
|
|
118
|
+
if (!this.props.handle) {
|
|
119
|
+
this.trackAllocatedMemory(byteLength);
|
|
120
|
+
} else {
|
|
121
|
+
this.trackReferencedMemory(byteLength, 'Buffer');
|
|
122
|
+
}
|
|
110
123
|
|
|
111
124
|
return this;
|
|
112
125
|
}
|
|
@@ -2,29 +2,26 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
CopyBufferToBufferOptions,
|
|
7
|
-
CopyBufferToTextureOptions,
|
|
8
|
-
CopyTextureToBufferOptions,
|
|
9
|
-
CopyTextureToTextureOptions
|
|
10
|
-
// ClearTextureOptions,
|
|
11
|
-
// TextureReadOptions
|
|
12
|
-
} from '@luma.gl/core';
|
|
13
|
-
import {CommandBuffer, Texture, Framebuffer} from '@luma.gl/core';
|
|
14
5
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
type CommandBufferProps,
|
|
7
|
+
type CopyBufferToBufferOptions,
|
|
8
|
+
type CopyBufferToTextureOptions,
|
|
9
|
+
type CopyTextureToBufferOptions,
|
|
10
|
+
type CopyTextureToTextureOptions,
|
|
11
|
+
type TextureReadOptions,
|
|
12
|
+
// type ClearTextureOptions,
|
|
13
|
+
CommandBuffer,
|
|
14
|
+
Texture,
|
|
15
|
+
Framebuffer,
|
|
16
|
+
assertDefined
|
|
17
|
+
} from '@luma.gl/core';
|
|
18
|
+
import {GL, type GLTextureTarget, type GLTextureCubeMapTarget} from '@luma.gl/webgl/constants';
|
|
22
19
|
|
|
20
|
+
import {getTextureFormatWebGL} from '../converters/webgl-texture-table';
|
|
23
21
|
import {WebGLDevice} from '../webgl-device';
|
|
24
22
|
import {WEBGLBuffer} from './webgl-buffer';
|
|
25
23
|
import {WEBGLTexture} from './webgl-texture';
|
|
26
24
|
import {WEBGLFramebuffer} from './webgl-framebuffer';
|
|
27
|
-
import {getTextureFormatWebGL} from '../converters/webgl-texture-table';
|
|
28
25
|
|
|
29
26
|
type CopyBufferToBufferCommand = {
|
|
30
27
|
name: 'copy-buffer-to-buffer';
|
|
@@ -69,8 +66,8 @@ export class WEBGLCommandBuffer extends CommandBuffer {
|
|
|
69
66
|
readonly handle = null;
|
|
70
67
|
commands: Command[] = [];
|
|
71
68
|
|
|
72
|
-
constructor(device: WebGLDevice) {
|
|
73
|
-
super(device,
|
|
69
|
+
constructor(device: WebGLDevice, props: CommandBufferProps = {}) {
|
|
70
|
+
super(device, props);
|
|
74
71
|
this.device = device;
|
|
75
72
|
}
|
|
76
73
|
|
|
@@ -122,8 +119,8 @@ function _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOpt
|
|
|
122
119
|
* Copies data from a Buffer object into a Texture object
|
|
123
120
|
* NOTE: doesn't wait for copy to be complete
|
|
124
121
|
*/
|
|
125
|
-
function _copyBufferToTexture(
|
|
126
|
-
throw new Error('
|
|
122
|
+
function _copyBufferToTexture(_device: WebGLDevice, _options: CopyBufferToTextureOptions): void {
|
|
123
|
+
throw new Error('copyBufferToTexture is not supported in WebGL');
|
|
127
124
|
}
|
|
128
125
|
|
|
129
126
|
/**
|
|
@@ -132,45 +129,44 @@ function _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureO
|
|
|
132
129
|
*/
|
|
133
130
|
function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {
|
|
134
131
|
const {
|
|
135
|
-
/** Texture to copy to/from. */
|
|
136
132
|
sourceTexture,
|
|
137
|
-
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
138
133
|
mipLevel = 0,
|
|
139
|
-
/** Defines which aspects of the texture to copy to/from. */
|
|
140
134
|
aspect = 'all',
|
|
141
|
-
|
|
142
|
-
/** Width to copy */
|
|
143
135
|
width = options.sourceTexture.width,
|
|
144
|
-
/** Height to copy */
|
|
145
136
|
height = options.sourceTexture.height,
|
|
146
|
-
depthOrArrayLayers
|
|
147
|
-
|
|
148
|
-
origin = [0, 0],
|
|
149
|
-
|
|
150
|
-
/** Destination buffer */
|
|
137
|
+
depthOrArrayLayers,
|
|
138
|
+
origin = [0, 0, 0],
|
|
151
139
|
destinationBuffer,
|
|
152
|
-
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
|
|
153
140
|
byteOffset = 0,
|
|
154
|
-
/**
|
|
155
|
-
* The stride, in bytes, between the beginning of each block row and the subsequent block row.
|
|
156
|
-
* Required if there are multiple block rows (i.e. the copy height or depth is more than one block).
|
|
157
|
-
*/
|
|
158
141
|
bytesPerRow,
|
|
159
|
-
/**
|
|
160
|
-
* Number of block rows per single image of the texture.
|
|
161
|
-
* rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.
|
|
162
|
-
* Required if there are multiple images (i.e. the copy depth is more than one).
|
|
163
|
-
*/
|
|
164
142
|
rowsPerImage
|
|
165
143
|
} = options;
|
|
166
144
|
|
|
145
|
+
if (sourceTexture instanceof Texture) {
|
|
146
|
+
sourceTexture.readBuffer(
|
|
147
|
+
{
|
|
148
|
+
x: origin[0] ?? 0,
|
|
149
|
+
y: origin[1] ?? 0,
|
|
150
|
+
z: origin[2] ?? 0,
|
|
151
|
+
width,
|
|
152
|
+
height,
|
|
153
|
+
depthOrArrayLayers,
|
|
154
|
+
mipLevel,
|
|
155
|
+
aspect,
|
|
156
|
+
byteOffset
|
|
157
|
+
} as TextureReadOptions & {byteOffset?: number},
|
|
158
|
+
destinationBuffer
|
|
159
|
+
);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
167
163
|
// TODO - Not possible to read just stencil or depth part in WebGL?
|
|
168
164
|
if (aspect !== 'all') {
|
|
169
165
|
throw new Error('aspect not supported in WebGL');
|
|
170
166
|
}
|
|
171
167
|
|
|
172
168
|
// TODO - mipLevels are set when attaching texture to framebuffer
|
|
173
|
-
if (mipLevel !== 0 || depthOrArrayLayers !==
|
|
169
|
+
if (mipLevel !== 0 || depthOrArrayLayers !== undefined || bytesPerRow || rowsPerImage) {
|
|
174
170
|
throw new Error('not implemented');
|
|
175
171
|
}
|
|
176
172
|
|
|
@@ -181,9 +177,9 @@ function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferO
|
|
|
181
177
|
const webglBuffer = destinationBuffer as WEBGLBuffer;
|
|
182
178
|
const sourceWidth = width || framebuffer.width;
|
|
183
179
|
const sourceHeight = height || framebuffer.height;
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
);
|
|
180
|
+
const colorAttachment0 = assertDefined(framebuffer.colorAttachments[0]);
|
|
181
|
+
|
|
182
|
+
const sourceParams = getTextureFormatWebGL(colorAttachment0.texture.props.format);
|
|
187
183
|
const sourceFormat = sourceParams.format;
|
|
188
184
|
const sourceType = sourceParams.type;
|
|
189
185
|
|
|
@@ -256,7 +252,7 @@ function _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextur
|
|
|
256
252
|
origin = [0, 0],
|
|
257
253
|
|
|
258
254
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */
|
|
259
|
-
destinationOrigin = [0, 0],
|
|
255
|
+
destinationOrigin = [0, 0, 0],
|
|
260
256
|
|
|
261
257
|
/** Texture to copy to/from. */
|
|
262
258
|
destinationTexture
|
|
@@ -275,7 +271,7 @@ function _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextur
|
|
|
275
271
|
} = options;
|
|
276
272
|
|
|
277
273
|
const {framebuffer, destroyFramebuffer} = getFramebuffer(sourceTexture);
|
|
278
|
-
const [sourceX, sourceY] = origin;
|
|
274
|
+
const [sourceX = 0, sourceY = 0] = origin;
|
|
279
275
|
const [destinationX, destinationY, destinationZ] = destinationOrigin;
|
|
280
276
|
|
|
281
277
|
// @ts-expect-error native bindFramebuffer is overridden by our state tracker
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {CommandEncoder, CommandEncoderProps} from '@luma.gl/core';
|
|
5
|
+
import {CommandBufferProps, CommandEncoder, CommandEncoderProps} from '@luma.gl/core';
|
|
6
6
|
import type {
|
|
7
7
|
RenderPassProps,
|
|
8
8
|
ComputePass,
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
import {WEBGLCommandBuffer} from './webgl-command-buffer';
|
|
21
21
|
import {WEBGLRenderPass} from './webgl-render-pass';
|
|
22
22
|
import {WebGLDevice} from '../webgl-device';
|
|
23
|
+
import {WEBGLQuerySet} from './webgl-query-set';
|
|
23
24
|
|
|
24
25
|
export class WEBGLCommandEncoder extends CommandEncoder {
|
|
25
26
|
readonly device: WebGLDevice;
|
|
@@ -30,20 +31,29 @@ export class WEBGLCommandEncoder extends CommandEncoder {
|
|
|
30
31
|
constructor(device: WebGLDevice, props: CommandEncoderProps) {
|
|
31
32
|
super(device, props);
|
|
32
33
|
this.device = device;
|
|
33
|
-
this.commandBuffer = new WEBGLCommandBuffer(device
|
|
34
|
+
this.commandBuffer = new WEBGLCommandBuffer(device, {
|
|
35
|
+
id: `${this.props.id}-command-buffer`
|
|
36
|
+
});
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
override destroy(): void {
|
|
39
|
+
override destroy(): void {
|
|
40
|
+
this.destroyResource();
|
|
41
|
+
}
|
|
37
42
|
|
|
38
|
-
override finish(): WEBGLCommandBuffer {
|
|
43
|
+
override finish(props?: CommandBufferProps): WEBGLCommandBuffer {
|
|
44
|
+
if (props?.id && this.commandBuffer.id !== props.id) {
|
|
45
|
+
this.commandBuffer.id = props.id;
|
|
46
|
+
this.commandBuffer.props.id = props.id;
|
|
47
|
+
}
|
|
48
|
+
this.destroy();
|
|
39
49
|
return this.commandBuffer;
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
beginRenderPass(props: RenderPassProps): WEBGLRenderPass {
|
|
43
|
-
return new WEBGLRenderPass(this.device, props);
|
|
52
|
+
beginRenderPass(props: RenderPassProps = {}): WEBGLRenderPass {
|
|
53
|
+
return new WEBGLRenderPass(this.device, this._applyTimeProfilingToPassProps(props));
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
beginComputePass(props: ComputePassProps): ComputePass {
|
|
56
|
+
beginComputePass(props: ComputePassProps = {}): ComputePass {
|
|
47
57
|
throw new Error('ComputePass not supported in WebGL');
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -73,12 +83,19 @@ export class WEBGLCommandEncoder extends CommandEncoder {
|
|
|
73
83
|
override insertDebugMarker(markerLabel: string): void {}
|
|
74
84
|
|
|
75
85
|
override resolveQuerySet(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
_querySet: QuerySet,
|
|
87
|
+
_destination: Buffer,
|
|
88
|
+
_options?: {
|
|
79
89
|
firstQuery?: number;
|
|
80
90
|
queryCount?: number;
|
|
81
91
|
destinationOffset?: number;
|
|
82
92
|
}
|
|
83
|
-
): void {
|
|
93
|
+
): void {
|
|
94
|
+
throw new Error('resolveQuerySet is not supported in WebGL');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
writeTimestamp(querySet: QuerySet, queryIndex: number): void {
|
|
98
|
+
const webglQuerySet = querySet as WEBGLQuerySet;
|
|
99
|
+
webglQuerySet.writeTimestamp(queryIndex);
|
|
100
|
+
}
|
|
84
101
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Fence, type FenceProps} from '@luma.gl/core';
|
|
6
|
+
import {WebGLDevice} from '../webgl-device';
|
|
7
|
+
|
|
8
|
+
/** WebGL fence implemented with gl.fenceSync */
|
|
9
|
+
export class WEBGLFence extends Fence {
|
|
10
|
+
readonly device: WebGLDevice;
|
|
11
|
+
readonly gl: WebGL2RenderingContext;
|
|
12
|
+
readonly handle: WebGLSync;
|
|
13
|
+
readonly signaled: Promise<void>;
|
|
14
|
+
private _signaled = false;
|
|
15
|
+
|
|
16
|
+
constructor(device: WebGLDevice, props: FenceProps = {}) {
|
|
17
|
+
super(device, {});
|
|
18
|
+
this.device = device;
|
|
19
|
+
this.gl = device.gl;
|
|
20
|
+
|
|
21
|
+
const sync = this.props.handle || this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
22
|
+
if (!sync) {
|
|
23
|
+
throw new Error('Failed to create WebGL fence');
|
|
24
|
+
}
|
|
25
|
+
this.handle = sync;
|
|
26
|
+
|
|
27
|
+
this.signaled = new Promise(resolve => {
|
|
28
|
+
const poll = () => {
|
|
29
|
+
const status = this.gl.clientWaitSync(this.handle, 0, 0);
|
|
30
|
+
if (status === this.gl.ALREADY_SIGNALED || status === this.gl.CONDITION_SATISFIED) {
|
|
31
|
+
this._signaled = true;
|
|
32
|
+
resolve();
|
|
33
|
+
} else {
|
|
34
|
+
setTimeout(poll, 1);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
poll();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
isSignaled(): boolean {
|
|
42
|
+
if (this._signaled) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
const status = this.gl.getSyncParameter(this.handle, this.gl.SYNC_STATUS);
|
|
46
|
+
this._signaled = status === this.gl.SIGNALED;
|
|
47
|
+
return this._signaled;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
destroy(): void {
|
|
51
|
+
if (!this.destroyed) {
|
|
52
|
+
this.gl.deleteSync(this.handle);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {FramebufferProps} from '@luma.gl/core';
|
|
6
6
|
import {Framebuffer} from '@luma.gl/core';
|
|
7
|
-
import {GL} from '@luma.gl/constants';
|
|
7
|
+
import {GL} from '@luma.gl/webgl/constants';
|
|
8
8
|
import {WebGLDevice} from '../webgl-device';
|
|
9
9
|
import {WEBGLTexture} from './webgl-texture';
|
|
10
10
|
import {WEBGLTextureView} from './webgl-texture-view';
|
|
@@ -137,6 +137,17 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
137
137
|
|
|
138
138
|
gl.bindTexture(texture.glTarget, null);
|
|
139
139
|
}
|
|
140
|
+
|
|
141
|
+
/** Default framebuffer resize is managed by canvas size and should be a no-op. */
|
|
142
|
+
protected override resizeAttachments(width: number, height: number): void {
|
|
143
|
+
if (this.handle === null) {
|
|
144
|
+
this.width = width;
|
|
145
|
+
this.height = height;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
super.resizeAttachments(width, height);
|
|
150
|
+
}
|
|
140
151
|
}
|
|
141
152
|
|
|
142
153
|
// Helper functions
|