@luma.gl/webgl 9.0.0 → 9.0.4
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 +5 -5
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +8 -3
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +10 -10
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +29 -56
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +3 -2
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +3 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +4 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts +0 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -15
- package/dist/dist.dev.js +105 -80
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +51 -47
- package/dist/index.cjs.map +2 -2
- package/dist.min.js +19 -0
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +37 -28
- package/src/adapter/device-helpers/webgl-device-features.ts +11 -10
- package/src/adapter/resources/webgl-command-buffer.ts +54 -67
- package/src/adapter/resources/webgl-framebuffer.ts +6 -2
- package/src/adapter/resources/webgl-render-pipeline.ts +6 -4
- package/src/adapter/resources/webgl-vertex-array.ts +9 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type { GLParameters } from '@luma.gl/constants';
|
|
1
|
+
import type { CompareFunction } from '@luma.gl/core';
|
|
2
|
+
import { Device, Parameters } from '@luma.gl/core';
|
|
3
|
+
import type { GLFunction, GLParameters } from '@luma.gl/constants';
|
|
4
4
|
/**
|
|
5
5
|
* Execute a function with a set of temporary WebGL parameter overrides
|
|
6
6
|
* - Saves current "global" WebGL context settings
|
|
@@ -31,6 +31,6 @@ export declare function withGLParameters<T = unknown>(device: Device, parameters
|
|
|
31
31
|
export declare function withDeviceParameters<T = unknown>(device: Device, parameters: Parameters, func: (device?: Device) => T): T;
|
|
32
32
|
/** Set WebGPU Style Parameters */
|
|
33
33
|
export declare function setDeviceParameters(device: Device, parameters: Parameters): void;
|
|
34
|
-
export declare function convertCompareFunction(parameter: string, value: CompareFunction):
|
|
35
|
-
export declare function convertToCompareFunction(parameter: string, value:
|
|
34
|
+
export declare function convertCompareFunction(parameter: string, value: CompareFunction): GLFunction;
|
|
35
|
+
export declare function convertToCompareFunction(parameter: string, value: GLFunction): CompareFunction;
|
|
36
36
|
//# sourceMappingURL=device-parameters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
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,EAAsB,UAAU,EAA+B,MAAM,eAAe,CAAC;AAEnG,OAAO,KAAK,EAGV,UAAU,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAO5B;;;;;;;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,CAgBH;AAED,kCAAkC;AAClC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,QAsMzE;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"}
|
|
@@ -135,9 +135,9 @@ export function setDeviceParameters(device, parameters) {
|
|
|
135
135
|
const extensions = webglDevice.getExtension('WEBGL_polygon_mode');
|
|
136
136
|
const ext = extensions.WEBGL_polygon_mode;
|
|
137
137
|
if (parameters.polygonMode) {
|
|
138
|
-
const mode = map('polygonMode', parameters.
|
|
138
|
+
const mode = map('polygonMode', parameters.polygonMode, {
|
|
139
139
|
fill: 6914,
|
|
140
|
-
|
|
140
|
+
line: 6913
|
|
141
141
|
});
|
|
142
142
|
ext?.polygonModeWEBGL(1028, mode);
|
|
143
143
|
ext?.polygonModeWEBGL(1029, mode);
|
|
@@ -305,7 +305,12 @@ function convertBlendFactorToFunction(parameter, value) {
|
|
|
305
305
|
'src-alpha': 770,
|
|
306
306
|
'one-minus-src-alpha': 771,
|
|
307
307
|
'dst-alpha': 772,
|
|
308
|
-
'one-minus-dst-alpha': 773
|
|
308
|
+
'one-minus-dst-alpha': 773,
|
|
309
|
+
'src-alpha-saturated': 776,
|
|
310
|
+
'constant-color': 32769,
|
|
311
|
+
'one-minus-constant-color': 32770,
|
|
312
|
+
'constant-alpha': 32771,
|
|
313
|
+
'one-minus-constant-alpha': 32772
|
|
309
314
|
});
|
|
310
315
|
}
|
|
311
316
|
function message(parameter, value) {
|
|
@@ -14,6 +14,7 @@ export declare class WebGLDeviceFeatures extends DeviceFeatures {
|
|
|
14
14
|
[Symbol.iterator](): IterableIterator<DeviceFeature>;
|
|
15
15
|
has(feature: DeviceFeature): boolean;
|
|
16
16
|
initializeFeatures(): void;
|
|
17
|
+
getFeatures(): DeviceFeature[];
|
|
17
18
|
/** Extract all WebGL features */
|
|
18
19
|
protected getWebGLFeature(feature: DeviceFeature): boolean;
|
|
19
20
|
}
|
|
@@ -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;AA8BhD;;;;;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;
|
|
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;AA8BhD;;;;;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;IAIX,iCAAiC;IACjC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;CAU3D"}
|
|
@@ -48,12 +48,8 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
|
|
|
48
48
|
getWebGLExtension(gl, 'EXT_color_buffer_float', extensions);
|
|
49
49
|
}
|
|
50
50
|
*[Symbol.iterator]() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
yield feature;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
for (const feature of Object.keys(TEXTURE_FEATURES)) {
|
|
51
|
+
const features = this.getFeatures();
|
|
52
|
+
for (const feature of features) {
|
|
57
53
|
if (this.has(feature)) {
|
|
58
54
|
yield feature;
|
|
59
55
|
}
|
|
@@ -79,13 +75,17 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
|
|
|
79
75
|
}
|
|
80
76
|
// FOR DEVICE
|
|
81
77
|
initializeFeatures() {
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
// Initialize all features by checking them.
|
|
79
|
+
// Except WEBGL_polygon_mode since Chrome logs ugly console warnings
|
|
80
|
+
const features = this.getFeatures().filter(feature => feature !== 'polygon-mode-webgl');
|
|
81
|
+
for (const feature of features) {
|
|
82
|
+
this.has(feature);
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
// IMPLEMENTATION
|
|
86
|
+
getFeatures() {
|
|
87
|
+
return [...Object.keys(WEBGL_FEATURES), ...Object.keys(TEXTURE_FEATURES)];
|
|
88
|
+
}
|
|
89
89
|
/** Extract all WebGL features */
|
|
90
90
|
getWebGLFeature(feature) {
|
|
91
91
|
const featureInfo = WEBGL_FEATURES[feature];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,aAAa,EAAuB,MAAM,eAAe,CAAC;AAClE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAU5C,KAAK,yBAAyB,GAAG;IAC/B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,yBAAyB,CAAC;CACpC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,0BAA0B,CAAC;CACrC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,0BAA0B,CAAC;CACrC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,2BAA2B,CAAC;CACtC,CAAC;AAEF,KAAK,OAAO,GACR,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,2BAA2B,CAAC;AAEhC,qBA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,MAAM,KAAA,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAmB1D;AAGD,wBAAgB,aAAa,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAcjD"}
|
|
@@ -95,6 +95,7 @@ function _copyTextureToBuffer(device, options) {
|
|
|
95
95
|
}
|
|
96
96
|
// Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature
|
|
97
97
|
const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
|
|
98
|
+
let prevHandle;
|
|
98
99
|
try {
|
|
99
100
|
const webglBuffer = destination;
|
|
100
101
|
const sourceWidth = width || framebuffer.width;
|
|
@@ -110,12 +111,16 @@ function _copyTextureToBuffer(device, options) {
|
|
|
110
111
|
// target = device.createBuffer({byteLength});
|
|
111
112
|
// }
|
|
112
113
|
device.gl.bindBuffer(35051, webglBuffer.handle);
|
|
113
|
-
|
|
114
|
+
// @ts-expect-error native bindFramebuffer is overridden by our state tracker
|
|
115
|
+
prevHandle = device.gl.bindFramebuffer(36160, framebuffer.handle);
|
|
114
116
|
device.gl.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);
|
|
115
117
|
}
|
|
116
118
|
finally {
|
|
117
119
|
device.gl.bindBuffer(35051, null);
|
|
118
|
-
|
|
120
|
+
// prevHandle may be unassigned if the try block failed before binding
|
|
121
|
+
if (prevHandle !== undefined) {
|
|
122
|
+
device.gl.bindFramebuffer(36160, prevHandle);
|
|
123
|
+
}
|
|
119
124
|
if (destroyFramebuffer) {
|
|
120
125
|
framebuffer.destroy();
|
|
121
126
|
}
|
|
@@ -147,12 +152,14 @@ function _copyTextureToTexture(device, options) {
|
|
|
147
152
|
const {
|
|
148
153
|
/** Texture to copy to/from. */
|
|
149
154
|
source,
|
|
150
|
-
/** Mip-map level of the texture to copy to
|
|
151
|
-
|
|
155
|
+
/** Mip-map level of the texture to copy to (Default 0) */
|
|
156
|
+
destinationMipLevel = 0,
|
|
152
157
|
/** Defines which aspects of the texture to copy to/from. */
|
|
153
158
|
// aspect = 'all',
|
|
154
|
-
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy
|
|
159
|
+
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy from. */
|
|
155
160
|
origin = [0, 0],
|
|
161
|
+
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */
|
|
162
|
+
destinationOrigin = [0, 0],
|
|
156
163
|
/** Texture to copy to/from. */
|
|
157
164
|
destination
|
|
158
165
|
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
@@ -162,21 +169,14 @@ function _copyTextureToTexture(device, options) {
|
|
|
162
169
|
/** Defines which aspects of the texture to copy to/from. */
|
|
163
170
|
// destinationAspect = options.aspect,
|
|
164
171
|
} = options;
|
|
165
|
-
let { width = options.destination.width, height = options.destination.
|
|
172
|
+
let { width = options.destination.width, height = options.destination.height
|
|
166
173
|
// depthOrArrayLayers = 0
|
|
167
174
|
} = options;
|
|
168
|
-
const destinationMipmaplevel = 0;
|
|
169
|
-
const destinationInternalFormat = 6408;
|
|
170
175
|
const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
|
|
171
176
|
const [sourceX, sourceY] = origin;
|
|
172
|
-
const
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
// typeof destinationZ !== 'undefined';
|
|
176
|
-
// destinationX = destinationX || 0;
|
|
177
|
-
// destinationY = destinationY || 0;
|
|
178
|
-
// destinationZ = destinationZ || 0;
|
|
179
|
-
device.gl.bindFramebuffer(36160, framebuffer.handle);
|
|
177
|
+
const [destinationX, destinationY, destinationZ] = destinationOrigin;
|
|
178
|
+
// @ts-expect-error native bindFramebuffer is overridden by our state tracker
|
|
179
|
+
const prevHandle = device.gl.bindFramebuffer(36160, framebuffer.handle);
|
|
180
180
|
// TODO - support gl.readBuffer (WebGL2 only)
|
|
181
181
|
// const prevBuffer = gl.readBuffer(attachment);
|
|
182
182
|
let texture = null;
|
|
@@ -186,56 +186,29 @@ function _copyTextureToTexture(device, options) {
|
|
|
186
186
|
width = Number.isFinite(width) ? width : texture.width;
|
|
187
187
|
height = Number.isFinite(height) ? height : texture.height;
|
|
188
188
|
texture.bind(0);
|
|
189
|
-
textureTarget = texture.
|
|
189
|
+
textureTarget = texture.target;
|
|
190
190
|
}
|
|
191
191
|
else {
|
|
192
|
-
throw new Error('
|
|
193
|
-
// textureTarget = destination;
|
|
194
|
-
}
|
|
195
|
-
if (!isSubCopy) {
|
|
196
|
-
device.gl.copyTexImage2D(textureTarget, destinationMipmaplevel, destinationInternalFormat, sourceX, sourceY, width, height, 0 /* border must be 0 */);
|
|
192
|
+
throw new Error('invalid destination');
|
|
197
193
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// sourceY,
|
|
209
|
-
// width,
|
|
210
|
-
// height
|
|
211
|
-
// );
|
|
212
|
-
// break;
|
|
213
|
-
// case GL.TEXTURE_2D_ARRAY:
|
|
214
|
-
// case GL.TEXTURE_3D:
|
|
215
|
-
// device.gl.copyTexSubImage3D(
|
|
216
|
-
// textureTarget,
|
|
217
|
-
// destinationMipmaplevel,
|
|
218
|
-
// destinationX,
|
|
219
|
-
// destinationY,
|
|
220
|
-
// destinationZ,
|
|
221
|
-
// sourceX,
|
|
222
|
-
// sourceY,
|
|
223
|
-
// width,
|
|
224
|
-
// height
|
|
225
|
-
// );
|
|
226
|
-
// break;
|
|
227
|
-
// default:
|
|
228
|
-
// }
|
|
194
|
+
switch (textureTarget) {
|
|
195
|
+
case 3553:
|
|
196
|
+
case 34067:
|
|
197
|
+
device.gl.copyTexSubImage2D(textureTarget, destinationMipLevel, destinationX, destinationY, sourceX, sourceY, width, height);
|
|
198
|
+
break;
|
|
199
|
+
case 35866:
|
|
200
|
+
case 32879:
|
|
201
|
+
device.gl.copyTexSubImage3D(textureTarget, destinationMipLevel, destinationX, destinationY, destinationZ, sourceX, sourceY, width, height);
|
|
202
|
+
break;
|
|
203
|
+
default:
|
|
229
204
|
}
|
|
230
205
|
if (texture) {
|
|
231
206
|
texture.unbind();
|
|
232
207
|
}
|
|
233
|
-
|
|
234
|
-
// device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
208
|
+
device.gl.bindFramebuffer(36160, prevHandle);
|
|
235
209
|
if (destroyFramebuffer) {
|
|
236
210
|
framebuffer.destroy();
|
|
237
211
|
}
|
|
238
|
-
return texture;
|
|
239
212
|
}
|
|
240
213
|
// Returns number of components in a specific readPixels WebGL format
|
|
241
214
|
export function glFormatToComponents(format) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AACnE,OAAO,EAAC,WAAW,EAAE,OAAO,EAAS,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,gBAAgB,EAAC,gCAA6B;AAMtD,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,YAAY,CAAC;AAEzD,iDAAiD;AACjD,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,MAAM,EAAE,WAAW,CAAC;IACpB,EAAE,EAAE,sBAAsB,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IAEzB,IAAI,OAAO,wCAEV;gBAEW,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"webgl-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AACnE,OAAO,EAAC,WAAW,EAAE,OAAO,EAAS,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,gBAAgB,EAAC,gCAA6B;AAMtD,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,YAAY,CAAC;AAEzD,iDAAiD;AACjD,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,MAAM,EAAE,WAAW,CAAC;IACpB,EAAE,EAAE,sBAAsB,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IAEzB,IAAI,OAAO,wCAEV;gBAEW,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB;IAsDxD,+CAA+C;IACtC,OAAO,IAAI,IAAI;IAUxB,mGAAmG;cAChF,yBAAyB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAW5E;;OAEG;cACgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IA2BzE,4BAA4B;IAC5B,SAAS,CAAC,UAAU,CAAC,eAAe,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,GAAG,YAAY;IAqC/E;;;;;OAKG;IACH,SAAS,CAAC,cAAc,CACtB,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI;CA2BR"}
|
|
@@ -28,7 +28,8 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
28
28
|
// Auto create textures for attachments if needed
|
|
29
29
|
this.autoCreateAttachmentTextures();
|
|
30
30
|
/** Attach from a map of attachments */
|
|
31
|
-
|
|
31
|
+
// @ts-expect-error native bindFramebuffer is overridden by our state tracker
|
|
32
|
+
const prevHandle = this.gl.bindFramebuffer(36160, this.handle);
|
|
32
33
|
// Walk the attachments
|
|
33
34
|
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
34
35
|
const attachment = this.colorAttachments[i];
|
|
@@ -48,7 +49,7 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
48
49
|
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
this.gl.bindFramebuffer(36160,
|
|
52
|
+
this.gl.bindFramebuffer(36160, prevHandle);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
/** destroys any auto created resources etc. */
|
|
@@ -31,7 +31,9 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
31
31
|
* Bindings include: textures, samplers and uniform buffers
|
|
32
32
|
* @todo needed for portable model
|
|
33
33
|
*/
|
|
34
|
-
setBindings(bindings: Record<string, Binding
|
|
34
|
+
setBindings(bindings: Record<string, Binding>, options?: {
|
|
35
|
+
disableWarnings?: boolean;
|
|
36
|
+
}): void;
|
|
35
37
|
/** @todo needed for portable model
|
|
36
38
|
* @note The WebGL API is offers many ways to draw things
|
|
37
39
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
@@ -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,YAAY,EAAE,mBAAmB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC9E,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAsC,MAAM,eAAe,CAAC;AAUlF,OAAO,EAAC,WAAW,EAAC,2BAAwB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AAC,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;IAatB,iDAAiD;IACjD,cAAc;IAyFd;;;OAGG;IACH,cAAc;CASf"}
|
|
@@ -77,7 +77,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
77
77
|
* Bindings include: textures, samplers and uniform buffers
|
|
78
78
|
* @todo needed for portable model
|
|
79
79
|
*/
|
|
80
|
-
setBindings(bindings) {
|
|
80
|
+
setBindings(bindings, options) {
|
|
81
81
|
// if (log.priority >= 2) {
|
|
82
82
|
// checkUniformValues(uniforms, this.id, this._uniformSetters);
|
|
83
83
|
// }
|
|
@@ -92,7 +92,9 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
92
92
|
const validBindings = this.shaderLayout.bindings
|
|
93
93
|
.map(binding => `"${binding.name}"`)
|
|
94
94
|
.join(', ');
|
|
95
|
-
|
|
95
|
+
if (options?.disableWarnings) {
|
|
96
|
+
log.warn(`Unknown binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`)();
|
|
97
|
+
}
|
|
96
98
|
continue; // eslint-disable-line no-continue
|
|
97
99
|
}
|
|
98
100
|
if (!value) {
|
|
@@ -25,7 +25,6 @@ export declare class WEBGLVertexArray extends VertexArray {
|
|
|
25
25
|
setBuffer(location: number, attributeBuffer: Buffer): void;
|
|
26
26
|
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
27
27
|
setConstantWebGL(location: number, value: TypedArray): void;
|
|
28
|
-
init: boolean;
|
|
29
28
|
bindBeforeRender(): void;
|
|
30
29
|
unbindAfterRender(): void;
|
|
31
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-vertex-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAC,WAAW,EAA6B,MAAM,eAAe,CAAC;AACtE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAO5C,gCAAgC;AAChC,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAExC,kCAAkC;IAClC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,WAAW,CAAQ;IAE3B,6EAA6E;IAC7E,MAAM,CAAC,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;gBAKpD,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,gBAAgB;IAMhD,OAAO,IAAI,IAAI;IAexB;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAgBhD,gGAAgG;IAChG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-vertex-array.ts"],"names":[],"mappings":"AAIA,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xD;;;;;OAKG;IACH,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM;CA8BnE"}
|
|
@@ -54,11 +54,10 @@ export class WEBGLVertexArray extends VertexArray {
|
|
|
54
54
|
}
|
|
55
55
|
// In WebGL The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject
|
|
56
56
|
this.device.gl.bindVertexArray(this.handle);
|
|
57
|
-
// TODO - this initial binding does not seem to take effect? see bindBeforeRender()
|
|
58
57
|
this.device.gl.bindBuffer(34963, buffer ? buffer.handle : null);
|
|
59
|
-
// log.log(1, 'VertexArray.setIndexBuffer', indexBuffer)();
|
|
60
|
-
// log.log(1, `Binding vertex array ${this.id}`, buffer?.id)();
|
|
61
58
|
this.indexBuffer = buffer;
|
|
59
|
+
// Unbind to prevent unintended changes to the VAO.
|
|
60
|
+
this.device.gl.bindVertexArray(null);
|
|
62
61
|
}
|
|
63
62
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
64
63
|
setBuffer(location, attributeBuffer) {
|
|
@@ -84,30 +83,21 @@ export class WEBGLVertexArray extends VertexArray {
|
|
|
84
83
|
// Set the step mode 0=vertex, 1=instance
|
|
85
84
|
this.device.gl.vertexAttribDivisor(location, divisor || 0);
|
|
86
85
|
this.attributes[location] = buffer;
|
|
86
|
+
// Unbind to prevent unintended changes to the VAO.
|
|
87
|
+
this.device.gl.bindVertexArray(null);
|
|
87
88
|
}
|
|
88
89
|
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
89
90
|
setConstantWebGL(location, value) {
|
|
90
91
|
this._enable(location, false);
|
|
91
92
|
this.attributes[location] = value;
|
|
92
93
|
}
|
|
93
|
-
init = false;
|
|
94
94
|
bindBeforeRender() {
|
|
95
95
|
this.device.gl.bindVertexArray(this.handle);
|
|
96
|
-
// TODO - the initial bind does not seem to take effect.
|
|
97
|
-
if (!this.init) {
|
|
98
|
-
// log.log(1, `Binding vertex array ${this.id}`, this.indexBuffer?.id)();
|
|
99
|
-
const webglBuffer = this.indexBuffer;
|
|
100
|
-
this.device.gl.bindBuffer(34963, webglBuffer?.handle || null);
|
|
101
|
-
this.init = true;
|
|
102
|
-
}
|
|
103
96
|
this._applyConstantAttributes();
|
|
104
97
|
}
|
|
105
98
|
unbindAfterRender() {
|
|
106
|
-
//
|
|
107
|
-
// TODO technically this is not necessary, but we might be interfacing
|
|
108
|
-
// with code that does not use vertex array objects
|
|
99
|
+
// Unbind to prevent unintended changes to the VAO.
|
|
109
100
|
this.device.gl.bindVertexArray(null);
|
|
110
|
-
// this.device.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, null);
|
|
111
101
|
}
|
|
112
102
|
// Internal methods
|
|
113
103
|
/**
|