@luma.gl/webgl 9.0.0-beta.4 → 9.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +297 -155
- package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +73 -67
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +53 -46
- package/dist/adapter/converters/texture-formats.d.ts +13 -19
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +474 -879
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +53 -61
- package/dist/adapter/device-helpers/device-features.d.ts +2 -5
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +56 -87
- package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +88 -83
- package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +79 -63
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.js +86 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +5 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +90 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +35 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +47 -0
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +88 -76
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +261 -225
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +47 -37
- 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 +68 -82
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +78 -93
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +19 -12
- 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 +86 -77
- package/dist/adapter/objects/webgl-resource.d.ts +3 -25
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +102 -146
- package/dist/adapter/resources/webgl-buffer.d.ts +3 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +161 -119
- 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 +266 -168
- 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 +33 -39
- package/dist/adapter/resources/webgl-external-texture.js +93 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +8 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +167 -137
- 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 +124 -90
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +15 -6
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +356 -221
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -3
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +43 -33
- package/dist/adapter/resources/webgl-shader.d.ts +12 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +114 -47
- 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 -9
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +615 -695
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +2 -2
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +141 -143
- 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 +229 -157
- 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 +58 -36
- package/dist/adapter/webgl-device.d.ts +34 -40
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +418 -363
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +132 -101
- package/dist/classic/clear.d.ts +2 -2
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +73 -72
- 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 +175 -175
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +39 -32
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +96 -81
- package/dist/context/context/context-data.d.ts +14 -0
- package/dist/context/context/context-data.d.ts.map +1 -0
- package/dist/context/context/context-data.js +33 -0
- package/dist/context/context/create-browser-context.d.ts +1 -6
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +62 -49
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +55 -50
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +104 -77
- package/dist/context/helpers/create-browser-context.d.ts +35 -0
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
- package/dist/context/helpers/create-browser-context.js +67 -0
- package/dist/context/{polyfill/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -2
- 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 -3
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +94 -44
- package/dist/context/parameters/webgl-parameter-tables.d.ts +120 -99
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +469 -404
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +19 -14
- package/dist/context/state-tracker/track-context-state.d.ts +4 -4
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +188 -123
- package/dist/context/state-tracker/with-parameters.d.ts +2 -2
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +43 -26
- package/dist/dist.dev.js +3135 -4142
- package/dist/index.cjs +1766 -2717
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +25 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -1
- package/dist.min.js +9 -42
- package/package.json +11 -15
- package/src/adapter/converters/device-parameters.ts +105 -17
- package/src/adapter/converters/sampler-parameters.ts +12 -20
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +138 -185
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +101 -0
- package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +30 -22
- package/src/adapter/device-helpers/webgl-device-limits.ts +53 -0
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +21 -31
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +3 -4
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +3 -2
- package/src/adapter/objects/webgl-renderbuffer.ts +38 -16
- package/src/adapter/objects/webgl-resource.ts +7 -140
- package/src/adapter/resources/webgl-buffer.ts +10 -14
- package/src/adapter/resources/webgl-command-buffer.ts +24 -34
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +5 -5
- package/src/adapter/resources/webgl-framebuffer.ts +38 -34
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +24 -15
- package/src/adapter/resources/webgl-render-pipeline.ts +138 -70
- package/src/adapter/resources/webgl-sampler.ts +7 -10
- package/src/adapter/resources/webgl-shader.ts +65 -11
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +38 -105
- package/src/adapter/resources/webgl-transform-feedback.ts +16 -22
- package/src/adapter/resources/webgl-vertex-array.ts +20 -21
- package/src/adapter/webgl-canvas-context.ts +7 -11
- package/src/adapter/webgl-device.ts +106 -151
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +25 -20
- package/src/classic/copy-and-blit.ts +12 -6
- 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 +31 -20
- package/src/context/{context → helpers}/create-browser-context.ts +9 -33
- package/src/context/{polyfill/context-data.ts → helpers/webgl-context-data.ts} +3 -2
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +5 -4
- package/src/context/parameters/webgl-parameter-tables.ts +118 -90
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +29 -23
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +4 -18
- package/src/types.ts +2 -1
- package/dist/adapter/converters/device-parameters.js.map +0 -1
- package/dist/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/adapter/converters/shader-formats.js.map +0 -1
- package/dist/adapter/converters/texture-formats.js.map +0 -1
- package/dist/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.js +0 -9
- package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
- package/dist/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/adapter/webgl-device.js.map +0 -1
- package/dist/classic/accessor.js.map +0 -1
- package/dist/classic/clear.js.map +0 -1
- package/dist/classic/copy-and-blit.js.map +0 -1
- package/dist/classic/format-utils.js.map +0 -1
- package/dist/classic/typed-array-utils.js.map +0 -1
- package/dist/context/context/create-browser-context.js.map +0 -1
- package/dist/context/context/create-headless-context.d.ts +0 -9
- package/dist/context/context/create-headless-context.d.ts.map +0 -1
- package/dist/context/context/create-headless-context.js +0 -42
- package/dist/context/context/create-headless-context.js.map +0 -1
- package/dist/context/context/webgl-checks.d.ts +0 -13
- package/dist/context/context/webgl-checks.d.ts.map +0 -1
- package/dist/context/context/webgl-checks.js +0 -31
- package/dist/context/context/webgl-checks.js.map +0 -1
- package/dist/context/debug/spector.js.map +0 -1
- package/dist/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/context/polyfill/context-data.d.ts.map +0 -1
- package/dist/context/polyfill/context-data.js +0 -12
- package/dist/context/polyfill/context-data.js.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
- package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/context/polyfill/polyfill-context.d.ts +0 -5
- package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-context.js +0 -87
- package/dist/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/context/polyfill/polyfill-table.d.ts +0 -48
- package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-table.js +0 -137
- package/dist/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/adapter/device-helpers/device-features.ts +0 -161
- package/src/adapter/device-helpers/device-limits.ts +0 -155
- package/src/adapter/device-helpers/is-old-ie.ts +0 -14
- package/src/context/context/create-headless-context.ts +0 -51
- package/src/context/context/webgl-checks.ts +0 -51
- package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
- package/src/context/polyfill/polyfill-context.ts +0 -104
- package/src/context/polyfill/polyfill-table.ts +0 -167
- package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
|
@@ -1,192 +1,290 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { CommandBuffer, Texture } from '@luma.gl/core';
|
|
5
|
+
import { GL } from '@luma.gl/constants';
|
|
2
6
|
import { WEBGLTexture } from "./webgl-texture.js";
|
|
3
7
|
import { getWebGLTextureParameters } from "../converters/texture-formats.js";
|
|
4
8
|
function cast(value) {
|
|
5
|
-
|
|
9
|
+
return value;
|
|
6
10
|
}
|
|
7
11
|
export class WEBGLCommandBuffer extends CommandBuffer {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
device;
|
|
13
|
+
commands = [];
|
|
14
|
+
constructor(device) {
|
|
15
|
+
super(device, {});
|
|
16
|
+
this.device = device;
|
|
17
|
+
}
|
|
18
|
+
submitCommands(commands = this.commands) {
|
|
19
|
+
for (const command of commands) {
|
|
20
|
+
switch (command.name) {
|
|
21
|
+
case 'copy-buffer-to-buffer':
|
|
22
|
+
_copyBufferToBuffer(this.device, command.options);
|
|
23
|
+
break;
|
|
24
|
+
case 'copy-buffer-to-texture':
|
|
25
|
+
_copyBufferToTexture(this.device, command.options);
|
|
26
|
+
break;
|
|
27
|
+
case 'copy-texture-to-buffer':
|
|
28
|
+
_copyTextureToBuffer(this.device, command.options);
|
|
29
|
+
break;
|
|
30
|
+
case 'copy-texture-to-texture':
|
|
31
|
+
_copyTextureToTexture(this.device, command.options);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
|
-
}
|
|
33
36
|
}
|
|
34
37
|
function _copyBufferToBuffer(device, options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
gl2.bindBuffer(36663, null);
|
|
45
|
-
} else {
|
|
46
|
-
throw new Error('copyBufferToBuffer not implemented in WebGL1');
|
|
47
|
-
}
|
|
38
|
+
const source = cast(options.source);
|
|
39
|
+
const destination = cast(options.destination);
|
|
40
|
+
// {In WebGL2 we can p}erform the copy on the GPU
|
|
41
|
+
// Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type
|
|
42
|
+
device.gl.bindBuffer(GL.COPY_READ_BUFFER, source.handle);
|
|
43
|
+
device.gl.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);
|
|
44
|
+
device.gl.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, options.sourceOffset ?? 0, options.destinationOffset ?? 0, options.size);
|
|
45
|
+
device.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
|
|
46
|
+
device.gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);
|
|
48
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Copies data from a Buffer object into a Texture object
|
|
50
|
+
* NOTE: doesn't wait for copy to be complete
|
|
51
|
+
*/
|
|
49
52
|
function _copyBufferToTexture(device, options) {
|
|
50
|
-
|
|
53
|
+
throw new Error('Not implemented');
|
|
51
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Copies data from a Texture object into a Buffer object.
|
|
57
|
+
* NOTE: doesn't wait for copy to be complete
|
|
58
|
+
*/
|
|
52
59
|
function _copyTextureToBuffer(device, options) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
60
|
+
const {
|
|
61
|
+
/** Texture to copy to/from. */
|
|
62
|
+
source,
|
|
63
|
+
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
64
|
+
mipLevel = 0,
|
|
65
|
+
/** Defines which aspects of the texture to copy to/from. */
|
|
66
|
+
aspect = 'all',
|
|
67
|
+
/** Width to copy */
|
|
68
|
+
width = options.source.width,
|
|
69
|
+
/** Height to copy */
|
|
70
|
+
height = options.source.height, depthOrArrayLayers = 0,
|
|
71
|
+
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
72
|
+
origin = [0, 0],
|
|
73
|
+
/** Destination buffer */
|
|
74
|
+
destination,
|
|
75
|
+
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
|
|
76
|
+
byteOffset = 0,
|
|
77
|
+
/**
|
|
78
|
+
* The stride, in bytes, between the beginning of each block row and the subsequent block row.
|
|
79
|
+
* Required if there are multiple block rows (i.e. the copy height or depth is more than one block).
|
|
80
|
+
*/
|
|
81
|
+
bytesPerRow,
|
|
82
|
+
/**
|
|
83
|
+
* Number of block rows per single image of the texture.
|
|
84
|
+
* rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.
|
|
85
|
+
* Required if there are multiple images (i.e. the copy depth is more than one).
|
|
86
|
+
*/
|
|
87
|
+
rowsPerImage } = options;
|
|
88
|
+
// TODO - Not possible to read just stencil or depth part in WebGL?
|
|
89
|
+
if (aspect !== 'all') {
|
|
90
|
+
throw new Error('not supported');
|
|
91
|
+
}
|
|
92
|
+
// TODO - mipLevels are set when attaching texture to framebuffer
|
|
93
|
+
if (mipLevel !== 0 || depthOrArrayLayers !== 0 || bytesPerRow || rowsPerImage) {
|
|
94
|
+
throw new Error('not implemented');
|
|
95
|
+
}
|
|
96
|
+
// Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature
|
|
97
|
+
const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
|
|
98
|
+
try {
|
|
99
|
+
const webglBuffer = destination;
|
|
100
|
+
const sourceWidth = width || framebuffer.width;
|
|
101
|
+
const sourceHeight = height || framebuffer.height;
|
|
102
|
+
const sourceParams = getWebGLTextureParameters(framebuffer.texture.props.format);
|
|
103
|
+
const sourceFormat = sourceParams.dataFormat;
|
|
104
|
+
const sourceType = sourceParams.type;
|
|
105
|
+
// if (!target) {
|
|
106
|
+
// // Create new buffer with enough size
|
|
107
|
+
// const components = glFormatToComponents(sourceFormat);
|
|
108
|
+
// const byteCount = glTypeToBytes(sourceType);
|
|
109
|
+
// const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;
|
|
110
|
+
// target = device.createBuffer({byteLength});
|
|
111
|
+
// }
|
|
112
|
+
device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
|
|
113
|
+
device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
|
|
114
|
+
device.gl.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, null);
|
|
118
|
+
device.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
119
|
+
if (destroyFramebuffer) {
|
|
120
|
+
framebuffer.destroy();
|
|
121
|
+
}
|
|
92
122
|
}
|
|
93
|
-
}
|
|
94
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Copies data from a Framebuffer or a Texture object into a Buffer object.
|
|
126
|
+
* NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.
|
|
127
|
+
export function readPixelsToBuffer(
|
|
128
|
+
source: Framebuffer | Texture,
|
|
129
|
+
options?: {
|
|
130
|
+
sourceX?: number;
|
|
131
|
+
sourceY?: number;
|
|
132
|
+
sourceFormat?: number;
|
|
133
|
+
target?: Buffer; // A new Buffer object is created when not provided.
|
|
134
|
+
targetByteOffset?: number; // byte offset in buffer object
|
|
135
|
+
// following parameters are auto deduced if not provided
|
|
136
|
+
sourceWidth?: number;
|
|
137
|
+
sourceHeight?: number;
|
|
138
|
+
sourceType?: number;
|
|
139
|
+
}
|
|
140
|
+
): Buffer
|
|
141
|
+
*/
|
|
142
|
+
/**
|
|
143
|
+
* Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)
|
|
144
|
+
*/
|
|
145
|
+
// eslint-disable-next-line complexity, max-statements
|
|
95
146
|
function _copyTextureToTexture(device, options) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
147
|
+
const {
|
|
148
|
+
/** Texture to copy to/from. */
|
|
149
|
+
source,
|
|
150
|
+
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
151
|
+
// mipLevel = 0,
|
|
152
|
+
/** Defines which aspects of the texture to copy to/from. */
|
|
153
|
+
// aspect = 'all',
|
|
154
|
+
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
155
|
+
origin = [0, 0],
|
|
156
|
+
/** Texture to copy to/from. */
|
|
99
157
|
destination
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
158
|
+
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
159
|
+
// destinationMipLevel = options.mipLevel,
|
|
160
|
+
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
161
|
+
// destinationOrigin = [0, 0],
|
|
162
|
+
/** Defines which aspects of the texture to copy to/from. */
|
|
163
|
+
// destinationAspect = options.aspect,
|
|
164
|
+
} = options;
|
|
165
|
+
let { width = options.destination.width, height = options.destination.width
|
|
166
|
+
// depthOrArrayLayers = 0
|
|
167
|
+
} = options;
|
|
168
|
+
const destinationMipmaplevel = 0;
|
|
169
|
+
const destinationInternalFormat = GL.RGBA;
|
|
170
|
+
const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
|
|
171
|
+
const [sourceX, sourceY] = origin;
|
|
172
|
+
const isSubCopy = false;
|
|
173
|
+
// typeof destinationX !== 'undefined' ||
|
|
174
|
+
// typeof destinationY !== 'undefined' ||
|
|
175
|
+
// typeof destinationZ !== 'undefined';
|
|
176
|
+
// destinationX = destinationX || 0;
|
|
177
|
+
// destinationY = destinationY || 0;
|
|
178
|
+
// destinationZ = destinationZ || 0;
|
|
179
|
+
device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
|
|
180
|
+
// TODO - support gl.readBuffer (WebGL2 only)
|
|
181
|
+
// const prevBuffer = gl.readBuffer(attachment);
|
|
182
|
+
let texture = null;
|
|
183
|
+
let textureTarget;
|
|
184
|
+
if (destination instanceof WEBGLTexture) {
|
|
185
|
+
texture = destination;
|
|
186
|
+
width = Number.isFinite(width) ? width : texture.width;
|
|
187
|
+
height = Number.isFinite(height) ? height : texture.height;
|
|
188
|
+
texture.bind(0);
|
|
189
|
+
textureTarget = texture.destination;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
throw new Error('whoops');
|
|
193
|
+
// textureTarget = destination;
|
|
194
|
+
}
|
|
195
|
+
if (!isSubCopy) {
|
|
196
|
+
device.gl.copyTexImage2D(textureTarget, destinationMipmaplevel, destinationInternalFormat, sourceX, sourceY, width, height, 0 /* border must be 0 */);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
// switch (textureTarget) {
|
|
200
|
+
// case GL.TEXTURE_2D:
|
|
201
|
+
// case GL.TEXTURE_CUBE_MAP:
|
|
202
|
+
// device.gl.copyTexSubImage2D(
|
|
203
|
+
// textureTarget,
|
|
204
|
+
// destinationMipmaplevel,
|
|
205
|
+
// destinationX,
|
|
206
|
+
// destinationY,
|
|
207
|
+
// sourceX,
|
|
208
|
+
// sourceY,
|
|
209
|
+
// width,
|
|
210
|
+
// height
|
|
211
|
+
// );
|
|
212
|
+
// break;
|
|
213
|
+
// case GL.TEXTURE_2D_ARRAY:
|
|
214
|
+
// case GL.TEXTURE_3D:
|
|
215
|
+
// device.gl.copyTexSubImage3D(
|
|
216
|
+
// textureTarget,
|
|
217
|
+
// destinationMipmaplevel,
|
|
218
|
+
// destinationX,
|
|
219
|
+
// destinationY,
|
|
220
|
+
// destinationZ,
|
|
221
|
+
// sourceX,
|
|
222
|
+
// sourceY,
|
|
223
|
+
// width,
|
|
224
|
+
// height
|
|
225
|
+
// );
|
|
226
|
+
// break;
|
|
227
|
+
// default:
|
|
228
|
+
// }
|
|
229
|
+
}
|
|
230
|
+
if (texture) {
|
|
231
|
+
texture.unbind();
|
|
232
|
+
}
|
|
233
|
+
// ts-expect-error
|
|
234
|
+
// device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
235
|
+
if (destroyFramebuffer) {
|
|
236
|
+
framebuffer.destroy();
|
|
237
|
+
}
|
|
238
|
+
return texture;
|
|
135
239
|
}
|
|
240
|
+
// Returns number of components in a specific readPixels WebGL format
|
|
136
241
|
export function glFormatToComponents(format) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
242
|
+
switch (format) {
|
|
243
|
+
case GL.ALPHA:
|
|
244
|
+
case GL.R32F:
|
|
245
|
+
case GL.RED:
|
|
246
|
+
return 1;
|
|
247
|
+
case GL.RG32F:
|
|
248
|
+
case GL.RG:
|
|
249
|
+
return 2;
|
|
250
|
+
case GL.RGB:
|
|
251
|
+
case GL.RGB32F:
|
|
252
|
+
return 3;
|
|
253
|
+
case GL.RGBA:
|
|
254
|
+
case GL.RGBA32F:
|
|
255
|
+
return 4;
|
|
256
|
+
// TODO: Add support for additional WebGL2 formats
|
|
257
|
+
default:
|
|
258
|
+
throw new Error('GLFormat');
|
|
259
|
+
}
|
|
154
260
|
}
|
|
261
|
+
// Return byte count for given readPixels WebGL type
|
|
155
262
|
export function glTypeToBytes(type) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
263
|
+
switch (type) {
|
|
264
|
+
case GL.UNSIGNED_BYTE:
|
|
265
|
+
return 1;
|
|
266
|
+
case GL.UNSIGNED_SHORT_5_6_5:
|
|
267
|
+
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
268
|
+
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
269
|
+
return 2;
|
|
270
|
+
case GL.FLOAT:
|
|
271
|
+
return 4;
|
|
272
|
+
// TODO: Add support for additional WebGL2 types
|
|
273
|
+
default:
|
|
274
|
+
throw new Error('GLType');
|
|
275
|
+
}
|
|
168
276
|
}
|
|
277
|
+
// Helper methods
|
|
169
278
|
function getFramebuffer(source) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
});
|
|
182
|
-
return {
|
|
183
|
-
framebuffer,
|
|
184
|
-
destroyFramebuffer: true
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
framebuffer: source,
|
|
189
|
-
destroyFramebuffer: false
|
|
190
|
-
};
|
|
279
|
+
if (source instanceof Texture) {
|
|
280
|
+
const { width, height, id } = source;
|
|
281
|
+
const framebuffer = source.device.createFramebuffer({
|
|
282
|
+
id: `framebuffer-for-${id}`,
|
|
283
|
+
width,
|
|
284
|
+
height,
|
|
285
|
+
colorAttachments: [source]
|
|
286
|
+
});
|
|
287
|
+
return { framebuffer, destroyFramebuffer: true };
|
|
288
|
+
}
|
|
289
|
+
return { framebuffer: source, destroyFramebuffer: false };
|
|
191
290
|
}
|
|
192
|
-
//# sourceMappingURL=webgl-command-buffer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandEncoder, CommandEncoderProps } from '@luma.gl/core';
|
|
2
|
-
import type { CopyBufferToBufferOptions, CopyBufferToTextureOptions, CopyTextureToBufferOptions, CopyTextureToTextureOptions } from '@luma.gl/core';
|
|
3
|
-
import { WEBGLCommandBuffer } from
|
|
4
|
-
import { WebGLDevice } from
|
|
2
|
+
import type { CopyBufferToBufferOptions, CopyBufferToTextureOptions, CopyTextureToBufferOptions, CopyTextureToTextureOptions, QuerySet, Buffer } from '@luma.gl/core';
|
|
3
|
+
import { WEBGLCommandBuffer } from "./webgl-command-buffer.js";
|
|
4
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
5
5
|
export declare class WEBGLCommandEncoder extends CommandEncoder {
|
|
6
6
|
readonly device: WebGLDevice;
|
|
7
7
|
readonly commandBuffer: WEBGLCommandBuffer;
|
|
@@ -15,5 +15,10 @@ export declare class WEBGLCommandEncoder extends CommandEncoder {
|
|
|
15
15
|
pushDebugGroup(groupLabel: string): void;
|
|
16
16
|
popDebugGroup(): void;
|
|
17
17
|
insertDebugMarker(markerLabel: string): void;
|
|
18
|
+
resolveQuerySet(querySet: QuerySet, destination: Buffer, options?: {
|
|
19
|
+
firstQuery?: number;
|
|
20
|
+
queryCount?: number;
|
|
21
|
+
destinationOffset?: number;
|
|
22
|
+
}): void;
|
|
18
23
|
}
|
|
19
24
|
//# sourceMappingURL=webgl-command-encoder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,QAAQ,EACR,MAAM,EACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,kBAAkB,EAAC,kCAA+B;AAC1D,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;gBAE/B,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB;IAMlD,OAAO,IAAI,IAAI;IAEf,MAAM,IAAI,IAAI;IAQvB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAI5D,mBAAmB,CAAC,OAAO,EAAE,0BAA0B;IAIvD,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI;IAI9D,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI;IAIvD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IACxC,aAAa;IAEb,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAE5C,eAAe,CACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,GACA,IAAI;CACR"}
|
|
@@ -1,43 +1,37 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { CommandEncoder } from '@luma.gl/core';
|
|
2
5
|
import { WEBGLCommandBuffer } from "./webgl-command-buffer.js";
|
|
3
6
|
export class WEBGLCommandEncoder extends CommandEncoder {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.commandBuffer.commands.push({
|
|
35
|
-
name: 'copy-texture-to-texture',
|
|
36
|
-
options
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
pushDebugGroup(groupLabel) {}
|
|
40
|
-
popDebugGroup() {}
|
|
41
|
-
insertDebugMarker(markerLabel) {}
|
|
7
|
+
device;
|
|
8
|
+
commandBuffer;
|
|
9
|
+
constructor(device, props) {
|
|
10
|
+
super(device, props);
|
|
11
|
+
this.device = device;
|
|
12
|
+
this.commandBuffer = new WEBGLCommandBuffer(device);
|
|
13
|
+
}
|
|
14
|
+
destroy() { }
|
|
15
|
+
finish() {
|
|
16
|
+
this.commandBuffer.submitCommands();
|
|
17
|
+
}
|
|
18
|
+
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
19
|
+
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
20
|
+
// finish(options?: {id?: string}): GPUCommandBuffer;
|
|
21
|
+
copyBufferToBuffer(options) {
|
|
22
|
+
this.commandBuffer.commands.push({ name: 'copy-buffer-to-buffer', options });
|
|
23
|
+
}
|
|
24
|
+
copyBufferToTexture(options) {
|
|
25
|
+
this.commandBuffer.commands.push({ name: 'copy-buffer-to-texture', options });
|
|
26
|
+
}
|
|
27
|
+
copyTextureToBuffer(options) {
|
|
28
|
+
this.commandBuffer.commands.push({ name: 'copy-texture-to-buffer', options });
|
|
29
|
+
}
|
|
30
|
+
copyTextureToTexture(options) {
|
|
31
|
+
this.commandBuffer.commands.push({ name: 'copy-texture-to-texture', options });
|
|
32
|
+
}
|
|
33
|
+
pushDebugGroup(groupLabel) { }
|
|
34
|
+
popDebugGroup() { }
|
|
35
|
+
insertDebugMarker(markerLabel) { }
|
|
36
|
+
resolveQuerySet(querySet, destination, options) { }
|
|
42
37
|
}
|
|
43
|
-
//# sourceMappingURL=webgl-command-encoder.js.map
|
|
@@ -1,2 +1,94 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/*
|
|
5
|
+
export class WEBGLExternalTexture extends WEBGLTexture {
|
|
6
|
+
readonly device: WebGLDevice;
|
|
7
|
+
readonly gl: WebGL2RenderingContext;
|
|
8
|
+
readonly handle: WebGLTexture;
|
|
1
9
|
|
|
2
|
-
|
|
10
|
+
data;
|
|
11
|
+
|
|
12
|
+
width: number = undefined;
|
|
13
|
+
height: number = undefined;
|
|
14
|
+
depth: number = undefined;
|
|
15
|
+
|
|
16
|
+
format = undefined;
|
|
17
|
+
type = undefined;
|
|
18
|
+
dataFormat = undefined;
|
|
19
|
+
border = undefined;
|
|
20
|
+
mipmaps: boolean = undefined;
|
|
21
|
+
|
|
22
|
+
textureUnit: number = undefined;
|
|
23
|
+
|
|
24
|
+
sampler: WEBGLSampler;
|
|
25
|
+
|
|
26
|
+
// Program.draw() checks the loaded flag of all textures to avoid
|
|
27
|
+
// Textures that are still loading from promises
|
|
28
|
+
// Set to true as soon as texture has been initialized with valid data
|
|
29
|
+
loaded = false;
|
|
30
|
+
_video;
|
|
31
|
+
|
|
32
|
+
readonly target: GL;
|
|
33
|
+
// target cannot be modified by bind:
|
|
34
|
+
// textures are special because when you first bind them to a target,
|
|
35
|
+
// they get special information. When you first bind a texture as a
|
|
36
|
+
// GL_TEXTURE_2D, you are actually setting special state in the texture.
|
|
37
|
+
// You are saying that this texture is a 2D texture.
|
|
38
|
+
// And it will always be a 2D texture; this state cannot be changed ever.
|
|
39
|
+
// If you have a texture that was first bound as a GL_TEXTURE_2D,
|
|
40
|
+
// you must always bind it as a GL_TEXTURE_2D;
|
|
41
|
+
// attempting to bind it as GL_TEXTURE_3D will give rise to an error
|
|
42
|
+
// (while run-time).
|
|
43
|
+
|
|
44
|
+
static isSupported(device: WebGLDevice, options?: TextureSupportOptions): boolean {
|
|
45
|
+
const {format, linearFiltering} = options;
|
|
46
|
+
let supported = true;
|
|
47
|
+
if (format) {
|
|
48
|
+
supported = supported && isFormatSupported(device.gl, format);
|
|
49
|
+
supported = supported && (!linearFiltering || isTextureFormatFilterable(device.gl, format));
|
|
50
|
+
}
|
|
51
|
+
return supported;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// eslint-disable-next-line max-statements
|
|
55
|
+
constructor(device: Device | WebGL2RenderingContext, props: TextureProps) {
|
|
56
|
+
super(WebGLDevice.attach(device), {id: uid('texture'), ...props});
|
|
57
|
+
|
|
58
|
+
this.glTarget = getWebGLTextureTarget(props);
|
|
59
|
+
|
|
60
|
+
this.device = WebGLDevice.attach(device);
|
|
61
|
+
this.gl = this.device.gl;
|
|
62
|
+
this.gl2 = this.device.gl2;
|
|
63
|
+
this.handle = this.props.handle || this.gl.createTexture();
|
|
64
|
+
|
|
65
|
+
let data = props.data;
|
|
66
|
+
|
|
67
|
+
const isVideo = typeof HTMLVideoElement !== 'undefined' && data instanceof HTMLVideoElement;
|
|
68
|
+
// @ts-expect-error
|
|
69
|
+
if (isVideo && data.readyState < HTMLVideoElement.HAVE_METADATA) {
|
|
70
|
+
this._video = null; // Declare member before the object is sealed
|
|
71
|
+
data.addEventListener('loadeddata', () => this.initialize(props));
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
update(): this {
|
|
76
|
+
if (this._video) {
|
|
77
|
+
const {video, parameters, lastTime} = this._video;
|
|
78
|
+
// @ts-expect-error
|
|
79
|
+
if (lastTime === video.currentTime || video.readyState < HTMLVideoElement.HAVE_CURRENT_DATA) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.setSubImageData({
|
|
83
|
+
data: video,
|
|
84
|
+
parameters
|
|
85
|
+
});
|
|
86
|
+
if (this.mipmaps) {
|
|
87
|
+
this.generateMipmap();
|
|
88
|
+
}
|
|
89
|
+
this._video.lastTime = video.currentTime;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
*/
|