@luma.gl/webgl 9.0.0-alpha.33 → 9.0.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/adapter/converters/device-parameters.js +1 -1
  2. package/dist/adapter/converters/device-parameters.js.map +1 -1
  3. package/dist/adapter/converters/shader-formats.js +3 -3
  4. package/dist/adapter/converters/shader-formats.js.map +1 -1
  5. package/dist/adapter/converters/texture-formats.js +3 -3
  6. package/dist/adapter/converters/texture-formats.js.map +1 -1
  7. package/dist/adapter/converters/vertex-formats.js +3 -3
  8. package/dist/adapter/converters/vertex-formats.js.map +1 -1
  9. package/dist/adapter/device-helpers/device-features.js +1 -1
  10. package/dist/adapter/device-helpers/device-features.js.map +1 -1
  11. package/dist/adapter/helpers/get-shader-layout.js +2 -2
  12. package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
  13. package/dist/adapter/objects/constants-to-keys.js +1 -1
  14. package/dist/adapter/objects/constants-to-keys.js.map +1 -1
  15. package/dist/adapter/objects/webgl-renderbuffer.js +3 -4
  16. package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
  17. package/dist/adapter/objects/webgl-resource.js +7 -8
  18. package/dist/adapter/objects/webgl-resource.js.map +1 -1
  19. package/dist/adapter/objects/webgl-vertex-array-object.js +2 -3
  20. package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  21. package/dist/adapter/resources/webgl-buffer.js +10 -11
  22. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  23. package/dist/adapter/resources/webgl-command-buffer.js +3 -4
  24. package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
  25. package/dist/adapter/resources/webgl-command-encoder.js +2 -3
  26. package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
  27. package/dist/adapter/resources/webgl-framebuffer.js +6 -7
  28. package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
  29. package/dist/adapter/resources/webgl-render-pass.js +2 -3
  30. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  31. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  32. package/dist/adapter/resources/webgl-render-pipeline.js +32 -32
  33. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  34. package/dist/adapter/resources/webgl-sampler.js +4 -5
  35. package/dist/adapter/resources/webgl-sampler.js.map +1 -1
  36. package/dist/adapter/resources/webgl-shader.js +7 -8
  37. package/dist/adapter/resources/webgl-shader.js.map +1 -1
  38. package/dist/adapter/resources/webgl-texture.js +19 -20
  39. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  40. package/dist/adapter/webgl-canvas-context.js +4 -5
  41. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  42. package/dist/adapter/webgl-device.js +25 -24
  43. package/dist/adapter/webgl-device.js.map +1 -1
  44. package/dist/classic/accessor.js +9 -10
  45. package/dist/classic/accessor.js.map +1 -1
  46. package/dist/classic/buffer-with-accessor.js +1 -2
  47. package/dist/classic/buffer-with-accessor.js.map +1 -1
  48. package/dist/classic/copy-and-blit.js +1 -1
  49. package/dist/classic/copy-and-blit.js.map +1 -1
  50. package/dist/context/context/create-browser-context.js +1 -1
  51. package/dist/context/context/create-browser-context.js.map +1 -1
  52. package/dist/context/debug/webgl-developer-tools.js +5 -5
  53. package/dist/context/debug/webgl-developer-tools.js.map +1 -1
  54. package/dist/context/polyfill/polyfill-context.js +1 -1
  55. package/dist/context/polyfill/polyfill-context.js.map +1 -1
  56. package/dist/context/state-tracker/track-context-state.js +8 -9
  57. package/dist/context/state-tracker/track-context-state.js.map +1 -1
  58. package/dist/dist.dev.js +58 -30
  59. package/dist/index.cjs +3 -2
  60. package/dist.min.js +22 -22
  61. package/package.json +5 -5
  62. package/src/adapter/resources/webgl-render-pipeline.ts +3 -2
@@ -146,7 +146,7 @@ function readUniformBindings(gl, program) {
146
146
  uniforms.push(uniformInfo);
147
147
  if (uniformInfo.size > 1) {
148
148
  for (let j = 0; j < uniformInfo.size; j++) {
149
- const elementName = "".concat(name, "[").concat(j, "]");
149
+ const elementName = `${name}[${j}]`;
150
150
  webglLocation = gl.getUniformLocation(program, elementName);
151
151
  const arrayElementUniformInfo = {
152
152
  ...uniformInfo,
@@ -240,7 +240,7 @@ function parseUniformName(name) {
240
240
  const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
241
241
  const matches = UNIFORM_NAME_REGEXP.exec(name);
242
242
  if (!matches || matches.length < 2) {
243
- throw new Error("Failed to parse GLSL uniform name ".concat(name));
243
+ throw new Error(`Failed to parse GLSL uniform name ${name}`);
244
244
  }
245
245
  return {
246
246
  name: matches[1],
@@ -1 +1 @@
1
- {"version":3,"file":"get-shader-layout.js","names":["GL","isWebGL2","Accessor","decodeGLUniformType","decodeGLAttributeType","isSamplerUniform","getShaderLayout","gl","program","shaderLayout","attributes","bindings","readAttributeDeclarations","uniformBlocks","readUniformBlocks","uniformBlock","uniforms","map","uniform","name","format","byteOffset","byteStride","arrayLength","push","type","location","visibility","vertex","fragment","minBindingSize","byteLength","readUniformBindings","textureUnit","viewDimension","sampleType","getSamplerInfo","length","varyings","readVaryings","count","getProgramParameter","ACTIVE_ATTRIBUTES","index","activeInfo","getActiveAttrib","Error","compositeType","getAttribLocation","attributeType","stepMode","test","sort","a","b","gl2","TRANSFORM_FEEDBACK_VARYINGS","getTransformFeedbackVarying","size","glType","components","accessor","varying","uniformCount","ACTIVE_UNIFORMS","i","getActiveUniform","rawName","isArray","parseUniformName","webglLocation","getUniformLocation","uniformInfo","j","elementName","concat","arrayElementUniformInfo","getBlockParameter","blockIndex","pname","getActiveUniformBlockParameter","blockCount","ACTIVE_UNIFORM_BLOCKS","blockInfo","getActiveUniformBlockName","UNIFORM_BLOCK_BINDING","UNIFORM_BLOCK_DATA_SIZE","UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER","UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER","UNIFORM_BLOCK_ACTIVE_UNIFORMS","uniformIndices","UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES","uniformType","getActiveUniforms","UNIFORM_TYPE","uniformArrayLength","UNIFORM_SIZE","uniformOffset","UNIFORM_OFFSET","uniformStride","UNIFORM_ARRAY_STRIDE","SAMPLER_UNIFORMS_GL_TO_GPU","SAMPLER_2D","SAMPLER_CUBE","SAMPLER_3D","SAMPLER_2D_SHADOW","SAMPLER_2D_ARRAY","SAMPLER_2D_ARRAY_SHADOW","SAMPLER_CUBE_SHADOW","INT_SAMPLER_2D","INT_SAMPLER_3D","INT_SAMPLER_CUBE","INT_SAMPLER_2D_ARRAY","UNSIGNED_INT_SAMPLER_2D","UNSIGNED_INT_SAMPLER_3D","UNSIGNED_INT_SAMPLER_CUBE","UNSIGNED_INT_SAMPLER_2D_ARRAY","sampler","UNIFORM_NAME_REGEXP","matches","exec","Boolean"],"sources":["../../../src/adapter/helpers/get-shader-layout.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {\n ShaderLayout,\n UniformBinding,\n UniformBlockBinding,\n AttributeDeclaration,\n VaryingBinding\n} from '@luma.gl/core';\n\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2} from '../../context/context/webgl-checks';\nimport {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API\nimport {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './decode-webgl-types';\n\n/**\n * Extract metadata describing binding information for a program's shaders\n * Note: `linkProgram()` needs to have been called\n * (although linking does not need to have been successful).\n */\nexport function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram): ShaderLayout {\n const shaderLayout: ShaderLayout = {\n attributes: [],\n bindings: []\n };\n\n shaderLayout.attributes = readAttributeDeclarations(gl, program);\n\n // Uniform blocks\n const uniformBlocks: UniformBlockBinding[] = readUniformBlocks(gl, program);\n for (const uniformBlock of uniformBlocks) {\n const uniforms = uniformBlock.uniforms.map(uniform => ({\n name: uniform.name,\n format: uniform.format,\n byteOffset: uniform.byteOffset,\n byteStride: uniform.byteStride,\n arrayLength: uniform.arrayLength\n }));\n shaderLayout.bindings.push({\n type: 'uniform',\n name: uniformBlock.name,\n location: uniformBlock.location,\n visibility: (uniformBlock.vertex ? 0x1 : 0) & (uniformBlock.fragment ? 0x2 : 0),\n minBindingSize: uniformBlock.byteLength,\n uniforms\n });\n }\n\n const uniforms: UniformBinding[] = readUniformBindings(gl, program);\n let textureUnit = 0;\n for (const uniform of uniforms) {\n if (isSamplerUniform(uniform.type)) {\n const {viewDimension, sampleType} = getSamplerInfo(uniform.type);\n shaderLayout.bindings.push({\n type: 'texture',\n name: uniform.name,\n location: textureUnit,\n viewDimension,\n sampleType\n });\n\n // @ts-expect-error\n uniform.textureUnit = textureUnit;\n textureUnit += 1;\n }\n }\n\n if (uniforms.length) {\n shaderLayout.uniforms = uniforms;\n }\n\n // Varyings\n const varyings: VaryingBinding[] = readVaryings(gl, program);\n // Note - samplers are always in unform bindings, even if uniform blocks are used\n if (varyings?.length) {\n shaderLayout.varyings = varyings;\n }\n\n return shaderLayout;\n}\n\n// HELPERS\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readAttributeDeclarations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): AttributeDeclaration[] {\n const attributes: AttributeDeclaration[] = [];\n\n const count = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n\n for (let index = 0; index < count; index++) {\n const activeInfo = gl.getActiveAttrib(program, index);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType /* , size*/} = activeInfo;\n const location = gl.getAttribLocation(program, name);\n // Add only user provided attributes, for built-in attributes like `gl_InstanceID` location will be < 0\n if (location >= 0) {\n const {attributeType} = decodeGLAttributeType(compositeType);\n\n // Whether an attribute is instanced is essentially fixed by the structure of the shader code, \n // so it is arguably a static property of the shader.\n // There is no hint in the shader declarations\n // Heuristic: Any attribute name containing the word \"instance\" will be assumed to be instanced\n const stepMode = /instance/i.test(name) ? 'instance' : 'vertex';\n\n attributes.push({\n name,\n location,\n stepMode,\n type: attributeType,\n // size - for arrays, size is the number of elements in the array\n });\n }\n }\n\n // Sort by declaration order\n attributes.sort((a: AttributeDeclaration, b: AttributeDeclaration) => a.location - b.location);\n return attributes;\n}\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): VaryingBinding[] {\n if (!isWebGL2(gl)) {\n return [];\n }\n const gl2 = gl as WebGL2RenderingContext;\n\n const varyings: VaryingBinding[] = [];\n\n const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);\n for (let location = 0; location < count; location++) {\n const activeInfo = gl2.getTransformFeedbackVarying(program, location);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType, size} = activeInfo;\n const {glType, components} = decodeGLUniformType(compositeType);\n const accessor = new Accessor({type: glType, size: size * components});\n const varying = {location, name, accessor}; // Base values\n varyings.push(varying);\n }\n\n varyings.sort((a, b) => a.location - b.location);\n return varyings;\n}\n\n/**\n * Extract info about all uniforms\n *\n * Query uniform locations and build name to setter map.\n */\nfunction readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram): UniformBinding[] {\n const uniforms: UniformBinding[] = [];\n\n const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);\n for (let i = 0; i < uniformCount; i++) {\n const activeInfo = gl.getActiveUniform(program, i);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name: rawName, size, type} = activeInfo;\n const {name, isArray} = parseUniformName(rawName);\n let webglLocation = gl.getUniformLocation(program, name);\n const uniformInfo = {\n // WebGL locations are uniquely typed but just numbers\n location: webglLocation as number,\n name,\n size,\n type,\n isArray\n };\n uniforms.push(uniformInfo);\n\n // Array (e.g. matrix) uniforms can occupy several 4x4 byte banks\n if (uniformInfo.size > 1) {\n for (let j = 0; j < uniformInfo.size; j++) {\n const elementName = `${name}[${j}]`;\n\n webglLocation = gl.getUniformLocation(program, elementName);\n\n const arrayElementUniformInfo = {\n ...uniformInfo,\n name: elementName,\n location: webglLocation as number\n };\n\n uniforms.push(arrayElementUniformInfo);\n }\n }\n }\n return uniforms;\n}\n\n/**\n * Extract info about all \"active\" uniform blocks\n * @note In WebGL, \"active\" just means that unused (inactive) blocks may have been optimized away during linking)\n */\nfunction readUniformBlocks(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): UniformBlockBinding[] {\n if (!isWebGL2(gl)) {\n return [];\n }\n const gl2 = gl as WebGL2RenderingContext;\n\n const getBlockParameter = (blockIndex: number, pname: GL): any =>\n gl2.getActiveUniformBlockParameter(program, blockIndex, pname);\n\n const uniformBlocks: UniformBlockBinding[] = [];\n\n const blockCount = gl2.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {\n const blockInfo: UniformBlockBinding = {\n name: gl2.getActiveUniformBlockName(program, blockIndex) || '',\n location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),\n byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),\n vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n fragment: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n uniformCount: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n uniforms: [] as any[]\n };\n\n const uniformIndices =\n (getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[]) || [];\n\n const uniformType = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.\n const uniformArrayLength = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.\n // const uniformBlockIndex = gl2.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_BLOCK_INDEX\n // ); // Array of GLint indicating the block indices of the uniforms.\n const uniformOffset = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.\n const uniformStride = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.\n // const uniformMatrixStride = gl2.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_MATRIX_STRIDE\n // ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.\n // const uniformRowMajor = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);\n for (let i = 0; i < blockInfo.uniformCount; ++i) {\n const activeInfo = gl2.getActiveUniform(program, uniformIndices[i]);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n\n blockInfo.uniforms.push({\n name: activeInfo.name,\n format: decodeGLUniformType(uniformType[i]).format,\n type: uniformType[i],\n arrayLength: uniformArrayLength[i],\n byteOffset: uniformOffset[i],\n byteStride: uniformStride[i]\n // matrixStride: uniformStride[i],\n // rowMajor: uniformRowMajor[i]\n });\n }\n\n uniformBlocks.push(blockInfo);\n }\n\n uniformBlocks.sort((a, b) => a.location - b.location);\n return uniformBlocks;\n}\n\n/**\n * TOOD - compare with a above, confirm copy, then delete\n const bindings: Binding[] = [];\n const count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < count; blockIndex++) {\n const vertex = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n const fragment = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n const visibility = (vertex) + (fragment);\n const binding: BufferBinding = {\n location: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_BINDING),\n // name: gl.getActiveUniformBlockName(program, blockIndex),\n type: 'uniform',\n visibility,\n minBindingSize: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_DATA_SIZE),\n // uniformCount: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n // uniformIndices: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),\n }\n bindings.push(binding);\n }\n*/\n\nconst SAMPLER_UNIFORMS_GL_TO_GPU: Record<\n number,\n [\n '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d',\n 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint'\n ]\n> = {\n [GL.SAMPLER_2D]: ['2d', 'float'],\n [GL.SAMPLER_CUBE]: ['cube', 'float'],\n [GL.SAMPLER_3D]: ['3d', 'float'],\n [GL.SAMPLER_2D_SHADOW]: ['3d', 'depth'],\n [GL.SAMPLER_2D_ARRAY]: ['2d-array', 'float'],\n [GL.SAMPLER_2D_ARRAY_SHADOW]: ['2d-array', 'depth'],\n [GL.SAMPLER_CUBE_SHADOW]: ['cube', 'float'],\n [GL.INT_SAMPLER_2D]: ['2d', 'sint'],\n [GL.INT_SAMPLER_3D]: ['3d', 'sint'],\n [GL.INT_SAMPLER_CUBE]: ['cube', 'sint'],\n [GL.INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D]: ['2d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_3D]: ['3d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_CUBE]: ['cube', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint']\n};\n\ntype SamplerInfo = {\n viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n sampleType: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';\n};\n\nfunction getSamplerInfo(type: GL): SamplerInfo {\n const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];\n if (!sampler) {\n throw new Error('sampler');\n }\n const [viewDimension, sampleType] = sampler;\n return {viewDimension, sampleType};\n}\n\n// HELPERS\n\nfunction parseUniformName(name: string): {name: string; length: number; isArray: boolean} {\n // Shortcut to avoid redundant or bad matches\n if (name[name.length - 1] !== ']') {\n return {\n name,\n length: 1,\n isArray: false\n };\n }\n\n // if array name then clean the array brackets\n const UNIFORM_NAME_REGEXP = /([^[]*)(\\[[0-9]+\\])?/;\n const matches = UNIFORM_NAME_REGEXP.exec(name);\n if (!matches || matches.length < 2) {\n throw new Error(`Failed to parse GLSL uniform name ${name}`);\n }\n\n return {\n name: matches[1],\n length: matches[2] ? 1 : 0,\n isArray: Boolean(matches[2])\n };\n}\n"],"mappings":"AAUA,SAAQA,EAAE,QAAO,oBAAoB;AAAC,SAC9BC,QAAQ;AAAA,SACRC,QAAQ;AAAA,SACRC,mBAAmB,EAAEC,qBAAqB,EAAEC,gBAAgB;AAOpE,OAAO,SAASC,eAAeA,CAACC,EAAyB,EAAEC,OAAqB,EAAgB;EAC9F,MAAMC,YAA0B,GAAG;IACjCC,UAAU,EAAE,EAAE;IACdC,QAAQ,EAAE;EACZ,CAAC;EAEDF,YAAY,CAACC,UAAU,GAAGE,yBAAyB,CAACL,EAAE,EAAEC,OAAO,CAAC;EAGhE,MAAMK,aAAoC,GAAGC,iBAAiB,CAACP,EAAE,EAAEC,OAAO,CAAC;EAC3E,KAAK,MAAMO,YAAY,IAAIF,aAAa,EAAE;IACxC,MAAMG,QAAQ,GAAGD,YAAY,CAACC,QAAQ,CAACC,GAAG,CAACC,OAAO,KAAK;MACrDC,IAAI,EAAED,OAAO,CAACC,IAAI;MAClBC,MAAM,EAAEF,OAAO,CAACE,MAAM;MACtBC,UAAU,EAAEH,OAAO,CAACG,UAAU;MAC9BC,UAAU,EAAEJ,OAAO,CAACI,UAAU;MAC9BC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AAEC,UAAU,CAAC,GAAGkF,OAAO;EAC3C,OAAO;IAACnF,aAAa;IAAEC;EAAU,CAAC;AACpC;AAIA,SAASkC,gBAAgBA,CAAClD,IAAY,EAAoD;EAExF,IAAIA,IAAI,CAACA,IAAI,CAACkB,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;IACjC,OAAO;MACLlB,IAAI;MACJkB,MAAM,EAAE,CAAC;MACT+B,OAAO,EAAE;IACX,CAAC;EACH;EAGA,MAAMkD,mBAAmB,GAAG,sBAAsB;EAClD,MAAMC,OAAO,GAAGD,mBAAmB,CAACE,IAAI,CAACrG,IAAI,CAAC;EAC9C,IAAI,CAACoG,OAAO,IAAIA,OAAO,CAAClF,MAAM,GAAG,CAAC,EAAE;IAClC,MAAM,IAAIS,KAAK,sCAAA6B,MAAA,CAAsCxD,IAAI,CAAE,CAAC;EAC9D;EAEA,OAAO;IACLA,IAAI,EAAEoG,OAAO,CAAC,CAAC,CAAC;IAChBlF,MAAM,EAAEkF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC1BnD,OAAO,EAAEqD,OAAO,CAACF,OAAO,CAAC,CAAC,CAAC;EAC7B,CAAC;AACH"}
1
+ {"version":3,"file":"get-shader-layout.js","names":["GL","isWebGL2","Accessor","decodeGLUniformType","decodeGLAttributeType","isSamplerUniform","getShaderLayout","gl","program","shaderLayout","attributes","bindings","readAttributeDeclarations","uniformBlocks","readUniformBlocks","uniformBlock","uniforms","map","uniform","name","format","byteOffset","byteStride","arrayLength","push","type","location","visibility","vertex","fragment","minBindingSize","byteLength","readUniformBindings","textureUnit","viewDimension","sampleType","getSamplerInfo","length","varyings","readVaryings","count","getProgramParameter","ACTIVE_ATTRIBUTES","index","activeInfo","getActiveAttrib","Error","compositeType","getAttribLocation","attributeType","stepMode","test","sort","a","b","gl2","TRANSFORM_FEEDBACK_VARYINGS","getTransformFeedbackVarying","size","glType","components","accessor","varying","uniformCount","ACTIVE_UNIFORMS","i","getActiveUniform","rawName","isArray","parseUniformName","webglLocation","getUniformLocation","uniformInfo","j","elementName","arrayElementUniformInfo","getBlockParameter","blockIndex","pname","getActiveUniformBlockParameter","blockCount","ACTIVE_UNIFORM_BLOCKS","blockInfo","getActiveUniformBlockName","UNIFORM_BLOCK_BINDING","UNIFORM_BLOCK_DATA_SIZE","UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER","UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER","UNIFORM_BLOCK_ACTIVE_UNIFORMS","uniformIndices","UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES","uniformType","getActiveUniforms","UNIFORM_TYPE","uniformArrayLength","UNIFORM_SIZE","uniformOffset","UNIFORM_OFFSET","uniformStride","UNIFORM_ARRAY_STRIDE","SAMPLER_UNIFORMS_GL_TO_GPU","SAMPLER_2D","SAMPLER_CUBE","SAMPLER_3D","SAMPLER_2D_SHADOW","SAMPLER_2D_ARRAY","SAMPLER_2D_ARRAY_SHADOW","SAMPLER_CUBE_SHADOW","INT_SAMPLER_2D","INT_SAMPLER_3D","INT_SAMPLER_CUBE","INT_SAMPLER_2D_ARRAY","UNSIGNED_INT_SAMPLER_2D","UNSIGNED_INT_SAMPLER_3D","UNSIGNED_INT_SAMPLER_CUBE","UNSIGNED_INT_SAMPLER_2D_ARRAY","sampler","UNIFORM_NAME_REGEXP","matches","exec","Boolean"],"sources":["../../../src/adapter/helpers/get-shader-layout.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {\n ShaderLayout,\n UniformBinding,\n UniformBlockBinding,\n AttributeDeclaration,\n VaryingBinding\n} from '@luma.gl/core';\n\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2} from '../../context/context/webgl-checks';\nimport {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API\nimport {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './decode-webgl-types';\n\n/**\n * Extract metadata describing binding information for a program's shaders\n * Note: `linkProgram()` needs to have been called\n * (although linking does not need to have been successful).\n */\nexport function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram): ShaderLayout {\n const shaderLayout: ShaderLayout = {\n attributes: [],\n bindings: []\n };\n\n shaderLayout.attributes = readAttributeDeclarations(gl, program);\n\n // Uniform blocks\n const uniformBlocks: UniformBlockBinding[] = readUniformBlocks(gl, program);\n for (const uniformBlock of uniformBlocks) {\n const uniforms = uniformBlock.uniforms.map(uniform => ({\n name: uniform.name,\n format: uniform.format,\n byteOffset: uniform.byteOffset,\n byteStride: uniform.byteStride,\n arrayLength: uniform.arrayLength\n }));\n shaderLayout.bindings.push({\n type: 'uniform',\n name: uniformBlock.name,\n location: uniformBlock.location,\n visibility: (uniformBlock.vertex ? 0x1 : 0) & (uniformBlock.fragment ? 0x2 : 0),\n minBindingSize: uniformBlock.byteLength,\n uniforms\n });\n }\n\n const uniforms: UniformBinding[] = readUniformBindings(gl, program);\n let textureUnit = 0;\n for (const uniform of uniforms) {\n if (isSamplerUniform(uniform.type)) {\n const {viewDimension, sampleType} = getSamplerInfo(uniform.type);\n shaderLayout.bindings.push({\n type: 'texture',\n name: uniform.name,\n location: textureUnit,\n viewDimension,\n sampleType\n });\n\n // @ts-expect-error\n uniform.textureUnit = textureUnit;\n textureUnit += 1;\n }\n }\n\n if (uniforms.length) {\n shaderLayout.uniforms = uniforms;\n }\n\n // Varyings\n const varyings: VaryingBinding[] = readVaryings(gl, program);\n // Note - samplers are always in unform bindings, even if uniform blocks are used\n if (varyings?.length) {\n shaderLayout.varyings = varyings;\n }\n\n return shaderLayout;\n}\n\n// HELPERS\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readAttributeDeclarations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): AttributeDeclaration[] {\n const attributes: AttributeDeclaration[] = [];\n\n const count = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n\n for (let index = 0; index < count; index++) {\n const activeInfo = gl.getActiveAttrib(program, index);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType /* , size*/} = activeInfo;\n const location = gl.getAttribLocation(program, name);\n // Add only user provided attributes, for built-in attributes like `gl_InstanceID` location will be < 0\n if (location >= 0) {\n const {attributeType} = decodeGLAttributeType(compositeType);\n\n // Whether an attribute is instanced is essentially fixed by the structure of the shader code, \n // so it is arguably a static property of the shader.\n // There is no hint in the shader declarations\n // Heuristic: Any attribute name containing the word \"instance\" will be assumed to be instanced\n const stepMode = /instance/i.test(name) ? 'instance' : 'vertex';\n\n attributes.push({\n name,\n location,\n stepMode,\n type: attributeType,\n // size - for arrays, size is the number of elements in the array\n });\n }\n }\n\n // Sort by declaration order\n attributes.sort((a: AttributeDeclaration, b: AttributeDeclaration) => a.location - b.location);\n return attributes;\n}\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): VaryingBinding[] {\n if (!isWebGL2(gl)) {\n return [];\n }\n const gl2 = gl as WebGL2RenderingContext;\n\n const varyings: VaryingBinding[] = [];\n\n const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);\n for (let location = 0; location < count; location++) {\n const activeInfo = gl2.getTransformFeedbackVarying(program, location);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType, size} = activeInfo;\n const {glType, components} = decodeGLUniformType(compositeType);\n const accessor = new Accessor({type: glType, size: size * components});\n const varying = {location, name, accessor}; // Base values\n varyings.push(varying);\n }\n\n varyings.sort((a, b) => a.location - b.location);\n return varyings;\n}\n\n/**\n * Extract info about all uniforms\n *\n * Query uniform locations and build name to setter map.\n */\nfunction readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram): UniformBinding[] {\n const uniforms: UniformBinding[] = [];\n\n const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);\n for (let i = 0; i < uniformCount; i++) {\n const activeInfo = gl.getActiveUniform(program, i);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name: rawName, size, type} = activeInfo;\n const {name, isArray} = parseUniformName(rawName);\n let webglLocation = gl.getUniformLocation(program, name);\n const uniformInfo = {\n // WebGL locations are uniquely typed but just numbers\n location: webglLocation as number,\n name,\n size,\n type,\n isArray\n };\n uniforms.push(uniformInfo);\n\n // Array (e.g. matrix) uniforms can occupy several 4x4 byte banks\n if (uniformInfo.size > 1) {\n for (let j = 0; j < uniformInfo.size; j++) {\n const elementName = `${name}[${j}]`;\n\n webglLocation = gl.getUniformLocation(program, elementName);\n\n const arrayElementUniformInfo = {\n ...uniformInfo,\n name: elementName,\n location: webglLocation as number\n };\n\n uniforms.push(arrayElementUniformInfo);\n }\n }\n }\n return uniforms;\n}\n\n/**\n * Extract info about all \"active\" uniform blocks\n * @note In WebGL, \"active\" just means that unused (inactive) blocks may have been optimized away during linking)\n */\nfunction readUniformBlocks(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): UniformBlockBinding[] {\n if (!isWebGL2(gl)) {\n return [];\n }\n const gl2 = gl as WebGL2RenderingContext;\n\n const getBlockParameter = (blockIndex: number, pname: GL): any =>\n gl2.getActiveUniformBlockParameter(program, blockIndex, pname);\n\n const uniformBlocks: UniformBlockBinding[] = [];\n\n const blockCount = gl2.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {\n const blockInfo: UniformBlockBinding = {\n name: gl2.getActiveUniformBlockName(program, blockIndex) || '',\n location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),\n byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),\n vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n fragment: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n uniformCount: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n uniforms: [] as any[]\n };\n\n const uniformIndices =\n (getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[]) || [];\n\n const uniformType = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.\n const uniformArrayLength = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.\n // const uniformBlockIndex = gl2.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_BLOCK_INDEX\n // ); // Array of GLint indicating the block indices of the uniforms.\n const uniformOffset = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.\n const uniformStride = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.\n // const uniformMatrixStride = gl2.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_MATRIX_STRIDE\n // ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.\n // const uniformRowMajor = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);\n for (let i = 0; i < blockInfo.uniformCount; ++i) {\n const activeInfo = gl2.getActiveUniform(program, uniformIndices[i]);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n\n blockInfo.uniforms.push({\n name: activeInfo.name,\n format: decodeGLUniformType(uniformType[i]).format,\n type: uniformType[i],\n arrayLength: uniformArrayLength[i],\n byteOffset: uniformOffset[i],\n byteStride: uniformStride[i]\n // matrixStride: uniformStride[i],\n // rowMajor: uniformRowMajor[i]\n });\n }\n\n uniformBlocks.push(blockInfo);\n }\n\n uniformBlocks.sort((a, b) => a.location - b.location);\n return uniformBlocks;\n}\n\n/**\n * TOOD - compare with a above, confirm copy, then delete\n const bindings: Binding[] = [];\n const count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < count; blockIndex++) {\n const vertex = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n const fragment = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n const visibility = (vertex) + (fragment);\n const binding: BufferBinding = {\n location: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_BINDING),\n // name: gl.getActiveUniformBlockName(program, blockIndex),\n type: 'uniform',\n visibility,\n minBindingSize: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_DATA_SIZE),\n // uniformCount: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n // uniformIndices: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),\n }\n bindings.push(binding);\n }\n*/\n\nconst SAMPLER_UNIFORMS_GL_TO_GPU: Record<\n number,\n [\n '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d',\n 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint'\n ]\n> = {\n [GL.SAMPLER_2D]: ['2d', 'float'],\n [GL.SAMPLER_CUBE]: ['cube', 'float'],\n [GL.SAMPLER_3D]: ['3d', 'float'],\n [GL.SAMPLER_2D_SHADOW]: ['3d', 'depth'],\n [GL.SAMPLER_2D_ARRAY]: ['2d-array', 'float'],\n [GL.SAMPLER_2D_ARRAY_SHADOW]: ['2d-array', 'depth'],\n [GL.SAMPLER_CUBE_SHADOW]: ['cube', 'float'],\n [GL.INT_SAMPLER_2D]: ['2d', 'sint'],\n [GL.INT_SAMPLER_3D]: ['3d', 'sint'],\n [GL.INT_SAMPLER_CUBE]: ['cube', 'sint'],\n [GL.INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D]: ['2d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_3D]: ['3d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_CUBE]: ['cube', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint']\n};\n\ntype SamplerInfo = {\n viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n sampleType: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';\n};\n\nfunction getSamplerInfo(type: GL): SamplerInfo {\n const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];\n if (!sampler) {\n throw new Error('sampler');\n }\n const [viewDimension, sampleType] = sampler;\n return {viewDimension, sampleType};\n}\n\n// HELPERS\n\nfunction parseUniformName(name: string): {name: string; length: number; isArray: boolean} {\n // Shortcut to avoid redundant or bad matches\n if (name[name.length - 1] !== ']') {\n return {\n name,\n length: 1,\n isArray: false\n };\n }\n\n // if array name then clean the array brackets\n const UNIFORM_NAME_REGEXP = /([^[]*)(\\[[0-9]+\\])?/;\n const matches = UNIFORM_NAME_REGEXP.exec(name);\n if (!matches || matches.length < 2) {\n throw new Error(`Failed to parse GLSL uniform name ${name}`);\n }\n\n return {\n name: matches[1],\n length: matches[2] ? 1 : 0,\n isArray: Boolean(matches[2])\n };\n}\n"],"mappings":"AAUA,SAAQA,EAAE,QAAO,oBAAoB;AAAC,SAC9BC,QAAQ;AAAA,SACRC,QAAQ;AAAA,SACRC,mBAAmB,EAAEC,qBAAqB,EAAEC,gBAAgB;AAOpE,OAAO,SAASC,eAAeA,CAACC,EAAyB,EAAEC,OAAqB,EAAgB;EAC9F,MAAMC,YAA0B,GAAG;IACjCC,UAAU,EAAE,EAAE;IACdC,QAAQ,EAAE;EACZ,CAAC;EAEDF,YAAY,CAACC,UAAU,GAAGE,yBAAyB,CAACL,EAAE,EAAEC,OAAO,CAAC;EAGhE,MAAMK,aAAoC,GAAGC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AAM,EAAE,MAAM,CAAC;EAChD,CAAClH,EAAE,CAACmH,6BAA6B,GAAG,CAAC,UAAU,EAAE,MAAM;AACzD,CAAC;AAOD,SAAS/E,cAAcA,CAACX,IAAQ,EAAe;EAC7C,MAAM2F,OAAO,GAAGhB,0BAA0B,CAAC3E,IAAI,CAAC;EAChD,IAAI,CAAC2F,OAAO,EAAE;IACZ,MAAM,IAAItE,KAAK,CAAC,SAAS,CAAC;EAC5B;EACA,MAAM,CAACZ,aAAa,EAAEC,UAAU,CAAC,GAAGiF,OAAO;EAC3C,OAAO;IAAClF,aAAa;IAAEC;EAAU,CAAC;AACpC;AAIA,SAASkC,gBAAgBA,CAAClD,IAAY,EAAoD;EAExF,IAAIA,IAAI,CAACA,IAAI,CAACkB,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;IACjC,OAAO;MACLlB,IAAI;MACJkB,MAAM,EAAE,CAAC;MACT+B,OAAO,EAAE;IACX,CAAC;EACH;EAGA,MAAMiD,mBAAmB,GAAG,sBAAsB;EAClD,MAAMC,OAAO,GAAGD,mBAAmB,CAACE,IAAI,CAACpG,IAAI,CAAC;EAC9C,IAAI,CAACmG,OAAO,IAAIA,OAAO,CAACjF,MAAM,GAAG,CAAC,EAAE;IAClC,MAAM,IAAIS,KAAK,CAAE,qCAAoC3B,IAAK,EAAC,CAAC;EAC9D;EAEA,OAAO;IACLA,IAAI,EAAEmG,OAAO,CAAC,CAAC,CAAC;IAChBjF,MAAM,EAAEiF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC1BlD,OAAO,EAAEoD,OAAO,CAACF,OAAO,CAAC,CAAC,CAAC;EAC7B,CAAC;AACH"}
@@ -9,7 +9,7 @@ export function getKeyValue(gl, name) {
9
9
  }
10
10
  name = name.replace(/^.*\./, '');
11
11
  const value = gl[name];
12
- assert(value !== undefined, "Accessing undefined constant GL.".concat(name));
12
+ assert(value !== undefined, `Accessing undefined constant GL.${name}`);
13
13
  return value;
14
14
  }
15
15
  //# sourceMappingURL=constants-to-keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants-to-keys.js","names":["assert","getKeyValue","gl","name","number","Number","isNaN","replace","value","undefined","concat"],"sources":["../../../src/adapter/objects/constants-to-keys.ts"],"sourcesContent":["import {assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\n// Resolve a WebGL enumeration name (returns itself if already a number)\nexport function getKeyValue(gl: WebGLRenderingContext, name: string | GL): GL {\n // If not a string, return (assume number)\n if (typeof name !== 'string') {\n return name;\n }\n\n // If string converts to number, return number\n const number = Number(name);\n if (!isNaN(number)) {\n return number;\n }\n\n // Look up string, after removing any 'GL.' or 'gl.' prefix\n name = name.replace(/^.*\\./, '');\n // @ts-ignore expect-error depends on settings\n const value = gl[name];\n assert(value !== undefined, `Accessing undefined constant GL.${name}`);\n return value;\n}\n"],"mappings":"AAAA,SAAQA,MAAM,QAAO,eAAe;AAIpC,OAAO,SAASC,WAAWA,CAACC,EAAyB,EAAEC,IAAiB,EAAM;EAE5E,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI;EACb;EAGA,MAAMC,MAAM,GAAGC,MAAM,CAACF,IAAI,CAAC;EAC3B,IAAI,CAACG,KAAK,CAACF,MAAM,CAAC,EAAE;IAClB,OAAOA,MAAM;EACf;EAGAD,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;EAEhC,MAAMC,KAAK,GAAGN,EAAE,CAACC,IAAI,CAAC;EACtBH,MAAM,CAACQ,KAAK,KAAKC,SAAS,qCAAAC,MAAA,CAAqCP,IAAI,CAAE,CAAC;EACtE,OAAOK,KAAK;AACd"}
1
+ {"version":3,"file":"constants-to-keys.js","names":["assert","getKeyValue","gl","name","number","Number","isNaN","replace","value","undefined"],"sources":["../../../src/adapter/objects/constants-to-keys.ts"],"sourcesContent":["import {assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\n// Resolve a WebGL enumeration name (returns itself if already a number)\nexport function getKeyValue(gl: WebGLRenderingContext, name: string | GL): GL {\n // If not a string, return (assume number)\n if (typeof name !== 'string') {\n return name;\n }\n\n // If string converts to number, return number\n const number = Number(name);\n if (!isNaN(number)) {\n return number;\n }\n\n // Look up string, after removing any 'GL.' or 'gl.' prefix\n name = name.replace(/^.*\\./, '');\n // @ts-ignore expect-error depends on settings\n const value = gl[name];\n assert(value !== undefined, `Accessing undefined constant GL.${name}`);\n return value;\n}\n"],"mappings":"AAAA,SAAQA,MAAM,QAAO,eAAe;AAIpC,OAAO,SAASC,WAAWA,CAACC,EAAyB,EAAEC,IAAiB,EAAM;EAE5E,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI;EACb;EAGA,MAAMC,MAAM,GAAGC,MAAM,CAACF,IAAI,CAAC;EAC3B,IAAI,CAACG,KAAK,CAACF,MAAM,CAAC,EAAE;IAClB,OAAOA,MAAM;EACf;EAGAD,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;EAEhC,MAAMC,KAAK,GAAGN,EAAE,CAACC,IAAI,CAAC;EACtBH,MAAM,CAACQ,KAAK,KAAKC,SAAS,EAAG,mCAAkCN,IAAK,EAAC,CAAC;EACtE,OAAOK,KAAK;AACd"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  let _Symbol$toStringTag;
3
2
  import { assert } from '@luma.gl/core';
4
3
  import { GL } from '@luma.gl/constants';
@@ -33,7 +32,7 @@ export class WEBGLRenderbuffer extends WebGLResource {
33
32
  throw new Error('Renderbuffer');
34
33
  }
35
34
  super(device, props, WEBGLRenderbuffer.defaultProps);
36
- _defineProperty(this, "glFormat", void 0);
35
+ this.glFormat = void 0;
37
36
  this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);
38
37
  this._initialize(this.props);
39
38
  }
@@ -76,7 +75,7 @@ export class WEBGLRenderbuffer extends WebGLResource {
76
75
  this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);
77
76
  }
78
77
  }
79
- _defineProperty(WEBGLRenderbuffer, "defaultProps", {
78
+ WEBGLRenderbuffer.defaultProps = {
80
79
  id: undefined,
81
80
  handle: undefined,
82
81
  userData: undefined,
@@ -84,5 +83,5 @@ _defineProperty(WEBGLRenderbuffer, "defaultProps", {
84
83
  width: 1,
85
84
  height: 1,
86
85
  samples: 0
87
- });
86
+ };
88
87
  //# sourceMappingURL=webgl-renderbuffer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-renderbuffer.js","names":["assert","GL","WebGLResource","isRenderbufferFormatSupported","convertTextureFormatToGL","getTextureFormatBytesPerPixel","_Symbol$toStringTag","Symbol","toStringTag","WEBGLRenderbuffer","width","props","height","format","samples","attachment","isTextureFormatSupported","device","gl","constructor","Error","defaultProps","_defineProperty","glFormat","isWebGL2","_initialize","resize","size","Object","assign","trackDeallocatedMemory","bindRenderbuffer","RENDERBUFFER","handle","gl2","renderbufferStorageMultisample","renderbufferStorage","trackAllocatedMemory","_createHandle","createRenderbuffer","_deleteHandle","deleteRenderbuffer","_bindHandle","id","undefined","userData"],"sources":["../../../src/adapter/objects/webgl-renderbuffer.ts"],"sourcesContent":["import {assert, ResourceProps, TextureFormat} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\nimport {isRenderbufferFormatSupported} from '../converters/texture-formats';\nimport {convertTextureFormatToGL, getTextureFormatBytesPerPixel} from '../converters/texture-formats';\n\nexport type RenderbufferProps = ResourceProps & {\n format: TextureFormat;\n width?: number;\n height?: number;\n samples?: number;\n};\n\n/**\n * Renderbuffers are GPU objects that contain images.\n * In contrast to Textures they are optimized for use as render targets, with Framebuffers.\n * while Textures may not be, and are the logical choice when\n * you do not need to sample (i.e. in a post-pass shader)\n * from the produced image. If you need to resample\n * (such as when reading depth back in a second shader pass),\n * use Textures instead.\n * Renderbuffer objects also natively accommodate Multisampling (MSAA).\n */\nexport class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {\n static override readonly defaultProps: Required<RenderbufferProps> = {\n id: undefined,\n handle: undefined,\n userData: undefined,\n format: undefined, // 'depth16unorm'\n width: 1,\n height: 1, \n samples: 0\n }; \n\n override get [Symbol.toStringTag](): string { return 'Renderbuffer'; }\n\n get width(): number { return this.props.width; }\n get height(): number { return this.props.height; }\n get format(): TextureFormat { return this.props.format; }\n get samples(): number { return this.props.samples; }\n get attachment() { return }\n\n /** WebGL format constant */\n glFormat: GL;\n\n static isTextureFormatSupported(device: WebGLDevice, format: TextureFormat): boolean {\n return isRenderbufferFormatSupported(device.gl, format);\n }\n\n constructor(device: WebGLDevice, props: RenderbufferProps) {\n // TODO - remove temporary sanity check\n if (typeof props.format === 'number') {\n throw new Error('Renderbuffer');\n }\n super(device, props, WEBGLRenderbuffer.defaultProps);\n this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);\n this._initialize(this.props);\n }\n\n resize(size: {width: number, height: number}): void {\n // Don't resize if width/height haven't changed\n if (size.width !== this.width || size.height !== this.height) {\n Object.assign(this.props, {...size, format: this.format, samples: this.samples});\n this._initialize(this.props);\n }\n }\n\n // PRIVATE METHODS\n\n /** Creates and initializes a renderbuffer object's data store */\n protected _initialize(props: Required<RenderbufferProps>): void {\n const {format, width, height, samples} = props;\n assert(format, 'Needs format');\n\n this.trackDeallocatedMemory();\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);\n\n if (samples !== 0 && this.device.isWebGL2) {\n this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);\n } else {\n this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);\n }\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);\n\n this.trackAllocatedMemory(\n width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)\n );\n }\n\n // RESOURCE IMPLEMENTATION\n\n override _createHandle() {\n return this.gl.createRenderbuffer();\n }\n\n override _deleteHandle(): void {\n this.gl.deleteRenderbuffer(this.handle);\n this.trackDeallocatedMemory();\n }\n\n override _bindHandle(handle: WEBGLRenderbuffer): void {\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);\n }\n}\n"],"mappings":";;AAAA,SAAQA,MAAM,QAAqC,eAAe;AAClE,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,aAAa;AAAA,SACbC,6BAA6B;AAAA,SAC7BC,wBAAwB,EAAEC,6BAA6B;AAAAC,mBAAA,GA8B/CC,MAAM,CAACC,WAAW;AAXlC,OAAO,MAAMC,iBAAiB,SAASP,aAAa,CAAoB;EAWtE,KAAAI,mBAAA,IAA4C;IAAE,OAAO,cAAc;EAAE;EAErE,IAAII,KAAKA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACC,KAAK,CAACD,KAAK;EAAE;EAC/C,IAAIE,MAAMA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACD,KAAK,CAACC,MAAM;EAAE;EACjD,IAAIC,MAAMA,CAAA,EAAkB;IAAE,OAAO,IAAI,CAACF,KAAK,CAACE,MAAM;EAAE;EACxD,IAAIC,OAAOA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACH,KAAK,CAACG,OAAO;EAAE;EACnD,IAAIC,UAAUA,CAAA,EAAG;IAAE;EAAQ;EAK3B,OAAOC,wBAAwBA,CAACC,MAAmB,EAAEJ,MAAqB,EAAW;IACnF,OAAOV,6BAA6B,CAACc,MAAM,CAACC,EAAE,EAAEL,MAAM,CAAC;EACzD;EAEAM,WAAWA,CAACF,MAAmB,EAAEN,KAAwB,EAAE;IAEzD,IAAI,OAAOA,KAAK,CAACE,MAAM,KAAK,QAAQ,EAAE;MACpC,MAAM,IAAIO,KAAK,CAAC,cAAc,CAAC;IACjC;IACA,KAAK,CAACH,MAAM,EAAEN,KAAK,EAAEF,iBAA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E,MAAM,CAAC;IAC5E;IAEA,IAAI,CAACM,EAAE,CAACa,gBAAgB,CAAC9B,EAAE,CAAC+B,YAAY,EAAE,IAAI,CAAC;IAE/C,IAAI,CAACK,oBAAoB,CACvB3B,KAAK,GAAGE,MAAM,IAAIE,OAAO,IAAI,CAAC,CAAC,GAAGT,6BAA6B,CAAC,IAAI,CAACkB,QAAQ,EAAE,IAAI,CAACN,MAAM,CAACO,QAAQ,CACrG,CAAC;EACH;EAISc,aAAaA,CAAA,EAAG;IACvB,OAAO,IAAI,CAACpB,EAAE,CAACqB,kBAAkB,CAAC,CAAC;EACrC;EAESC,aAAaA,CAAA,EAAS;IAC7B,IAAI,CAACtB,EAAE,CAACuB,kBAAkB,CAAC,IAAI,CAACR,MAAM,CAAC;IACvC,IAAI,CAACH,sBAAsB,CAAC,CAAC;EAC/B;EAESY,WAAWA,CAACT,MAAyB,EAAQ;IACpD,IAAI,CAACf,EAAE,CAACa,gBAAgB,CAAC9B,EAAE,CAAC+B,YAAY,EAAEC,MAAM,CAAC;EACnD;AACF;AAACX,eAAA,CAlFYb,iBAAiB,kBACyC;EACnEkC,EAAE,EAAEC,SAAS;EACbX,MAAM,EAAEW,SAAS;EACjBC,QAAQ,EAAED,SAAS;EACnB/B,MAAM,EAAE+B,SAAS;EACjBlC,KAAK,EAAE,CAAC;EACRE,MAAM,EAAE,CAAC;EACTE,OAAO,EAAE;AACX,CAAC"}
1
+ {"version":3,"file":"webgl-renderbuffer.js","names":["assert","GL","WebGLResource","isRenderbufferFormatSupported","convertTextureFormatToGL","getTextureFormatBytesPerPixel","_Symbol$toStringTag","Symbol","toStringTag","WEBGLRenderbuffer","width","props","height","format","samples","attachment","isTextureFormatSupported","device","gl","constructor","Error","defaultProps","glFormat","isWebGL2","_initialize","resize","size","Object","assign","trackDeallocatedMemory","bindRenderbuffer","RENDERBUFFER","handle","gl2","renderbufferStorageMultisample","renderbufferStorage","trackAllocatedMemory","_createHandle","createRenderbuffer","_deleteHandle","deleteRenderbuffer","_bindHandle","id","undefined","userData"],"sources":["../../../src/adapter/objects/webgl-renderbuffer.ts"],"sourcesContent":["import {assert, ResourceProps, TextureFormat} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\nimport {isRenderbufferFormatSupported} from '../converters/texture-formats';\nimport {convertTextureFormatToGL, getTextureFormatBytesPerPixel} from '../converters/texture-formats';\n\nexport type RenderbufferProps = ResourceProps & {\n format: TextureFormat;\n width?: number;\n height?: number;\n samples?: number;\n};\n\n/**\n * Renderbuffers are GPU objects that contain images.\n * In contrast to Textures they are optimized for use as render targets, with Framebuffers.\n * while Textures may not be, and are the logical choice when\n * you do not need to sample (i.e. in a post-pass shader)\n * from the produced image. If you need to resample\n * (such as when reading depth back in a second shader pass),\n * use Textures instead.\n * Renderbuffer objects also natively accommodate Multisampling (MSAA).\n */\nexport class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {\n static override readonly defaultProps: Required<RenderbufferProps> = {\n id: undefined,\n handle: undefined,\n userData: undefined,\n format: undefined, // 'depth16unorm'\n width: 1,\n height: 1, \n samples: 0\n }; \n\n override get [Symbol.toStringTag](): string { return 'Renderbuffer'; }\n\n get width(): number { return this.props.width; }\n get height(): number { return this.props.height; }\n get format(): TextureFormat { return this.props.format; }\n get samples(): number { return this.props.samples; }\n get attachment() { return }\n\n /** WebGL format constant */\n glFormat: GL;\n\n static isTextureFormatSupported(device: WebGLDevice, format: TextureFormat): boolean {\n return isRenderbufferFormatSupported(device.gl, format);\n }\n\n constructor(device: WebGLDevice, props: RenderbufferProps) {\n // TODO - remove temporary sanity check\n if (typeof props.format === 'number') {\n throw new Error('Renderbuffer');\n }\n super(device, props, WEBGLRenderbuffer.defaultProps);\n this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);\n this._initialize(this.props);\n }\n\n resize(size: {width: number, height: number}): void {\n // Don't resize if width/height haven't changed\n if (size.width !== this.width || size.height !== this.height) {\n Object.assign(this.props, {...size, format: this.format, samples: this.samples});\n this._initialize(this.props);\n }\n }\n\n // PRIVATE METHODS\n\n /** Creates and initializes a renderbuffer object's data store */\n protected _initialize(props: Required<RenderbufferProps>): void {\n const {format, width, height, samples} = props;\n assert(format, 'Needs format');\n\n this.trackDeallocatedMemory();\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);\n\n if (samples !== 0 && this.device.isWebGL2) {\n this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);\n } else {\n this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);\n }\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);\n\n this.trackAllocatedMemory(\n width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)\n );\n }\n\n // RESOURCE IMPLEMENTATION\n\n override _createHandle() {\n return this.gl.createRenderbuffer();\n }\n\n override _deleteHandle(): void {\n this.gl.deleteRenderbuffer(this.handle);\n this.trackDeallocatedMemory();\n }\n\n override _bindHandle(handle: WEBGLRenderbuffer): void {\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);\n }\n}\n"],"mappings":";AAAA,SAAQA,MAAM,QAAqC,eAAe;AAClE,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,aAAa;AAAA,SACbC,6BAA6B;AAAA,SAC7BC,wBAAwB,EAAEC,6BAA6B;AAAAC,mBAAA,GA8B/CC,MAAM,CAACC,WAAW;AAXlC,OAAO,MAAMC,iBAAiB,SAASP,aAAa,CAAoB;EAWtE,KAAAI,mBAAA,IAA4C;IAAE,OAAO,cAAc;EAAE;EAErE,IAAII,KAAKA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACC,KAAK,CAACD,KAAK;EAAE;EAC/C,IAAIE,MAAMA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACD,KAAK,CAACC,MAAM;EAAE;EACjD,IAAIC,MAAMA,CAAA,EAAk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,SAAS;EACbX,MAAM,EAAEW,SAAS;EACjBC,QAAQ,EAAED,SAAS;EACnB9B,MAAM,EAAE8B,SAAS;EACjBjC,KAAK,EAAE,CAAC;EACRE,MAAM,EAAE,CAAC;EACTE,OAAO,EAAE;AACX,CAAC"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Resource, assert, uid, stubRemovedMethods } from '@luma.gl/core';
3
2
  import { isWebGL2, assertWebGLContext } from "../../context/context/webgl-checks.js";
4
3
  import { WebGLDevice } from "../webgl-device.js";
@@ -7,12 +6,12 @@ const ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual met
7
6
  export class WebGLResource extends Resource {
8
7
  constructor(device, props, defaultProps) {
9
8
  super(device, props, defaultProps);
10
- _defineProperty(this, "device", void 0);
11
- _defineProperty(this, "gl", void 0);
12
- _defineProperty(this, "gl2", void 0);
13
- _defineProperty(this, "_handle", void 0);
14
- _defineProperty(this, "_bound", false);
15
- _defineProperty(this, "byteLength", 0);
9
+ this.device = void 0;
10
+ this.gl = void 0;
11
+ this.gl2 = void 0;
12
+ this._handle = void 0;
13
+ this._bound = false;
14
+ this.byteLength = 0;
16
15
  this.device = WebGLDevice.attach(device);
17
16
  const gl = this.device.gl;
18
17
  assertWebGLContext(gl);
@@ -29,7 +28,7 @@ export class WebGLResource extends Resource {
29
28
  this.byteLength = 0;
30
29
  }
31
30
  toString() {
32
- return "".concat(this.constructor.name, "(").concat(this.id, ")");
31
+ return `${this.constructor.name}(${this.id})`;
33
32
  }
34
33
  get handle() {
35
34
  return this._handle;
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-resource.js","names":["Resource","assert","uid","stubRemovedMethods","isWebGL2","assertWebGLContext","WebGLDevice","getKeyValue","ERR_RESOURCE_METHOD_UNDEFINED","WebGLResource","constructor","device","props","defaultProps","_defineProperty","attach","gl","id","gl2","name","_handle","handle","undefined","_createHandle","byteLength","toString","concat","delete","deleteChildren","arguments","length","children","_deleteHandle","removeStats","filter","Boolean","forEach","child","destroy","bind","funcOrHandle","_bindHandle","value","_bound","unbind","getParameter","pname","parameters","PARAMETERS","parameter","isWebgl2","parameterAvailable","getExtension","extension","webgl1Default","webgl1","webgl2Default","webgl2","defaultValue","_getParameter","getParameters","options","keys","values","parameterKeys","Object","key","getGLKey","type","setParameter","Error","_setParameter","setParameters","className","version","methodNames","initialize","_getOptsFromHandle"],"sources":["../../../src/adapter/objects/webgl-resource.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/core';\nimport type {Device, ResourceProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2, assertWebGLContext} from '../../context/context/webgl-checks';\nimport {WebGLDevice} from '../webgl-device';\n\n// Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?\nimport {getKeyValue} from './constants-to-keys';\n\nconst ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';\n\n/**\n * Base class for WebGL object wrappers\n */\nexport abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n private _handle: any;\n\n private _bound = false;\n // Only meaningful for resources that allocate GPU memory\n byteLength = 0;\n\n constructor(device: Device, props: Props, defaultProps: Required<Props>) {\n super(device, props, defaultProps);\n\n this.device = WebGLDevice.attach(device);\n const gl = this.device.gl;\n\n assertWebGLContext(gl);\n\n // extends \n const {id} = props || {};\n this.gl = gl;\n this.gl2 = gl as WebGL2RenderingContext;\n this.id = id || uid(this.constructor.name);\n\n // Set the handle\n // If handle was provided, use it, otherwise create a new handle\n\n // TODO - Stores the handle with context loss information\n // this.glCount = glGetContextLossCount(this.gl);\n\n // Default VertexArray needs to be created with null handle, so compare against undefined\n this._handle = props?.handle;\n if (this._handle === undefined) {\n this._handle = this._createHandle();\n }\n\n this.byteLength = 0;\n }\n\n override toString(): string {\n return `${this.constructor.name}(${this.id})`;\n }\n\n get handle() {\n // TODO - Add context loss handling\n // Will regenerate and reinitialize the handle if necessary\n // const glCount = glGetContextLossCount(this.gl);\n // if (this.glCount !== glCount) {\n // this._handle = this._createHandle(this.props);\n // this._glCount = glCount;\n // // Reinitialize object\n // this.initialize(this.props);\n // }\n return this._handle;\n }\n\n override delete({deleteChildren = false} = {}) {\n // Delete this object, and get refs to any children\n // @ts-expect-error\n const children = this._handle && this._deleteHandle(this._handle);\n if (this._handle) {\n this.removeStats();\n }\n this._handle = null;\n\n // Optionally, recursively delete the children\n // @ts-expect-error\n if (children && deleteChildren) {\n // @ts-expect-error\n children.filter(Boolean).forEach((child) => child.destroy());\n }\n\n return this;\n }\n\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this._bindHandle(funcOrHandle);\n return this;\n }\n\n let value;\n\n if (!this._bound) {\n this._bindHandle(this.handle);\n this._bound = true;\n\n value = funcOrHandle();\n\n this._bound = false;\n this._bindHandle(null);\n } else {\n value = funcOrHandle();\n }\n\n return value;\n }\n\n unbind() {\n this.bind(null);\n }\n\n /**\n * Query a Resource parameter\n *\n * @param name\n * @return param\n */\n getParameter(pname: number, props: any = {}): any {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n // Use parameter definitions to handle unsupported parameters\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if we can query for this parameter\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n const webgl1Default = parameter.webgl1;\n const webgl2Default = 'webgl2' in parameter ? parameter.webgl2 : parameter.webgl1;\n const defaultValue = isWebgl2 ? webgl2Default : webgl1Default;\n return defaultValue;\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // Attempt to query for it and let WebGL report errors\n return this._getParameter(pname, props);\n }\n\n // Many resources support a getParameter call -\n // getParameters will get all parameters - slow but useful for debugging\n // eslint-disable-next-line complexity\n getParameters(options: {parameters?: any, keys?: any} = {}) {\n const {parameters, keys} = options;\n\n // Get parameter definitions for this Resource\n // @ts-expect-error\n const PARAMETERS = this.constructor.PARAMETERS || {};\n\n const isWebgl2 = isWebGL2(this.gl);\n\n const values: Record<string, any> = {};\n\n // Query all parameters if no list provided\n const parameterKeys = parameters || Object.keys(PARAMETERS);\n\n // WEBGL limits\n for (const pname of parameterKeys) {\n const parameter = PARAMETERS[pname];\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n parameter &&\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (parameterAvailable) {\n const key = keys ? this.device.getGLKey(pname) : pname;\n values[key] = this.getParameter(pname, options);\n if (keys && parameter.type === 'GLenum') {\n values[key] = this.device.getGLKey(values[key]);\n }\n }\n }\n\n return values;\n }\n\n /**\n * Update a Resource setting\n *\n * @todo - cache parameter to avoid issuing WebGL calls?\n *\n * @param pname - parameter (GL constant, value or key)\n * @param value {GLint|GLfloat|GLenum} \n * @return returns self to enable chaining\n */\n setParameter(pname: GL | string, value: any): this {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n throw new Error('Parameter not available on this platform');\n }\n\n // Handle string keys\n if (parameter.type === 'GLenum') {\n // @ts-expect-error\n value = getKeyValue(value);\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // attempt to set it and let WebGL report errors\n this._setParameter(pname, value);\n return this;\n }\n\n /*\n * Batch update resource parameters\n * Assumes the subclass supports a setParameter call\n */\n setParameters(parameters: Record<GL, any>) {\n for (const pname in parameters) {\n this.setParameter(pname, parameters[pname]);\n }\n return this;\n }\n\n // Install stubs for removed methods\n stubRemovedMethods(className: string, version: string, methodNames: string[]) {\n return stubRemovedMethods(this, className, version, methodNames);\n }\n\n // PUBLIC VIRTUAL METHODS\n initialize(props: ResourceProps) {}\n\n // PROTECTED METHODS - These must be overridden by subclass\n _createHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _deleteHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _bindHandle(handle: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getOptsFromHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getParameter(pname: GL, props: Record<string, any>): number {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _setParameter(pname: GL | string, value: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n // PRIVATE METHODS\n\n /*\n _addStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get('Resources Created').incrementCount();\n stats.get(`${name}s Created`).incrementCount();\n stats.get(`${name}s Active`).incrementCount();\n }\n\n _removeStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get(`${name}s Active`).decrementCount();\n }\n\n trackAllocatedMemory(bytes, name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').addCount(bytes);\n stats.get(`${name} Memory`).addCount(bytes);\n this.byteLength = bytes;\n }\n\n trackDeallocatedMemory(name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').subtractCount(this.byteLength);\n stats.get(`${name} Memory`).subtractCount(this.byteLength);\n this.byteLength = 0;\n }\n */\n}\n"],"mappings":";AACA,SAAQA,QAAQ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6B,CAAC;EAChD;EAEAqE,kBAAkBA,CAAA,EAAG;IACnB,MAAM,IAAIP,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;EAEAmD,aAAaA,CAACb,KAAS,EAAElC,KAA0B,EAAU;IAC3D,MAAM,IAAI0D,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;EAEA+D,aAAaA,CAACzB,KAAkB,EAAEJ,KAAU,EAAE;IAC5C,MAAM,IAAI4B,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;AAqCF"}
1
+ {"version":3,"file":"webgl-resource.js","names":["Resource","assert","uid","stubRemovedMethods","isWebGL2","assertWebGLContext","WebGLDevice","getKeyValue","ERR_RESOURCE_METHOD_UNDEFINED","WebGLResource","constructor","device","props","defaultProps","gl","gl2","_handle","_bound","byteLength","attach","id","name","handle","undefined","_createHandle","toString","delete","deleteChildren","arguments","length","children","_deleteHandle","removeStats","filter","Boolean","forEach","child","destroy","bind","funcOrHandle","_bindHandle","value","unbind","getParameter","pname","parameters","PARAMETERS","parameter","isWebgl2","parameterAvailable","getExtension","extension","webgl1Default","webgl1","webgl2Default","webgl2","defaultValue","_getParameter","getParameters","options","keys","values","parameterKeys","Object","key","getGLKey","type","setParameter","Error","_setParameter","setParameters","className","version","methodNames","initialize","_getOptsFromHandle"],"sources":["../../../src/adapter/objects/webgl-resource.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/core';\nimport type {Device, ResourceProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2, assertWebGLContext} from '../../context/context/webgl-checks';\nimport {WebGLDevice} from '../webgl-device';\n\n// Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?\nimport {getKeyValue} from './constants-to-keys';\n\nconst ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';\n\n/**\n * Base class for WebGL object wrappers\n */\nexport abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n private _handle: any;\n\n private _bound = false;\n // Only meaningful for resources that allocate GPU memory\n byteLength = 0;\n\n constructor(device: Device, props: Props, defaultProps: Required<Props>) {\n super(device, props, defaultProps);\n\n this.device = WebGLDevice.attach(device);\n const gl = this.device.gl;\n\n assertWebGLContext(gl);\n\n // extends \n const {id} = props || {};\n this.gl = gl;\n this.gl2 = gl as WebGL2RenderingContext;\n this.id = id || uid(this.constructor.name);\n\n // Set the handle\n // If handle was provided, use it, otherwise create a new handle\n\n // TODO - Stores the handle with context loss information\n // this.glCount = glGetContextLossCount(this.gl);\n\n // Default VertexArray needs to be created with null handle, so compare against undefined\n this._handle = props?.handle;\n if (this._handle === undefined) {\n this._handle = this._createHandle();\n }\n\n this.byteLength = 0;\n }\n\n override toString(): string {\n return `${this.constructor.name}(${this.id})`;\n }\n\n get handle() {\n // TODO - Add context loss handling\n // Will regenerate and reinitialize the handle if necessary\n // const glCount = glGetContextLossCount(this.gl);\n // if (this.glCount !== glCount) {\n // this._handle = this._createHandle(this.props);\n // this._glCount = glCount;\n // // Reinitialize object\n // this.initialize(this.props);\n // }\n return this._handle;\n }\n\n override delete({deleteChildren = false} = {}) {\n // Delete this object, and get refs to any children\n // @ts-expect-error\n const children = this._handle && this._deleteHandle(this._handle);\n if (this._handle) {\n this.removeStats();\n }\n this._handle = null;\n\n // Optionally, recursively delete the children\n // @ts-expect-error\n if (children && deleteChildren) {\n // @ts-expect-error\n children.filter(Boolean).forEach((child) => child.destroy());\n }\n\n return this;\n }\n\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this._bindHandle(funcOrHandle);\n return this;\n }\n\n let value;\n\n if (!this._bound) {\n this._bindHandle(this.handle);\n this._bound = true;\n\n value = funcOrHandle();\n\n this._bound = false;\n this._bindHandle(null);\n } else {\n value = funcOrHandle();\n }\n\n return value;\n }\n\n unbind() {\n this.bind(null);\n }\n\n /**\n * Query a Resource parameter\n *\n * @param name\n * @return param\n */\n getParameter(pname: number, props: any = {}): any {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n // Use parameter definitions to handle unsupported parameters\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if we can query for this parameter\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n const webgl1Default = parameter.webgl1;\n const webgl2Default = 'webgl2' in parameter ? parameter.webgl2 : parameter.webgl1;\n const defaultValue = isWebgl2 ? webgl2Default : webgl1Default;\n return defaultValue;\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // Attempt to query for it and let WebGL report errors\n return this._getParameter(pname, props);\n }\n\n // Many resources support a getParameter call -\n // getParameters will get all parameters - slow but useful for debugging\n // eslint-disable-next-line complexity\n getParameters(options: {parameters?: any, keys?: any} = {}) {\n const {parameters, keys} = options;\n\n // Get parameter definitions for this Resource\n // @ts-expect-error\n const PARAMETERS = this.constructor.PARAMETERS || {};\n\n const isWebgl2 = isWebGL2(this.gl);\n\n const values: Record<string, any> = {};\n\n // Query all parameters if no list provided\n const parameterKeys = parameters || Object.keys(PARAMETERS);\n\n // WEBGL limits\n for (const pname of parameterKeys) {\n const parameter = PARAMETERS[pname];\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n parameter &&\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (parameterAvailable) {\n const key = keys ? this.device.getGLKey(pname) : pname;\n values[key] = this.getParameter(pname, options);\n if (keys && parameter.type === 'GLenum') {\n values[key] = this.device.getGLKey(values[key]);\n }\n }\n }\n\n return values;\n }\n\n /**\n * Update a Resource setting\n *\n * @todo - cache parameter to avoid issuing WebGL calls?\n *\n * @param pname - parameter (GL constant, value or key)\n * @param value {GLint|GLfloat|GLenum} \n * @return returns self to enable chaining\n */\n setParameter(pname: GL | string, value: any): this {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n throw new Error('Parameter not available on this platform');\n }\n\n // Handle string keys\n if (parameter.type === 'GLenum') {\n // @ts-expect-error\n value = getKeyValue(value);\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // attempt to set it and let WebGL report errors\n this._setParameter(pname, value);\n return this;\n }\n\n /*\n * Batch update resource parameters\n * Assumes the subclass supports a setParameter call\n */\n setParameters(parameters: Record<GL, any>) {\n for (const pname in parameters) {\n this.setParameter(pname, parameters[pname]);\n }\n return this;\n }\n\n // Install stubs for removed methods\n stubRemovedMethods(className: string, version: string, methodNames: string[]) {\n return stubRemovedMethods(this, className, version, methodNames);\n }\n\n // PUBLIC VIRTUAL METHODS\n initialize(props: ResourceProps) {}\n\n // PROTECTED METHODS - These must be overridden by subclass\n _createHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _deleteHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _bindHandle(handle: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getOptsFromHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getParameter(pname: GL, props: Record<string, any>): number {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _setParameter(pname: GL | string, value: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n // PRIVATE METHODS\n\n /*\n _addStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get('Resources Created').incrementCount();\n stats.get(`${name}s Created`).incrementCount();\n stats.get(`${name}s Active`).incrementCount();\n }\n\n _removeStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get(`${name}s Active`).decrementCount();\n }\n\n trackAllocatedMemory(bytes, name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').addCount(bytes);\n stats.get(`${name} Memory`).addCount(bytes);\n this.byteLength = bytes;\n }\n\n trackDeallocatedMemory(name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').subtractCount(this.byteLength);\n stats.get(`${name} Memory`).subtractCount(this.byteLength);\n this.byteLength = 0;\n }\n */\n}\n"],"mappings":"AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,GAAG,EAAEC,kBAAkB,QAAO,eAAe;AAAC,SAGhEC,QAAQ,EAAEC,kBAAkB;AAAA,SAC5BC,WAAW;AAAA,SAGXC,WAAW;AAEnB,MAAMC,6BAA6B,GAAG,+CAA+C;AAKrF,OAAO,MAAeC,aAAa,SAAsCT,QAAQ,CAAQ;EAUvFU,WAAWA,CAACC,MAAc,EAAEC,KAAY,EAAEC,YAA6B,EAAE;IACvE,KAAK,CAACF,MAAM,EAAEC,KAAK,EAAEC,YAAY,CAAC;IAAC,KAV5BF,MAAM;IAAA,KACNG,EAAE;IAAA,KACFC,GAAG;IAAA,KACJC,OAAO;IAAA,KAEPC,MAAM,GAAG,KAAK;IAAA,KAEtBC,UAAU,GAAG,CAAC;IAKZ,IAAI,CAACP,MAAM,GAAGL,WAAW,CAACa,MAAM,CAACR,MAAM,CAAC;IACxC,MAAMG,EAAE,GAAG,IAAI,CAACH,MAAM,CAACG,EAAE;IAEzBT,kBAAkB,CAACS,EAAE,CAAC;IAGtB,MAAM;MAACM;IAAE,CAAC,GAAGR,KAAK,IAAI,CAAC,CAAC;IACxB,I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IAAIC,UAAU,EAAE;MAC9B,IAAI,CAACsB,YAAY,CAACvB,KAAK,EAAEC,UAAU,CAACD,KAAK,CAAC,CAAC;IAC7C;IACA,OAAO,IAAI;EACb;EAGAzC,kBAAkBA,CAACoE,SAAiB,EAAEC,OAAe,EAAEC,WAAqB,EAAE;IAC5E,OAAOtE,kBAAkB,CAAC,IAAI,EAAEoE,SAAS,EAAEC,OAAO,EAAEC,WAAW,CAAC;EAClE;EAGAC,UAAUA,CAAC9D,KAAoB,EAAE,CAAC;EAGlCY,aAAaA,CAAA,EAAG;IACd,MAAM,IAAI4C,KAAK,CAAC5D,6BAA6B,CAAC;EAChD;EAEAuB,aAAaA,CAAA,EAAG;IACd,MAAM,IAAIqC,KAAK,CAAC5D,6BAA6B,CAAC;EAChD;EAEAgC,WAAWA,CAAClB,MAAW,EAAE;IACvB,MAAM,IAAI8C,KAAK,CAAC5D,6BAA6B,CAAC;EAChD;EAEAmE,kBAAkBA,CAAA,EAAG;IACnB,MAAM,IAAIP,KAAK,CAAC5D,6BAA6B,CAAC;EAChD;EAEAiD,aAAaA,CAACb,KAAS,EAAEhC,KAA0B,EAAU;IAC3D,MAAM,IAAIwD,KAAK,CAAC5D,6BAA6B,CAAC;EAChD;EAEA6D,aAAaA,CAACzB,KAAkB,EAAEH,KAAU,EAAE;IAC5C,MAAM,IAAI2B,KAAK,CAAC5D,6BAA6B,CAAC;EAChD;AAqCF"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  let _Symbol$toStringTag;
3
2
  import { Resource, assert, getScratchArray, fillArray } from '@luma.gl/core';
4
3
  import { GL } from '@luma.gl/constants';
@@ -18,8 +17,8 @@ export class WEBGLVertexArrayObject extends WebGLResource {
18
17
  ...Resource.defaultProps,
19
18
  constantAttributeZero: false
20
19
  });
21
- _defineProperty(this, "buffer", null);
22
- _defineProperty(this, "bufferValue", null);
20
+ this.buffer = null;
21
+ this.bufferValue = null;
23
22
  Object.seal(this);
24
23
  }
25
24
  destroy() {
@@ -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';\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,WAAWA,CAACH,MAAc,EAAEI,KAA8B,EAAE;IAC1D,KAAK,CAACJ,MAAM,EAAEI,KAAK,EAAE;MAAC,GAAGjB,QAAQ,CAACkB,YAAY;MAAEC,qBAAqB,EAAE;I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A,GAAAnF,MAAM,CAACc,GAAG,cAAAqE,UAAA,uBAAVA,UAAA,CAAYC,gBAAgB,CAAC7D,QAAQ,EAAEgC,KAAK,CAAC;AAgB/C;AAEA,SAASM,oBAAoBA,CAAC7D,MAAmB,EAAEuB,QAAgB,EAAEgC,KAAkB,EAAE;EAAA,IAAA8B,WAAA;EACvFrF,MAAM,CAACkD,YAAY,CAAC,CAAC;EACrB,CAAAmC,WAAA,GAAArF,MAAM,CAACc,GAAG,cAAAuE,WAAA,uBAAVA,WAAA,CAAYC,iBAAiB,CAAC/D,QAAQ,EAAEgC,KAAK,CAAC;AAiBhD;AAQA,SAASW,2BAA2BA,CAACqB,UAAwB,EAAE;EAC7D,IAAIC,KAAK,CAACC,OAAO,CAACF,UAAU,CAAC,EAAE;IAC7B,OAAO,IAAI/B,YAAY,CAAC+B,UAAU,CAAC;EACrC;EACA,OAAOA,UAAU;AACnB;AAKA,SAAShB,0BAA0BA,CAACmB,EAAgB,EAAEC,EAAgB,EAAW;EAC/E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAACjE,MAAM,KAAKkE,EAAE,CAAClE,MAAM,IAAIiE,EAAE,CAACvF,WAAW,KAAKwF,EAAE,CAACxF,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIyF,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,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","buffer","bufferValue","Object","seal","destroy","_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","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,WAAWA,CAACH,MAAc,EAAEI,KAA8B,EAAE;IAC1D,KAAK,CAACJ,MAAM,EAAEI,KAAK,EAAE;MAAC,GAAGjB,QAAQ,CAACkB,YAAY;MAAEC,qBAAqB,EAAE;IAAK,CAAC,CAAC;IAAC,KATzEC,MAAM,GAA8B,IAAI;IAAA,KACxCC,WAAW,GAAG,IAAI;IASxBC,MAAM,CAACC,IAAI,CAAC,IAAI,CAAC;EACnB;EAESC,OAAOA,CAAA,EAAS;IACvB,KAAK,CAACA,OAAO,CAAC,CAAC;IACf,IAAI,IAAI,CAACJ,MAAM,EAAE;MAAA,IAAAK,YAAA;MAC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D,YAAY,CAAC,CAAC;EACrB,CAAAkC,WAAA,GAAApF,MAAM,CAACc,GAAG,cAAAsE,WAAA,uBAAVA,WAAA,CAAYC,iBAAiB,CAAC9D,QAAQ,EAAEgC,KAAK,CAAC;AAiBhD;AAQA,SAASW,2BAA2BA,CAACoB,UAAwB,EAAE;EAC7D,IAAIC,KAAK,CAACC,OAAO,CAACF,UAAU,CAAC,EAAE;IAC7B,OAAO,IAAI9B,YAAY,CAAC8B,UAAU,CAAC;EACrC;EACA,OAAOA,UAAU;AACnB;AAKA,SAASf,0BAA0BA,CAACkB,EAAgB,EAAEC,EAAgB,EAAW;EAC/E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAAChE,MAAM,KAAKiE,EAAE,CAACjE,MAAM,IAAIgE,EAAE,CAACtF,WAAW,KAAKuF,EAAE,CAACvF,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIwF,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAAChE,MAAM,EAAE,EAAEkE,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Buffer, assert } from '@luma.gl/core';
3
2
  import { GL } from '@luma.gl/constants';
4
3
  const DEBUG_DATA_LENGTH = 10;
@@ -6,16 +5,16 @@ export class WEBGLBuffer extends Buffer {
6
5
  constructor(device) {
7
6
  let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8
7
  super(device, props);
9
- _defineProperty(this, "device", void 0);
10
- _defineProperty(this, "gl", void 0);
11
- _defineProperty(this, "gl2", void 0);
12
- _defineProperty(this, "handle", void 0);
13
- _defineProperty(this, "glTarget", void 0);
14
- _defineProperty(this, "glUsage", void 0);
15
- _defineProperty(this, "glIndexType", GL.UNSIGNED_SHORT);
16
- _defineProperty(this, "byteLength", void 0);
17
- _defineProperty(this, "bytesUsed", void 0);
18
- _defineProperty(this, "debugData", null);
8
+ this.device = void 0;
9
+ this.gl = void 0;
10
+ this.gl2 = void 0;
11
+ this.handle = void 0;
12
+ this.glTarget = void 0;
13
+ this.glUsage = void 0;
14
+ this.glIndexType = GL.UNSIGNED_SHORT;
15
+ this.byteLength = void 0;
16
+ this.bytesUsed = void 0;
17
+ this.debugData = null;
19
18
  this.device = device;
20
19
  this.gl = this.device.gl;
21
20
  this.gl2 = this.device.gl2;
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-buffer.js","names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","arguments","length","undefined","_defineProperty","UNSIGNED_SHORT","gl","gl2","handle","createBuffer","setSpectorMetadata","data","glTarget","getWebGLTarget","usage","glUsage","getWebGLUsage","glIndexType","indexType","UNSIGNED_INT","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","destroy","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","write","srcOffset","isWebGL2","COPY_WRITE_BUFFER","assertWebGL2","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"sources":["../../../src/adapter/resources/webgl-buffer.ts"],"sourcesContent":["import type {BufferProps} from '@luma.gl/core';\nimport {Buffer, assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n\n /** Target in OpenGL defines the type of buffer */\n readonly glTarget: GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;\n /** Usage is a hint on how frequently the buffer will be updates */\n readonly glUsage: GL.STATIC_DRAW | GL.DYNAMIC_DRAW;\n /** Index type is needed when issuing draw calls, so we pre-compute it */\n readonly glIndexType: GL.UNSIGNED_SHORT | GL.UNSIGNED_INT = GL.UNSIGNED_SHORT;\n\n /** Number of bytes allocated on the GPU for this buffer */\n byteLength: number;\n /** Number of bytes used */\n bytesUsed: number;\n /** A partial CPU-side copy of the data in this buffer, for debugging purposes */\n debugData: ArrayBuffer | null = null;\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props ).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n device.setSpectorMetadata(this.handle, {...this.props, data: typeof this.props.data});\n\n // - In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // - In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n this.glTarget = getWebGLTarget(this.props.usage);\n this.glUsage = getWebGLUsage(this.props.usage);\n this.glIndexType = this.props.indexType === 'uint32' ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;\n\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n }\n\n // PRIVATE METHODS\n\n /** Allocate a new buffer and initialize to contents of typed array */\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const glTarget = this._getWriteTarget();\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, byteLength, this.glUsage);\n this.gl.bufferSubData(glTarget, byteOffset, data);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const glTarget = this._getWriteTarget();\n\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // @ts-expect-error\n this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = undefined; // data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n this.gl2.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(glTarget, byteOffset, data);\n }\n this.gl.bindBuffer(glTarget, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.glTarget;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n }\n\n _getReadTarget() {\n return this.glTarget;\n // return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.glTarget;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n return GL.ARRAY_BUFFER;\n}\n\n/** @todo usage is not passed correctly */\nfunction getWebGLUsage(usage: number): GL.STATIC_DRAW | GL.DYNAMIC_DRAW {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.STATIC_DRAW;\n}\n"],"mappings":";AACA,SAAQA,MAAM,EAAEC,MAAM,QAAO,eAAe;AAC5C,SAAQC,EAAE,QAAO,oBAAoB;AAGrC,MAAMC,iBAAiB,GAAG,EAAE;AAG5B,OAAO,MAAMC,WAAW,SAASJ,MAAM,CAAC;EAoBtCK,WAAWA,CAACC,MAAmB,EAA2B;IAAA,IAAzBC,KAAkB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACtD,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACI,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,sBAVqCT,EAAE,CAACU,cAAc;IAAAD,eAAA;IAAAA,eAAA;IAAAA,eAAA,oBAO7C,IAAI;IAKlC,IAAI,CAACL,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACO,EAAE,GAAG,IAAI,CAACP,MAAM,CAACO,EAAE;IACxB,IAAI,CAACC,GAAG,GAAG,IAAI,CAACR,MAAM,CAACQ,GAAG;IAE1B,MAAMC,MAAM,GAAG,OAAOR,KAAK,KAAK,QAAQ,GAAIA,KAAK,CAAGQ,MAAM,GAAGL,SAAS;IACtE,IAAI,CAACK,MAAM,GAAGA,MAAM,IAAI,IAAI,CAACF,EAAE,CAACG,YA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W;EACvB;EACA,IAAI5C,KAAK,GAAGrB,MAAM,CAAC6D,MAAM,EAAE;IACzB,OAAO3D,EAAE,CAAC+D,WAAW;EACvB;EACA,IAAI5C,KAAK,GAAGrB,MAAM,CAAC+D,OAAO,EAAE;IAC1B,OAAO7D,EAAE,CAACgE,YAAY;EACxB;EACA,OAAOhE,EAAE,CAAC+D,WAAW;AACvB"}
1
+ {"version":3,"file":"webgl-buffer.js","names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","arguments","length","undefined","gl","gl2","handle","glTarget","glUsage","glIndexType","UNSIGNED_SHORT","byteLength","bytesUsed","debugData","createBuffer","setSpectorMetadata","data","getWebGLTarget","usage","getWebGLUsage","indexType","UNSIGNED_INT","_initWithData","byteOffset","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","trackAllocatedMemory","Float32Array","destroy","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","write","srcOffset","isWebGL2","COPY_WRITE_BUFFER","assertWebGL2","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"sources":["../../../src/adapter/resources/webgl-buffer.ts"],"sourcesContent":["import type {BufferProps} from '@luma.gl/core';\nimport {Buffer, assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n\n /** Target in OpenGL defines the type of buffer */\n readonly glTarget: GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;\n /** Usage is a hint on how frequently the buffer will be updates */\n readonly glUsage: GL.STATIC_DRAW | GL.DYNAMIC_DRAW;\n /** Index type is needed when issuing draw calls, so we pre-compute it */\n readonly glIndexType: GL.UNSIGNED_SHORT | GL.UNSIGNED_INT = GL.UNSIGNED_SHORT;\n\n /** Number of bytes allocated on the GPU for this buffer */\n byteLength: number;\n /** Number of bytes used */\n bytesUsed: number;\n /** A partial CPU-side copy of the data in this buffer, for debugging purposes */\n debugData: ArrayBuffer | null = null;\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props ).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n device.setSpectorMetadata(this.handle, {...this.props, data: typeof this.props.data});\n\n // - In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // - In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n this.glTarget = getWebGLTarget(this.props.usage);\n this.glUsage = getWebGLUsage(this.props.usage);\n this.glIndexType = this.props.indexType === 'uint32' ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;\n\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n }\n\n // PRIVATE METHODS\n\n /** Allocate a new buffer and initialize to contents of typed array */\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const glTarget = this._getWriteTarget();\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, byteLength, this.glUsage);\n this.gl.bufferSubData(glTarget, byteOffset, data);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const glTarget = this._getWriteTarget();\n\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // @ts-expect-error\n this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = undefined; // data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n this.gl2.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(glTarget, byteOffset, data);\n }\n this.gl.bindBuffer(glTarget, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.glTarget;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n }\n\n _getReadTarget() {\n return this.glTarget;\n // return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.glTarget;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n return GL.ARRAY_BUFFER;\n}\n\n/** @todo usage is not passed correctly */\nfunction getWebGLUsage(usage: number): GL.STATIC_DRAW | GL.DYNAMIC_DRAW {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.STATIC_DRAW;\n}\n"],"mappings":"AACA,SAAQA,MAAM,EAAEC,MAAM,QAAO,eAAe;AAC5C,SAAQC,EAAE,QAAO,oBAAoB;AAGrC,MAAMC,iBAAiB,GAAG,EAAE;AAG5B,OAAO,MAAMC,WAAW,SAASJ,MAAM,CAAC;EAoBtCK,WAAWA,CAACC,MAAmB,EAA2B;IAAA,IAAzBC,KAAkB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACtD,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAAC,KApBdD,MAAM;IAAA,KACNK,EAAE;IAAA,KACFC,GAAG;IAAA,KACHC,MAAM;IAAA,KAGNC,QAAQ;IAAA,KAERC,OAAO;IAAA,KAEPC,WAAW,GAAwCd,EAAE,CAACe,cAAc;IAAA,KAG7EC,UAAU;IAAA,KAEVC,SAAS;IAAA,KAETC,SAAS,GAAuB,IAAI;IAKlC,IAAI,CAACd,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,EAAE,GAAG,IAAI,CAACL,MAAM,CAACK,EAAE;IACxB,IAAI,CAACC,GAAG,GAAG,IAAI,CAACN,MAAM,CAACM,GAAG;IAE1B,MAAMC,MAAM,GAAG,OAAON,KAAK,KAAK,QAAQ,GAAIA,KAAK,CAAGM,MAAM,GAAGH,SAAS;IACtE,IAAI,CAACG,MAAM,GAAGA,MAAM,IAAI,IAAI,CAACF,EAAE,CAACU,YAAY,CAAC,CAAC;IAC9Cf,MAAM,CAACgB,kBAAkB,CAAC,IAAI,CAACT,MAAM,EAAE;MAAC,GAAG,IAAI,CAACN,KAAK;MAAE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B;EACA,IAAIvC,KAAK,GAAGzB,MAAM,CAAC8D,OAAO,EAAE;IAC1B,OAAO5D,EAAE,CAAC+D,YAAY;EACxB;EACA,OAAO/D,EAAE,CAAC8D,WAAW;AACvB"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { CommandBuffer, Texture } from '@luma.gl/core';
3
2
  import { GL } from '@luma.gl/constants';
4
3
  import { WEBGLTexture } from "./webgl-texture.js";
@@ -8,8 +7,8 @@ function cast(value) {
8
7
  export class WEBGLCommandBuffer extends CommandBuffer {
9
8
  constructor(device) {
10
9
  super({});
11
- _defineProperty(this, "device", void 0);
12
- _defineProperty(this, "commands", []);
10
+ this.device = void 0;
11
+ this.commands = [];
13
12
  this.device = device;
14
13
  }
15
14
  submitCommands() {
@@ -175,7 +174,7 @@ function getFramebuffer(source) {
175
174
  id
176
175
  } = source;
177
176
  const framebuffer = source.device.createFramebuffer({
178
- id: "framebuffer-for-".concat(id),
177
+ id: `framebuffer-for-${id}`,
179
178
  width,
180
179
  height,
181
180
  colorAttachments: [source]