@luma.gl/webgl 9.1.0-alpha.12 → 9.1.0-alpha.14
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-framebuffer.d.ts +31 -32
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +57 -61
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +1 -0
- package/dist/adapter/webgl-device.d.ts +2 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +1 -2
- package/dist/dist.dev.js +29 -60
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +24 -54
- package/dist/index.cjs.map +2 -2
- package/package.json +3 -3
- package/src/adapter/resources/webgl-framebuffer.ts +68 -73
- package/src/adapter/resources/webgl-texture.ts +2 -0
- package/src/adapter/webgl-device.ts +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.1.0-alpha.
|
|
3
|
+
"version": "9.1.0-alpha.14",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@luma.gl/core": "9.1.0-alpha.10"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.1.0-alpha.
|
|
46
|
+
"@luma.gl/constants": "9.1.0-alpha.14",
|
|
47
47
|
"@math.gl/types": "4.1.0-alpha.3",
|
|
48
48
|
"@probe.gl/env": "^4.0.8"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "e6e014efa323dbcd7d3774e982e442b1bf2c93be"
|
|
51
51
|
}
|
|
@@ -39,39 +39,7 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
39
39
|
// Auto create textures for attachments if needed
|
|
40
40
|
this.autoCreateAttachmentTextures();
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
// @ts-expect-error native bindFramebuffer is overridden by our state tracker
|
|
44
|
-
const prevHandle: WebGLFramebuffer | null = this.gl.bindFramebuffer(
|
|
45
|
-
GL.FRAMEBUFFER,
|
|
46
|
-
this.handle
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
// Walk the attachments
|
|
50
|
-
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
51
|
-
const attachment = this.colorAttachments[i];
|
|
52
|
-
const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;
|
|
53
|
-
if (attachment) {
|
|
54
|
-
this._attachTexture(attachmentPoint, attachment);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (this.depthStencilAttachment) {
|
|
59
|
-
this._attachTexture(
|
|
60
|
-
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format),
|
|
61
|
-
this.depthStencilAttachment
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Check the status */
|
|
66
|
-
// @ts-expect-error
|
|
67
|
-
if (props.check !== false) {
|
|
68
|
-
const status = this.gl.checkFramebufferStatus(GL.FRAMEBUFFER) as GL;
|
|
69
|
-
if (status !== GL.FRAMEBUFFER_COMPLETE) {
|
|
70
|
-
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle);
|
|
42
|
+
this.updateAttachments();
|
|
75
43
|
}
|
|
76
44
|
}
|
|
77
45
|
|
|
@@ -84,6 +52,42 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
84
52
|
}
|
|
85
53
|
}
|
|
86
54
|
|
|
55
|
+
protected updateAttachments(): void {
|
|
56
|
+
/** Attach from a map of attachments */
|
|
57
|
+
// @ts-expect-error native bindFramebuffer is overridden by our state tracker
|
|
58
|
+
const prevHandle: WebGLFramebuffer | null = this.gl.bindFramebuffer(
|
|
59
|
+
GL.FRAMEBUFFER,
|
|
60
|
+
this.handle
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// Walk the attachments
|
|
64
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
65
|
+
const attachment = this.colorAttachments[i];
|
|
66
|
+
if (attachment) {
|
|
67
|
+
const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;
|
|
68
|
+
this._attachTextureView(attachmentPoint, attachment);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (this.depthStencilAttachment) {
|
|
73
|
+
const attachmentPoint = getDepthStencilAttachmentWebGL(
|
|
74
|
+
this.depthStencilAttachment.props.format
|
|
75
|
+
);
|
|
76
|
+
this._attachTextureView(attachmentPoint, this.depthStencilAttachment);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Check the status */
|
|
80
|
+
// @ts-expect-error
|
|
81
|
+
if (this.props.check !== false) {
|
|
82
|
+
const status = this.gl.checkFramebufferStatus(GL.FRAMEBUFFER) as GL;
|
|
83
|
+
if (status !== GL.FRAMEBUFFER_COMPLETE) {
|
|
84
|
+
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle);
|
|
89
|
+
}
|
|
90
|
+
|
|
87
91
|
// PRIVATE
|
|
88
92
|
|
|
89
93
|
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
@@ -98,46 +102,6 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
/**
|
|
102
|
-
* Attachment resize is expected to be a noop if size is same
|
|
103
|
-
*
|
|
104
|
-
protected override resizeAttachments(width: number, height: number): this {
|
|
105
|
-
// for default framebuffer, just update the stored size
|
|
106
|
-
if (this.handle === null) {
|
|
107
|
-
// assert(width === undefined && height === undefined);
|
|
108
|
-
this.width = this.gl.drawingBufferWidth;
|
|
109
|
-
this.height = this.gl.drawingBufferHeight;
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (width === undefined) {
|
|
114
|
-
width = this.gl.drawingBufferWidth;
|
|
115
|
-
}
|
|
116
|
-
if (height === undefined) {
|
|
117
|
-
height = this.gl.drawingBufferHeight;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// TODO Not clear that this is better than default destroy/create implementation
|
|
121
|
-
|
|
122
|
-
for (const colorAttachment of this.colorAttachments) {
|
|
123
|
-
colorAttachment.texture.clone({width, height});
|
|
124
|
-
}
|
|
125
|
-
if (this.depthStencilAttachment) {
|
|
126
|
-
this.depthStencilAttachment.texture.resize({width, height});
|
|
127
|
-
}
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
/** Attach one attachment */
|
|
133
|
-
protected _attachTexture(attachmentPoint: GL, textureView: WEBGLTextureView): void {
|
|
134
|
-
// if (attachment instanceof WEBGLRenderbuffer) {
|
|
135
|
-
// this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
136
|
-
// return attachment;
|
|
137
|
-
// }
|
|
138
|
-
this._attachTextureView(attachmentPoint, textureView);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
105
|
/**
|
|
142
106
|
* @param attachment
|
|
143
107
|
* @param texture
|
|
@@ -210,3 +174,34 @@ function _getFrameBufferStatus(status: GL) {
|
|
|
210
174
|
return `${status}`;
|
|
211
175
|
}
|
|
212
176
|
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Attachment resize is expected to be a noop if size is same
|
|
180
|
+
*
|
|
181
|
+
protected override resizeAttachments(width: number, height: number): this {
|
|
182
|
+
// for default framebuffer, just update the stored size
|
|
183
|
+
if (this.handle === null) {
|
|
184
|
+
// assert(width === undefined && height === undefined);
|
|
185
|
+
this.width = this.gl.drawingBufferWidth;
|
|
186
|
+
this.height = this.gl.drawingBufferHeight;
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (width === undefined) {
|
|
191
|
+
width = this.gl.drawingBufferWidth;
|
|
192
|
+
}
|
|
193
|
+
if (height === undefined) {
|
|
194
|
+
height = this.gl.drawingBufferHeight;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// TODO Not clear that this is better than default destroy/create implementation
|
|
198
|
+
|
|
199
|
+
for (const colorAttachment of this.colorAttachments) {
|
|
200
|
+
colorAttachment.texture.clone({width, height});
|
|
201
|
+
}
|
|
202
|
+
if (this.depthStencilAttachment) {
|
|
203
|
+
this.depthStencilAttachment.texture.resize({width, height});
|
|
204
|
+
}
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
*/
|
|
@@ -143,6 +143,8 @@ export class WEBGLTexture extends Texture {
|
|
|
143
143
|
} | null = null;
|
|
144
144
|
|
|
145
145
|
constructor(device: Device, props: TextureProps) {
|
|
146
|
+
props = Texture._fixProps(props);
|
|
147
|
+
|
|
146
148
|
// Note: Clear out `props.data` so that we don't hold a reference to any big memory chunks
|
|
147
149
|
super(device, {...Texture.defaultProps, ...props, data: undefined!});
|
|
148
150
|
|
|
@@ -216,8 +216,7 @@ export class WebGLDevice extends Device {
|
|
|
216
216
|
return new WEBGLBuffer(this, newProps);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
|
|
220
|
-
_createTexture(props: TextureProps): Texture {
|
|
219
|
+
createTexture(props: TextureProps): WEBGLTexture {
|
|
221
220
|
return new WEBGLTexture(this, props);
|
|
222
221
|
}
|
|
223
222
|
|