@luma.gl/webgl 9.0.0-alpha.30 → 9.0.0-alpha.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/shader-formats.d.ts +9 -0
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -0
- package/dist/adapter/converters/shader-formats.js +53 -0
- package/dist/adapter/converters/shader-formats.js.map +1 -0
- package/dist/adapter/converters/texture-formats.d.ts +1 -2
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +2 -23
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts +8 -2
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +47 -9
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/helpers/{uniforms.d.ts → decode-webgl-types.d.ts} +9 -8
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -0
- package/dist/adapter/helpers/{uniforms.js → decode-webgl-types.js} +14 -13
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -51
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +14 -86
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +25 -25
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/{attribute-utils.d.ts → webgl-topology-utils.d.ts} +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/{attribute-utils.js → webgl-topology-utils.js} +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +2 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +16 -10
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +58 -59
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/classic/buffer-with-accessor.d.ts +0 -1
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -1
- package/dist/classic/buffer-with-accessor.js +0 -1
- package/dist/classic/buffer-with-accessor.js.map +1 -1
- package/dist/dist.dev.js +513 -418
- package/dist/index.cjs +670 -722
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/converters/shader-formats.ts +41 -0
- package/src/adapter/converters/texture-formats.ts +3 -16
- package/src/adapter/converters/vertex-formats.ts +67 -10
- package/src/adapter/helpers/{uniforms.ts → decode-webgl-types.ts} +22 -17
- package/src/adapter/helpers/get-shader-layout.ts +51 -159
- package/src/adapter/helpers/set-uniform.ts +33 -33
- package/src/adapter/objects/webgl-vertex-array-object.ts +2 -1
- package/src/adapter/resources/webgl-command-encoder.ts +1 -1
- package/src/adapter/resources/webgl-render-pipeline.ts +125 -82
- package/src/classic/buffer-with-accessor.ts +0 -1
- package/src/index.ts +1 -1
- package/src/types.ts +2 -0
- package/dist/adapter/helpers/attribute-utils.d.ts.map +0 -1
- package/dist/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/adapter/helpers/uniforms.d.ts.map +0 -1
- package/dist/adapter/helpers/uniforms.js.map +0 -1
- /package/src/adapter/helpers/{attribute-utils.ts → webgl-topology-utils.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-topology-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/webgl-topology-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,EAAE,CAACI,KAAK;IACjB,KAAKJ,EAAE,CAACK,UAAU;MAChB,OAAOL,EAAE,CAACI,KAAK;IACjB,KAAKJ,EAAE,CAACM,SAAS;MACf,OAAON,EAAE,CAACI,KAAK;IACjB,KAAKJ,EAAE,CAACO,SAAS;MACf,OAAOP,EAAE,CAACO,SAAS;IACrB,KAAKP,EAAE,CAACQ,cAAc;MACpB,OAAOR,EAAE,CAACO,SAAS;IACrB,KAAKP,EAAE,CAACS,YAAY;MAClB,OAAOT,EAAE,CAACO,SAAS;IACrB;MACE,MAAM,IAAIG,KAAK,CAAC,UAAU,CAAC;EAC/B;AACF;AAGA,OAAO,SAASC,iBAAiBA,CAACC,OAA6D,EAAU;EACvG,MAAM;IAACV,QAAQ;IAAEW;EAAW,CAAC,GAAGD,OAAO;EACvC,QAAQV,QAAQ;IACd,KAAKF,EAAE,CAACG,MAAM;IACd,KAAKH,EAAE,CAACM,SAAS;MACf,OAAOO,WAAW;IACpB,KAAKb,EAAE,CAACI,KAAK;MACX,OAAOS,WAAW,GAAG,CAAC;IACxB,KAAKb,EAAE,CAACK,UAAU;MAChB,OAAOQ,WAAW,GAAG,CAAC;IACxB,KAAKb,EAAE,CAACO,SAAS;MACf,OAAOM,WAAW,GAAG,CAAC;IACxB,KAAKb,EAAE,CAACQ,cAAc;IACtB,KAAKR,EAAE,CAACS,YAAY;MAClB,OAAOI,WAAW,GAAG,CAAC;IACxB;MACE,MAAM,IAAIH,KAAK,CAAC,UAAU,CAAC;EAC/B;AACF;AAGA,OAAO,SAASI,cAAcA,CAACF,OAA6D,EAAU;EACpG,MAAM;IAACV,QAAQ;IAAEW;EAAW,CAAC,GAAGD,OAAO;EACvC,MAAMG,cAAc,GAAGJ,iBAAiB,CAAC;IAACT,QAAQ;IAAEW;EAAW,CAAC,CAAC;EACjE,QAAQZ,oBAAoB,CAACC,QAAQ,CAAC;IACpC,KAAKF,EAAE,CAACG,MAAM;MACZ,OAAOY,cAAc;IACvB,KAAKf,EAAE,CAACI,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,6 +1,7 @@
|
|
|
1
1
|
import type { Device, Buffer, ResourceProps, TypedArray } from '@luma.gl/core';
|
|
2
2
|
import { WebGLResource } from './webgl-resource';
|
|
3
3
|
import { WEBGLBuffer } from '../resources/webgl-buffer';
|
|
4
|
+
import { AccessorObject } from '../..';
|
|
4
5
|
/**
|
|
5
6
|
* VertexArrayObject properties
|
|
6
7
|
* @param constantAttributeZero Attribute 0 can not be disable on most desktop OpenGL based browsers
|
|
@@ -30,7 +31,7 @@ export declare class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObj
|
|
|
30
31
|
enable(location: number, enable?: boolean): void;
|
|
31
32
|
setElementBuffer(elementBuffer?: WEBGLBuffer | null, opts?: {}): void;
|
|
32
33
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
33
|
-
setBuffer(location: number, buffer: WEBGLBuffer, accessor:
|
|
34
|
+
setBuffer(location: number, buffer: WEBGLBuffer, accessor: AccessorObject): void;
|
|
34
35
|
/**
|
|
35
36
|
* Set an attribute to a constant value
|
|
36
37
|
* @param device
|
|
@@ -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,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAe,MAAM,eAAe,CAAC;AAM3F,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;
|
|
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,eAAe,CAAC;AAM3F,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAGtD,OAAO,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAIrC;;;;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,cAAc,GAAG,IAAI;IA+BhF;;;;;;;;;;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 +1 @@
|
|
|
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","glTarget","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","target","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/core';\nimport {Resource, assert, getScratchArray, fillArray} from '@luma.gl/core';\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.glTarget === 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.glTarget === 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,eAAe;AAC1E,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,UAAU,QAAO,eAAe;AAAC,SAGjCC,aAAa;AAKrB,MAAMC,YAAY,GAAG,0CAA0C;AAACC,mBAAA,GAahDC,MAAM,CAACC,WAAW;AADlC,OAAO,MAAMC,sBAA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EAAE,CAACjE,MAAM,EAAE,EAAEmE,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
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","glTarget","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","target","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/core';\nimport {Resource, assert, getScratchArray, fillArray} from '@luma.gl/core';\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';\nimport {AccessorObject} from '../..';\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.glTarget === 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: AccessorObject): void {\n // Check target\n if (buffer.glTarget === 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,eAAe;AAC1E,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,UAAU,QAAO,eAAe;AAAC,SAGjCC,aAAa;AAMrB,MAAMC,YAAY,GAAG,0CAA0C;AAACC,mBAAA,GAahDC,MAAM,CAACC,WAAW;AADlC,OAAO,MAAMC,sBAAsB,SAASL,aAAa,CAAyB;EAChF,KAAAE,mBAAA,IAA4C;IAC1C,OAAO,uBAAuB;EAChC;EAMA,OAAOI,gCAAgCA,CAACC,MAAc,EAAW;IAC/D,OAAOA,MAAM,CAACC,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAIV,UAAU,CAAC,CAAC,KAAK,QAAQ;EACnE;EAGAW,WAAW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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,
|
|
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,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TypedArray, UniformValue, RenderPipelineProps, Binding, ShaderLayout, BufferLayout } from '@luma.gl/core';
|
|
2
|
+
import type { RenderPass, Buffer } from '@luma.gl/core';
|
|
2
3
|
import { RenderPipeline } from '@luma.gl/core';
|
|
3
4
|
import { WebGLDevice } from '../webgl-device';
|
|
4
5
|
import { WEBGLBuffer } from './webgl-buffer';
|
|
@@ -14,12 +15,12 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
14
15
|
vs: WEBGLShader;
|
|
15
16
|
/** fragment shader */
|
|
16
17
|
fs: WEBGLShader;
|
|
17
|
-
/** The merged layout */
|
|
18
|
-
layout: ShaderLayout;
|
|
19
18
|
/** The layout extracted from shader by WebGL introspection APIs */
|
|
20
19
|
introspectedLayout: ShaderLayout;
|
|
20
|
+
/** The merged layout */
|
|
21
|
+
shaderLayout: ShaderLayout;
|
|
21
22
|
/** Buffer map describing buffer interleaving etc */
|
|
22
|
-
|
|
23
|
+
bufferLayout: BufferLayout[];
|
|
23
24
|
/** Uniforms set on this model */
|
|
24
25
|
uniforms: Record<string, any>;
|
|
25
26
|
/** Bindings set on this model */
|
|
@@ -40,7 +41,7 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
40
41
|
destroy(): void;
|
|
41
42
|
setIndexBuffer(indexBuffer: Buffer): void;
|
|
42
43
|
/** @todo needed for portable model */
|
|
43
|
-
setAttributes(
|
|
44
|
+
setAttributes(buffers: Record<string, Buffer>): void;
|
|
44
45
|
/**
|
|
45
46
|
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
46
47
|
* Any attribute that is disabled in the current vertex array object
|
|
@@ -53,7 +54,7 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
53
54
|
* @todo needed for portable model
|
|
54
55
|
*/
|
|
55
56
|
setBindings(bindings: Record<string, Binding>): void;
|
|
56
|
-
setUniforms(uniforms: Record<string,
|
|
57
|
+
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
57
58
|
/** @todo needed for portable model
|
|
58
59
|
* @note The WebGL API is offers many ways to draw things
|
|
59
60
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
@@ -75,14 +76,19 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
75
76
|
* Note: This is currently done before every draw call
|
|
76
77
|
*/
|
|
77
78
|
_areTexturesRenderable(): boolean;
|
|
78
|
-
/** Apply any bindings */
|
|
79
|
-
_applyBindings(): void;
|
|
80
|
-
_applyUniforms(): void;
|
|
81
79
|
/**
|
|
82
|
-
* Constant attributes
|
|
80
|
+
* Constant attributes need to be reset before every draw call
|
|
83
81
|
* Any attribute that is disabled in the current vertex array object
|
|
84
82
|
* is read from the context's global constant value for that attribute location.
|
|
83
|
+
* @note Constant attributes are only supported in WebGL, not in WebGPU
|
|
85
84
|
*/
|
|
86
85
|
_applyConstantAttributes(): void;
|
|
86
|
+
/** Apply any bindings (before each draw call) */
|
|
87
|
+
_applyBindings(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Due to program sharing, uniforms need to be reset before every draw call
|
|
90
|
+
* (though caching will avoid redundant WebGL calls)
|
|
91
|
+
*/
|
|
92
|
+
_applyUniforms(): void;
|
|
87
93
|
}
|
|
88
94
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,YAAY,EAEb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,cAAc,EAAY,MAAM,eAAe,CAAC;AAUxD,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,sBAAsB;IACtB,EAAE,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IAKlD;;;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
|
|
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 {
|
|
5
|
-
import { getShaderLayout
|
|
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, "
|
|
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.
|
|
52
|
-
this.
|
|
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(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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.
|
|
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 =
|
|
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.
|
|
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.
|
|
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
|
|
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;IACpB,IAAI,CAACG,MAAM,GAAG,IAAI,CAACF,KAAK,CAACE,MAAM,IAAI,IAAI,CAACH,MAAM,CAACI,EAAE,CAACC,aAAa,CAAC,CAAC;IACjE,IAAI,CAACL,MAAM,CAACM,kBAAkB,CAAC,IAAI,CAACH,MAAM,EAAE;MAACI,EAAE,EAAE,IAAI,CAACN,KAAK,CAACM;IAAE,CAAC,CAAC;IAGhE,IAAI,CAACC,EAAE,GA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AA0B;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":["// luma.gl, MIT license\nimport type {\n TypedArray,\n UniformValue,\n RenderPipelineProps,\n Binding,\n ShaderLayout,\n BufferLayout,\n PrimitiveTopology\n} from '@luma.gl/core';\nimport type {RenderPass, Buffer} from '@luma.gl/core';\nimport {RenderPipeline, cast, log} from '@luma.gl/core';\nimport {mergeShaderLayout, getAttributeInfosFromLayouts} 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 /** @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(\n `setAttributes(): Ignoring (buffer \"${buffer.id}\" for unknown attribute \"${name}\" in pipeline \"${this.id}\"`\n )();\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, UniformValue>) {\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":";AAWA,SAAQA,cAAc,EAAEC,IAAI,EAAEC,GAAG,QAAO,eAAe;AACvD,SAAQC,iBAAiB,EAAEC,4BAA4B,QAAO,eAAe;AAC7E,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,MAAMC,yBAAyB,GAAG,CAAC;AAGnC,OAAO,MAAMC,mBAAmB,SAASf,cAAc,CAAC;EAmCtDgB,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;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,KAAK,gBAAgB;MAAE,OAAOhK,EAAE,CAACiK,cAAc;IAC/C,KAAK,oBAAoB;MAAE,OAAOjK,EAAE,CAACkK,YAAY;IACjD;MAAS,MAAM,IAAIhF,KAAK,CAACY,QAAQ,CAAC;EACpC;AACF;AAGA,SAASW,cAAcA,CAACX,QAA2B,EAAuC;EAExF,QAAQA,QAAQ;IACd,KAAK,YAAY;MAAE,OAAO9F,EAAE,CAAC4J,MAAM;IACnC,KAAK,WAAW;MAAE,OAAO5J,EAAE,CAAC6J,KAAK;IACjC,KAAK,YAAY;MAAE,OAAO7J,EAAE,CAAC6J,KAAK;IAClC,KAAK,iBAAiB;MAAE,OAAO7J,EAAE,CAAC6J,KAAK;IACvC,KAAK,eAAe;MAAE,OAAO7J,EAAE,CAACgK,SAAS;IACzC,KAAK,gBAAgB;MAAE,OAAOhK,EAAE,CAACgK,SAAS;IAC1C,KAAK,oBAAoB;MAAE,OAAOhK,EAAE,CAACgK,SAAS;IAC9C;MAAS,MAAM,IAAI9E,KAAK,CAACY,QAAQ,CAAC;EACpC;AACF"}
|
|
@@ -10,7 +10,6 @@ export type BufferWithAccessorProps = BufferProps & {
|
|
|
10
10
|
};
|
|
11
11
|
/** WebGL Buffer interface */
|
|
12
12
|
export declare class BufferWithAccessor extends WEBGLBuffer {
|
|
13
|
-
usage: number;
|
|
14
13
|
accessor: Accessor;
|
|
15
14
|
constructor(device: Device | WebGLRenderingContext, props?: BufferWithAccessorProps);
|
|
16
15
|
constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-with-accessor.d.ts","sourceRoot":"","sources":["../../src/classic/buffer-with-accessor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,OAAO,EAAC,cAA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