@luma.gl/webgl 9.0.0-alpha.21 → 9.0.0-alpha.23
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 +9 -9
- 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/texture-formats.d.ts +27 -38
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +152 -114
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/attribute-utils.js +1 -1
- package/dist/adapter/helpers/attribute-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-info.js.map +1 -1
- package/dist/adapter/helpers/uniforms.d.ts +7 -8
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
- package/dist/adapter/helpers/uniforms.js +4 -4
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts +0 -2
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +0 -20
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +11 -8
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +29 -19
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +0 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +4 -7
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +3 -2
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +8 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +168 -25
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +3 -2
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +6 -2
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +9 -12
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +29 -79
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +16 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +80 -0
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +3 -4
- 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-texture.d.ts +39 -19
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +32 -30
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +1 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +13 -6
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +20 -2
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/buffer.d.ts +0 -1
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js +0 -6
- package/dist/classic/buffer.js.map +1 -1
- package/dist/classic/typed-array-utils.d.ts +15 -17
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.js.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/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -2
- 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/dist.dev.js +1102 -670
- package/dist/index.cjs +1085 -898
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist.min.js +22 -21
- package/package.json +7 -4
- package/src/adapter/converters/device-parameters.ts +46 -22
- package/src/adapter/converters/sampler-parameters.ts +1 -2
- package/src/adapter/converters/texture-formats.ts +242 -161
- package/src/adapter/helpers/attribute-utils.ts +1 -2
- package/src/adapter/helpers/get-shader-info.ts +3 -0
- package/src/adapter/helpers/uniforms.ts +9 -10
- package/src/adapter/objects/constants-to-keys.ts +0 -25
- package/src/adapter/objects/webgl-renderbuffer.ts +32 -29
- package/src/adapter/objects/webgl-resource.ts +4 -8
- package/src/adapter/resources/webgl-buffer.ts +4 -5
- package/src/adapter/resources/webgl-command-buffer.ts +328 -21
- package/src/adapter/resources/webgl-command-encoder.ts +7 -2
- package/src/adapter/resources/webgl-framebuffer.ts +63 -111
- package/src/adapter/resources/webgl-render-pass.ts +146 -2
- package/src/adapter/resources/webgl-render-pipeline.ts +6 -3
- package/src/adapter/resources/webgl-sampler.ts +1 -2
- package/src/adapter/resources/webgl-texture.ts +61 -43
- package/src/adapter/webgl-canvas-context.ts +2 -2
- package/src/adapter/webgl-device.ts +37 -8
- package/src/classic/buffer.ts +3 -3
- package/src/classic/typed-array-utils.ts +15 -26
- package/src/context/context/create-browser-context.ts +2 -2
- package/src/context/parameters/unified-parameter-api.ts +1 -1
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/index.ts +5 -3
- package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
- package/dist/adapter/converters/renderbuffer-formats.js +0 -180
- package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/types/webgl.d.ts +0 -145
- package/dist/types/webgl.d.ts.map +0 -1
- package/dist/types/webgl.js +0 -2
- package/dist/types/webgl.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
- package/src/adapter/converters/renderbuffer-formats.ts +0 -90
- package/src/context/.DS_Store +0 -0
- package/src/types/webgl.ts +0 -286
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { CommandBuffer, Texture } from '@luma.gl/api';
|
|
2
3
|
import GL from '@luma.gl/constants';
|
|
4
|
+
import { WEBGLTexture } from "./webgl-texture.js";
|
|
3
5
|
function cast(value) {
|
|
4
6
|
return value;
|
|
5
7
|
}
|
|
6
|
-
export class CommandBuffer {
|
|
7
|
-
constructor() {
|
|
8
|
+
export class WEBGLCommandBuffer extends CommandBuffer {
|
|
9
|
+
constructor(device) {
|
|
10
|
+
super({});
|
|
11
|
+
_defineProperty(this, "device", void 0);
|
|
8
12
|
_defineProperty(this, "commands", []);
|
|
13
|
+
this.device = device;
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
submitCommands() {
|
|
16
|
+
let commands = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.commands;
|
|
17
|
+
for (const command of commands) {
|
|
18
|
+
switch (command.name) {
|
|
19
|
+
case 'copy-buffer-to-buffer':
|
|
20
|
+
_copyBufferToBuffer(this.device, command.options);
|
|
21
|
+
break;
|
|
22
|
+
case 'copy-buffer-to-texture':
|
|
23
|
+
_copyBufferToTexture(this.device, command.options);
|
|
24
|
+
break;
|
|
25
|
+
case 'copy-texture-to-buffer':
|
|
26
|
+
_copyTextureToBuffer(this.device, command.options);
|
|
27
|
+
break;
|
|
28
|
+
case 'copy-texture-to-texture':
|
|
29
|
+
_copyTextureToTexture(this.device, command.options);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
function _copyBufferToBuffer(device, options) {
|
|
31
36
|
const source = cast(options.source);
|
|
32
37
|
const destination = cast(options.destination);
|
|
33
|
-
const
|
|
34
|
-
gl2
|
|
35
|
-
} = device;
|
|
38
|
+
const gl2 = device.assertWebGL2();
|
|
36
39
|
if (gl2) {
|
|
37
40
|
var _options$sourceOffset, _options$destinationO;
|
|
38
41
|
gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);
|
|
@@ -44,7 +47,147 @@ function _copyBufferToBuffer(device, options) {
|
|
|
44
47
|
throw new Error('copyBufferToBuffer not implemented in WebGL1');
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
|
-
function _copyBufferToTexture(device, options) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
function _copyBufferToTexture(device, options) {
|
|
51
|
+
throw new Error('Not implemented');
|
|
52
|
+
}
|
|
53
|
+
function _copyTextureToBuffer(device, options) {
|
|
54
|
+
const {
|
|
55
|
+
source,
|
|
56
|
+
mipLevel = 0,
|
|
57
|
+
aspect = 'all',
|
|
58
|
+
width = options.source.width,
|
|
59
|
+
height = options.source.height,
|
|
60
|
+
depthOrArrayLayers = 0,
|
|
61
|
+
origin = [0, 0],
|
|
62
|
+
destination,
|
|
63
|
+
byteOffset = 0,
|
|
64
|
+
bytesPerRow,
|
|
65
|
+
rowsPerImage
|
|
66
|
+
} = options;
|
|
67
|
+
if (aspect !== 'all') {
|
|
68
|
+
throw new Error('not supported');
|
|
69
|
+
}
|
|
70
|
+
if (mipLevel !== 0 || depthOrArrayLayers !== undefined || bytesPerRow || rowsPerImage) {
|
|
71
|
+
throw new Error('not implemented');
|
|
72
|
+
}
|
|
73
|
+
const gl2 = device.assertWebGL2();
|
|
74
|
+
const {
|
|
75
|
+
framebuffer,
|
|
76
|
+
destroyFramebuffer
|
|
77
|
+
} = getFramebuffer(source);
|
|
78
|
+
try {
|
|
79
|
+
const webglBuffer = destination;
|
|
80
|
+
const sourceWidth = width || framebuffer.width;
|
|
81
|
+
const sourceHeight = height || framebuffer.height;
|
|
82
|
+
const sourceFormat = GL.RGBA;
|
|
83
|
+
const sourceType = GL.UNSIGNED_BYTE;
|
|
84
|
+
gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
|
|
85
|
+
gl2.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
|
|
86
|
+
gl2.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);
|
|
87
|
+
} finally {
|
|
88
|
+
gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, null);
|
|
89
|
+
gl2.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
90
|
+
if (destroyFramebuffer) {
|
|
91
|
+
framebuffer.destroy();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function _copyTextureToTexture(device, options) {
|
|
96
|
+
const {
|
|
97
|
+
source,
|
|
98
|
+
origin = [0, 0],
|
|
99
|
+
destination
|
|
100
|
+
} = options;
|
|
101
|
+
let {
|
|
102
|
+
width = options.destination.width,
|
|
103
|
+
height = options.destination.width
|
|
104
|
+
} = options;
|
|
105
|
+
const destinationMipmaplevel = 0;
|
|
106
|
+
const destinationInternalFormat = GL.RGBA;
|
|
107
|
+
const {
|
|
108
|
+
framebuffer,
|
|
109
|
+
destroyFramebuffer
|
|
110
|
+
} = getFramebuffer(source);
|
|
111
|
+
const [sourceX, sourceY] = origin;
|
|
112
|
+
const isSubCopy = false;
|
|
113
|
+
device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
|
|
114
|
+
let texture = null;
|
|
115
|
+
let textureTarget;
|
|
116
|
+
if (destination instanceof WEBGLTexture) {
|
|
117
|
+
texture = destination;
|
|
118
|
+
width = Number.isFinite(width) ? width : texture.width;
|
|
119
|
+
height = Number.isFinite(height) ? height : texture.height;
|
|
120
|
+
texture.bind(0);
|
|
121
|
+
textureTarget = texture.destination;
|
|
122
|
+
} else {
|
|
123
|
+
throw new Error('whoops');
|
|
124
|
+
}
|
|
125
|
+
if (!isSubCopy) {
|
|
126
|
+
device.gl.copyTexImage2D(textureTarget, destinationMipmaplevel, destinationInternalFormat, sourceX, sourceY, width, height, 0);
|
|
127
|
+
} else {}
|
|
128
|
+
if (texture) {
|
|
129
|
+
texture.unbind();
|
|
130
|
+
}
|
|
131
|
+
device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
132
|
+
if (destroyFramebuffer) {
|
|
133
|
+
framebuffer.destroy();
|
|
134
|
+
}
|
|
135
|
+
return texture;
|
|
136
|
+
}
|
|
137
|
+
export function glFormatToComponents(format) {
|
|
138
|
+
switch (format) {
|
|
139
|
+
case GL.ALPHA:
|
|
140
|
+
case GL.R32F:
|
|
141
|
+
case GL.RED:
|
|
142
|
+
return 1;
|
|
143
|
+
case GL.RG32F:
|
|
144
|
+
case GL.RG:
|
|
145
|
+
return 2;
|
|
146
|
+
case GL.RGB:
|
|
147
|
+
case GL.RGB32F:
|
|
148
|
+
return 3;
|
|
149
|
+
case GL.RGBA:
|
|
150
|
+
case GL.RGBA32F:
|
|
151
|
+
return 4;
|
|
152
|
+
default:
|
|
153
|
+
throw new Error('GLFormat');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export function glTypeToBytes(type) {
|
|
157
|
+
switch (type) {
|
|
158
|
+
case GL.UNSIGNED_BYTE:
|
|
159
|
+
return 1;
|
|
160
|
+
case GL.UNSIGNED_SHORT_5_6_5:
|
|
161
|
+
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
162
|
+
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
163
|
+
return 2;
|
|
164
|
+
case GL.FLOAT:
|
|
165
|
+
return 4;
|
|
166
|
+
default:
|
|
167
|
+
throw new Error('GLType');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function getFramebuffer(source) {
|
|
171
|
+
if (source instanceof Texture) {
|
|
172
|
+
const {
|
|
173
|
+
width,
|
|
174
|
+
height,
|
|
175
|
+
id
|
|
176
|
+
} = source;
|
|
177
|
+
const framebuffer = source.device.createFramebuffer({
|
|
178
|
+
id: "framebuffer-for-".concat(id),
|
|
179
|
+
width,
|
|
180
|
+
height,
|
|
181
|
+
colorAttachments: [source]
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
framebuffer,
|
|
185
|
+
destroyFramebuffer: true
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
framebuffer: source,
|
|
190
|
+
destroyFramebuffer: false
|
|
191
|
+
};
|
|
192
|
+
}
|
|
50
193
|
//# sourceMappingURL=webgl-command-buffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-buffer.js","names":["GL","cast","value","CommandBuffer","constructor","_defineProperty","submitCommands","device","commands","arguments","length","undefined","command","name","_copyBufferToBuffer","options","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","source","destination","gl2","_options$sourceOffset","_options$destinationO","bindBuffer","COPY_READ_BUFFER","handle","COPY_WRITE_BUFFER","copyBufferSubData","sourceOffset","destinationOffset","size","Error"],"sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"sourcesContent":["import type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\n\nfunction cast<T>(value: unknown): T {\n return value as T;\n}\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand;\n\nexport class CommandBuffer {\n commands: Command[] = [];\n}\n\nexport function submitCommands(device: WebGLDevice, commands: Command[] = []) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(device, command.options);\n break;\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = cast<WEBGLBuffer>(options.source);\n const destination = cast<WEBGLBuffer>(options.destination);\n\n const {gl2} = device;\n if (gl2) {\n // In WebGL2 we can perform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n gl2.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n gl2.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n } else {\n // TODO - in WebGL1 we would have to read back to CPU\n // read / write buffer from / to CPU\n throw new Error('copyBufferToBuffer not implemented in WebGL1');\n }\n}\n\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {}\n\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {}\n\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {}\n"],"mappings":";AAMA,OAAOA,EAAE,MAAM,oBAAoB;AAInC,SAASC,IAAIA,CAAIC,KAAc,EAAK;EAClC,OAAOA,KAAK;AACd;AA4BA,OAAO,MAAMC,aAAa,CAAC;EAAAC,YAAA;IAAAC,eAAA,mBACH,EAAE;EAAA;AAC1B;AAEA,OAAO,SAASC,cAAcA,CAACC,MAAmB,EAA4B;EAAA,IAA1BC,QAAmB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;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E,CAACyB,gBAAgB,EAAE,IAAI,CAAC;IACzCJ,GAAG,CAACG,UAAU,CAACxB,EAAE,CAAC2B,iBAAiB,EAAE,IAAI,CAAC;EAC5C,CAAC,MAAM;IAGL,MAAM,IAAIK,KAAK,CAAC,8CAA8C,CAAC;EACjE;AACF;AAEA,SAAShB,oBAAoBA,CAACT,MAAmB,EAAEQ,OAAmC,EAAQ,CAAC;AAE/F,SAASE,oBAAoBA,CAACV,MAAmB,EAAEQ,OAAmC,EAAQ,CAAC;AAE/F,SAASG,qBAAqBA,CAACX,MAAmB,EAAEQ,OAAoC,EAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"webgl-command-buffer.js","names":["CommandBuffer","Texture","GL","WEBGLTexture","cast","value","WEBGLCommandBuffer","constructor","device","_defineProperty","submitCommands","commands","arguments","length","undefined","command","name","_copyBufferToBuffer","options","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","source","destination","gl2","assertWebGL2","_options$sourceOffset","_options$destinationO","bindBuffer","COPY_READ_BUFFER","handle","COPY_WRITE_BUFFER","copyBufferSubData","sourceOffset","destinationOffset","size","Error","mipLevel","aspect","width","height","depthOrArrayLayers","origin","byteOffset","bytesPerRow","rowsPerImage","framebuffer","destroyFramebuffer","getFramebuffer","webglBuffer","sourceWidth","sourceHeight","sourceFormat","RGBA","sourceType","UNSIGNED_BYTE","PIXEL_PACK_BUFFER","bindFramebuffer","FRAMEBUFFER","readPixels","destroy","destinationMipmaplevel","destinationInternalFormat","sourceX","sourceY","isSubCopy","gl","texture","textureTarget","Number","isFinite","bind","copyTexImage2D","unbind","prevHandle","glFormatToComponents","format","ALPHA","R32F","RED","RG32F","RG","RGB","RGB32F","RGBA32F","glTypeToBytes","type","UNSIGNED_SHORT_5_6_5","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","FLOAT","id","createFramebuffer","concat","colorAttachments"],"sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\nimport {\n CommandBuffer,\n Texture,\n // Buffer,\n Framebuffer\n} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\n// import {getTypedArrayFromGLType, getGLTypeFromTypedArray} from '../../classic/typed-array-utils';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLFramebuffer} from './webgl-framebuffer';\n\nfunction cast<T>(value: unknown): T {\n return value as T;\n}\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand;\n\nexport class WEBGLCommandBuffer extends CommandBuffer {\n device: WebGLDevice;\n commands: Command[] = [];\n\n constructor(device: WebGLDevice) {\n super({});\n this.device = device;\n }\n\n submitCommands(commands: Command[] = this.commands) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(this.device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(this.device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(this.device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(this.device, command.options);\n break;\n }\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = cast<WEBGLBuffer>(options.source);\n const destination = cast<WEBGLBuffer>(options.destination);\n\n const gl2 = device.assertWebGL2();\n if (gl2) {\n // In WebGL2 we can perform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n gl2.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n gl2.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n } else {\n // TODO - in WebGL1 we would have to read back to CPU\n // read / write buffer from / to CPU\n throw new Error('copyBufferToBuffer not implemented in WebGL1');\n }\n}\n\n/**\n * Copies data from a Buffer object into a Texture object\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {\n throw new Error('Not implemented');\n}\n\n/**\n * Copies data from a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n aspect = 'all',\n\n /** Width to copy */\n width = options.source.width,\n /** Height to copy */\n height = options.source.height,\n depthOrArrayLayers = 0,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Destination buffer */\n destination,\n /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */\n byteOffset = 0,\n /**\n * The stride, in bytes, between the beginning of each block row and the subsequent block row.\n * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).\n */\n bytesPerRow,\n /**\n * Number of block rows per single image of the texture.\n * rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.\n * Required if there are multiple images (i.e. the copy depth is more than one).\n */\n rowsPerImage\n } = options;\n\n // TODO - Not possible to read just stencil or depth part in WebGL?\n if (aspect !== 'all') {\n throw new Error('not supported');\n }\n\n // TODO - mipLevels are set when attaching texture to framebuffer\n if (mipLevel !== 0 || depthOrArrayLayers !== undefined || bytesPerRow || rowsPerImage) {\n throw new Error('not implemented');\n }\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const gl2 = device.assertWebGL2();\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n try {\n const webglBuffer = destination as WEBGLBuffer;\n const sourceWidth = width || framebuffer.width;\n const sourceHeight = height || framebuffer.height;\n\n // TODO - hack - should be deduced\n const sourceFormat = GL.RGBA;\n const sourceType = GL.UNSIGNED_BYTE;\n\n // if (!target) {\n // // Create new buffer with enough size\n // const components = glFormatToComponents(sourceFormat);\n // const byteCount = glTypeToBytes(sourceType);\n // const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;\n // target = device.createBuffer({byteLength});\n // }\n\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n\n gl2.readPixels(\n origin[0],\n origin[1],\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n byteOffset\n );\n } finally {\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, null);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, null);\n\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n }\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer\n */\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n */\n// eslint-disable-next-line complexity, max-statements\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n // aspect = 'all',\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Texture to copy to/from. */\n destination,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // destinationMipLevel = options.mipLevel,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n // destinationOrigin = [0, 0],\n /** Defines which aspects of the texture to copy to/from. */\n // destinationAspect = options.aspect,\n\n } = options;\n\n let {\n width = options.destination.width,\n height = options.destination.width,\n // depthOrArrayLayers = 0\n } = options;\n\n const destinationMipmaplevel = 0;\n const destinationInternalFormat = GL.RGBA;\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n const [sourceX, sourceY] = origin;\n\n const isSubCopy = false;\n // typeof destinationX !== 'undefined' ||\n // typeof destinationY !== 'undefined' ||\n // typeof destinationZ !== 'undefined';\n\n // destinationX = destinationX || 0;\n // destinationY = destinationY || 0;\n // destinationZ = destinationZ || 0;\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n\n let texture = null;\n let textureTarget: GL;\n if (destination instanceof WEBGLTexture) {\n texture = destination;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.destination;\n } else {\n throw new Error('whoops');\n // textureTarget = destination;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n destinationMipmaplevel,\n destinationInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n // switch (textureTarget) {\n // case GL.TEXTURE_2D:\n // case GL.TEXTURE_CUBE_MAP:\n // device.gl.copyTexSubImage2D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // case GL.TEXTURE_2D_ARRAY:\n // case GL.TEXTURE_3D:\n // const gl2 = device.assertWebGL2();\n // gl2.copyTexSubImage3D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // destinationZ,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // default:\n // }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format): 1 | 2 | 3 | 4 {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n return 1;\n case GL.RG32F:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n throw new Error('GLFormat');\n }\n}\n\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type: GL): 1 | 2 | 4 {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n throw new Error('GLType');\n }\n}\n\n// Helper methods\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: WEBGLFramebuffer;\n destroyFramebuffer: boolean;\n} {\n if (source instanceof Texture) {\n const {width, height, id} = source;\n const framebuffer = source.device.createFramebuffer({\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [source]\n }) as unknown as WEBGLFramebuffer;\n\n return {framebuffer, destroyFramebuffer: true};\n }\n return {framebuffer: source as unknown as WEBGLFramebuffer, destroyFramebuffer: false};\n}\n"],"mappings":";AAQA,SACEA,aAAa,EACbC,OAAO,QAGF,cAAc;AACrB,OAAOC,EAAE,MAAM,oBAAoB;AAAC,SAK5BC,YAAY;AAGpB,SAASC,IAAIA,CAAIC,KAAc,EAAK;EAClC,OAAOA,KAAK;AACd;AA4BA,OAAO,MAAMC,kBAAkB,SAASN,aAAa,CAAC;EAIpDO,WAAWA,CAACC,MAAmB,EAAE;IAC/B,KAAK,CAAC,CAAC,CAAC,CAAC;IAACC,eAAA;IAAAA,eAAA,mBAHU,EAAE;IAItB,IAAI,CAACD,MAAM,GAAGA,MAAM;EACtB;EAEAE,cAAcA,CAAA,EAAsC;IAAA,IAArCC,QAAmB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI,CAACD,QAAQ;IAChD,KAAK,MAAMI,OAAO,IAAIJ,QAAQ,EAAE;MAC9B,QAAQI,OAAO,CAACC,IAAI;QAClB,KAAK,uBAAuB;UAC1BC,mBAAmB,CAAC,IAAI,CAACT,MAAM,EAAEO,OAAO,CAACG,OAAO,CAAC;UACjD;QACF,KAAK,wBAAwB;UAC3BC,oBAAoB,CAAC,IAAI,CAACX,MAAM,EAAEO,OAAO,CAACG,OAAO,CAAC;UAClD;QACF,KAAK,wBAAwB;UAC3BE,oBAAoB,CAAC,IAAI,CAACZ,MAAM,EAAEO,OAAO,CAACG,OAAO,CAAC;UAClD;QACF,KAAK,yBAAyB;UAC5BG,qBAAqB,CAAC,IAAI,CAACb,MAAM,EAAEO,OAAO,CAACG,OAAO,CAAC;UACnD;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EAAE,CAACqD,aAAa;MACnB,OAAO,CAAC;IACV,KAAKrD,EAAE,CAACqF,oBAAoB;IAC5B,KAAKrF,EAAE,CAACsF,sBAAsB;IAC9B,KAAKtF,EAAE,CAACuF,sBAAsB;MAC5B,OAAO,CAAC;IACV,KAAKvF,EAAE,CAACwF,KAAK;MACX,OAAO,CAAC;IAEV;MACE,MAAM,IAAItD,KAAK,CAAC,QAAQ,CAAC;EAAC;AAEhC;AAIA,SAASY,cAAcA,CAAC1B,MAA6B,EAGnD;EACA,IAAIA,MAAM,YAAYrB,OAAO,EAAE;IAC7B,MAAM;MAACsC,KAAK;MAAEC,MAAM;MAAEmD;IAAE,CAAC,GAAGrE,MAAM;IAClC,MAAMwB,WAAW,GAAGxB,MAAM,CAACd,MAAM,CAACoF,iBAAiB,CAAC;MAClDD,EAAE,qBAAAE,MAAA,CAAqBF,EAAE,CAAE;MAC3BpD,KAAK;MACLC,MAAM;MACNsD,gBAAgB,EAAE,CAACxE,MAAM;IAC3B,CAAC,CAAgC;IAEjC,OAAO;MAACwB,WAAW;MAAEC,kBAAkB,EAAE;IAAI,CAAC;EAChD;EACA,OAAO;IAACD,WAAW,EAAExB,MAAqC;IAAEyB,kBAAkB,EAAE;EAAK,CAAC;AACxF"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CommandEncoder, CommandEncoderProps } from '@luma.gl/api';
|
|
2
2
|
import type { CopyBufferToBufferOptions, CopyBufferToTextureOptions, CopyTextureToBufferOptions, CopyTextureToTextureOptions } from '@luma.gl/api';
|
|
3
|
-
import {
|
|
3
|
+
import { WEBGLCommandBuffer } from './webgl-command-buffer';
|
|
4
4
|
import { WebGLDevice } from '../webgl-device';
|
|
5
5
|
export declare class WEBGLCommandEncoder extends CommandEncoder {
|
|
6
6
|
readonly device: WebGLDevice;
|
|
7
|
-
readonly commandBuffer:
|
|
7
|
+
readonly commandBuffer: WEBGLCommandBuffer;
|
|
8
8
|
constructor(device: WebGLDevice, props: CommandEncoderProps);
|
|
9
9
|
destroy(): void;
|
|
10
|
+
finish(): void;
|
|
10
11
|
copyBufferToBuffer(options: CopyBufferToBufferOptions): void;
|
|
11
12
|
copyBufferToTexture(options: CopyBufferToTextureOptions): void;
|
|
12
13
|
copyTextureToBuffer(options: CopyTextureToBufferOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"webgl-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;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;CAWtD"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { CommandEncoder } from '@luma.gl/api';
|
|
3
|
-
import {
|
|
3
|
+
import { WEBGLCommandBuffer } from "./webgl-command-buffer.js";
|
|
4
4
|
export class WEBGLCommandEncoder extends CommandEncoder {
|
|
5
5
|
constructor(device, props) {
|
|
6
6
|
super(props);
|
|
7
7
|
_defineProperty(this, "device", void 0);
|
|
8
|
-
_defineProperty(this, "commandBuffer",
|
|
8
|
+
_defineProperty(this, "commandBuffer", void 0);
|
|
9
9
|
this.device = device;
|
|
10
|
+
this.commandBuffer = new WEBGLCommandBuffer(device);
|
|
10
11
|
}
|
|
11
12
|
destroy() {}
|
|
13
|
+
finish() {
|
|
14
|
+
this.commandBuffer.submitCommands();
|
|
15
|
+
}
|
|
12
16
|
copyBufferToBuffer(options) {
|
|
13
17
|
this.commandBuffer.commands.push({
|
|
14
18
|
name: 'copy-buffer-to-buffer',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-encoder.js","names":["CommandEncoder","
|
|
1
|
+
{"version":3,"file":"webgl-command-encoder.js","names":["CommandEncoder","WEBGLCommandBuffer","WEBGLCommandEncoder","constructor","device","props","_defineProperty","commandBuffer","destroy","finish","submitCommands","copyBufferToBuffer","options","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/api';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\n\nimport {WEBGLCommandBuffer} from './webgl-command-buffer';\nimport {WebGLDevice} from '../webgl-device';\n\nexport class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer: WEBGLCommandBuffer;\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n\n override destroy(): void {}\n\n override finish(): void {\n this.commandBuffer.submitCommands();\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}\n"],"mappings":";AAAA,SAAQA,cAAc,QAA4B,cAAc;AAAC,SAQzDC,kBAAkB;AAG1B,OAAO,MAAMC,mBAAmB,SAASF,cAAc,CAAC;EAKtDG,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACb,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,aAAa,GAAG,IAAIN,kBAAkB,CAACG,MAAM,CAAC;EACrD;EAESI,OAAOA,CAAA,EAAS,CAAC;EAEjBC,MAAMA,CAAA,EAAS;IACtB,IAAI,CAACF,aAAa,CAACG,cAAc,EAAE;EACrC;EAMAC,kBAAkBA,CAACC,OAAkC,EAAQ;IAC3D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,uBAAuB;MAAEH;IAAO,CAAC,CAAC;EAC5E;EAEAI,mBAAmBA,CAACJ,OAAmC,EAAE;IACvD,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAK,mBAAmBA,CAACL,OAAmC,EAAQ;IAC7D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAM,oBAAoBA,CAACN,OAAoC,EAAQ;IAC/D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,yBAAyB;MAAEH;IAAO,CAAC,CAAC;EAC9E;EAESO,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAG,CAAC;EAEjBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;AAWzD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FramebufferProps,
|
|
1
|
+
import type { FramebufferProps, TextureFormat } from '@luma.gl/api';
|
|
2
2
|
import { Framebuffer, Texture } from '@luma.gl/api';
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
4
|
import { WebGLDevice } from '../webgl-device';
|
|
@@ -11,21 +11,18 @@ export declare class WEBGLFramebuffer extends Framebuffer {
|
|
|
11
11
|
device: WebGLDevice;
|
|
12
12
|
gl: WebGLRenderingContext;
|
|
13
13
|
handle: WebGLFramebuffer;
|
|
14
|
-
get texture():
|
|
15
|
-
readonly colorAttachments: WEBGLTexture[];
|
|
16
|
-
readonly depthStencilAttachment: WEBGLTexture | null;
|
|
17
|
-
protected _ownResources: (WEBGLTexture | WEBGLRenderbuffer)[];
|
|
14
|
+
get texture(): Texture<import("@luma.gl/api").TextureProps>;
|
|
18
15
|
constructor(device: WebGLDevice, props: FramebufferProps);
|
|
16
|
+
/** destroys any auto created resources etc. */
|
|
19
17
|
destroy(): void;
|
|
20
18
|
/** Check the status */
|
|
21
19
|
protected _checkStatus(): void;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
protected _resizeAttachments(width: number, height: number): this;
|
|
20
|
+
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
21
|
+
protected createDepthStencilTexture(format: TextureFormat): Texture;
|
|
22
|
+
/**
|
|
23
|
+
* Attachment resize is expected to be a noop if size is same
|
|
24
|
+
*/
|
|
25
|
+
protected resizeAttachments(width: number, height: number): this;
|
|
29
26
|
/** Attach one attachment */
|
|
30
27
|
protected _attachOne(attachmentPoint: GL, attachment: Attachment): WEBGLTexture | WEBGLRenderbuffer;
|
|
31
28
|
protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"webgl-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EA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,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI;CA2BR"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Framebuffer,
|
|
2
|
+
import { Framebuffer, assert } from '@luma.gl/api';
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
4
|
import { WEBGLTexture } from "./webgl-texture.js";
|
|
5
5
|
import { WEBGLRenderbuffer } from "../objects/webgl-renderbuffer.js";
|
|
6
|
-
import {
|
|
6
|
+
import { getDepthStencilAttachmentWebGL } from "../converters/texture-formats.js";
|
|
7
7
|
export class WEBGLFramebuffer extends Framebuffer {
|
|
8
8
|
get texture() {
|
|
9
9
|
return this.colorAttachments[0];
|
|
@@ -13,43 +13,37 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
13
13
|
_defineProperty(this, "device", void 0);
|
|
14
14
|
_defineProperty(this, "gl", void 0);
|
|
15
15
|
_defineProperty(this, "handle", void 0);
|
|
16
|
-
|
|
17
|
-
_defineProperty(this, "depthStencilAttachment", null);
|
|
18
|
-
_defineProperty(this, "_ownResources", []);
|
|
16
|
+
const isDefaultFramebuffer = props.handle === null;
|
|
19
17
|
this.device = device;
|
|
20
18
|
this.gl = device.gl;
|
|
21
|
-
this.handle = this.props.handle
|
|
22
|
-
if (
|
|
19
|
+
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
20
|
+
if (!isDefaultFramebuffer) {
|
|
23
21
|
device.setSpectorMetadata(this.handle, {
|
|
24
22
|
id: this.props.id,
|
|
25
23
|
props: this.props
|
|
26
24
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this._attachOne(attachmentPoint, attachment);
|
|
25
|
+
this.autoCreateAttachmentTextures();
|
|
26
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);
|
|
27
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
28
|
+
const attachment = this.colorAttachments[i];
|
|
29
|
+
const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;
|
|
30
|
+
if (attachment) {
|
|
31
|
+
this._attachOne(attachmentPoint, attachment);
|
|
32
|
+
}
|
|
36
33
|
}
|
|
34
|
+
if (this.depthStencilAttachment) {
|
|
35
|
+
this._attachOne(getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
36
|
+
}
|
|
37
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
37
38
|
}
|
|
38
|
-
if (this.props.depthStencilAttachment) {
|
|
39
|
-
this._attachOne(getWebGLDepthStencilAttachment(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
40
|
-
}
|
|
41
|
-
this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
42
39
|
if (props.check !== false) {
|
|
43
40
|
this._checkStatus();
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
destroy() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
resource.destroy();
|
|
50
|
-
}
|
|
44
|
+
super.destroy();
|
|
45
|
+
if (!this.destroyed && this.handle !== null) {
|
|
51
46
|
this.gl.deleteFramebuffer(this.handle);
|
|
52
|
-
this.destroyed = true;
|
|
53
47
|
}
|
|
54
48
|
}
|
|
55
49
|
_checkStatus() {
|
|
@@ -63,58 +57,15 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
63
57
|
throw new Error("Framebuffer ".concat(_getFrameBufferStatus(status)));
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
|
|
67
|
-
return this.
|
|
68
|
-
if (!colorAttachment) {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
if (colorAttachment instanceof WEBGLTexture) {
|
|
72
|
-
return colorAttachment;
|
|
73
|
-
}
|
|
74
|
-
return this._createColorAttachment(colorAttachment, this.width, this.height);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
_createColorAttachment(format, width, height) {
|
|
78
|
-
const texture = this.device._createTexture({
|
|
79
|
-
id: "".concat(this.id, "-color"),
|
|
80
|
-
data: null,
|
|
81
|
-
format,
|
|
82
|
-
width,
|
|
83
|
-
height,
|
|
84
|
-
mipmaps: false,
|
|
85
|
-
sampler: {
|
|
86
|
-
minFilter: 'linear',
|
|
87
|
-
magFilter: 'linear',
|
|
88
|
-
addressModeU: 'clamp-to-edge',
|
|
89
|
-
addressModeV: 'clamp-to-edge'
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
this._ownResources.push(texture);
|
|
93
|
-
return texture;
|
|
94
|
-
}
|
|
95
|
-
_createDepthStencilAttachment() {
|
|
96
|
-
if (!this.props.depthStencilAttachment) {
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
if (this.props.depthStencilAttachment instanceof WEBGLRenderbuffer) {
|
|
100
|
-
return this.props.depthStencilAttachment;
|
|
101
|
-
}
|
|
102
|
-
if (this.props.depthStencilAttachment instanceof Texture) {
|
|
103
|
-
return this.props.depthStencilAttachment;
|
|
104
|
-
}
|
|
105
|
-
const format = this.props.depthStencilAttachment;
|
|
106
|
-
const webglFormat = getWebGLTextureFormat(this.gl, format);
|
|
107
|
-
const texture = new WEBGLRenderbuffer(this.device, {
|
|
60
|
+
createDepthStencilTexture(format) {
|
|
61
|
+
return new WEBGLRenderbuffer(this.device, {
|
|
108
62
|
id: "".concat(this.id, "-depth-stencil"),
|
|
109
|
-
format
|
|
63
|
+
format,
|
|
110
64
|
width: this.width,
|
|
111
65
|
height: this.height
|
|
112
66
|
});
|
|
113
|
-
this._ownResources.push(texture);
|
|
114
|
-
return texture;
|
|
115
67
|
}
|
|
116
|
-
|
|
117
|
-
var _this$depthStencilAtt;
|
|
68
|
+
resizeAttachments(width, height) {
|
|
118
69
|
if (this.handle === null) {
|
|
119
70
|
this.width = this.gl.drawingBufferWidth;
|
|
120
71
|
this.height = this.gl.drawingBufferHeight;
|
|
@@ -126,19 +77,18 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
126
77
|
if (height === undefined) {
|
|
127
78
|
height = this.gl.drawingBufferHeight;
|
|
128
79
|
}
|
|
129
|
-
if (width !== this.width && height !== this.height) {
|
|
130
|
-
log.log(2, "Resizing framebuffer ".concat(this.id, " to ").concat(width, "x").concat(height))();
|
|
131
|
-
}
|
|
132
80
|
for (const colorAttachment of this.colorAttachments) {
|
|
133
81
|
colorAttachment.resize({
|
|
134
82
|
width,
|
|
135
83
|
height
|
|
136
84
|
});
|
|
137
85
|
}
|
|
138
|
-
(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
86
|
+
if (this.depthStencilAttachment) {
|
|
87
|
+
this.depthStencilAttachment.resize({
|
|
88
|
+
width,
|
|
89
|
+
height
|
|
90
|
+
});
|
|
91
|
+
}
|
|
142
92
|
return this;
|
|
143
93
|
}
|
|
144
94
|
_attachOne(attachmentPoint, attachment) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-framebuffer.js","names":["Framebuffer","Texture","log","assert","GL","WEBGLTexture","WEBGLRenderbuffer","getWebGLTextureFormat","getWebGLDepthStencilAttachment","WEBGLFramebuffer","texture","colorAttachments","constructor","device","props","_defineProperty","gl","handle","undefined","createFramebuffer","setSpectorMetadata","id","_createColorAttachments","depthStencilAttachment","_createDepthStencilAttachment","prevHandle","bindFramebuffer","FRAMEBUFFER","i","length","attachment","attachmentPoint","COLOR_ATTACHMENT0","_attachOne","format","check","_checkStatus","destroy","resource","_ownResources","deleteFramebuffer","destroyed","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","Error","concat","_getFrameBufferStatus","map","colorAttachment","_createColorAttachment","width","height","_createTexture","data","mipmaps","sampler","minFilter","magFilter","addressModeU","addressModeV","push","webglFormat","_resizeAttachments","_this$depthStencilAtt","drawingBufferWidth","drawingBufferHeight","resize","_attachWEBGLRenderbuffer","Array","isArray","layer","level","_attachTexture","renderbuffer","framebufferRenderbuffer","RENDERBUFFER","gl2","bindTexture","target","TEXTURE_2D_ARRAY","TEXTURE_3D","assertWebGL2","framebufferTextureLayer","TEXTURE_CUBE_MAP","face","mapIndexToCubeMapFace","framebufferTexture2D","TEXTURE_2D","TEXTURE_CUBE_MAP_POSITIVE_X","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"],"sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture, log, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';\nimport {getWebGLTextureFormat, getWebGLDepthStencilAttachment} from '../converters/texture-formats';\n\nexport type TextureAttachment = [Texture, number?, number?];\nexport type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGLRenderingContext;\n handle: WebGLFramebuffer;\n\n get texture() { return this.colorAttachments[0]; }\n readonly colorAttachments: WEBGLTexture[] = [];\n readonly depthStencilAttachment: WEBGLTexture | null = null;\n protected _ownResources: (WEBGLTexture | WEBGLRenderbuffer)[] = [];\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n this.gl = device.gl;\n this.handle = this.props.handle !== undefined ? this.props.handle : this.gl.createFramebuffer();\n\n if (this.handle) { // default framebuffer is null...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n }\n\n this.colorAttachments = this._createColorAttachments();\n // @ts-expect-error\n this.depthStencilAttachment = this._createDepthStencilAttachment();\n\n /** Attach from a map of attachments */\n const prevHandle = this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n if (attachment) {\n this._attachOne(attachmentPoint, attachment);\n }\n }\n\n if (this.props.depthStencilAttachment) {\n this._attachOne(getWebGLDepthStencilAttachment(this.depthStencilAttachment.format), this.depthStencilAttachment);\n }\n\n // @ts-expect-error\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n\n // @ts-expect-error\n if (props.check !== false) {\n this._checkStatus();\n }\n }\n\n override destroy(): void {\n if (this.handle !== null) {\n for (const resource of this._ownResources) {\n resource.destroy();\n }\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n // PRIVATE\n\n /** Check the status */\n protected _checkStatus(): void {\n const {gl} = this;\n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);\n // @ts-expect-error\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n _createColorAttachments(): WEBGLTexture[] {\n return this.props.colorAttachments.map(colorAttachment => {\n if (!colorAttachment) {\n return undefined;\n }\n if (colorAttachment instanceof WEBGLTexture) {\n return colorAttachment;\n }\n // if (typeof colorAttachment === 'default') {\n // return this._createColorAttachment('rgba8unorm', this.width, this.height);\n // }\n // @ts-expect-error\n return this._createColorAttachment(colorAttachment, this.width, this.height);\n });\n }\n\n /** Create a color attachment */\n protected _createColorAttachment(format: ColorTextureFormat, width: number, height: number): WEBGLTexture {\n const texture = this.device._createTexture({\n id: `${this.id}-color`,\n data: null, // reserves texture memory, but texels are undefined\n format,\n // type: GL.UNSIGNED_BYTE,\n width,\n height,\n // Note: Mipmapping can be disabled by texture resource when we resize the texture\n // to a non-power-of-two dimenstion (NPOT texture) under WebGL1. To have consistant\n // behavior we always disable mipmaps.\n mipmaps: false,\n // Set MIN and MAG filtering parameters so mipmaps are not used in sampling.\n // Use LINEAR so subpixel algos like fxaa work.\n // Set WRAP modes that support NPOT textures too.\n sampler: {\n minFilter: 'linear',\n magFilter: 'linear',\n addressModeU: 'clamp-to-edge',\n addressModeV: 'clamp-to-edge'\n },\n // parameters: {\n // [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,\n // [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,\n // [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,\n // [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE\n // }\n }) ;\n this._ownResources.push(texture);\n return texture;\n }\n\n /** Create a depth stencil attachment GL.DEPTH24_STENCIL8 */\n protected _createDepthStencilAttachment(): WEBGLRenderbuffer | WEBGLTexture {\n if (!this.props.depthStencilAttachment) {\n return undefined;\n }\n if (this.props.depthStencilAttachment instanceof WEBGLRenderbuffer) {\n return this.props.depthStencilAttachment;\n }\n if (this.props.depthStencilAttachment instanceof Texture) {\n return this.props.depthStencilAttachment as unknown as WEBGLTexture;\n }\n const format = this.props.depthStencilAttachment;\n const webglFormat = getWebGLTextureFormat(this.gl, format);\n\n const texture = new WEBGLRenderbuffer(this.device, {\n id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?\n format: webglFormat,\n // dataFormat: GL.DEPTH_STENCIL,\n // type: GL.UNSIGNED_INT_24_8,\n width: this.width,\n height: this.height\n });\n this._ownResources.push(texture);\n return texture;\n }\n\n /** Attachment resize is expected to be a noop if size is same */\n protected _resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n if (width !== this.width && height !== this.height) {\n log.log(2, `Resizing framebuffer ${this.id} to ${width}x${height}`)();\n }\n\n for (const colorAttachment of this.colorAttachments) {\n colorAttachment.resize({width, height});\n }\n this.depthStencilAttachment?.resize({width, height});\n return this;\n }\n\n /** Attach one attachment */\n protected _attachOne(attachmentPoint: GL, attachment: Attachment): WEBGLTexture | WEBGLRenderbuffer {\n if (attachment instanceof WEBGLRenderbuffer) {\n this._attachWEBGLRenderbuffer(attachmentPoint, attachment);\n return attachment;\n } else if (Array.isArray(attachment)) {\n const [texture, layer = 0, level = 0] = attachment;\n this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);\n return texture as unknown as WEBGLTexture;\n } else if (attachment instanceof WEBGLTexture) {\n this._attachTexture(attachmentPoint, attachment, 0, 0);\n return attachment;\n }\n throw new Error('attach');\n }\n\n protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {\n this.gl.framebufferRenderbuffer(\n GL.FRAMEBUFFER,\n attachment,\n GL.RENDERBUFFER,\n renderbuffer.handle\n );\n }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel (must be 0 in WebGL1)\n */\n protected _attachTexture(attachment: GL, texture: WEBGLTexture, layer: number, level: number): void {\n const {gl, gl2} = this.device;\n gl.bindTexture(texture.target, texture.handle);\n\n switch (texture.target) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n this.device.assertWebGL2();\n gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n assert(false, 'Illegal texture type');\n }\n\n gl.bindTexture(texture.target, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n"],"mappings":";AAGA,SAAQA,WAAW,EAAEC,OAAO,EAAEC,GAAG,EAAEC,MAAM,QAAO,cAAc;AAC9D,OAAOC,EAAE,MAAM,oBAAoB;AAAC,SAE5BC,YAAY;AAAA,SACZC,iBAAiB;AAAA,SACjBC,qBAAqB,EAAEC,8BAA8B;AAM7D,OAAO,MAAMC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,OAAO,SAAS;IAClB,KAAKxC,EAAE,CAACsF,iCAAiC;MACvC,OAAO,wBAAwB;IACjC,KAAKtF,EAAE,CAACuF,yCAAyC;MAC/C,OAAO,gBAAgB;IACzB,KAAKvF,EAAE,CAACwF,iCAAiC;MACvC,OAAO,uBAAuB;IAChC,KAAKxF,EAAE,CAACyF,uBAAuB;MAC7B,OAAO,kCAAkC;IAE3C,KAAKzF,EAAE,CAAC0F,kCAAkC;MACxC,OAAO,kBAAkB;IAG3B;MACE,UAAAhD,MAAA,CAAUJ,MAAM;EAAG;AAEzB"}
|
|
1
|
+
{"version":3,"file":"webgl-framebuffer.js","names":["Framebuffer","assert","GL","WEBGLTexture","WEBGLRenderbuffer","getDepthStencilAttachmentWebGL","WEBGLFramebuffer","texture","colorAttachments","constructor","device","props","_defineProperty","isDefaultFramebuffer","handle","gl","createFramebuffer","setSpectorMetadata","id","autoCreateAttachmentTextures","bindFramebuffer","FRAMEBUFFER","i","length","attachment","attachmentPoint","COLOR_ATTACHMENT0","_attachOne","depthStencilAttachment","format","check","_checkStatus","destroy","destroyed","deleteFramebuffer","prevHandle","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","Error","concat","_getFrameBufferStatus","createDepthStencilTexture","width","height","resizeAttachments","drawingBufferWidth","drawingBufferHeight","undefined","colorAttachment","resize","_attachWEBGLRenderbuffer","Array","isArray","layer","level","_attachTexture","renderbuffer","framebufferRenderbuffer","RENDERBUFFER","gl2","bindTexture","target","TEXTURE_2D_ARRAY","TEXTURE_3D","assertWebGL2","framebufferTextureLayer","TEXTURE_CUBE_MAP","face","mapIndexToCubeMapFace","framebufferTexture2D","TEXTURE_2D","TEXTURE_CUBE_MAP_POSITIVE_X","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"],"sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {FramebufferProps, TextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';\nimport {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';\n\nexport type TextureAttachment = [Texture, number?, number?];\nexport type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGLRenderingContext;\n handle: WebGLFramebuffer;\n\n get texture() {\n return this.colorAttachments[0];\n }\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n\n // WebGL default framebuffer handle is null\n const isDefaultFramebuffer = props.handle === null;\n\n this.device = device;\n this.gl = device.gl;\n this.handle =\n this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();\n\n if (!isDefaultFramebuffer) {\n // default framebuffer handle is null, so we can't set spector metadata...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n\n /** Attach from a map of attachments */\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n if (attachment) {\n this._attachOne(attachmentPoint, attachment as WEBGLTexture);\n }\n }\n\n if (this.depthStencilAttachment) {\n this._attachOne(\n getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),\n this.depthStencilAttachment as WEBGLTexture\n );\n }\n\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);\n }\n\n // @ts-expect-error\n if (props.check !== false) {\n this._checkStatus();\n }\n }\n\n /** destroys any auto created resources etc. */\n override destroy(): void {\n super.destroy(); // destroys owned resources etc.\n if (!this.destroyed && this.handle !== null) {\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n }\n }\n\n // PRIVATE\n\n /** Check the status */\n protected _checkStatus(): void {\n const {gl} = this;\n // TODO - should we really rely on this trick? \n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle) as unknown as WebGLFramebuffer;\n const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */\n protected override createDepthStencilTexture(format: TextureFormat): Texture {\n return new WEBGLRenderbuffer(this.device, {\n id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?\n format,\n // dataFormat: GL.DEPTH_STENCIL,\n // type: GL.UNSIGNED_INT_24_8,\n width: this.width,\n height: this.height\n }) as unknown as WEBGLTexture;\n }\n\n /** \n * Attachment resize is expected to be a noop if size is same \n */\n protected override resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n // TODO Not clear that this is better than default destroy/create implementation\n\n for (const colorAttachment of this.colorAttachments) {\n (colorAttachment as WEBGLTexture).resize({width, height});\n }\n if (this.depthStencilAttachment) {\n (this.depthStencilAttachment as WEBGLTexture).resize({width, height});\n }\n return this;\n }\n\n /** Attach one attachment */\n protected _attachOne(\n attachmentPoint: GL,\n attachment: Attachment\n ): WEBGLTexture | WEBGLRenderbuffer {\n if (attachment instanceof WEBGLRenderbuffer) {\n this._attachWEBGLRenderbuffer(attachmentPoint, attachment);\n return attachment;\n } else if (Array.isArray(attachment)) {\n const [texture, layer = 0, level = 0] = attachment;\n this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);\n return texture as unknown as WEBGLTexture;\n } else if (attachment instanceof WEBGLTexture) {\n this._attachTexture(attachmentPoint, attachment, 0, 0);\n return attachment;\n }\n throw new Error('attach');\n }\n\n protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {\n this.gl.framebufferRenderbuffer(\n GL.FRAMEBUFFER,\n attachment,\n GL.RENDERBUFFER,\n renderbuffer.handle\n );\n }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel (must be 0 in WebGL1)\n */\n protected _attachTexture(\n attachment: GL,\n texture: WEBGLTexture,\n layer: number,\n level: number\n ): void {\n const {gl, gl2} = this.device;\n gl.bindTexture(texture.target, texture.handle);\n\n switch (texture.target) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n this.device.assertWebGL2();\n gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n assert(false, 'Illegal texture type');\n }\n\n gl.bindTexture(texture.target, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n"],"mappings":";AAGA,SAAQA,WAAW,EAAWC,MAAM,QAAO,cAAc;AACzD,OAAOC,EAAE,MAAM,oBAAoB;AAAC,SAE5BC,YAAY;AAAA,SACZC,iBAAiB;AAAA,SACjBC,8BAA8B;AAMtC,OAAO,MAAMC,gBAAgB,SAASN,WAAW,CAAC;EAKhD,IAAIO,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAAC;EACjC;EAEAC,WAAWA,CAACC,MAAmB,EAAEC,KAAuB,EAAE;IACxD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAGrB,MAAMC,oBAAoB,GAAGF,KAAK,CAACG,MAAM,KAAK,IAAI;IAElD,IAAI,CAACJ,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,EAAE,GAAGL,MAAM,CAACK,EAAE;IACnB,IAAI,CAACD,MAAM,GACT,IA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