@luma.gl/webgl 9.3.0-alpha.4 → 9.3.0-alpha.8
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 +30 -19
- package/dist/adapter/helpers/get-shader-layout-from-glsl.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 +20 -5
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +3 -3
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +22 -36
- 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-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 +25 -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 +69 -167
- 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 +27 -6
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +199 -101
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +1 -1
- 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-device.d.ts +6 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +36 -4
- 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/webgl-developer-tools.js +1 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/helpers/webgl-context-data.d.ts +1 -1
- package/dist/context/helpers/webgl-context-data.d.ts.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 +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts.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/dist.dev.js +1473 -824
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +3 -5491
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.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 +18 -4
- 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 +38 -20
- 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 +17 -5
- package/src/adapter/resources/webgl-command-buffer.ts +28 -28
- package/src/adapter/resources/webgl-command-encoder.ts +28 -11
- 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 +26 -13
- package/src/adapter/resources/webgl-render-pipeline.ts +101 -196
- 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 +324 -122
- package/src/adapter/resources/webgl-transform-feedback.ts +1 -1
- package/src/adapter/resources/webgl-vertex-array.ts +1 -1
- package/src/adapter/webgl-device.ts +50 -6
- 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/webgl-developer-tools.ts +1 -1
- package/src/context/helpers/webgl-context-data.ts +1 -1
- package/src/context/helpers/webgl-extensions.ts +1 -1
- package/src/context/parameters/unified-parameter-api.ts +1 -1
- package/src/context/parameters/webgl-parameter-tables.ts +1 -1
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +1 -1
- package/src/index.ts +26 -0
- 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
|
@@ -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, assertDefined} 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,
|
|
@@ -253,26 +253,44 @@ function readUniformBlocks(
|
|
|
253
253
|
// const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
|
|
254
254
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
255
255
|
const uniformIndex = uniformIndices[i];
|
|
256
|
-
if (uniformIndex
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
+
});
|
|
262
274
|
}
|
|
275
|
+
}
|
|
263
276
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
+
)();
|
|
276
294
|
}
|
|
277
295
|
|
|
278
296
|
uniformBlocks.push(blockInfo);
|
|
@@ -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 */
|
|
@@ -56,8 +56,12 @@ export class WEBGLBuffer extends Buffer {
|
|
|
56
56
|
override destroy(): void {
|
|
57
57
|
if (!this.destroyed && this.handle) {
|
|
58
58
|
this.removeStats();
|
|
59
|
-
this.
|
|
60
|
-
|
|
59
|
+
if (!this.props.handle) {
|
|
60
|
+
this.trackDeallocatedMemory();
|
|
61
|
+
this.gl.deleteBuffer(this.handle);
|
|
62
|
+
} else {
|
|
63
|
+
this.trackDeallocatedReferencedMemory('Buffer');
|
|
64
|
+
}
|
|
61
65
|
this.destroyed = true;
|
|
62
66
|
// @ts-expect-error
|
|
63
67
|
this.handle = null;
|
|
@@ -81,7 +85,11 @@ export class WEBGLBuffer extends Buffer {
|
|
|
81
85
|
this.byteLength = byteLength;
|
|
82
86
|
|
|
83
87
|
this._setDebugData(data, byteOffset, byteLength);
|
|
84
|
-
this.
|
|
88
|
+
if (!this.props.handle) {
|
|
89
|
+
this.trackAllocatedMemory(byteLength);
|
|
90
|
+
} else {
|
|
91
|
+
this.trackReferencedMemory(byteLength, 'Buffer');
|
|
92
|
+
}
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
// Allocate a GPU buffer of specified size.
|
|
@@ -107,7 +115,11 @@ export class WEBGLBuffer extends Buffer {
|
|
|
107
115
|
this.byteLength = byteLength;
|
|
108
116
|
|
|
109
117
|
this._setDebugData(null, 0, byteLength);
|
|
110
|
-
this.
|
|
118
|
+
if (!this.props.handle) {
|
|
119
|
+
this.trackAllocatedMemory(byteLength);
|
|
120
|
+
} else {
|
|
121
|
+
this.trackReferencedMemory(byteLength, 'Buffer');
|
|
122
|
+
}
|
|
111
123
|
|
|
112
124
|
return this;
|
|
113
125
|
}
|
|
@@ -3,24 +3,25 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
+
type CommandBufferProps,
|
|
6
7
|
type CopyBufferToBufferOptions,
|
|
7
8
|
type CopyBufferToTextureOptions,
|
|
8
9
|
type CopyTextureToBufferOptions,
|
|
9
10
|
type CopyTextureToTextureOptions,
|
|
11
|
+
type TextureReadOptions,
|
|
10
12
|
// type ClearTextureOptions,
|
|
11
|
-
// type TextureReadOptions
|
|
12
13
|
CommandBuffer,
|
|
13
14
|
Texture,
|
|
14
15
|
Framebuffer,
|
|
15
16
|
assertDefined
|
|
16
17
|
} from '@luma.gl/core';
|
|
17
|
-
import {GL, type GLTextureTarget, type GLTextureCubeMapTarget} from '@luma.gl/constants';
|
|
18
|
+
import {GL, type GLTextureTarget, type GLTextureCubeMapTarget} from '@luma.gl/webgl/constants';
|
|
18
19
|
|
|
20
|
+
import {getTextureFormatWebGL} from '../converters/webgl-texture-table';
|
|
19
21
|
import {WebGLDevice} from '../webgl-device';
|
|
20
22
|
import {WEBGLBuffer} from './webgl-buffer';
|
|
21
23
|
import {WEBGLTexture} from './webgl-texture';
|
|
22
24
|
import {WEBGLFramebuffer} from './webgl-framebuffer';
|
|
23
|
-
import {getTextureFormatWebGL} from '../converters/webgl-texture-table';
|
|
24
25
|
|
|
25
26
|
type CopyBufferToBufferCommand = {
|
|
26
27
|
name: 'copy-buffer-to-buffer';
|
|
@@ -65,8 +66,8 @@ export class WEBGLCommandBuffer extends CommandBuffer {
|
|
|
65
66
|
readonly handle = null;
|
|
66
67
|
commands: Command[] = [];
|
|
67
68
|
|
|
68
|
-
constructor(device: WebGLDevice) {
|
|
69
|
-
super(device,
|
|
69
|
+
constructor(device: WebGLDevice, props: CommandBufferProps = {}) {
|
|
70
|
+
super(device, props);
|
|
70
71
|
this.device = device;
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -118,8 +119,8 @@ function _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOpt
|
|
|
118
119
|
* Copies data from a Buffer object into a Texture object
|
|
119
120
|
* NOTE: doesn't wait for copy to be complete
|
|
120
121
|
*/
|
|
121
|
-
function _copyBufferToTexture(
|
|
122
|
-
throw new Error('
|
|
122
|
+
function _copyBufferToTexture(_device: WebGLDevice, _options: CopyBufferToTextureOptions): void {
|
|
123
|
+
throw new Error('copyBufferToTexture is not supported in WebGL');
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
/**
|
|
@@ -128,45 +129,44 @@ function _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureO
|
|
|
128
129
|
*/
|
|
129
130
|
function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {
|
|
130
131
|
const {
|
|
131
|
-
/** Texture to copy to/from. */
|
|
132
132
|
sourceTexture,
|
|
133
|
-
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
134
133
|
mipLevel = 0,
|
|
135
|
-
/** Defines which aspects of the texture to copy to/from. */
|
|
136
134
|
aspect = 'all',
|
|
137
|
-
|
|
138
|
-
/** Width to copy */
|
|
139
135
|
width = options.sourceTexture.width,
|
|
140
|
-
/** Height to copy */
|
|
141
136
|
height = options.sourceTexture.height,
|
|
142
|
-
depthOrArrayLayers
|
|
143
|
-
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
137
|
+
depthOrArrayLayers,
|
|
144
138
|
origin = [0, 0, 0],
|
|
145
|
-
|
|
146
|
-
/** Destination buffer */
|
|
147
139
|
destinationBuffer,
|
|
148
|
-
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
|
|
149
140
|
byteOffset = 0,
|
|
150
|
-
/**
|
|
151
|
-
* The stride, in bytes, between the beginning of each block row and the subsequent block row.
|
|
152
|
-
* Required if there are multiple block rows (i.e. the copy height or depth is more than one block).
|
|
153
|
-
*/
|
|
154
141
|
bytesPerRow,
|
|
155
|
-
/**
|
|
156
|
-
* Number of block rows per single image of the texture.
|
|
157
|
-
* rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.
|
|
158
|
-
* Required if there are multiple images (i.e. the copy depth is more than one).
|
|
159
|
-
*/
|
|
160
142
|
rowsPerImage
|
|
161
143
|
} = options;
|
|
162
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
|
+
|
|
163
163
|
// TODO - Not possible to read just stencil or depth part in WebGL?
|
|
164
164
|
if (aspect !== 'all') {
|
|
165
165
|
throw new Error('aspect not supported in WebGL');
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// TODO - mipLevels are set when attaching texture to framebuffer
|
|
169
|
-
if (mipLevel !== 0 || depthOrArrayLayers !==
|
|
169
|
+
if (mipLevel !== 0 || depthOrArrayLayers !== undefined || bytesPerRow || rowsPerImage) {
|
|
170
170
|
throw new Error('not implemented');
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -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
|
}
|
|
@@ -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
|