@luma.gl/webgl 9.0.0-alpha.20 → 9.0.0-alpha.23
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 +1 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +10 -10
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts +27 -38
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +152 -114
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/attribute-utils.js +1 -1
- package/dist/adapter/helpers/attribute-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-info.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +1 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/uniforms.d.ts +7 -8
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
- package/dist/adapter/helpers/uniforms.js +4 -4
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts +0 -2
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +0 -20
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +14 -11
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +31 -21
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +2 -3
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -9
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +6 -6
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +2 -2
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +4 -3
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +9 -3
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +168 -25
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +5 -4
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +7 -3
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +18 -21
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +36 -86
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +18 -3
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +81 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +7 -8
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +3 -3
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +2 -2
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts +2 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +41 -21
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +35 -33
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +4 -5
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +2 -2
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +22 -15
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +29 -11
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/buffer.d.ts +3 -4
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js +4 -10
- package/dist/classic/buffer.js.map +1 -1
- package/dist/classic/typed-array-utils.d.ts +15 -17
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +1 -1
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -2
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +1 -1
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +1107 -676
- package/dist/index.cjs +1088 -901
- package/dist/index.d.ts +18 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/dist.min.js +22 -21
- package/package.json +7 -4
- package/src/adapter/converters/device-parameters.ts +47 -23
- package/src/adapter/converters/sampler-parameters.ts +1 -2
- package/src/adapter/converters/texture-formats.ts +242 -161
- package/src/adapter/helpers/attribute-utils.ts +1 -2
- package/src/adapter/helpers/get-shader-info.ts +3 -0
- package/src/adapter/helpers/get-shader-layout.ts +1 -1
- package/src/adapter/helpers/uniforms.ts +9 -10
- package/src/adapter/objects/constants-to-keys.ts +0 -25
- package/src/adapter/objects/webgl-renderbuffer.ts +35 -32
- package/src/adapter/objects/webgl-resource.ts +6 -10
- package/src/adapter/objects/webgl-vertex-array-object.ts +6 -6
- package/src/adapter/resources/webgl-buffer.ts +6 -7
- package/src/adapter/resources/webgl-command-buffer.ts +330 -23
- package/src/adapter/resources/webgl-command-encoder.ts +9 -4
- package/src/adapter/resources/webgl-external-texture.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +75 -123
- package/src/adapter/resources/webgl-render-pass.ts +148 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +12 -9
- package/src/adapter/resources/webgl-sampler.ts +3 -4
- package/src/adapter/resources/webgl-shader.ts +2 -2
- package/src/adapter/resources/webgl-texture.ts +64 -46
- package/src/adapter/webgl-canvas-context.ts +5 -5
- package/src/adapter/webgl-device.ts +47 -18
- package/src/classic/accessor.ts +1 -1
- package/src/classic/buffer.ts +7 -7
- package/src/classic/typed-array-utils.ts +15 -26
- package/src/context/context/create-browser-context.ts +2 -2
- package/src/context/parameters/unified-parameter-api.ts +2 -2
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +24 -22
- package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
- package/dist/adapter/converters/renderbuffer-formats.js +0 -181
- package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/types/webgl.d.ts +0 -145
- package/dist/types/webgl.d.ts.map +0 -1
- package/dist/types/webgl.js +0 -2
- package/dist/types/webgl.js.map +0 -1
- package/src/adapter/converters/renderbuffer-formats.ts +0 -92
- package/src/types/webgl.ts +0 -286
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Framebuffer,
|
|
2
|
+
import { Framebuffer, assert } from '@luma.gl/api';
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
export
|
|
4
|
+
import { WEBGLTexture } from "./webgl-texture.js";
|
|
5
|
+
import { WEBGLRenderbuffer } from "../objects/webgl-renderbuffer.js";
|
|
6
|
+
import { getDepthStencilAttachmentWebGL } from "../converters/texture-formats.js";
|
|
7
|
+
export class WEBGLFramebuffer extends Framebuffer {
|
|
8
8
|
get texture() {
|
|
9
9
|
return this.colorAttachments[0];
|
|
10
10
|
}
|
|
@@ -13,43 +13,37 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
13
13
|
_defineProperty(this, "device", void 0);
|
|
14
14
|
_defineProperty(this, "gl", void 0);
|
|
15
15
|
_defineProperty(this, "handle", void 0);
|
|
16
|
-
|
|
17
|
-
_defineProperty(this, "depthStencilAttachment", null);
|
|
18
|
-
_defineProperty(this, "_ownResources", []);
|
|
16
|
+
const isDefaultFramebuffer = props.handle === null;
|
|
19
17
|
this.device = device;
|
|
20
18
|
this.gl = device.gl;
|
|
21
|
-
this.handle = this.props.handle
|
|
22
|
-
if (
|
|
19
|
+
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
20
|
+
if (!isDefaultFramebuffer) {
|
|
23
21
|
device.setSpectorMetadata(this.handle, {
|
|
24
22
|
id: this.props.id,
|
|
25
23
|
props: this.props
|
|
26
24
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this._attachOne(attachmentPoint, attachment);
|
|
25
|
+
this.autoCreateAttachmentTextures();
|
|
26
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);
|
|
27
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
28
|
+
const attachment = this.colorAttachments[i];
|
|
29
|
+
const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;
|
|
30
|
+
if (attachment) {
|
|
31
|
+
this._attachOne(attachmentPoint, attachment);
|
|
32
|
+
}
|
|
36
33
|
}
|
|
34
|
+
if (this.depthStencilAttachment) {
|
|
35
|
+
this._attachOne(getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
36
|
+
}
|
|
37
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
37
38
|
}
|
|
38
|
-
if (this.props.depthStencilAttachment) {
|
|
39
|
-
this._attachOne(getWebGLDepthStencilAttachment(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
40
|
-
}
|
|
41
|
-
this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
42
39
|
if (props.check !== false) {
|
|
43
40
|
this._checkStatus();
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
destroy() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
resource.destroy();
|
|
50
|
-
}
|
|
44
|
+
super.destroy();
|
|
45
|
+
if (!this.destroyed && this.handle !== null) {
|
|
51
46
|
this.gl.deleteFramebuffer(this.handle);
|
|
52
|
-
this.destroyed = true;
|
|
53
47
|
}
|
|
54
48
|
}
|
|
55
49
|
_checkStatus() {
|
|
@@ -63,58 +57,15 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
63
57
|
throw new Error("Framebuffer ".concat(_getFrameBufferStatus(status)));
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
|
|
67
|
-
return this.
|
|
68
|
-
if (!colorAttachment) {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
if (colorAttachment instanceof WebGLTexture) {
|
|
72
|
-
return colorAttachment;
|
|
73
|
-
}
|
|
74
|
-
return this._createColorAttachment(colorAttachment, this.width, this.height);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
_createColorAttachment(format, width, height) {
|
|
78
|
-
const texture = this.device._createTexture({
|
|
79
|
-
id: "".concat(this.id, "-color"),
|
|
80
|
-
data: null,
|
|
81
|
-
format,
|
|
82
|
-
width,
|
|
83
|
-
height,
|
|
84
|
-
mipmaps: false,
|
|
85
|
-
sampler: {
|
|
86
|
-
minFilter: 'linear',
|
|
87
|
-
magFilter: 'linear',
|
|
88
|
-
addressModeU: 'clamp-to-edge',
|
|
89
|
-
addressModeV: 'clamp-to-edge'
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
this._ownResources.push(texture);
|
|
93
|
-
return texture;
|
|
94
|
-
}
|
|
95
|
-
_createDepthStencilAttachment() {
|
|
96
|
-
if (!this.props.depthStencilAttachment) {
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
if (this.props.depthStencilAttachment instanceof Renderbuffer) {
|
|
100
|
-
return this.props.depthStencilAttachment;
|
|
101
|
-
}
|
|
102
|
-
if (this.props.depthStencilAttachment instanceof Texture) {
|
|
103
|
-
return this.props.depthStencilAttachment;
|
|
104
|
-
}
|
|
105
|
-
const format = this.props.depthStencilAttachment;
|
|
106
|
-
const webglFormat = getWebGLTextureFormat(this.gl, format);
|
|
107
|
-
const texture = new Renderbuffer(this.device, {
|
|
60
|
+
createDepthStencilTexture(format) {
|
|
61
|
+
return new WEBGLRenderbuffer(this.device, {
|
|
108
62
|
id: "".concat(this.id, "-depth-stencil"),
|
|
109
|
-
format
|
|
63
|
+
format,
|
|
110
64
|
width: this.width,
|
|
111
65
|
height: this.height
|
|
112
66
|
});
|
|
113
|
-
this._ownResources.push(texture);
|
|
114
|
-
return texture;
|
|
115
67
|
}
|
|
116
|
-
|
|
117
|
-
var _this$depthStencilAtt;
|
|
68
|
+
resizeAttachments(width, height) {
|
|
118
69
|
if (this.handle === null) {
|
|
119
70
|
this.width = this.gl.drawingBufferWidth;
|
|
120
71
|
this.height = this.gl.drawingBufferHeight;
|
|
@@ -126,36 +77,35 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
126
77
|
if (height === undefined) {
|
|
127
78
|
height = this.gl.drawingBufferHeight;
|
|
128
79
|
}
|
|
129
|
-
if (width !== this.width && height !== this.height) {
|
|
130
|
-
log.log(2, "Resizing framebuffer ".concat(this.id, " to ").concat(width, "x").concat(height))();
|
|
131
|
-
}
|
|
132
80
|
for (const colorAttachment of this.colorAttachments) {
|
|
133
81
|
colorAttachment.resize({
|
|
134
82
|
width,
|
|
135
83
|
height
|
|
136
84
|
});
|
|
137
85
|
}
|
|
138
|
-
(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
86
|
+
if (this.depthStencilAttachment) {
|
|
87
|
+
this.depthStencilAttachment.resize({
|
|
88
|
+
width,
|
|
89
|
+
height
|
|
90
|
+
});
|
|
91
|
+
}
|
|
142
92
|
return this;
|
|
143
93
|
}
|
|
144
94
|
_attachOne(attachmentPoint, attachment) {
|
|
145
|
-
if (attachment instanceof
|
|
146
|
-
this.
|
|
95
|
+
if (attachment instanceof WEBGLRenderbuffer) {
|
|
96
|
+
this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
147
97
|
return attachment;
|
|
148
98
|
} else if (Array.isArray(attachment)) {
|
|
149
99
|
const [texture, layer = 0, level = 0] = attachment;
|
|
150
100
|
this._attachTexture(attachmentPoint, texture, layer, level);
|
|
151
101
|
return texture;
|
|
152
|
-
} else if (attachment instanceof
|
|
102
|
+
} else if (attachment instanceof WEBGLTexture) {
|
|
153
103
|
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
154
104
|
return attachment;
|
|
155
105
|
}
|
|
156
106
|
throw new Error('attach');
|
|
157
107
|
}
|
|
158
|
-
|
|
108
|
+
_attachWEBGLRenderbuffer(attachment, renderbuffer) {
|
|
159
109
|
this.gl.framebufferRenderbuffer(GL.FRAMEBUFFER, attachment, GL.RENDERBUFFER, renderbuffer.handle);
|
|
160
110
|
}
|
|
161
111
|
_attachTexture(attachment, texture, layer, level) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-framebuffer.js","names":["Framebuffer","Texture","log","assert","GL","WebGLTexture","Renderbuffer","getWebGLTextureFormat","getWebGLDepthStencilAttachment","WEBGLFramebuffer","texture","colorAttachments","constructor","device","props","_defineProperty","gl","handle","undefined","createFramebuffer","setSpectorMetadata","id","_createColorAttachments","depthStencilAttachment","_createDepthStencilAttachment","prevHandle","bindFramebuffer","FRAMEBUFFER","i","length","attachment","attachmentPoint","COLOR_ATTACHMENT0","_attachOne","format","check","_checkStatus","destroy","resource","_ownResources","deleteFramebuffer","destroyed","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","Error","concat","_getFrameBufferStatus","map","colorAttachment","_createColorAttachment","width","height","_createTexture","data","mipmaps","sampler","minFilter","magFilter","addressModeU","addressModeV","push","webglFormat","_resizeAttachments","_this$depthStencilAtt","drawingBufferWidth","drawingBufferHeight","resize","_attachRenderbuffer","Array","isArray","layer","level","_attachTexture","renderbuffer","framebufferRenderbuffer","RENDERBUFFER","gl2","bindTexture","target","TEXTURE_2D_ARRAY","TEXTURE_3D","assertWebGL2","framebufferTextureLayer","TEXTURE_CUBE_MAP","face","mapIndexToCubeMapFace","framebufferTexture2D","TEXTURE_2D","TEXTURE_CUBE_MAP_POSITIVE_X","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"],"sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture, log, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\nimport WebGLTexture from './webgl-texture';\nimport Renderbuffer from '../objects/webgl-renderbuffer';\nimport {getWebGLTextureFormat, getWebGLDepthStencilAttachment} from '../converters/texture-formats';\n\nexport type TextureAttachment = [Texture, number?, number?];\nexport type Attachment = WebGLTexture | Renderbuffer | TextureAttachment;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport default class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGLRenderingContext;\n handle: WebGLFramebuffer;\n\n get texture() { return this.colorAttachments[0]; }\n readonly colorAttachments: WebGLTexture[] = [];\n readonly depthStencilAttachment: WebGLTexture | null = null;\n protected _ownResources: (WebGLTexture | Renderbuffer)[] = [];\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n this.gl = device.gl;\n this.handle = this.props.handle !== undefined ? this.props.handle : this.gl.createFramebuffer();\n\n if (this.handle) { // default framebuffer is null...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n }\n\n this.colorAttachments = this._createColorAttachments();\n // @ts-expect-error\n this.depthStencilAttachment = this._createDepthStencilAttachment();\n\n /** Attach from a map of attachments */\n const prevHandle = this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n if (attachment) {\n this._attachOne(attachmentPoint, attachment);\n }\n }\n\n if (this.props.depthStencilAttachment) {\n this._attachOne(getWebGLDepthStencilAttachment(this.depthStencilAttachment.format), this.depthStencilAttachment);\n }\n\n // @ts-expect-error\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n\n // @ts-expect-error\n if (props.check !== false) {\n this._checkStatus();\n }\n }\n\n override destroy(): void {\n if (this.handle !== null) {\n for (const resource of this._ownResources) {\n resource.destroy();\n }\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n // PRIVATE\n\n /** Check the status */\n protected _checkStatus(): void {\n const {gl} = this;\n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);\n // @ts-expect-error\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n _createColorAttachments(): WebGLTexture[] {\n return this.props.colorAttachments.map(colorAttachment => {\n if (!colorAttachment) {\n return undefined;\n }\n if (colorAttachment instanceof WebGLTexture) {\n return colorAttachment;\n }\n // if (typeof colorAttachment === 'default') {\n // return this._createColorAttachment('rgba8unorm', this.width, this.height);\n // }\n // @ts-expect-error\n return this._createColorAttachment(colorAttachment, this.width, this.height);\n });\n }\n\n /** Create a color attachment */\n protected _createColorAttachment(format: ColorTextureFormat, width: number, height: number): WebGLTexture {\n const texture = this.device._createTexture({\n id: `${this.id}-color`,\n data: null, // reserves texture memory, but texels are undefined\n format,\n // type: GL.UNSIGNED_BYTE,\n width,\n height,\n // Note: Mipmapping can be disabled by texture resource when we resize the texture\n // to a non-power-of-two dimenstion (NPOT texture) under WebGL1. To have consistant\n // behavior we always disable mipmaps.\n mipmaps: false,\n // Set MIN and MAG filtering parameters so mipmaps are not used in sampling.\n // Use LINEAR so subpixel algos like fxaa work.\n // Set WRAP modes that support NPOT textures too.\n sampler: {\n minFilter: 'linear',\n magFilter: 'linear',\n addressModeU: 'clamp-to-edge',\n addressModeV: 'clamp-to-edge'\n },\n // parameters: {\n // [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,\n // [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,\n // [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,\n // [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE\n // }\n }) ;\n this._ownResources.push(texture);\n return texture;\n }\n\n /** Create a depth stencil attachment GL.DEPTH24_STENCIL8 */\n protected _createDepthStencilAttachment(): Renderbuffer | WebGLTexture {\n if (!this.props.depthStencilAttachment) {\n return undefined;\n }\n if (this.props.depthStencilAttachment instanceof Renderbuffer) {\n return this.props.depthStencilAttachment;\n }\n if (this.props.depthStencilAttachment instanceof Texture) {\n return this.props.depthStencilAttachment as unknown as WebGLTexture;\n }\n const format = this.props.depthStencilAttachment;\n const webglFormat = getWebGLTextureFormat(this.gl, format);\n\n const texture = new Renderbuffer(this.device, {\n id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?\n format: webglFormat,\n // dataFormat: GL.DEPTH_STENCIL,\n // type: GL.UNSIGNED_INT_24_8,\n width: this.width,\n height: this.height\n });\n this._ownResources.push(texture);\n return texture;\n }\n\n /** Attachment resize is expected to be a noop if size is same */\n protected _resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n if (width !== this.width && height !== this.height) {\n log.log(2, `Resizing framebuffer ${this.id} to ${width}x${height}`)();\n }\n\n for (const colorAttachment of this.colorAttachments) {\n colorAttachment.resize({width, height});\n }\n this.depthStencilAttachment?.resize({width, height});\n return this;\n }\n\n /** Attach one attachment */\n protected _attachOne(attachmentPoint: GL, attachment: Attachment): WebGLTexture | Renderbuffer {\n if (attachment instanceof Renderbuffer) {\n this._attachRenderbuffer(attachmentPoint, attachment);\n return attachment;\n } else if (Array.isArray(attachment)) {\n const [texture, layer = 0, level = 0] = attachment;\n this._attachTexture(attachmentPoint, texture as unknown as WebGLTexture, layer, level);\n return texture as unknown as WebGLTexture;\n } else if (attachment instanceof WebGLTexture) {\n this._attachTexture(attachmentPoint, attachment, 0, 0);\n return attachment;\n }\n throw new Error('attach');\n }\n\n protected _attachRenderbuffer(attachment: GL, renderbuffer: Renderbuffer): void {\n this.gl.framebufferRenderbuffer(\n GL.FRAMEBUFFER,\n attachment,\n GL.RENDERBUFFER,\n renderbuffer.handle\n );\n }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WebGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel (must be 0 in WebGL1)\n */\n protected _attachTexture(attachment: GL, texture: WebGLTexture, layer: number, level: number): void {\n const {gl, gl2} = this.device;\n gl.bindTexture(texture.target, texture.handle);\n\n switch (texture.target) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n this.device.assertWebGL2();\n gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n assert(false, 'Illegal texture type');\n }\n\n gl.bindTexture(texture.target, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n"],"mappings":";AAGA,SAAQA,WAAW,EAAEC,OAAO,EAAEC,GAAG,EAAEC,MAAM,QAAO,cAAc;AAC9D,OAAOC,EAAE,MAAM,oBAAoB;AAAC,OAE7BC,YAAY;AAAA,OACZC,YAAY;AAAA,SACXC,qBAAqB,EAAEC,8BAA8B;AAM7D,eAAe,MAAMC,gBAAgB,SAAST,WAAW,CAAC;EAKxD,IAAIU,OAAOA,CAAA,EAAG;IAAE,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAAC;EAAE;EAKjDC,WAAWA,CAACC,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E,CAACwF,iCAAiC;MACvC,OAAO,uBAAuB;IAChC,KAAKxF,EAAE,CAACyF,uBAAuB;MAC7B,OAAO,kCAAkC;IAE3C,KAAKzF,EAAE,CAAC0F,kCAAkC;MACxC,OAAO,kBAAkB;IAG3B;MACE,UAAAhD,MAAA,CAAUJ,MAAM;EAAG;AAEzB"}
|
|
1
|
+
{"version":3,"file":"webgl-framebuffer.js","names":["Framebuffer","assert","GL","WEBGLTexture","WEBGLRenderbuffer","getDepthStencilAttachmentWebGL","WEBGLFramebuffer","texture","colorAttachments","constructor","device","props","_defineProperty","isDefaultFramebuffer","handle","gl","createFramebuffer","setSpectorMetadata","id","autoCreateAttachmentTextures","bindFramebuffer","FRAMEBUFFER","i","length","attachment","attachmentPoint","COLOR_ATTACHMENT0","_attachOne","depthStencilAttachment","format","check","_checkStatus","destroy","destroyed","deleteFramebuffer","prevHandle","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","Error","concat","_getFrameBufferStatus","createDepthStencilTexture","width","height","resizeAttachments","drawingBufferWidth","drawingBufferHeight","undefined","colorAttachment","resize","_attachWEBGLRenderbuffer","Array","isArray","layer","level","_attachTexture","renderbuffer","framebufferRenderbuffer","RENDERBUFFER","gl2","bindTexture","target","TEXTURE_2D_ARRAY","TEXTURE_3D","assertWebGL2","framebufferTextureLayer","TEXTURE_CUBE_MAP","face","mapIndexToCubeMapFace","framebufferTexture2D","TEXTURE_2D","TEXTURE_CUBE_MAP_POSITIVE_X","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"],"sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {FramebufferProps, TextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';\nimport {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';\n\nexport type TextureAttachment = [Texture, number?, number?];\nexport type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGLRenderingContext;\n handle: WebGLFramebuffer;\n\n get texture() {\n return this.colorAttachments[0];\n }\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n\n // WebGL default framebuffer handle is null\n const isDefaultFramebuffer = props.handle === null;\n\n this.device = device;\n this.gl = device.gl;\n this.handle =\n this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();\n\n if (!isDefaultFramebuffer) {\n // default framebuffer handle is null, so we can't set spector metadata...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n\n /** Attach from a map of attachments */\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n if (attachment) {\n this._attachOne(attachmentPoint, attachment as WEBGLTexture);\n }\n }\n\n if (this.depthStencilAttachment) {\n this._attachOne(\n getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),\n this.depthStencilAttachment as WEBGLTexture\n );\n }\n\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);\n }\n\n // @ts-expect-error\n if (props.check !== false) {\n this._checkStatus();\n }\n }\n\n /** destroys any auto created resources etc. */\n override destroy(): void {\n super.destroy(); // destroys owned resources etc.\n if (!this.destroyed && this.handle !== null) {\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n }\n }\n\n // PRIVATE\n\n /** Check the status */\n protected _checkStatus(): void {\n const {gl} = this;\n // TODO - should we really rely on this trick? \n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle) as unknown as WebGLFramebuffer;\n const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */\n protected override createDepthStencilTexture(format: TextureFormat): Texture {\n return new WEBGLRenderbuffer(this.device, {\n id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?\n format,\n // dataFormat: GL.DEPTH_STENCIL,\n // type: GL.UNSIGNED_INT_24_8,\n width: this.width,\n height: this.height\n }) as unknown as WEBGLTexture;\n }\n\n /** \n * Attachment resize is expected to be a noop if size is same \n */\n protected override resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n // TODO Not clear that this is better than default destroy/create implementation\n\n for (const colorAttachment of this.colorAttachments) {\n (colorAttachment as WEBGLTexture).resize({width, height});\n }\n if (this.depthStencilAttachment) {\n (this.depthStencilAttachment as WEBGLTexture).resize({width, height});\n }\n return this;\n }\n\n /** Attach one attachment */\n protected _attachOne(\n attachmentPoint: GL,\n attachment: Attachment\n ): WEBGLTexture | WEBGLRenderbuffer {\n if (attachment instanceof WEBGLRenderbuffer) {\n this._attachWEBGLRenderbuffer(attachmentPoint, attachment);\n return attachment;\n } else if (Array.isArray(attachment)) {\n const [texture, layer = 0, level = 0] = attachment;\n this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);\n return texture as unknown as WEBGLTexture;\n } else if (attachment instanceof WEBGLTexture) {\n this._attachTexture(attachmentPoint, attachment, 0, 0);\n return attachment;\n }\n throw new Error('attach');\n }\n\n protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {\n this.gl.framebufferRenderbuffer(\n GL.FRAMEBUFFER,\n attachment,\n GL.RENDERBUFFER,\n renderbuffer.handle\n );\n }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel (must be 0 in WebGL1)\n */\n protected _attachTexture(\n attachment: GL,\n texture: WEBGLTexture,\n layer: number,\n level: number\n ): void {\n const {gl, gl2} = this.device;\n gl.bindTexture(texture.target, texture.handle);\n\n switch (texture.target) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n this.device.assertWebGL2();\n gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n assert(false, 'Illegal texture type');\n }\n\n gl.bindTexture(texture.target, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n"],"mappings":";AAGA,SAAQA,WAAW,EAAWC,MAAM,QAAO,cAAc;AACzD,OAAOC,EAAE,MAAM,oBAAoB;AAAC,SAE5BC,YAAY;AAAA,SACZC,iBAAiB;AAAA,SACjBC,8BAA8B;AAMtC,OAAO,MAAMC,gBAAgB,SAASN,WAAW,CAAC;EAKhD,IAAIO,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAAC;EACjC;EAEAC,WAAWA,CAACC,MAAmB,EAAEC,KAAuB,EAAE;IACxD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAGrB,MAAMC,oBAAoB,GAAGF,KAAK,CAACG,MAAM,KAAK,IAAI;IAElD,IAAI,CAACJ,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,EAAE,GAAGL,MAAM,CAACK,EAAE;IACnB,IAAI,CAACD,MAAM,GACT,IAAI,CAACH,KAAK,CAACG,MAAM,IAAID,oBAAoB,GAAG,IAAI,CAACF,KAAK,CAACG,MAAM,GAAG,IAAI,CAACC,EAAE,CAACC,iBAAiB,EAAE;IAE7F,IAAI,CAACH,oBA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AAO,SAAS;IAClB,KAAKpC,EAAE,CAACuE,iCAAiC;MACvC,OAAO,wBAAwB;IACjC,KAAKvE,EAAE,CAACwE,yCAAyC;MAC/C,OAAO,gBAAgB;IACzB,KAAKxE,EAAE,CAACyE,iCAAiC;MACvC,OAAO,uBAAuB;IAChC,KAAKzE,EAAE,CAAC0E,uBAAuB;MAC7B,OAAO,kCAAkC;IAE3C,KAAK1E,EAAE,CAAC2E,kCAAkC;MACxC,OAAO,kBAAkB;IAG3B;MACE,UAAArC,MAAA,CAAUJ,MAAM;EAAG;AAEzB"}
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
import { RenderPass, RenderPassProps } from '@luma.gl/api';
|
|
2
|
-
import WebGLDevice from '../webgl-device';
|
|
3
|
-
|
|
1
|
+
import { RenderPass, RenderPassProps, NumericArray, RenderPassParameters } from '@luma.gl/api';
|
|
2
|
+
import { WebGLDevice } from '../webgl-device';
|
|
3
|
+
import { GLParameters } from '@luma.gl/constants';
|
|
4
|
+
export declare class WEBGLRenderPass extends RenderPass {
|
|
4
5
|
readonly device: WebGLDevice;
|
|
6
|
+
/** Parameters that should be applied before each draw call */
|
|
7
|
+
glParameters: GLParameters;
|
|
5
8
|
constructor(device: WebGLDevice, props: RenderPassProps);
|
|
6
9
|
end(): void;
|
|
7
10
|
pushDebugGroup(groupLabel: string): void;
|
|
8
11
|
popDebugGroup(): void;
|
|
9
12
|
insertDebugMarker(markerLabel: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Maps RenderPass parameters to GL parameters
|
|
15
|
+
*/
|
|
16
|
+
setParameters(parameters?: RenderPassParameters): void;
|
|
17
|
+
/**
|
|
18
|
+
* Optionally clears depth, color and stencil buffers based on parameters
|
|
19
|
+
*/
|
|
20
|
+
protected clear(): void;
|
|
21
|
+
/**
|
|
22
|
+
* WebGL2 - clear a specific color buffer
|
|
23
|
+
*/
|
|
24
|
+
protected clearColorBuffer(drawBuffer?: number, value?: NumericArray): void;
|
|
10
25
|
}
|
|
11
26
|
//# 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":"AAAA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAK,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAWpD,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;IAWvD,GAAG,IAAI,IAAI;IAIX,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IACxC,aAAa,IAAI,IAAI;IACrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAS5C;;OAEG;IACH,aAAa,CAAC,UAAU,GAAE,oBAAyB,GAAG,IAAI;IAyC1D;;OAEG;IACH,SAAS,CAAC,KAAK,IAAI,IAAI;IA+BvB;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,UAAU,GAAE,MAAU,EAAE,KAAK,GAAE,YAA2B;CAwCtF"}
|
|
@@ -1,14 +1,94 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { RenderPass } from '@luma.gl/api';
|
|
3
|
-
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
import { withParameters } from "../../context/state-tracker/with-parameters.js";
|
|
5
|
+
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
6
|
+
const GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
7
|
+
const GL_COLOR_BUFFER_BIT = 0x00004000;
|
|
8
|
+
const GL_COLOR = 0x1800;
|
|
9
|
+
export class WEBGLRenderPass extends RenderPass {
|
|
4
10
|
constructor(device, props) {
|
|
5
11
|
super(device, props);
|
|
6
12
|
_defineProperty(this, "device", void 0);
|
|
13
|
+
_defineProperty(this, "glParameters", void 0);
|
|
7
14
|
this.device = device;
|
|
15
|
+
this.setParameters(this.props.parameters);
|
|
16
|
+
this.clear();
|
|
8
17
|
}
|
|
9
18
|
end() {}
|
|
10
19
|
pushDebugGroup(groupLabel) {}
|
|
11
20
|
popDebugGroup() {}
|
|
12
21
|
insertDebugMarker(markerLabel) {}
|
|
22
|
+
setParameters() {
|
|
23
|
+
let parameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
24
|
+
const glParameters = {};
|
|
25
|
+
if (this.props.framebuffer) {
|
|
26
|
+
glParameters.framebuffer = this.props.framebuffer;
|
|
27
|
+
}
|
|
28
|
+
if (this.props.depthReadOnly) {
|
|
29
|
+
glParameters.depthMask = !this.props.depthReadOnly;
|
|
30
|
+
}
|
|
31
|
+
glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;
|
|
32
|
+
glParameters[GL.RASTERIZER_DISCARD] = this.props.discard;
|
|
33
|
+
if (parameters.viewport) {
|
|
34
|
+
glParameters.viewport = parameters.viewport;
|
|
35
|
+
glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];
|
|
36
|
+
}
|
|
37
|
+
glParameters.scissorTest = Boolean(parameters.scissorRect);
|
|
38
|
+
if (parameters.scissorRect) {
|
|
39
|
+
glParameters.scissor = parameters.scissorRect;
|
|
40
|
+
}
|
|
41
|
+
if (parameters.blendConstant) {
|
|
42
|
+
glParameters.blendColor = parameters.blendConstant;
|
|
43
|
+
}
|
|
44
|
+
if (parameters.stencilReference) {
|
|
45
|
+
console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');
|
|
46
|
+
parameters[GL.STENCIL_REF] = parameters.stencilReference;
|
|
47
|
+
}
|
|
48
|
+
this.glParameters = glParameters;
|
|
49
|
+
}
|
|
50
|
+
clear() {
|
|
51
|
+
const glParameters = {
|
|
52
|
+
...this.glParameters
|
|
53
|
+
};
|
|
54
|
+
let clearMask = 0;
|
|
55
|
+
if (this.props.clearColor !== false) {
|
|
56
|
+
clearMask |= GL_COLOR_BUFFER_BIT;
|
|
57
|
+
glParameters.clearColor = this.props.clearColor;
|
|
58
|
+
}
|
|
59
|
+
if (this.props.clearDepth !== false) {
|
|
60
|
+
clearMask |= GL_DEPTH_BUFFER_BIT;
|
|
61
|
+
glParameters.clearDepth = this.props.clearDepth;
|
|
62
|
+
}
|
|
63
|
+
if (this.props.clearStencil !== false) {
|
|
64
|
+
clearMask |= GL_STENCIL_BUFFER_BIT;
|
|
65
|
+
glParameters.clearStencil = this.props.clearStencil;
|
|
66
|
+
}
|
|
67
|
+
if (clearMask !== 0) {
|
|
68
|
+
withParameters(this.device, glParameters, () => {
|
|
69
|
+
this.device.gl.clear(clearMask);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
clearColorBuffer() {
|
|
74
|
+
let drawBuffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
75
|
+
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0, 0];
|
|
76
|
+
withParameters(this.device.gl2, {
|
|
77
|
+
framebuffer: this.props.framebuffer
|
|
78
|
+
}, () => {
|
|
79
|
+
switch (value.constructor) {
|
|
80
|
+
case Int32Array:
|
|
81
|
+
this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);
|
|
82
|
+
break;
|
|
83
|
+
case Uint32Array:
|
|
84
|
+
this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);
|
|
85
|
+
break;
|
|
86
|
+
case Float32Array:
|
|
87
|
+
default:
|
|
88
|
+
this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
13
93
|
}
|
|
14
94
|
//# sourceMappingURL=webgl-render-pass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pass.js","names":["RenderPass","WEBGLRenderPass","constructor","device","props","_defineProperty","end","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"sourcesContent":["import {RenderPass, RenderPassProps} from '@luma.gl/api';\nimport WebGLDevice from '../webgl-device';\n\nexport
|
|
1
|
+
{"version":3,"file":"webgl-render-pass.js","names":["RenderPass","GL","withParameters","GL_DEPTH_BUFFER_BIT","GL_STENCIL_BUFFER_BIT","GL_COLOR_BUFFER_BIT","GL_COLOR","WEBGLRenderPass","constructor","device","props","_defineProperty","setParameters","parameters","clear","end","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel","arguments","length","undefined","glParameters","framebuffer","depthReadOnly","depthMask","stencilMask","stencilReadOnly","RASTERIZER_DISCARD","discard","viewport","depthRange","scissorTest","Boolean","scissorRect","scissor","blendConstant","blendColor","stencilReference","console","warn","STENCIL_REF","clearMask","clearColor","clearDepth","clearStencil","gl","clearColorBuffer","drawBuffer","value","gl2","Int32Array","clearBufferiv","Uint32Array","clearBufferuiv","Float32Array","clearBufferfv"],"sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"sourcesContent":["import {RenderPass, RenderPassProps, NumericArray, RenderPassParameters} from '@luma.gl/api';\nimport {WebGLDevice} from '../webgl-device';\nimport {GL, GLParameters} from '@luma.gl/constants';\nimport {withParameters} from '../../context/state-tracker/with-parameters';\n\n// Should collapse during minification\n\nconst GL_DEPTH_BUFFER_BIT = 0x00000100;\nconst GL_STENCIL_BUFFER_BIT = 0x00000400;\nconst GL_COLOR_BUFFER_BIT = 0x00004000;\n\nconst GL_COLOR = 0x1800;\n\nexport class WEBGLRenderPass extends RenderPass {\n readonly device: WebGLDevice;\n\n /** Parameters that should be applied before each draw call */\n glParameters: GLParameters;\n\n constructor(device: WebGLDevice, props: RenderPassProps) {\n super(device, props);\n this.device = device;\n\n // TODO - do parameters (scissorRect) affect the clear operation?\n this.setParameters(this.props.parameters);\n\n // Hack - for now WebGL draws in \"immediate mode\" (instead of queueing the operations)...\n this.clear();\n }\n\n end(): void {\n // should add commands to CommandEncoder.\n }\n\n pushDebugGroup(groupLabel: string): void {}\n popDebugGroup(): void {}\n insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n /**\n * Maps RenderPass parameters to GL parameters\n */\n setParameters(parameters: RenderPassParameters = {}): void {\n const glParameters: GLParameters = {};\n\n // Framebuffers are specified using parameters in WebGL\n if (this.props.framebuffer) {\n glParameters.framebuffer = this.props.framebuffer;\n }\n\n if (this.props.depthReadOnly) {\n glParameters.depthMask = !this.props.depthReadOnly;\n }\n\n glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;\n\n glParameters[GL.RASTERIZER_DISCARD] = this.props.discard;\n\n // Map the four renderpass parameters to WebGL parameters\n if (parameters.viewport) {\n glParameters.viewport = parameters.viewport;\n glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];\n }\n glParameters.scissorTest = Boolean(parameters.scissorRect);\n if (parameters.scissorRect) {\n glParameters.scissor = parameters.scissorRect;\n }\n if (parameters.blendConstant) {\n glParameters.blendColor = parameters.blendConstant;\n }\n if (parameters.stencilReference) {\n // eslint-disable-next-line no-console\n console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');\n // parameters.stencilFunc = [func, ref, mask];\n // Does this work?\n parameters[GL.STENCIL_REF] = parameters.stencilReference;\n }\n\n this.glParameters = glParameters;\n }\n\n // Internal\n\n /**\n * Optionally clears depth, color and stencil buffers based on parameters\n */\n protected clear(): void {\n const glParameters: GLParameters = {...this.glParameters};\n\n let clearMask = 0;\n\n if (this.props.clearColor !== false) {\n clearMask |= GL_COLOR_BUFFER_BIT;\n glParameters.clearColor = this.props.clearColor;\n }\n if (this.props.clearDepth !== false) {\n clearMask |= GL_DEPTH_BUFFER_BIT;\n glParameters.clearDepth = this.props.clearDepth;\n }\n if (this.props.clearStencil !== false) {\n clearMask |= GL_STENCIL_BUFFER_BIT;\n glParameters.clearStencil = this.props.clearStencil;\n }\n\n if (clearMask !== 0) {\n // Temporarily set any clear \"colors\" and call clear\n withParameters(this.device, glParameters, () => {\n this.device.gl.clear(clearMask);\n });\n\n // TODO - clear multiple color attachments\n // for (attachment of this.framebuffer.colorAttachments) {\n // this.clearColorBuffer \n // }\n }\n }\n\n /** \n * WebGL2 - clear a specific color buffer \n */\n protected clearColorBuffer(drawBuffer: number = 0, value: NumericArray = [0, 0, 0, 0]) {\n withParameters(this.device.gl2, {framebuffer: this.props.framebuffer}, () => {\n // Method selection per OpenGL ES 3 docs\n switch (value.constructor) {\n case Int32Array:\n this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);\n break;\n case Uint32Array:\n this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);\n break;\n case Float32Array:\n default:\n this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);\n break;\n }\n });\n }\n\n // clearDepthStencil() {\n // const GL_DEPTH = 0x1801;\n // const GL_STENCIL = 0x1802;\n // const GL_DEPTH_STENCIL = 0x84f9;\n\n // case GL_DEPTH:\n // this.device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);\n // break;\n\n // case GL_STENCIL:\n // this.device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);\n // break;\n\n // case GL_DEPTH_STENCIL:\n // const [depth, stencil] = value;\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C2C,GAAG,CAACM,aAAa,CAACpD,QAAQ,EAAE4C,UAAU,EAAEC,KAAK,CAAC;UAC1D;MAAM;IAEZ,CAAC,CAAC;EACJ;AAwBF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { RenderPipelineProps, RenderPass, Buffer, Binding, ShaderLayout } from '@luma.gl/api';
|
|
2
2
|
import { RenderPipeline } from '@luma.gl/api';
|
|
3
|
-
import WebGLDevice from '../webgl-device';
|
|
4
|
-
import WEBGLShader from './webgl-shader';
|
|
5
|
-
import WEBGLVertexArrayObject from '../objects/webgl-vertex-array-object';
|
|
3
|
+
import { WebGLDevice } from '../webgl-device';
|
|
4
|
+
import { WEBGLShader } from './webgl-shader';
|
|
5
|
+
import { WEBGLVertexArrayObject } from '../objects/webgl-vertex-array-object';
|
|
6
6
|
/** Creates a new render pipeline */
|
|
7
|
-
export
|
|
7
|
+
export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
8
8
|
device: WebGLDevice;
|
|
9
9
|
handle: WebGLProgram;
|
|
10
10
|
vs: WEBGLShader;
|
|
@@ -32,7 +32,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
32
32
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
33
33
|
*/
|
|
34
34
|
draw(options: {
|
|
35
|
-
renderPass
|
|
35
|
+
renderPass: RenderPass;
|
|
36
36
|
vertexCount?: number;
|
|
37
37
|
indexCount?: number;
|
|
38
38
|
instanceCount?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,MAAM,EACN,OAAO,EACP,YAAY,EAIb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,cAAc,EAAgC,MAAM,cAAc,CAAC;AAS3E,OAAO,WAAW,MAAM,iBAAiB,CAAC;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AC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAwBvD,sCAAsC;IACtC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAqCpD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAKzC;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,EAAE,UAAU,CAAC;QACvB,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;KACrB,GAAG,OAAO;IA6EX,SAAS,CAAC,eAAe;IA0BzB;;;;OAIG;IACH,sBAAsB;IAkBtB,yBAAyB;IACzB,cAAc;IA6Dd,cAAc;CASf"}
|
|
@@ -5,11 +5,11 @@ import { getWebGLDataType } from "../converters/texture-formats.js";
|
|
|
5
5
|
import { getShaderLayout } from "../helpers/get-shader-layout.js";
|
|
6
6
|
import { withDeviceParameters, withGLParameters } from "../converters/device-parameters.js";
|
|
7
7
|
import { setUniform } from "../helpers/set-uniform.js";
|
|
8
|
-
import WEBGLBuffer from "./webgl-buffer.js";
|
|
9
|
-
import WEBGLTexture from "./webgl-texture.js";
|
|
10
|
-
import WEBGLVertexArrayObject from "../objects/webgl-vertex-array-object.js";
|
|
8
|
+
import { WEBGLBuffer } from "./webgl-buffer.js";
|
|
9
|
+
import { WEBGLTexture } from "./webgl-texture.js";
|
|
10
|
+
import { WEBGLVertexArrayObject } from "../objects/webgl-vertex-array-object.js";
|
|
11
11
|
const LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
12
|
-
export
|
|
12
|
+
export class WEBGLRenderPipeline extends RenderPipeline {
|
|
13
13
|
constructor(device, props) {
|
|
14
14
|
super(device, props);
|
|
15
15
|
_defineProperty(this, "device", void 0);
|
|
@@ -123,7 +123,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
123
123
|
draw(options) {
|
|
124
124
|
var _this$_indexBuffer;
|
|
125
125
|
const {
|
|
126
|
-
renderPass
|
|
126
|
+
renderPass,
|
|
127
127
|
vertexCount,
|
|
128
128
|
instanceCount,
|
|
129
129
|
firstVertex = 0
|
|
@@ -144,10 +144,9 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
144
144
|
}
|
|
145
145
|
this._applyBindings();
|
|
146
146
|
this._applyUniforms();
|
|
147
|
+
const webglRenderPass = renderPass;
|
|
147
148
|
withDeviceParameters(this.device, this.props.parameters, () => {
|
|
148
|
-
withGLParameters(this.device, {
|
|
149
|
-
framebuffer: renderPass.props.framebuffer
|
|
150
|
-
}, () => {
|
|
149
|
+
withGLParameters(this.device, webglRenderPass.glParameters, () => {
|
|
151
150
|
if (isIndexed && isInstanced) {
|
|
152
151
|
var _this$device$gl2;
|
|
153
152
|
(_this$device$gl2 = this.device.gl2) === null || _this$device$gl2 === void 0 ? void 0 : _this$device$gl2.drawElementsInstanced(drawMode, vertexCount || 0, indexType, firstVertex, instanceCount || 0);
|