@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
@@ -3,7 +3,7 @@ import { CommandEncoder } from '@luma.gl/core';
3
3
  import { WEBGLCommandBuffer } from "./webgl-command-buffer.js";
4
4
  export class WEBGLCommandEncoder extends CommandEncoder {
5
5
  constructor(device, props) {
6
- super(props);
6
+ super(device, props);
7
7
  _defineProperty(this, "device", void 0);
8
8
  _defineProperty(this, "commandBuffer", void 0);
9
9
  this.device = device;
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-command-encoder.js","names":["CommandEncoder","WEBGLCommandBuffer","WEBGLCommandEncoder","constructor","device","props","_defineProperty","commandBuffer","destroy","finish","submitCommands","copyBufferToBuffer","options","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/core';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/core';\n\nimport {WEBGLCommandBuffer} from './webgl-command-buffer';\nimport {WebGLDevice} from '../webgl-device';\n\nexport class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer: WEBGLCommandBuffer;\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n\n override destroy(): void {}\n\n override finish(): void {\n this.commandBuffer.submitCommands();\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}\n"],"mappings":";AAAA,SAAQA,cAAc,QAA4B,eAAe;AAAC,SAQ1DC,kBAAkB;AAG1B,OAAO,MAAMC,mBAAmB,SAASF,cAAc,CAAC;EAKtDG,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACb,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,aAAa,GAAG,IAAIN,kBAAkB,CAACG,MAAM,CAAC;EACrD;EAESI,OAAOA,CAAA,EAAS,CAAC;EAEjBC,MAAMA,CAAA,EAAS;IACtB,IAAI,CAACF,aAAa,CAACG,cAAc,CAAC,CAAC;EACrC;EAMAC,kBAAkBA,CAACC,OAAkC,EAAQ;IAC3D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,uBAAuB;MAAEH;IAAO,CAAC,CAAC;EAC5E;EAEAI,mBAAmBA,CAACJ,OAAmC,EAAE;IACvD,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAK,mBAAmBA,CAACL,OAAmC,EAAQ;IAC7D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAM,oBAAoBA,CAACN,OAAoC,EAAQ;IAC/D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,yBAAyB;MAAEH;IAAO,CAAC,CAAC;EAC9E;EAESO,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAG,CAAC;EAEjBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;AAWzD"}
1
+ {"version":3,"file":"webgl-command-encoder.js","names":["CommandEncoder","WEBGLCommandBuffer","WEBGLCommandEncoder","constructor","device","props","_defineProperty","commandBuffer","destroy","finish","submitCommands","copyBufferToBuffer","options","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/core';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/core';\n\nimport {WEBGLCommandBuffer} from './webgl-command-buffer';\nimport {WebGLDevice} from '../webgl-device';\n\nexport class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer: WEBGLCommandBuffer;\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(device, props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n\n override destroy(): void {}\n\n override finish(): void {\n this.commandBuffer.submitCommands();\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}\n"],"mappings":";AAAA,SAAQA,cAAc,QAA4B,eAAe;AAAC,SAQ1DC,kBAAkB;AAG1B,OAAO,MAAMC,mBAAmB,SAASF,cAAc,CAAC;EAKtDG,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,aAAa,GAAG,IAAIN,kBAAkB,CAACG,MAAM,CAAC;EACrD;EAESI,OAAOA,CAAA,EAAS,CAAC;EAEjBC,MAAMA,CAAA,EAAS;IACtB,IAAI,CAACF,aAAa,CAACG,cAAc,CAAC,CAAC;EACrC;EAMAC,kBAAkBA,CAACC,OAAkC,EAAQ;IAC3D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,uBAAuB;MAAEH;IAAO,CAAC,CAAC;EAC5E;EAEAI,mBAAmBA,CAACJ,OAAmC,EAAE;IACvD,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAK,mBAAmBA,CAACL,OAAmC,EAAQ;IAC7D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAM,oBAAoBA,CAACN,OAAoC,EAAQ;IAC/D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,yBAAyB;MAAEH;IAAO,CAAC,CAAC;EAC9E;EAESO,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAG,CAAC;EAEjBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;AAWzD"}
@@ -1,4 +1,4 @@
1
- import type { RenderPipelineProps, RenderPass, Buffer, Binding, ShaderLayout, TypedArray, BufferMapping } from '@luma.gl/core';
1
+ import type { RenderPipelineProps, RenderPass, Buffer, Binding, ShaderLayout, TypedArray, BufferLayout } from '@luma.gl/core';
2
2
  import { RenderPipeline } from '@luma.gl/core';
3
3
  import { WebGLDevice } from '../webgl-device';
4
4
  import { WEBGLBuffer } from './webgl-buffer';
@@ -14,12 +14,12 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
14
14
  vs: WEBGLShader;
15
15
  /** fragment shader */
16
16
  fs: WEBGLShader;
17
- /** The merged layout */
18
- layout: ShaderLayout;
19
17
  /** The layout extracted from shader by WebGL introspection APIs */
20
18
  introspectedLayout: ShaderLayout;
19
+ /** The merged layout */
20
+ shaderLayout: ShaderLayout;
21
21
  /** Buffer map describing buffer interleaving etc */
22
- bufferMap: BufferMapping[];
22
+ bufferLayout: BufferLayout[];
23
23
  /** Uniforms set on this model */
24
24
  uniforms: Record<string, any>;
25
25
  /** Bindings set on this model */
@@ -40,7 +40,7 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
40
40
  destroy(): void;
41
41
  setIndexBuffer(indexBuffer: Buffer): void;
42
42
  /** @todo needed for portable model */
43
- setAttributes(attributes: Record<string, Buffer>): void;
43
+ setAttributes(buffers: Record<string, Buffer>): void;
44
44
  /**
45
45
  * Constant attributes are only supported in WebGL, not in WebGPU
46
46
  * Any attribute that is disabled in the current vertex array object
@@ -75,14 +75,19 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
75
75
  * Note: This is currently done before every draw call
76
76
  */
77
77
  _areTexturesRenderable(): boolean;
78
- /** Apply any bindings */
79
- _applyBindings(): void;
80
- _applyUniforms(): void;
81
78
  /**
82
- * Constant attributes are only supported in WebGL, not in WebGPU
79
+ * Constant attributes need to be reset before every draw call
83
80
  * Any attribute that is disabled in the current vertex array object
84
81
  * is read from the context's global constant value for that attribute location.
82
+ * @note Constant attributes are only supported in WebGL, not in WebGPU
85
83
  */
86
84
  _applyConstantAttributes(): void;
85
+ /** Apply any bindings (before each draw call) */
86
+ _applyBindings(): void;
87
+ /**
88
+ * Due to program sharing, uniforms need to be reset before every draw call
89
+ * (though caching will avoid redundant WebGL calls)
90
+ */
91
+ _applyUniforms(): void;
87
92
  }
88
93
  //# sourceMappingURL=webgl-render-pipeline.d.ts.map
@@ -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,EAIZ,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,cAAc,EAAgC,MAAM,eAAe,CAAC;AAS5E,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAK5E,oCAAoC;AACpC,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,yDAAyD;IACzD,MAAM,EAAE,WAAW,CAAC;IACpB,yCAAyC;IACzC,MAAM,EAAE,YAAY,CAAC;I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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;IA8EX,SAAS,CAAC,eAAe;IA0BzB;;;;OAIG;IACH,sBAAsB;IAkBtB,yBAAyB;IACzB,cAAc;IA6Dd,cAAc;IAUd;;;;OAIG;IACH,wBAAwB,IAAI,IAAI;CAUjC"}
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,EAEZ,UAAU,EACV,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,cAAc,EAAY,MAAM,eAAe,CAAC;AAaxD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAK5E,oCAAoC;AACpC,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,yDAAyD;IACzD,MAAM,EAAE,WAAW,CAAC;IACpB,yCAAyC;IACzC,MAAM,EAAE,YAAY,CAAC;IACrB,oBAAoB;IACpB,EAAE,EAAE,WAAW,CAAC;IAChB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AM,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;IAmFX,SAAS,CAAC,eAAe;IA0BzB;;;;OAIG;IACH,sBAAsB;IAkBtB;;;;;OAKG;IACH,wBAAwB,IAAI,IAAI;IAchC,iDAAiD;IACjD,cAAc;IA6Dd;;;OAGG;IACH,cAAc;CASf"}
@@ -1,8 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { RenderPipeline, cast, log, decodeVertexFormat } from '@luma.gl/core';
2
+ import { RenderPipeline, cast, log } from '@luma.gl/core';
3
+ import { mergeShaderLayout, getAttributeInfosFromLayouts } from '@luma.gl/core';
3
4
  import { GL } from '@luma.gl/constants';
4
- import { getWebGLDataType } from "../converters/texture-formats.js";
5
- import { getShaderLayout, mergeShaderLayout, mergeBufferMap } from "../helpers/get-shader-layout.js";
5
+ import { getGLFromVertexType } from "../converters/vertex-formats.js";
6
+ import { getShaderLayout } from "../helpers/get-shader-layout.js";
6
7
  import { withDeviceParameters, withGLParameters } from "../converters/device-parameters.js";
7
8
  import { setUniform } from "../helpers/set-uniform.js";
8
9
  import { WEBGLBuffer } from "./webgl-buffer.js";
@@ -16,9 +17,9 @@ export class WEBGLRenderPipeline extends RenderPipeline {
16
17
  _defineProperty(this, "handle", void 0);
17
18
  _defineProperty(this, "vs", void 0);
18
19
  _defineProperty(this, "fs", void 0);
19
- _defineProperty(this, "layout", void 0);
20
20
  _defineProperty(this, "introspectedLayout", void 0);
21
- _defineProperty(this, "bufferMap", void 0);
21
+ _defineProperty(this, "shaderLayout", void 0);
22
+ _defineProperty(this, "bufferLayout", void 0);
22
23
  _defineProperty(this, "uniforms", {});
23
24
  _defineProperty(this, "bindings", {});
24
25
  _defineProperty(this, "constantAttributes", {});
@@ -48,9 +49,8 @@ export class WEBGLRenderPipeline extends RenderPipeline {
48
49
  }
49
50
  this._compileAndLink();
50
51
  this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
51
- this.layout = mergeShaderLayout(this.introspectedLayout, props.layout);
52
- this.bufferMap = props.bufferMap || [];
53
- this.layout = mergeBufferMap(this.layout, this.bufferMap);
52
+ this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
53
+ this.bufferLayout = props.bufferLayout || [];
54
54
  this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);
55
55
  }
56
56
  destroy() {
@@ -64,48 +64,49 @@ export class WEBGLRenderPipeline extends RenderPipeline {
64
64
  this.vertexArrayObject.setElementBuffer(webglBuffer);
65
65
  this._indexBuffer = webglBuffer;
66
66
  }
67
- setAttributes(attributes) {
68
- for (const [name, buffer] of Object.entries(attributes)) {
69
- const webglBuffer = cast(buffer);
70
- const attribute = getAttributeLayout(this.layout, name);
71
- if (!attribute) {
72
- log.warn("Ignoring buffer supplied for unknown attribute \"".concat(name, "\" in pipeline \"").concat(this.id, "\" (buffer \"").concat(buffer.id, "\")"))();
73
- continue;
67
+ setAttributes(buffers) {
68
+ const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);
69
+ for (const [bufferName, buffer] of Object.entries(buffers)) {
70
+ let set = false;
71
+ for (const attributeInfo of Object.values(attributeInfos)) {
72
+ if (attributeInfo.bufferName !== bufferName) {
73
+ continue;
74
+ }
75
+ const webglBuffer = cast(buffer);
76
+ const glType = getGLFromVertexType(attributeInfo.bufferDataType);
77
+ log.log(1, {
78
+ setAttribute: attributeInfo.name,
79
+ toBuffer: bufferName,
80
+ size: attributeInfo.bufferComponents,
81
+ type: glType,
82
+ stride: attributeInfo.byteStride,
83
+ offset: attributeInfo.byteOffset,
84
+ normalized: attributeInfo.normalized,
85
+ integer: attributeInfo.integer,
86
+ divisor: attributeInfo.stepMode === 'instance' ? 1 : 0
87
+ })();
88
+ this.vertexArrayObject.setBuffer(attributeInfo.location, webglBuffer, {
89
+ size: attributeInfo.bufferComponents,
90
+ type: glType,
91
+ stride: attributeInfo.byteStride,
92
+ offset: attributeInfo.byteOffset,
93
+ normalized: attributeInfo.normalized,
94
+ integer: attributeInfo.integer,
95
+ divisor: attributeInfo.stepMode === 'instance' ? 1 : 0
96
+ });
97
+ set = true;
98
+ }
99
+ if (!set) {
100
+ log.warn("setAttributes(): Ignoring (buffer \"".concat(buffer.id, "\" for unknown attribute \"").concat(name, "\" in pipeline \"").concat(this.id, "\""))();
74
101
  }
75
- const decoded = decodeVertexFormat(attribute.format);
76
- const {
77
- type: typeString,
78
- components: size,
79
- byteLength: stride,
80
- normalized
81
- } = decoded;
82
- const divisor = attribute.stepMode === 'instance' ? 1 : 0;
83
- const type = getWebGLDataType(typeString);
84
- this.vertexArrayObject.setBuffer(attribute.location, webglBuffer, {
85
- size,
86
- type,
87
- stride,
88
- offset: 0,
89
- normalized,
90
- integer: false,
91
- divisor
92
- });
93
102
  }
94
103
  }
95
104
  setConstantAttributes(attributes) {
96
- for (const [name, value] of Object.entries(attributes)) {
97
- const attribute = getAttributeLayout(this.layout, name);
98
- if (!attribute) {
99
- log.warn("Ignoring constant value supplied for unknown attribute \"".concat(name, "\" in pipeline \"").concat(this.id, "\""))();
100
- continue;
101
- }
102
- this.vertexArrayObject.setConstant(attribute.location, value);
103
- }
104
105
  Object.assign(this.constantAttributes, attributes);
105
106
  }
106
107
  setBindings(bindings) {
107
108
  for (const [name, value] of Object.entries(bindings)) {
108
- const binding = this.layout.bindings.find(binding => binding.name === name);
109
+ const binding = this.shaderLayout.bindings.find(binding => binding.name === name);
109
110
  if (!binding) {
110
111
  log.warn("Unknown binding ".concat(name, " in render pipeline ").concat(this.id))();
111
112
  continue;
@@ -144,7 +145,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
144
145
  instanceCount,
145
146
  firstVertex = 0
146
147
  } = options;
147
- const drawMode = getDrawMode(this.props.topology);
148
+ const drawMode = getGLDrawMode(this.props.topology);
148
149
  const isIndexed = Boolean(this._indexBuffer);
149
150
  const indexType = (_this$_indexBuffer = this._indexBuffer) === null || _this$_indexBuffer === void 0 ? void 0 : _this$_indexBuffer.glIndexType;
150
151
  const isInstanced = Number(options.instanceCount) > 0;
@@ -217,6 +218,17 @@ export class WEBGLRenderPipeline extends RenderPipeline {
217
218
  }
218
219
  return texturesRenderable;
219
220
  }
221
+ _applyConstantAttributes() {
222
+ const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);
223
+ for (const [name, value] of Object.entries(this.constantAttributes)) {
224
+ const attributeInfo = attributeInfos[name];
225
+ if (!attributeInfo) {
226
+ log.warn("Ignoring constant value supplied for unknown attribute \"".concat(name, "\" in pipeline \"").concat(this.id, "\""))();
227
+ continue;
228
+ }
229
+ this.vertexArrayObject.setConstant(attributeInfo.location, value);
230
+ }
231
+ }
220
232
  _applyBindings() {
221
233
  this.device.gl.useProgram(this.handle);
222
234
  const {
@@ -227,7 +239,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
227
239
  }
228
240
  let textureUnit = 0;
229
241
  let uniformBufferIndex = 0;
230
- for (const binding of this.layout.bindings) {
242
+ for (const binding of this.shaderLayout.bindings) {
231
243
  const value = this.bindings[binding.name];
232
244
  if (!value) {
233
245
  throw new Error("No value for binding ".concat(binding.name, " in ").concat(this.id));
@@ -267,7 +279,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
267
279
  }
268
280
  }
269
281
  _applyUniforms() {
270
- for (const uniformLayout of this.layout.uniforms || []) {
282
+ for (const uniformLayout of this.shaderLayout.uniforms || []) {
271
283
  var _this$uniforms$name;
272
284
  const {
273
285
  name,
@@ -281,18 +293,8 @@ export class WEBGLRenderPipeline extends RenderPipeline {
281
293
  }
282
294
  }
283
295
  }
284
- _applyConstantAttributes() {
285
- for (const [name, value] of Object.entries(this.constantAttributes)) {
286
- const attribute = getAttributeLayout(this.layout, name);
287
- if (!attribute) {
288
- log.warn("Ignoring constant value supplied for unknown attribute \"".concat(name, "\" in pipeline \"").concat(this.id, "\""))();
289
- continue;
290
- }
291
- this.vertexArrayObject.setConstant(attribute.location, value);
292
- }
293
- }
294
296
  }
295
- function getDrawMode(topology) {
297
+ function getGLDrawMode(topology) {
296
298
  switch (topology) {
297
299
  case 'point-list':
298
300
  return GL.POINTS;
@@ -332,7 +334,4 @@ function getGLPrimitive(topology) {
332
334
  throw new Error(topology);
333
335
  }
334
336
  }
335
- function getAttributeLayout(layout, name) {
336
- return layout.attributes.find(binding => binding.name === name) || null;
337
- }
338
337
  //# sourceMappingURL=webgl-render-pipeline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-render-pipeline.js","names":["RenderPipeline","cast","log","decodeVertexFormat","GL","getWebGLDataType","getShaderLayout","mergeShaderLayout","mergeBufferMap","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","introspectedLayout","layout","bufferMap","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","divisor","stepMode","setBuffer","location","offset","integer","setConstantAttributes","value","setConstant","assign","constantAttributes","setBindings","bindings","binding","find","Error","setUniforms","uniforms","draw","options","_this$_indexBuffer","renderPass","vertexCount","instanceCount","firstVertex","drawMode","getDrawMode","topology","isIndexed","Boolean","indexType","glIndexType","isInstanced","Number","_areTexturesRenderable","useProgram","bind","primitiveMode","getGLPrimitive","transformFeedback","begin","_applyBindings","_applyUniforms","_applyConstantAttributes","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 BufferMapping\n} from '@luma.gl/core';\nimport {RenderPipeline, cast, log, decodeVertexFormat} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\nimport {getWebGLDataType} from '../converters/texture-formats';\nimport {getShaderLayout, mergeShaderLayout, mergeBufferMap} 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 /** The WebGL device that created this render pipeline */\n device: WebGLDevice;\n /** Handle to underlying WebGL program */\n handle: WebGLProgram;\n /** vertex shader */\n vs: WEBGLShader;\n /** fragment shader */\n fs: WEBGLShader;\n /** The merged layout */\n layout: ShaderLayout;\n /** The layout extracted from shader by WebGL introspection APIs */\n introspectedLayout: ShaderLayout;\n /** Buffer map describing buffer interleaving etc */\n bufferMap: BufferMapping[];\n\n /** Uniforms set on this model */\n uniforms: Record<string, any> = {};\n /** Bindings set on this model */\n bindings: Record<string, any> = {};\n /** Any constant attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Index buffer is stored separately */\n _indexBuffer?: WEBGLBuffer;\n /** WebGL varyings */\n varyings: string[] | null = null;\n\n /** Stores attribute bindings */\n vertexArrayObject: WEBGLVertexArrayObject;\n\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.introspectedLayout = getShaderLayout(this.device.gl, this.handle);\n // Merge provided layout with introspected layout\n this.layout = mergeShaderLayout(this.introspectedLayout, props.layout); \n // Merge layout with any buffer map overrides\n this.bufferMap = props.bufferMap || [];\n this.layout = mergeBufferMap(this.layout, this.bufferMap); \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 = webglBuffer;\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 // it is the shader attribute declaration, not the vertex memory format, \n // that determines if the data in the buffer will be treated as integers.\n // /\n // Also note that WebGL supports assigning non-normalized integer data to floating point attributes,\n // but as far as we can tell, WebGPU does not.\n integer: false,\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 Object.assign(this.constantAttributes, attributes);\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?.glIndexType;\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 this._applyConstantAttributes();\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 * 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 */\n _applyConstantAttributes(): void {\n for (const [name, value] of Object.entries(this.constantAttributes)) {\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/** Get the primitive type for draw */\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-webgl': return GL.LINE_LOOP;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLE_STRIP;\n case 'triangle-fan-webgl': 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-webgl': return GL.LINES;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLES;\n case 'triangle-fan-webgl': return GL.TRIANGLES;\n default: throw new Error(topology);\n }\n}\n\nfunction getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout | null {\n return layout.attributes.find((binding) => binding.name === name) || null;\n}\n"],"mappings":";AAYA,SAAQA,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAEC,kBAAkB,QAAO,eAAe;AAC3E,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,gBAAgB;AAAA,SAChBC,eAAe,EAAEC,iBAAiB,EAAEC,cAAc;AAAA,SAClDC,oBAAoB,EAAEC,gBAAgB;AAAA,SACtCC,UAAU;AAAA,SAIVC,WAAW;AAAA,SAEXC,YAAY;AAAA,SACZC,sBAAsB;AAG9B,MAAMC,yBAAyB,GAAG,CAAC;AAGnC,OAAO,MAAMC,mBAAmB,SAAShB,cAAc,CAAC;EAmCtDiB,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;IAAAA,eAAA;IAAAA,eAAA,mBAnBS,CAAC,CAAC;IAAAA,eAAA,mBAEF,CAAC,CAAC;IAAAA,eAAA,6BAEe,CAAC,CAAC;IAAAA,eAAA;IAAAA,eAAA,mBAIvB,IAAI;IAAAA,eAAA;IAAAA,eAAA,2BAKQ,CAAC,CAAC;IAAAA,eAAA,+BACX,CAAC;IAAAA,eAAA,wBACR,CAAC;IAAAA,eAAA,0BACmB,CAAC,CAAC;IAI5C,IAAI,CAACF,MAAM,GAAGA,MAAM;IACp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AK,eAAe;MAAE,OAAOxJ,EAAE,CAAC2J,SAAS;IACzC,KAAK,gBAAgB;MAAE,OAAO3J,EAAE,CAAC2J,SAAS;IAC1C,KAAK,oBAAoB;MAAE,OAAO3J,EAAE,CAAC2J,SAAS;IAC9C;MAAS,MAAM,IAAI5E,KAAK,CAACY,QAAQ,CAAC;EACpC;AACF;AAEA,SAASvC,kBAAkBA,CAAClB,MAAoB,EAAEa,IAAY,EAA0B;EACtF,OAAOb,MAAM,CAACY,UAAU,CAACgC,IAAI,CAAED,OAAO,IAAKA,OAAO,CAAC9B,IAAI,KAAKA,IAAI,CAAC,IAAI,IAAI;AAC3E"}
1
+ {"version":3,"file":"webgl-render-pipeline.js","names":["RenderPipeline","cast","log","mergeShaderLayout","getAttributeInfosFromLayouts","GL","getGLFromVertexType","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","introspectedLayout","shaderLayout","bufferLayout","vertexArrayObject","destroy","deleteProgram","destroyed","setIndexBuffer","indexBuffer","webglBuffer","setElementBuffer","_indexBuffer","setAttributes","buffers","attributeInfos","bufferName","buffer","Object","entries","set","attributeInfo","values","glType","bufferDataType","setAttribute","name","toBuffer","size","bufferComponents","type","stride","byteStride","offset","byteOffset","normalized","integer","divisor","stepMode","setBuffer","location","warn","concat","setConstantAttributes","attributes","assign","constantAttributes","setBindings","bindings","value","binding","find","Error","setUniforms","uniforms","draw","options","_this$_indexBuffer","renderPass","vertexCount","instanceCount","firstVertex","drawMode","getGLDrawMode","topology","isIndexed","Boolean","indexType","glIndexType","isInstanced","Number","_areTexturesRenderable","useProgram","bind","primitiveMode","getGLPrimitive","transformFeedback","begin","_applyBindings","_applyUniforms","_applyConstantAttributes","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","setConstant","textureUnit","uniformBufferIndex","getUniformBlockIndex","INVALID_INDEX","uniformBlockBinding","bindBufferBase","UNIFORM_BUFFER","bindBufferRange","byteLength","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 TypedArray,\n BufferLayout\n} from '@luma.gl/core';\nimport {RenderPipeline, cast, log} from '@luma.gl/core';\nimport {\n mergeShaderLayout,\n getAttributeInfosFromLayouts\n} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\nimport {getGLFromVertexType} from '../converters/vertex-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 /** The WebGL device that created this render pipeline */\n device: WebGLDevice;\n /** Handle to underlying WebGL program */\n handle: WebGLProgram;\n /** vertex shader */\n vs: WEBGLShader;\n /** fragment shader */\n fs: WEBGLShader;\n /** The layout extracted from shader by WebGL introspection APIs */\n introspectedLayout: ShaderLayout;\n /** The merged layout */\n shaderLayout: ShaderLayout;\n /** Buffer map describing buffer interleaving etc */\n bufferLayout: BufferLayout[];\n\n /** Uniforms set on this model */\n uniforms: Record<string, any> = {};\n /** Bindings set on this model */\n bindings: Record<string, any> = {};\n /** Any constant attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Index buffer is stored separately */\n _indexBuffer?: WEBGLBuffer;\n /** WebGL varyings */\n varyings: string[] | null = null;\n\n /** Stores attribute bindings */\n vertexArrayObject: WEBGLVertexArrayObject;\n\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.introspectedLayout = getShaderLayout(this.device.gl, this.handle);\n // Merge provided layout with introspected layout\n this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);\n // Merge layout with any buffer map overrides\n this.bufferLayout = props.bufferLayout || [];\n // this.shaderLayout = mergeBufferMap(this.shaderLayout, this.bufferLayout);\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 = webglBuffer;\n }\n\n\n /** @todo needed for portable model */\n setAttributes(buffers: Record<string, Buffer>): void {\n const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);\n\n for (const [bufferName, buffer] of Object.entries(buffers)) {\n let set = false;\n for (const attributeInfo of Object.values(attributeInfos)) {\n if (attributeInfo.bufferName !== bufferName) {\n continue; // eslint-disable-line no-continue\n }\n const webglBuffer = cast<WEBGLBuffer>(buffer);\n\n const glType = getGLFromVertexType(attributeInfo.bufferDataType);\n // TODO remove when we have more confidence\n log.log(1, {\n setAttribute: attributeInfo.name,\n toBuffer: bufferName,\n size: attributeInfo.bufferComponents,\n type: glType,\n stride: attributeInfo.byteStride,\n offset: attributeInfo.byteOffset,\n normalized: attributeInfo.normalized,\n // it is the shader attribute declaration, not the vertex memory format,\n // that determines if the data in the buffer will be treated as integers.\n // /\n // Also note that WebGL supports assigning non-normalized integer data to floating point attributes,\n // but as far as we can tell, WebGPU does not.\n integer: attributeInfo.integer,\n divisor: attributeInfo.stepMode === 'instance' ? 1 : 0\n })();\n this.vertexArrayObject.setBuffer(attributeInfo.location, webglBuffer, {\n size: attributeInfo.bufferComponents,\n type: glType,\n stride: attributeInfo.byteStride,\n offset: attributeInfo.byteOffset,\n normalized: attributeInfo.normalized,\n // it is the shader attribute declaration, not the vertex memory format,\n // that determines if the data in the buffer will be treated as integers.\n // /\n // Also note that WebGL supports assigning non-normalized integer data to floating point attributes,\n // but as far as we can tell, WebGPU does not.\n integer: attributeInfo.integer,\n divisor: attributeInfo.stepMode === 'instance' ? 1 : 0\n });\n set = true;\n }\n if (!set) {\n log.warn(`setAttributes(): Ignoring (buffer \"${buffer.id}\" for unknown attribute \"${name}\" in pipeline \"${this.id}\"`)();\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 // TODO - there should be no advantage to setting these here vs in _applyConstantAttributes\n // for (const [name, value] of Object.entries(attributes)) {\n // const attributeInfo = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout, name);\n // if (!attributeInfo) {\n // log.warn(\n // `Ignoring constant value supplied for unknown attribute \"${name}\" in pipeline \"${this.id}\"`\n // )();\n // continue; // eslint-disable-line no-continue\n // }\n // this.vertexArrayObject.setConstant(attributeInfo.location, value);\n // }\n Object.assign(this.constantAttributes, attributes);\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.shaderLayout.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 = getGLDrawMode(this.props.topology);\n const isIndexed: boolean = Boolean(this._indexBuffer);\n const indexType = this._indexBuffer?.glIndexType;\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 this._applyConstantAttributes();\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(\n drawMode,\n firstVertex,\n vertexCount || 0,\n instanceCount || 0\n );\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 /**\n * Constant attributes need to be reset before every draw call\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 * @note Constant attributes are only supported in WebGL, not in WebGPU\n */\n _applyConstantAttributes(): void {\n const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);\n for (const [name, value] of Object.entries(this.constantAttributes)) {\n const attributeInfo = attributeInfos[name];\n if (!attributeInfo) {\n log.warn(\n `Ignoring constant value supplied for unknown attribute \"${name}\" in pipeline \"${this.id}\"`\n )();\n continue; // eslint-disable-line no-continue\n }\n this.vertexArrayObject.setConstant(attributeInfo.location, value);\n }\n }\n\n /** Apply any bindings (before each draw call) */\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.shaderLayout.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 /**\n * Due to program sharing, uniforms need to be reset before every draw call\n * (though caching will avoid redundant WebGL calls)\n */\n _applyUniforms() {\n for (const uniformLayout of this.shaderLayout.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 draw */\nfunction getGLDrawMode(\n topology: PrimitiveTopology\n):\n | GL.POINTS\n | GL.LINES\n | GL.LINE_STRIP\n | GL.LINE_LOOP\n | GL.TRIANGLES\n | GL.TRIANGLE_STRIP\n | 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-webgl': return GL.LINE_LOOP;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLE_STRIP;\n case 'triangle-fan-webgl': 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-webgl': return GL.LINES;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLES;\n case 'triangle-fan-webgl': return GL.TRIANGLES;\n default: throw new Error(topology);\n }\n}\n"],"mappings":";AAUA,SAAQA,cAAc,EAAEC,IAAI,EAAEC,GAAG,QAAO,eAAe;AACvD,SACEC,iBAAiB,EACjBC,4BAA4B,QACvB,eAAe;AACtB,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,mBAAmB;AAAA,SACnBC,eAAe;AAAA,SACfC,oBAAoB,EAAEC,gBAAgB;AAAA,SACtCC,UAAU;AAAA,SAIVC,WAAW;AAAA,SAEXC,YAAY;AAAA,SACZC,sBAAsB;AAG9B,M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