@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
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-command-buffer.js","names":["CommandBuffer","Texture","GL","WEBGLTexture","cast","value","WEBGLCommandBuffer","constructor","device","_defineProperty","submitCommands","commands","arguments","length","undefined","command","name","_copyBufferToBuffer","options","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","source","destination","gl2","assertWebGL2","_options$sourceOffset","_options$destinationO","bindBuffer","COPY_READ_BUFFER","handle","COPY_WRITE_BUFFER","copyBufferSubData","sourceOffset","destinationOffset","size","Error","mipLevel","aspect","width","height","depthOrArrayLayers","origin","byteOffset","bytesPerRow","rowsPerImage","framebuffer","destroyFramebuffer","getFramebuffer","webglBuffer","sourceWidth","sourceHeight","sourceFormat","RGBA","sourceType","UNSIGNED_BYTE","PIXEL_PACK_BUFFER","bindFramebuffer","FRAMEBUFFER","readPixels","destroy","destinationMipmaplevel","destinationInternalFormat","sourceX","sourceY","isSubCopy","gl","texture","textureTarget","Number","isFinite","bind","copyTexImage2D","unbind","prevHandle","glFormatToComponents","format","ALPHA","R32F","RED","RG32F","RG","RGB","RGB32F","RGBA32F","glTypeToBytes","type","UNSIGNED_SHORT_5_6_5","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","FLOAT","id","createFramebuffer","concat","colorAttachments"],"sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/core';\nimport {\n CommandBuffer,\n Texture,\n // Buffer,\n Framebuffer\n} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\n// import {getTypedArrayFromGLType, getGLTypeFromTypedArray} from '../../classic/typed-array-utils';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLFramebuffer} from './webgl-framebuffer';\n\nfunction cast<T>(value: unknown): T {\n return value as T;\n}\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand;\n\nexport class WEBGLCommandBuffer extends CommandBuffer {\n device: WebGLDevice;\n commands: Command[] = [];\n\n constructor(device: WebGLDevice) {\n super({});\n this.device = device;\n }\n\n submitCommands(commands: Command[] = this.commands) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(this.device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(this.device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(this.device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(this.device, command.options);\n break;\n }\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = cast<WEBGLBuffer>(options.source);\n const destination = cast<WEBGLBuffer>(options.destination);\n\n const gl2 = device.assertWebGL2();\n if (gl2) {\n // In WebGL2 we can perform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n gl2.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n gl2.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n } else {\n // TODO - in WebGL1 we would have to read back to CPU\n // read / write buffer from / to CPU\n throw new Error('copyBufferToBuffer not implemented in WebGL1');\n }\n}\n\n/**\n * Copies data from a Buffer object into a Texture object\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {\n throw new Error('Not implemented');\n}\n\n/**\n * Copies data from a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n aspect = 'all',\n\n /** Width to copy */\n width = options.source.width,\n /** Height to copy */\n height = options.source.height,\n depthOrArrayLayers = 0,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Destination buffer */\n destination,\n /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */\n byteOffset = 0,\n /**\n * The stride, in bytes, between the beginning of each block row and the subsequent block row.\n * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).\n */\n bytesPerRow,\n /**\n * Number of block rows per single image of the texture.\n * rowsPerImage &times; bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.\n * Required if there are multiple images (i.e. the copy depth is more than one).\n */\n rowsPerImage\n } = options;\n\n // TODO - Not possible to read just stencil or depth part in WebGL?\n if (aspect !== 'all') {\n throw new Error('not supported');\n }\n\n // TODO - mipLevels are set when attaching texture to framebuffer\n if (mipLevel !== 0 || depthOrArrayLayers !== undefined || bytesPerRow || rowsPerImage) {\n throw new Error('not implemented');\n }\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const gl2 = device.assertWebGL2();\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n try {\n const webglBuffer = destination as WEBGLBuffer;\n const sourceWidth = width || framebuffer.width;\n const sourceHeight = height || framebuffer.height;\n\n // TODO - hack - should be deduced\n const sourceFormat = GL.RGBA;\n const sourceType = GL.UNSIGNED_BYTE;\n\n // if (!target) {\n // // Create new buffer with enough size\n // const components = glFormatToComponents(sourceFormat);\n // const byteCount = glTypeToBytes(sourceType);\n // const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;\n // target = device.createBuffer({byteLength});\n // }\n\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n\n gl2.readPixels(\n origin[0],\n origin[1],\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n byteOffset\n );\n } finally {\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, null);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, null);\n\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n }\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer\n */\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n */\n// eslint-disable-next-line complexity, max-statements\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n // aspect = 'all',\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Texture to copy to/from. */\n destination,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // destinationMipLevel = options.mipLevel,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n // destinationOrigin = [0, 0],\n /** Defines which aspects of the texture to copy to/from. */\n // destinationAspect = options.aspect,\n\n } = options;\n\n let {\n width = options.destination.width,\n height = options.destination.width,\n // depthOrArrayLayers = 0\n } = options;\n\n const destinationMipmaplevel = 0;\n const destinationInternalFormat = GL.RGBA;\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n const [sourceX, sourceY] = origin;\n\n const isSubCopy = false;\n // typeof destinationX !== 'undefined' ||\n // typeof destinationY !== 'undefined' ||\n // typeof destinationZ !== 'undefined';\n\n // destinationX = destinationX || 0;\n // destinationY = destinationY || 0;\n // destinationZ = destinationZ || 0;\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n\n let texture = null;\n let textureTarget: GL;\n if (destination instanceof WEBGLTexture) {\n texture = destination;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.destination;\n } else {\n throw new Error('whoops');\n // textureTarget = destination;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n destinationMipmaplevel,\n destinationInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n // switch (textureTarget) {\n // case GL.TEXTURE_2D:\n // case GL.TEXTURE_CUBE_MAP:\n // device.gl.copyTexSubImage2D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // case GL.TEXTURE_2D_ARRAY:\n // case GL.TEXTURE_3D:\n // const gl2 = device.assertWebGL2();\n // gl2.copyTexSubImage3D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // destinationZ,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // default:\n // }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format): 1 | 2 | 3 | 4 {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n return 1;\n case GL.RG32F:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n throw new Error('GLFormat');\n }\n}\n\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type: GL): 1 | 2 | 4 {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n throw new Error('GLType');\n }\n}\n\n// Helper methods\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: WEBGLFramebuffer;\n destroyFramebuffer: boolean;\n} {\n if (source instanceof Texture) {\n const {width, height, id} = source;\n const framebuffer = source.device.createFramebuffer({\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [source]\n }) as unknown as WEBGLFramebuffer;\n\n return {framebuffer, destroyFramebuffer: true};\n }\n return {framebuffer: source as unknown as WEBGLFramebuffer, destroyFramebuffer: false};\n}\n"],"mappings":";AAQA,SACEA,aAAa,EACbC,OAAO,QAGF,eAAe;AACtB,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAK9BC,YAAY;AAGpB,SAASC,IAAIA,CAAIC,KAAc,EAAK;EAClC,OAAOA,KAAK;AACd;AA4BA,OAAO,MAAMC,kBAAkB,SAASN,aAAa,CAAC;EAIpDO,WAAWA,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AGxB,MAAM,CAACd,MAAM,CAACoF,iBAAiB,CAAC;MAClDD,EAAE,qBAAAE,MAAA,CAAqBF,EAAE,CAAE;MAC3BpD,KAAK;MACLC,MAAM;MACNsD,gBAAgB,EAAE,CAACxE,MAAM;IAC3B,CAAC,CAAgC;IAEjC,OAAO;MAACwB,WAAW;MAAEC,kBAAkB,EAAE;IAAI,CAAC;EAChD;EACA,OAAO;IAACD,WAAW,EAAExB,MAAqC;IAAEyB,kBAAkB,EAAE;EAAK,CAAC;AACxF"}
1
+ {"version":3,"file":"webgl-command-buffer.js","names":["CommandBuffer","Texture","GL","WEBGLTexture","cast","value","WEBGLCommandBuffer","constructor","device","commands","submitCommands","arguments","length","undefined","command","name","_copyBufferToBuffer","options","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","source","destination","gl2","assertWebGL2","_options$sourceOffset","_options$destinationO","bindBuffer","COPY_READ_BUFFER","handle","COPY_WRITE_BUFFER","copyBufferSubData","sourceOffset","destinationOffset","size","Error","mipLevel","aspect","width","height","depthOrArrayLayers","origin","byteOffset","bytesPerRow","rowsPerImage","framebuffer","destroyFramebuffer","getFramebuffer","webglBuffer","sourceWidth","sourceHeight","sourceFormat","RGBA","sourceType","UNSIGNED_BYTE","PIXEL_PACK_BUFFER","bindFramebuffer","FRAMEBUFFER","readPixels","destroy","destinationMipmaplevel","destinationInternalFormat","sourceX","sourceY","isSubCopy","gl","texture","textureTarget","Number","isFinite","bind","copyTexImage2D","unbind","prevHandle","glFormatToComponents","format","ALPHA","R32F","RED","RG32F","RG","RGB","RGB32F","RGBA32F","glTypeToBytes","type","UNSIGNED_SHORT_5_6_5","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","FLOAT","id","createFramebuffer","colorAttachments"],"sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/core';\nimport {\n CommandBuffer,\n Texture,\n // Buffer,\n Framebuffer\n} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\n// import {getTypedArrayFromGLType, getGLTypeFromTypedArray} from '../../classic/typed-array-utils';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLFramebuffer} from './webgl-framebuffer';\n\nfunction cast<T>(value: unknown): T {\n return value as T;\n}\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand;\n\nexport class WEBGLCommandBuffer extends CommandBuffer {\n device: WebGLDevice;\n commands: Command[] = [];\n\n constructor(device: WebGLDevice) {\n super({});\n this.device = device;\n }\n\n submitCommands(commands: Command[] = this.commands) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(this.device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(this.device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(this.device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(this.device, command.options);\n break;\n }\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = cast<WEBGLBuffer>(options.source);\n const destination = cast<WEBGLBuffer>(options.destination);\n\n const gl2 = device.assertWebGL2();\n if (gl2) {\n // In WebGL2 we can perform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n gl2.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n gl2.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n } else {\n // TODO - in WebGL1 we would have to read back to CPU\n // read / write buffer from / to CPU\n throw new Error('copyBufferToBuffer not implemented in WebGL1');\n }\n}\n\n/**\n * Copies data from a Buffer object into a Texture object\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {\n throw new Error('Not implemented');\n}\n\n/**\n * Copies data from a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n aspect = 'all',\n\n /** Width to copy */\n width = options.source.width,\n /** Height to copy */\n height = options.source.height,\n depthOrArrayLayers = 0,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Destination buffer */\n destination,\n /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */\n byteOffset = 0,\n /**\n * The stride, in bytes, between the beginning of each block row and the subsequent block row.\n * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).\n */\n bytesPerRow,\n /**\n * Number of block rows per single image of the texture.\n * rowsPerImage &times; bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.\n * Required if there are multiple images (i.e. the copy depth is more than one).\n */\n rowsPerImage\n } = options;\n\n // TODO - Not possible to read just stencil or depth part in WebGL?\n if (aspect !== 'all') {\n throw new Error('not supported');\n }\n\n // TODO - mipLevels are set when attaching texture to framebuffer\n if (mipLevel !== 0 || depthOrArrayLayers !== undefined || bytesPerRow || rowsPerImage) {\n throw new Error('not implemented');\n }\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const gl2 = device.assertWebGL2();\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n try {\n const webglBuffer = destination as WEBGLBuffer;\n const sourceWidth = width || framebuffer.width;\n const sourceHeight = height || framebuffer.height;\n\n // TODO - hack - should be deduced\n const sourceFormat = GL.RGBA;\n const sourceType = GL.UNSIGNED_BYTE;\n\n // if (!target) {\n // // Create new buffer with enough size\n // const components = glFormatToComponents(sourceFormat);\n // const byteCount = glTypeToBytes(sourceType);\n // const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;\n // target = device.createBuffer({byteLength});\n // }\n\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n\n gl2.readPixels(\n origin[0],\n origin[1],\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n byteOffset\n );\n } finally {\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, null);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, null);\n\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n }\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer\n */\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n */\n// eslint-disable-next-line complexity, max-statements\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n // aspect = 'all',\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Texture to copy to/from. */\n destination,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // destinationMipLevel = options.mipLevel,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n // destinationOrigin = [0, 0],\n /** Defines which aspects of the texture to copy to/from. */\n // destinationAspect = options.aspect,\n\n } = options;\n\n let {\n width = options.destination.width,\n height = options.destination.width,\n // depthOrArrayLayers = 0\n } = options;\n\n const destinationMipmaplevel = 0;\n const destinationInternalFormat = GL.RGBA;\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n const [sourceX, sourceY] = origin;\n\n const isSubCopy = false;\n // typeof destinationX !== 'undefined' ||\n // typeof destinationY !== 'undefined' ||\n // typeof destinationZ !== 'undefined';\n\n // destinationX = destinationX || 0;\n // destinationY = destinationY || 0;\n // destinationZ = destinationZ || 0;\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n\n let texture = null;\n let textureTarget: GL;\n if (destination instanceof WEBGLTexture) {\n texture = destination;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.destination;\n } else {\n throw new Error('whoops');\n // textureTarget = destination;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n destinationMipmaplevel,\n destinationInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n // switch (textureTarget) {\n // case GL.TEXTURE_2D:\n // case GL.TEXTURE_CUBE_MAP:\n // device.gl.copyTexSubImage2D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // case GL.TEXTURE_2D_ARRAY:\n // case GL.TEXTURE_3D:\n // const gl2 = device.assertWebGL2();\n // gl2.copyTexSubImage3D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // destinationZ,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // default:\n // }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format): 1 | 2 | 3 | 4 {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n return 1;\n case GL.RG32F:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n throw new Error('GLFormat');\n }\n}\n\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type: GL): 1 | 2 | 4 {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n throw new Error('GLType');\n }\n}\n\n// Helper methods\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: WEBGLFramebuffer;\n destroyFramebuffer: boolean;\n} {\n if (source instanceof Texture) {\n const {width, height, id} = source;\n const framebuffer = source.device.createFramebuffer({\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [source]\n }) as unknown as WEBGLFramebuffer;\n\n return {framebuffer, destroyFramebuffer: true};\n }\n return {framebuffer: source as unknown as WEBGLFramebuffer, destroyFramebuffer: false};\n}\n"],"mappings":"AAQA,SACEA,aAAa,EACbC,OAAO,QAGF,eAAe;AACtB,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAK9BC,YAAY;AAGpB,SAASC,IAAIA,CAAIC,KAAc,EAAK;EAClC,OAAOA,KAAK;AACd;AA4BA,OAAO,MAAMC,kBAAkB,SAASN,aAAa,CAAC;EAIpDO,WAAWA,CAACC,MAAmB,EAAE;IAC/B,KAAK,CAAC,CAAC,CAAC,CAAC;IAAC,KAJZA,MAAM;IAAA,KACNC,QAAQ,GAAc,EAAE;IAItB,IAAI,CAACD,MAAM,GAAGA,MAAM;EACtB;EAEAE,cAAcA,CAAA,EAAsC;IAAA,IAArCD,QAAmB,GAAAE,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI,CAACF,QAAQ;IAChD,KAAK,MAAMK,OAAO,IAAIL,QAAQ,EAAE;MAC9B,QAAQK,OAAO,CAACC,IAAI;QAClB,KAAK,uBAAuB;UAC1BC,mBAAmB,CAAC,IAAI,CAACR,MAAM,EAAEM,OAAO,CAACG,OAAO,CAAC;UACjD;QACF,KAAK,wBAAwB;UAC3BC,oBAAoB,CAAC,IAAI,CAACV,MAAM,EAAEM,OAAO,CAACG,OAAO,CAAC;UAClD;QACF,KAAK,wBAAwB;UAC3BE,oBAAoB,CAAC,IAAI,CAACX,MAAM,EAAEM,OAAO,CAACG,OAAO,CAAC;UAClD;QACF,KAAK,yBAAyB;UAC5BG,qBAAqB,CAAC,IAAI,CAACZ,MAAM,EAAEM,OAAO,CAACG,OAAO,CAAC;UACnD;MACJ;IACF;EACF;AACF;AAEA,SAASD,mBAAmBA,CAACR,MAAmB,EAAES,OA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,CAACoF,oBAAoB;IAC5B,KAAKpF,EAAE,CAACqF,sBAAsB;IAC9B,KAAKrF,EAAE,CAACsF,sBAAsB;MAC5B,OAAO,CAAC;IACV,KAAKtF,EAAE,CAACuF,KAAK;MACX,OAAO,CAAC;IAEV;MACE,MAAM,IAAItD,KAAK,CAAC,QAAQ,CAAC;EAC7B;AACF;AAIA,SAASY,cAAcA,CAAC1B,MAA6B,EAGnD;EACA,IAAIA,MAAM,YAAYpB,OAAO,EAAE;IAC7B,MAAM;MAACqC,KAAK;MAAEC,MAAM;MAAEmD;IAAE,CAAC,GAAGrE,MAAM;IAClC,MAAMwB,WAAW,GAAGxB,MAAM,CAACb,MAAM,CAACmF,iBAAiB,CAAC;MAClDD,EAAE,EAAG,mBAAkBA,EAAG,EAAC;MAC3BpD,KAAK;MACLC,MAAM;MACNqD,gBAAgB,EAAE,CAACvE,MAAM;IAC3B,CAAC,CAAgC;IAEjC,OAAO;MAACwB,WAAW;MAAEC,kBAAkB,EAAE;IAAI,CAAC;EAChD;EACA,OAAO;IAACD,WAAW,EAAExB,MAAqC;IAAEyB,kBAAkB,EAAE;EAAK,CAAC;AACxF"}
@@ -1,11 +1,10 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { CommandEncoder } from '@luma.gl/core';
3
2
  import { WEBGLCommandBuffer } from "./webgl-command-buffer.js";
4
3
  export class WEBGLCommandEncoder extends CommandEncoder {
5
4
  constructor(device, props) {
6
5
  super(device, props);
7
- _defineProperty(this, "device", void 0);
8
- _defineProperty(this, "commandBuffer", void 0);
6
+ this.device = void 0;
7
+ this.commandBuffer = void 0;
9
8
  this.device = device;
10
9
  this.commandBuffer = new WEBGLCommandBuffer(device);
11
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-command-encoder.js","names":["CommandEncoder","WEBGLCommandBuffer","WEBGLCommandEncoder","constructor","device","props","_defineProperty","commandBuffer","destroy","finish","submitCommands","copyBufferToBuffer","options","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/core';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/core';\n\nimport {WEBGLCommandBuffer} from './webgl-command-buffer';\nimport {WebGLDevice} from '../webgl-device';\n\nexport class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer: WEBGLCommandBuffer;\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(device, props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n\n override destroy(): void {}\n\n override finish(): void {\n this.commandBuffer.submitCommands();\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset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-encoder.js","names":["CommandEncoder","WEBGLCommandBuffer","WEBGLCommandEncoder","constructor","device","props","commandBuffer","destroy","finish","submitCommands","copyBufferToBuffer","options","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/core';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/core';\n\nimport {WEBGLCommandBuffer} from './webgl-command-buffer';\nimport {WebGLDevice} from '../webgl-device';\n\nexport class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer: WEBGLCommandBuffer;\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(device, props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n\n override destroy(): void {}\n\n override finish(): void {\n this.commandBuffer.submitCommands();\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}\n"],"mappings":"AAAA,SAAQA,cAAc,QAA4B,eAAe;AAAC,SAQ1DC,kBAAkB;AAG1B,OAAO,MAAMC,mBAAmB,SAASF,cAAc,CAAC;EAKtDG,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KALdD,MAAM;IAAA,KAENE,aAAa;IAIpB,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,aAAa,GAAG,IAAIL,kBAAkB,CAACG,MAAM,CAAC;EACrD;EAESG,OAAOA,CAAA,EAAS,CAAC;EAEjBC,MAAMA,CAAA,EAAS;IACtB,IAAI,CAACF,aAAa,CAACG,cAAc,CAAC,CAAC;EACrC;EAMAC,kBAAkBA,CAACC,OAAkC,EAAQ;IAC3D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,uBAAuB;MAAEH;IAAO,CAAC,CAAC;EAC5E;EAEAI,mBAAmBA,CAACJ,OAAmC,EAAE;IACvD,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAK,mBAAmBA,CAACL,OAAmC,EAAQ;IAC7D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAM,oBAAoBA,CAACN,OAAoC,EAAQ;IAC/D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,yBAAyB;MAAEH;IAAO,CAAC,CAAC;EAC9E;EAESO,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAG,CAAC;EAEjBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;AAWzD"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Framebuffer, assert } from '@luma.gl/core';
3
2
  import { GL } from '@luma.gl/constants';
4
3
  import { WEBGLTexture } from "./webgl-texture.js";
@@ -10,9 +9,9 @@ export class WEBGLFramebuffer extends Framebuffer {
10
9
  }
11
10
  constructor(device, props) {
12
11
  super(device, props);
13
- _defineProperty(this, "device", void 0);
14
- _defineProperty(this, "gl", void 0);
15
- _defineProperty(this, "handle", void 0);
12
+ this.device = void 0;
13
+ this.gl = void 0;
14
+ this.handle = void 0;
16
15
  const isDefaultFramebuffer = props.handle === null;
17
16
  this.device = device;
18
17
  this.gl = device.gl;
@@ -54,12 +53,12 @@ export class WEBGLFramebuffer extends Framebuffer {
54
53
  const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);
55
54
  gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
56
55
  if (status !== gl.FRAMEBUFFER_COMPLETE) {
57
- throw new Error("Framebuffer ".concat(_getFrameBufferStatus(status)));
56
+ throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
58
57
  }
59
58
  }
60
59
  createDepthStencilTexture(format) {
61
60
  return new WEBGLRenderbuffer(this.device, {
62
- id: "".concat(this.id, "-depth-stencil"),
61
+ id: `${this.id}-depth-stencil`,
63
62
  format,
64
63
  width: this.width,
65
64
  height: this.height
@@ -151,7 +150,7 @@ function _getFrameBufferStatus(status) {
151
150
  case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
152
151
  return 'Samples mismatch';
153
152
  default:
154
- return "".concat(status);
153
+ return `${status}`;
155
154
  }
156
155
  }
157
156
  //# sourceMappingURL=webgl-framebuffer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-framebuffer.js","names":["Framebuffer","assert","GL","WEBGLTexture","WEBGLRenderbuffer","getDepthStencilAttachmentWebGL","WEBGLFramebuffer","texture","colorAttachments","constructor","device","props","_defineProperty","isDefaultFramebuffer","handle","gl","createFramebuffer","setSpectorMetadata","id","autoCreateAttachmentTextures","bindFramebuffer","FRAMEBUFFER","i","length","attachment","attachmentPoint","COLOR_ATTACHMENT0","_attachOne","depthStencilAttachment","format","check","_checkStatus","destroy","destroyed","deleteFramebuffer","prevHandle","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","Error","concat","_getFrameBufferStatus","createDepthStencilTexture","width","height","resizeAttachments","drawingBufferWidth","drawingBufferHeight","undefined","colorAttachment","resize","_attachWEBGLRenderbuffer","Array","isArray","layer","level","_attachTexture","renderbuffer","framebufferRenderbuffer","RENDERBUFFER","gl2","bindTexture","target","TEXTURE_2D_ARRAY","TEXTURE_3D","assertWebGL2","framebufferTextureLayer","TEXTURE_CUBE_MAP","face","mapIndexToCubeMapFace","framebufferTexture2D","TEXTURE_2D","TEXTURE_CUBE_MAP_POSITIVE_X","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"],"sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {FramebufferProps, TextureFormat} from '@luma.gl/core';\nimport {Framebuffer, Texture, assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';\nimport {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';\n\nexport type TextureAttachment = [Texture, number?, number?];\nexport type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGLRenderingContext;\n handle: WebGLFramebuffer;\n\n get texture() {\n return this.colorAttachments[0];\n }\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n\n // WebGL default framebuffer handle is null\n const isDefaultFramebuffer = props.handle === null;\n\n this.device = device;\n this.gl = device.gl;\n this.handle =\n this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();\n\n if (!isDefaultFramebuffer) {\n // default framebuffer handle is null, so we can't set spector metadata...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n\n /** Attach from a map of attachments */\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n if (attachment) {\n this._attachOne(attachmentPoint, attachment as WEBGLTexture);\n }\n }\n\n if (this.depthStencilAttachment) {\n this._attachOne(\n getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),\n this.depthStencilAttachment as WEBGLTexture\n );\n }\n\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);\n }\n\n // @ts-expect-error\n if (props.check !== false) {\n this._checkStatus();\n }\n }\n\n /** destroys any auto created resources etc. */\n override destroy(): void {\n super.destroy(); // destroys owned resources etc.\n if (!this.destroyed && this.handle !== null) {\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n }\n }\n\n // PRIVATE\n\n /** Check the status */\n protected _checkStatus(): void {\n const {gl} = this;\n // TODO - should we really rely on this trick? \n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle) as unknown as WebGLFramebuffer;\n const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */\n protected override createDepthStencilTexture(format: TextureFormat): Texture {\n return new WEBGLRenderbuffer(this.device, {\n id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?\n format,\n // dataFormat: GL.DEPTH_STENCIL,\n // type: GL.UNSIGNED_INT_24_8,\n width: this.width,\n height: this.height\n }) as unknown as WEBGLTexture;\n }\n\n /** \n * Attachment resize is expected to be a noop if size is same \n */\n protected override resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n // TODO Not clear that this is better than default destroy/create implementation\n\n for (const colorAttachment of this.colorAttachments) {\n (colorAttachment as WEBGLTexture).resize({width, height});\n }\n if (this.depthStencilAttachment) {\n (this.depthStencilAttachment as WEBGLTexture).resize({width, height});\n }\n return this;\n }\n\n /** Attach one attachment */\n protected _attachOne(\n attachmentPoint: GL,\n attachment: Attachment\n ): WEBGLTexture | WEBGLRenderbuffer {\n if (attachment instanceof WEBGLRenderbuffer) {\n this._attachWEBGLRenderbuffer(attachmentPoint, attachment);\n return attachment;\n } else if (Array.isArray(attachment)) {\n const [texture, layer = 0, level = 0] = attachment;\n this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);\n return texture as unknown as WEBGLTexture;\n } else if (attachment instanceof WEBGLTexture) {\n this._attachTexture(attachmentPoint, attachment, 0, 0);\n return attachment;\n }\n throw new Error('attach');\n }\n\n protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {\n this.gl.framebufferRenderbuffer(\n GL.FRAMEBUFFER,\n attachment,\n GL.RENDERBUFFER,\n renderbuffer.handle\n );\n }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel (must be 0 in WebGL1)\n */\n protected _attachTexture(\n attachment: GL,\n texture: WEBGLTexture,\n layer: number,\n level: number\n ): void {\n const {gl, gl2} = this.device;\n gl.bindTexture(texture.target, texture.handle);\n\n switch (texture.target) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n this.device.assertWebGL2();\n gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n assert(false, 'Illegal texture type');\n }\n\n gl.bindTexture(texture.target, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n"],"mappings":";AAGA,SAAQA,WAAW,EAAWC,MAAM,QAAO,eAAe;AAC1D,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,YAAY;AAAA,SACZC,iBAAiB;AAAA,SACjBC,8BAA8B;AAMtC,OAAO,MAAMC,gBAAgB,SAASN,WAAW,CAAC;EAKhD,IAAIO,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAAC;EACjC;EAEAC,WAAWA,CAACC,MAAmB,EAAEC,KAAuB,EAAE;IACxD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAGrB,MAAMC,oBAAoB,GAAGF,KAAK,CAACG,MAAM,KAAK,IAAI;IAElD,IAAI,CAACJ,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,EAAE,GAAGL,MAAM,CAACK,EAAE;IACnB,IAAI,CAACD,MAAM,GACT,IAAI,CAACH,KAAK,CAACG,MAAM,IAAID,oBAAoB,GAAG,IAAI,CAACF,KAAK,CAACG,MAAM,GAAG,IAAI,CAACC,EAAE,CAACC,iBAAiB,CAAC,CAAC;IAE7F,IAAI,CAACH,oBAAoB,EAAE;MAEzBH,MAAM,CAACO,kBAAkB,CAAC,IAAI,CAACH,MAAM,EAAE;QAACI,EAAE,EAAE,IAAI,CAACP,KAAK,CAACO,EAAE;QAAEP,KAAK,EAAE,IAAI,CAACA;MAAK,CAAC,CAAC;MAG9E,IAAI,CAACQ,4BAA4B,CAAC,CAAC;MAGnC,IAAI,CAACJ,EAAE,CAACK,eAAe,CAAClB,EA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CAAkC;IAE3C,KAAK1E,EAAE,CAAC2E,kCAAkC;MACxC,OAAO,kBAAkB;IAG3B;MACE,UAAArC,MAAA,CAAUJ,MAAM;EACpB;AACF"}
1
+ {"version":3,"file":"webgl-framebuffer.js","names":["Framebuffer","assert","GL","WEBGLTexture","WEBGLRenderbuffer","getDepthStencilAttachmentWebGL","WEBGLFramebuffer","texture","colorAttachments","constructor","device","props","gl","handle","isDefaultFramebuffer","createFramebuffer","setSpectorMetadata","id","autoCreateAttachmentTextures","bindFramebuffer","FRAMEBUFFER","i","length","attachment","attachmentPoint","COLOR_ATTACHMENT0","_attachOne","depthStencilAttachment","format","check","_checkStatus","destroy","destroyed","deleteFramebuffer","prevHandle","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","Error","_getFrameBufferStatus","createDepthStencilTexture","width","height","resizeAttachments","drawingBufferWidth","drawingBufferHeight","undefined","colorAttachment","resize","_attachWEBGLRenderbuffer","Array","isArray","layer","level","_attachTexture","renderbuffer","framebufferRenderbuffer","RENDERBUFFER","gl2","bindTexture","target","TEXTURE_2D_ARRAY","TEXTURE_3D","assertWebGL2","framebufferTextureLayer","TEXTURE_CUBE_MAP","face","mapIndexToCubeMapFace","framebufferTexture2D","TEXTURE_2D","TEXTURE_CUBE_MAP_POSITIVE_X","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"],"sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {FramebufferProps, TextureFormat} from '@luma.gl/core';\nimport {Framebuffer, Texture, assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';\nimport {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';\n\nexport type TextureAttachment = [Texture, number?, number?];\nexport type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGLRenderingContext;\n handle: WebGLFramebuffer;\n\n get texture() {\n return this.colorAttachments[0];\n }\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n\n // WebGL default framebuffer handle is null\n const isDefaultFramebuffer = props.handle === null;\n\n this.device = device;\n this.gl = device.gl;\n this.handle =\n this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();\n\n if (!isDefaultFramebuffer) {\n // default framebuffer handle is null, so we can't set spector metadata...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n\n /** Attach from a map of attachments */\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n if (attachment) {\n this._attachOne(attachmentPoint, attachment as WEBGLTexture);\n }\n }\n\n if (this.depthStencilAttachment) {\n this._attachOne(\n getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),\n this.depthStencilAttachment as WEBGLTexture\n );\n }\n\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);\n }\n\n // @ts-expect-error\n if (props.check !== false) {\n this._checkStatus();\n }\n }\n\n /** destroys any auto created resources etc. */\n override destroy(): void {\n super.destroy(); // destroys owned resources etc.\n if (!this.destroyed && this.handle !== null) {\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n }\n }\n\n // PRIVATE\n\n /** Check the status */\n protected _checkStatus(): void {\n const {gl} = this;\n // TODO - should we really rely on this trick? \n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle) as unknown as WebGLFramebuffer;\n const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */\n protected override createDepthStencilTexture(format: TextureFormat): Texture {\n return new WEBGLRenderbuffer(this.device, {\n id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?\n format,\n // dataFormat: GL.DEPTH_STENCIL,\n // type: GL.UNSIGNED_INT_24_8,\n width: this.width,\n height: this.height\n }) as unknown as WEBGLTexture;\n }\n\n /** \n * Attachment resize is expected to be a noop if size is same \n */\n protected override resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n // TODO Not clear that this is better than default destroy/create implementation\n\n for (const colorAttachment of this.colorAttachments) {\n (colorAttachment as WEBGLTexture).resize({width, height});\n }\n if (this.depthStencilAttachment) {\n (this.depthStencilAttachment as WEBGLTexture).resize({width, height});\n }\n return this;\n }\n\n /** Attach one attachment */\n protected _attachOne(\n attachmentPoint: GL,\n attachment: Attachment\n ): WEBGLTexture | WEBGLRenderbuffer {\n if (attachment instanceof WEBGLRenderbuffer) {\n this._attachWEBGLRenderbuffer(attachmentPoint, attachment);\n return attachment;\n } else if (Array.isArray(attachment)) {\n const [texture, layer = 0, level = 0] = attachment;\n this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);\n return texture as unknown as WEBGLTexture;\n } else if (attachment instanceof WEBGLTexture) {\n this._attachTexture(attachmentPoint, attachment, 0, 0);\n return attachment;\n }\n throw new Error('attach');\n }\n\n protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {\n this.gl.framebufferRenderbuffer(\n GL.FRAMEBUFFER,\n attachment,\n GL.RENDERBUFFER,\n renderbuffer.handle\n );\n }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel (must be 0 in WebGL1)\n */\n protected _attachTexture(\n attachment: GL,\n texture: WEBGLTexture,\n layer: number,\n level: number\n ): void {\n const {gl, gl2} = this.device;\n gl.bindTexture(texture.target, texture.handle);\n\n switch (texture.target) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n this.device.assertWebGL2();\n gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n assert(false, 'Illegal texture type');\n }\n\n gl.bindTexture(texture.target, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n"],"mappings":"AAGA,SAAQA,WAAW,EAAWC,MAAM,QAAO,eAAe;AAC1D,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,YAAY;AAAA,SACZC,iBAAiB;AAAA,SACjBC,8BAA8B;AAMtC,OAAO,MAAMC,gBAAgB,SAASN,WAAW,CAAC;EAKhD,IAAIO,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAAC;EACjC;EAEAC,WAAWA,CAACC,MAAmB,EAAEC,KAAuB,EAAE;IACxD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KATvBD,MAAM;IAAA,KACNE,EAAE;IAAA,KACFC,MAAM;IAUJ,MAAMC,oBAAoB,GAAGH,KAAK,CAACE,MAAM,KAAK,IAAI;IAElD,IAAI,CAACH,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,EAAE,GAAGF,MAAM,CAACE,EAAE;IACnB,IAAI,CAACC,MAAM,GACT,IAAI,CAACF,KAAK,CAACE,MAAM,IAAIC,oBAAoB,GAAG,IAAI,CAACH,KAAK,CAACE,MAAM,GAAG,IAAI,CAACD,EAAE,CAACG,iBAAiB,CAAC,CAAC;IAE7F,IAAI,CAACD,oBAAoB,EAAE;MAEzBJ,MAAM,CAACM,kBAAkB,CAAC,IAAI,CAACH,MAAM,EAAE;QAACI,EAAE,EA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E,CAACsE,yCAAyC;MAC/C,OAAO,gBAAgB;IACzB,KAAKtE,EAAE,CAACuE,iCAAiC;MACvC,OAAO,uBAAuB;IAChC,KAAKvE,EAAE,CAACwE,uBAAuB;MAC7B,OAAO,kCAAkC;IAE3C,KAAKxE,EAAE,CAACyE,kCAAkC;MACxC,OAAO,kBAAkB;IAG3B;MACE,OAAQ,GAAExC,MAAO,EAAC;EACtB;AACF"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { RenderPass } from '@luma.gl/core';
3
2
  import { GL } from '@luma.gl/constants';
4
3
  import { withParameters } from "../../context/state-tracker/with-parameters.js";
@@ -9,8 +8,8 @@ const GL_COLOR = 0x1800;
9
8
  export class WEBGLRenderPass extends RenderPass {
10
9
  constructor(device, props) {
11
10
  super(device, props);
12
- _defineProperty(this, "device", void 0);
13
- _defineProperty(this, "glParameters", void 0);
11
+ this.device = void 0;
12
+ this.glParameters = void 0;
14
13
  this.device = device;
15
14
  this.setParameters(this.props.parameters);
16
15
  this.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-render-pass.js","names":["RenderPass","GL","withParameters","GL_DEPTH_BUFFER_BIT","GL_STENCIL_BUFFER_BIT","GL_COLOR_BUFFER_BIT","GL_COLOR","WEBGLRenderPass","constructor","device","props","_defineProperty","setParameters","parameters","clear","end","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel","arguments","length","undefined","glParameters","framebuffer","depthReadOnly","depthMask","stencilMask","stencilReadOnly","RASTERIZER_DISCARD","discard","viewport","slice","depthRange","scissorTest","Boolean","scissorRect","scissor","blendConstant","blendColor","stencilReference","console","warn","STENCIL_REF","clearMask","clearColor","clearDepth","clearStencil","gl","clearColorBuffer","drawBuffer","value","gl2","Int32Array","clearBufferiv","Uint32Array","clearBufferuiv","Float32Array","clearBufferfv"],"sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"sourcesContent":["import {RenderPass, RenderPassProps, NumericArray, RenderPassParameters} from '@luma.gl/core';\nimport {WebGLDevice} from '../webgl-device';\nimport {GL, GLParameters} from '@luma.gl/constants';\nimport {withParameters} from '../../context/state-tracker/with-parameters';\n\n// Should collapse during minification\n\nconst GL_DEPTH_BUFFER_BIT = 0x00000100;\nconst GL_STENCIL_BUFFER_BIT = 0x00000400;\nconst GL_COLOR_BUFFER_BIT = 0x00004000;\n\nconst GL_COLOR = 0x1800;\n\nexport class WEBGLRenderPass extends RenderPass {\n readonly device: WebGLDevice;\n\n /** Parameters that should be applied before each draw call */\n glParameters: GLParameters;\n\n constructor(device: WebGLDevice, props: RenderPassProps) {\n super(device, props);\n this.device = device;\n\n // TODO - do parameters (scissorRect) affect the clear operation?\n this.setParameters(this.props.parameters);\n\n // Hack - for now WebGL draws in \"immediate mode\" (instead of queueing the operations)...\n this.clear();\n }\n\n end(): void {\n // should add commands to CommandEncoder.\n }\n\n pushDebugGroup(groupLabel: string): void {}\n popDebugGroup(): void {}\n insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n /**\n * Maps RenderPass parameters to GL parameters\n */\n setParameters(parameters: RenderPassParameters = {}): void {\n const glParameters: GLParameters = {};\n\n // Framebuffers are specified using parameters in WebGL\n if (this.props.framebuffer) {\n glParameters.framebuffer = this.props.framebuffer;\n }\n\n if (this.props.depthReadOnly) {\n glParameters.depthMask = !this.props.depthReadOnly;\n }\n\n glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;\n\n glParameters[GL.RASTERIZER_DISCARD] = this.props.discard;\n\n // Map the four renderpass parameters to WebGL parameters\n if (parameters.viewport) {\n // WebGPU viewports are 6 coordinates (X, Y, Z)\n if (parameters.viewport.length >= 6) {\n glParameters.viewport = parameters.viewport.slice(0, 4);\n glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];\n } else {\n // WebGL viewports are 4 coordinates (X, Y)\n glParameters.viewport = parameters.viewport;\n }\n }\n glParameters.scissorTest = Boolean(parameters.scissorRect);\n if (parameters.scissorRect) {\n glParameters.scissor = parameters.scissorRect;\n }\n if (parameters.blendConstant) {\n glParameters.blendColor = parameters.blendConstant;\n }\n if (parameters.stencilReference) {\n // eslint-disable-next-line no-console\n console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');\n // parameters.stencilFunc = [func, ref, mask];\n // Does this work?\n parameters[GL.STENCIL_REF] = parameters.stencilReference;\n }\n\n this.glParameters = glParameters;\n }\n\n // Internal\n\n /**\n * Optionally clears depth, color and stencil buffers based on parameters\n */\n protected clear(): void {\n const glParameters: GLParameters = {...this.glParameters};\n\n let clearMask = 0;\n\n if (this.props.clearColor !== false) {\n clearMask |= GL_COLOR_BUFFER_BIT;\n glParameters.clearColor = this.props.clearColor;\n }\n if (this.props.clearDepth !== false) {\n clearMask |= GL_DEPTH_BUFFER_BIT;\n glParameters.clearDepth = this.props.clearDepth;\n }\n if (this.props.clearStencil !== false) {\n clearMask |= GL_STENCIL_BUFFER_BIT;\n glParameters.clearStencil = this.props.clearStencil;\n }\n\n if (clearMask !== 0) {\n // Temporarily set any clear \"colors\" and call clear\n withParameters(this.device, glParameters, () => {\n this.device.gl.clear(clearMask);\n });\n\n // TODO - clear multiple color attachments\n // for (attachment of this.framebuffer.colorAttachments) {\n // this.clearColorBuffer \n // }\n }\n }\n\n /** \n * WebGL2 - clear a specific color buffer \n */\n protected clearColorBuffer(drawBuffer: number = 0, value: NumericArray = [0, 0, 0, 0]) {\n withParameters(this.device.gl2, {framebuffer: this.props.framebuffer}, () => {\n // Method selection per OpenGL ES 3 docs\n switch (value.constructor) {\n case Int32Array:\n this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);\n break;\n case Uint32Array:\n this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);\n break;\n case Float32Array:\n default:\n this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);\n break;\n }\n });\n }\n\n // clearDepthStencil() {\n // const GL_DEPTH = 0x1801;\n // const GL_STENCIL = 0x1802;\n // const GL_DEPTH_STENCIL = 0x84f9;\n\n // case GL_DEPTH:\n // this.device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);\n // break;\n\n // case GL_STENCIL:\n // this.device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);\n // break;\n\n // case GL_DEPTH_STENCIL:\n // const [depth, stencil] = value;\n // this.device.gl2.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);\n // break;\n\n // default:\n // assert(false, ERR_ARGUMENTS);\n // }\n // });\n}\n\n"],"mappings":";AAAA,SAAQA,UAAU,QAA4D,eAAe;AAE7F,SAAQC,EAAE,QAAqB,oBAAoB;AAAC,SAC5CC,cAAc;AAItB,MAAMC,mBAAmB,GAAG,UAAU;AACtC,MAAMC,qBAAqB,GAAG,UAAU;AACxC,MAAMC,mBAAmB,GAAG,UAAU;AAEtC,MAAMC,QAAQ,GAAG,MAAM;AAEvB,OAAO,MAAMC,eAAe,SAASP,UAAU,CAAC;EAM9CQ,WAAWA,CAACC,MAAmB,EAAEC,KAAsB,EAAE;IACvD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAGpB,IAAI,CAACG,aAAa,CAAC,IAAI,CAACF,KAAK,CAACG,UAAU,CAAC;IAGzC,IAAI,CAACC,KAAK,CAAC,CAAC;EACd;EAEAC,GAAGA,CAAA,EAAS,CAEZ;EAEAC,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAS,CAAC;EACvBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;EAY9CR,aAAaA,CAAA,EAA8C;IAAA,IAA7CC,UAAgC,GAAAQ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,S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AE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACnFnB,cAAc,CAAC,IAAI,CAACO,MAAM,CAAC4C,GAAG,EAAE;MAAC5B,WAAW,EAAE,IAAI,CAACf,KAAK,CAACe;IAAW,CAAC,EAAE,MAAM;MAE3E,QAAQ2B,KAAK,CAAC5C,WAAW;QACvB,KAAK8C,UAAU;UACb,IAAI,CAAC7C,MAAM,CAAC4C,GAAG,CAACE,aAAa,CAACjD,QAAQ,EAAE6C,UAAU,EAAEC,KAAK,CAAC;UAC1D;QACF,KAAKI,WAAW;UACd,IAAI,CAAC/C,MAAM,CAAC4C,GAAG,CAACI,cAAc,CAACnD,QAAQ,EAAE6C,UAAU,EAAEC,KAAK,CAAC;UAC3D;QACF,KAAKM,YAAY;QACjB;UACE,IAAI,CAACjD,MAAM,CAAC4C,GAAG,CAACM,aAAa,CAACrD,QAAQ,EAAE6C,UAAU,EAAEC,KAAK,CAAC;UAC1D;MACJ;IACF,CAAC,CAAC;EACJ;AAwBF"}
1
+ {"version":3,"file":"webgl-render-pass.js","names":["RenderPass","GL","withParameters","GL_DEPTH_BUFFER_BIT","GL_STENCIL_BUFFER_BIT","GL_COLOR_BUFFER_BIT","GL_COLOR","WEBGLRenderPass","constructor","device","props","glParameters","setParameters","parameters","clear","end","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel","arguments","length","undefined","framebuffer","depthReadOnly","depthMask","stencilMask","stencilReadOnly","RASTERIZER_DISCARD","discard","viewport","slice","depthRange","scissorTest","Boolean","scissorRect","scissor","blendConstant","blendColor","stencilReference","console","warn","STENCIL_REF","clearMask","clearColor","clearDepth","clearStencil","gl","clearColorBuffer","drawBuffer","value","gl2","Int32Array","clearBufferiv","Uint32Array","clearBufferuiv","Float32Array","clearBufferfv"],"sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"sourcesContent":["import {RenderPass, RenderPassProps, NumericArray, RenderPassParameters} from '@luma.gl/core';\nimport {WebGLDevice} from '../webgl-device';\nimport {GL, GLParameters} from '@luma.gl/constants';\nimport {withParameters} from '../../context/state-tracker/with-parameters';\n\n// Should collapse during minification\n\nconst GL_DEPTH_BUFFER_BIT = 0x00000100;\nconst GL_STENCIL_BUFFER_BIT = 0x00000400;\nconst GL_COLOR_BUFFER_BIT = 0x00004000;\n\nconst GL_COLOR = 0x1800;\n\nexport class WEBGLRenderPass extends RenderPass {\n readonly device: WebGLDevice;\n\n /** Parameters that should be applied before each draw call */\n glParameters: GLParameters;\n\n constructor(device: WebGLDevice, props: RenderPassProps) {\n super(device, props);\n this.device = device;\n\n // TODO - do parameters (scissorRect) affect the clear operation?\n this.setParameters(this.props.parameters);\n\n // Hack - for now WebGL draws in \"immediate mode\" (instead of queueing the operations)...\n this.clear();\n }\n\n end(): void {\n // should add commands to CommandEncoder.\n }\n\n pushDebugGroup(groupLabel: string): void {}\n popDebugGroup(): void {}\n insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n /**\n * Maps RenderPass parameters to GL parameters\n */\n setParameters(parameters: RenderPassParameters = {}): void {\n const glParameters: GLParameters = {};\n\n // Framebuffers are specified using parameters in WebGL\n if (this.props.framebuffer) {\n glParameters.framebuffer = this.props.framebuffer;\n }\n\n if (this.props.depthReadOnly) {\n glParameters.depthMask = !this.props.depthReadOnly;\n }\n\n glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;\n\n glParameters[GL.RASTERIZER_DISCARD] = this.props.discard;\n\n // Map the four renderpass parameters to WebGL parameters\n if (parameters.viewport) {\n // WebGPU viewports are 6 coordinates (X, Y, Z)\n if (parameters.viewport.length >= 6) {\n glParameters.viewport = parameters.viewport.slice(0, 4);\n glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];\n } else {\n // WebGL viewports are 4 coordinates (X, Y)\n glParameters.viewport = parameters.viewport;\n }\n }\n glParameters.scissorTest = Boolean(parameters.scissorRect);\n if (parameters.scissorRect) {\n glParameters.scissor = parameters.scissorRect;\n }\n if (parameters.blendConstant) {\n glParameters.blendColor = parameters.blendConstant;\n }\n if (parameters.stencilReference) {\n // eslint-disable-next-line no-console\n console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');\n // parameters.stencilFunc = [func, ref, mask];\n // Does this work?\n parameters[GL.STENCIL_REF] = parameters.stencilReference;\n }\n\n this.glParameters = glParameters;\n }\n\n // Internal\n\n /**\n * Optionally clears depth, color and stencil buffers based on parameters\n */\n protected clear(): void {\n const glParameters: GLParameters = {...this.glParameters};\n\n let clearMask = 0;\n\n if (this.props.clearColor !== false) {\n clearMask |= GL_COLOR_BUFFER_BIT;\n glParameters.clearColor = this.props.clearColor;\n }\n if (this.props.clearDepth !== false) {\n clearMask |= GL_DEPTH_BUFFER_BIT;\n glParameters.clearDepth = this.props.clearDepth;\n }\n if (this.props.clearStencil !== false) {\n clearMask |= GL_STENCIL_BUFFER_BIT;\n glParameters.clearStencil = this.props.clearStencil;\n }\n\n if (clearMask !== 0) {\n // Temporarily set any clear \"colors\" and call clear\n withParameters(this.device, glParameters, () => {\n this.device.gl.clear(clearMask);\n });\n\n // TODO - clear multiple color attachments\n // for (attachment of this.framebuffer.colorAttachments) {\n // this.clearColorBuffer \n // }\n }\n }\n\n /** \n * WebGL2 - clear a specific color buffer \n */\n protected clearColorBuffer(drawBuffer: number = 0, value: NumericArray = [0, 0, 0, 0]) {\n withParameters(this.device.gl2, {framebuffer: this.props.framebuffer}, () => {\n // Method selection per OpenGL ES 3 docs\n switch (value.constructor) {\n case Int32Array:\n this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);\n break;\n case Uint32Array:\n this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);\n break;\n case Float32Array:\n default:\n this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);\n break;\n }\n });\n }\n\n // clearDepthStencil() {\n // const GL_DEPTH = 0x1801;\n // const GL_STENCIL = 0x1802;\n // const GL_DEPTH_STENCIL = 0x84f9;\n\n // case GL_DEPTH:\n // this.device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);\n // break;\n\n // case GL_STENCIL:\n // this.device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);\n // break;\n\n // case GL_DEPTH_STENCIL:\n // const [depth, stencil] = value;\n // this.device.gl2.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);\n // break;\n\n // default:\n // assert(false, ERR_ARGUMENTS);\n // }\n // });\n}\n\n"],"mappings":"AAAA,SAAQA,UAAU,QAA4D,eAAe;AAE7F,SAAQC,EAAE,QAAqB,oBAAoB;AAAC,SAC5CC,cAAc;AAItB,MAAMC,mBAAmB,GAAG,UAAU;AACtC,MAAMC,qBAAqB,GAAG,UAAU;AACxC,MAAMC,mBAAmB,GAAG,UAAU;AAEtC,MAAMC,QAAQ,GAAG,MAAM;AAEvB,OAAO,MAAMC,eAAe,SAASP,UAAU,CAAC;EAM9CQ,WAAWA,CAACC,MAAmB,EAAEC,KAAsB,EAAE;IACvD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KANdD,MAAM;IAAA,KAGfE,YAAY;IAIV,IAAI,CAACF,MAAM,GAAGA,MAAM;IAGpB,IAAI,CAACG,aAAa,CAAC,IAAI,CAACF,KAAK,CAACG,UAAU,CAAC;IAGzC,IAAI,CAACC,KAAK,CAAC,CAAC;EACd;EAEAC,GAAGA,CAAA,EAAS,CAEZ;EAEAC,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAS,CAAC;EACvBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;EAY9CR,aAAaA,CAAA,EAA8C;IAAA,IAA7CC,UAAgC,GAAAQ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACjD,MAAMV,YAA0B,GAA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ACnFnB,cAAc,CAAC,IAAI,CAACO,MAAM,CAAC2C,GAAG,EAAE;MAAC5B,WAAW,EAAE,IAAI,CAACd,KAAK,CAACc;IAAW,CAAC,EAAE,MAAM;MAE3E,QAAQ2B,KAAK,CAAC3C,WAAW;QACvB,KAAK6C,UAAU;UACb,IAAI,CAAC5C,MAAM,CAAC2C,GAAG,CAACE,aAAa,CAAChD,QAAQ,EAAE4C,UAAU,EAAEC,KAAK,CAAC;UAC1D;QACF,KAAKI,WAAW;UACd,IAAI,CAAC9C,MAAM,CAAC2C,GAAG,CAACI,cAAc,CAAClD,QAAQ,EAAE4C,UAAU,EAAEC,KAAK,CAAC;UAC3D;QACF,KAAKM,YAAY;QACjB;UACE,IAAI,CAAChD,MAAM,CAAC2C,GAAG,CAACM,aAAa,CAACpD,QAAQ,EAAE4C,UAAU,EAAEC,KAAK,CAAC;UAC1D;MACJ;IACF,CAAC,CAAC;EACJ;AAwBF"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,YAAY,EAEb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,cAAc,EAAY,MAAM,eAAe,CAAC;AAUxD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAK5E,oCAAoC;AACpC,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,yDAAyD;IACzD,MAAM,EAAE,WAAW,CAAC;IACpB,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AC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAqCpD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;IAKlD;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,EAAE,UAAU,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO;IAmFX,SAAS,CAAC,eAAe;IA0BzB;;;;OAIG;IACH,sBAAsB;IAkBtB;;;;;OAKG;IACH,wBAAwB,IAAI,IAAI;IAchC,iDAAiD;IACjD,cAAc;IA6Dd;;;OAGG;IACH,cAAc;CASf"}
1
+ {"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,YAAY,EAEb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,cAAc,EAAY,MAAM,eAAe,CAAC;AAUxD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAK5E,oCAAoC;AACpC,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,yDAAyD;IACzD,MAAM,EAAE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AQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAqCpD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;IAKlD;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,EAAE,UAAU,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO;IAmFX,SAAS,CAAC,eAAe;IA0BzB;;;;OAIG;IACH,sBAAsB;IAkBtB;;;;;OAKG;IACH,wBAAwB,IAAI,IAAI;IAehC,iDAAiD;IACjD,cAAc;IA6Dd;;;OAGG;IACH,cAAc;CASf"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { RenderPipeline, cast, log } from '@luma.gl/core';
3
2
  import { mergeShaderLayout, getAttributeInfosFromLayouts } from '@luma.gl/core';
4
3
  import { GL } from '@luma.gl/constants';
@@ -13,23 +12,23 @@ const LOG_PROGRAM_PERF_PRIORITY = 4;
13
12
  export class WEBGLRenderPipeline extends RenderPipeline {
14
13
  constructor(device, props) {
15
14
  super(device, props);
16
- _defineProperty(this, "device", void 0);
17
- _defineProperty(this, "handle", void 0);
18
- _defineProperty(this, "vs", void 0);
19
- _defineProperty(this, "fs", void 0);
20
- _defineProperty(this, "introspectedLayout", void 0);
21
- _defineProperty(this, "shaderLayout", void 0);
22
- _defineProperty(this, "bufferLayout", void 0);
23
- _defineProperty(this, "uniforms", {});
24
- _defineProperty(this, "bindings", {});
25
- _defineProperty(this, "constantAttributes", {});
26
- _defineProperty(this, "_indexBuffer", void 0);
27
- _defineProperty(this, "varyings", null);
28
- _defineProperty(this, "vertexArrayObject", void 0);
29
- _defineProperty(this, "_textureUniforms", {});
30
- _defineProperty(this, "_textureIndexCounter", 0);
31
- _defineProperty(this, "_uniformCount", 0);
32
- _defineProperty(this, "_uniformSetters", {});
15
+ this.device = void 0;
16
+ this.handle = void 0;
17
+ this.vs = void 0;
18
+ this.fs = void 0;
19
+ this.introspectedLayout = void 0;
20
+ this.shaderLayout = void 0;
21
+ this.bufferLayout = void 0;
22
+ this.uniforms = {};
23
+ this.bindings = {};
24
+ this.constantAttributes = {};
25
+ this._indexBuffer = void 0;
26
+ this.varyings = null;
27
+ this.vertexArrayObject = void 0;
28
+ this._textureUniforms = {};
29
+ this._textureIndexCounter = 0;
30
+ this._uniformCount = 0;
31
+ this._uniformSetters = {};
33
32
  this.device = device;
34
33
  this.handle = this.props.handle || this.device.gl.createProgram();
35
34
  this.device.setSpectorMetadata(this.handle, {
@@ -74,8 +73,8 @@ export class WEBGLRenderPipeline extends RenderPipeline {
74
73
  }
75
74
  const webglBuffer = cast(buffer);
76
75
  const glType = getGLFromVertexType(attributeInfo.bufferDataType);
77
- log.log(1, {
78
- setAttribute: attributeInfo.name,
76
+ log.log(2, {
77
+ setAttribute: attributeInfo.attributeName,
79
78
  toBuffer: bufferName,
80
79
  size: attributeInfo.bufferComponents,
81
80
  type: glType,
@@ -97,7 +96,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
97
96
  set = true;
98
97
  }
99
98
  if (!set) {
100
- log.warn("setAttributes(): Ignoring (buffer \"".concat(buffer.id, "\" for unknown attribute \"").concat(name, "\" in pipeline \"").concat(this.id, "\""))();
99
+ log.warn(`setAttributes(): Ignoring (buffer "${buffer.id}" for unknown attribute "${name}" in pipeline "${this.id}"`)();
101
100
  }
102
101
  }
103
102
  }
@@ -108,11 +107,11 @@ export class WEBGLRenderPipeline extends RenderPipeline {
108
107
  for (const [name, value] of Object.entries(bindings)) {
109
108
  const binding = this.shaderLayout.bindings.find(binding => binding.name === name);
110
109
  if (!binding) {
111
- log.warn("Unknown binding ".concat(name, " in render pipeline ").concat(this.id))();
110
+ log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();
112
111
  continue;
113
112
  }
114
113
  if (!value) {
115
- log.warn("Unsetting binding ".concat(name, " in render pipeline ").concat(this.id))();
114
+ log.warn(`Unsetting binding ${name} in render pipeline ${this.id}`)();
116
115
  }
117
116
  switch (binding.type) {
118
117
  case 'uniform':
@@ -126,7 +125,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
126
125
  }
127
126
  break;
128
127
  case 'sampler':
129
- log.warn("Ignoring sampler ".concat(name))();
128
+ log.warn(`Ignoring sampler ${name}`)();
130
129
  break;
131
130
  default:
132
131
  throw new Error(binding.type);
@@ -190,18 +189,18 @@ export class WEBGLRenderPipeline extends RenderPipeline {
190
189
  } = this.device;
191
190
  gl.attachShader(this.handle, this.vs.handle);
192
191
  gl.attachShader(this.handle, this.fs.handle);
193
- log.time(LOG_PROGRAM_PERF_PRIORITY, "linkProgram for ".concat(this.id))();
192
+ log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
194
193
  gl.linkProgram(this.handle);
195
- log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, "linkProgram for ".concat(this.id))();
194
+ log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
196
195
  if (gl.debug || log.level > 0) {
197
196
  const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);
198
197
  if (!linked) {
199
- throw new Error("Error linking: ".concat(gl.getProgramInfoLog(this.handle)));
198
+ throw new Error(`Error linking: ${gl.getProgramInfoLog(this.handle)}`);
200
199
  }
201
200
  gl.validateProgram(this.handle);
202
201
  const validated = gl.getProgramParameter(this.handle, gl.VALIDATE_STATUS);
203
202
  if (!validated) {
204
- throw new Error("Error validating: ".concat(gl.getProgramInfoLog(this.handle)));
203
+ throw new Error(`Error validating: ${gl.getProgramInfoLog(this.handle)}`);
205
204
  }
206
205
  }
207
206
  }
@@ -223,10 +222,11 @@ export class WEBGLRenderPipeline extends RenderPipeline {
223
222
  for (const [name, value] of Object.entries(this.constantAttributes)) {
224
223
  const attributeInfo = attributeInfos[name];
225
224
  if (!attributeInfo) {
226
- log.warn("Ignoring constant value supplied for unknown attribute \"".concat(name, "\" in pipeline \"").concat(this.id, "\""))();
225
+ log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
227
226
  continue;
228
227
  }
229
228
  this.vertexArrayObject.setConstant(attributeInfo.location, value);
229
+ this.vertexArrayObject.enable(attributeInfo.location, false);
230
230
  }
231
231
  }
232
232
  _applyBindings() {
@@ -242,7 +242,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
242
242
  for (const binding of this.shaderLayout.bindings) {
243
243
  const value = this.bindings[binding.name];
244
244
  if (!value) {
245
- throw new Error("No value for binding ".concat(binding.name, " in ").concat(this.id));
245
+ throw new Error(`No value for binding ${binding.name} in ${this.id}`);
246
246
  }
247
247
  switch (binding.type) {
248
248
  case 'uniform':
@@ -251,7 +251,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
251
251
  } = binding;
252
252
  const location = gl2.getUniformBlockIndex(this.handle, name);
253
253
  if (location === GL.INVALID_INDEX) {
254
- throw new Error("Invalid uniform block name ".concat(name));
254
+ throw new Error(`Invalid uniform block name ${name}`);
255
255
  }
256
256
  gl2.uniformBlockBinding(this.handle, uniformBufferIndex, location);
257
257
  if (value instanceof WEBGLBuffer) {
@@ -274,7 +274,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
274
274
  break;
275
275
  case 'storage':
276
276
  case 'read-only-storage':
277
- throw new Error("binding type '".concat(binding.type, "' not supported in WebGL"));
277
+ throw new Error(`binding type '${binding.type}' not supported in WebGL`);
278
278
  }
279
279
  }
280
280
  }