@luma.gl/webgl 9.1.0-alpha.1 → 9.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +18 -11
- package/dist/adapter/converters/texture-formats.d.ts +1 -1
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +9 -16
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +0 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +4 -4
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +11 -9
- package/dist/adapter/resources/webgl-framebuffer.js +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +17 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +21 -3
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +23 -29
- package/dist/adapter/resources/webgl-transform-feedback.js +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +3 -0
- package/dist/adapter/webgl-adapter.d.ts +21 -0
- package/dist/adapter/webgl-adapter.d.ts.map +1 -0
- package/dist/adapter/webgl-adapter.js +91 -0
- package/dist/adapter/webgl-device.d.ts +15 -27
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +32 -112
- package/dist/classic/copy-and-blit.d.ts +1 -0
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +11 -10
- package/dist/context/debug/spector-types.d.ts +1108 -0
- package/dist/context/debug/spector-types.d.ts.map +1 -0
- package/dist/context/debug/spector-types.js +697 -0
- package/dist/context/debug/spector.d.ts +12 -8
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +23 -17
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts +9 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts.map +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +181 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts +43 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts.map +1 -0
- package/dist/context/state-tracker/{track-context-state.js → webgl-state-tracker.js} +44 -74
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +5 -4
- package/dist/dist.dev.js +352 -236
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +355 -238
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/utils/split-uniforms-and-bindings.d.ts +1 -1
- package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/utils/uid.d.ts +7 -0
- package/dist/utils/uid.d.ts.map +1 -0
- package/dist/utils/uid.js +14 -0
- package/package.json +3 -3
- package/src/adapter/converters/device-parameters.ts +18 -12
- package/src/adapter/converters/texture-formats.ts +12 -20
- package/src/adapter/device-helpers/webgl-device-features.ts +0 -1
- package/src/adapter/helpers/webgl-texture-utils.ts +12 -9
- package/src/adapter/resources/webgl-framebuffer.ts +1 -1
- package/src/adapter/resources/webgl-render-pass.ts +17 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +1 -1
- package/src/adapter/resources/webgl-texture.ts +42 -29
- package/src/adapter/resources/webgl-transform-feedback.ts +1 -1
- package/src/adapter/resources/webgl-vertex-array.ts +3 -0
- package/src/adapter/webgl-adapter.ts +113 -0
- package/src/adapter/webgl-device.ts +32 -135
- package/src/classic/copy-and-blit.ts +14 -9
- package/src/context/debug/spector-types.ts +1154 -0
- package/src/context/debug/spector.ts +38 -29
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +202 -0
- package/src/context/state-tracker/{track-context-state.ts → webgl-state-tracker.ts} +55 -94
- package/src/context/state-tracker/with-parameters.ts +5 -4
- package/src/index.ts +5 -7
- package/src/utils/split-uniforms-and-bindings.ts +3 -3
- package/src/utils/uid.ts +16 -0
- package/dist/context/state-tracker/track-context-state.d.ts +0 -22
- package/dist/context/state-tracker/track-context-state.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAgD,MAAM,eAAe,CAAC;AAClG,OAAO,EAAC,MAAM,EAAO,UAAU,EAA+B,MAAM,eAAe,CAAC;AAEpF,OAAO,KAAK,EAGV,UAAU,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAgD,MAAM,eAAe,CAAC;AAClG,OAAO,EAAC,MAAM,EAAO,UAAU,EAA+B,MAAM,eAAe,CAAC;AAEpF,OAAO,KAAK,EAGV,UAAU,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAM5B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACnD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAgBH;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,YAAY,EACxB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAeH;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAC9C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAeH;AAED,kCAAkC;AAClC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,QAgNzE;AAyBD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,UAAU,CAW5F;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,CAW9F"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { log } from '@luma.gl/core';
|
|
5
5
|
import { GL } from '@luma.gl/constants';
|
|
6
|
-
import { pushContextState, popContextState } from "../../context/state-tracker/track-context-state.js";
|
|
7
6
|
import { setGLParameters } from "../../context/parameters/unified-parameter-api.js";
|
|
8
7
|
/* eslint-disable no-unused-expressions */ // For expression ? gl.enable() : gl.disable()
|
|
9
8
|
/**
|
|
@@ -21,14 +20,14 @@ export function withDeviceAndGLParameters(device, parameters, glParameters, func
|
|
|
21
20
|
}
|
|
22
21
|
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
23
22
|
const webglDevice = device;
|
|
24
|
-
|
|
23
|
+
webglDevice.pushState();
|
|
25
24
|
try {
|
|
26
25
|
setDeviceParameters(device, parameters);
|
|
27
26
|
setGLParameters(webglDevice.gl, glParameters);
|
|
28
27
|
return func(device);
|
|
29
28
|
}
|
|
30
29
|
finally {
|
|
31
|
-
|
|
30
|
+
webglDevice.popState();
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
/**
|
|
@@ -47,13 +46,13 @@ export function withGLParameters(device, parameters, func) {
|
|
|
47
46
|
}
|
|
48
47
|
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
49
48
|
const webglDevice = device;
|
|
50
|
-
|
|
49
|
+
webglDevice.pushState();
|
|
51
50
|
try {
|
|
52
51
|
setGLParameters(webglDevice.gl, parameters);
|
|
53
52
|
return func(device);
|
|
54
53
|
}
|
|
55
54
|
finally {
|
|
56
|
-
|
|
55
|
+
webglDevice.popState();
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
@@ -69,16 +68,15 @@ export function withDeviceParameters(device, parameters, func) {
|
|
|
69
68
|
// Avoid setting state if no parameters provided. Just call and return
|
|
70
69
|
return func(device);
|
|
71
70
|
}
|
|
72
|
-
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
// Wrap in a try-catch to ensure that parameters are restored on exceptions'
|
|
72
|
+
const webglDevice = device;
|
|
73
|
+
webglDevice.pushState();
|
|
75
74
|
try {
|
|
76
75
|
setDeviceParameters(device, parameters);
|
|
77
76
|
return func(device);
|
|
78
77
|
}
|
|
79
78
|
finally {
|
|
80
|
-
|
|
81
|
-
popContextState(device.gl);
|
|
79
|
+
webglDevice.popState();
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
/** Set WebGPU Style Parameters */
|
|
@@ -218,8 +216,17 @@ export function setDeviceParameters(device, parameters) {
|
|
|
218
216
|
// // handled by stencilPassOperation
|
|
219
217
|
// },
|
|
220
218
|
// COLOR STATE
|
|
219
|
+
switch (parameters.blend) {
|
|
220
|
+
case true:
|
|
221
|
+
gl.enable(3042);
|
|
222
|
+
break;
|
|
223
|
+
case false:
|
|
224
|
+
gl.disable(3042);
|
|
225
|
+
break;
|
|
226
|
+
default:
|
|
227
|
+
// leave WebGL blend state unchanged if `parameters.blend` is not set
|
|
228
|
+
}
|
|
221
229
|
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
222
|
-
gl.enable(3042);
|
|
223
230
|
const colorEquation = convertBlendOperationToEquation('blendColorOperation', parameters.blendColorOperation || 'add');
|
|
224
231
|
const alphaEquation = convertBlendOperationToEquation('blendAlphaOperation', parameters.blendAlphaOperation || 'add');
|
|
225
232
|
gl.blendEquationSeparate(colorEquation, alphaEquation);
|
|
@@ -65,7 +65,7 @@ export declare function getTextureFormatWebGL(format: TextureFormat): {
|
|
|
65
65
|
export declare function getDepthStencilAttachmentWebGL(format: TextureFormat): GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
|
|
66
66
|
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
67
67
|
export declare function getTextureFormatBytesPerPixel(format: TextureFormat): number;
|
|
68
|
-
export declare function getWebGLPixelDataFormat(
|
|
68
|
+
export declare function getWebGLPixelDataFormat(channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra', integer: boolean, normalized: boolean, format: GL): GLTexelDataFormat;
|
|
69
69
|
export {};
|
|
70
70
|
/**
|
|
71
71
|
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAC,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AA2CpF,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAwBrE,CAAC;AAEF,wGAAwG;AASxG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAEhE;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,sBAAsB,EAC1B,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,YAAY,GACvB,OAAO,CAGT;AAID,0CAA0C;AAC1C,KAAK,MAAM,GAAG;IACZ,EAAE,CAAC,EAAE,EAAE,CAAC;IACR,mGAAmG;IACnG,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,wDAAwD;IACxD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,eAAe;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iBAAiB;IACjB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,CAAC,CAAC,EAAE,aAAa,CAAC;IAClB,uCAAuC;IACvC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,uCAAuC;IACvC,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB,iCAAiC;IACjC,IAAI,CAAC,EAAE,KAAK,CAAC;IAEb,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,iHAAiH;IACjH,UAAU,CAAC,EAAE,EAAE,CAAC,gBAAgB,GAAG,EAAE,CAAC,kBAAkB,GAAG,EAAE,CAAC,wBAAwB,CAAC;IACvF,0FAA0F;IAC1F,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,6DAA6D;IAC7D,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,CAAC;AAIF;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO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,aAAa,GACpB,EAAE,CAAC,gBAAgB,GAAG,EAAE,CAAC,kBAAkB,GAAG,EAAE,CAAC,wBAAwB,CAM3E;AAED,uEAAuE;AACvE,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAO3E;AAID,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,GAAG,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,EAC9C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,EAAE,GACT,iBAAiB,CAcnB;;AAcD;;;;;;;;;;;;GAYG"}
|
|
@@ -82,14 +82,6 @@ export function checkTextureFeature(gl, feature, extensions) {
|
|
|
82
82
|
*/
|
|
83
83
|
// prettier-ignore
|
|
84
84
|
export const TEXTURE_FORMATS = {
|
|
85
|
-
// Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
|
|
86
|
-
'rgb8unorm-unsized': { gl: 6407, b: 4, c: 2, bpp: 4,
|
|
87
|
-
dataFormat: 6407, types: [5121, 33635] },
|
|
88
|
-
'rgba8unorm-unsized': { gl: 6408, b: 4, c: 2, bpp: 4,
|
|
89
|
-
dataFormat: 6408, types: [5121, 32819, 32820] },
|
|
90
|
-
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
91
|
-
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
92
|
-
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
93
85
|
// 8-bit formats
|
|
94
86
|
'r8unorm': { gl: 33321, b: 1, c: 1, rb: true },
|
|
95
87
|
'r8snorm': { gl: 36756, b: 1, c: 1, render: snorm8_renderable },
|
|
@@ -164,9 +156,6 @@ export const TEXTURE_FORMATS = {
|
|
|
164
156
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
165
157
|
'depth24plus-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306, rb: true, depthTexture: true,
|
|
166
158
|
dataFormat: 34041, types: [34042] },
|
|
167
|
-
// "depth24unorm-stencil8" feature
|
|
168
|
-
'depth24unorm-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306,
|
|
169
|
-
dataFormat: 34041, types: [34042], rb: true },
|
|
170
159
|
// "depth32float-stencil8" feature - TODO below is render buffer only?
|
|
171
160
|
'depth32float-stencil8': { gl: 36013, b: 5, c: 2, p: 1, attachment: 33306,
|
|
172
161
|
dataFormat: 34041, types: [36269], rb: true },
|
|
@@ -370,6 +359,10 @@ export function isTextureFormatSupported(gl, format, extensions) {
|
|
|
370
359
|
if (info.gl === undefined) {
|
|
371
360
|
return false;
|
|
372
361
|
}
|
|
362
|
+
const feature = info.f;
|
|
363
|
+
if (feature) {
|
|
364
|
+
return checkTextureFeature(gl, feature, extensions);
|
|
365
|
+
}
|
|
373
366
|
// Check extensions
|
|
374
367
|
const extension = info.x || info.gl2ext;
|
|
375
368
|
if (extension) {
|
|
@@ -452,13 +445,12 @@ export function getTextureFormatWebGL(format) {
|
|
|
452
445
|
return {
|
|
453
446
|
internalFormat: webglFormat,
|
|
454
447
|
format: formatData?.dataFormat ||
|
|
455
|
-
getWebGLPixelDataFormat(decoded.
|
|
448
|
+
getWebGLPixelDataFormat(decoded.channels, decoded.integer, decoded.normalized, webglFormat),
|
|
456
449
|
// depth formats don't have a type
|
|
457
450
|
type: decoded.dataType
|
|
458
451
|
? getGLFromVertexType(decoded.dataType)
|
|
459
452
|
: formatData?.types?.[0] || 5121,
|
|
460
|
-
|
|
461
|
-
compressed: decoded.compressed
|
|
453
|
+
compressed: decoded.compressed || false
|
|
462
454
|
};
|
|
463
455
|
}
|
|
464
456
|
export function getDepthStencilAttachmentWebGL(format) {
|
|
@@ -478,17 +470,18 @@ export function getTextureFormatBytesPerPixel(format) {
|
|
|
478
470
|
return channels * channelSize;
|
|
479
471
|
}
|
|
480
472
|
// DATA TYPE HELPERS
|
|
481
|
-
export function getWebGLPixelDataFormat(
|
|
473
|
+
export function getWebGLPixelDataFormat(channels, integer, normalized, format) {
|
|
482
474
|
// WebGL1 formats use same internalFormat
|
|
483
475
|
if (format === 6408 || format === 6407) {
|
|
484
476
|
return format;
|
|
485
477
|
}
|
|
486
478
|
// prettier-ignore
|
|
487
|
-
switch (
|
|
479
|
+
switch (channels) {
|
|
488
480
|
case 'r': return integer && !normalized ? 36244 : 6403;
|
|
489
481
|
case 'rg': return integer && !normalized ? 33320 : 33319;
|
|
490
482
|
case 'rgb': return integer && !normalized ? 36248 : 6407;
|
|
491
483
|
case 'rgba': return integer && !normalized ? 36249 : 6408;
|
|
484
|
+
case 'bgra': throw new Error('bgra pixels not supported by WebGL');
|
|
492
485
|
default: return 6408;
|
|
493
486
|
}
|
|
494
487
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device-features.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-features.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-device-features.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-features.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AA6BhD;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAS,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACrC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,cAAc,qBAA4B;gBAGlD,EAAE,EAAE,sBAAsB,EAC1B,UAAU,EAAE,YAAY,EACxB,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAU1D,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC;IAU5C,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IAuB7C,kBAAkB;IAWlB,WAAW,IACoE,aAAa,EAAE;IAG9F,iCAAiC;IACjC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;CAU3D"}
|
|
@@ -17,7 +17,6 @@ const WEBGL_FEATURES = {
|
|
|
17
17
|
// 'timestamp-query' // GPUQueryType "timestamp-query"
|
|
18
18
|
// "indirect-first-instance"
|
|
19
19
|
// Textures are handled by getTextureFeatures()
|
|
20
|
-
// 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
|
|
21
20
|
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
22
21
|
// optional WebGL features
|
|
23
22
|
'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',
|
|
@@ -87,7 +87,7 @@ export declare function getWebGLTextureTarget(dimension: '1d' | '2d' | '2d-array
|
|
|
87
87
|
export function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextureOptions): void {
|
|
88
88
|
const {dimension, width, height, depth = 0, level = 0} = options;
|
|
89
89
|
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
90
|
-
const glTarget =
|
|
90
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
91
91
|
|
|
92
92
|
switch (dimension) {
|
|
93
93
|
case '2d-array':
|
|
@@ -130,7 +130,7 @@ export function setMipLevelFromExternalImage(
|
|
|
130
130
|
const {dimension, width, height, depth = 0, level = 0} = options;
|
|
131
131
|
const {glInternalFormat, glType} = options;
|
|
132
132
|
|
|
133
|
-
const glTarget =
|
|
133
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
134
134
|
|
|
135
135
|
// TODO - we can't change texture width (due to WebGPU limitations) -
|
|
136
136
|
// and the width/heigh of an external image is implicit, so why do we need to extract it?
|
|
@@ -181,7 +181,7 @@ export function setMipLevelFromTypedArray(
|
|
|
181
181
|
const {dimension, width, height, depth = 0, level = 0, offset = 0} = options;
|
|
182
182
|
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
183
183
|
|
|
184
|
-
const glTarget =
|
|
184
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
185
185
|
|
|
186
186
|
withGLParameters(gl, parameters, () => {
|
|
187
187
|
switch (dimension) {
|
|
@@ -260,7 +260,7 @@ export function setMipLevelFromGPUBuffer(
|
|
|
260
260
|
): void {
|
|
261
261
|
const {dimension, width, height, depth = 0, level = 0, byteOffset = 0} = options;
|
|
262
262
|
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
263
|
-
const glTarget =
|
|
263
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
264
264
|
|
|
265
265
|
const webglBuffer = buffer as WEBGLBuffer;
|
|
266
266
|
const imageSize = buffer.byteLength;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgl-texture-utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAEjD,OAAO,EACL,EAAE,EACF,eAAe,EAEf,iBAAiB,EACjB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAK1C,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IACnE,MAAM,EAAE,MAAM,CAAC;IACf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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwNE"}
|
|
@@ -19,7 +19,7 @@ const BORDER = 0;
|
|
|
19
19
|
export function initializeTextureStorage(gl, levels, options) {
|
|
20
20
|
const { dimension, width, height, depth = 0 } = options;
|
|
21
21
|
const { glInternalFormat } = options;
|
|
22
|
-
const glTarget = options.glTarget; //
|
|
22
|
+
const glTarget = options.glTarget; // getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
23
23
|
switch (dimension) {
|
|
24
24
|
case '2d-array':
|
|
25
25
|
case '3d':
|
|
@@ -36,7 +36,7 @@ export function copyCPUImageToMipLevel(gl, image, options) {
|
|
|
36
36
|
const { dimension, width, height, depth = 0, level = 0 } = options;
|
|
37
37
|
const { x = 0, y = 0, z = 0 } = options;
|
|
38
38
|
const { glFormat, glType } = options;
|
|
39
|
-
const glTarget =
|
|
39
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
40
40
|
// width = size.width,
|
|
41
41
|
// height = size.height
|
|
42
42
|
switch (dimension) {
|
|
@@ -61,7 +61,8 @@ export function copyCPUDataToMipLevel(gl, typedArray, options) {
|
|
|
61
61
|
const { dimension, width, height, depth = 0, level = 0, byteOffset = 0 } = options;
|
|
62
62
|
const { x = 0, y = 0, z = 0 } = options;
|
|
63
63
|
const { glFormat, glType, compressed } = options;
|
|
64
|
-
const glTarget =
|
|
64
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
65
|
+
// gl.bindTexture(glTarget, null);
|
|
65
66
|
switch (dimension) {
|
|
66
67
|
case '2d-array':
|
|
67
68
|
case '3d':
|
|
@@ -96,7 +97,7 @@ export function copyGPUBufferToMipLevel(gl, webglBuffer, byteLength, options) {
|
|
|
96
97
|
const { dimension, width, height, depth = 0, level = 0, byteOffset = 0 } = options;
|
|
97
98
|
const { x = 0, y = 0, z = 0 } = options;
|
|
98
99
|
const { glFormat, glType, compressed } = options;
|
|
99
|
-
const glTarget =
|
|
100
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
100
101
|
gl.bindBuffer(35052, webglBuffer);
|
|
101
102
|
switch (dimension) {
|
|
102
103
|
case '2d-array':
|
|
@@ -143,9 +144,10 @@ export function getWebGLTextureTarget(dimension) {
|
|
|
143
144
|
}
|
|
144
145
|
/**
|
|
145
146
|
* In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.
|
|
147
|
+
* @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.
|
|
146
148
|
* @returns glTarget unchanged, if dimension !== 'cube'.
|
|
147
149
|
*/
|
|
148
|
-
function
|
|
150
|
+
function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
149
151
|
return dimension === 'cube' ? 34069 + level : glTarget;
|
|
150
152
|
}
|
|
151
153
|
// texImage methods
|
|
@@ -156,7 +158,7 @@ function getCubeTargetWebGL(glTarget, dimension, level) {
|
|
|
156
158
|
export function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextureOptions): void {
|
|
157
159
|
const {dimension, width, height, depth = 0, level = 0} = options;
|
|
158
160
|
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
159
|
-
const glTarget =
|
|
161
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
160
162
|
|
|
161
163
|
switch (dimension) {
|
|
162
164
|
case '2d-array':
|
|
@@ -199,7 +201,7 @@ export function setMipLevelFromExternalImage(
|
|
|
199
201
|
const {dimension, width, height, depth = 0, level = 0} = options;
|
|
200
202
|
const {glInternalFormat, glType} = options;
|
|
201
203
|
|
|
202
|
-
const glTarget =
|
|
204
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
203
205
|
|
|
204
206
|
// TODO - we can't change texture width (due to WebGPU limitations) -
|
|
205
207
|
// and the width/heigh of an external image is implicit, so why do we need to extract it?
|
|
@@ -250,7 +252,7 @@ export function setMipLevelFromTypedArray(
|
|
|
250
252
|
const {dimension, width, height, depth = 0, level = 0, offset = 0} = options;
|
|
251
253
|
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
252
254
|
|
|
253
|
-
const glTarget =
|
|
255
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
254
256
|
|
|
255
257
|
withGLParameters(gl, parameters, () => {
|
|
256
258
|
switch (dimension) {
|
|
@@ -329,7 +331,7 @@ export function setMipLevelFromGPUBuffer(
|
|
|
329
331
|
): void {
|
|
330
332
|
const {dimension, width, height, depth = 0, level = 0, byteOffset = 0} = options;
|
|
331
333
|
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
332
|
-
const glTarget =
|
|
334
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
333
335
|
|
|
334
336
|
const webglBuffer = buffer as WEBGLBuffer;
|
|
335
337
|
const imageSize = buffer.byteLength;
|
|
@@ -123,7 +123,7 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
123
123
|
switch (texture.glTarget) {
|
|
124
124
|
case 35866:
|
|
125
125
|
case 32879:
|
|
126
|
-
gl.framebufferTextureLayer(36160, attachment, texture.
|
|
126
|
+
gl.framebufferTextureLayer(36160, attachment, texture.handle, level, layer);
|
|
127
127
|
break;
|
|
128
128
|
case 34067:
|
|
129
129
|
// layer must be a cubemap face (or if index, converted to cube map face)
|
|
@@ -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,EAAC,MAAM,gBAAgB,CAAC;AAC5C,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,EAAC,MAAM,gBAAgB,CAAC;AAC5C,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;AAapD,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;IA0BvD,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;IA+BvB;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,UAAU,GAAE,MAAU,EAAE,KAAK,GAAE,YAA2B;CAwCtF"}
|
|
@@ -5,7 +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
|
-
import { pushContextState, popContextState } from "../../context/state-tracker/track-context-state.js";
|
|
9
8
|
// Should collapse during minification
|
|
10
9
|
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
11
10
|
const GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
@@ -19,14 +18,28 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
19
18
|
constructor(device, props) {
|
|
20
19
|
super(device, props);
|
|
21
20
|
this.device = device;
|
|
21
|
+
// If no viewport is provided, apply reasonably defaults
|
|
22
|
+
let viewport;
|
|
23
|
+
if (!props?.parameters?.viewport) {
|
|
24
|
+
if (props?.framebuffer) {
|
|
25
|
+
// Set the viewport to the size of the framebuffer
|
|
26
|
+
const { width, height } = props.framebuffer;
|
|
27
|
+
viewport = [0, 0, width, height];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// Instead of using our own book-keeping, we can just read the values from the WebGL context
|
|
31
|
+
const [width, height] = device.getCanvasContext().getDrawingBufferSize();
|
|
32
|
+
viewport = [0, 0, width, height];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
22
35
|
// TODO - do parameters (scissorRect) affect the clear operation?
|
|
23
|
-
|
|
24
|
-
this.setParameters(this.props.parameters);
|
|
36
|
+
this.device.pushState();
|
|
37
|
+
this.setParameters({ viewport, ...this.props.parameters });
|
|
25
38
|
// Hack - for now WebGL draws in "immediate mode" (instead of queueing the operations)...
|
|
26
39
|
this.clear();
|
|
27
40
|
}
|
|
28
41
|
end() {
|
|
29
|
-
|
|
42
|
+
this.device.popState();
|
|
30
43
|
// should add commands to CommandEncoder.
|
|
31
44
|
}
|
|
32
45
|
pushDebugGroup(groupLabel) { }
|
|
@@ -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,EAAC,mBAAmB,EAAE,wBAAwB,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACpG,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAC,MAAM,eAAe,C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AE,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;IACxF,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY;IAmB9D;;;;OAIG;IACH,cAAc,IAAI,SAAS,GAAG,SAAS,GAAG,YAAY;IAmBtD,6DAA6D;IACvD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3C;;;;OAIG;IACH,sBAAsB;IAsBtB,iDAAiD;IACjD,cAAc;IAyFd;;;OAGG;IACH,cAAc;CASf"}
|
|
@@ -85,7 +85,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
85
85
|
.map(binding => `"${binding.name}"`)
|
|
86
86
|
.join(', ');
|
|
87
87
|
if (!options?.disableWarnings) {
|
|
88
|
-
log.warn(`
|
|
88
|
+
log.warn(`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
|
|
89
89
|
}
|
|
90
90
|
continue; // eslint-disable-line no-continue
|
|
91
91
|
}
|
|
@@ -49,7 +49,7 @@ export class WEBGLShader extends Shader {
|
|
|
49
49
|
// PRIVATE METHODS
|
|
50
50
|
/** Compile a shader and get compilation status */
|
|
51
51
|
async _compile(source) {
|
|
52
|
-
const addGLSLVersion = (source) => source.startsWith('#version ') ? source : `#version
|
|
52
|
+
const addGLSLVersion = (source) => source.startsWith('#version ') ? source : `#version 300 es\n${source}`;
|
|
53
53
|
source = addGLSLVersion(source);
|
|
54
54
|
const { gl } = this.device;
|
|
55
55
|
gl.shaderSource(this.handle, source);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Device, TextureProps, TextureViewProps, Sampler, SamplerProps, TextureCubeFace, Texture1DData, Texture2DData, Texture3DData, TextureCubeData, TextureArrayData, TextureCubeArrayData } from '@luma.gl/core';
|
|
1
|
+
import type { Device, TextureProps, TextureViewProps, Sampler, SamplerProps, TextureCubeFace, ExternalImage, Texture1DData, Texture2DData, Texture3DData, TextureCubeData, TextureArrayData, TextureCubeArrayData } from '@luma.gl/core';
|
|
2
2
|
import { Texture } from '@luma.gl/core';
|
|
3
3
|
import { GL, GLPixelType, GLSamplerParameters, GLTexelDataFormat, GLTextureTarget } from '@luma.gl/constants';
|
|
4
4
|
import { WebGLDevice } from "../webgl-device.js";
|
|
@@ -52,9 +52,27 @@ export declare class WEBGLTexture extends Texture {
|
|
|
52
52
|
/** Update external texture (video frame or canvas) */
|
|
53
53
|
update(): void;
|
|
54
54
|
generateMipmap(params?: {}): void;
|
|
55
|
+
copyExternalImage(options: {
|
|
56
|
+
image: ExternalImage;
|
|
57
|
+
sourceX?: number;
|
|
58
|
+
sourceY?: number;
|
|
59
|
+
width?: number;
|
|
60
|
+
height?: number;
|
|
61
|
+
depth?: number;
|
|
62
|
+
mipLevel?: number;
|
|
63
|
+
x?: number;
|
|
64
|
+
y?: number;
|
|
65
|
+
z?: number;
|
|
66
|
+
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
67
|
+
colorSpace?: 'srgb';
|
|
68
|
+
premultipliedAlpha?: boolean;
|
|
69
|
+
}): {
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
};
|
|
55
73
|
setTexture1DData(data: Texture1DData): void;
|
|
56
74
|
/** Set a simple texture */
|
|
57
|
-
setTexture2DData(lodData: Texture2DData, depth?: number
|
|
75
|
+
setTexture2DData(lodData: Texture2DData, depth?: number): void;
|
|
58
76
|
/**
|
|
59
77
|
* Sets a 3D texture
|
|
60
78
|
* @param data
|
|
@@ -89,7 +107,7 @@ export declare class WEBGLTexture extends Texture {
|
|
|
89
107
|
* Copy a region of data from a CPU memory buffer into this texture.
|
|
90
108
|
* @todo - GLUnpackParameters parameters
|
|
91
109
|
*/
|
|
92
|
-
protected _setMipLevel(depth: number, level: number, textureData: Texture2DData,
|
|
110
|
+
protected _setMipLevel(depth: number, level: number, textureData: Texture2DData, glTarget?: GL): void;
|
|
93
111
|
getActiveUnit(): number;
|
|
94
112
|
bind(textureUnit?: number): number;
|
|
95
113
|
unbind(textureUnit?: number): number | undefined;
|
|
@@ -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,EAGZ,eAAe,
|
|
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,EAGZ,eAAe,EACf,aAAa,EAEb,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,WA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GAAG,CAAC,GAAG,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;IAarE;;OAEG;IACH,qBAAqB,CAAC,UAAU,EAAE,mBAAmB,GAAG,IAAI;IAkG5D;;;OAGG;IACH,SAAS,CAAC,YAAY,CACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,aAAa,EAC1B,QAAQ,GAAE,EAAkB;IA2B9B,aAAa,IAAI,MAAM;IAIvB,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM;IAYlC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAWjD"}
|
|
@@ -125,7 +125,7 @@ export class WEBGLTexture extends Texture {
|
|
|
125
125
|
// const {parameters = {} as Record<GL, any>} = props;
|
|
126
126
|
let { width, height } = props;
|
|
127
127
|
if (!width || !height) {
|
|
128
|
-
const textureSize =
|
|
128
|
+
const textureSize = Texture.getTextureDataSize(data);
|
|
129
129
|
width = textureSize?.width || 1;
|
|
130
130
|
height = textureSize?.height || 1;
|
|
131
131
|
}
|
|
@@ -263,11 +263,20 @@ export class WEBGLTexture extends Texture {
|
|
|
263
263
|
this.gl.bindTexture(this.glTarget, null);
|
|
264
264
|
}
|
|
265
265
|
// Image Data Setters
|
|
266
|
+
copyExternalImage(options) {
|
|
267
|
+
const size = Texture.getExternalImageSize(options.image);
|
|
268
|
+
const opts = { ...Texture.defaultCopyExternalImageOptions, ...size, ...options };
|
|
269
|
+
const { depth, mipLevel: lodLevel, image } = opts;
|
|
270
|
+
this.bind();
|
|
271
|
+
this._setMipLevel(depth, lodLevel, image);
|
|
272
|
+
this.unbind();
|
|
273
|
+
return { width: opts.width, height: opts.height };
|
|
274
|
+
}
|
|
266
275
|
setTexture1DData(data) {
|
|
267
276
|
throw new Error('setTexture1DData not supported in WebGL.');
|
|
268
277
|
}
|
|
269
278
|
/** Set a simple texture */
|
|
270
|
-
setTexture2DData(lodData, depth = 0
|
|
279
|
+
setTexture2DData(lodData, depth = 0) {
|
|
271
280
|
this.bind();
|
|
272
281
|
const lodArray = normalizeTextureData(lodData, this);
|
|
273
282
|
// If the user provides multiple LODs, then automatic mipmap
|
|
@@ -290,7 +299,9 @@ export class WEBGLTexture extends Texture {
|
|
|
290
299
|
throw new Error(this.id);
|
|
291
300
|
}
|
|
292
301
|
if (ArrayBuffer.isView(data)) {
|
|
302
|
+
this.bind();
|
|
293
303
|
copyCPUDataToMipLevel(this.device.gl, data, this);
|
|
304
|
+
this.unbind();
|
|
294
305
|
}
|
|
295
306
|
}
|
|
296
307
|
/**
|
|
@@ -303,9 +314,9 @@ export class WEBGLTexture extends Texture {
|
|
|
303
314
|
if (this.props.dimension !== 'cube') {
|
|
304
315
|
throw new Error(this.id);
|
|
305
316
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
317
|
+
for (const face of Texture.CubeFaces) {
|
|
318
|
+
this.setTextureCubeFaceData(data[face], face);
|
|
319
|
+
}
|
|
309
320
|
}
|
|
310
321
|
/**
|
|
311
322
|
* Sets an entire texture array
|
|
@@ -331,26 +342,8 @@ export class WEBGLTexture extends Texture {
|
|
|
331
342
|
if (Array.isArray(lodData) && lodData.length > 1 && this.props.mipmaps !== false) {
|
|
332
343
|
log.warn(`${this.id} has mipmap and multiple LODs.`)();
|
|
333
344
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
// const {width, height, format = GL.RGBA, type = GL.UNSIGNED_BYTE} = this;
|
|
337
|
-
// const {width, height, format = GL.RGBA, type = GL.UNSIGNED_BYTE} = this;
|
|
338
|
-
this.bind();
|
|
339
|
-
// for (let lodLevel = 0; lodLevel < lodData.length; lodLevel++) {
|
|
340
|
-
// const imageData = lodData[lodLevel];
|
|
341
|
-
// if (imageData instanceof ArrayBuffer) {
|
|
342
|
-
// // const imageData = image instanceof ArrayBuffer ? new ImageData(new Uint8ClampedArray(image), this.width) : image;
|
|
343
|
-
// this.device.gl.texImage2D?.(
|
|
344
|
-
// glFace,
|
|
345
|
-
// lodLevel,
|
|
346
|
-
// this.glInternalFormat,
|
|
347
|
-
// this.glInternalFormat,
|
|
348
|
-
// glType,
|
|
349
|
-
// imageData
|
|
350
|
-
// );
|
|
351
|
-
// }
|
|
352
|
-
// }
|
|
353
|
-
this.unbind();
|
|
345
|
+
const faceDepth = Texture.CubeFaces.indexOf(face);
|
|
346
|
+
this.setTexture2DData(lodData, faceDepth);
|
|
354
347
|
}
|
|
355
348
|
// INTERNAL METHODS
|
|
356
349
|
/** @todo update this method to accept LODs */
|
|
@@ -482,21 +475,22 @@ export class WEBGLTexture extends Texture {
|
|
|
482
475
|
* Copy a region of data from a CPU memory buffer into this texture.
|
|
483
476
|
* @todo - GLUnpackParameters parameters
|
|
484
477
|
*/
|
|
485
|
-
_setMipLevel(depth, level, textureData,
|
|
478
|
+
_setMipLevel(depth, level, textureData, glTarget = this.glTarget) {
|
|
486
479
|
// if (!textureData) {
|
|
487
480
|
// clearMipLevel(this.device.gl, {...this, depth, level});
|
|
488
481
|
// return;
|
|
489
482
|
// }
|
|
490
483
|
if (Texture.isExternalImage(textureData)) {
|
|
491
|
-
copyCPUImageToMipLevel(this.device.gl, textureData, { ...this, depth, level });
|
|
484
|
+
copyCPUImageToMipLevel(this.device.gl, textureData, { ...this, depth, level, glTarget });
|
|
492
485
|
return;
|
|
493
486
|
}
|
|
494
487
|
// @ts-expect-error
|
|
495
|
-
if (
|
|
488
|
+
if (Texture.isTextureLevelData(textureData)) {
|
|
496
489
|
copyCPUDataToMipLevel(this.device.gl, textureData.data, {
|
|
497
490
|
...this,
|
|
498
491
|
depth,
|
|
499
|
-
level
|
|
492
|
+
level,
|
|
493
|
+
glTarget
|
|
500
494
|
});
|
|
501
495
|
return;
|
|
502
496
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-vertex-array.ts"],"names":[],"mappings":"AAIA,OA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device.gl.vertexAttribPointer(location, size, type, normalized, stride, offset);
|
|
79
79
|
}
|
|
80
|
+
// Clear binding - keeping it may cause [.WebGL-0x12804417100]
|
|
81
|
+
// GL_INVALID_OPERATION: A transform feedback buffer that would be written to is also bound to a non-transform-feedback target
|
|
82
|
+
this.device.gl.bindBuffer(34962, null);
|
|
80
83
|
// Mark as non-constant
|
|
81
84
|
this.device.gl.enableVertexAttribArray(location);
|
|
82
85
|
// Set the step mode 0=vertex, 1=instance
|