@luma.gl/webgl 9.0.0-alpha.26 → 9.0.0-alpha.27
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/objects/webgl-vertex-array-object.d.ts +35 -8
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +114 -14
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +12 -2
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +10 -0
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/dist.dev.js +186 -16
- package/dist/index.cjs +144 -19
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/objects/webgl-vertex-array-object.ts +190 -26
- package/src/adapter/resources/webgl-render-pipeline.ts +23 -2
|
@@ -1,27 +1,54 @@
|
|
|
1
|
-
import { ResourceProps } from '@luma.gl/api';
|
|
2
|
-
import { WebGLDevice } from '../webgl-device';
|
|
1
|
+
import type { Device, Buffer, ResourceProps, TypedArray } from '@luma.gl/api';
|
|
3
2
|
import { WebGLResource } from './webgl-resource';
|
|
4
3
|
import { WEBGLBuffer } from '../resources/webgl-buffer';
|
|
5
4
|
/**
|
|
6
5
|
* VertexArrayObject properties
|
|
6
|
+
* @param constantAttributeZero Attribute 0 can not be disable on most desktop OpenGL based browsers
|
|
7
|
+
* and on iOS Safari browser.
|
|
7
8
|
*/
|
|
8
|
-
export type VertexArrayObjectProps = ResourceProps & {
|
|
9
|
+
export type VertexArrayObjectProps = ResourceProps & {
|
|
10
|
+
constantAttributeZero?: boolean;
|
|
11
|
+
};
|
|
9
12
|
/** VertexArrayObject wrapper */
|
|
10
13
|
export declare class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {
|
|
11
14
|
get [Symbol.toStringTag](): string;
|
|
12
|
-
|
|
15
|
+
/** Buffer constant */
|
|
16
|
+
private buffer;
|
|
17
|
+
private bufferValue;
|
|
18
|
+
static isConstantAttributeZeroSupported(device: Device): boolean;
|
|
19
|
+
constructor(device: Device, props?: VertexArrayObjectProps);
|
|
20
|
+
destroy(): void;
|
|
13
21
|
_createHandle(): WebGLVertexArrayObject;
|
|
14
22
|
_deleteHandle(): void;
|
|
15
23
|
_bindHandle(handle: WEBGLVertexArrayObject): void;
|
|
16
|
-
setElementBuffer(elementBuffer?: WEBGLBuffer | null, opts?: {}): this;
|
|
17
|
-
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
18
|
-
setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): this;
|
|
19
24
|
/**
|
|
20
25
|
* Enabling an attribute location makes it reference the currently bound buffer
|
|
21
26
|
* Disabling an attribute location makes it reference the global constant value
|
|
22
27
|
* TODO - handle single values for size 1 attributes?
|
|
23
28
|
* TODO - convert classic arrays based on known type?
|
|
24
29
|
*/
|
|
25
|
-
enable(location: number, enable?: boolean):
|
|
30
|
+
enable(location: number, enable?: boolean): void;
|
|
31
|
+
setElementBuffer(elementBuffer?: WEBGLBuffer | null, opts?: {}): void;
|
|
32
|
+
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
33
|
+
setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): void;
|
|
34
|
+
/**
|
|
35
|
+
* Set an attribute to a constant value
|
|
36
|
+
* @param device
|
|
37
|
+
* @param location
|
|
38
|
+
* @param array
|
|
39
|
+
*
|
|
40
|
+
* @note Constants are stored globally on the WebGL context, not the VAO
|
|
41
|
+
* so they need to be updated before every render
|
|
42
|
+
* @todo - use known type (in configuration or passed in) to allow non-typed arrays?
|
|
43
|
+
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
44
|
+
*/
|
|
45
|
+
setConstant(location: any, array: TypedArray): void;
|
|
46
|
+
/**
|
|
47
|
+
* Provide a means to create a buffer that is equivalent to a constant.
|
|
48
|
+
* NOTE: Desktop OpenGL cannot disable attribute 0.
|
|
49
|
+
* https://stackoverflow.com/questions/20305231/webgl-warning-attribute-0-is-disabled-
|
|
50
|
+
* this-has-significant-performance-penalty
|
|
51
|
+
*/
|
|
52
|
+
getConstantBuffer(elementCount: number, value: any): Buffer;
|
|
26
53
|
}
|
|
27
54
|
//# sourceMappingURL=webgl-vertex-array-object.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array-object.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array-object.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AAM1F,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAMtD;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,gCAAgC;AAChC,qBAAa,sBAAuB,SAAQ,aAAa,CAAC,sBAAsB,CAAC;IAC/E,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,sBAAsB;IACtB,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,WAAW,CAAQ;IAE3B,MAAM,CAAC,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;gBAKpD,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,sBAAsB;IAKjD,OAAO,IAAI,IAAI;IAMf,aAAa;IAIb,aAAa,IAAI,IAAI;IAOrB,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;IAI1D;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,IAAI;IAgB7C,gBAAgB,CAAC,aAAa,GAAE,WAAW,GAAG,IAAW,EAAE,IAAI,KAAK;IASpE,gGAAgG;IAChG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;IA+BrE;;;;;;;;;;OAUG;IACH,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAgBnD;;;;;OAKG;IACH,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,KAAA,GAAG,MAAM;CA2BvD"}
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
let _Symbol$toStringTag;
|
|
3
|
+
import { Resource, assert, getScratchArray, fillArray } from '@luma.gl/api';
|
|
2
4
|
import { GL } from '@luma.gl/constants';
|
|
3
5
|
import { getBrowser } from '@probe.gl/env';
|
|
4
6
|
import { WebGLResource } from "./webgl-resource.js";
|
|
5
7
|
const ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';
|
|
8
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
6
9
|
export class WEBGLVertexArrayObject extends WebGLResource {
|
|
7
|
-
get [
|
|
10
|
+
get [_Symbol$toStringTag]() {
|
|
8
11
|
return 'BaseVertexArrayObject';
|
|
9
12
|
}
|
|
13
|
+
static isConstantAttributeZeroSupported(device) {
|
|
14
|
+
return device.info.type === 'webgl2' || getBrowser() === 'Chrome';
|
|
15
|
+
}
|
|
10
16
|
constructor(device, props) {
|
|
11
|
-
super(device, props, {
|
|
17
|
+
super(device, props, {
|
|
18
|
+
...Resource.defaultProps,
|
|
19
|
+
constantAttributeZero: false
|
|
20
|
+
});
|
|
21
|
+
_defineProperty(this, "buffer", null);
|
|
22
|
+
_defineProperty(this, "bufferValue", null);
|
|
23
|
+
Object.seal(this);
|
|
24
|
+
}
|
|
25
|
+
destroy() {
|
|
26
|
+
super.destroy();
|
|
27
|
+
if (this.buffer) {
|
|
28
|
+
var _this$buffer;
|
|
29
|
+
(_this$buffer = this.buffer) === null || _this$buffer === void 0 ? void 0 : _this$buffer.destroy();
|
|
30
|
+
}
|
|
12
31
|
}
|
|
13
32
|
_createHandle() {
|
|
14
33
|
return this.gl2.createVertexArray();
|
|
@@ -20,6 +39,15 @@ export class WEBGLVertexArrayObject extends WebGLResource {
|
|
|
20
39
|
_bindHandle(handle) {
|
|
21
40
|
this.gl2.bindVertexArray(handle);
|
|
22
41
|
}
|
|
42
|
+
enable(location) {
|
|
43
|
+
let enable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
44
|
+
const canDisableAttributeZero = this.device.isWebGL2 || getBrowser() === 'Chrome';
|
|
45
|
+
const canDisableAttribute = canDisableAttributeZero || location !== 0;
|
|
46
|
+
if (enable || canDisableAttribute) {
|
|
47
|
+
location = Number(location);
|
|
48
|
+
this.bind(() => enable ? this.gl.enableVertexAttribArray(location) : this.gl.disableVertexAttribArray(location));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
23
51
|
setElementBuffer() {
|
|
24
52
|
let elementBuffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
25
53
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -27,11 +55,11 @@ export class WEBGLVertexArrayObject extends WebGLResource {
|
|
|
27
55
|
this.bind(() => {
|
|
28
56
|
this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);
|
|
29
57
|
});
|
|
30
|
-
return this;
|
|
31
58
|
}
|
|
32
59
|
setBuffer(location, buffer, accessor) {
|
|
33
60
|
if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {
|
|
34
|
-
|
|
61
|
+
this.setElementBuffer(buffer, accessor);
|
|
62
|
+
return;
|
|
35
63
|
}
|
|
36
64
|
const {
|
|
37
65
|
size,
|
|
@@ -58,17 +86,89 @@ export class WEBGLVertexArrayObject extends WebGLResource {
|
|
|
58
86
|
gl.enableVertexAttribArray(location);
|
|
59
87
|
gl2.vertexAttribDivisor(location, divisor || 0);
|
|
60
88
|
});
|
|
61
|
-
return this;
|
|
62
89
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
setConstant(location, array) {
|
|
91
|
+
switch (array.constructor) {
|
|
92
|
+
case Float32Array:
|
|
93
|
+
setConstantFloatArray(this.device, location, array);
|
|
94
|
+
break;
|
|
95
|
+
case Int32Array:
|
|
96
|
+
setConstantIntArray(this.device, location, array);
|
|
97
|
+
break;
|
|
98
|
+
case Uint32Array:
|
|
99
|
+
setConstantUintArray(this.device, location, array);
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
assert(false);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
getConstantBuffer(elementCount, value) {
|
|
106
|
+
const constantValue = normalizeConstantArrayValue(value);
|
|
107
|
+
const byteLength = constantValue.byteLength * elementCount;
|
|
108
|
+
const length = constantValue.length * elementCount;
|
|
109
|
+
let updateNeeded = !this.buffer;
|
|
110
|
+
this.buffer = this.buffer || this.device.createBuffer({
|
|
111
|
+
byteLength
|
|
112
|
+
});
|
|
113
|
+
updateNeeded = updateNeeded || this.buffer.reallocate(byteLength);
|
|
114
|
+
updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
115
|
+
if (updateNeeded) {
|
|
116
|
+
const typedArray = getScratchArray(value.constructor, length);
|
|
117
|
+
fillArray({
|
|
118
|
+
target: typedArray,
|
|
119
|
+
source: constantValue,
|
|
120
|
+
start: 0,
|
|
121
|
+
count: length
|
|
122
|
+
});
|
|
123
|
+
this.buffer.subData(typedArray);
|
|
124
|
+
this.bufferValue = value;
|
|
125
|
+
}
|
|
126
|
+
return this.buffer;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function setConstantFloatArray(device, location, array) {
|
|
130
|
+
switch (array.length) {
|
|
131
|
+
case 1:
|
|
132
|
+
device.gl.vertexAttrib1fv(location, array);
|
|
133
|
+
break;
|
|
134
|
+
case 2:
|
|
135
|
+
device.gl.vertexAttrib2fv(location, array);
|
|
136
|
+
break;
|
|
137
|
+
case 3:
|
|
138
|
+
device.gl.vertexAttrib3fv(location, array);
|
|
139
|
+
break;
|
|
140
|
+
case 4:
|
|
141
|
+
device.gl.vertexAttrib4fv(location, array);
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
assert(false);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function setConstantIntArray(device, location, array) {
|
|
148
|
+
var _device$gl;
|
|
149
|
+
device.assertWebGL2();
|
|
150
|
+
(_device$gl = device.gl2) === null || _device$gl === void 0 ? void 0 : _device$gl.vertexAttribI4iv(location, array);
|
|
151
|
+
}
|
|
152
|
+
function setConstantUintArray(device, location, array) {
|
|
153
|
+
var _device$gl2;
|
|
154
|
+
device.assertWebGL2();
|
|
155
|
+
(_device$gl2 = device.gl2) === null || _device$gl2 === void 0 ? void 0 : _device$gl2.vertexAttribI4uiv(location, array);
|
|
156
|
+
}
|
|
157
|
+
function normalizeConstantArrayValue(arrayValue) {
|
|
158
|
+
if (Array.isArray(arrayValue)) {
|
|
159
|
+
return new Float32Array(arrayValue);
|
|
160
|
+
}
|
|
161
|
+
return arrayValue;
|
|
162
|
+
}
|
|
163
|
+
function compareConstantArrayValues(v1, v2) {
|
|
164
|
+
if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
for (let i = 0; i < v1.length; ++i) {
|
|
168
|
+
if (v1[i] !== v2[i]) {
|
|
169
|
+
return false;
|
|
70
170
|
}
|
|
71
|
-
return this;
|
|
72
171
|
}
|
|
172
|
+
return true;
|
|
73
173
|
}
|
|
74
174
|
//# sourceMappingURL=webgl-vertex-array-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array-object.js","names":["assert","GL","getBrowser","WebGLResource","ERR_ELEMENTS","WEBGLVertexArrayObject","Symbol","toStringTag","constructor","device","props","_createHandle","gl2","createVertexArray","_deleteHandle","deleteVertexArray","handle","elements","_bindHandle","bindVertexArray","setElementBuffer","elementBuffer","arguments","length","undefined","opts","target","ELEMENT_ARRAY_BUFFER","bind","gl","bindBuffer","setBuffer","location","buffer","accessor","size","type","stride","offset","normalized","integer","divisor","Number","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","canDisableAttributeZero","isWebGL2","canDisableAttribute","disableVertexAttribArray"],"sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"sourcesContent":["import {assert, ResourceProps} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\n\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\n/**\n * VertexArrayObject properties\n */\nexport type VertexArrayObjectProps = ResourceProps & {\n};\n\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {\n override get [Symbol.toStringTag](): string {\n return 'BaseVertexArrayObject';\n }\n\n constructor(device: WebGLDevice, props?: VertexArrayObjectProps) {\n // @ts-expect-error\n super(device, props, {});\n }\n\n override _createHandle() {\n return this.gl2.createVertexArray();\n }\n\n override _deleteHandle(): void {\n this.gl2.deleteVertexArray(this.handle);\n // @ts-expect-error\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n override _bindHandle(handle: WEBGLVertexArrayObject): void {\n this.gl2.bindVertexArray(handle);\n }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer: WEBGLBuffer | null = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n\n return this;\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): this {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n return this.setElementBuffer(buffer, accessor);\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.assertWebGL2();\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n\n return this;\n }\n\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n enable(location: number, enable = true): this {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = this.device.isWebGL2 || getBrowser() === 'Chrome';\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.bind(() =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n }\n return this;\n }\n}\n"],"mappings":"AAAA,SAAQA,MAAM,QAAsB,cAAc;AAClD,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,UAAU,QAAO,eAAe;AAAC,SAGjCC,aAAa;AAIrB,MAAMC,YAAY,GAAG,0CAA0C;AAS/D,OAAO,MAAMC,sBAAsB,SAASF,aAAa,CAAyB;EAChF,KAAcG,MAAM,CAACC,WAAW,IAAY;IAC1C,OAAO,uBAAuB;EAChC;EAEAC,WAAWA,CAACC,MAAmB,EAAEC,KAA8B,EAAE;IAE/D,KAAK,CAACD,MAAM,EAAEC,KAAK,EAAE,CAAC,CAAC,CAAC;EAC1B;EAESC,aAAaA,CAAA,EAAG;IACvB,OAAO,IAAI,CAACC,GAAG,CAACC,iBAAiB,CAAC,CAAC;EACrC;EAESC,aAAaA,CAAA,EAAS;IAC7B,IAAI,CAACF,GAAG,CAACG,iBAAiB,CAAC,IAAI,CAACC,MAAM,CAAC;IAEvC,OAAO,CAAC,IAAI,CAACC,QAAQ,CAAC;EAExB;EAESC,WAAWA,CAACF,MAA8B,EAAQ;IACzD,IAAI,CAACJ,GAAG,CAACO,eAAe,CAACH,MAAM,CAAC;EAClC;EAIAI,gBAAgBA,CAAA,EAAsD;IAAA,IAArDC,aAAiC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;IAAA,IAAEG,IAAI,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAClEtB,MAAM,CAAC,CAACqB,aAAa,IAAIA,aAAa,CAACK,MAAM,KAAKzB,EAAE,CAAC0B,oBA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AC,CAAC;IAEF,OAAO,IAAI;EACb;EAQAQ,MAAMA,CAACjB,QAAgB,EAAuB;IAAA,IAArBiB,MAAM,GAAA3B,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;IAEpC,MAAM4B,uBAAuB,GAAG,IAAI,CAACzC,MAAM,CAAC0C,QAAQ,IAAIjD,UAAU,CAAC,CAAC,KAAK,QAAQ;IACjF,MAAMkD,mBAAmB,GAAGF,uBAAuB,IAAIlB,QAAQ,KAAK,CAAC;IAErE,IAAIiB,MAAM,IAAIG,mBAAmB,EAAE;MACjCpB,QAAQ,GAAGU,MAAM,CAACV,QAAQ,CAAC;MAC3B,IAAI,CAACJ,IAAI,CAAC,MACRqB,MAAM,GACF,IAAI,CAACpB,EAAE,CAACkB,uBAAuB,CAACf,QAAQ,CAAC,GACzC,IAAI,CAACH,EAAE,CAACwB,wBAAwB,CAACrB,QAAQ,CAC/C,CAAC;IACH;IACA,OAAO,IAAI;EACb;AACF"}
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array-object.js","names":["Resource","assert","getScratchArray","fillArray","GL","getBrowser","WebGLResource","ERR_ELEMENTS","_Symbol$toStringTag","Symbol","toStringTag","WEBGLVertexArrayObject","isConstantAttributeZeroSupported","device","info","type","constructor","props","defaultProps","constantAttributeZero","_defineProperty","Object","seal","destroy","buffer","_this$buffer","_createHandle","gl2","createVertexArray","_deleteHandle","deleteVertexArray","handle","elements","_bindHandle","bindVertexArray","enable","location","arguments","length","undefined","canDisableAttributeZero","isWebGL2","canDisableAttribute","Number","bind","gl","enableVertexAttribArray","disableVertexAttribArray","setElementBuffer","elementBuffer","opts","target","ELEMENT_ARRAY_BUFFER","bindBuffer","setBuffer","accessor","size","stride","offset","normalized","integer","divisor","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","vertexAttribDivisor","setConstant","array","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","getConstantBuffer","elementCount","value","constantValue","normalizeConstantArrayValue","byteLength","updateNeeded","createBuffer","reallocate","compareConstantArrayValues","bufferValue","typedArray","source","start","count","subData","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","arrayValue","Array","isArray","v1","v2","i"],"sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"sourcesContent":["import type {Device, Buffer, ResourceProps, TypedArray, NumericArray} from '@luma.gl/api';\nimport {Resource, assert, getScratchArray, fillArray} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\n\nimport {BufferWithAccessor} from '../../classic/buffer-with-accessor';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\n/**\n * VertexArrayObject properties\n * @param constantAttributeZero Attribute 0 can not be disable on most desktop OpenGL based browsers\n * and on iOS Safari browser.\n */\nexport type VertexArrayObjectProps = ResourceProps & {\n constantAttributeZero?: boolean;\n};\n\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {\n override get [Symbol.toStringTag](): string {\n return 'BaseVertexArrayObject';\n }\n\n /** Buffer constant */\n private buffer: BufferWithAccessor | null = null;\n private bufferValue = null;\n\n static isConstantAttributeZeroSupported(device: Device): boolean {\n return device.info.type === 'webgl2' || getBrowser() === 'Chrome';\n }\n\n // Create a VertexArray\n constructor(device: Device, props?: VertexArrayObjectProps) {\n super(device, props, {...Resource.defaultProps, constantAttributeZero: false});\n Object.seal(this);\n }\n\n override destroy(): void {\n super.destroy();\n if (this.buffer) {\n this.buffer?.destroy();\n } }\n\n override _createHandle() {\n return this.gl2.createVertexArray();\n }\n\n override _deleteHandle(): void {\n this.gl2.deleteVertexArray(this.handle);\n // @ts-expect-error\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n override _bindHandle(handle: WEBGLVertexArrayObject): void {\n this.gl2.bindVertexArray(handle);\n }\n\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n enable(location: number, enable = true): void {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = this.device.isWebGL2 || getBrowser() === 'Chrome';\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.bind(() =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n } }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer: WEBGLBuffer | null = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): void {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n this.setElementBuffer(buffer, accessor);\n return;\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.assertWebGL2();\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n }\n\n /**\n * Set an attribute to a constant value\n * @param device\n * @param location\n * @param array\n * \n * @note Constants are stored globally on the WebGL context, not the VAO\n * so they need to be updated before every render\n * @todo - use known type (in configuration or passed in) to allow non-typed arrays?\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstant(location: any, array: TypedArray): void {\n switch (array.constructor) {\n case Float32Array:\n setConstantFloatArray(this.device, location, array as Float32Array);\n break;\n case Int32Array:\n setConstantIntArray(this.device, location, array as Int32Array);\n break;\n case Uint32Array:\n setConstantUintArray(this.device, location, array as Uint32Array);\n break;\n default:\n assert(false);\n }\n }\n\n /**\n * Provide a means to create a buffer that is equivalent to a constant.\n * NOTE: Desktop OpenGL cannot disable attribute 0.\n * https://stackoverflow.com/questions/20305231/webgl-warning-attribute-0-is-disabled-\n * this-has-significant-performance-penalty\n */\n getConstantBuffer(elementCount: number, value): Buffer {\n // Create buffer only when needed, and reuse it (avoids inflating buffer creation statistics)\n\n const constantValue = normalizeConstantArrayValue(value);\n\n const byteLength = constantValue.byteLength * elementCount;\n const length = constantValue.length * elementCount;\n\n let updateNeeded = !this.buffer;\n\n this.buffer = this.buffer || this.device.createBuffer({byteLength}) as BufferWithAccessor;\n updateNeeded = updateNeeded || this.buffer.reallocate(byteLength);\n\n // Reallocate and update contents if needed\n updateNeeded =\n updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);\n\n if (updateNeeded) {\n // Create a typed array that is big enough, and fill it with the required data\n const typedArray = getScratchArray(value.constructor, length);\n fillArray({target: typedArray, source: constantValue, start: 0, count: length});\n this.buffer.subData(typedArray);\n this.bufferValue = value;\n }\n\n return this.buffer;\n }\n}\n\nfunction setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n}\n\nfunction setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4iv(location, array);\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n\nfunction setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4uiv(location, array);\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n\n// HELPERS\n\n/**\n * TODO - convert Arrays based on known type? (read type from accessor, don't assume Float32Array)\n * TODO - handle single values for size 1 attributes?\n */\nfunction normalizeConstantArrayValue(arrayValue: NumericArray) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n}\n\n/**\n * \n */\nfunction compareConstantArrayValues(v1: NumericArray, v2: NumericArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":";;AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,eAAe,EAAEC,SAAS,QAAO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AAE,CAAChE,MAAM,KAAKiE,EAAE,CAACjE,MAAM,IAAIgE,EAAE,CAACtF,WAAW,KAAKuF,EAAE,CAACvF,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIwF,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAAChE,MAAM,EAAE,EAAEkE,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RenderPipelineProps, RenderPass, Buffer, Binding, ShaderLayout } from '@luma.gl/api';
|
|
1
|
+
import type { RenderPipelineProps, RenderPass, Buffer, Binding, ShaderLayout, TypedArray } from '@luma.gl/api';
|
|
2
2
|
import { RenderPipeline } from '@luma.gl/api';
|
|
3
3
|
import { WebGLDevice } from '../webgl-device';
|
|
4
4
|
import { WEBGLShader } from './webgl-shader';
|
|
@@ -24,7 +24,17 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
24
24
|
setIndexBuffer(indexBuffer: Buffer): void;
|
|
25
25
|
/** @todo needed for portable model */
|
|
26
26
|
setAttributes(attributes: Record<string, Buffer>): void;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
29
|
+
* Any attribute that is disabled in the current vertex array object
|
|
30
|
+
* is read from the context's global constant value for that attribute location.
|
|
31
|
+
* @param attributes
|
|
32
|
+
*/
|
|
33
|
+
setConstantAttributes(attributes: Record<string, TypedArray>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Bindings include: textures, samplers and uniform buffers
|
|
36
|
+
* @todo needed for portable model
|
|
37
|
+
*/
|
|
28
38
|
setBindings(bindings: Record<string, Binding>): void;
|
|
29
39
|
setUniforms(uniforms: Record<string, any>): void;
|
|
30
40
|
/** @todo needed for portable model
|
|
@@ -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,
|
|
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,EAIZ,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,cAAc,EAAgC,MAAM,cAAc,CAAC;AAS3E,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAK5E,oCAAoC;AACpC,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,WAAW,CAAC;IAChB,EAAE,EAAE,WAAW,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;IAIrB,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAQ;IACjC,iBAAiB,EAAE,sBAAsB,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IACnC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IAC3C,oBAAoB,EAAE,MAAM,CAAK;IACjC,aAAa,EAAE,MAAM,CAAK;IAC1B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAM;gBAEnC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB;IA2BlD,OAAO,IAAI,IAAI;IAQxB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAMzC,sCAAsC;IACtC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAwBvD;;;;;OAKG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAWnE;;;OAGG;IACH,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"}
|
|
@@ -87,6 +87,16 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
setConstantAttributes(attributes) {
|
|
91
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
92
|
+
const attribute = getAttributeLayout(this.layout, name);
|
|
93
|
+
if (!attribute) {
|
|
94
|
+
log.warn("Ignoring constant value supplied for unknown attribute \"".concat(name, "\" in pipeline \"").concat(this.id, "\""))();
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
this.vertexArrayObject.setConstant(attribute.location, value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
90
100
|
setBindings(bindings) {
|
|
91
101
|
for (const [name, value] of Object.entries(bindings)) {
|
|
92
102
|
const binding = this.layout.bindings.find(binding => binding.name === name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pipeline.js","names":["RenderPipeline","cast","log","decodeVertexFormat","GL","getWebGLDataType","getShaderLayout","withDeviceParameters","withGLParameters","setUniform","WEBGLBuffer","WEBGLTexture","WEBGLVertexArrayObject","LOG_PROGRAM_PERF_PRIORITY","WEBGLRenderPipeline","constructor","device","props","_defineProperty","handle","gl","createProgram","setSpectorMetadata","id","vs","fs","varyings","bufferMode","SEPARATE_ATTRIBS","length","_this$device$gl","assertWebGL2","gl2","transformFeedbackVaryings","_compileAndLink","layout","vertexArrayObject","destroy","deleteProgram","destroyed","setIndexBuffer","indexBuffer","webglBuffer","setElementBuffer","_indexBuffer","setAttributes","attributes","name","buffer","Object","entries","attribute","getAttributeLayout","warn","concat","decoded","format","type","typeString","components","size","byteLength","stride","normalized","integer","divisor","stepMode","setBuffer","location","offset","setBindings","bindings","value","binding","find","Error","setUniforms","uniforms","assign","draw","options","_this$_indexBuffer","renderPass","vertexCount","instanceCount","firstVertex","drawMode","getDrawMode","topology","isIndexed","Boolean","indexType","UNSIGNED_SHORT","UNSIGNED_INT","isInstanced","Number","_areTexturesRenderable","useProgram","bind","primitiveMode","getGLPrimitive","transformFeedback","begin","_applyBindings","_applyUniforms","webglRenderPass","parameters","glParameters","_this$device$gl2","drawElementsInstanced","drawElements","_this$device$gl3","drawArraysInstanced","drawArrays","end","attachShader","time","linkProgram","timeEnd","debug","level","linked","getProgramParameter","LINK_STATUS","getProgramInfoLog","validateProgram","validated","VALIDATE_STATUS","texturesRenderable","texture","_textureUniforms","update","loaded","undefined","textureUnit","uniformBufferIndex","getUniformBlockIndex","INVALID_INDEX","uniformBlockBinding","bindBufferBase","UNIFORM_BUFFER","bindBufferRange","activeTexture","TEXTURE0","bindTexture","target","uniformLayout","_this$uniforms$name","POINTS","LINES","LINE_STRIP","LINE_LOOP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN"],"sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"sourcesContent":["import type {\n RenderPipelineProps,\n RenderPass,\n Buffer,\n Binding,\n ShaderLayout,\n PrimitiveTopology,\n // BindingLayout,\n AttributeLayout\n} from '@luma.gl/api';\nimport {RenderPipeline, cast, log, decodeVertexFormat} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\n\nimport {getWebGLDataType} from '../converters/texture-formats';\nimport {getShaderLayout} from '../helpers/get-shader-layout';\nimport {withDeviceParameters, withGLParameters} from '../converters/device-parameters';\nimport {setUniform} from '../helpers/set-uniform';\n// import {copyUniform, checkUniformValues} from '../../classes/uniforms';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLShader} from './webgl-shader';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLVertexArrayObject} from '../objects/webgl-vertex-array-object';\nimport {WEBGLRenderPass} from './webgl-render-pass';\n\nconst LOG_PROGRAM_PERF_PRIORITY = 4;\n\n/** Creates a new render pipeline */\nexport class WEBGLRenderPipeline extends RenderPipeline {\n device: WebGLDevice;\n handle: WebGLProgram;\n vs: WEBGLShader;\n fs: WEBGLShader;\n layout: ShaderLayout;\n\n // configuration: ProgramConfiguration;\n // Experimental flag to avoid deleting Program object while it is cached\n varyings: string[] | null = null;\n vertexArrayObject: WEBGLVertexArrayObject;\n _indexBuffer?: Buffer;\n uniforms: Record<string, any> = {};\n bindings: Record<string, any> = {};\n _textureUniforms: Record<string, any> = {};\n _textureIndexCounter: number = 0;\n _uniformCount: number = 0;\n _uniformSetters: Record<string, Function> = {}; // TODO are these used?\n\n constructor(device: WebGLDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.gl.createProgram();\n this.device.setSpectorMetadata(this.handle, {id: this.props.id});\n\n // Create shaders if needed\n this.vs = cast<WEBGLShader>(props.vs);\n this.fs = cast<WEBGLShader>(props.fs);\n // assert(this.vs.stage === 'vertex');\n // assert(this.fs.stage === 'fragment');\n\n // Setup varyings if supplied\n // @ts-expect-error WebGL only\n const {varyings, bufferMode = GL.SEPARATE_ATTRIBS} = props;\n if (varyings && varyings.length > 0) {\n this.device.assertWebGL2();\n this.varyings = varyings;\n this.device.gl2?.transformFeedbackVaryings(this.handle, varyings, bufferMode);\n }\n\n this._compileAndLink();\n\n this.layout = props.layout || getShaderLayout(this.device.gl, this.handle);\n this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);\n }\n\n override destroy(): void {\n if (this.handle) {\n this.device.gl.deleteProgram(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n const webglBuffer = cast<WEBGLBuffer>(indexBuffer);\n this.vertexArrayObject.setElementBuffer(webglBuffer);\n this._indexBuffer = indexBuffer;\n }\n\n /** @todo needed for portable model */\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const webglBuffer = cast<WEBGLBuffer>(buffer);\n const attribute = getAttributeLayout(this.layout, name);\n if (!attribute) {\n log.warn(`Ignoring buffer supplied for unknown attribute \"${name}\" in pipeline \"${this.id}\" (buffer \"${buffer.id}\")`)();\n continue; // eslint-disable-line no-continue\n }\n const decoded = decodeVertexFormat(attribute.format);\n const {type: typeString, components: size, byteLength: stride, normalized, integer} = decoded;\n const divisor = attribute.stepMode === 'instance' ? 1 : 0;\n const type = getWebGLDataType(typeString);\n this.vertexArrayObject.setBuffer(attribute.location, webglBuffer, {\n size,\n type,\n stride,\n offset: 0,\n normalized,\n integer,\n divisor\n });\n }\n }\n\n /** @todo needed for portable model */\n setBindings(bindings: Record<string, Binding>): void {\n // if (log.priority >= 2) {\n // checkUniformValues(uniforms, this.id, this._uniformSetters);\n // }\n\n for (const [name, value] of Object.entries(bindings)) {\n const binding = this.layout.bindings.find((binding) => binding.name === name);\n if (!binding) {\n log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();\n continue; // eslint-disable-line no-continue\n }\n if (!value) {\n log.warn(`Unsetting binding ${name} in render pipeline ${this.id}`)();\n }\n switch (binding.type) {\n case 'uniform':\n // @ts-expect-error\n if (!(value instanceof WEBGLBuffer) && !(value.buffer instanceof WEBGLBuffer)) {\n throw new Error('buffer value');\n }\n break;\n case 'texture':\n if (!(value instanceof WEBGLTexture)) {\n throw new Error('texture value');\n }\n break;\n case 'sampler':\n log.warn(`Ignoring sampler ${name}`)();\n break;\n default:\n throw new Error(binding.type);\n }\n\n this.bindings[name] = value;\n }\n }\n\n setUniforms(uniforms: Record<string, any>) {\n // TODO - check against layout\n Object.assign(this.uniforms, uniforms);\n }\n\n /** @todo needed for portable model\n * @note The WebGL API is offers many ways to draw things\n * This function unifies those ways into a single call using common parameters with sane defaults\n */\n draw(options: {\n renderPass: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): boolean {\n const {\n renderPass,\n vertexCount,\n // indexCount,\n instanceCount,\n firstVertex = 0,\n // firstIndex,\n // firstInstance,\n // baseVertex\n } = options;\n\n const drawMode = getDrawMode(this.props.topology);\n const isIndexed: boolean = Boolean(this._indexBuffer);\n const indexType = this._indexBuffer?.props.indexType === 'uint16' ? GL.UNSIGNED_SHORT : GL.UNSIGNED_INT;\n const isInstanced: boolean = Number(options.instanceCount) > 0;\n\n // Avoid WebGL draw call when not rendering any data or values are incomplete\n // Note: async textures set as uniforms might still be loading.\n // Now that all uniforms have been updated, check if any texture\n // in the uniforms is not yet initialized, then we don't draw\n if (!this._areTexturesRenderable() || options.vertexCount === 0) {\n // (isInstanced && instanceCount === 0)\n return false;\n }\n\n this.device.gl.useProgram(this.handle);\n\n this.vertexArrayObject.bind(() => {\n const primitiveMode = getGLPrimitive(this.props.topology);\n const transformFeedback: any = null;\n if (transformFeedback) {\n transformFeedback.begin(primitiveMode);\n }\n\n // We have to apply bindings before every draw call since other draw calls will overwrite\n this._applyBindings();\n this._applyUniforms();\n\n const webglRenderPass = renderPass as WEBGLRenderPass;\n\n // TODO - double context push/pop\n withDeviceParameters(this.device, this.props.parameters, () => {\n withGLParameters(this.device, webglRenderPass.glParameters, () => {\n // TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension\n if (isIndexed && isInstanced) {\n // ANGLE_instanced_arrays extension\n this.device.gl2?.drawElementsInstanced(\n drawMode,\n vertexCount || 0, // indexCount?\n indexType,\n firstVertex,\n instanceCount || 0\n );\n // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {\n // this.device.gl2.drawRangeElements(drawMode, start, end, vertexCount, indexType, offset);\n } else if (isIndexed) {\n this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?\n } else if (isInstanced) {\n this.device.gl2?.drawArraysInstanced(drawMode, firstVertex, vertexCount || 0, instanceCount || 0);\n } else {\n this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);\n }\n });\n\n if (transformFeedback) {\n transformFeedback.end();\n }\n });\n });\n\n return true;\n }\n\n // setAttributes(attributes: Record<string, Buffer>): void {}\n // setBindings(bindings: Record<string, Binding>): void {}\n\n protected _compileAndLink() {\n const {gl} = this.device;\n gl.attachShader(this.handle, this.vs.handle);\n gl.attachShader(this.handle, this.fs.handle);\n log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n gl.linkProgram(this.handle);\n log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n\n // Avoid checking program linking error in production\n // @ts-expect-error\n if (gl.debug || log.level > 0) {\n const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);\n if (!linked) {\n throw new Error(`Error linking: ${gl.getProgramInfoLog(this.handle)}`);\n }\n\n gl.validateProgram(this.handle);\n const validated = gl.getProgramParameter(this.handle, gl.VALIDATE_STATUS);\n if (!validated) {\n throw new Error(`Error validating: ${gl.getProgramInfoLog(this.handle)}`);\n }\n }\n }\n\n // PRIVATE METHODS\n\n /**\n * Checks if all texture-values uniforms are renderable (i.e. loaded)\n * Update a texture if needed (e.g. from video)\n * Note: This is currently done before every draw call\n */\n _areTexturesRenderable() {\n let texturesRenderable = true;\n\n for (const [, texture] of Object.entries(this._textureUniforms)) {\n texture.update();\n texturesRenderable = texturesRenderable && texture.loaded;\n }\n\n for (const [, texture] of Object.entries(this.bindings)) {\n // texture.update();\n if (texture.loaded !== undefined) {\n texturesRenderable = texturesRenderable && texture.loaded;\n }\n }\n\n return texturesRenderable;\n }\n\n /** Apply any bindings */\n _applyBindings() {\n this.device.gl.useProgram(this.handle);\n\n const {gl2} = this.device;\n if (!gl2) {\n throw new Error('bindings');\n }\n\n let textureUnit = 0;\n let uniformBufferIndex = 0;\n for (const binding of this.layout.bindings) {\n const value = this.bindings[binding.name];\n if (!value) {\n throw new Error(`No value for binding ${binding.name} in ${this.id}`);\n }\n switch (binding.type) {\n case 'uniform':\n // Set buffer\n const {name} = binding;\n const location = gl2.getUniformBlockIndex(this.handle, name);\n if (location === GL.INVALID_INDEX) {\n throw new Error(`Invalid uniform block name ${name}`);\n }\n gl2.uniformBlockBinding(this.handle, uniformBufferIndex, location);\n // console.debug(binding, location);\n if (value instanceof WEBGLBuffer) {\n gl2.bindBufferBase(GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);\n } else {\n gl2.bindBufferRange(\n GL.UNIFORM_BUFFER,\n uniformBufferIndex,\n value.buffer.handle,\n value.offset || 0,\n value.size || value.buffer.byteLength - value.offset\n );\n }\n uniformBufferIndex += 1;\n break;\n\n case 'texture':\n if (!(value instanceof WEBGLTexture)) {\n throw new Error('texture');\n }\n const texture: WEBGLTexture = value;\n gl2.activeTexture(GL.TEXTURE0 + textureUnit);\n gl2.bindTexture(texture.target, texture.handle);\n // gl2.bindSampler(textureUnit, sampler.handle);\n textureUnit += 1;\n break;\n\n case 'sampler':\n // ignore\n break;\n\n case 'storage':\n case 'read-only-storage':\n throw new Error(`binding type '${binding.type}' not supported in WebGL`);\n }\n }\n }\n\n _applyUniforms() {\n for (const uniformLayout of this.layout.uniforms || []) {\n const {name, location, type, textureUnit} = uniformLayout;\n const value = this.uniforms[name] ?? textureUnit;\n if (value !== undefined) {\n setUniform(this.device.gl, location, type, value);\n }\n }\n }\n}\n\n/** Get the primitive type for transform feedback */\nfunction getDrawMode(\n topology: PrimitiveTopology\n): GL.POINTS | GL.LINES | GL.LINE_STRIP | GL.LINE_LOOP | GL.TRIANGLES | GL.TRIANGLE_STRIP | GL.TRIANGLE_FAN {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINE_STRIP;\n case 'line-loop': return GL.LINE_LOOP;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLE_STRIP;\n case 'triangle-fan': return GL.TRIANGLE_FAN;\n default: throw new Error(topology);\n }\n}\n\n/** Get the primitive type for transform feedback */\nfunction getGLPrimitive(topology: PrimitiveTopology): GL.POINTS | GL.LINES | GL.TRIANGLES {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINES;\n case 'line-loop': return GL.LINES;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLES;\n case 'triangle-fan': return GL.TRIANGLES;\n default: throw new Error(topology);\n }\n}\n\n// function getAttributesByLocation(\n// attributes: Record<string, Buffer>,\n// layout: ShaderLayout\n// ): Record<number, Buffer> {\n// const byLocation: Record<number, Buffer> = {};\n// for (const [name, buffer] of Object.entries(attributes)) {\n// const attribute = getAttributeLayout(layout, name);\n// if (attribute) {\n// byLocation[attribute.location] = buffer;\n// }\n// }\n// return byLocation;\n// }\n\nfunction getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout | null {\n return layout.attributes.find((binding) => binding.name === name) || null;\n}\n\n/* TODO\nfunction getBindingLayout(layout: ShaderLayout, name: string): BindingLayout {\n const binding = layout.bindings.find((binding) => binding.name === name);\n if (!binding) {\n throw new Error(`Unknown binding ${name}`);\n }\n return binding;\n}\n*/\n"],"mappings":";AAUA,SAAQA,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAEC,kBAAkB,QAAO,cAAc;AAC1E,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,gBAAgB;AAAA,SAChBC,eAAe;AAAA,SACfC,oBAAoB,EAAEC,gBAAgB;AAAA,SACtCC,UAAU;AAAA,SAIVC,WAAW;AAAA,SAEXC,YAAY;AAAA,SACZC,sBAAsB;AAG9B,MAAMC,yBAAyB,GAAG,CAAC;AAGnC,OAAO,MAAMC,mBAAmB,SAASd,cAAc,CAAC;EAmBtDe,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,mBAXK,IAAI;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,mBAGA,CAAC,CAAC;IAAAA,eAAA,mBACF,CAAC,CAAC;IAAAA,eAAA,2BACM,CAAC,CAAC;IAAAA,eAAA,+BACX,CAAC;IAAAA,eAAA,wBACR,CAAC;IAAAA,eAAA,0BACmB,CAAC,CAAC;IAI5C,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,MAAM,GAAG,IAAI,CAACF,KAAK,CAACE,MAAM,IAAI,IAAI,CAACH,MAAM,CAACI,EAAE,CAACC,aAAa,CAAC,CAAC;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E,CAACoJ,SAAS;IACxC;MAAS,MAAM,IAAI7E,KAAK,CAACa,QAAQ,CAAC;EACpC;AACF;AAgBA,SAASpC,kBAAkBA,CAACjB,MAAoB,EAAEY,IAAY,EAA0B;EACtF,OAAOZ,MAAM,CAACW,UAAU,CAAC4B,IAAI,CAAED,OAAO,IAAKA,OAAO,CAAC1B,IAAI,KAAKA,IAAI,CAAC,IAAI,IAAI;AAC3E"}
|
|
1
|
+
{"version":3,"file":"webgl-render-pipeline.js","names":["RenderPipeline","cast","log","decodeVertexFormat","GL","getWebGLDataType","getShaderLayout","withDeviceParameters","withGLParameters","setUniform","WEBGLBuffer","WEBGLTexture","WEBGLVertexArrayObject","LOG_PROGRAM_PERF_PRIORITY","WEBGLRenderPipeline","constructor","device","props","_defineProperty","handle","gl","createProgram","setSpectorMetadata","id","vs","fs","varyings","bufferMode","SEPARATE_ATTRIBS","length","_this$device$gl","assertWebGL2","gl2","transformFeedbackVaryings","_compileAndLink","layout","vertexArrayObject","destroy","deleteProgram","destroyed","setIndexBuffer","indexBuffer","webglBuffer","setElementBuffer","_indexBuffer","setAttributes","attributes","name","buffer","Object","entries","attribute","getAttributeLayout","warn","concat","decoded","format","type","typeString","components","size","byteLength","stride","normalized","integer","divisor","stepMode","setBuffer","location","offset","setConstantAttributes","value","setConstant","setBindings","bindings","binding","find","Error","setUniforms","uniforms","assign","draw","options","_this$_indexBuffer","renderPass","vertexCount","instanceCount","firstVertex","drawMode","getDrawMode","topology","isIndexed","Boolean","indexType","UNSIGNED_SHORT","UNSIGNED_INT","isInstanced","Number","_areTexturesRenderable","useProgram","bind","primitiveMode","getGLPrimitive","transformFeedback","begin","_applyBindings","_applyUniforms","webglRenderPass","parameters","glParameters","_this$device$gl2","drawElementsInstanced","drawElements","_this$device$gl3","drawArraysInstanced","drawArrays","end","attachShader","time","linkProgram","timeEnd","debug","level","linked","getProgramParameter","LINK_STATUS","getProgramInfoLog","validateProgram","validated","VALIDATE_STATUS","texturesRenderable","texture","_textureUniforms","update","loaded","undefined","textureUnit","uniformBufferIndex","getUniformBlockIndex","INVALID_INDEX","uniformBlockBinding","bindBufferBase","UNIFORM_BUFFER","bindBufferRange","activeTexture","TEXTURE0","bindTexture","target","uniformLayout","_this$uniforms$name","POINTS","LINES","LINE_STRIP","LINE_LOOP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN"],"sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"sourcesContent":["import type {\n RenderPipelineProps,\n RenderPass,\n Buffer,\n Binding,\n ShaderLayout,\n PrimitiveTopology,\n // BindingLayout,\n AttributeLayout,\n TypedArray\n} from '@luma.gl/api';\nimport {RenderPipeline, cast, log, decodeVertexFormat} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\n\nimport {getWebGLDataType} from '../converters/texture-formats';\nimport {getShaderLayout} from '../helpers/get-shader-layout';\nimport {withDeviceParameters, withGLParameters} from '../converters/device-parameters';\nimport {setUniform} from '../helpers/set-uniform';\n// import {copyUniform, checkUniformValues} from '../../classes/uniforms';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLShader} from './webgl-shader';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLVertexArrayObject} from '../objects/webgl-vertex-array-object';\nimport {WEBGLRenderPass} from './webgl-render-pass';\n\nconst LOG_PROGRAM_PERF_PRIORITY = 4;\n\n/** Creates a new render pipeline */\nexport class WEBGLRenderPipeline extends RenderPipeline {\n device: WebGLDevice;\n handle: WebGLProgram;\n vs: WEBGLShader;\n fs: WEBGLShader;\n layout: ShaderLayout;\n\n // configuration: ProgramConfiguration;\n // Experimental flag to avoid deleting Program object while it is cached\n varyings: string[] | null = null;\n vertexArrayObject: WEBGLVertexArrayObject;\n _indexBuffer?: Buffer;\n uniforms: Record<string, any> = {};\n bindings: Record<string, any> = {};\n _textureUniforms: Record<string, any> = {};\n _textureIndexCounter: number = 0;\n _uniformCount: number = 0;\n _uniformSetters: Record<string, Function> = {}; // TODO are these used?\n\n constructor(device: WebGLDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.gl.createProgram();\n this.device.setSpectorMetadata(this.handle, {id: this.props.id});\n\n // Create shaders if needed\n this.vs = cast<WEBGLShader>(props.vs);\n this.fs = cast<WEBGLShader>(props.fs);\n // assert(this.vs.stage === 'vertex');\n // assert(this.fs.stage === 'fragment');\n\n // Setup varyings if supplied\n // @ts-expect-error WebGL only\n const {varyings, bufferMode = GL.SEPARATE_ATTRIBS} = props;\n if (varyings && varyings.length > 0) {\n this.device.assertWebGL2();\n this.varyings = varyings;\n this.device.gl2?.transformFeedbackVaryings(this.handle, varyings, bufferMode);\n }\n\n this._compileAndLink();\n\n this.layout = props.layout || getShaderLayout(this.device.gl, this.handle);\n this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);\n }\n\n override destroy(): void {\n if (this.handle) {\n this.device.gl.deleteProgram(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n const webglBuffer = cast<WEBGLBuffer>(indexBuffer);\n this.vertexArrayObject.setElementBuffer(webglBuffer);\n this._indexBuffer = indexBuffer;\n }\n\n /** @todo needed for portable model */\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const webglBuffer = cast<WEBGLBuffer>(buffer);\n const attribute = getAttributeLayout(this.layout, name);\n if (!attribute) {\n log.warn(`Ignoring buffer supplied for unknown attribute \"${name}\" in pipeline \"${this.id}\" (buffer \"${buffer.id}\")`)();\n continue; // eslint-disable-line no-continue\n }\n const decoded = decodeVertexFormat(attribute.format);\n const {type: typeString, components: size, byteLength: stride, normalized, integer} = decoded;\n const divisor = attribute.stepMode === 'instance' ? 1 : 0;\n const type = getWebGLDataType(typeString);\n this.vertexArrayObject.setBuffer(attribute.location, webglBuffer, {\n size,\n type,\n stride,\n offset: 0,\n normalized,\n integer,\n divisor\n });\n }\n }\n\n /**\n * Constant attributes are only supported in WebGL, not in WebGPU\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @param attributes \n */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n for (const [name, value] of Object.entries(attributes)) {\n const attribute = getAttributeLayout(this.layout, name);\n if (!attribute) {\n log.warn(`Ignoring constant value supplied for unknown attribute \"${name}\" in pipeline \"${this.id}\"`)();\n continue; // eslint-disable-line no-continue\n }\n this.vertexArrayObject.setConstant(attribute.location, value);\n }\n }\n\n /** \n * Bindings include: textures, samplers and uniform buffers\n * @todo needed for portable model \n */\n setBindings(bindings: Record<string, Binding>): void {\n // if (log.priority >= 2) {\n // checkUniformValues(uniforms, this.id, this._uniformSetters);\n // }\n\n for (const [name, value] of Object.entries(bindings)) {\n const binding = this.layout.bindings.find((binding) => binding.name === name);\n if (!binding) {\n log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();\n continue; // eslint-disable-line no-continue\n }\n if (!value) {\n log.warn(`Unsetting binding ${name} in render pipeline ${this.id}`)();\n }\n switch (binding.type) {\n case 'uniform':\n // @ts-expect-error\n if (!(value instanceof WEBGLBuffer) && !(value.buffer instanceof WEBGLBuffer)) {\n throw new Error('buffer value');\n }\n break;\n case 'texture':\n if (!(value instanceof WEBGLTexture)) {\n throw new Error('texture value');\n }\n break;\n case 'sampler':\n log.warn(`Ignoring sampler ${name}`)();\n break;\n default:\n throw new Error(binding.type);\n }\n\n this.bindings[name] = value;\n }\n }\n\n setUniforms(uniforms: Record<string, any>) {\n // TODO - check against layout\n Object.assign(this.uniforms, uniforms);\n }\n\n /** @todo needed for portable model\n * @note The WebGL API is offers many ways to draw things\n * This function unifies those ways into a single call using common parameters with sane defaults\n */\n draw(options: {\n renderPass: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): boolean {\n const {\n renderPass,\n vertexCount,\n // indexCount,\n instanceCount,\n firstVertex = 0,\n // firstIndex,\n // firstInstance,\n // baseVertex\n } = options;\n\n const drawMode = getDrawMode(this.props.topology);\n const isIndexed: boolean = Boolean(this._indexBuffer);\n const indexType = this._indexBuffer?.props.indexType === 'uint16' ? GL.UNSIGNED_SHORT : GL.UNSIGNED_INT;\n const isInstanced: boolean = Number(options.instanceCount) > 0;\n\n // Avoid WebGL draw call when not rendering any data or values are incomplete\n // Note: async textures set as uniforms might still be loading.\n // Now that all uniforms have been updated, check if any texture\n // in the uniforms is not yet initialized, then we don't draw\n if (!this._areTexturesRenderable() || options.vertexCount === 0) {\n // (isInstanced && instanceCount === 0)\n return false;\n }\n\n this.device.gl.useProgram(this.handle);\n\n this.vertexArrayObject.bind(() => {\n const primitiveMode = getGLPrimitive(this.props.topology);\n const transformFeedback: any = null;\n if (transformFeedback) {\n transformFeedback.begin(primitiveMode);\n }\n\n // We have to apply bindings before every draw call since other draw calls will overwrite\n this._applyBindings();\n this._applyUniforms();\n\n const webglRenderPass = renderPass as WEBGLRenderPass;\n\n // TODO - double context push/pop\n withDeviceParameters(this.device, this.props.parameters, () => {\n withGLParameters(this.device, webglRenderPass.glParameters, () => {\n // TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension\n if (isIndexed && isInstanced) {\n // ANGLE_instanced_arrays extension\n this.device.gl2?.drawElementsInstanced(\n drawMode,\n vertexCount || 0, // indexCount?\n indexType,\n firstVertex,\n instanceCount || 0\n );\n // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {\n // this.device.gl2.drawRangeElements(drawMode, start, end, vertexCount, indexType, offset);\n } else if (isIndexed) {\n this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?\n } else if (isInstanced) {\n this.device.gl2?.drawArraysInstanced(drawMode, firstVertex, vertexCount || 0, instanceCount || 0);\n } else {\n this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);\n }\n });\n\n if (transformFeedback) {\n transformFeedback.end();\n }\n });\n });\n\n return true;\n }\n\n // setAttributes(attributes: Record<string, Buffer>): void {}\n // setBindings(bindings: Record<string, Binding>): void {}\n\n protected _compileAndLink() {\n const {gl} = this.device;\n gl.attachShader(this.handle, this.vs.handle);\n gl.attachShader(this.handle, this.fs.handle);\n log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n gl.linkProgram(this.handle);\n log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n\n // Avoid checking program linking error in production\n // @ts-expect-error\n if (gl.debug || log.level > 0) {\n const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);\n if (!linked) {\n throw new Error(`Error linking: ${gl.getProgramInfoLog(this.handle)}`);\n }\n\n gl.validateProgram(this.handle);\n const validated = gl.getProgramParameter(this.handle, gl.VALIDATE_STATUS);\n if (!validated) {\n throw new Error(`Error validating: ${gl.getProgramInfoLog(this.handle)}`);\n }\n }\n }\n\n // PRIVATE METHODS\n\n /**\n * Checks if all texture-values uniforms are renderable (i.e. loaded)\n * Update a texture if needed (e.g. from video)\n * Note: This is currently done before every draw call\n */\n _areTexturesRenderable() {\n let texturesRenderable = true;\n\n for (const [, texture] of Object.entries(this._textureUniforms)) {\n texture.update();\n texturesRenderable = texturesRenderable && texture.loaded;\n }\n\n for (const [, texture] of Object.entries(this.bindings)) {\n // texture.update();\n if (texture.loaded !== undefined) {\n texturesRenderable = texturesRenderable && texture.loaded;\n }\n }\n\n return texturesRenderable;\n }\n\n /** Apply any bindings */\n _applyBindings() {\n this.device.gl.useProgram(this.handle);\n\n const {gl2} = this.device;\n if (!gl2) {\n throw new Error('bindings');\n }\n\n let textureUnit = 0;\n let uniformBufferIndex = 0;\n for (const binding of this.layout.bindings) {\n const value = this.bindings[binding.name];\n if (!value) {\n throw new Error(`No value for binding ${binding.name} in ${this.id}`);\n }\n switch (binding.type) {\n case 'uniform':\n // Set buffer\n const {name} = binding;\n const location = gl2.getUniformBlockIndex(this.handle, name);\n if (location === GL.INVALID_INDEX) {\n throw new Error(`Invalid uniform block name ${name}`);\n }\n gl2.uniformBlockBinding(this.handle, uniformBufferIndex, location);\n // console.debug(binding, location);\n if (value instanceof WEBGLBuffer) {\n gl2.bindBufferBase(GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);\n } else {\n gl2.bindBufferRange(\n GL.UNIFORM_BUFFER,\n uniformBufferIndex,\n value.buffer.handle,\n value.offset || 0,\n value.size || value.buffer.byteLength - value.offset\n );\n }\n uniformBufferIndex += 1;\n break;\n\n case 'texture':\n if (!(value instanceof WEBGLTexture)) {\n throw new Error('texture');\n }\n const texture: WEBGLTexture = value;\n gl2.activeTexture(GL.TEXTURE0 + textureUnit);\n gl2.bindTexture(texture.target, texture.handle);\n // gl2.bindSampler(textureUnit, sampler.handle);\n textureUnit += 1;\n break;\n\n case 'sampler':\n // ignore\n break;\n\n case 'storage':\n case 'read-only-storage':\n throw new Error(`binding type '${binding.type}' not supported in WebGL`);\n }\n }\n }\n\n _applyUniforms() {\n for (const uniformLayout of this.layout.uniforms || []) {\n const {name, location, type, textureUnit} = uniformLayout;\n const value = this.uniforms[name] ?? textureUnit;\n if (value !== undefined) {\n setUniform(this.device.gl, location, type, value);\n }\n }\n }\n}\n\n/** Get the primitive type for transform feedback */\nfunction getDrawMode(\n topology: PrimitiveTopology\n): GL.POINTS | GL.LINES | GL.LINE_STRIP | GL.LINE_LOOP | GL.TRIANGLES | GL.TRIANGLE_STRIP | GL.TRIANGLE_FAN {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINE_STRIP;\n case 'line-loop': return GL.LINE_LOOP;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLE_STRIP;\n case 'triangle-fan': return GL.TRIANGLE_FAN;\n default: throw new Error(topology);\n }\n}\n\n/** Get the primitive type for transform feedback */\nfunction getGLPrimitive(topology: PrimitiveTopology): GL.POINTS | GL.LINES | GL.TRIANGLES {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINES;\n case 'line-loop': return GL.LINES;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLES;\n case 'triangle-fan': return GL.TRIANGLES;\n default: throw new Error(topology);\n }\n}\n\n// function getAttributesByLocation(\n// attributes: Record<string, Buffer>,\n// layout: ShaderLayout\n// ): Record<number, Buffer> {\n// const byLocation: Record<number, Buffer> = {};\n// for (const [name, buffer] of Object.entries(attributes)) {\n// const attribute = getAttributeLayout(layout, name);\n// if (attribute) {\n// byLocation[attribute.location] = buffer;\n// }\n// }\n// return byLocation;\n// }\n\nfunction getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout | null {\n return layout.attributes.find((binding) => binding.name === name) || null;\n}\n\n/* TODO\nfunction getBindingLayout(layout: ShaderLayout, name: string): BindingLayout {\n const binding = layout.bindings.find((binding) => binding.name === name);\n if (!binding) {\n throw new Error(`Unknown binding ${name}`);\n }\n return binding;\n}\n*/\n"],"mappings":";AAWA,SAAQA,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAEC,kBAAkB,QAAO,cAAc;AAC1E,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,gBAAgB;AAAA,SAChBC,eAAe;AAAA,SACfC,oBAAoB,EAAEC,gBAAgB;AAAA,SACtCC,UAAU;AAAA,SAIVC,WAAW;AAAA,SAEXC,YAAY;AAAA,SACZC,sBAAsB;AAG9B,MAAMC,yBAAyB,GAAG,CAAC;AAGnC,OAAO,MAAMC,mBAAmB,SAASd,cAAc,CAAC;EAmBtDe,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,mBAX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