@luma.gl/webgl 9.0.0-alpha.42 → 9.0.0-alpha.44
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/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +10 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +0 -2
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +11 -10
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/dist.dev.js +48 -9
- package/dist/index.cjs +15 -9
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/resources/webgl-render-pass.ts +6 -0
- package/src/adapter/resources/webgl-render-pipeline.ts +19 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.44",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
48
|
-
"@luma.gl/core": "9.0.0-alpha.
|
|
47
|
+
"@luma.gl/constants": "9.0.0-alpha.44",
|
|
48
|
+
"@luma.gl/core": "9.0.0-alpha.44",
|
|
49
49
|
"@probe.gl/env": "^4.0.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@luma.gl/test-utils": "9.0.0-alpha.
|
|
52
|
+
"@luma.gl/test-utils": "9.0.0-alpha.44"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "195bed39c8587a68686cf28c0ae0e8dbd9c963f5"
|
|
55
55
|
}
|
|
@@ -6,6 +6,7 @@ import {WebGLDevice} from '../webgl-device';
|
|
|
6
6
|
import {GL, GLParameters} from '@luma.gl/constants';
|
|
7
7
|
import {withGLParameters} from '../../context/state-tracker/with-parameters';
|
|
8
8
|
import {setGLParameters} from '../../context/parameters/unified-parameter-api';
|
|
9
|
+
import {pushContextState, popContextState} from '../../context/state-tracker/track-context-state';
|
|
9
10
|
|
|
10
11
|
// Should collapse during minification
|
|
11
12
|
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
@@ -25,6 +26,7 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
25
26
|
this.device = device;
|
|
26
27
|
|
|
27
28
|
// TODO - do parameters (scissorRect) affect the clear operation?
|
|
29
|
+
pushContextState(this.device.gl);
|
|
28
30
|
this.setParameters(this.props.parameters);
|
|
29
31
|
|
|
30
32
|
// Hack - for now WebGL draws in "immediate mode" (instead of queueing the operations)...
|
|
@@ -32,6 +34,10 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
end(): void {
|
|
37
|
+
popContextState(this.device.gl);
|
|
38
|
+
if (this.props.framebuffer) {
|
|
39
|
+
setGLParameters(this.device, {framebuffer: null});
|
|
40
|
+
}
|
|
35
41
|
// should add commands to CommandEncoder.
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type {UniformValue, RenderPipelineProps, Binding} from '@luma.gl/core';
|
|
5
5
|
import type {ShaderLayout, PrimitiveTopology} from '@luma.gl/core';
|
|
6
6
|
import type {RenderPass, VertexArray} from '@luma.gl/core';
|
|
7
|
-
import {RenderPipeline, cast, log} from '@luma.gl/core';
|
|
7
|
+
import {RenderPipeline, cast, splitUniformsAndBindings, log} from '@luma.gl/core';
|
|
8
8
|
import {mergeShaderLayout} from '@luma.gl/core';
|
|
9
9
|
// import {mergeShaderLayout, getAttributeInfosFromLayouts} from '@luma.gl/core';
|
|
10
10
|
import {GL} from '@luma.gl/constants';
|
|
@@ -44,8 +44,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
44
44
|
/** WebGL varyings */
|
|
45
45
|
varyings: string[] | null = null;
|
|
46
46
|
|
|
47
|
-
_textureUniforms: Record<string, any> = {};
|
|
48
|
-
_textureIndexCounter: number = 0;
|
|
49
47
|
_uniformCount: number = 0;
|
|
50
48
|
_uniformSetters: Record<string, Function> = {}; // TODO are these used?
|
|
51
49
|
|
|
@@ -131,7 +129,14 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
131
129
|
// }
|
|
132
130
|
|
|
133
131
|
for (const [name, value] of Object.entries(bindings)) {
|
|
134
|
-
|
|
132
|
+
// Accept both `xyz` and `xyzUniforms` as valid names for `xyzUniforms` uniform block
|
|
133
|
+
// This convention allows shaders to name uniform blocks as `uniform appUniforms {} app;`
|
|
134
|
+
// and reference them as `app` from both GLSL and JS.
|
|
135
|
+
// TODO - this is rather hacky - we could also remap the name directly in the shader layout.
|
|
136
|
+
const binding =
|
|
137
|
+
this.shaderLayout.bindings.find(binding => binding.name === name) ||
|
|
138
|
+
this.shaderLayout.bindings.find(binding => binding.name === `${name}Uniforms`);
|
|
139
|
+
|
|
135
140
|
if (!binding) {
|
|
136
141
|
const validBindings = this.shaderLayout.bindings
|
|
137
142
|
.map(binding => `"${binding.name}"`)
|
|
@@ -168,6 +173,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
168
173
|
}
|
|
169
174
|
|
|
170
175
|
setUniforms(uniforms: Record<string, UniformValue>) {
|
|
176
|
+
const {bindings} = splitUniformsAndBindings(uniforms);
|
|
177
|
+
Object.keys(bindings).forEach(name => {
|
|
178
|
+
log.warn(
|
|
179
|
+
`Unsupported value "${bindings[name]}" used in setUniforms() for key ${name}. Use setBindings() instead?`
|
|
180
|
+
)();
|
|
181
|
+
});
|
|
171
182
|
// TODO - check against layout
|
|
172
183
|
Object.assign(this.uniforms, uniforms);
|
|
173
184
|
}
|
|
@@ -335,16 +346,9 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
335
346
|
_areTexturesRenderable() {
|
|
336
347
|
let texturesRenderable = true;
|
|
337
348
|
|
|
338
|
-
for (const [, texture] of Object.entries(this._textureUniforms)) {
|
|
339
|
-
texture.update();
|
|
340
|
-
texturesRenderable = texturesRenderable && texture.loaded;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
349
|
for (const [, texture] of Object.entries(this.bindings)) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (texture.loaded !== undefined) {
|
|
347
|
-
// @ts-expect-error
|
|
350
|
+
if (texture instanceof WEBGLTexture) {
|
|
351
|
+
texture.update();
|
|
348
352
|
texturesRenderable = texturesRenderable && texture.loaded;
|
|
349
353
|
}
|
|
350
354
|
}
|
|
@@ -386,7 +390,8 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
386
390
|
let textureUnit = 0;
|
|
387
391
|
let uniformBufferIndex = 0;
|
|
388
392
|
for (const binding of this.shaderLayout.bindings) {
|
|
389
|
-
|
|
393
|
+
// Accept both `xyz` and `xyzUniforms` as valid names for `xyzUniforms` uniform block
|
|
394
|
+
const value = this.bindings[binding.name] || this.bindings[binding.name.replace(/Uniforms$/, '')];
|
|
390
395
|
if (!value) {
|
|
391
396
|
throw new Error(`No value for binding ${binding.name} in ${this.id}`);
|
|
392
397
|
}
|