@luma.gl/webgl 9.0.11 → 9.1.0-alpha.1
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/LICENSE +34 -0
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +12 -1
- 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 +31 -32
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -1
- 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 +368 -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 +1 -3
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +45 -20
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +2 -2
- 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 +58 -172
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +402 -510
- 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-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 +4 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +6 -5
- 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 +2 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +11 -9
- 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.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- 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/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -6
- package/dist/dist.dev.js +870 -1261
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +859 -1137
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- 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/package.json +6 -5
- package/src/adapter/converters/device-parameters.ts +13 -1
- package/src/adapter/converters/texture-formats.ts +45 -42
- package/src/adapter/device-helpers/webgl-device-features.ts +1 -1
- package/src/adapter/device-helpers/webgl-device-limits.ts +1 -1
- package/src/adapter/helpers/webgl-texture-utils.ts +481 -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 +4 -5
- package/src/adapter/resources/webgl-render-pipeline.ts +48 -23
- package/src/adapter/resources/webgl-shader.ts +3 -3
- package/src/adapter/resources/webgl-texture-view.ts +1 -3
- package/src/adapter/resources/webgl-texture.ts +432 -784
- package/src/adapter/resources/webgl-vertex-array.ts +8 -7
- package/src/adapter/webgl-canvas-context.ts +4 -1
- package/src/adapter/webgl-device.ts +10 -18
- package/src/classic/accessor.ts +31 -11
- package/src/classic/clear.ts +3 -6
- package/src/classic/copy-and-blit.ts +19 -19
- package/src/classic/format-utils.ts +0 -3
- package/src/classic/typed-array-utils.ts +1 -1
- package/src/context/debug/spector.ts +2 -1
- package/src/context/debug/webgl-developer-tools.ts +3 -7
- package/src/context/parameters/webgl-parameter-tables.ts +3 -3
- package/src/context/state-tracker/track-context-state.ts +5 -6
- package/src/index.ts +0 -6
- 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/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/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.glTarget, 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;AAcpD,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;IAYvD,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"}
|
|
@@ -41,9 +41,7 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
41
41
|
setParameters(parameters = {}) {
|
|
42
42
|
const glParameters = { ...this.glParameters };
|
|
43
43
|
// Framebuffers are specified using parameters in WebGL
|
|
44
|
-
|
|
45
|
-
glParameters.framebuffer = this.props.framebuffer;
|
|
46
|
-
}
|
|
44
|
+
glParameters.framebuffer = this.props.framebuffer || null;
|
|
47
45
|
if (this.props.depthReadOnly) {
|
|
48
46
|
glParameters.depthMask = !this.props.depthReadOnly;
|
|
49
47
|
}
|
|
@@ -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;IAyD3F;;;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) {
|
|
@@ -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,12 +39,12 @@ 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 */
|
|
@@ -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 });
|
|
@@ -1,211 +1,97 @@
|
|
|
1
|
-
import { Device, TextureProps, TextureViewProps, Sampler, SamplerProps,
|
|
1
|
+
import type { Device, TextureProps, TextureViewProps, Sampler, SamplerProps, TextureCubeFace, Texture1DData, Texture2DData, Texture3DData, TextureCubeData, TextureArrayData, TextureCubeArrayData } from '@luma.gl/core';
|
|
2
2
|
import { Texture } from '@luma.gl/core';
|
|
3
|
-
import { GL, GLSamplerParameters } from '@luma.gl/constants';
|
|
3
|
+
import { GL, GLPixelType, GLSamplerParameters, GLTexelDataFormat, GLTextureTarget } from '@luma.gl/constants';
|
|
4
4
|
import { WebGLDevice } from "../webgl-device.js";
|
|
5
5
|
import { WEBGLSampler } from "./webgl-sampler.js";
|
|
6
6
|
import { WEBGLTextureView } from "./webgl-texture-view.js";
|
|
7
|
-
export type WEBGLTextureProps = TextureProps & {
|
|
8
|
-
/** @deprecated use props.sampler */
|
|
9
|
-
parameters?: Record<number, number>;
|
|
10
|
-
/** @deprecated use props.data */
|
|
11
|
-
pixels?: any;
|
|
12
|
-
/** @deprecated use props.format */
|
|
13
|
-
dataFormat?: number | null;
|
|
14
|
-
/** @deprecated rarely supported */
|
|
15
|
-
border?: number;
|
|
16
|
-
/** @deprecated WebGL only. */
|
|
17
|
-
pixelStore?: object;
|
|
18
|
-
/** @deprecated WebGL only. */
|
|
19
|
-
textureUnit?: number;
|
|
20
|
-
/** @deprecated WebGL only. Use dimension. */
|
|
21
|
-
target?: number;
|
|
22
|
-
};
|
|
23
|
-
export declare const DEFAULT_WEBGL_TEXTURE_PROPS: {
|
|
24
|
-
parameters: {};
|
|
25
|
-
pixelStore: {};
|
|
26
|
-
pixels: any;
|
|
27
|
-
border: number;
|
|
28
|
-
dataFormat: any;
|
|
29
|
-
textureUnit: any;
|
|
30
|
-
target: any;
|
|
31
|
-
};
|
|
32
|
-
export type TextureSourceData = TypedArray | ImageData | HTMLImageElement | HTMLCanvasElement | ImageBitmap | HTMLVideoElement;
|
|
33
|
-
type SetImageDataOptions = {
|
|
34
|
-
target?: number;
|
|
35
|
-
level?: number;
|
|
36
|
-
dataFormat?: any;
|
|
37
|
-
width?: number;
|
|
38
|
-
height?: number;
|
|
39
|
-
depth?: number;
|
|
40
|
-
glFormat?: GL;
|
|
41
|
-
type?: any;
|
|
42
|
-
offset?: number;
|
|
43
|
-
data: any;
|
|
44
|
-
compressed?: boolean;
|
|
45
|
-
parameters?: Record<GL, any>;
|
|
46
|
-
/** @deprecated */
|
|
47
|
-
pixels?: any;
|
|
48
|
-
};
|
|
49
7
|
/**
|
|
50
|
-
*
|
|
51
|
-
* null - create empty texture of specified format
|
|
52
|
-
* Typed array - init from image data in typed array
|
|
53
|
-
* Buffer|WebGLBuffer - (WEBGL2) init from image data in WebGLBuffer
|
|
54
|
-
* HTMLImageElement|Image - Inits with content of image. Auto width/height
|
|
55
|
-
* HTMLCanvasElement - Inits with contents of canvas. Auto width/height
|
|
56
|
-
* HTMLVideoElement - Creates video texture. Auto width/height
|
|
57
|
-
*
|
|
58
|
-
* @param x - xOffset from where texture to be updated
|
|
59
|
-
* @param y - yOffset from where texture to be updated
|
|
60
|
-
* @param width - width of the sub image to be updated
|
|
61
|
-
* @param height - height of the sub image to be updated
|
|
62
|
-
* @param level - mip level to be updated
|
|
63
|
-
* @param {GLenum} format - internal format of image data.
|
|
64
|
-
* @param {GLenum} type
|
|
65
|
-
* - format of array (autodetect from type) or
|
|
66
|
-
* - (WEBGL2) format of buffer or ArrayBufferView
|
|
67
|
-
* @param {GLenum} dataFormat - format of image data.
|
|
68
|
-
* @param {Number} offset - (WEBGL2) offset from start of buffer
|
|
69
|
-
* @parameters - temporary settings to be applied, can be used to supply pixel store settings.
|
|
8
|
+
* WebGL... the texture API from hell... hopefully made simpler
|
|
70
9
|
*/
|
|
71
|
-
|
|
72
|
-
target?: number;
|
|
73
|
-
level?: number;
|
|
74
|
-
dataFormat?: any;
|
|
75
|
-
width?: number;
|
|
76
|
-
height?: number;
|
|
77
|
-
depth?: number;
|
|
78
|
-
glFormat?: any;
|
|
79
|
-
type?: any;
|
|
80
|
-
offset?: number;
|
|
81
|
-
data: any;
|
|
82
|
-
parameters?: Record<GL, any>;
|
|
83
|
-
compressed?: boolean;
|
|
84
|
-
x?: number;
|
|
85
|
-
y?: number;
|
|
86
|
-
/** @deprecated */
|
|
87
|
-
pixels?: any;
|
|
88
|
-
};
|
|
89
|
-
type SetImageData3DOptions = {
|
|
90
|
-
level?: number;
|
|
91
|
-
dataFormat?: any;
|
|
92
|
-
width?: number;
|
|
93
|
-
height?: number;
|
|
94
|
-
depth?: number;
|
|
95
|
-
format?: any;
|
|
96
|
-
type?: any;
|
|
97
|
-
offset?: number;
|
|
98
|
-
data: any;
|
|
99
|
-
parameters?: Record<GL, any>;
|
|
100
|
-
};
|
|
101
|
-
export declare class WEBGLTexture extends Texture<WEBGLTextureProps> {
|
|
102
|
-
static FACES: number[];
|
|
10
|
+
export declare class WEBGLTexture extends Texture {
|
|
103
11
|
readonly MAX_ATTRIBUTES: number;
|
|
104
12
|
readonly device: WebGLDevice;
|
|
105
13
|
readonly gl: WebGL2RenderingContext;
|
|
106
|
-
|
|
14
|
+
handle: WebGLTexture;
|
|
107
15
|
sampler: WEBGLSampler;
|
|
108
16
|
view: WEBGLTextureView;
|
|
109
|
-
glFormat: GL;
|
|
110
|
-
type: GL;
|
|
111
|
-
dataFormat: GL;
|
|
112
17
|
mipmaps: boolean;
|
|
113
18
|
/**
|
|
114
19
|
* @note `target` cannot be modified by bind:
|
|
115
20
|
* textures are special because when you first bind them to a target,
|
|
116
|
-
*
|
|
117
|
-
* GL_TEXTURE_2D, you are saying that this texture is a 2D texture.
|
|
21
|
+
* When you first bind a texture as a GL_TEXTURE_2D, you are saying that this texture is a 2D texture.
|
|
118
22
|
* And it will always be a 2D texture; this state cannot be changed ever.
|
|
119
23
|
* A texture that was first bound as a GL_TEXTURE_2D, must always be bound as a GL_TEXTURE_2D;
|
|
120
24
|
* attempting to bind it as GL_TEXTURE_3D will give rise to a run-time error
|
|
121
|
-
* */
|
|
122
|
-
target: GL;
|
|
123
|
-
textureUnit: number;
|
|
124
|
-
/**
|
|
125
|
-
* Program.draw() checks the loaded flag of all textures to avoid
|
|
126
|
-
* Textures that are still loading from promises
|
|
127
|
-
* Set to true as soon as texture has been initialized with valid data
|
|
128
25
|
*/
|
|
129
|
-
|
|
26
|
+
glTarget: GLTextureTarget;
|
|
27
|
+
/** The WebGL format - essentially channel structure */
|
|
28
|
+
glFormat: GLTexelDataFormat;
|
|
29
|
+
/** The WebGL data format - the type of each channel */
|
|
30
|
+
glType: GLPixelType;
|
|
31
|
+
/** The WebGL constant corresponding to the WebGPU style constant in format */
|
|
32
|
+
glInternalFormat: GL;
|
|
33
|
+
/** Whether the internal format is compressed */
|
|
34
|
+
compressed: boolean;
|
|
35
|
+
/** Texture binding slot */
|
|
36
|
+
textureUnit: number;
|
|
37
|
+
/** For automatically updating video */
|
|
130
38
|
_video: {
|
|
131
39
|
video: HTMLVideoElement;
|
|
132
40
|
parameters: any;
|
|
133
41
|
lastTime: number;
|
|
134
|
-
};
|
|
135
|
-
constructor(device: Device, props:
|
|
42
|
+
} | null;
|
|
43
|
+
constructor(device: Device, props: TextureProps);
|
|
44
|
+
/**
|
|
45
|
+
* Initialize texture with supplied props
|
|
46
|
+
*/
|
|
47
|
+
initialize(props?: TextureProps): void;
|
|
136
48
|
destroy(): void;
|
|
137
49
|
toString(): string;
|
|
138
50
|
createView(props: TextureViewProps): WEBGLTextureView;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
51
|
+
setSampler(sampler?: Sampler | SamplerProps): void;
|
|
52
|
+
/** Update external texture (video frame or canvas) */
|
|
53
|
+
update(): void;
|
|
54
|
+
generateMipmap(params?: {}): void;
|
|
55
|
+
setTexture1DData(data: Texture1DData): void;
|
|
56
|
+
/** Set a simple texture */
|
|
57
|
+
setTexture2DData(lodData: Texture2DData, depth?: number, glTarget?: GLTextureTarget): void;
|
|
142
58
|
/**
|
|
143
|
-
*
|
|
144
|
-
* @
|
|
59
|
+
* Sets a 3D texture
|
|
60
|
+
* @param data
|
|
145
61
|
*/
|
|
146
|
-
|
|
147
|
-
height: number;
|
|
148
|
-
width: number;
|
|
149
|
-
mipmaps?: boolean;
|
|
150
|
-
}): this;
|
|
151
|
-
/** Update external texture (video frame) */
|
|
152
|
-
update(): void;
|
|
153
|
-
generateMipmap(params?: {}): this;
|
|
154
|
-
setImageData(options: SetImageDataOptions): this;
|
|
62
|
+
setTexture3DData(data: Texture3DData): void;
|
|
155
63
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
64
|
+
* Set a Texture Cube Data
|
|
65
|
+
* @todo - could support TextureCubeArray with depth
|
|
66
|
+
* @param data
|
|
67
|
+
* @param index
|
|
159
68
|
*/
|
|
160
|
-
|
|
69
|
+
setTextureCubeData(data: TextureCubeData, depth?: number): void;
|
|
161
70
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* (gl.copyTexImage2D wrapper)
|
|
165
|
-
*
|
|
166
|
-
* Note that binding a texture into a Framebuffer's color buffer and
|
|
167
|
-
* rendering can be faster.
|
|
71
|
+
* Sets an entire texture array
|
|
72
|
+
* @param data
|
|
168
73
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}): {
|
|
177
|
-
data: any;
|
|
178
|
-
dataType: string;
|
|
179
|
-
};
|
|
180
|
-
_deduceParameters(opts: WEBGLTextureProps): {
|
|
181
|
-
dataFormat: number;
|
|
182
|
-
type: number;
|
|
183
|
-
compressed: boolean;
|
|
184
|
-
width: number;
|
|
185
|
-
height: number;
|
|
186
|
-
format: import("@luma.gl/core").TextureFormat;
|
|
187
|
-
data: string | import("@luma.gl/core").TextureData | Promise<import("@luma.gl/core").TextureData> | import("modules/core/dist/adapter/resources/texture").CubeTextureData | HTMLVideoElement;
|
|
188
|
-
};
|
|
189
|
-
_deduceImageSize(data: any, width: any, height: any): {
|
|
190
|
-
width: number;
|
|
191
|
-
height: number;
|
|
192
|
-
};
|
|
193
|
-
setCubeMapImageData(options: {
|
|
194
|
-
width: any;
|
|
195
|
-
height: any;
|
|
196
|
-
pixels: any;
|
|
197
|
-
data: any;
|
|
198
|
-
format?: any;
|
|
199
|
-
type?: any;
|
|
200
|
-
}): Promise<void>;
|
|
74
|
+
setTextureArrayData(data: TextureArrayData): void;
|
|
75
|
+
/**
|
|
76
|
+
* Sets an entire texture cube array
|
|
77
|
+
* @param data
|
|
78
|
+
*/
|
|
79
|
+
setTextureCubeArrayData(data: TextureCubeArrayData): void;
|
|
80
|
+
setTextureCubeFaceData(lodData: Texture2DData, face: TextureCubeFace, depth?: number): void;
|
|
201
81
|
/** @todo update this method to accept LODs */
|
|
202
|
-
setImageDataForFace(options: any):
|
|
203
|
-
|
|
204
|
-
setImageData3D(options: SetImageData3DOptions): this;
|
|
82
|
+
setImageDataForFace(options: any): void;
|
|
83
|
+
_getImageDataMap(faceData: Record<string | GL, any>): Record<GL, any>;
|
|
205
84
|
/**
|
|
206
85
|
* Sets sampler parameters on texture
|
|
207
86
|
*/
|
|
208
87
|
_setSamplerParameters(parameters: GLSamplerParameters): void;
|
|
88
|
+
/**
|
|
89
|
+
* Copy a region of data from a CPU memory buffer into this texture.
|
|
90
|
+
* @todo - GLUnpackParameters parameters
|
|
91
|
+
*/
|
|
92
|
+
protected _setMipLevel(depth: number, level: number, textureData: Texture2DData, offset?: number): void;
|
|
93
|
+
getActiveUnit(): number;
|
|
94
|
+
bind(textureUnit?: number): number;
|
|
95
|
+
unbind(textureUnit?: number): number | undefined;
|
|
209
96
|
}
|
|
210
|
-
export {};
|
|
211
97
|
//# sourceMappingURL=webgl-texture.d.ts.map
|