@luma.gl/webgl 9.1.0-alpha.15 → 9.1.0-alpha.17
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 +3 -3
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +6 -4
- package/dist/adapter/converters/texture-formats.d.ts +49 -11
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +150 -160
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/format-utils.js +6 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +34 -30
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +52 -256
- package/dist/adapter/resources/webgl-command-buffer.d.ts +59 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +87 -31
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +3 -0
- package/dist/adapter/resources/webgl-external-texture.js +14 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +1 -2
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +38 -20
- 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 +30 -16
- package/dist/adapter/resources/webgl-shader.d.ts +1 -0
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +7 -5
- package/dist/adapter/resources/webgl-texture.d.ts +8 -14
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +119 -208
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +4 -10
- package/dist/adapter/webgl-device.d.ts +8 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +53 -22
- package/dist/context/debug/spector-types.js +1 -1
- package/dist/context/debug/spector.d.ts +5 -5
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +6 -6
- package/dist/context/debug/webgl-developer-tools.d.ts +2 -3
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +6 -19
- package/dist/context/helpers/create-browser-context.d.ts +6 -22
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +40 -32
- package/dist/dist.dev.js +366 -400
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +341 -384
- package/dist/index.cjs.map +3 -3
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +3 -3
- package/src/adapter/converters/sampler-parameters.ts +6 -4
- package/src/adapter/converters/texture-formats.ts +171 -177
- package/src/adapter/helpers/format-utils.ts +6 -0
- package/src/adapter/helpers/webgl-texture-utils.ts +99 -75
- package/src/adapter/resources/webgl-command-buffer.ts +124 -40
- package/src/adapter/resources/webgl-command-encoder.ts +6 -0
- package/src/adapter/resources/webgl-external-texture.ts +14 -0
- package/src/adapter/resources/webgl-framebuffer.ts +1 -2
- package/src/adapter/resources/webgl-render-pass.ts +44 -23
- package/src/adapter/resources/webgl-render-pipeline.ts +32 -16
- package/src/adapter/resources/webgl-shader.ts +8 -6
- package/src/adapter/resources/webgl-texture.ts +126 -235
- package/src/adapter/webgl-adapter.ts +4 -12
- package/src/adapter/webgl-device.ts +88 -48
- package/src/context/debug/spector-types.ts +1 -1
- package/src/context/debug/spector.ts +11 -11
- package/src/context/debug/webgl-developer-tools.ts +8 -31
- package/src/context/helpers/create-browser-context.ts +53 -63
|
@@ -27,13 +27,18 @@ export class WEBGLCommandBuffer extends CommandBuffer {
|
|
|
27
27
|
case 'copy-texture-to-texture':
|
|
28
28
|
_copyTextureToTexture(this.device, command.options);
|
|
29
29
|
break;
|
|
30
|
+
// case 'clear-texture':
|
|
31
|
+
// _clearTexture(this.device, command.options);
|
|
32
|
+
// break;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(command.name);
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
function _copyBufferToBuffer(device, options) {
|
|
35
|
-
const source = options.
|
|
36
|
-
const destination = options.
|
|
40
|
+
const source = options.sourceBuffer;
|
|
41
|
+
const destination = options.destinationBuffer;
|
|
37
42
|
// {In WebGL2 we can p}erform the copy on the GPU
|
|
38
43
|
// Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type
|
|
39
44
|
device.gl.bindBuffer(36662, source.handle);
|
|
@@ -56,19 +61,19 @@ function _copyBufferToTexture(device, options) {
|
|
|
56
61
|
function _copyTextureToBuffer(device, options) {
|
|
57
62
|
const {
|
|
58
63
|
/** Texture to copy to/from. */
|
|
59
|
-
|
|
64
|
+
sourceTexture,
|
|
60
65
|
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
61
66
|
mipLevel = 0,
|
|
62
67
|
/** Defines which aspects of the texture to copy to/from. */
|
|
63
68
|
aspect = 'all',
|
|
64
69
|
/** Width to copy */
|
|
65
|
-
width = options.
|
|
70
|
+
width = options.sourceTexture.width,
|
|
66
71
|
/** Height to copy */
|
|
67
|
-
height = options.
|
|
72
|
+
height = options.sourceTexture.height, depthOrArrayLayers = 0,
|
|
68
73
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
69
74
|
origin = [0, 0],
|
|
70
75
|
/** Destination buffer */
|
|
71
|
-
|
|
76
|
+
destinationBuffer,
|
|
72
77
|
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
|
|
73
78
|
byteOffset = 0,
|
|
74
79
|
/**
|
|
@@ -84,17 +89,17 @@ function _copyTextureToBuffer(device, options) {
|
|
|
84
89
|
rowsPerImage } = options;
|
|
85
90
|
// TODO - Not possible to read just stencil or depth part in WebGL?
|
|
86
91
|
if (aspect !== 'all') {
|
|
87
|
-
throw new Error('not supported');
|
|
92
|
+
throw new Error('aspect not supported in WebGL');
|
|
88
93
|
}
|
|
89
94
|
// TODO - mipLevels are set when attaching texture to framebuffer
|
|
90
95
|
if (mipLevel !== 0 || depthOrArrayLayers !== 0 || bytesPerRow || rowsPerImage) {
|
|
91
96
|
throw new Error('not implemented');
|
|
92
97
|
}
|
|
93
98
|
// Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature
|
|
94
|
-
const { framebuffer, destroyFramebuffer } = getFramebuffer(
|
|
99
|
+
const { framebuffer, destroyFramebuffer } = getFramebuffer(sourceTexture);
|
|
95
100
|
let prevHandle;
|
|
96
101
|
try {
|
|
97
|
-
const webglBuffer =
|
|
102
|
+
const webglBuffer = destinationBuffer;
|
|
98
103
|
const sourceWidth = width || framebuffer.width;
|
|
99
104
|
const sourceHeight = height || framebuffer.height;
|
|
100
105
|
const sourceParams = getTextureFormatWebGL(framebuffer.colorAttachments[0].texture.props.format);
|
|
@@ -148,7 +153,7 @@ export function readPixelsToBuffer(
|
|
|
148
153
|
function _copyTextureToTexture(device, options) {
|
|
149
154
|
const {
|
|
150
155
|
/** Texture to copy to/from. */
|
|
151
|
-
|
|
156
|
+
sourceTexture,
|
|
152
157
|
/** Mip-map level of the texture to copy to (Default 0) */
|
|
153
158
|
destinationMipLevel = 0,
|
|
154
159
|
/** Defines which aspects of the texture to copy to/from. */
|
|
@@ -158,7 +163,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
158
163
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */
|
|
159
164
|
destinationOrigin = [0, 0],
|
|
160
165
|
/** Texture to copy to/from. */
|
|
161
|
-
|
|
166
|
+
destinationTexture
|
|
162
167
|
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
163
168
|
// destinationMipLevel = options.mipLevel,
|
|
164
169
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
@@ -166,10 +171,10 @@ function _copyTextureToTexture(device, options) {
|
|
|
166
171
|
/** Defines which aspects of the texture to copy to/from. */
|
|
167
172
|
// destinationAspect = options.aspect,
|
|
168
173
|
} = options;
|
|
169
|
-
let { width = options.
|
|
174
|
+
let { width = options.destinationTexture.width, height = options.destinationTexture.height
|
|
170
175
|
// depthOrArrayLayers = 0
|
|
171
176
|
} = options;
|
|
172
|
-
const { framebuffer, destroyFramebuffer } = getFramebuffer(
|
|
177
|
+
const { framebuffer, destroyFramebuffer } = getFramebuffer(sourceTexture);
|
|
173
178
|
const [sourceX, sourceY] = origin;
|
|
174
179
|
const [destinationX, destinationY, destinationZ] = destinationOrigin;
|
|
175
180
|
// @ts-expect-error native bindFramebuffer is overridden by our state tracker
|
|
@@ -178,8 +183,8 @@ function _copyTextureToTexture(device, options) {
|
|
|
178
183
|
// const prevBuffer = gl.readBuffer(attachment);
|
|
179
184
|
let texture = null;
|
|
180
185
|
let textureTarget;
|
|
181
|
-
if (
|
|
182
|
-
texture =
|
|
186
|
+
if (destinationTexture instanceof WEBGLTexture) {
|
|
187
|
+
texture = destinationTexture;
|
|
183
188
|
width = Number.isFinite(width) ? width : texture.width;
|
|
184
189
|
height = Number.isFinite(height) ? height : texture.height;
|
|
185
190
|
texture.bind(0);
|
|
@@ -207,7 +212,69 @@ function _copyTextureToTexture(device, options) {
|
|
|
207
212
|
framebuffer.destroy();
|
|
208
213
|
}
|
|
209
214
|
}
|
|
210
|
-
|
|
215
|
+
/** Clear one mip level of a texture *
|
|
216
|
+
function _clearTexture(device: WebGLDevice, options: ClearTextureOptions) {
|
|
217
|
+
const BORDER = 0;
|
|
218
|
+
const {dimension, width, height, depth = 0, mipLevel = 0} = options;
|
|
219
|
+
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
220
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
221
|
+
|
|
222
|
+
switch (dimension) {
|
|
223
|
+
case '2d-array':
|
|
224
|
+
case '3d':
|
|
225
|
+
if (compressed) {
|
|
226
|
+
// prettier-ignore
|
|
227
|
+
device.gl.compressedTexImage3D(glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, null);
|
|
228
|
+
} else {
|
|
229
|
+
// prettier-ignore
|
|
230
|
+
device.gl.texImage3D( glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
|
|
234
|
+
case '2d':
|
|
235
|
+
case 'cube':
|
|
236
|
+
if (compressed) {
|
|
237
|
+
// prettier-ignore
|
|
238
|
+
device.gl.compressedTexImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, null);
|
|
239
|
+
} else {
|
|
240
|
+
// prettier-ignore
|
|
241
|
+
device.gl.texImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, glFormat, glType, null);
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
|
|
245
|
+
default:
|
|
246
|
+
throw new Error(dimension);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
*/
|
|
250
|
+
// function _readTexture(device: WebGLDevice, options: CopyTextureToBufferOptions) {}
|
|
251
|
+
// HELPERS
|
|
252
|
+
/**
|
|
253
|
+
* In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.
|
|
254
|
+
* @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.
|
|
255
|
+
* @returns glTarget unchanged, if dimension !== 'cube'.
|
|
256
|
+
*/
|
|
257
|
+
export function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
258
|
+
return dimension === 'cube' ? 34069 + level : glTarget;
|
|
259
|
+
}
|
|
260
|
+
/** Wrap a texture in a framebuffer so that we can use WebGL APIs that work on framebuffers */
|
|
261
|
+
function getFramebuffer(source) {
|
|
262
|
+
if (source instanceof Texture) {
|
|
263
|
+
const { width, height, id } = source;
|
|
264
|
+
const framebuffer = source.device.createFramebuffer({
|
|
265
|
+
id: `framebuffer-for-${id}`,
|
|
266
|
+
width,
|
|
267
|
+
height,
|
|
268
|
+
colorAttachments: [source]
|
|
269
|
+
});
|
|
270
|
+
return { framebuffer, destroyFramebuffer: true };
|
|
271
|
+
}
|
|
272
|
+
return { framebuffer: source, destroyFramebuffer: false };
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Returns number of components in a specific readPixels WebGL format
|
|
276
|
+
* @todo use shadertypes utils instead?
|
|
277
|
+
*/
|
|
211
278
|
export function glFormatToComponents(format) {
|
|
212
279
|
switch (format) {
|
|
213
280
|
case 6406:
|
|
@@ -228,7 +295,10 @@ export function glFormatToComponents(format) {
|
|
|
228
295
|
throw new Error('GLFormat');
|
|
229
296
|
}
|
|
230
297
|
}
|
|
231
|
-
|
|
298
|
+
/**
|
|
299
|
+
* Return byte count for given readPixels WebGL type
|
|
300
|
+
* @todo use shadertypes utils instead?
|
|
301
|
+
*/
|
|
232
302
|
export function glTypeToBytes(type) {
|
|
233
303
|
switch (type) {
|
|
234
304
|
case 5121:
|
|
@@ -244,17 +314,3 @@ export function glTypeToBytes(type) {
|
|
|
244
314
|
throw new Error('GLType');
|
|
245
315
|
}
|
|
246
316
|
}
|
|
247
|
-
// Helper methods
|
|
248
|
-
function getFramebuffer(source) {
|
|
249
|
-
if (source instanceof Texture) {
|
|
250
|
-
const { width, height, id } = source;
|
|
251
|
-
const framebuffer = source.device.createFramebuffer({
|
|
252
|
-
id: `framebuffer-for-${id}`,
|
|
253
|
-
width,
|
|
254
|
-
height,
|
|
255
|
-
colorAttachments: [source]
|
|
256
|
-
});
|
|
257
|
-
return { framebuffer, destroyFramebuffer: true };
|
|
258
|
-
}
|
|
259
|
-
return { framebuffer: source, destroyFramebuffer: false };
|
|
260
|
-
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAG3B,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;IAQvD,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"}
|
|
@@ -30,6 +30,9 @@ export class WEBGLCommandEncoder extends CommandEncoder {
|
|
|
30
30
|
copyTextureToTexture(options) {
|
|
31
31
|
this.commandBuffer.commands.push({ name: 'copy-texture-to-texture', options });
|
|
32
32
|
}
|
|
33
|
+
// clearTexture(options: ClearTextureOptions): void {
|
|
34
|
+
// this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});
|
|
35
|
+
// }
|
|
33
36
|
pushDebugGroup(groupLabel) { }
|
|
34
37
|
popDebugGroup() { }
|
|
35
38
|
insertDebugMarker(markerLabel) { }
|
|
@@ -71,6 +71,20 @@ export class WEBGLExternalTexture extends WEBGLTexture {
|
|
|
71
71
|
data.addEventListener('loadeddata', () => this.initialize(props));
|
|
72
72
|
return this;
|
|
73
73
|
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
initialize() {
|
|
77
|
+
// TODO - Video handling, move to ExternalTexture?
|
|
78
|
+
// if (isVideo) {
|
|
79
|
+
// this._video = {
|
|
80
|
+
// video: data,
|
|
81
|
+
// // TODO - should we be using the sampler parameters here?
|
|
82
|
+
// parameters: {},
|
|
83
|
+
// // @ts-expect-error HTMLVideoElement.HAVE_CURRENT_DATA is not declared
|
|
84
|
+
// lastTime: data.readyState >= HTMLVideoElement.HAVE_CURRENT_DATA ? data.currentTime : -1
|
|
85
|
+
// };
|
|
86
|
+
// }
|
|
87
|
+
}
|
|
74
88
|
|
|
75
89
|
update(): this {
|
|
76
90
|
if (this._video) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"names":[],"mappings":"AAIA,OA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AAE,sBAAsB,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IAEzB,gBAAgB,EAAE,gBAAgB,EAAE,CAAM;IAC1C,sBAAsB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;gBAE3C,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB;IAsBxD,+CAA+C;IACtC,OAAO,IAAI,IAAI;IAQxB,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAqCnC,mGAAmG;IAYnG;;;;;OAKG;IACH,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,gBAAgB,GAAG,IAAI;CA8BlF;AAqCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BE"}
|
|
@@ -52,8 +52,7 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
52
52
|
this._attachTextureView(attachmentPoint, this.depthStencilAttachment);
|
|
53
53
|
}
|
|
54
54
|
/** Check the status */
|
|
55
|
-
|
|
56
|
-
if (this.props.check !== false) {
|
|
55
|
+
if (this.device.props.debug) {
|
|
57
56
|
const status = this.gl.checkFramebufferStatus(36160);
|
|
58
57
|
if (status !== 36053) {
|
|
59
58
|
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAChF,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAK,YAAY,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAChF,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAK,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAOpD,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B,8DAA8D;IAC9D,YAAY,EAAE,YAAY,CAAC;gBAEf,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe;IAoCvD,GAAG,IAAI,IAAI;IAKX,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IACxC,aAAa,IAAI,IAAI;IACrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAO5C;;OAEG;IACH,aAAa,CAAC,UAAU,GAAE,oBAAyB,GAAG,IAAI;IAmD1D,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKpC,iBAAiB,IAAI,IAAI;IAOlC;;OAEG;IACH,SAAS,CAAC,KAAK,IAAI,IAAI;IA0CvB;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,UAAU,GAAE,MAAU,EAAE,KAAK,GAAE,YAA2B;CA8CtF"}
|
|
@@ -5,11 +5,6 @@ import { RenderPass } from '@luma.gl/core';
|
|
|
5
5
|
import { GL } from '@luma.gl/constants';
|
|
6
6
|
import { withGLParameters } from "../../context/state-tracker/with-parameters.js";
|
|
7
7
|
import { setGLParameters } from "../../context/parameters/unified-parameter-api.js";
|
|
8
|
-
// Should collapse during minification
|
|
9
|
-
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
10
|
-
const GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
11
|
-
const GL_COLOR_BUFFER_BIT = 0x00004000;
|
|
12
|
-
const GL_COLOR = 0x1800;
|
|
13
8
|
const COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPUColorWrite RED, GREEN, BLUE, ALPHA
|
|
14
9
|
export class WEBGLRenderPass extends RenderPass {
|
|
15
10
|
device;
|
|
@@ -35,6 +30,14 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
35
30
|
// TODO - do parameters (scissorRect) affect the clear operation?
|
|
36
31
|
this.device.pushState();
|
|
37
32
|
this.setParameters({ viewport, ...this.props.parameters });
|
|
33
|
+
// Specify mapping of draw buffer locations to color attachments
|
|
34
|
+
if (this.props.framebuffer) {
|
|
35
|
+
const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);
|
|
36
|
+
this.device.gl.drawBuffers(drawBuffers);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.device.gl.drawBuffers([1029]);
|
|
40
|
+
}
|
|
38
41
|
// Hack - for now WebGL draws in "immediate mode" (instead of queueing the operations)...
|
|
39
42
|
this.clear();
|
|
40
43
|
}
|
|
@@ -105,29 +108,38 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
105
108
|
* Optionally clears depth, color and stencil buffers based on parameters
|
|
106
109
|
*/
|
|
107
110
|
clear() {
|
|
111
|
+
const DEFAULT_CLEAR_COLOR = [0, 0, 0, 1];
|
|
112
|
+
const DEFAULT_CLEAR_DEPTH = 1;
|
|
113
|
+
const DEFAULT_CLEAR_STENCIL = 0;
|
|
108
114
|
const glParameters = { ...this.glParameters };
|
|
109
115
|
let clearMask = 0;
|
|
110
|
-
if (this.props.
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
if (this.props.clearColors) {
|
|
117
|
+
this.props.clearColors.forEach((color, drawBufferIndex) => {
|
|
118
|
+
if (color) {
|
|
119
|
+
this.clearColorBuffer(drawBufferIndex, color);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (this.props.clearColor !== false && this.props.clearColors === undefined) {
|
|
124
|
+
clearMask |= 16384;
|
|
125
|
+
const clearColor = this.props.clearColor === true ? DEFAULT_CLEAR_COLOR : this.props.clearColor;
|
|
126
|
+
glParameters.clearColor = clearColor;
|
|
113
127
|
}
|
|
114
128
|
if (this.props.clearDepth !== false) {
|
|
115
|
-
clearMask |=
|
|
116
|
-
glParameters.clearDepth =
|
|
129
|
+
clearMask |= 256;
|
|
130
|
+
glParameters.clearDepth =
|
|
131
|
+
this.props.clearDepth === true ? DEFAULT_CLEAR_DEPTH : this.props.clearDepth;
|
|
117
132
|
}
|
|
118
133
|
if (this.props.clearStencil !== false) {
|
|
119
|
-
clearMask |=
|
|
120
|
-
glParameters.clearStencil =
|
|
134
|
+
clearMask |= 1024;
|
|
135
|
+
glParameters.clearStencil =
|
|
136
|
+
this.props.clearStencil === true ? DEFAULT_CLEAR_STENCIL : this.props.clearStencil;
|
|
121
137
|
}
|
|
122
138
|
if (clearMask !== 0) {
|
|
123
139
|
// Temporarily set any clear "colors" and call clear
|
|
124
140
|
withGLParameters(this.device.gl, glParameters, () => {
|
|
125
141
|
this.device.gl.clear(clearMask);
|
|
126
142
|
});
|
|
127
|
-
// TODO - clear multiple color attachments
|
|
128
|
-
// for (attachment of this.framebuffer.colorAttachments) {
|
|
129
|
-
// this.clearColorBuffer
|
|
130
|
-
// }
|
|
131
143
|
}
|
|
132
144
|
}
|
|
133
145
|
/**
|
|
@@ -137,16 +149,22 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
137
149
|
withGLParameters(this.device.gl, { framebuffer: this.props.framebuffer }, () => {
|
|
138
150
|
// Method selection per OpenGL ES 3 docs
|
|
139
151
|
switch (value.constructor) {
|
|
152
|
+
case Int8Array:
|
|
153
|
+
case Int16Array:
|
|
140
154
|
case Int32Array:
|
|
141
|
-
this.device.gl.clearBufferiv(
|
|
155
|
+
this.device.gl.clearBufferiv(6144, drawBuffer, value);
|
|
142
156
|
break;
|
|
157
|
+
case Uint8Array:
|
|
158
|
+
case Uint8ClampedArray:
|
|
159
|
+
case Uint16Array:
|
|
143
160
|
case Uint32Array:
|
|
144
|
-
this.device.gl.clearBufferuiv(
|
|
161
|
+
this.device.gl.clearBufferuiv(6144, drawBuffer, value);
|
|
145
162
|
break;
|
|
146
163
|
case Float32Array:
|
|
147
|
-
|
|
148
|
-
this.device.gl.clearBufferfv(GL_COLOR, drawBuffer, value);
|
|
164
|
+
this.device.gl.clearBufferfv(6144, drawBuffer, value);
|
|
149
165
|
break;
|
|
166
|
+
default:
|
|
167
|
+
throw new Error('clearColorBuffer: color must be typed array');
|
|
150
168
|
}
|
|
151
169
|
});
|
|
152
170
|
}
|
|
@@ -54,7 +54,7 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
54
54
|
setUniformsWebGL(uniforms: Record<string, UniformValue>): void;
|
|
55
55
|
protected _linkShaders(): Promise<void>;
|
|
56
56
|
/** Report link status. First, check for shader compilation failures if linking fails */
|
|
57
|
-
_reportLinkStatus(status: 'success' | 'linking' | 'validation'): void
|
|
57
|
+
_reportLinkStatus(status: 'success' | 'linking' | 'validation'): Promise<void>;
|
|
58
58
|
/**
|
|
59
59
|
* Get the shader compilation status
|
|
60
60
|
* TODO - Load log even when no error reported, to catch warnings?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,UAAU,EACV,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,cAAc,EAAM,MAAM,eAAe,CAAC;AAUlD,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C,OAAO,EAAC,WAAW,EAAC,0BAAuB;AAK3C,OAAO,EAAC,sBAAsB,EAAC,sCAAmC;AAKlE,oCAAoC;AACpC,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,yDAAyD;IACzD,MAAM,EAAE,WAAW,CA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;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAC,GAAG,IAAI;IA0D3F;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,EAAE,UAAU,CAAC;QACvB,UAAU,CAAC,EAAE,wBAAwB,CAAC;QACtC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;QAC7B,WAAW,EAAE,WAAW,CAAC;QACzB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;KAC5C,GAAG,OAAO;IAgGF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;cAkBhD,YAAY;IA2B5B,wFAAwF;IAClF,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCpF;;;;OAIG;IACH,cAAc,IAAI,SAAS,GAAG,SAAS,GAAG,YAAY;IAmBtD,6DAA6D;IACvD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3C;;;;OAIG;IACH,sBAAsB;IAuBtB,iDAAiD;IACjD,cAAc;IAyFd;;;OAGG;IACH,cAAc;CASf"}
|
|
@@ -78,11 +78,11 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
78
78
|
// This convention allows shaders to name uniform blocks as `uniform appUniforms {} app;`
|
|
79
79
|
// and reference them as `app` from both GLSL and JS.
|
|
80
80
|
// TODO - this is rather hacky - we could also remap the name directly in the shader layout.
|
|
81
|
-
const binding = this.shaderLayout.bindings.find(
|
|
82
|
-
this.shaderLayout.bindings.find(
|
|
81
|
+
const binding = this.shaderLayout.bindings.find(binding_ => binding_.name === name) ||
|
|
82
|
+
this.shaderLayout.bindings.find(binding_ => binding_.name === `${name}Uniforms`);
|
|
83
83
|
if (!binding) {
|
|
84
84
|
const validBindings = this.shaderLayout.bindings
|
|
85
|
-
.map(
|
|
85
|
+
.map(binding_ => `"${binding_.name}"`)
|
|
86
86
|
.join(', ');
|
|
87
87
|
if (!options?.disableWarnings) {
|
|
88
88
|
log.warn(`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
|
|
@@ -220,21 +220,34 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
220
220
|
this._reportLinkStatus(status);
|
|
221
221
|
}
|
|
222
222
|
/** Report link status. First, check for shader compilation failures if linking fails */
|
|
223
|
-
_reportLinkStatus(status) {
|
|
223
|
+
async _reportLinkStatus(status) {
|
|
224
224
|
switch (status) {
|
|
225
225
|
case 'success':
|
|
226
226
|
return;
|
|
227
227
|
default:
|
|
228
228
|
// First check for shader compilation failures if linking fails
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
switch (this.vs.compilationStatus) {
|
|
230
|
+
case 'error':
|
|
231
|
+
this.vs.debugShader();
|
|
232
|
+
throw new Error(`Error during compilation of shader ${this.vs.id}`);
|
|
233
|
+
case 'pending':
|
|
234
|
+
this.vs.asyncCompilationStatus.then(() => this.vs.debugShader());
|
|
235
|
+
break;
|
|
236
|
+
case 'success':
|
|
237
|
+
break;
|
|
232
238
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
239
|
+
switch (this.fs?.compilationStatus) {
|
|
240
|
+
case 'error':
|
|
241
|
+
this.fs.debugShader();
|
|
242
|
+
throw new Error(`Error during compilation of shader ${this.fs.id}`);
|
|
243
|
+
case 'pending':
|
|
244
|
+
this.fs.asyncCompilationStatus.then(() => this.fs.debugShader());
|
|
245
|
+
break;
|
|
246
|
+
case 'success':
|
|
247
|
+
break;
|
|
236
248
|
}
|
|
237
|
-
|
|
249
|
+
const linkErrorLog = this.device.gl.getProgramInfoLog(this.handle);
|
|
250
|
+
throw new Error(`Error during ${status}: ${linkErrorLog}`);
|
|
238
251
|
}
|
|
239
252
|
}
|
|
240
253
|
/**
|
|
@@ -290,11 +303,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
290
303
|
texturesRenderable = false;
|
|
291
304
|
}
|
|
292
305
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
306
|
+
// TODO - remove this should be handled by ExternalTexture
|
|
307
|
+
// for (const [, texture] of Object.entries(this.bindings)) {
|
|
308
|
+
// if (texture instanceof WEBGLTexture) {
|
|
309
|
+
// texture.update();
|
|
310
|
+
// }
|
|
311
|
+
// }
|
|
298
312
|
return texturesRenderable;
|
|
299
313
|
}
|
|
300
314
|
/** Apply any bindings (before each draw call) */
|
|
@@ -8,6 +8,7 @@ export declare class WEBGLShader extends Shader {
|
|
|
8
8
|
readonly handle: WebGLShader;
|
|
9
9
|
constructor(device: WebGLDevice, props: ShaderProps);
|
|
10
10
|
destroy(): void;
|
|
11
|
+
get asyncCompilationStatus(): Promise<'pending' | 'success' | 'error'>;
|
|
11
12
|
getCompilationInfo(): Promise<readonly CompilerMessage[]>;
|
|
12
13
|
getCompilationInfoSync(): readonly CompilerMessage[];
|
|
13
14
|
getTranslatedSource(): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-shader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAM,MAAM,eAAe,CAAC;AAGxE,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C;;GAEG;AACH,qBAAa,WAAY,SAAQ,MAAM;IACrC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW;IAgB1C,OAAO,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"webgl-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-shader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAM,MAAM,eAAe,CAAC;AAGxE,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C;;GAEG;AACH,qBAAa,WAAY,SAAQ,MAAM;IACrC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW;IAgB1C,OAAO,IAAI,IAAI;IASxB,IAAI,sBAAsB,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,CAErE;IAEc,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAK/D,sBAAsB,IAAI,SAAS,eAAe,EAAE;IAKpD,mBAAmB,IAAI,MAAM,GAAG,IAAI;IAQ7C,kDAAkD;cAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCvD,6DAA6D;cAC7C,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5D;;;;OAIG;IACH,SAAS,CAAC,qBAAqB;CAKhC"}
|
|
@@ -33,13 +33,16 @@ export class WEBGLShader extends Shader {
|
|
|
33
33
|
this.destroyed = true;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
get asyncCompilationStatus() {
|
|
37
|
+
return this._waitForCompilationComplete().then(() => this.compilationStatus);
|
|
38
|
+
}
|
|
36
39
|
async getCompilationInfo() {
|
|
37
40
|
await this._waitForCompilationComplete();
|
|
38
41
|
return this.getCompilationInfoSync();
|
|
39
42
|
}
|
|
40
43
|
getCompilationInfoSync() {
|
|
41
|
-
const
|
|
42
|
-
return
|
|
44
|
+
const shaderLog = this.device.gl.getShaderInfoLog(this.handle);
|
|
45
|
+
return shaderLog ? parseShaderCompilerLog(shaderLog) : [];
|
|
43
46
|
}
|
|
44
47
|
getTranslatedSource() {
|
|
45
48
|
const extensions = this.device.getExtension('WEBGL_debug_shaders');
|
|
@@ -49,13 +52,12 @@ export class WEBGLShader extends Shader {
|
|
|
49
52
|
// PRIVATE METHODS
|
|
50
53
|
/** Compile a shader and get compilation status */
|
|
51
54
|
async _compile(source) {
|
|
52
|
-
|
|
53
|
-
source = addGLSLVersion(source);
|
|
55
|
+
source = source.startsWith('#version ') ? source : `#version 300 es\n${source}`;
|
|
54
56
|
const { gl } = this.device;
|
|
55
57
|
gl.shaderSource(this.handle, source);
|
|
56
58
|
gl.compileShader(this.handle);
|
|
57
59
|
// For performance reasons, avoid checking shader compilation errors on production
|
|
58
|
-
if (
|
|
60
|
+
if (!this.device.props.debug) {
|
|
59
61
|
this.compilationStatus = 'pending';
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
@@ -8,14 +8,16 @@ import { WEBGLTextureView } from "./webgl-texture-view.js";
|
|
|
8
8
|
* WebGL... the texture API from hell... hopefully made simpler
|
|
9
9
|
*/
|
|
10
10
|
export declare class WEBGLTexture extends Texture {
|
|
11
|
-
readonly MAX_ATTRIBUTES: number;
|
|
12
11
|
readonly device: WebGLDevice;
|
|
13
12
|
readonly gl: WebGL2RenderingContext;
|
|
14
13
|
handle: WebGLTexture;
|
|
15
14
|
sampler: WEBGLSampler;
|
|
16
15
|
view: WEBGLTextureView;
|
|
17
16
|
mipmaps: boolean;
|
|
17
|
+
/** Whether the internal format is compressed */
|
|
18
|
+
compressed: boolean;
|
|
18
19
|
/**
|
|
20
|
+
* The WebGL target corresponding to the texture type
|
|
19
21
|
* @note `target` cannot be modified by bind:
|
|
20
22
|
* textures are special because when you first bind them to a target,
|
|
21
23
|
* When you first bind a texture as a GL_TEXTURE_2D, you are saying that this texture is a 2D texture.
|
|
@@ -30,27 +32,16 @@ export declare class WEBGLTexture extends Texture {
|
|
|
30
32
|
glType: GLPixelType;
|
|
31
33
|
/** The WebGL constant corresponding to the WebGPU style constant in format */
|
|
32
34
|
glInternalFormat: GL;
|
|
33
|
-
/**
|
|
34
|
-
compressed: boolean;
|
|
35
|
-
/** Texture binding slot */
|
|
35
|
+
/** Texture binding slot - TODO - move to texture view? */
|
|
36
36
|
textureUnit: number;
|
|
37
|
-
/** For automatically updating video */
|
|
38
|
-
_video: {
|
|
39
|
-
video: HTMLVideoElement;
|
|
40
|
-
parameters: any;
|
|
41
|
-
lastTime: number;
|
|
42
|
-
} | null;
|
|
43
37
|
constructor(device: Device, props: TextureProps);
|
|
44
38
|
/**
|
|
45
39
|
* Initialize texture with supplied props
|
|
46
40
|
*/
|
|
47
|
-
|
|
41
|
+
_initialize(propsWithData: TextureProps): void;
|
|
48
42
|
destroy(): void;
|
|
49
|
-
toString(): string;
|
|
50
43
|
createView(props: TextureViewProps): WEBGLTextureView;
|
|
51
44
|
setSampler(sampler?: Sampler | SamplerProps): void;
|
|
52
|
-
/** Update external texture (video frame or canvas) */
|
|
53
|
-
update(): void;
|
|
54
45
|
generateMipmap(params?: {}): void;
|
|
55
46
|
copyExternalImage(options: {
|
|
56
47
|
image: ExternalImage;
|
|
@@ -66,6 +57,7 @@ export declare class WEBGLTexture extends Texture {
|
|
|
66
57
|
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
67
58
|
colorSpace?: 'srgb';
|
|
68
59
|
premultipliedAlpha?: boolean;
|
|
60
|
+
flipY?: boolean;
|
|
69
61
|
}): {
|
|
70
62
|
width: number;
|
|
71
63
|
height: number;
|
|
@@ -96,6 +88,8 @@ export declare class WEBGLTexture extends Texture {
|
|
|
96
88
|
*/
|
|
97
89
|
setTextureCubeArrayData(data: TextureCubeArrayData): void;
|
|
98
90
|
setTextureCubeFaceData(lodData: Texture2DData, face: TextureCubeFace, depth?: number): void;
|
|
91
|
+
/** Update external texture (video frame or canvas) @deprecated Use ExternalTexture */
|
|
92
|
+
update(): void;
|
|
99
93
|
/** @todo update this method to accept LODs */
|
|
100
94
|
setImageDataForFace(options: any): void;
|
|
101
95
|
_getImageDataMap(faceData: Record<string | GL, any>): Record<GL, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,
|
|
1
|
+
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,EAEZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,OAAO,EAAM,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,EAAE,EACF,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,gBAAgB,EAAC,gCAA6B;AAYtD;;GAEG;AACH,qBAAa,YAAa,SAAQ,OAAO;IAEvC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACpC,MAAM,EAAE,YAAY,CAAC;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