@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
|
@@ -10,12 +10,6 @@ import {withGLParameters} from '../../context/state-tracker/with-parameters';
|
|
|
10
10
|
import {setGLParameters} from '../../context/parameters/unified-parameter-api';
|
|
11
11
|
import {WEBGLQuerySet} from './webgl-query-set';
|
|
12
12
|
|
|
13
|
-
// Should collapse during minification
|
|
14
|
-
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
15
|
-
const GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
16
|
-
const GL_COLOR_BUFFER_BIT = 0x00004000;
|
|
17
|
-
|
|
18
|
-
const GL_COLOR = 0x1800;
|
|
19
13
|
const COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPUColorWrite RED, GREEN, BLUE, ALPHA
|
|
20
14
|
|
|
21
15
|
export class WEBGLRenderPass extends RenderPass {
|
|
@@ -46,6 +40,16 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
46
40
|
this.device.pushState();
|
|
47
41
|
this.setParameters({viewport, ...this.props.parameters});
|
|
48
42
|
|
|
43
|
+
// Specify mapping of draw buffer locations to color attachments
|
|
44
|
+
if (this.props.framebuffer) {
|
|
45
|
+
const drawBuffers = this.props.framebuffer.colorAttachments.map(
|
|
46
|
+
(_, i) => GL.COLOR_ATTACHMENT0 + i
|
|
47
|
+
);
|
|
48
|
+
this.device.gl.drawBuffers(drawBuffers);
|
|
49
|
+
} else {
|
|
50
|
+
this.device.gl.drawBuffers([GL.BACK]);
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
// Hack - for now WebGL draws in "immediate mode" (instead of queueing the operations)...
|
|
50
54
|
this.clear();
|
|
51
55
|
}
|
|
@@ -134,21 +138,37 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
134
138
|
* Optionally clears depth, color and stencil buffers based on parameters
|
|
135
139
|
*/
|
|
136
140
|
protected clear(): void {
|
|
141
|
+
const DEFAULT_CLEAR_COLOR: [number, number, number, number] = [0, 0, 0, 1];
|
|
142
|
+
const DEFAULT_CLEAR_DEPTH = 1;
|
|
143
|
+
const DEFAULT_CLEAR_STENCIL = 0;
|
|
144
|
+
|
|
137
145
|
const glParameters: GLParameters = {...this.glParameters};
|
|
138
146
|
|
|
139
147
|
let clearMask = 0;
|
|
140
148
|
|
|
141
|
-
if (this.props.
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
if (this.props.clearColors) {
|
|
150
|
+
this.props.clearColors.forEach((color, drawBufferIndex) => {
|
|
151
|
+
if (color) {
|
|
152
|
+
this.clearColorBuffer(drawBufferIndex, color);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (this.props.clearColor !== false && this.props.clearColors === undefined) {
|
|
158
|
+
clearMask |= GL.COLOR_BUFFER_BIT;
|
|
159
|
+
const clearColor =
|
|
160
|
+
this.props.clearColor === true ? DEFAULT_CLEAR_COLOR : this.props.clearColor;
|
|
161
|
+
glParameters.clearColor = clearColor;
|
|
144
162
|
}
|
|
145
163
|
if (this.props.clearDepth !== false) {
|
|
146
|
-
clearMask |=
|
|
147
|
-
glParameters.clearDepth =
|
|
164
|
+
clearMask |= GL.DEPTH_BUFFER_BIT;
|
|
165
|
+
glParameters.clearDepth =
|
|
166
|
+
this.props.clearDepth === true ? DEFAULT_CLEAR_DEPTH : this.props.clearDepth;
|
|
148
167
|
}
|
|
149
168
|
if (this.props.clearStencil !== false) {
|
|
150
|
-
clearMask |=
|
|
151
|
-
glParameters.clearStencil =
|
|
169
|
+
clearMask |= GL.STENCIL_BUFFER_BIT;
|
|
170
|
+
glParameters.clearStencil =
|
|
171
|
+
this.props.clearStencil === true ? DEFAULT_CLEAR_STENCIL : this.props.clearStencil;
|
|
152
172
|
}
|
|
153
173
|
|
|
154
174
|
if (clearMask !== 0) {
|
|
@@ -156,11 +176,6 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
156
176
|
withGLParameters(this.device.gl, glParameters, () => {
|
|
157
177
|
this.device.gl.clear(clearMask);
|
|
158
178
|
});
|
|
159
|
-
|
|
160
|
-
// TODO - clear multiple color attachments
|
|
161
|
-
// for (attachment of this.framebuffer.colorAttachments) {
|
|
162
|
-
// this.clearColorBuffer
|
|
163
|
-
// }
|
|
164
179
|
}
|
|
165
180
|
}
|
|
166
181
|
|
|
@@ -171,22 +186,28 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
171
186
|
withGLParameters(this.device.gl, {framebuffer: this.props.framebuffer}, () => {
|
|
172
187
|
// Method selection per OpenGL ES 3 docs
|
|
173
188
|
switch (value.constructor) {
|
|
189
|
+
case Int8Array:
|
|
190
|
+
case Int16Array:
|
|
174
191
|
case Int32Array:
|
|
175
|
-
this.device.gl.clearBufferiv(
|
|
192
|
+
this.device.gl.clearBufferiv(GL.COLOR, drawBuffer, value);
|
|
176
193
|
break;
|
|
194
|
+
case Uint8Array:
|
|
195
|
+
case Uint8ClampedArray:
|
|
196
|
+
case Uint16Array:
|
|
177
197
|
case Uint32Array:
|
|
178
|
-
this.device.gl.clearBufferuiv(
|
|
198
|
+
this.device.gl.clearBufferuiv(GL.COLOR, drawBuffer, value);
|
|
179
199
|
break;
|
|
180
200
|
case Float32Array:
|
|
181
|
-
|
|
182
|
-
this.device.gl.clearBufferfv(GL_COLOR, drawBuffer, value);
|
|
201
|
+
this.device.gl.clearBufferfv(GL.COLOR, drawBuffer, value);
|
|
183
202
|
break;
|
|
203
|
+
default:
|
|
204
|
+
throw new Error('clearColorBuffer: color must be typed array');
|
|
184
205
|
}
|
|
185
206
|
});
|
|
186
207
|
}
|
|
187
208
|
|
|
188
209
|
// clearDepthStencil() {
|
|
189
|
-
// const
|
|
210
|
+
// const GL.DEPTH = 0x1801;
|
|
190
211
|
// const GL_STENCIL = 0x1802;
|
|
191
212
|
// const GL_DEPTH_STENCIL = 0x84f9;
|
|
192
213
|
|
|
@@ -110,12 +110,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
110
110
|
// and reference them as `app` from both GLSL and JS.
|
|
111
111
|
// TODO - this is rather hacky - we could also remap the name directly in the shader layout.
|
|
112
112
|
const binding =
|
|
113
|
-
this.shaderLayout.bindings.find(
|
|
114
|
-
this.shaderLayout.bindings.find(
|
|
113
|
+
this.shaderLayout.bindings.find(binding_ => binding_.name === name) ||
|
|
114
|
+
this.shaderLayout.bindings.find(binding_ => binding_.name === `${name}Uniforms`);
|
|
115
115
|
|
|
116
116
|
if (!binding) {
|
|
117
117
|
const validBindings = this.shaderLayout.bindings
|
|
118
|
-
.map(
|
|
118
|
+
.map(binding_ => `"${binding_.name}"`)
|
|
119
119
|
.join(', ');
|
|
120
120
|
if (!options?.disableWarnings) {
|
|
121
121
|
log.warn(
|
|
@@ -317,22 +317,37 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/** Report link status. First, check for shader compilation failures if linking fails */
|
|
320
|
-
_reportLinkStatus(status: 'success' | 'linking' | 'validation') {
|
|
320
|
+
async _reportLinkStatus(status: 'success' | 'linking' | 'validation'): Promise<void> {
|
|
321
321
|
switch (status) {
|
|
322
322
|
case 'success':
|
|
323
323
|
return;
|
|
324
324
|
|
|
325
325
|
default:
|
|
326
326
|
// First check for shader compilation failures if linking fails
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
switch (this.vs.compilationStatus) {
|
|
328
|
+
case 'error':
|
|
329
|
+
this.vs.debugShader();
|
|
330
|
+
throw new Error(`Error during compilation of shader ${this.vs.id}`);
|
|
331
|
+
case 'pending':
|
|
332
|
+
this.vs.asyncCompilationStatus.then(() => this.vs.debugShader());
|
|
333
|
+
break;
|
|
334
|
+
case 'success':
|
|
335
|
+
break;
|
|
330
336
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
337
|
+
|
|
338
|
+
switch (this.fs?.compilationStatus) {
|
|
339
|
+
case 'error':
|
|
340
|
+
this.fs.debugShader();
|
|
341
|
+
throw new Error(`Error during compilation of shader ${this.fs.id}`);
|
|
342
|
+
case 'pending':
|
|
343
|
+
this.fs.asyncCompilationStatus.then(() => this.fs.debugShader());
|
|
344
|
+
break;
|
|
345
|
+
case 'success':
|
|
346
|
+
break;
|
|
334
347
|
}
|
|
335
|
-
|
|
348
|
+
|
|
349
|
+
const linkErrorLog = this.device.gl.getProgramInfoLog(this.handle);
|
|
350
|
+
throw new Error(`Error during ${status}: ${linkErrorLog}`);
|
|
336
351
|
}
|
|
337
352
|
}
|
|
338
353
|
|
|
@@ -399,11 +414,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
399
414
|
}
|
|
400
415
|
}
|
|
401
416
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
417
|
+
// TODO - remove this should be handled by ExternalTexture
|
|
418
|
+
// for (const [, texture] of Object.entries(this.bindings)) {
|
|
419
|
+
// if (texture instanceof WEBGLTexture) {
|
|
420
|
+
// texture.update();
|
|
421
|
+
// }
|
|
422
|
+
// }
|
|
407
423
|
|
|
408
424
|
return texturesRenderable;
|
|
409
425
|
}
|
|
@@ -39,14 +39,18 @@ export class WEBGLShader extends Shader {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
get asyncCompilationStatus(): Promise<'pending' | 'success' | 'error'> {
|
|
43
|
+
return this._waitForCompilationComplete().then(() => this.compilationStatus);
|
|
44
|
+
}
|
|
45
|
+
|
|
42
46
|
override async getCompilationInfo(): Promise<readonly CompilerMessage[]> {
|
|
43
47
|
await this._waitForCompilationComplete();
|
|
44
48
|
return this.getCompilationInfoSync();
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
override getCompilationInfoSync(): readonly CompilerMessage[] {
|
|
48
|
-
const
|
|
49
|
-
return
|
|
52
|
+
const shaderLog = this.device.gl.getShaderInfoLog(this.handle);
|
|
53
|
+
return shaderLog ? parseShaderCompilerLog(shaderLog) : [];
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
override getTranslatedSource(): string | null {
|
|
@@ -59,16 +63,14 @@ export class WEBGLShader extends Shader {
|
|
|
59
63
|
|
|
60
64
|
/** Compile a shader and get compilation status */
|
|
61
65
|
protected async _compile(source: string): Promise<void> {
|
|
62
|
-
|
|
63
|
-
source.startsWith('#version ') ? source : `#version 300 es\n${source}`;
|
|
64
|
-
source = addGLSLVersion(source);
|
|
66
|
+
source = source.startsWith('#version ') ? source : `#version 300 es\n${source}`;
|
|
65
67
|
|
|
66
68
|
const {gl} = this.device;
|
|
67
69
|
gl.shaderSource(this.handle, source);
|
|
68
70
|
gl.compileShader(this.handle);
|
|
69
71
|
|
|
70
72
|
// For performance reasons, avoid checking shader compilation errors on production
|
|
71
|
-
if (
|
|
73
|
+
if (!this.device.props.debug) {
|
|
72
74
|
this.compilationStatus = 'pending';
|
|
73
75
|
return;
|
|
74
76
|
}
|