@luma.gl/webgl 9.0.0-alpha.30 → 9.0.0-alpha.31

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.
Files changed (59) hide show
  1. package/dist/adapter/converters/shader-formats.d.ts +9 -0
  2. package/dist/adapter/converters/shader-formats.d.ts.map +1 -0
  3. package/dist/adapter/converters/shader-formats.js +53 -0
  4. package/dist/adapter/converters/shader-formats.js.map +1 -0
  5. package/dist/adapter/converters/texture-formats.d.ts +1 -2
  6. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  7. package/dist/adapter/converters/texture-formats.js +2 -23
  8. package/dist/adapter/converters/texture-formats.js.map +1 -1
  9. package/dist/adapter/converters/vertex-formats.d.ts +8 -2
  10. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  11. package/dist/adapter/converters/vertex-formats.js +47 -9
  12. package/dist/adapter/converters/vertex-formats.js.map +1 -1
  13. package/dist/adapter/helpers/{uniforms.d.ts → decode-webgl-types.d.ts} +9 -8
  14. package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -0
  15. package/dist/adapter/helpers/{uniforms.js → decode-webgl-types.js} +14 -13
  16. package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
  17. package/dist/adapter/helpers/get-shader-layout.d.ts +1 -51
  18. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  19. package/dist/adapter/helpers/get-shader-layout.js +14 -86
  20. package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
  21. package/dist/adapter/helpers/{attribute-utils.d.ts → webgl-topology-utils.d.ts} +1 -1
  22. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -0
  23. package/dist/adapter/helpers/{attribute-utils.js → webgl-topology-utils.js} +1 -1
  24. package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
  25. package/dist/adapter/objects/webgl-vertex-array-object.d.ts +2 -1
  26. package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
  27. package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  28. package/dist/adapter/resources/webgl-command-encoder.js +1 -1
  29. package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
  30. package/dist/adapter/resources/webgl-render-pipeline.d.ts +14 -9
  31. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  32. package/dist/adapter/resources/webgl-render-pipeline.js +58 -59
  33. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  34. package/dist/dist.dev.js +478 -391
  35. package/dist/index.cjs +641 -695
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/types.d.ts +2 -0
  41. package/dist/types.d.ts.map +1 -1
  42. package/dist/types.js.map +1 -1
  43. package/dist.min.js +22 -22
  44. package/package.json +5 -5
  45. package/src/adapter/converters/shader-formats.ts +41 -0
  46. package/src/adapter/converters/texture-formats.ts +3 -16
  47. package/src/adapter/converters/vertex-formats.ts +67 -10
  48. package/src/adapter/helpers/{uniforms.ts → decode-webgl-types.ts} +22 -17
  49. package/src/adapter/helpers/get-shader-layout.ts +51 -159
  50. package/src/adapter/objects/webgl-vertex-array-object.ts +2 -1
  51. package/src/adapter/resources/webgl-command-encoder.ts +1 -1
  52. package/src/adapter/resources/webgl-render-pipeline.ts +121 -77
  53. package/src/index.ts +1 -1
  54. package/src/types.ts +2 -0
  55. package/dist/adapter/helpers/attribute-utils.d.ts.map +0 -1
  56. package/dist/adapter/helpers/attribute-utils.js.map +0 -1
  57. package/dist/adapter/helpers/uniforms.d.ts.map +0 -1
  58. package/dist/adapter/helpers/uniforms.js.map +0 -1
  59. /package/src/adapter/helpers/{attribute-utils.ts → webgl-topology-utils.ts} +0 -0
@@ -5,16 +5,18 @@ import type {
5
5
  Binding,
6
6
  ShaderLayout,
7
7
  PrimitiveTopology,
8
- // BindingLayout,
9
- AttributeLayout,
10
8
  TypedArray,
11
- BufferMapping
9
+ BufferLayout
10
+ } from '@luma.gl/core';
11
+ import {RenderPipeline, cast, log} from '@luma.gl/core';
12
+ import {
13
+ mergeShaderLayout,
14
+ getAttributeInfosFromLayouts
12
15
  } from '@luma.gl/core';
13
- import {RenderPipeline, cast, log, decodeVertexFormat} from '@luma.gl/core';
14
16
  import {GL} from '@luma.gl/constants';
15
17
 
16
- import {getWebGLDataType} from '../converters/texture-formats';
17
- import {getShaderLayout, mergeShaderLayout, mergeBufferMap} from '../helpers/get-shader-layout';
18
+ import {getGLFromVertexType} from '../converters/vertex-formats';
19
+ import {getShaderLayout} from '../helpers/get-shader-layout';
18
20
  import {withDeviceParameters, withGLParameters} from '../converters/device-parameters';
19
21
  import {setUniform} from '../helpers/set-uniform';
20
22
  // import {copyUniform, checkUniformValues} from '../../classes/uniforms';
@@ -38,12 +40,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
38
40
  vs: WEBGLShader;
39
41
  /** fragment shader */
40
42
  fs: WEBGLShader;
41
- /** The merged layout */
42
- layout: ShaderLayout;
43
43
  /** The layout extracted from shader by WebGL introspection APIs */
44
44
  introspectedLayout: ShaderLayout;
45
+ /** The merged layout */
46
+ shaderLayout: ShaderLayout;
45
47
  /** Buffer map describing buffer interleaving etc */
46
- bufferMap: BufferMapping[];
48
+ bufferLayout: BufferLayout[];
47
49
 
48
50
  /** Uniforms set on this model */
49
51
  uniforms: Record<string, any> = {};
@@ -89,10 +91,10 @@ export class WEBGLRenderPipeline extends RenderPipeline {
89
91
 
90
92
  this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
91
93
  // Merge provided layout with introspected layout
92
- this.layout = mergeShaderLayout(this.introspectedLayout, props.layout);
94
+ this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
93
95
  // Merge layout with any buffer map overrides
94
- this.bufferMap = props.bufferMap || [];
95
- this.layout = mergeBufferMap(this.layout, this.bufferMap);
96
+ this.bufferLayout = props.bufferLayout || [];
97
+ // this.shaderLayout = mergeBufferMap(this.shaderLayout, this.bufferLayout);
96
98
  this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);
97
99
  }
98
100
 
@@ -110,33 +112,56 @@ export class WEBGLRenderPipeline extends RenderPipeline {
110
112
  this._indexBuffer = webglBuffer;
111
113
  }
112
114
 
115
+
113
116
  /** @todo needed for portable model */
114
- setAttributes(attributes: Record<string, Buffer>): void {
115
- for (const [name, buffer] of Object.entries(attributes)) {
116
- const webglBuffer = cast<WEBGLBuffer>(buffer);
117
- const attribute = getAttributeLayout(this.layout, name);
118
- if (!attribute) {
119
- log.warn(`Ignoring buffer supplied for unknown attribute "${name}" in pipeline "${this.id}" (buffer "${buffer.id}")`)();
120
- continue; // eslint-disable-line no-continue
117
+ setAttributes(buffers: Record<string, Buffer>): void {
118
+ const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);
119
+
120
+ for (const [bufferName, buffer] of Object.entries(buffers)) {
121
+ let set = false;
122
+ for (const attributeInfo of Object.values(attributeInfos)) {
123
+ if (attributeInfo.bufferName !== bufferName) {
124
+ continue; // eslint-disable-line no-continue
125
+ }
126
+ const webglBuffer = cast<WEBGLBuffer>(buffer);
127
+
128
+ const glType = getGLFromVertexType(attributeInfo.bufferDataType);
129
+ // TODO remove when we have more confidence
130
+ log.log(1, {
131
+ setAttribute: attributeInfo.name,
132
+ toBuffer: bufferName,
133
+ size: attributeInfo.bufferComponents,
134
+ type: glType,
135
+ stride: attributeInfo.byteStride,
136
+ offset: attributeInfo.byteOffset,
137
+ normalized: attributeInfo.normalized,
138
+ // it is the shader attribute declaration, not the vertex memory format,
139
+ // that determines if the data in the buffer will be treated as integers.
140
+ // /
141
+ // Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
142
+ // but as far as we can tell, WebGPU does not.
143
+ integer: attributeInfo.integer,
144
+ divisor: attributeInfo.stepMode === 'instance' ? 1 : 0
145
+ })();
146
+ this.vertexArrayObject.setBuffer(attributeInfo.location, webglBuffer, {
147
+ size: attributeInfo.bufferComponents,
148
+ type: glType,
149
+ stride: attributeInfo.byteStride,
150
+ offset: attributeInfo.byteOffset,
151
+ normalized: attributeInfo.normalized,
152
+ // it is the shader attribute declaration, not the vertex memory format,
153
+ // that determines if the data in the buffer will be treated as integers.
154
+ // /
155
+ // Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
156
+ // but as far as we can tell, WebGPU does not.
157
+ integer: attributeInfo.integer,
158
+ divisor: attributeInfo.stepMode === 'instance' ? 1 : 0
159
+ });
160
+ set = true;
161
+ }
162
+ if (!set) {
163
+ log.warn(`setAttributes(): Ignoring (buffer "${buffer.id}" for unknown attribute "${name}" in pipeline "${this.id}"`)();
121
164
  }
122
- const decoded = decodeVertexFormat(attribute.format);
123
- const {type: typeString, components: size, byteLength: stride, normalized /* , integer*/} = decoded;
124
- const divisor = attribute.stepMode === 'instance' ? 1 : 0;
125
- const type = getWebGLDataType(typeString);
126
- this.vertexArrayObject.setBuffer(attribute.location, webglBuffer, {
127
- size,
128
- type,
129
- stride,
130
- offset: 0,
131
- normalized,
132
- // it is the shader attribute declaration, not the vertex memory format,
133
- // that determines if the data in the buffer will be treated as integers.
134
- // /
135
- // Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
136
- // but as far as we can tell, WebGPU does not.
137
- integer: false,
138
- divisor
139
- });
140
165
  }
141
166
  }
142
167
 
@@ -144,23 +169,26 @@ export class WEBGLRenderPipeline extends RenderPipeline {
144
169
  * Constant attributes are only supported in WebGL, not in WebGPU
145
170
  * Any attribute that is disabled in the current vertex array object
146
171
  * is read from the context's global constant value for that attribute location.
147
- * @param attributes
172
+ * @param attributes
148
173
  */
149
174
  setConstantAttributes(attributes: Record<string, TypedArray>): void {
150
- for (const [name, value] of Object.entries(attributes)) {
151
- const attribute = getAttributeLayout(this.layout, name);
152
- if (!attribute) {
153
- log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
154
- continue; // eslint-disable-line no-continue
155
- }
156
- this.vertexArrayObject.setConstant(attribute.location, value);
157
- }
175
+ // TODO - there should be no advantage to setting these here vs in _applyConstantAttributes
176
+ // for (const [name, value] of Object.entries(attributes)) {
177
+ // const attributeInfo = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout, name);
178
+ // if (!attributeInfo) {
179
+ // log.warn(
180
+ // `Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`
181
+ // )();
182
+ // continue; // eslint-disable-line no-continue
183
+ // }
184
+ // this.vertexArrayObject.setConstant(attributeInfo.location, value);
185
+ // }
158
186
  Object.assign(this.constantAttributes, attributes);
159
187
  }
160
188
 
161
- /**
189
+ /**
162
190
  * Bindings include: textures, samplers and uniform buffers
163
- * @todo needed for portable model
191
+ * @todo needed for portable model
164
192
  */
165
193
  setBindings(bindings: Record<string, Binding>): void {
166
194
  // if (log.priority >= 2) {
@@ -168,7 +196,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
168
196
  // }
169
197
 
170
198
  for (const [name, value] of Object.entries(bindings)) {
171
- const binding = this.layout.bindings.find((binding) => binding.name === name);
199
+ const binding = this.shaderLayout.bindings.find(binding => binding.name === name);
172
200
  if (!binding) {
173
201
  log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();
174
202
  continue; // eslint-disable-line no-continue
@@ -223,13 +251,13 @@ export class WEBGLRenderPipeline extends RenderPipeline {
223
251
  vertexCount,
224
252
  // indexCount,
225
253
  instanceCount,
226
- firstVertex = 0,
254
+ firstVertex = 0
227
255
  // firstIndex,
228
256
  // firstInstance,
229
257
  // baseVertex
230
258
  } = options;
231
259
 
232
- const drawMode = getDrawMode(this.props.topology);
260
+ const drawMode = getGLDrawMode(this.props.topology);
233
261
  const isIndexed: boolean = Boolean(this._indexBuffer);
234
262
  const indexType = this._indexBuffer?.glIndexType;
235
263
  const isInstanced: boolean = Number(options.instanceCount) > 0;
@@ -277,7 +305,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
277
305
  } else if (isIndexed) {
278
306
  this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?
279
307
  } else if (isInstanced) {
280
- this.device.gl2?.drawArraysInstanced(drawMode, firstVertex, vertexCount || 0, instanceCount || 0);
308
+ this.device.gl2?.drawArraysInstanced(
309
+ drawMode,
310
+ firstVertex,
311
+ vertexCount || 0,
312
+ instanceCount || 0
313
+ );
281
314
  } else {
282
315
  this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);
283
316
  }
@@ -344,7 +377,27 @@ export class WEBGLRenderPipeline extends RenderPipeline {
344
377
  return texturesRenderable;
345
378
  }
346
379
 
347
- /** Apply any bindings */
380
+ /**
381
+ * Constant attributes need to be reset before every draw call
382
+ * Any attribute that is disabled in the current vertex array object
383
+ * is read from the context's global constant value for that attribute location.
384
+ * @note Constant attributes are only supported in WebGL, not in WebGPU
385
+ */
386
+ _applyConstantAttributes(): void {
387
+ const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);
388
+ for (const [name, value] of Object.entries(this.constantAttributes)) {
389
+ const attributeInfo = attributeInfos[name];
390
+ if (!attributeInfo) {
391
+ log.warn(
392
+ `Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`
393
+ )();
394
+ continue; // eslint-disable-line no-continue
395
+ }
396
+ this.vertexArrayObject.setConstant(attributeInfo.location, value);
397
+ }
398
+ }
399
+
400
+ /** Apply any bindings (before each draw call) */
348
401
  _applyBindings() {
349
402
  this.device.gl.useProgram(this.handle);
350
403
 
@@ -355,7 +408,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
355
408
 
356
409
  let textureUnit = 0;
357
410
  let uniformBufferIndex = 0;
358
- for (const binding of this.layout.bindings) {
411
+ for (const binding of this.shaderLayout.bindings) {
359
412
  const value = this.bindings[binding.name];
360
413
  if (!value) {
361
414
  throw new Error(`No value for binding ${binding.name} in ${this.id}`);
@@ -406,8 +459,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
406
459
  }
407
460
  }
408
461
 
462
+ /**
463
+ * Due to program sharing, uniforms need to be reset before every draw call
464
+ * (though caching will avoid redundant WebGL calls)
465
+ */
409
466
  _applyUniforms() {
410
- for (const uniformLayout of this.layout.uniforms || []) {
467
+ for (const uniformLayout of this.shaderLayout.uniforms || []) {
411
468
  const {name, location, type, textureUnit} = uniformLayout;
412
469
  const value = this.uniforms[name] ?? textureUnit;
413
470
  if (value !== undefined) {
@@ -415,28 +472,19 @@ export class WEBGLRenderPipeline extends RenderPipeline {
415
472
  }
416
473
  }
417
474
  }
418
-
419
- /**
420
- * Constant attributes are only supported in WebGL, not in WebGPU
421
- * Any attribute that is disabled in the current vertex array object
422
- * is read from the context's global constant value for that attribute location.
423
- */
424
- _applyConstantAttributes(): void {
425
- for (const [name, value] of Object.entries(this.constantAttributes)) {
426
- const attribute = getAttributeLayout(this.layout, name);
427
- if (!attribute) {
428
- log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
429
- continue; // eslint-disable-line no-continue
430
- }
431
- this.vertexArrayObject.setConstant(attribute.location, value);
432
- }
433
- }
434
475
  }
435
476
 
436
477
  /** Get the primitive type for draw */
437
- function getDrawMode(
478
+ function getGLDrawMode(
438
479
  topology: PrimitiveTopology
439
- ): GL.POINTS | GL.LINES | GL.LINE_STRIP | GL.LINE_LOOP | GL.TRIANGLES | GL.TRIANGLE_STRIP | GL.TRIANGLE_FAN {
480
+ ):
481
+ | GL.POINTS
482
+ | GL.LINES
483
+ | GL.LINE_STRIP
484
+ | GL.LINE_LOOP
485
+ | GL.TRIANGLES
486
+ | GL.TRIANGLE_STRIP
487
+ | GL.TRIANGLE_FAN {
440
488
  // prettier-ignore
441
489
  switch (topology) {
442
490
  case 'point-list': return GL.POINTS;
@@ -464,7 +512,3 @@ function getGLPrimitive(topology: PrimitiveTopology): GL.POINTS | GL.LINES | GL.
464
512
  default: throw new Error(topology);
465
513
  }
466
514
  }
467
-
468
- function getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout | null {
469
- return layout.attributes.find((binding) => binding.name === name) || null;
470
- }
package/src/index.ts CHANGED
@@ -73,7 +73,7 @@ export {
73
73
  export {polyfillContext} from './context/polyfill/polyfill-context';
74
74
 
75
75
  // HELPERS - EXPERIMENTAL
76
- export {getShaderLayout, mergeShaderLayout} from './adapter/helpers/get-shader-layout';
76
+ export {getShaderLayout} from './adapter/helpers/get-shader-layout';
77
77
  export {convertGLToTextureFormat, _checkFloat32ColorAttachment} from './adapter/converters/texture-formats';
78
78
 
79
79
  // TEST EXPORTS
package/src/types.ts CHANGED
@@ -5,4 +5,6 @@ export type AccessorObject = {
5
5
  divisor?: number;
6
6
  offset?: number;
7
7
  stride?: number;
8
+ normalized?: boolean;
9
+ integer?: boolean;
8
10
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"attribute-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/attribute-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,mBAAmB,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAGxE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,WAAW,CAmB/E;AAGD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IAAC,QAAQ,EAAE,mBAAmB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,GAAG,MAAM,CAkBvG;AAGD,wBAAgB,cAAc,CAAC,OAAO,EAAE;IAAC,QAAQ,EAAE,mBAAmB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,GAAG,MAAM,CAapG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attribute-utils.js","names":["GL","getPrimitiveDrawMode","drawMode","POINTS","LINES","LINE_STRIP","LINE_LOOP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN","Error","getPrimitiveCount","options","vertexCount","getVertexCount","primitiveCount"],"sources":["../../../src/adapter/helpers/attribute-utils.ts"],"sourcesContent":["import {GL, GLPrimitiveTopology, GLPrimitive} from '@luma.gl/constants';\n\n// Counts the number of complete primitives given a number of vertices and a drawMode\nexport function getPrimitiveDrawMode(drawMode: GLPrimitiveTopology): GLPrimitive {\n switch (drawMode) {\n case GL.POINTS:\n return GL.POINTS;\n case GL.LINES:\n return GL.LINES;\n case GL.LINE_STRIP:\n return GL.LINES;\n case GL.LINE_LOOP:\n return GL.LINES;\n case GL.TRIANGLES:\n return GL.TRIANGLES;\n case GL.TRIANGLE_STRIP:\n return GL.TRIANGLES;\n case GL.TRIANGLE_FAN:\n return GL.TRIANGLES;\n default:\n throw new Error('drawMode');\n }\n}\n\n// Counts the number of complete \"primitives\" given a number of vertices and a drawMode\nexport function getPrimitiveCount(options: {drawMode: GLPrimitiveTopology, vertexCount: number}): number {\n const {drawMode, vertexCount} = options;\n switch (drawMode) {\n case GL.POINTS:\n case GL.LINE_LOOP:\n return vertexCount;\n case GL.LINES:\n return vertexCount / 2;\n case GL.LINE_STRIP:\n return vertexCount - 1;\n case GL.TRIANGLES:\n return vertexCount / 3;\n case GL.TRIANGLE_STRIP:\n case GL.TRIANGLE_FAN:\n return vertexCount - 2;\n default:\n throw new Error('drawMode');\n }\n}\n\n// Counts the number of vertices after splitting the vertex stream into separate \"primitives\"\nexport function getVertexCount(options: {drawMode: GLPrimitiveTopology, vertexCount: number}): number {\n const {drawMode, vertexCount} = options;\n const primitiveCount = getPrimitiveCount({drawMode, vertexCount});\n switch (getPrimitiveDrawMode(drawMode)) {\n case GL.POINTS:\n return primitiveCount;\n case GL.LINES:\n return primitiveCount * 2;\n case GL.TRIANGLES:\n return primitiveCount * 3;\n default:\n throw new Error('drawMode');\n }\n}\n"],"mappings":"AAAA,SAAQA,EAAE,QAAyC,oBAAoB;AAGvE,OAAO,SAASC,oBAAoBA,CAACC,QAA6B,EAAe;EAC/E,QAAQA,QAAQ;IACd,KAAKF,EAAE,CAACG,MAAM;MACZ,OAAOH,EAAE,CAACG,MAAM;IAClB,KAAKH,EAAE,CAACI,KAAK;MACX,OAAOJ,EA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ACI,KAAK;MACX,OAAOW,cAAc,GAAG,CAAC;IAC3B,KAAKf,EAAE,CAACO,SAAS;MACf,OAAOQ,cAAc,GAAG,CAAC;IAC3B;MACE,MAAM,IAAIL,KAAK,CAAC,UAAU,CAAC;EAC/B;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"uniforms.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/uniforms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,EAAE,EAAE,aAAa,EAAiB,eAAe,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAEjG,0CAA0C;AAC1C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAE7D;AA0DD,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,EAAE,GACd;IAAC,MAAM,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAC,CAOjE;AAED,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,EAAE,GAAG;IACtD,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;CACpB,CAOA;AAED,0FAA0F;AAC1F,wBAAgB,4BAA4B,CAC1C,mBAAmB,EAAE,eAAe,GACnC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAO/C;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,EAAE,EAAE,UAAU,KAAA,GAAG;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAkBtG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"uniforms.js","names":["GL","isSamplerUniform","type","SAMPLER_TYPES","includes","SAMPLER_2D","SAMPLER_CUBE","SAMPLER_3D","SAMPLER_2D_SHADOW","SAMPLER_2D_ARRAY","SAMPLER_2D_ARRAY_SHADOW","SAMPLER_CUBE_SHADOW","INT_SAMPLER_2D","INT_SAMPLER_3D","INT_SAMPLER_CUBE","INT_SAMPLER_2D_ARRAY","UNSIGNED_INT_SAMPLER_2D","UNSIGNED_INT_SAMPLER_3D","UNSIGNED_INT_SAMPLER_CUBE","UNSIGNED_INT_SAMPLER_2D_ARRAY","COMPOSITE_GL_TYPES","FLOAT","FLOAT_VEC2","FLOAT_VEC3","FLOAT_VEC4","INT","INT_VEC2","INT_VEC3","INT_VEC4","UNSIGNED_INT","UNSIGNED_INT_VEC2","UNSIGNED_INT_VEC3","UNSIGNED_INT_VEC4","BOOL","BOOL_VEC2","BOOL_VEC3","BOOL_VEC4","FLOAT_MAT2","FLOAT_MAT2x3","FLOAT_MAT2x4","FLOAT_MAT3x2","FLOAT_MAT3","FLOAT_MAT3x4","FLOAT_MAT4x2","FLOAT_MAT4x3","FLOAT_MAT4","decodeUniformType","uniformType","typeAndSize","Error","glType","components","format","decodeAttributeType","attributeType","decomposeCompositeGLDataType","compositeGLDataType","getCompositeGLDataType","BYTE","UNSIGNED_BYTE","SHORT","UNSIGNED_SHORT","compType","compComponents","name","Number"],"sources":["../../../src/adapter/helpers/uniforms.ts"],"sourcesContent":["import {UniformFormat, VertexFormat} from '@luma.gl/core';\nimport {GL, GLUniformType, GLSamplerType, GLCompositeType, GLDataType} from '@luma.gl/constants';\n\n/** Check is uniform is of sampler type */\nexport function isSamplerUniform(type: GLUniformType): boolean {\n return SAMPLER_TYPES.includes(type as GLSamplerType);\n}\n\nconst SAMPLER_TYPES: GLSamplerType[] = [\n GL.SAMPLER_2D,\n GL.SAMPLER_CUBE,\n GL.SAMPLER_3D,\n GL.SAMPLER_2D_SHADOW,\n GL.SAMPLER_2D_ARRAY,\n GL.SAMPLER_2D_ARRAY_SHADOW,\n GL.SAMPLER_CUBE_SHADOW,\n GL.INT_SAMPLER_2D,\n GL.INT_SAMPLER_3D,\n GL.INT_SAMPLER_CUBE,\n GL.INT_SAMPLER_2D_ARRAY,\n GL.UNSIGNED_INT_SAMPLER_2D,\n GL.UNSIGNED_INT_SAMPLER_3D,\n GL.UNSIGNED_INT_SAMPLER_CUBE,\n GL.UNSIGNED_INT_SAMPLER_2D_ARRAY\n];\n\n// Composite types table\nconst COMPOSITE_GL_TYPES: Record<\n GLCompositeType,\n [GLDataType, number, string, UniformFormat, VertexFormat?]\n> = {\n [GL.FLOAT]: [GL.FLOAT, 1, 'float', 'f32', 'float32'],\n [GL.FLOAT_VEC2]: [GL.FLOAT, 2, 'vec2', 'vec2<f32>', 'float32x2'],\n [GL.FLOAT_VEC3]: [GL.FLOAT, 3, 'vec3', 'vec3<f32>', 'float32x3'],\n [GL.FLOAT_VEC4]: [GL.FLOAT, 4, 'vec4', 'vec4<f32>', 'float32x4'],\n\n [GL.INT]: [GL.INT, 1, 'int', 'i32', 'sint32'],\n [GL.INT_VEC2]: [GL.INT, 2, 'ivec2', 'vec2<i32>', 'sint32x2'],\n [GL.INT_VEC3]: [GL.INT, 3, 'ivec3', 'vec3<i32>', 'sint32x3'],\n [GL.INT_VEC4]: [GL.INT, 4, 'ivec4', 'vec4<i32>', 'sint32x4'],\n\n [GL.UNSIGNED_INT]: [GL.UNSIGNED_INT, 1, 'uint', 'u32', 'uint32'],\n [GL.UNSIGNED_INT_VEC2]: [GL.UNSIGNED_INT, 2, 'uvec2', 'vec2<u32>', 'uint32x2'],\n [GL.UNSIGNED_INT_VEC3]: [GL.UNSIGNED_INT, 3, 'uvec3', 'vec3<u32>', 'uint32x3'],\n [GL.UNSIGNED_INT_VEC4]: [GL.UNSIGNED_INT, 4, 'uvec4', 'vec4<u32>', 'uint32x4'],\n\n [GL.BOOL]: [GL.FLOAT, 1, 'bool', 'f32', 'float32x2'],\n [GL.BOOL_VEC2]: [GL.FLOAT, 2, 'bvec2', 'vec2<f32>'],\n [GL.BOOL_VEC3]: [GL.FLOAT, 3, 'bvec3', 'vec3<f32>'],\n [GL.BOOL_VEC4]: [GL.FLOAT, 4, 'bvec4', 'vec4<f32>'],\n\n [GL.FLOAT_MAT2]: [GL.FLOAT, 8, 'mat2', 'mat2x2<f32>'], // 4\n [GL.FLOAT_MAT2x3]: [GL.FLOAT, 8, 'mat2x3', 'mat2x3<f32>'], // 6\n [GL.FLOAT_MAT2x4]: [GL.FLOAT, 8, 'mat2x4', 'mat2x4<f32>'], // 8\n\n [GL.FLOAT_MAT3x2]: [GL.FLOAT, 12, 'mat3x2', 'mat3x2<f32>'], // 6\n [GL.FLOAT_MAT3]: [GL.FLOAT, 12, 'mat3', 'mat3x3<f32>'], // 9\n [GL.FLOAT_MAT3x4]: [GL.FLOAT, 12, 'mat3x4', 'mat3x4<f32>'], // 12\n\n [GL.FLOAT_MAT4x2]: [GL.FLOAT, 16, 'mat4x2', 'mat4x2<f32>'], // 8\n [GL.FLOAT_MAT4x3]: [GL.FLOAT, 16, 'mat4x3', 'mat4x3<f32>'], // 12\n [GL.FLOAT_MAT4]: [GL.FLOAT, 16, 'mat4', 'mat4x4<f32>'] // 16\n};\n\n/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */\nexport function decodeUniformType(\n uniformType: GL\n): {format: UniformFormat; components: number; glType: GLDataType} {\n const typeAndSize = COMPOSITE_GL_TYPES[uniformType];\n if (!typeAndSize) {\n throw new Error('uniform');\n }\n const [glType, components, , format] = typeAndSize;\n return {format, components, glType};\n}\n\nexport function decodeAttributeType(attributeType: GL): {\n format: VertexFormat;\n components: number;\n glType: GLDataType;\n} {\n const typeAndSize = COMPOSITE_GL_TYPES[attributeType];\n if (!typeAndSize) {\n throw new Error('attribute')\n }\n const [glType, components, , , format] = typeAndSize;\n return {format, components, glType};\n}\n\n/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */\nexport function decomposeCompositeGLDataType(\n compositeGLDataType: GLCompositeType\n): {type: GLDataType; components: number} | null {\n const typeAndSize = COMPOSITE_GL_TYPES[compositeGLDataType];\n if (!typeAndSize) {\n return null;\n }\n const [type, components] = typeAndSize;\n return {type, components};\n}\n\nexport function getCompositeGLDataType(type: GL, components): {glType: GLDataType; name: string} | null {\n switch (type) {\n case GL.BYTE:\n case GL.UNSIGNED_BYTE:\n case GL.SHORT:\n case GL.UNSIGNED_SHORT:\n type = GL.FLOAT;\n break;\n default:\n }\n\n for (const glType in COMPOSITE_GL_TYPES) {\n const [compType, compComponents, name] = COMPOSITE_GL_TYPES[glType];\n if (compType === type && compComponents === components) {\n return {glType: Number(glType), name};\n }\n }\n return null;\n}\n"],"mappings":"AACA,SAAQA,EAAE,QAAkE,oBAAoB;AAGhG,OAAO,SAASC,gBAAgBA,CAACC,IAAmB,EAAW;EAC7D,OAAOC,aAAa,CAACC,QAAQ,CAACF,IAAqB,CAAC;AACtD;AAEA,MAAMC,aAA8B,GAAG,CACrCH,EAAE,CAACK,UAAU,EACbL,EAAE,CAACM,YAAY,EACfN,EAAE,CAACO,UAAU,EACbP,EAAE,CAACQ,iBAAiB,EACpBR,EAAE,CAACS,gBAAgB,EACnBT,EAAE,CAACU,uBAAuB,EAC1BV,EAAE,CAACW,mBAAmB,EACtBX,EAAE,CAACY,cAAc,EACjBZ,EAAE,CAACa,cAAc,EACjBb,EAAE,CAACc,gBAAgB,EACnBd,EAAE,CAACe,oBAAoB,EACvBf,EAAE,CAACgB,uBAAuB,EAC1BhB,EAAE,CAACiB,uBAAuB,EAC1BjB,EAAE,CAACkB,yBAAyB,EAC5BlB,EAAE,CAACmB,6BAA6B,CACjC;AAGD,MAAMC,kBAGL,GAAG;EACF,CAACpB,EAAE,CAACqB,KAAK,GAAG,CAACrB,EAAE,CAACqB,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC;EACpD,CAACrB,EAAE,CAACsB,UAAU,GAAG,CAACtB,EAAE,CAACqB,KAAK,EAAE,CAAC,EAAE,MAAM,E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