@luma.gl/webgl 9.0.17 → 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 +30 -12
- package/dist/adapter/converters/texture-formats.d.ts +22 -16
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +39 -47
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -2
- package/dist/adapter/device-helpers/webgl-device-limits.js +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +300 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/webgl-texture-utils.js +370 -0
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +0 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +6 -9
- package/dist/adapter/resources/webgl-framebuffer.d.ts +32 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +42 -60
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -2
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +18 -7
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +46 -21
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +3 -3
- package/dist/adapter/resources/webgl-texture-view.d.ts +1 -1
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture-view.js +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +76 -172
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +397 -511
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +2 -2
- 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-canvas-context.d.ts +3 -1
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +2 -0
- package/dist/adapter/webgl-device.d.ts +19 -30
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +35 -114
- package/dist/classic/accessor.d.ts +22 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -9
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +2 -5
- package/dist/classic/copy-and-blit.d.ts +3 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +21 -18
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +0 -3
- package/dist/classic/typed-array-utils.d.ts +1 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- 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 +25 -18
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +2 -5
- package/dist/context/parameters/webgl-parameter-tables.js +1 -1
- 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} +46 -77
- 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 +1112 -1380
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +1122 -1284
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/utils/fill-array.d.ts +8 -0
- package/dist/utils/fill-array.d.ts.map +1 -0
- package/dist/utils/fill-array.js +26 -0
- package/dist/utils/load-script.d.ts +8 -0
- package/dist/utils/load-script.d.ts.map +1 -0
- package/dist/utils/load-script.js +26 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts +9 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -0
- package/dist/utils/split-uniforms-and-bindings.js +20 -0
- 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 +6 -5
- package/src/adapter/converters/device-parameters.ts +31 -13
- package/src/adapter/converters/texture-formats.ts +51 -56
- package/src/adapter/device-helpers/webgl-device-features.ts +1 -2
- package/src/adapter/device-helpers/webgl-device-limits.ts +1 -1
- package/src/adapter/helpers/webgl-texture-utils.ts +484 -0
- package/src/adapter/helpers/webgl-topology-utils.ts +0 -4
- package/src/adapter/resources/webgl-buffer.ts +2 -2
- package/src/adapter/resources/webgl-command-buffer.ts +8 -10
- package/src/adapter/resources/webgl-framebuffer.ts +22 -56
- package/src/adapter/resources/webgl-render-pass.ts +21 -9
- package/src/adapter/resources/webgl-render-pipeline.ts +50 -24
- package/src/adapter/resources/webgl-shader.ts +4 -4
- package/src/adapter/resources/webgl-texture-view.ts +1 -3
- package/src/adapter/resources/webgl-texture.ts +445 -784
- package/src/adapter/resources/webgl-vertex-array.ts +8 -7
- package/src/adapter/webgl-adapter.ts +113 -0
- package/src/adapter/webgl-canvas-context.ts +4 -1
- package/src/adapter/webgl-device.ts +40 -151
- package/src/classic/accessor.ts +31 -11
- package/src/classic/clear.ts +3 -6
- package/src/classic/copy-and-blit.ts +32 -27
- package/src/classic/format-utils.ts +0 -3
- package/src/classic/typed-array-utils.ts +1 -1
- package/src/context/debug/spector-types.ts +1154 -0
- package/src/context/debug/spector.ts +40 -30
- package/src/context/debug/webgl-developer-tools.ts +3 -7
- package/src/context/parameters/webgl-parameter-tables.ts +3 -3
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +202 -0
- package/src/context/state-tracker/{track-context-state.ts → webgl-state-tracker.ts} +57 -97
- package/src/context/state-tracker/with-parameters.ts +5 -4
- package/src/index.ts +5 -13
- package/src/utils/fill-array.ts +35 -0
- package/src/utils/load-script.ts +30 -0
- package/src/utils/split-uniforms-and-bindings.ts +31 -0
- package/src/utils/uid.ts +16 -0
- package/dist/adapter/objects/constants-to-keys.d.ts +0 -3
- package/dist/adapter/objects/constants-to-keys.d.ts.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js +0 -22
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +0 -43
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +0 -95
- package/dist/adapter/objects/webgl-resource.d.ts +0 -32
- package/dist/adapter/objects/webgl-resource.d.ts.map +0 -1
- package/dist/adapter/objects/webgl-resource.js +0 -114
- 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
- package/src/adapter/objects/constants-to-keys.ts +0 -27
- package/src/adapter/objects/webgl-renderbuffer.ts +0 -132
- package/src/adapter/objects/webgl-resource.ts +0 -183
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { Framebuffer
|
|
4
|
+
import { Framebuffer } from '@luma.gl/core';
|
|
5
5
|
import { GL } from '@luma.gl/constants';
|
|
6
6
|
import { WEBGLTexture } from "./webgl-texture.js";
|
|
7
|
-
import { WEBGLTextureView } from "./webgl-texture-view.js";
|
|
8
7
|
import { getDepthStencilAttachmentWebGL } from "../converters/texture-formats.js";
|
|
9
8
|
/** luma.gl Framebuffer, WebGL implementation */
|
|
10
9
|
export class WEBGLFramebuffer extends Framebuffer {
|
|
11
10
|
device;
|
|
12
11
|
gl;
|
|
13
12
|
handle;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
colorAttachments = [];
|
|
14
|
+
depthStencilAttachment = null;
|
|
17
15
|
constructor(device, props) {
|
|
18
16
|
super(device, props);
|
|
19
17
|
// WebGL default framebuffer handle is null
|
|
@@ -35,11 +33,11 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
35
33
|
const attachment = this.colorAttachments[i];
|
|
36
34
|
const attachmentPoint = 36064 + i;
|
|
37
35
|
if (attachment) {
|
|
38
|
-
this.
|
|
36
|
+
this._attachTexture(attachmentPoint, attachment);
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
if (this.depthStencilAttachment) {
|
|
42
|
-
this.
|
|
40
|
+
this._attachTexture(getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format), this.depthStencilAttachment);
|
|
43
41
|
}
|
|
44
42
|
/** Check the status */
|
|
45
43
|
// @ts-expect-error
|
|
@@ -74,74 +72,58 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
74
|
* Attachment resize is expected to be a noop if size is same
|
|
77
|
-
|
|
78
|
-
resizeAttachments(width, height) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
if (width === undefined) {
|
|
87
|
-
width = this.gl.drawingBufferWidth;
|
|
88
|
-
}
|
|
89
|
-
if (height === undefined) {
|
|
90
|
-
height = this.gl.drawingBufferHeight;
|
|
91
|
-
}
|
|
92
|
-
// TODO Not clear that this is better than default destroy/create implementation
|
|
93
|
-
for (const colorAttachment of this.colorAttachments) {
|
|
94
|
-
colorAttachment.texture.resize({ width, height });
|
|
95
|
-
}
|
|
96
|
-
if (this.depthStencilAttachment) {
|
|
97
|
-
this.depthStencilAttachment.texture.resize({ width, height });
|
|
98
|
-
}
|
|
75
|
+
*
|
|
76
|
+
protected override resizeAttachments(width: number, height: number): this {
|
|
77
|
+
// for default framebuffer, just update the stored size
|
|
78
|
+
if (this.handle === null) {
|
|
79
|
+
// assert(width === undefined && height === undefined);
|
|
80
|
+
this.width = this.gl.drawingBufferWidth;
|
|
81
|
+
this.height = this.gl.drawingBufferHeight;
|
|
99
82
|
return this;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (width === undefined) {
|
|
86
|
+
width = this.gl.drawingBufferWidth;
|
|
87
|
+
}
|
|
88
|
+
if (height === undefined) {
|
|
89
|
+
height = this.gl.drawingBufferHeight;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// TODO Not clear that this is better than default destroy/create implementation
|
|
93
|
+
|
|
94
|
+
for (const colorAttachment of this.colorAttachments) {
|
|
95
|
+
colorAttachment.texture.clone({width, height});
|
|
96
|
+
}
|
|
97
|
+
if (this.depthStencilAttachment) {
|
|
98
|
+
this.depthStencilAttachment.texture.resize({width, height});
|
|
99
|
+
}
|
|
100
|
+
return this;
|
|
100
101
|
}
|
|
102
|
+
*/
|
|
101
103
|
/** Attach one attachment */
|
|
102
|
-
|
|
104
|
+
_attachTexture(attachmentPoint, textureView) {
|
|
103
105
|
// if (attachment instanceof WEBGLRenderbuffer) {
|
|
104
106
|
// this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
105
107
|
// return attachment;
|
|
106
108
|
// }
|
|
107
|
-
|
|
108
|
-
const [texture, layer = 0, level = 0] = attachment;
|
|
109
|
-
this._attachTexture(attachmentPoint, texture, layer, level);
|
|
110
|
-
return texture;
|
|
111
|
-
}
|
|
112
|
-
if (attachment instanceof WEBGLTexture) {
|
|
113
|
-
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
114
|
-
return attachment;
|
|
115
|
-
}
|
|
116
|
-
if (attachment instanceof WEBGLTextureView) {
|
|
117
|
-
const textureView = attachment;
|
|
118
|
-
this._attachTexture(attachmentPoint, textureView.texture, textureView.props.baseMipLevel, textureView.props.baseArrayLayer);
|
|
119
|
-
return attachment.texture;
|
|
120
|
-
}
|
|
121
|
-
throw new Error('attach');
|
|
109
|
+
this._attachTextureView(attachmentPoint, textureView);
|
|
122
110
|
}
|
|
123
|
-
// TODO - we do not seem to need render buffers in WebGL 2
|
|
124
|
-
// protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {
|
|
125
|
-
// this.gl.framebufferRenderbuffer(
|
|
126
|
-
// GL.FRAMEBUFFER,
|
|
127
|
-
// attachment,
|
|
128
|
-
// GL.RENDERBUFFER,
|
|
129
|
-
// renderbuffer.handle
|
|
130
|
-
// );
|
|
131
|
-
// }
|
|
132
111
|
/**
|
|
133
112
|
* @param attachment
|
|
134
113
|
* @param texture
|
|
135
114
|
* @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`
|
|
136
115
|
* @param level = 0 - mipmapLevel
|
|
137
116
|
*/
|
|
138
|
-
|
|
117
|
+
_attachTextureView(attachment, textureView) {
|
|
139
118
|
const { gl } = this.device;
|
|
140
|
-
|
|
141
|
-
|
|
119
|
+
const { texture } = textureView;
|
|
120
|
+
const level = textureView.props.baseMipLevel;
|
|
121
|
+
const layer = textureView.props.baseArrayLayer;
|
|
122
|
+
gl.bindTexture(texture.glTarget, texture.handle);
|
|
123
|
+
switch (texture.glTarget) {
|
|
142
124
|
case 35866:
|
|
143
125
|
case 32879:
|
|
144
|
-
gl.framebufferTextureLayer(36160, attachment, texture.
|
|
126
|
+
gl.framebufferTextureLayer(36160, attachment, texture.handle, level, layer);
|
|
145
127
|
break;
|
|
146
128
|
case 34067:
|
|
147
129
|
// layer must be a cubemap face (or if index, converted to cube map face)
|
|
@@ -152,9 +134,9 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
152
134
|
gl.framebufferTexture2D(36160, attachment, 3553, texture.handle, level);
|
|
153
135
|
break;
|
|
154
136
|
default:
|
|
155
|
-
|
|
137
|
+
throw new Error('Illegal texture type');
|
|
156
138
|
}
|
|
157
|
-
gl.bindTexture(texture.
|
|
139
|
+
gl.bindTexture(texture.glTarget, null);
|
|
158
140
|
}
|
|
159
141
|
}
|
|
160
142
|
// Helper functions
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NumericArray } from '@math.gl/types';
|
|
2
|
+
import { RenderPass, RenderPassProps, RenderPassParameters } from '@luma.gl/core';
|
|
2
3
|
import { WebGLDevice } from "../webgl-device.js";
|
|
3
4
|
import { GLParameters } from '@luma.gl/constants';
|
|
4
5
|
export declare class WEBGLRenderPass extends RenderPass {
|
|
@@ -23,6 +24,6 @@ export declare class WEBGLRenderPass extends RenderPass {
|
|
|
23
24
|
/**
|
|
24
25
|
* WebGL2 - clear a specific color buffer
|
|
25
26
|
*/
|
|
26
|
-
protected clearColorBuffer(drawBuffer?: number, value?:
|
|
27
|
+
protected clearColorBuffer(drawBuffer?: number, value?: NumericArray): void;
|
|
27
28
|
}
|
|
28
29
|
//# sourceMappingURL=webgl-render-pass.d.ts.map
|
|
@@ -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,UAAU,EAAE,eAAe,EAAE,
|
|
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) { }
|
|
@@ -41,9 +54,7 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
41
54
|
setParameters(parameters = {}) {
|
|
42
55
|
const glParameters = { ...this.glParameters };
|
|
43
56
|
// Framebuffers are specified using parameters in WebGL
|
|
44
|
-
|
|
45
|
-
glParameters.framebuffer = this.props.framebuffer;
|
|
46
|
-
}
|
|
57
|
+
glParameters.framebuffer = this.props.framebuffer || null;
|
|
47
58
|
if (this.props.depthReadOnly) {
|
|
48
59
|
glParameters.depthMask = !this.props.depthReadOnly;
|
|
49
60
|
}
|
|
@@ -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,CAAC;AACvE,OAAO,KAAK,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,cAAc,
|
|
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,CAAC;AACvE,OAAO,KAAK,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAM,MAAM,eAAe,CAAC;AAUlD,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C,OAAO,EAAC,WAAW,EAAC,0BAAuB;AAK3C,OAAO,EAAC,sBAAsB,EAAC,sCAAmC;AAKlE,oCAAoC;AACpC,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,yDAAyD;IACzD,MAAM,EAAE,WAAW,CAAC;IACpB,yCAAyC;IACzC,MAAM,EAAE,YAAY,CAAC;IACrB,oBAAoB;IACpB,EAAE,EAAE,WAAW,CAAC;IAChB,sBAAsB;IACtB,EAAE,EAAE,WAAW,CAAC;IAChB,mEAAmE;IACnE,kBAAkB,EAAE,YAAY,CAAC;IAEjC,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;IAC5C,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IACvC,qBAAqB;IACrB,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAQ;IAEjC,aAAa,EAAE,MAAM,CAAK;IAC1B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAM;gBAEnC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB;IA8BlD,OAAO,IAAI,IAAI;IAQxB;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAC,GAAG,IAAI;IA0D3F;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,EAAE,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"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { RenderPipeline,
|
|
5
|
-
import {
|
|
6
|
-
// import {mergeShaderLayout, getAttributeInfosFromLayouts} from '@luma.gl/core';
|
|
4
|
+
import { RenderPipeline, log } from '@luma.gl/core';
|
|
5
|
+
// import {getAttributeInfosFromLayouts} from '@luma.gl/core';
|
|
7
6
|
import { GL } from '@luma.gl/constants';
|
|
8
7
|
import { getShaderLayout } from "../helpers/get-shader-layout.js";
|
|
9
8
|
import { withDeviceAndGLParameters } from "../converters/device-parameters.js";
|
|
10
9
|
import { setUniform } from "../helpers/set-uniform.js";
|
|
10
|
+
import { splitUniformsAndBindings } from "../../utils/split-uniforms-and-bindings.js";
|
|
11
11
|
import { WEBGLBuffer } from "./webgl-buffer.js";
|
|
12
12
|
import { WEBGLFramebuffer } from "./webgl-framebuffer.js";
|
|
13
13
|
import { WEBGLTexture } from "./webgl-texture.js";
|
|
@@ -40,8 +40,8 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
40
40
|
this.handle = this.props.handle || this.device.gl.createProgram();
|
|
41
41
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
42
42
|
// Create shaders if needed
|
|
43
|
-
this.vs =
|
|
44
|
-
this.fs =
|
|
43
|
+
this.vs = props.vs;
|
|
44
|
+
this.fs = props.fs;
|
|
45
45
|
// assert(this.vs.stage === 'vertex');
|
|
46
46
|
// assert(this.fs.stage === 'fragment');
|
|
47
47
|
// Setup varyings if supplied
|
|
@@ -57,14 +57,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
57
57
|
log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
58
58
|
// Merge provided layout with introspected layout
|
|
59
59
|
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
60
|
-
// WebGPU has more restrictive topology support than WebGL
|
|
61
|
-
switch (this.props.topology) {
|
|
62
|
-
case 'triangle-fan-webgl':
|
|
63
|
-
case 'line-loop-webgl':
|
|
64
|
-
log.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
}
|
|
68
60
|
}
|
|
69
61
|
destroy() {
|
|
70
62
|
if (this.handle) {
|
|
@@ -93,7 +85,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
93
85
|
.map(binding => `"${binding.name}"`)
|
|
94
86
|
.join(', ');
|
|
95
87
|
if (!options?.disableWarnings) {
|
|
96
|
-
log.warn(`
|
|
88
|
+
log.warn(`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
|
|
97
89
|
}
|
|
98
90
|
continue; // eslint-disable-line no-continue
|
|
99
91
|
}
|
|
@@ -148,15 +140,17 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
148
140
|
// Note: async textures set as uniforms might still be loading.
|
|
149
141
|
// Now that all uniforms have been updated, check if any texture
|
|
150
142
|
// in the uniforms is not yet initialized, then we don't draw
|
|
151
|
-
if (!this._areTexturesRenderable()
|
|
143
|
+
if (!this._areTexturesRenderable()) {
|
|
152
144
|
log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
145
|
+
// Note: false means that the app needs to redraw the pipeline again.
|
|
153
146
|
return false;
|
|
154
147
|
}
|
|
155
148
|
// (isInstanced && instanceCount === 0)
|
|
156
|
-
if (vertexCount === 0) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
149
|
+
// if (vertexCount === 0) {
|
|
150
|
+
// log.info(2, `RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)();
|
|
151
|
+
// Note: false means that the app needs to redraw the pipeline again.
|
|
152
|
+
// return true;
|
|
153
|
+
// }
|
|
160
154
|
this.device.gl.useProgram(this.handle);
|
|
161
155
|
// Note: Rebinds constant attributes before each draw call
|
|
162
156
|
vertexArray.bindBeforeRender(renderPass);
|
|
@@ -289,10 +283,16 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
289
283
|
*/
|
|
290
284
|
_areTexturesRenderable() {
|
|
291
285
|
let texturesRenderable = true;
|
|
286
|
+
for (const bindingInfo of this.shaderLayout.bindings) {
|
|
287
|
+
if (!this.bindings[bindingInfo.name] &&
|
|
288
|
+
!this.bindings[bindingInfo.name.replace(/Uniforms$/, '')]) {
|
|
289
|
+
log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
|
|
290
|
+
texturesRenderable = false;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
292
293
|
for (const [, texture] of Object.entries(this.bindings)) {
|
|
293
294
|
if (texture instanceof WEBGLTexture) {
|
|
294
295
|
texture.update();
|
|
295
|
-
texturesRenderable = texturesRenderable && texture.loaded;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
return texturesRenderable;
|
|
@@ -359,7 +359,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
359
359
|
throw new Error('No texture');
|
|
360
360
|
}
|
|
361
361
|
gl.activeTexture(33984 + textureUnit);
|
|
362
|
-
gl.bindTexture(texture.
|
|
362
|
+
gl.bindTexture(texture.glTarget, texture.handle);
|
|
363
363
|
// gl.bindSampler(textureUnit, sampler.handle);
|
|
364
364
|
textureUnit += 1;
|
|
365
365
|
break;
|
|
@@ -386,3 +386,28 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Merges an provided shader layout into a base shader layout
|
|
391
|
+
* In WebGL, this allows the auto generated shader layout to be overridden by the application
|
|
392
|
+
* Typically to change the format of the vertex attributes (from float32x4 to uint8x4 etc).
|
|
393
|
+
* @todo Drop this? Aren't all use cases covered by mergeBufferLayout()?
|
|
394
|
+
*/
|
|
395
|
+
function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
396
|
+
// Deep clone the base layout
|
|
397
|
+
const mergedLayout = {
|
|
398
|
+
...baseLayout,
|
|
399
|
+
attributes: baseLayout.attributes.map(attribute => ({ ...attribute }))
|
|
400
|
+
};
|
|
401
|
+
// Merge the attributes
|
|
402
|
+
for (const attribute of overrideLayout?.attributes || []) {
|
|
403
|
+
const baseAttribute = mergedLayout.attributes.find(attr => attr.name === attribute.name);
|
|
404
|
+
if (!baseAttribute) {
|
|
405
|
+
log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
baseAttribute.type = attribute.type || baseAttribute.type;
|
|
409
|
+
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return mergedLayout;
|
|
413
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-shader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAM,MAAM,eAAe,CAAC;AAGxE,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C;;GAEG;AACH,qBAAa,WAAY,SAAQ,MAAM;IACrC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW;IAgB1C,OAAO,IAAI,IAAI;IAST,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAK/D,sBAAsB;
|
|
1
|
+
{"version":3,"file":"webgl-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-shader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAM,MAAM,eAAe,CAAC;AAGxE,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C;;GAEG;AACH,qBAAa,WAAY,SAAQ,MAAM;IACrC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW;IAgB1C,OAAO,IAAI,IAAI;IAST,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAK/D,sBAAsB,IAAI,SAAS,eAAe,EAAE;IAKpD,mBAAmB,IAAI,MAAM,GAAG,IAAI;IAQ7C,kDAAkD;cAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCvD,6DAA6D;cAC7C,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5D;;;;OAIG;IACH,SAAS,CAAC,qBAAqB;CAKhC"}
|
|
@@ -39,17 +39,17 @@ export class WEBGLShader extends Shader {
|
|
|
39
39
|
}
|
|
40
40
|
getCompilationInfoSync() {
|
|
41
41
|
const log = this.device.gl.getShaderInfoLog(this.handle);
|
|
42
|
-
return parseShaderCompilerLog(log);
|
|
42
|
+
return log ? parseShaderCompilerLog(log) : [];
|
|
43
43
|
}
|
|
44
44
|
getTranslatedSource() {
|
|
45
45
|
const extensions = this.device.getExtension('WEBGL_debug_shaders');
|
|
46
46
|
const ext = extensions.WEBGL_debug_shaders;
|
|
47
|
-
return ext?.getTranslatedShaderSource(this.handle);
|
|
47
|
+
return ext?.getTranslatedShaderSource(this.handle) || null;
|
|
48
48
|
}
|
|
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);
|
|
@@ -5,7 +5,7 @@ import { WEBGLTexture } from "./webgl-texture.js";
|
|
|
5
5
|
export declare class WEBGLTextureView extends TextureView {
|
|
6
6
|
readonly device: WebGLDevice;
|
|
7
7
|
readonly gl: WebGL2RenderingContext;
|
|
8
|
-
readonly handle:
|
|
8
|
+
readonly handle: null;
|
|
9
9
|
readonly texture: WEBGLTexture;
|
|
10
10
|
constructor(device: Device, props: TextureViewProps & {
|
|
11
11
|
texture: WEBGLTexture;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture-view.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture-view.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAC,WAAW,EAAU,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAE7C,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"webgl-texture-view.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture-view.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAC,WAAW,EAAU,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAE7C,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;gBAEnB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG;QAAC,OAAO,EAAE,YAAY,CAAA;KAAC;CAQ9E"}
|
|
@@ -6,7 +6,7 @@ import { TextureView, Texture } from '@luma.gl/core';
|
|
|
6
6
|
export class WEBGLTextureView extends TextureView {
|
|
7
7
|
device;
|
|
8
8
|
gl;
|
|
9
|
-
handle;
|
|
9
|
+
handle; // Does not have a WebGL representation
|
|
10
10
|
texture;
|
|
11
11
|
constructor(device, props) {
|
|
12
12
|
super(device, { ...Texture.defaultProps, ...props });
|