@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.7
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 +128 -71
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +20 -19
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +16 -11
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +224 -205
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +22 -21
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +89 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +22 -19
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +47 -46
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +35 -34
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +42 -41
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +30 -17
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -101
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +16 -15
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +32 -31
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +6 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +60 -53
- package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +136 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +20 -12
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +52 -61
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +5 -4
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +15 -9
- package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +18 -0
- package/dist/adapter/resources/webgl-texture.d.ts +6 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +39 -32
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +10 -10
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +10 -9
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +3 -2
- package/dist/adapter/webgl-device.d.ts +35 -30
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +110 -109
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +8 -7
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +5 -4
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +19 -19
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +16 -15
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +20 -19
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/{context → helpers}/create-browser-context.d.ts.map +1 -1
- package/dist/context/{context → helpers}/create-browser-context.js +2 -1
- package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +21 -0
- package/dist/context/helpers/webgl-extensions.d.ts +4 -0
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +10 -0
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +7 -11
- package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +302 -295
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +2 -3
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -8
- package/dist/dist.dev.js +1635 -1387
- package/dist/index.cjs +1766 -1534
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +6 -6
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +114 -27
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +138 -114
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +36 -14
- package/src/adapter/objects/webgl-resource.ts +7 -125
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +6 -5
- package/src/adapter/resources/webgl-framebuffer.ts +61 -53
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +20 -11
- package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +14 -3
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +116 -107
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +14 -8
- package/src/classic/copy-and-blit.ts +11 -4
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- package/src/context/helpers/webgl-context-data.ts +31 -0
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +6 -17
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +8 -8
- package/src/index.ts +7 -6
- package/src/types.ts +2 -1
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js +0 -87
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/src/context/context/context-data.ts +0 -44
- /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {RenderPass, RenderPassProps, NumberArray, RenderPassParameters} from '@luma.gl/core';
|
|
@@ -7,6 +8,7 @@ import {GL, GLParameters} from '@luma.gl/constants';
|
|
|
7
8
|
import {withGLParameters} from '../../context/state-tracker/with-parameters';
|
|
8
9
|
import {setGLParameters} from '../../context/parameters/unified-parameter-api';
|
|
9
10
|
import {pushContextState, popContextState} from '../../context/state-tracker/track-context-state';
|
|
11
|
+
import {WEBGLQuerySet} from './webgl-query-set';
|
|
10
12
|
|
|
11
13
|
// Should collapse during minification
|
|
12
14
|
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
@@ -36,7 +38,7 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
36
38
|
end(): void {
|
|
37
39
|
popContextState(this.device.gl);
|
|
38
40
|
if (this.props.framebuffer) {
|
|
39
|
-
setGLParameters(this.device, {framebuffer: null});
|
|
41
|
+
setGLParameters(this.device.gl, {framebuffer: null});
|
|
40
42
|
}
|
|
41
43
|
// should add commands to CommandEncoder.
|
|
42
44
|
}
|
|
@@ -45,8 +47,6 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
45
47
|
popDebugGroup(): void {}
|
|
46
48
|
insertDebugMarker(markerLabel: string): void {}
|
|
47
49
|
|
|
48
|
-
// writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
|
|
49
|
-
|
|
50
50
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
51
51
|
// endOcclusionQuery(): void;
|
|
52
52
|
|
|
@@ -99,10 +99,20 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
99
99
|
|
|
100
100
|
this.glParameters = glParameters;
|
|
101
101
|
|
|
102
|
-
setGLParameters(this.device, glParameters);
|
|
102
|
+
setGLParameters(this.device.gl, glParameters);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
beginOcclusionQuery(queryIndex: number): void {
|
|
106
|
+
const webglQuerySet = this.props.occlusionQuerySet as WEBGLQuerySet;
|
|
107
|
+
webglQuerySet?.beginOcclusionQuery();
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
|
|
110
|
+
override endOcclusionQuery(): void {
|
|
111
|
+
const webglQuerySet = this.props.occlusionQuerySet as WEBGLQuerySet;
|
|
112
|
+
webglQuerySet?.endOcclusionQuery();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// PRIVATE
|
|
106
116
|
|
|
107
117
|
/**
|
|
108
118
|
* Optionally clears depth, color and stencil buffers based on parameters
|
|
@@ -127,19 +137,19 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
127
137
|
|
|
128
138
|
if (clearMask !== 0) {
|
|
129
139
|
// Temporarily set any clear "colors" and call clear
|
|
130
|
-
withGLParameters(this.device, glParameters, () => {
|
|
140
|
+
withGLParameters(this.device.gl, glParameters, () => {
|
|
131
141
|
this.device.gl.clear(clearMask);
|
|
132
142
|
});
|
|
133
143
|
|
|
134
144
|
// TODO - clear multiple color attachments
|
|
135
145
|
// for (attachment of this.framebuffer.colorAttachments) {
|
|
136
|
-
// this.clearColorBuffer
|
|
146
|
+
// this.clearColorBuffer
|
|
137
147
|
// }
|
|
138
148
|
}
|
|
139
149
|
}
|
|
140
150
|
|
|
141
|
-
/**
|
|
142
|
-
* WebGL2 - clear a specific color buffer
|
|
151
|
+
/**
|
|
152
|
+
* WebGL2 - clear a specific color buffer
|
|
143
153
|
*/
|
|
144
154
|
protected clearColorBuffer(drawBuffer: number = 0, value: NumberArray = [0, 0, 0, 0]) {
|
|
145
155
|
withGLParameters(this.device.gl, {framebuffer: this.props.framebuffer}, () => {
|
|
@@ -182,4 +192,3 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
182
192
|
// }
|
|
183
193
|
// });
|
|
184
194
|
}
|
|
185
|
-
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {UniformValue, RenderPipelineProps, Binding} from '@luma.gl/core';
|
|
@@ -19,7 +20,7 @@ import {WEBGLBuffer} from './webgl-buffer';
|
|
|
19
20
|
import {WEBGLShader} from './webgl-shader';
|
|
20
21
|
import {WEBGLFramebuffer} from './webgl-framebuffer';
|
|
21
22
|
import {WEBGLTexture} from './webgl-texture';
|
|
22
|
-
|
|
23
|
+
import {WEBGLTextureView} from './webgl-texture-view';
|
|
23
24
|
import {WEBGLRenderPass} from './webgl-render-pass';
|
|
24
25
|
import {WEBGLTransformFeedback} from './webgl-transform-feedback';
|
|
25
26
|
import {getGLDrawMode} from '../helpers/webgl-topology-utils';
|
|
@@ -71,7 +72,10 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
71
72
|
|
|
72
73
|
this._linkShaders();
|
|
73
74
|
|
|
75
|
+
log.time(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
74
76
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
77
|
+
log.timeEnd(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
78
|
+
|
|
75
79
|
// Merge provided layout with introspected layout
|
|
76
80
|
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
77
81
|
|
|
@@ -133,7 +137,13 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
133
137
|
}
|
|
134
138
|
break;
|
|
135
139
|
case 'texture':
|
|
136
|
-
if (
|
|
140
|
+
if (
|
|
141
|
+
!(
|
|
142
|
+
value instanceof WEBGLTextureView ||
|
|
143
|
+
value instanceof WEBGLTexture ||
|
|
144
|
+
value instanceof WEBGLFramebuffer
|
|
145
|
+
)
|
|
146
|
+
) {
|
|
137
147
|
throw new Error('texture value');
|
|
138
148
|
}
|
|
139
149
|
break;
|
|
@@ -148,20 +158,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
160
|
|
|
151
|
-
/** This function is @deprecated, use uniform buffers */
|
|
152
|
-
setUniforms(uniforms: Record<string, UniformValue>) {
|
|
153
|
-
const {bindings} = splitUniformsAndBindings(uniforms);
|
|
154
|
-
Object.keys(bindings).forEach(name => {
|
|
155
|
-
log.warn(
|
|
156
|
-
`Unsupported value "${JSON.stringify(
|
|
157
|
-
bindings[name]
|
|
158
|
-
)}" used in setUniforms() for key ${name}. Use setBindings() instead?`
|
|
159
|
-
)();
|
|
160
|
-
});
|
|
161
|
-
// TODO - check against layout
|
|
162
|
-
Object.assign(this.uniforms, uniforms);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
161
|
/** @todo needed for portable model
|
|
166
162
|
* @note The WebGL API is offers many ways to draw things
|
|
167
163
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
@@ -179,11 +175,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
179
175
|
baseVertex?: number;
|
|
180
176
|
transformFeedback?: WEBGLTransformFeedback;
|
|
181
177
|
}): boolean {
|
|
182
|
-
// If we are using async linking, we need to wait until linking completes
|
|
183
|
-
if (this.linkStatus !== 'success') {
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
178
|
const {
|
|
188
179
|
renderPass,
|
|
189
180
|
vertexArray,
|
|
@@ -202,15 +193,27 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
202
193
|
const glIndexType = (vertexArray.indexBuffer as WEBGLBuffer)?.glIndexType;
|
|
203
194
|
const isInstanced: boolean = Number(instanceCount) > 0;
|
|
204
195
|
|
|
196
|
+
// If we are using async linking, we need to wait until linking completes
|
|
197
|
+
if (this.linkStatus !== 'success') {
|
|
198
|
+
log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
205
202
|
// Avoid WebGL draw call when not rendering any data or values are incomplete
|
|
206
203
|
// Note: async textures set as uniforms might still be loading.
|
|
207
204
|
// Now that all uniforms have been updated, check if any texture
|
|
208
205
|
// in the uniforms is not yet initialized, then we don't draw
|
|
209
206
|
if (!this._areTexturesRenderable() || vertexCount === 0) {
|
|
210
|
-
|
|
207
|
+
log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
211
208
|
return false;
|
|
212
209
|
}
|
|
213
210
|
|
|
211
|
+
// (isInstanced && instanceCount === 0)
|
|
212
|
+
if (vertexCount === 0) {
|
|
213
|
+
log.info(2, `RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)();
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
214
217
|
this.device.gl.useProgram(this.handle);
|
|
215
218
|
|
|
216
219
|
// Note: Rebinds constant attributes before each draw call
|
|
@@ -225,31 +228,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
225
228
|
this._applyUniforms();
|
|
226
229
|
|
|
227
230
|
const webglRenderPass = renderPass as WEBGLRenderPass;
|
|
228
|
-
// // TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension
|
|
229
|
-
// if (isIndexed && isInstanced) {
|
|
230
|
-
// // ANGLE_instanced_arrays extension
|
|
231
|
-
// this.device.gl.drawElementsInstanced(
|
|
232
|
-
// drawMode,
|
|
233
|
-
// vertexCount || 0, // indexCount?
|
|
234
|
-
// indexType,
|
|
235
|
-
// firstVertex,
|
|
236
|
-
// instanceCount || 0
|
|
237
|
-
// );
|
|
238
|
-
// // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {
|
|
239
|
-
// // this.device.gldrawRangeElements(drawMode, start, end, vertexCount, indexType, offset);
|
|
240
|
-
// } else if (isIndexed) {
|
|
241
|
-
// this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?
|
|
242
|
-
// } else if (isInstanced) {
|
|
243
|
-
// this.device.gl.drawArraysInstanced(
|
|
244
|
-
// drawMode,
|
|
245
|
-
// firstVertex,
|
|
246
|
-
// vertexCount || 0,
|
|
247
|
-
// instanceCount || 0
|
|
248
|
-
// );
|
|
249
|
-
// } else {
|
|
250
|
-
// this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);
|
|
251
|
-
// }
|
|
252
|
-
// });
|
|
253
231
|
|
|
254
232
|
withDeviceAndGLParameters(
|
|
255
233
|
this.device,
|
|
@@ -257,7 +235,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
257
235
|
webglRenderPass.glParameters,
|
|
258
236
|
() => {
|
|
259
237
|
if (isIndexed && isInstanced) {
|
|
260
|
-
// ANGLE_instanced_arrays extension
|
|
261
238
|
this.device.gl.drawElementsInstanced(
|
|
262
239
|
glDrawMode,
|
|
263
240
|
vertexCount || 0, // indexCount?
|
|
@@ -291,6 +268,21 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
291
268
|
return true;
|
|
292
269
|
}
|
|
293
270
|
|
|
271
|
+
// DEPRECATED METHODS
|
|
272
|
+
|
|
273
|
+
override setUniformsWebGL(uniforms: Record<string, UniformValue>) {
|
|
274
|
+
const {bindings} = splitUniformsAndBindings(uniforms);
|
|
275
|
+
Object.keys(bindings).forEach(name => {
|
|
276
|
+
log.warn(
|
|
277
|
+
`Unsupported value "${JSON.stringify(
|
|
278
|
+
bindings[name]
|
|
279
|
+
)}" used in setUniforms() for key ${name}. Use setBindings() instead?`
|
|
280
|
+
)();
|
|
281
|
+
});
|
|
282
|
+
// TODO - check against layout
|
|
283
|
+
Object.assign(this.uniforms, uniforms);
|
|
284
|
+
}
|
|
285
|
+
|
|
294
286
|
// PRIVATE METHODS
|
|
295
287
|
|
|
296
288
|
// setAttributes(attributes: Record<string, Buffer>): void {}
|
|
@@ -309,7 +301,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
309
301
|
// return;
|
|
310
302
|
}
|
|
311
303
|
|
|
312
|
-
if (!this.device.features.has('
|
|
304
|
+
if (!this.device.features.has('compilation-status-async-webgl')) {
|
|
313
305
|
const status = this._getLinkStatus();
|
|
314
306
|
this._reportLinkStatus(status);
|
|
315
307
|
return;
|
|
@@ -373,14 +365,14 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
373
365
|
const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)
|
|
374
366
|
|
|
375
367
|
// If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking
|
|
376
|
-
if (!this.device.features.has('
|
|
368
|
+
if (!this.device.features.has('compilation-status-async-webgl')) {
|
|
377
369
|
await waitMs(DELAY_MS);
|
|
378
370
|
return;
|
|
379
371
|
}
|
|
380
372
|
|
|
381
373
|
const {gl} = this.device;
|
|
382
374
|
for (;;) {
|
|
383
|
-
const complete = gl.getProgramParameter(this.handle, GL.
|
|
375
|
+
const complete = gl.getProgramParameter(this.handle, GL.COMPLETION_STATUS_KHR);
|
|
384
376
|
if (complete) {
|
|
385
377
|
return;
|
|
386
378
|
}
|
|
@@ -453,11 +445,19 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
453
445
|
break;
|
|
454
446
|
|
|
455
447
|
case 'texture':
|
|
456
|
-
if (
|
|
448
|
+
if (
|
|
449
|
+
!(
|
|
450
|
+
value instanceof WEBGLTextureView ||
|
|
451
|
+
value instanceof WEBGLTexture ||
|
|
452
|
+
value instanceof WEBGLFramebuffer
|
|
453
|
+
)
|
|
454
|
+
) {
|
|
457
455
|
throw new Error('texture');
|
|
458
456
|
}
|
|
459
457
|
let texture: WEBGLTexture;
|
|
460
|
-
if (value instanceof
|
|
458
|
+
if (value instanceof WEBGLTextureView) {
|
|
459
|
+
texture = value.texture;
|
|
460
|
+
} else if (value instanceof WEBGLTexture) {
|
|
461
461
|
texture = value;
|
|
462
462
|
} else if (
|
|
463
463
|
value instanceof WEBGLFramebuffer &&
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {Shader, ShaderProps, CompilerMessage, log} from '@luma.gl/core';
|
|
@@ -48,6 +49,12 @@ export class WEBGLShader extends Shader {
|
|
|
48
49
|
return parseShaderCompilerLog(log);
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
override getTranslatedSource(): string | null {
|
|
53
|
+
const extensions = this.device.getExtension('WEBGL_debug_shaders');
|
|
54
|
+
const ext = extensions.WEBGL_debug_shaders;
|
|
55
|
+
return ext?.getTranslatedShaderSource(this.handle);
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
// PRIVATE METHODS
|
|
52
59
|
|
|
53
60
|
/** Compile a shader and get compilation status */
|
|
@@ -67,7 +74,7 @@ export class WEBGLShader extends Shader {
|
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
// Sync case - slower, but advantage is that it throws in the constructor, making break on error more useful
|
|
70
|
-
if (!this.device.features.has('
|
|
77
|
+
if (!this.device.features.has('compilation-status-async-webgl')) {
|
|
71
78
|
this._getCompilationStatus();
|
|
72
79
|
if (this.compilationStatus === 'error') {
|
|
73
80
|
throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
|
|
@@ -93,14 +100,14 @@ export class WEBGLShader extends Shader {
|
|
|
93
100
|
const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)
|
|
94
101
|
|
|
95
102
|
// If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking
|
|
96
|
-
if (!this.device.features.has('
|
|
103
|
+
if (!this.device.features.has('compilation-status-async-webgl')) {
|
|
97
104
|
await waitMs(DELAY_MS);
|
|
98
105
|
return;
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
const {gl} = this.device;
|
|
102
109
|
for (;;) {
|
|
103
|
-
const complete = gl.getShaderParameter(this.handle, GL.
|
|
110
|
+
const complete = gl.getShaderParameter(this.handle, GL.COMPLETION_STATUS_KHR);
|
|
104
111
|
if (complete) {
|
|
105
112
|
return;
|
|
106
113
|
}
|
|
@@ -112,7 +119,7 @@ export class WEBGLShader extends Shader {
|
|
|
112
119
|
* Get the shader compilation status
|
|
113
120
|
* TODO - Load log even when no error reported, to catch warnings?
|
|
114
121
|
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
115
|
-
|
|
122
|
+
*/
|
|
116
123
|
protected _getCompilationStatus() {
|
|
117
124
|
this.compilationStatus = this.device.gl.getShaderParameter(this.handle, GL.COMPILE_STATUS)
|
|
118
125
|
? 'success'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Device, TextureViewProps} from '@luma.gl/core';
|
|
6
|
+
// import {decodeTextureFormat} from '@luma.gl/core';
|
|
7
|
+
import {TextureView, Texture} from '@luma.gl/core';
|
|
8
|
+
|
|
9
|
+
import {WebGLDevice} from '../webgl-device';
|
|
10
|
+
import {WEBGLTexture} from './webgl-texture';
|
|
11
|
+
|
|
12
|
+
export class WEBGLTextureView extends TextureView {
|
|
13
|
+
readonly device: WebGLDevice;
|
|
14
|
+
readonly gl: WebGL2RenderingContext;
|
|
15
|
+
readonly handle: WebGLTexture;
|
|
16
|
+
|
|
17
|
+
readonly texture: WEBGLTexture;
|
|
18
|
+
|
|
19
|
+
constructor(device: Device, props: TextureViewProps & {texture: WEBGLTexture}) {
|
|
20
|
+
super(device, {...Texture.defaultProps, ...props});
|
|
21
|
+
|
|
22
|
+
this.device = device as WebGLDevice;
|
|
23
|
+
this.gl = this.device.gl;
|
|
24
|
+
this.handle = null;
|
|
25
|
+
|
|
26
|
+
this.texture = props.texture;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
// Texture class.
|
|
@@ -9,6 +10,7 @@
|
|
|
9
10
|
import {
|
|
10
11
|
Device,
|
|
11
12
|
TextureProps,
|
|
13
|
+
TextureViewProps,
|
|
12
14
|
Sampler,
|
|
13
15
|
SamplerProps,
|
|
14
16
|
SamplerParameters,
|
|
@@ -26,6 +28,7 @@ import {convertSamplerParametersToWebGL} from '../converters/sampler-parameters'
|
|
|
26
28
|
import {WebGLDevice} from '../webgl-device';
|
|
27
29
|
import {WEBGLBuffer} from './webgl-buffer';
|
|
28
30
|
import {WEBGLSampler} from './webgl-sampler';
|
|
31
|
+
import {WEBGLTextureView} from './webgl-texture-view';
|
|
29
32
|
|
|
30
33
|
export type WEBGLTextureProps = TextureProps & {
|
|
31
34
|
/** @deprecated use props.sampler */
|
|
@@ -151,9 +154,11 @@ export class WEBGLTexture extends Texture<WEBGLTextureProps> {
|
|
|
151
154
|
readonly gl: WebGL2RenderingContext;
|
|
152
155
|
readonly handle: WebGLTexture;
|
|
153
156
|
|
|
154
|
-
|
|
157
|
+
// (TODO - currently unused in WebGL, but WebGL 2 does support sampler objects) */
|
|
155
158
|
sampler: WEBGLSampler = undefined;
|
|
156
159
|
|
|
160
|
+
view: WEBGLTextureView = undefined;
|
|
161
|
+
|
|
157
162
|
// data;
|
|
158
163
|
|
|
159
164
|
glFormat: GL = undefined;
|
|
@@ -223,6 +228,10 @@ export class WEBGLTexture extends Texture<WEBGLTextureProps> {
|
|
|
223
228
|
return `Texture(${this.id},${this.width}x${this.height})`;
|
|
224
229
|
}
|
|
225
230
|
|
|
231
|
+
createView(props: TextureViewProps): WEBGLTextureView {
|
|
232
|
+
return new WEBGLTextureView(this.device, {...props, texture: this});
|
|
233
|
+
}
|
|
234
|
+
|
|
226
235
|
// eslint-disable-next-line max-statements
|
|
227
236
|
initialize(props: WEBGLTextureProps = {}): this {
|
|
228
237
|
// Cube textures
|
|
@@ -314,7 +323,9 @@ export class WEBGLTexture extends Texture<WEBGLTextureProps> {
|
|
|
314
323
|
this.setSampler(props.sampler);
|
|
315
324
|
this._setSamplerParameters(parameters);
|
|
316
325
|
|
|
317
|
-
|
|
326
|
+
this.view = this.createView({...this.props, mipLevelCount: 1, arrayLayerCount: 1});
|
|
327
|
+
|
|
328
|
+
if (mipmaps && this.device.isTextureFormatFilterable(props.format)) {
|
|
318
329
|
this.generateMipmap();
|
|
319
330
|
}
|
|
320
331
|
|
|
@@ -2,7 +2,7 @@ import type {PrimitiveTopology, ShaderLayout, TransformFeedbackProps} from '@lum
|
|
|
2
2
|
import {log, TransformFeedback, Buffer, BufferRange} from '@luma.gl/core';
|
|
3
3
|
import {GL} from '@luma.gl/constants';
|
|
4
4
|
import {WebGLDevice} from '../webgl-device';
|
|
5
|
-
import {WEBGLBuffer} from '
|
|
5
|
+
import {WEBGLBuffer} from '../../index';
|
|
6
6
|
import {getGLPrimitive} from '../helpers/webgl-topology-utils';
|
|
7
7
|
|
|
8
8
|
export class WEBGLTransformFeedback extends TransformFeedback {
|
|
@@ -174,12 +174,7 @@ export class WEBGLTransformFeedback extends TransformFeedback {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
protected _bindBuffer(
|
|
178
|
-
index: number,
|
|
179
|
-
buffer: Buffer,
|
|
180
|
-
byteOffset = 0,
|
|
181
|
-
byteLength?: number
|
|
182
|
-
): void {
|
|
177
|
+
protected _bindBuffer(index: number, buffer: Buffer, byteOffset = 0, byteLength?: number): void {
|
|
183
178
|
const handle = buffer && (buffer as WEBGLBuffer).handle;
|
|
184
179
|
if (!handle || byteLength === undefined) {
|
|
185
180
|
this.gl.bindBufferBase(GL.TRANSFORM_FEEDBACK_BUFFER, index, handle);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {Device, Buffer, VertexArrayProps, TypedArray, NumberArray} from '@luma.gl/core';
|
|
@@ -106,7 +107,7 @@ export class WEBGLVertexArray extends VertexArray {
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
109
|
-
override
|
|
110
|
+
override setConstantWebGL(location: number, value: TypedArray): void {
|
|
110
111
|
this._enable(location, false);
|
|
111
112
|
this.attributes[location] = value;
|
|
112
113
|
}
|
|
@@ -146,7 +147,7 @@ export class WEBGLVertexArray extends VertexArray {
|
|
|
146
147
|
const constant = this.attributes[location];
|
|
147
148
|
// A typed array means this is a constant
|
|
148
149
|
if (ArrayBuffer.isView(constant)) {
|
|
149
|
-
this.device.
|
|
150
|
+
this.device.setConstantAttributeWebGL(location, constant);
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {CanvasContextProps} from '@luma.gl/core';
|
|
@@ -6,8 +7,8 @@ import {CanvasContext} from '@luma.gl/core';
|
|
|
6
7
|
import {WebGLDevice} from './webgl-device';
|
|
7
8
|
import {WEBGLFramebuffer} from './resources/webgl-framebuffer';
|
|
8
9
|
|
|
9
|
-
/**
|
|
10
|
-
* A WebGL Canvas Context which manages the canvas and handles drawing buffer resizing etc
|
|
10
|
+
/**
|
|
11
|
+
* A WebGL Canvas Context which manages the canvas and handles drawing buffer resizing etc
|
|
11
12
|
*/
|
|
12
13
|
export class WebGLCanvasContext extends CanvasContext {
|
|
13
14
|
readonly device: WebGLDevice;
|
|
@@ -33,7 +34,8 @@ export class WebGLCanvasContext extends CanvasContext {
|
|
|
33
34
|
/** Resizes and updates render targets if necessary */
|
|
34
35
|
update() {
|
|
35
36
|
const size = this.getPixelSize();
|
|
36
|
-
const sizeChanged =
|
|
37
|
+
const sizeChanged =
|
|
38
|
+
size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];
|
|
37
39
|
if (sizeChanged) {
|
|
38
40
|
this.presentationSize = size;
|
|
39
41
|
this.resize();
|