@luma.gl/webgpu 9.0.0-alpha.24 → 9.0.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/helpers/accessor-to-format.js.map +1 -1
- package/dist/adapter/helpers/generate-mipmaps.js.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js +3 -3
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +2 -2
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +34 -76
- package/dist/glsl/glsllang.js.map +1 -1
- package/dist.min.js +3 -3
- package/package.json +3 -3
- package/src/adapter/helpers/accessor-to-format.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-canvas-context.js","names":["CanvasContext","log","getWebGPUTextureFormat","WebGPUFramebuffer","WebGPUCanvasContext","constructor","device","adapter","props","_defineProperty","width","height","_setAutoCreatedCanvasId","concat","id","gpuCanvasContext","canvas","getContext","format","getPreferredFormat","destroy","unconfigure","getCurrentFramebuffer","update","currentColorAttachment","createTexture","handle","getCurrentTexture","_createDepthStencilAttachment","colorAttachments","depthStencilAttachment","getPixelSize","sizeChanged","configure","colorSpace","alphaMode","resize","options","depthStencilFormat","usage","GPUTextureUsage","RENDER_ATTACHMENT"],"sources":["../../src/adapter/webgpu-canvas-context.ts"],"sourcesContent":["import type {Texture, TextureFormat, CanvasContextProps} from '@luma.gl/api';\nimport {CanvasContext, log} from '@luma.gl/api';\nimport {getWebGPUTextureFormat} from './helpers/convert-texture-format';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\n\n/** \n * Holds a WebGPU Canvas Context which handles resizing etc \n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly gpuCanvasContext: GPUCanvasContext;\n readonly format: TextureFormat;\n depthStencilFormat: TextureFormat = 'depth24plus';\n sampleCount: number = 1;\n\n private depthStencilAttachment: Texture | null = null;\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n \n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu') ;\n // @ts-expect-error TODO this has been replaced\n this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n }\n\n destroy(): void {\n this.gpuCanvasContext.unconfigure();\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer(): WebGPUFramebuffer {\n // Ensure the canvas context size is updated\n this.update();\n\n // Wrap the current canvas context texture in a luma.gl texture \n const currentColorAttachment = this.device.createTexture({\n id: 'default-render-target',\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format,\n width: this.width,\n height: this.height\n });\n\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n\n const sizeChanged = width !== this.width || height !== this.height;\n\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // size: [this.width, this.height],\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n\n }\n\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n this.update();\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: 'depth-stencil-target',\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n"],"mappings":";AACA,SAAQA,aAAa,EAAEC,GAAG,QAAO,cAAc;AAAC,SACxCC,sBAAsB;AAAA,SAEtBC,iBAAiB;AAKzB,OAAO,MAAMC,mBAAmB,SAASJ,aAAa,CAAC;EASrDK,WAAWA,CAACC,MAAoB,EAAEC,OAAmB,EAAEC,KAAyB,EAAE;IAChF,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,6BANqB,aAAa;IAAAA,eAAA,sBAC3B,CAAC;IAAAA,eAAA,iCAE0B,IAAI;IAInD,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACI,KAAK,GAAG,CAAC,CAAC;IACf,IAAI,CAACC,MAAM,GAAG,CAAC,CAAC;IAEhB,IAAI,CAACC,uBAAuB,IAAAC,MAAA,CAAI,IAAI,CAACP,MAAM,CAACQ,EAAE,
|
|
1
|
+
{"version":3,"file":"webgpu-canvas-context.js","names":["CanvasContext","log","getWebGPUTextureFormat","WebGPUFramebuffer","WebGPUCanvasContext","constructor","device","adapter","props","_defineProperty","width","height","_setAutoCreatedCanvasId","concat","id","gpuCanvasContext","canvas","getContext","format","getPreferredFormat","destroy","unconfigure","getCurrentFramebuffer","update","currentColorAttachment","createTexture","handle","getCurrentTexture","_createDepthStencilAttachment","colorAttachments","depthStencilAttachment","getPixelSize","sizeChanged","configure","colorSpace","alphaMode","resize","options","depthStencilFormat","usage","GPUTextureUsage","RENDER_ATTACHMENT"],"sources":["../../src/adapter/webgpu-canvas-context.ts"],"sourcesContent":["import type {Texture, TextureFormat, CanvasContextProps} from '@luma.gl/api';\nimport {CanvasContext, log} from '@luma.gl/api';\nimport {getWebGPUTextureFormat} from './helpers/convert-texture-format';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\n\n/** \n * Holds a WebGPU Canvas Context which handles resizing etc \n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly gpuCanvasContext: GPUCanvasContext;\n readonly format: TextureFormat;\n depthStencilFormat: TextureFormat = 'depth24plus';\n sampleCount: number = 1;\n\n private depthStencilAttachment: Texture | null = null;\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n \n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu') ;\n // @ts-expect-error TODO this has been replaced\n this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n }\n\n destroy(): void {\n this.gpuCanvasContext.unconfigure();\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer(): WebGPUFramebuffer {\n // Ensure the canvas context size is updated\n this.update();\n\n // Wrap the current canvas context texture in a luma.gl texture \n const currentColorAttachment = this.device.createTexture({\n id: 'default-render-target',\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format,\n width: this.width,\n height: this.height\n });\n\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n\n const sizeChanged = width !== this.width || height !== this.height;\n\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // size: [this.width, this.height],\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n\n }\n\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n this.update();\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: 'depth-stencil-target',\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n"],"mappings":";AACA,SAAQA,aAAa,EAAEC,GAAG,QAAO,cAAc;AAAC,SACxCC,sBAAsB;AAAA,SAEtBC,iBAAiB;AAKzB,OAAO,MAAMC,mBAAmB,SAASJ,aAAa,CAAC;EASrDK,WAAWA,CAACC,MAAoB,EAAEC,OAAmB,EAAEC,KAAyB,EAAE;IAChF,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,6BANqB,aAAa;IAAAA,eAAA,sBA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","names":["Device","CanvasContext","log","uid","WebGPUBuffer","WebGPUTexture","WebGPUExternalTexture","WebGPUSampler","WebGPUShader","WebGPURenderPipeline","WebGPUComputePipeline","WebGPURenderPass","WebGPUComputePass","WebGPUCanvasContext","WebGPUDevice","isSupported","Boolean","navigator","gpu","create","props","Error","groupCollapsed","adapter","requestAdapter","powerPreference","adapterInfo","requestAdapterInfo","probe","gpuDevice","requestDevice","requiredFeatures","features","canvas","pageLoaded","device","info","table","groupEnd","constructor","id","_defineProperty","handle","_info","type","vendor","__brand","renderer","version","shadingLanguages","shadingLanguageVersions","glsl","wgsl","vendorMasked","rendererMasked","lost","Promise","resolve","lostInfo","_isLost","reason","message","canvasContext","_getFeatures","destroy","limits","isTextureFormatSupported","format","includes","isTextureFormatFilterable","isTextureFormatRenderable","isLost","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createShader","createSampler","createRenderPipeline","createFramebuffer","createComputePipeline","beginRenderPass","commandEncoder","createCommandEncoder","beginComputePass","createCanvasContext","getDefaultRenderPass","_this$canvasContext","renderPass","framebuffer","getCurrentFramebuffer","submit","_this$renderPass","_this$commandEncoder","end","commandBuffer","finish","queue","Set","has","delete","add","copyExternalImageToTexture","options","_this$handle","source","sourceX","sourceY","texture","mipLevel","aspect","colorSpace","premultipliedAlpha","width","height","depth","webGpuTexture","origin"],"sources":["../../src/adapter/webgpu-device.ts"],"sourcesContent":["// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n Texture,\n TextureProps,\n TextureFormat,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n RenderPassProps,\n ComputePassProps,\n // CommandEncoderProps\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/api';\nimport {WebGPUBuffer} from './resources/webgpu-buffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {WebGPUExternalTexture} from './resources/webgpu-external-texture';\nimport {WebGPUSampler} from './resources/webgpu-sampler';\nimport {WebGPUShader} from './resources/webgpu-shader';\nimport {WebGPURenderPipeline} from './resources/webgpu-render-pipeline';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUComputePipeline} from './resources/webgpu-compute-pipeline';\nimport {WebGPURenderPass} from './resources/webgpu-render-pass';\nimport {WebGPUComputePass} from './resources/webgpu-compute-pass';\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\n// import {loadGlslangModule} from '../glsl/glslang';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n readonly handle: GPUDevice;\n readonly adapter: GPUAdapter;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n canvasContext: WebGPUCanvasContext | null = null;\n\n commandEncoder: GPUCommandEncoder | null = null;\n renderPass: WebGPURenderPass | null = null;\n\n private _info: DeviceInfo;\n private _isLost: boolean = false;\n\n static type: string = 'webgpu';\n\n /** Check if WebGPU is available */\n static isSupported(): boolean {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n static async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error(\n 'WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu'\n );\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(1, 'Adapter available', adapterInfo)();\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>\n // TODO ensure we obtain best limits\n // requiredLimits: adapter.limits\n });\n log.probe(1, 'GPUDevice available')();\n\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n\n const device = new WebGPUDevice(gpuDevice, adapter, props);\n log.probe(1, 'Device created', device.info)();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n\n constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps) {\n super({...props, id: props.id || uid('webgpu-device')});\n this.handle = device;\n this.adapter = adapter;\n\n this._info = {\n type: 'webgpu',\n vendor: this.adapter.__brand,\n renderer: '',\n version: '',\n gpu: 'unknown', // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n shadingLanguages: ['glsl', 'wgsl'],\n shadingLanguageVersions: {\n glsl: '450',\n wgsl: '100'\n },\n vendorMasked: '',\n rendererMasked: ''\n };\n\n // \"Context\" loss handling\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({reason: 'destroyed', message: lostInfo.message});\n });\n\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n if (props.canvas) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {canvas: props.canvas});\n }\n\n this.features = this._getFeatures();\n }\n\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n\n destroy(): void {\n this.handle.destroy();\n }\n\n get info(): DeviceInfo {\n return this._info;\n }\n\n features: Set<DeviceFeature>;\n\n get limits(): DeviceLimits {\n return this.handle.limits;\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return !format.includes('webgl');\n }\n\n /** @todo implement proper check? */\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n /** @todo implement proper check? */\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n get isLost(): boolean {\n return this._isLost;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WebGPUTexture {\n return new WebGPUTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture {\n return new WebGPUExternalTexture(this, props);\n }\n\n createShader(props: ShaderProps): WebGPUShader {\n return new WebGPUShader(this, props);\n }\n\n createSampler(props: SamplerProps): WebGPUSampler {\n return new WebGPUSampler(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline {\n return new WebGPURenderPipeline(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WebGPUFramebuffer {\n throw new Error('Not implemented');\n }\n\n createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n // WebGPU specifics\n\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props: RenderPassProps): WebGPURenderPass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n /**\n * Gets default renderpass encoder.\n * Creates a new encoder against default canvasContext if not already created\n * @note Called internally by Model.\n */\n getDefaultRenderPass(): WebGPURenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext?.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n submit(): void {\n this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n this.renderPass = null;\n }\n\n _getFeatures() {\n // WebGPU Features\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\n\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n\n // Add subsets\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n features.add('webgpu');\n\n features.add('timer-query-webgl');\n\n // WEBGL1 SUPPORT\n features.add('vertex-array-object-webgl1');\n features.add('instanced-rendering-webgl1');\n features.add('multiple-render-targets-webgl1');\n features.add('index-uint32-webgl1');\n features.add('blend-minmax-webgl1');\n features.add('texture-blend-float-webgl1');\n\n // TEXTURES, RENDERBUFFERS\n features.add('texture-formats-srgb-webgl1');\n\n // TEXTURES\n features.add('texture-formats-depth-webgl1');\n features.add('texture-formats-float32-webgl1');\n features.add('texture-formats-float16-webgl1');\n\n features.add('texture-filter-linear-float32-webgl');\n features.add('texture-filter-linear-float16-webgl');\n features.add('texture-filter-anisotropic-webgl');\n\n // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS\n features.add('texture-renderable-rgba32float-webgl');\n features.add('texture-renderable-float32-webgl');\n features.add('texture-renderable-float16-webgl');\n\n // GLSL extensions\n features.add('glsl-frag-data');\n features.add('glsl-frag-depth');\n features.add('glsl-derivatives');\n features.add('glsl-texture-lod');\n\n return features;\n }\n\n copyExternalImageToTexture(options: {\n texture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'display-p3' | 'srgb';\n premultipliedAlpha?: boolean;\n\n source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;\n sourceX?: number;\n sourceY?: number;\n\n width?: number;\n height?: number;\n depth?: number;\n }): void {\n const {\n source,\n sourceX = 0,\n sourceY = 0,\n\n texture,\n mipLevel = 0,\n aspect = 'all',\n colorSpace = 'display-p3',\n premultipliedAlpha = false,\n // destinationX,\n // destinationY,\n // desitnationZ,\n\n width = texture.width,\n height = texture.height,\n depth = 1\n } = options;\n\n const webGpuTexture = texture as WebGPUTexture;\n\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n )\n }\n}\n"],"mappings":";AAuBA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,QAAO,cAAc;AAAC,SACrDC,YAAY;AAAA,SACZC,aAAa;AAAA,SACbC,qBAAqB;AAAA,SACrBC,aAAa;AAAA,SACbC,YAAY;AAAA,SACZC,oBAAoB;AAAA,SAEpBC,qBAAqB;AAAA,SACrBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SAGjBC,mBAAmB;AAI3B,OAAO,MAAMC,YAAY,SAASd,MAAM,CAAC;EAevC,OAAOe,WAAWA,CAAA,EAAY;IAC5B,OAAOC,OAAO,CAAC,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,GAAG,CAAC;EACnE;EAEA,aAAaC,MAAMA,CAACC,KAAkB,EAAyB;IAC7D,IAAI,CAACH,SAAS,CAACC,GAAG,EAAE;MAClB,MAAM,IAAIG,KAAK,CACb,8FAA8F,CAC/F;IACH;IACAnB,GAAG,CAACoB,cAAc,CAAC,CAAC,EAAE,sBAAsB,CAAC,EAAE;IAC/C,MAAMC,OAAO,GAAG,MAAMN,SAAS,CAACC,GAAG,CAACM,cAAc,CAAC;MACjDC,eAAe,EAAE;IAEnB,CAAC,CAAC;IACF,IAAI,CAACF,OAAO,EAAE;M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uffer","WebGPUTexture","WebGPUExternalTexture","WebGPUSampler","WebGPUShader","WebGPURenderPipeline","WebGPUComputePipeline","WebGPURenderPass","WebGPUComputePass","WebGPUCanvasContext","WebGPUDevice","isSupported","Boolean","navigator","gpu","create","props","Error","groupCollapsed","adapter","requestAdapter","powerPreference","adapterInfo","requestAdapterInfo","probe","gpuDevice","requestDevice","requiredFeatures","features","canvas","pageLoaded","device","info","table","groupEnd","constructor","id","_defineProperty","handle","_info","type","vendor","__brand","renderer","version","shadingLanguages","shadingLanguageVersions","glsl","wgsl","vendorMasked","rendererMasked","lost","Promise","resolve","lostInfo","_isLost","reason","message","canvasContext","_getFeatures","destroy","limits","isTextureFormatSupported","format","includes","isTextureFormatFilterable","isTextureFormatRenderable","isLost","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createShader","createSampler","createRenderPipeline","createFramebuffer","createComputePipeline","beginRenderPass","commandEncoder","createCommandEncoder","beginComputePass","createCanvasContext","getDefaultRenderPass","_this$canvasContext","renderPass","framebuffer","getCurrentFramebuffer","submit","_this$renderPass","_this$commandEncoder","end","commandBuffer","finish","queue","Set","has","delete","add","copyExternalImageToTexture","options","_this$handle","source","sourceX","sourceY","texture","mipLevel","aspect","colorSpace","premultipliedAlpha","width","height","depth","webGpuTexture","origin"],"sources":["../../src/adapter/webgpu-device.ts"],"sourcesContent":["// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n Texture,\n TextureProps,\n TextureFormat,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n RenderPassProps,\n ComputePassProps,\n // CommandEncoderProps\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/api';\nimport {WebGPUBuffer} from './resources/webgpu-buffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {WebGPUExternalTexture} from './resources/webgpu-external-texture';\nimport {WebGPUSampler} from './resources/webgpu-sampler';\nimport {WebGPUShader} from './resources/webgpu-shader';\nimport {WebGPURenderPipeline} from './resources/webgpu-render-pipeline';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUComputePipeline} from './resources/webgpu-compute-pipeline';\nimport {WebGPURenderPass} from './resources/webgpu-render-pass';\nimport {WebGPUComputePass} from './resources/webgpu-compute-pass';\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\n// import {loadGlslangModule} from '../glsl/glslang';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n readonly handle: GPUDevice;\n readonly adapter: GPUAdapter;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n canvasContext: WebGPUCanvasContext | null = null;\n\n commandEncoder: GPUCommandEncoder | null = null;\n renderPass: WebGPURenderPass | null = null;\n\n private _info: DeviceInfo;\n private _isLost: boolean = false;\n\n static type: string = 'webgpu';\n\n /** Check if WebGPU is available */\n static isSupported(): boolean {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n static async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error(\n 'WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu'\n );\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(1, 'Adapter available', adapterInfo)();\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>\n // TODO ensure we obtain best limits\n // requiredLimits: adapter.limits\n });\n log.probe(1, 'GPUDevice available')();\n\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n\n const device = new WebGPUDevice(gpuDevice, adapter, props);\n log.probe(1, 'Device created', device.info)();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n\n constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps) {\n super({...props, id: props.id || uid('webgpu-device')});\n this.handle = device;\n this.adapter = adapter;\n\n this._info = {\n type: 'webgpu',\n vendor: this.adapter.__brand,\n renderer: '',\n version: '',\n gpu: 'unknown', // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n shadingLanguages: ['glsl', 'wgsl'],\n shadingLanguageVersions: {\n glsl: '450',\n wgsl: '100'\n },\n vendorMasked: '',\n rendererMasked: ''\n };\n\n // \"Context\" loss handling\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({reason: 'destroyed', message: lostInfo.message});\n });\n\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n if (props.canvas) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {canvas: props.canvas});\n }\n\n this.features = this._getFeatures();\n }\n\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n\n destroy(): void {\n this.handle.destroy();\n }\n\n get info(): DeviceInfo {\n return this._info;\n }\n\n features: Set<DeviceFeature>;\n\n get limits(): DeviceLimits {\n return this.handle.limits;\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return !format.includes('webgl');\n }\n\n /** @todo implement proper check? */\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n /** @todo implement proper check? */\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n get isLost(): boolean {\n return this._isLost;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WebGPUTexture {\n return new WebGPUTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture {\n return new WebGPUExternalTexture(this, props);\n }\n\n createShader(props: ShaderProps): WebGPUShader {\n return new WebGPUShader(this, props);\n }\n\n createSampler(props: SamplerProps): WebGPUSampler {\n return new WebGPUSampler(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline {\n return new WebGPURenderPipeline(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WebGPUFramebuffer {\n throw new Error('Not implemented');\n }\n\n createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n // WebGPU specifics\n\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props: RenderPassProps): WebGPURenderPass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n /**\n * Gets default renderpass encoder.\n * Creates a new encoder against default canvasContext if not already created\n * @note Called internally by Model.\n */\n getDefaultRenderPass(): WebGPURenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext?.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n submit(): void {\n this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n this.renderPass = null;\n }\n\n _getFeatures() {\n // WebGPU Features\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\n\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n\n // Add subsets\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n features.add('webgpu');\n\n features.add('timer-query-webgl');\n\n // WEBGL1 SUPPORT\n features.add('vertex-array-object-webgl1');\n features.add('instanced-rendering-webgl1');\n features.add('multiple-render-targets-webgl1');\n features.add('index-uint32-webgl1');\n features.add('blend-minmax-webgl1');\n features.add('texture-blend-float-webgl1');\n\n // TEXTURES, RENDERBUFFERS\n features.add('texture-formats-srgb-webgl1');\n\n // TEXTURES\n features.add('texture-formats-depth-webgl1');\n features.add('texture-formats-float32-webgl1');\n features.add('texture-formats-float16-webgl1');\n\n features.add('texture-filter-linear-float32-webgl');\n features.add('texture-filter-linear-float16-webgl');\n features.add('texture-filter-anisotropic-webgl');\n\n // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS\n features.add('texture-renderable-rgba32float-webgl');\n features.add('texture-renderable-float32-webgl');\n features.add('texture-renderable-float16-webgl');\n\n // GLSL extensions\n features.add('glsl-frag-data');\n features.add('glsl-frag-depth');\n features.add('glsl-derivatives');\n features.add('glsl-texture-lod');\n\n return features;\n }\n\n copyExternalImageToTexture(options: {\n texture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'display-p3' | 'srgb';\n premultipliedAlpha?: boolean;\n\n source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;\n sourceX?: number;\n sourceY?: number;\n\n width?: number;\n height?: number;\n depth?: number;\n }): void {\n const {\n source,\n sourceX = 0,\n sourceY = 0,\n\n texture,\n mipLevel = 0,\n aspect = 'all',\n colorSpace = 'display-p3',\n premultipliedAlpha = false,\n // destinationX,\n // destinationY,\n // desitnationZ,\n\n width = texture.width,\n height = texture.height,\n depth = 1\n } = options;\n\n const webGpuTexture = texture as WebGPUTexture;\n\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n )\n }\n}\n"],"mappings":";AAuBA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,QAAO,cAAc;AAAC,SACrDC,YAAY;AAAA,SACZC,aAAa;AAAA,SACbC,qBAAqB;AAAA,SACrBC,aAAa;AAAA,SACbC,YAAY;AAAA,SACZC,oBAAoB;AAAA,SAEpBC,qBAAqB;AAAA,SACrBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SAGjBC,mBAAmB;AAI3B,OAAO,MAAMC,YAAY,SAASd,MAAM,CAAC;EAevC,OAAOe,WAAWA,CAAA,EAAY;IAC5B,OAAOC,OAAO,CAAC,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,GAAG,CAAC;EACnE;EAEA,aAAaC,MAAMA,CAACC,KAAkB,EAAyB;IAC7D,IAAI,CAACH,SAAS,CAACC,GAAG,EAAE;MAClB,MAAM,IAAIG,KAAK,CACb,8FACF,CAAC;IACH;IACAnB,GAAG,CAACoB,cAAc,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAC/C,MAAMC,OAAO,GAAG,MAAMN,SAAS,CAACC,GAAG,CAACM,cAAc,CAAC;MACjDC,eAAe,EAAE;IAEnB,CAAC,CAAC;IACF,IAAI,CAACF,OAAO,EAAE;MACZ,MAAM,IAAIF,KAAK,CAA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/dist.dev.js
CHANGED
|
@@ -72,52 +72,6 @@ var __exports__ = (() => {
|
|
|
72
72
|
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
73
73
|
var isBrowser2 = isBrowser();
|
|
74
74
|
|
|
75
|
-
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
76
|
-
function _typeof(obj) {
|
|
77
|
-
"@babel/helpers - typeof";
|
|
78
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
79
|
-
return typeof obj2;
|
|
80
|
-
} : function(obj2) {
|
|
81
|
-
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
82
|
-
}, _typeof(obj);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
86
|
-
function _toPrimitive(input, hint) {
|
|
87
|
-
if (_typeof(input) !== "object" || input === null)
|
|
88
|
-
return input;
|
|
89
|
-
var prim = input[Symbol.toPrimitive];
|
|
90
|
-
if (prim !== void 0) {
|
|
91
|
-
var res = prim.call(input, hint || "default");
|
|
92
|
-
if (_typeof(res) !== "object")
|
|
93
|
-
return res;
|
|
94
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
95
|
-
}
|
|
96
|
-
return (hint === "string" ? String : Number)(input);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
100
|
-
function _toPropertyKey(arg) {
|
|
101
|
-
var key = _toPrimitive(arg, "string");
|
|
102
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
106
|
-
function _defineProperty(obj, key, value) {
|
|
107
|
-
key = _toPropertyKey(key);
|
|
108
|
-
if (key in obj) {
|
|
109
|
-
Object.defineProperty(obj, key, {
|
|
110
|
-
value,
|
|
111
|
-
enumerable: true,
|
|
112
|
-
configurable: true,
|
|
113
|
-
writable: true
|
|
114
|
-
});
|
|
115
|
-
} else {
|
|
116
|
-
obj[key] = value;
|
|
117
|
-
}
|
|
118
|
-
return obj;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
75
|
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
122
76
|
function getStorage(type) {
|
|
123
77
|
try {
|
|
@@ -133,9 +87,9 @@ var __exports__ = (() => {
|
|
|
133
87
|
var LocalStorage = class {
|
|
134
88
|
constructor(id, defaultConfig) {
|
|
135
89
|
let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
90
|
+
this.storage = void 0;
|
|
91
|
+
this.id = void 0;
|
|
92
|
+
this.config = void 0;
|
|
139
93
|
this.storage = getStorage(type);
|
|
140
94
|
this.id = id;
|
|
141
95
|
this.config = defaultConfig;
|
|
@@ -299,13 +253,13 @@ var __exports__ = (() => {
|
|
|
299
253
|
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
300
254
|
id: ""
|
|
301
255
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
256
|
+
this.id = void 0;
|
|
257
|
+
this.VERSION = VERSION;
|
|
258
|
+
this._startTs = getHiResTimestamp();
|
|
259
|
+
this._deltaTs = getHiResTimestamp();
|
|
260
|
+
this._storage = void 0;
|
|
261
|
+
this.userData = {};
|
|
262
|
+
this.LOG_THROTTLE_TIMEOUT = 0;
|
|
309
263
|
this.id = id;
|
|
310
264
|
this.userData = {};
|
|
311
265
|
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
@@ -503,7 +457,7 @@ var __exports__ = (() => {
|
|
|
503
457
|
return noop;
|
|
504
458
|
}
|
|
505
459
|
};
|
|
506
|
-
|
|
460
|
+
Log.VERSION = VERSION;
|
|
507
461
|
function normalizeLogLevel(logLevel) {
|
|
508
462
|
if (!logLevel) {
|
|
509
463
|
return 0;
|
|
@@ -634,20 +588,20 @@ var __exports__ = (() => {
|
|
|
634
588
|
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
635
589
|
var Stat = class {
|
|
636
590
|
constructor(name, type) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
591
|
+
this.name = void 0;
|
|
592
|
+
this.type = void 0;
|
|
593
|
+
this.sampleSize = 1;
|
|
594
|
+
this.time = 0;
|
|
595
|
+
this.count = 0;
|
|
596
|
+
this.samples = 0;
|
|
597
|
+
this.lastTiming = 0;
|
|
598
|
+
this.lastSampleTime = 0;
|
|
599
|
+
this.lastSampleCount = 0;
|
|
600
|
+
this._count = 0;
|
|
601
|
+
this._time = 0;
|
|
602
|
+
this._samples = 0;
|
|
603
|
+
this._startTime = 0;
|
|
604
|
+
this._timerPending = false;
|
|
651
605
|
this.name = name;
|
|
652
606
|
this.type = type;
|
|
653
607
|
this.reset();
|
|
@@ -746,8 +700,8 @@ var __exports__ = (() => {
|
|
|
746
700
|
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
747
701
|
var Stats = class {
|
|
748
702
|
constructor(options) {
|
|
749
|
-
|
|
750
|
-
|
|
703
|
+
this.id = void 0;
|
|
704
|
+
this.stats = {};
|
|
751
705
|
this.id = options.id;
|
|
752
706
|
this.stats = {};
|
|
753
707
|
this._initializeStats(options.stats);
|
|
@@ -1187,9 +1141,9 @@ var __exports__ = (() => {
|
|
|
1187
1141
|
};
|
|
1188
1142
|
if ((props.usage || 0) & Buffer2.INDEX && !props.indexType) {
|
|
1189
1143
|
if (props.data instanceof Uint32Array) {
|
|
1190
|
-
|
|
1144
|
+
newProps.indexType = "uint32";
|
|
1191
1145
|
} else if (props.data instanceof Uint16Array) {
|
|
1192
|
-
|
|
1146
|
+
newProps.indexType = "uint16";
|
|
1193
1147
|
}
|
|
1194
1148
|
}
|
|
1195
1149
|
return newProps;
|
|
@@ -1835,7 +1789,11 @@ var __exports__ = (() => {
|
|
|
1835
1789
|
constructor(device, props) {
|
|
1836
1790
|
super(device, props, _RenderPass.defaultProps);
|
|
1837
1791
|
}
|
|
1838
|
-
/**
|
|
1792
|
+
/** Call when rendering is done in this pass. */
|
|
1793
|
+
/**
|
|
1794
|
+
* A small set of parameters can be changed between every draw call
|
|
1795
|
+
* (viewport, scissorRect, blendColor, stencilReference)
|
|
1796
|
+
*/
|
|
1839
1797
|
// writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
|
|
1840
1798
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
1841
1799
|
// endOcclusionQuery(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glsllang.js","names":["glslang","loadGlslangModule","glslangModule","default"],"sources":["../../src/glsl/glsllang.ts"],"sourcesContent":["// Inspired by webgpu samples at https://github.com/austinEng/webgpu-samples/blob/master/src/glslang.ts\n// under BSD 3-clause license\n\nlet glslang: unknown;\n\n/** Dynamically load the GLSL compiler */\nexport async function loadGlslangModule() {\n if (!glslang) {\n // @ts-ignore\n const glslangModule = await import(/* webpackIgnore: true */ 'https://unpkg.com/@webgpu/glslang@0.0.15/dist/web-devel/glslang.js');\n glslang = await glslangModule.default();\n }\n return glslang;\n}\n"],"mappings":"AAGA,IAAIA,OAAgB;AAGpB,OAAO,eAAeC,iBAAiBA,CAAA,EAAG;EACxC,IAAI,CAACD,OAAO,EAAE;IAEZ,MAAME,aAAa,GAAG,MAAM,MAAM,CAA2B,oEAAoE,CAAC;IAClIF,OAAO,GAAG,MAAME,aAAa,CAACC,OAAO,
|
|
1
|
+
{"version":3,"file":"glsllang.js","names":["glslang","loadGlslangModule","glslangModule","default"],"sources":["../../src/glsl/glsllang.ts"],"sourcesContent":["// Inspired by webgpu samples at https://github.com/austinEng/webgpu-samples/blob/master/src/glslang.ts\n// under BSD 3-clause license\n\nlet glslang: unknown;\n\n/** Dynamically load the GLSL compiler */\nexport async function loadGlslangModule() {\n if (!glslang) {\n // @ts-ignore\n const glslangModule = await import(/* webpackIgnore: true */ 'https://unpkg.com/@webgpu/glslang@0.0.15/dist/web-devel/glslang.js');\n glslang = await glslangModule.default();\n }\n return glslang;\n}\n"],"mappings":"AAGA,IAAIA,OAAgB;AAGpB,OAAO,eAAeC,iBAAiBA,CAAA,EAAG;EACxC,IAAI,CAACD,OAAO,EAAE;IAEZ,MAAME,aAAa,GAAG,MAAM,MAAM,CAA2B,oEAAoE,CAAC;IAClIF,OAAO,GAAG,MAAME,aAAa,CAACC,OAAO,CAAC,CAAC;EACzC;EACA,OAAOH,OAAO;AAChB"}
|