@luma.gl/webgpu 9.1.5 → 9.1.6

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/dist.min.js CHANGED
@@ -4,10 +4,10 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['luma'] = factory();
6
6
  else root['luma'] = factory();})(globalThis, function () {
7
- var __exports__=(()=>{var Ce=Object.create;var F=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Ge=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Te=(n,e)=>{for(var t in e)F(n,t,{get:e[t],enumerable:!0})},R=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Pe(e))!Ae.call(n,i)&&i!==t&&F(n,i,{get:()=>e[i],enumerable:!(r=Ee(e,i))||r.enumerable});return n},O=(n,e,t)=>(R(n,e,"default"),t&&R(t,e,"default")),d=(n,e,t)=>(t=n!=null?Ce(Be(n)):{},R(e||!n||!n.__esModule?F(t,"default",{value:n,enumerable:!0}):t,n)),Le=n=>R(F({},"__esModule",{value:!0}),n);var h=Ge((Me,re)=>{re.exports=globalThis.luma});var W={};Te(W,{WebGPUBuffer:()=>b,WebGPUDevice:()=>S,WebGPUSampler:()=>c,WebGPUShader:()=>P,WebGPUTexture:()=>E,webgpuAdapter:()=>xe});O(W,d(h(),1));var f=d(h(),1);var I=d(h(),1);var U=d(h(),1);function _e(n){return n.byteLength||n.data?.byteLength||0}var b=class extends U.Buffer{device;handle;byteLength;constructor(e,t){super(e,t),this.device=e,this.byteLength=_e(t);let r=Boolean(t.data),i=Math.ceil(this.byteLength/4)*4;this.handle=this.props.handle||this.device.handle.createBuffer({size:i,usage:this.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:this.props.mappedAtCreation||r,label:this.props.id}),t.data&&this._writeMapped(t.data),r&&!t.mappedAtCreation&&this.handle.unmap()}destroy(){this.handle?.destroy(),this.handle=null}write(e,t=0){this.device.handle.queue.writeBuffer(this.handle,t,e.buffer,e.byteOffset,e.byteLength)}async readAsync(e=0,t=this.byteLength){let r=new b(this.device,{usage:U.Buffer.MAP_READ|U.Buffer.COPY_DST,byteLength:t}),i=this.device.handle.createCommandEncoder();i.copyBufferToBuffer(this.handle,e,r.handle,0,t),this.device.handle.queue.submit([i.finish()]),await r.handle.mapAsync(GPUMapMode.READ,e,t);let s=r.handle.getMappedRange().slice(0);return r.handle.unmap(),r.destroy(),new Uint8Array(s)}_writeMapped(e){let t=this.handle.getMappedRange();new e.constructor(t).set(e)}mapAsync(e,t=0,r){return this.handle.mapAsync(e,t,r)}getMappedRange(e=0,t){return this.handle.getMappedRange(e,t)}unmap(){this.handle.unmap()}};var v=d(h(),1);function C(n){if(n.includes("webgl"))throw new Error("webgl-only format");return n}var ne=d(h(),1),c=class extends ne.Sampler{device;handle;constructor(e,t){super(e,t),this.device=e;let r={...this.props,mipmapFilter:void 0};t.type!=="comparison-sampler"&&delete r.compare,t.mipmapFilter&&t.mipmapFilter!=="none"&&(r.mipmapFilter=t.mipmapFilter),this.handle=this.handle||this.device.handle.createSampler(r),this.handle.label=this.props.id}destroy(){this.handle=null}};var ie=d(h(),1),T=class extends ie.TextureView{device;handle;texture;constructor(e,t){super(e,t),this.device=e,this.texture=t.texture,this.handle=this.handle||this.texture.handle.createView({format:t.format||this.texture.format,dimension:t.dimension||this.texture.dimension,aspect:t.aspect,baseMipLevel:t.baseMipLevel,mipLevelCount:t.mipLevelCount,baseArrayLayer:t.baseArrayLayer,arrayLayerCount:t.arrayLayerCount}),this.handle.label=this.props.id}destroy(){this.handle=null}};var De={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},E=class extends v.Texture{device;handle;sampler;view;constructor(e,t){super(e,t),this.device=e;let r={...this.props};t.data&&(r.data=t.data),this.initialize(r)}destroy(){this.handle?.destroy(),this.handle=null}createView(e){return new T(this.device,{...e,texture:this})}initialize(e){this.handle=this.props.handle||this.createHandle(),this.handle.label||=this.id,this.props.data&&(v.Texture.isExternalImage(this.props.data)?this.copyExternalImage({image:this.props.data}):this.setData({data:this.props.data})),this.width=this.handle.width,this.height=this.handle.height,this.sampler=e.sampler instanceof c?e.sampler:new c(this.device,e.sampler||{}),this.view=new T(this.device,{...this.props,texture:this})}createHandle(){let e=this.props.width||this.props.data?.width||1,t=this.props.height||this.props.data?.height||1;return this.device.handle.createTexture({label:this.id,size:{width:e,height:t,depthOrArrayLayers:this.depth},usage:this.props.usage||v.Texture.TEXTURE|v.Texture.COPY_DST,dimension:De[this.dimension],format:C(this.format),mipLevelCount:this.mipLevels,sampleCount:this.props.samples})}createGPUTextureView(){return this.handle.createView({label:this.id})}setSampler(e){return this.sampler=e instanceof c?e:new c(this.device,e),this}setTexture1DData(e){throw new Error("not implemented")}setTexture2DData(e,t,r){throw new Error("not implemented")}setTexture3DData(e,t,r){throw new Error("not implemented")}setTextureCubeData(e,t){throw new Error("not implemented")}setTextureArrayData(e){throw new Error("not implemented")}setTextureCubeArrayData(e){throw new Error("not implemented")}setData(e){if(ArrayBuffer.isView(e.data)){let t=new Uint8ClampedArray(e.data.buffer),r=new ImageData(t,this.width,this.height);return this.copyExternalImage({image:r})}throw new Error("Texture.setData: Use CommandEncoder to upload data to texture in WebGPU")}copyExternalImage(e){let t=v.Texture.getExternalImageSize(e.image),r={...v.Texture.defaultCopyExternalImageOptions,...t,...e},{image:i,sourceX:s,sourceY:a,width:o,height:p,depth:l,mipLevel:g,x:u,y:G,z:J,aspect:we,colorSpace:ye,premultipliedAlpha:ve,flipY:Se}=r;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[s,a],flipY:Se},{texture:this.handle,origin:[u,G,J],mipLevel:g,aspect:we,colorSpace:ye,premultipliedAlpha:ve},[o,p,l]),{width:o,height:p}}};var se=d(h(),1);var M=class extends se.ExternalTexture{device;handle;sampler;constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.handle.importExternalTexture({source:t.source,colorSpace:t.colorSpace}),this.sampler=null}destroy(){this.handle=null}setSampler(e){return this.sampler=e instanceof c?e:new c(this.device,e),this}};var L=d(h(),1),P=class extends L.Shader{device;handle;constructor(e,t){super(e,t),this.device=e;let r=t.source.includes("#version");if(this.props.language==="glsl"||r)throw new Error("GLSL shaders are not supported in WebGPU");this.device.handle.pushErrorScope("validation"),this.handle=this.props.handle||this.device.handle.createShaderModule({code:t.source}),this.device.handle.popErrorScope().then(i=>{i&&L.log.error(`${this} creation failed:
8
- "${i.message}"`,this,this.props.source)()}),this.handle.label=this.props.id,this._checkCompilationError()}get asyncCompilationStatus(){return this.getCompilationInfo().then(()=>this.compilationStatus)}async _checkCompilationError(){let e=await this.getCompilationInfo(),t=Boolean(e.find(r=>r.type==="error"));this.compilationStatus=t?"error":"success",this.debugShader(),this.compilationStatus==="error"&&L.log.error("Shader compilation error",e)()}destroy(){this.handle=null}async getCompilationInfo(){return(await this.handle.getCompilationInfo()).messages}};var w=d(h(),1);var Z=d(h(),1);function m(n){return n.depthStencil=n.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:!1,depthCompare:"less-equal"},n.depthStencil}function k(n){return m(n).stencilFront}function V(n){return m(n).stencilBack}var Ie={cullMode:(n,e,t)=>{t.primitive=t.primitive||{},t.primitive.cullMode=e},frontFace:(n,e,t)=>{t.primitive=t.primitive||{},t.primitive.frontFace=e},depthWriteEnabled:(n,e,t)=>{let r=m(t);r.depthWriteEnabled=e},depthCompare:(n,e,t)=>{let r=m(t);r.depthCompare=e},depthFormat:(n,e,t)=>{let r=m(t);r.format=e},depthBias:(n,e,t)=>{let r=m(t);r.depthBias=e},depthBiasSlopeScale:(n,e,t)=>{let r=m(t);r.depthBiasSlopeScale=e},depthBiasClamp:(n,e,t)=>{let r=m(t);r.depthBiasClamp=e},stencilReadMask:(n,e,t)=>{let r=m(t);r.stencilReadMask=e},stencilWriteMask:(n,e,t)=>{let r=m(t);r.stencilWriteMask=e},stencilCompare:(n,e,t)=>{let r=k(t),i=V(t);r.compare=e,i.compare=e},stencilPassOperation:(n,e,t)=>{let r=k(t),i=V(t);r.passOp=e,i.passOp=e},stencilFailOperation:(n,e,t)=>{let r=k(t),i=V(t);r.failOp=e,i.failOp=e},stencilDepthFailOperation:(n,e,t)=>{let r=k(t),i=V(t);r.depthFailOp=e,i.depthFailOp=e},sampleCount:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.count=e},sampleMask:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.mask=e},sampleAlphaToCoverageEnabled:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.alphaToCoverageEnabled=e},colorMask:(n,e,t)=>{let r=ae(t);r[0].writeMask=e},blendColorOperation:(n,e,t)=>{ae(t)}},We={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function oe(n,e={}){Object.assign(n,{...We,...n}),Re(n,e)}function Re(n,e){for(let[t,r]of Object.entries(e)){let i=Ie[t];if(!i){Z.log.warn(`Illegal parameter ${t}`)();continue}i(t,r,n)}}function ae(n){return n.fragment.targets=n.fragment?.targets||[],Array.isArray(n.fragment?.targets)||Z.log.warn("parameters: no targets array")(),n.fragment?.targets?.length===0&&n.fragment.targets?.push({}),n.fragment?.targets}var x=d(h(),1);function $(n,e,t,r){let i=Fe(r,t);return n.createBindGroup({layout:e,entries:i})}function he(n,e){let t=n.bindings.find(r=>r.name===e||`${r.name}uniforms`===e.toLocaleLowerCase());return t||x.log.warn(`Binding ${e} not set: Not found in shader layout.`)(),t||null}function Fe(n,e){let t=[];for(let[r,i]of Object.entries(n)){let s=he(e,r);s&&t.push(de(i,s.location)),s=he(e,`${r}Sampler`),s&&t.push(de(i,s.location,{sampler:!0}))}return t}function de(n,e,t){if(n instanceof x.Buffer)return{binding:e,resource:{buffer:n.handle}};if(n instanceof x.Sampler)return{binding:e,resource:n.handle};if(n instanceof x.Texture)return t?.sampler?{binding:e,resource:n.sampler.handle}:{binding:e,resource:n.handle.createView({label:"bind-group-auto-created"})};throw new Error("invalid binding")}var B=d(h(),1);function K(n){if(n.endsWith("-webgl"))throw new Error(`WebGPU does not support vertex format ${n}`);return n}function pe(n,e){let t=[],r=new Set;for(let i of e){let s=[],a="vertex",o=0,p=i.format;if(i.attributes)for(let l of i.attributes){let g=l.attribute,u=le(n,g,r),G=u?.location;p=l.format||i.format,a=u?.stepMode||(u?.name.startsWith("instance")?"instance":"vertex"),s.push({format:K(p),offset:l.byteOffset,shaderLocation:G}),o+=(0,B.decodeVertexFormat)(p).byteLength}else{let l=le(n,i.name,r);if(!l)continue;o=(0,B.decodeVertexFormat)(p).byteLength,a=l.stepMode||(l.name.startsWith("instance")?"instance":"vertex"),s.push({format:K(p),offset:0,shaderLocation:l.location})}t.push({arrayStride:i.byteStride||o,stepMode:a,attributes:s})}for(let i of n.attributes)r.has(i.name)||t.push({arrayStride:(0,B.decodeVertexFormat)("float32x3").byteLength,stepMode:i.stepMode||(i.name.startsWith("instance")?"instance":"vertex"),attributes:[{format:K("float32x3"),offset:0,shaderLocation:i.location}]});return t}function le(n,e,t){let r=n.attributes.find(i=>i.name===e);if(!r)return B.log.warn(`Unknown attribute ${e}`)(),null;if(t.has(e))throw new Error(`Duplicate attribute ${e}`);return t.add(e),r}var q=class extends w.RenderPipeline{device;handle;vs;fs=null;_bindings;_bindGroupLayout=null;_bindGroup=null;constructor(e,t){if(super(e,t),this.device=e,this.handle=this.props.handle,!this.handle){let r=this._getRenderPipelineDescriptor();w.log.groupCollapsed(1,`new WebGPURenderPipeline(${this.id})`)(),w.log.probe(1,JSON.stringify(r,null,2))(),w.log.groupEnd(1)(),this.device.handle.pushErrorScope("validation"),this.handle=this.device.handle.createRenderPipeline(r),this.device.handle.popErrorScope().then(i=>{i&&w.log.error(`${this} creation failed:
9
- "${i.message}"`,this,this.props.vs?.source)()})}this.handle.label=this.props.id,this.vs=t.vs,this.fs=t.fs,this._bindings={...this.props.bindings}}destroy(){this.handle=null}setBindings(e){Object.assign(this._bindings,e)}draw(e){let t=e.renderPass;this.device.handle.pushErrorScope("validation"),t.handle.setPipeline(this.handle),this.device.handle.popErrorScope().then(i=>{i&&w.log.error(`${this} setPipeline failed:
10
- "${i.message}"`,this)()});let r=this._getBindGroup();return r&&t.handle.setBindGroup(0,r),e.vertexArray.bindBeforeRender(e.renderPass),e.indexCount?t.handle.drawIndexed(e.indexCount,e.instanceCount,e.firstIndex,e.baseVertex,e.firstInstance):t.handle.draw(e.vertexCount||0,e.instanceCount||1,e.firstInstance),e.vertexArray.unbindAfterRender(e.renderPass),!0}_getBindGroup(){return this.shaderLayout.bindings.length===0?null:(this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=this._bindGroup||$(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup)}_getRenderPipelineDescriptor(){let e={module:this.props.vs.handle,entryPoint:this.props.vertexEntryPoint||"main",buffers:pe(this.shaderLayout,this.props.bufferLayout)},t={module:this.props.fs.handle,entryPoint:this.props.fragmentEntryPoint||"main",targets:[{format:C(this.device.getCanvasContext().format)}]},r={vertex:e,fragment:t,primitive:{topology:this.props.topology},layout:"auto"};return this.props.parameters.depthWriteEnabled&&this.props.parameters.depthCompare&&(r.depthStencil={format:"depth24plus",depthWriteEnabled:this.props.parameters.depthWriteEnabled,depthCompare:this.props.parameters.depthCompare}),oe(r,this.props.parameters),r}};var ce=d(h(),1),A=class extends ce.Framebuffer{device;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t),this.device=e,this.autoCreateAttachmentTextures()}updateAttachments(){}};var ue=d(h(),1);var z=class extends ue.ComputePipeline{device;handle;_bindGroupLayout=null;_bindGroup=null;_bindings={};constructor(e,t){super(e,t),this.device=e;let r=this.props.shader;this.handle=this.props.handle||this.device.handle.createComputePipeline({label:this.props.id,compute:{module:r.handle,entryPoint:this.props.entryPoint,constants:this.props.constants},layout:"auto"})}setBindings(e){Object.assign(this._bindings,e)}_getBindGroup(){return this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=this._bindGroup||$(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup}};var y=d(h(),1),Q=class extends y.RenderPass{device;handle;pipeline=null;constructor(e,t={}){super(e,t),this.device=e;let r=t.framebuffer||e.getCanvasContext().getCurrentFramebuffer(),i=this.getRenderPassDescriptor(r),s=t.timestampQuerySet;if(s&&(i.occlusionQuerySet=s.handle),e.features.has("timestamp-query")){let a=t.timestampQuerySet;i.timestampWrites=a?{querySet:a.handle,beginningOfPassWriteIndex:t.beginTimestampIndex,endOfPassWriteIndex:t.endTimestampIndex}:void 0}if(!e.commandEncoder)throw new Error("commandEncoder not available");this.device.handle.pushErrorScope("validation"),this.handle=this.props.handle||e.commandEncoder.beginRenderPass(i),this.device.handle.popErrorScope().then(a=>{a&&y.log.error(`${this} creation failed:
11
- "${a.message}"`,this)()}),this.handle.label=this.props.id,y.log.groupCollapsed(3,`new WebGPURenderPass(${this.id})`)(),y.log.probe(3,JSON.stringify(i,null,2))(),y.log.groupEnd(3)()}destroy(){}end(){this.handle.end()}setPipeline(e){this.pipeline=e,this.handle.setPipeline(this.pipeline.handle)}setBindings(e){this.pipeline?.setBindings(e);let t=this.pipeline?._getBindGroup();t&&this.handle.setBindGroup(0,t)}setIndexBuffer(e,t,r=0,i){this.handle.setIndexBuffer(e.handle,t,r,i)}setVertexBuffer(e,t,r=0){this.handle.setVertexBuffer(e,t.handle,r)}draw(e){e.indexCount?this.handle.drawIndexed(e.indexCount,e.instanceCount,e.firstIndex,e.baseVertex,e.firstInstance):this.handle.draw(e.vertexCount||0,e.instanceCount||1,e.firstIndex,e.firstInstance)}drawIndirect(){}setParameters(e){let{blendConstant:t,stencilReference:r,scissorRect:i,viewport:s}=e;t&&this.handle.setBlendConstant(t),r&&this.handle.setStencilReference(r),i&&this.handle.setScissorRect(i[0],i[1],i[2],i[3]),s&&this.handle.setViewport(s[0],s[1],s[2],s[3],s[4],s[5])}pushDebugGroup(e){this.handle.pushDebugGroup(e)}popDebugGroup(){this.handle.popDebugGroup()}insertDebugMarker(e){this.handle.insertDebugMarker(e)}beginOcclusionQuery(e){this.handle.beginOcclusionQuery(e)}endOcclusionQuery(){this.handle.endOcclusionQuery()}getRenderPassDescriptor(e){let t={colorAttachments:[]};if(t.colorAttachments=e.colorAttachments.map((r,i)=>({loadOp:this.props.clearColor!==!1?"clear":"load",clearValue:Oe(this.props.clearColors?.[i]||this.props.clearColor||y.RenderPass.defaultClearColor),storeOp:this.props.discard?"discard":"store",view:r.handle})),e.depthStencilAttachment){t.depthStencilAttachment={view:e.depthStencilAttachment.handle};let{depthStencilAttachment:r}=t;this.props.depthReadOnly&&(r.depthReadOnly=!0),this.props.clearDepth!==!1&&(r.depthClearValue=this.props.clearDepth),!0&&(r.depthLoadOp=this.props.clearDepth!==!1?"clear":"load",r.depthStoreOp="store"),!1&&(r.stencilLoadOp=this.props.clearStencil!==!1?"clear":"load",r.stencilStoreOp="store")}return t}};function Oe(n){return{r:n[0],g:n[1],b:n[2],a:n[3]}}var me=d(h(),1),N=class extends me.ComputePass{device;handle;_webgpuPipeline=null;constructor(e,t){super(e,t),this.device=e;let r;if(e.features.has("timestamp-query")){let i=t.timestampQuerySet;i&&(r={querySet:i.handle,beginningOfPassWriteIndex:t.beginTimestampIndex,endOfPassWriteIndex:t.endTimestampIndex})}this.handle=this.props.handle||e.commandEncoder?.beginComputePass({label:this.props.id,timestampWrites:r})}destroy(){}end(){this.handle.end()}setPipeline(e){let t=e;this.handle.setPipeline(t.handle),this._webgpuPipeline=t,this.setBindings([])}setBindings(e){let t=this._webgpuPipeline._getBindGroup();this.handle.setBindGroup(0,t)}dispatch(e,t,r){this.handle.dispatchWorkgroups(e,t,r)}dispatchIndirect(e,t=0){let r=e;this.handle.dispatchWorkgroupsIndirect(r.handle,t)}pushDebugGroup(e){this.handle.pushDebugGroup(e)}popDebugGroup(){this.handle.popDebugGroup()}insertDebugMarker(e){this.handle.insertDebugMarker(e)}};var _=d(h(),1);var lt=globalThis.document||{},pt=globalThis.process||{},ct=globalThis.console,fe=globalThis.navigator||{};function j(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return Boolean(t&&t.indexOf("Electron")>=0)}function ge(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||j()}function ee(n){return!n&&!ge()?"Node":j(n)?"Electron":(n||fe.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var Y=class extends _.VertexArray{get[Symbol.toStringTag](){return"WebGPUVertexArray"}device;handle;constructor(e,t){super(e,t),this.device=e}destroy(){}setIndexBuffer(e){this.indexBuffer=e}setBuffer(e,t){this.attributes[e]=t}bindBeforeRender(e,t,r){let i=e,s=this.indexBuffer;s?.handle&&(_.log.info(3,"setting index buffer",s?.handle,s?.indexType)(),i.handle.setIndexBuffer(s?.handle,s?.indexType));for(let a=0;a<this.maxVertexAttributes;a++){let o=this.attributes[a];o?.handle&&(_.log.info(3,`setting vertex buffer ${a}`,o?.handle)(),i.handle.setVertexBuffer(a,o?.handle))}}unbindAfterRender(e){}static isConstantAttributeZeroSupported(e){return ee()==="Chrome"}};var H=d(h(),1);var D=class extends H.CanvasContext{device;gpuCanvasContext;format=navigator.gpu.getPreferredCanvasFormat();depthStencilFormat="depth24plus";depthStencilAttachment=null;get[Symbol.toStringTag](){return"WebGPUCanvasContext"}constructor(e,t,r){super(r),this.device=e,this.width=-1,this.height=-1,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.gpuCanvasContext=this.canvas.getContext("webgpu"),this.format="bgra8unorm"}destroy(){this.gpuCanvasContext.unconfigure()}getCurrentFramebuffer(){this.update();let e=this.getCurrentTexture();return this.width=e.width,this.height=e.height,this._createDepthStencilAttachment(),new A(this.device,{colorAttachments:[e],depthStencilAttachment:this.depthStencilAttachment})}update(){let e=this.width,t=this.height,[r,i]=this.getPixelSize();(r!==e||i!==t)&&(this.width=r,this.height=i,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:C(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),H.log.log(1,`${this} Resized ${e}x${t} => ${r}x${i}px`)())}resize(e){if(this.update(),!!this.device.handle&&this.canvas){let t=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(t,e);return}}getCurrentTexture(){return this.device.createTexture({id:`${this.id}#color-texture`,handle:this.gpuCanvasContext.getCurrentTexture(),format:this.format})}_createDepthStencilAttachment(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:`${this.id}#depth-stencil-texture`,format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment}};var be=d(h(),1),X=class extends be.QuerySet{device;handle;constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.handle.createQuerySet({type:this.props.type,count:this.props.count}),this.handle.label=this.props.id}destroy(){this.handle?.destroy(),this.handle=null}};var S=class extends I.Device{type="webgpu";handle;adapter;adapterInfo;features;info;limits;lost;canvasContext=null;_isLost=!1;commandEncoder=null;renderPass=null;constructor(e,t,r,i){super({...e,id:e.id||"webgpu-device"}),this.handle=t,this.adapter=r,this.adapterInfo=i,this.info=this._getInfo(),this.features=this._getFeatures(),this.limits=this.handle.limits,t.addEventListener("uncapturederror",a=>{let o=a instanceof GPUUncapturedErrorEvent?a.error.message:"Unknown WebGPU error";if(this.reportError(new Error(o)),this.props.debug)debugger;a.preventDefault()}),this.lost=new Promise(async a=>{let o=await this.handle.lost;this._isLost=!0,a({reason:"destroyed",message:o.message})});let s=I.Device._getCanvasContextProps(e);s&&(this.canvasContext=new D(this,this.adapter,s))}destroy(){this.handle.destroy()}get isLost(){return this._isLost}createBuffer(e){let t=this._normalizeBufferProps(e);return new b(this,t)}createTexture(e){return new E(this,e)}createExternalTexture(e){return new M(this,e)}createShader(e){return new P(this,e)}createSampler(e){return new c(this,e)}createRenderPipeline(e){return new q(this,e)}createFramebuffer(e){return new A(this,e)}createComputePipeline(e){return new z(this,e)}createVertexArray(e){return new Y(this,e)}beginRenderPass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Q(this,e)}beginComputePass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new N(this,e)}createTransformFeedback(e){throw new Error("Transform feedback not supported in WebGPU")}createQuerySet(e){return new X(this,e)}createCanvasContext(e){return new D(this,this.adapter,e)}submit(){let e=this.commandEncoder?.finish();e&&(this.handle.pushErrorScope("validation"),this.handle.queue.submit([e]),this.handle.popErrorScope().then(t=>{t&&this.reportError(new Error(`WebGPU command submission failed: ${t.message}`))})),this.commandEncoder=null}_getInfo(){let[e,t]=(this.adapterInfo.driver||"").split(" Version "),r=this.adapterInfo.vendor||this.adapter.__brand||"unknown",i=e||"",s=t||"",a=r==="apple"?"apple":"unknown",o=this.adapterInfo.architecture||"unknown",p=this.adapterInfo.backend||"unknown",l=(this.adapterInfo.type||"").split(" ")[0].toLowerCase()||"unknown";return{type:"webgpu",vendor:r,renderer:i,version:s,gpu:a,gpuType:l,gpuBackend:p,gpuArchitecture:o,shadingLanguage:"wgsl",shadingLanguageVersion:100}}_getFeatures(){let e=new Set(this.handle.features);e.has("depth-clamping")&&(e.delete("depth-clamping"),e.add("depth-clip-control")),e.has("texture-compression-bc")&&e.add("texture-compression-bc5-webgl");let t=["timer-query-webgl","compilation-status-async-webgl","float32-renderable-webgl","float16-renderable-webgl","norm16-renderable-webgl","texture-filterable-anisotropic-webgl","shader-noperspective-interpolation-webgl"];for(let r of t)e.add(r);return new I.DeviceFeatures(Array.from(e),this.props._disabledFeatures)}_getDeviceSpecificTextureFormatCapabilities(e){let{format:t}=e;return t.includes("webgl")?{format:t,create:!1,render:!1,filter:!1,blend:!1,store:!1}:e}copyExternalImageToTexture(e){let{source:t,sourceX:r=0,sourceY:i=0,texture:s,mipLevel:a=0,aspect:o="all",colorSpace:p="display-p3",premultipliedAlpha:l=!1,width:g=s.width,height:u=s.height,depth:G=1}=e,J=s;this.handle?.queue.copyExternalImageToTexture({source:t,origin:[r,i]},{texture:J.handle,origin:[0,0,0],mipLevel:a,aspect:o,colorSpace:p,premultipliedAlpha:l},[g,u,G])}};var te=class extends f.Adapter{type="webgpu";constructor(){super(),S.adapter=this}isSupported(){return Boolean(typeof navigator<"u"&&navigator.gpu)}async create(e){if(!navigator.gpu)throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");f.log.groupCollapsed(1,"WebGPUDevice created")();let t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw new Error("Failed to request WebGPU adapter");let r=t.info||await t.requestAdapterInfo?.();f.log.probe(2,"Adapter available",r)();let i=[],s={};if(e._requestMaxLimits){i.push(...Array.from(t.features));let p=Object.keys(t.limits).filter(l=>!["minSubgroupSize","maxSubgroupSize"].includes(l));for(let l of p){let g=l,u=t.limits[g];typeof u=="number"&&(s[g]=u)}}let a=await t.requestDevice({requiredFeatures:i,requiredLimits:s});f.log.probe(1,"GPUDevice available")();let o=new S(e,a,t,r);return f.log.probe(1,"Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")(),f.log.table(1,o.info)(),f.log.groupEnd(1)(),o}async attach(e){throw new Error("WebGPUAdapter.attach() not implemented")}},xe=new te;return Le(W);})();
7
+ var __exports__=(()=>{var Pe=Object.create;var W=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Ge=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Le=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),De=(n,e)=>{for(var t in e)W(n,t,{get:e[t],enumerable:!0})},R=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ae(e))!Te.call(n,i)&&i!==t&&W(n,i,{get:()=>e[i],enumerable:!(r=Be(e,i))||r.enumerable});return n},U=(n,e,t)=>(R(n,e,"default"),t&&R(t,e,"default")),h=(n,e,t)=>(t=n!=null?Pe(Ge(n)):{},R(e||!n||!n.__esModule?W(t,"default",{value:n,enumerable:!0}):t,n)),_e=n=>R(W({},"__esModule",{value:!0}),n);var o=Le((ze,ne)=>{ne.exports=globalThis.luma});var O={};De(O,{WebGPUBuffer:()=>b,WebGPUDevice:()=>S,WebGPUSampler:()=>u,WebGPUShader:()=>P,WebGPUTexture:()=>E,webgpuAdapter:()=>we});U(O,h(o(),1));var f=h(o(),1);var I=h(o(),1);var F=h(o(),1);function Ie(n){return n.byteLength||n.data?.byteLength||0}var b=class extends F.Buffer{device;handle;byteLength;constructor(e,t){super(e,t),this.device=e,this.byteLength=Ie(t);let r=Boolean(t.data),i=Math.ceil(this.byteLength/4)*4;this.handle=this.props.handle||this.device.handle.createBuffer({size:i,usage:this.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:this.props.mappedAtCreation||r,label:this.props.id}),t.data&&this._writeMapped(t.data),r&&!t.mappedAtCreation&&this.handle.unmap()}destroy(){this.handle?.destroy(),this.handle=null}write(e,t=0){this.device.handle.queue.writeBuffer(this.handle,t,e.buffer,e.byteOffset,e.byteLength)}async readAsync(e=0,t=this.byteLength){let r=new b(this.device,{usage:F.Buffer.MAP_READ|F.Buffer.COPY_DST,byteLength:t}),i=this.device.handle.createCommandEncoder();i.copyBufferToBuffer(this.handle,e,r.handle,0,t),this.device.handle.queue.submit([i.finish()]),await r.handle.mapAsync(GPUMapMode.READ,e,t);let s=r.handle.getMappedRange().slice(0);return r.handle.unmap(),r.destroy(),new Uint8Array(s)}_writeMapped(e){let t=this.handle.getMappedRange();new e.constructor(t).set(e)}mapAsync(e,t=0,r){return this.handle.mapAsync(e,t,r)}getMappedRange(e=0,t){return this.handle.getMappedRange(e,t)}unmap(){this.handle.unmap()}};var v=h(o(),1);function C(n){if(n.includes("webgl"))throw new Error("webgl-only format");return n}var ie=h(o(),1),u=class extends ie.Sampler{device;handle;constructor(e,t){super(e,t),this.device=e;let r={...this.props,mipmapFilter:void 0};t.type!=="comparison-sampler"&&delete r.compare,t.mipmapFilter&&t.mipmapFilter!=="none"&&(r.mipmapFilter=t.mipmapFilter),this.handle=this.handle||this.device.handle.createSampler(r),this.handle.label=this.props.id}destroy(){this.handle=null}};var se=h(o(),1),T=class extends se.TextureView{device;handle;texture;constructor(e,t){super(e,t),this.device=e,this.texture=t.texture,this.handle=this.handle||this.texture.handle.createView({format:t.format||this.texture.format,dimension:t.dimension||this.texture.dimension,aspect:t.aspect,baseMipLevel:t.baseMipLevel,mipLevelCount:t.mipLevelCount,baseArrayLayer:t.baseArrayLayer,arrayLayerCount:t.arrayLayerCount}),this.handle.label=this.props.id}destroy(){this.handle=null}};var Oe={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},E=class extends v.Texture{device;handle;sampler;view;constructor(e,t){super(e,t),this.device=e;let r={...this.props};t.data&&(r.data=t.data),this.initialize(r)}destroy(){this.handle?.destroy(),this.handle=null}createView(e){return new T(this.device,{...e,texture:this})}initialize(e){this.handle=this.props.handle||this.createHandle(),this.handle.label||=this.id,this.props.data&&(v.Texture.isExternalImage(this.props.data)?this.copyExternalImage({image:this.props.data}):this.setData({data:this.props.data})),this.width=this.handle.width,this.height=this.handle.height,this.sampler=e.sampler instanceof u?e.sampler:new u(this.device,e.sampler||{}),this.view=new T(this.device,{...this.props,texture:this})}createHandle(){let e=this.props.width||this.props.data?.width||1,t=this.props.height||this.props.data?.height||1;return this.device.handle.createTexture({label:this.id,size:{width:e,height:t,depthOrArrayLayers:this.depth},usage:this.props.usage||v.Texture.TEXTURE|v.Texture.COPY_DST,dimension:Oe[this.dimension],format:C(this.format),mipLevelCount:this.mipLevels,sampleCount:this.props.samples})}createGPUTextureView(){return this.handle.createView({label:this.id})}setSampler(e){return this.sampler=e instanceof u?e:new u(this.device,e),this}setTexture1DData(e){throw new Error("not implemented")}setTexture2DData(e,t,r){throw new Error("not implemented")}setTexture3DData(e,t,r){throw new Error("not implemented")}setTextureCubeData(e,t){throw new Error("not implemented")}setTextureArrayData(e){throw new Error("not implemented")}setTextureCubeArrayData(e){throw new Error("not implemented")}setData(e){if(ArrayBuffer.isView(e.data)){let t=new Uint8ClampedArray(e.data.buffer),r=new ImageData(t,this.width,this.height);return this.copyExternalImage({image:r})}throw new Error("Texture.setData: Use CommandEncoder to upload data to texture in WebGPU")}copyExternalImage(e){let t=v.Texture.getExternalImageSize(e.image),r={...v.Texture.defaultCopyExternalImageOptions,...t,...e},{image:i,sourceX:s,sourceY:a,width:d,height:p,depth:l,mipLevel:g,x:c,y:G,z:Z,aspect:ve,colorSpace:Se,premultipliedAlpha:Ce,flipY:Ee}=r;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[s,a],flipY:Ee},{texture:this.handle,origin:[c,G,Z],mipLevel:g,aspect:ve,colorSpace:Se,premultipliedAlpha:Ce},[d,p,l]),{width:d,height:p}}};var ae=h(o(),1);var M=class extends ae.ExternalTexture{device;handle;sampler;constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.handle.importExternalTexture({source:t.source,colorSpace:t.colorSpace}),this.sampler=null}destroy(){this.handle=null}setSampler(e){return this.sampler=e instanceof u?e:new u(this.device,e),this}};var L=h(o(),1),P=class extends L.Shader{device;handle;constructor(e,t){super(e,t),this.device=e;let r=t.source.includes("#version");if(this.props.language==="glsl"||r)throw new Error("GLSL shaders are not supported in WebGPU");this.device.handle.pushErrorScope("validation"),this.handle=this.props.handle||this.device.handle.createShaderModule({code:t.source}),this.device.handle.popErrorScope().then(i=>{i&&L.log.error(`${this} creation failed:
8
+ "${i.message}"`,this,this.props.source)()}),this.handle.label=this.props.id,this._checkCompilationError()}get asyncCompilationStatus(){return this.getCompilationInfo().then(()=>this.compilationStatus)}async _checkCompilationError(){let e=await this.getCompilationInfo(),t=Boolean(e.find(r=>r.type==="error"));this.compilationStatus=t?"error":"success",this.debugShader(),this.compilationStatus==="error"&&L.log.error("Shader compilation error",e)()}destroy(){this.handle=null}async getCompilationInfo(){return(await this.handle.getCompilationInfo()).messages}};var y=h(o(),1);var K=h(o(),1);function m(n){return n.depthStencil=n.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:!1,depthCompare:"less-equal"},n.depthStencil}function k(n){return m(n).stencilFront}function V(n){return m(n).stencilBack}var Re={cullMode:(n,e,t)=>{t.primitive=t.primitive||{},t.primitive.cullMode=e},frontFace:(n,e,t)=>{t.primitive=t.primitive||{},t.primitive.frontFace=e},depthWriteEnabled:(n,e,t)=>{let r=m(t);r.depthWriteEnabled=e},depthCompare:(n,e,t)=>{let r=m(t);r.depthCompare=e},depthFormat:(n,e,t)=>{let r=m(t);r.format=e},depthBias:(n,e,t)=>{let r=m(t);r.depthBias=e},depthBiasSlopeScale:(n,e,t)=>{let r=m(t);r.depthBiasSlopeScale=e},depthBiasClamp:(n,e,t)=>{let r=m(t);r.depthBiasClamp=e},stencilReadMask:(n,e,t)=>{let r=m(t);r.stencilReadMask=e},stencilWriteMask:(n,e,t)=>{let r=m(t);r.stencilWriteMask=e},stencilCompare:(n,e,t)=>{let r=k(t),i=V(t);r.compare=e,i.compare=e},stencilPassOperation:(n,e,t)=>{let r=k(t),i=V(t);r.passOp=e,i.passOp=e},stencilFailOperation:(n,e,t)=>{let r=k(t),i=V(t);r.failOp=e,i.failOp=e},stencilDepthFailOperation:(n,e,t)=>{let r=k(t),i=V(t);r.depthFailOp=e,i.depthFailOp=e},sampleCount:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.count=e},sampleMask:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.mask=e},sampleAlphaToCoverageEnabled:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.alphaToCoverageEnabled=e},colorMask:(n,e,t)=>{let r=oe(t);r[0].writeMask=e},blendColorOperation:(n,e,t)=>{oe(t)}},We={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function de(n,e={}){Object.assign(n,{...We,...n}),Ue(n,e)}function Ue(n,e){for(let[t,r]of Object.entries(e)){let i=Re[t];if(!i){K.log.warn(`Illegal parameter ${t}`)();continue}i(t,r,n)}}function oe(n){return n.fragment.targets=n.fragment?.targets||[],Array.isArray(n.fragment?.targets)||K.log.warn("parameters: no targets array")(),n.fragment?.targets?.length===0&&n.fragment.targets?.push({}),n.fragment?.targets}var x=h(o(),1);function $(n,e,t,r){let i=Fe(r,t);return n.createBindGroup({layout:e,entries:i})}function he(n,e){let t=n.bindings.find(r=>r.name===e||`${r.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return t||x.log.warn(`Binding ${e} not set: Not found in shader layout.`)(),t||null}function Fe(n,e){let t=[];for(let[r,i]of Object.entries(n)){let s=he(e,r);s&&t.push(le(i,s.location)),s=he(e,`${r}Sampler`),s&&t.push(le(i,s.location,{sampler:!0}))}return t}function le(n,e,t){if(n instanceof x.Buffer)return{binding:e,resource:{buffer:n.handle}};if(n instanceof x.Sampler)return{binding:e,resource:n.handle};if(n instanceof x.Texture)return t?.sampler?{binding:e,resource:n.sampler.handle}:{binding:e,resource:n.handle.createView({label:"bind-group-auto-created"})};throw new Error("invalid binding")}var B=h(o(),1);function ee(n){if(n.endsWith("-webgl"))throw new Error(`WebGPU does not support vertex format ${n}`);return n}function ue(n,e){let t=[],r=new Set;for(let i of e){let s=[],a="vertex",d=0,p=i.format;if(i.attributes)for(let l of i.attributes){let g=l.attribute,c=pe(n,g,r),G=c?.location;p=l.format||i.format,a=c?.stepMode||(c?.name.startsWith("instance")?"instance":"vertex"),s.push({format:ee(p),offset:l.byteOffset,shaderLocation:G}),d+=(0,B.decodeVertexFormat)(p).byteLength}else{let l=pe(n,i.name,r);if(!l)continue;d=(0,B.decodeVertexFormat)(p).byteLength,a=l.stepMode||(l.name.startsWith("instance")?"instance":"vertex"),s.push({format:ee(p),offset:0,shaderLocation:l.location})}t.push({arrayStride:i.byteStride||d,stepMode:a,attributes:s})}for(let i of n.attributes)r.has(i.name)||t.push({arrayStride:(0,B.decodeVertexFormat)("float32x3").byteLength,stepMode:i.stepMode||(i.name.startsWith("instance")?"instance":"vertex"),attributes:[{format:ee("float32x3"),offset:0,shaderLocation:i.location}]});return t}function pe(n,e,t){let r=n.attributes.find(i=>i.name===e);if(!r)return B.log.warn(`Unknown attribute ${e}`)(),null;if(t.has(e))throw new Error(`Duplicate attribute ${e}`);return t.add(e),r}var z=class extends y.RenderPipeline{device;handle;vs;fs=null;_bindings;_bindGroupLayout=null;_bindGroup=null;constructor(e,t){if(super(e,t),this.device=e,this.handle=this.props.handle,!this.handle){let r=this._getRenderPipelineDescriptor();y.log.groupCollapsed(1,`new WebGPURenderPipeline(${this.id})`)(),y.log.probe(1,JSON.stringify(r,null,2))(),y.log.groupEnd(1)(),this.device.handle.pushErrorScope("validation"),this.handle=this.device.handle.createRenderPipeline(r),this.device.handle.popErrorScope().then(i=>{i&&y.log.error(`${this} creation failed:
9
+ "${i.message}"`,this,this.props.vs?.source)()})}this.handle.label=this.props.id,this.vs=t.vs,this.fs=t.fs,this._bindings={...this.props.bindings}}destroy(){this.handle=null}setBindings(e){Object.assign(this._bindings,e)}draw(e){let t=e.renderPass;this.device.handle.pushErrorScope("validation"),t.handle.setPipeline(this.handle),this.device.handle.popErrorScope().then(i=>{i&&y.log.error(`${this} setPipeline failed:
10
+ "${i.message}"`,this)()});let r=this._getBindGroup();return r&&t.handle.setBindGroup(0,r),e.vertexArray.bindBeforeRender(e.renderPass),e.indexCount?t.handle.drawIndexed(e.indexCount,e.instanceCount,e.firstIndex,e.baseVertex,e.firstInstance):t.handle.draw(e.vertexCount||0,e.instanceCount||1,e.firstInstance),e.vertexArray.unbindAfterRender(e.renderPass),!0}_getBindGroup(){return this.shaderLayout.bindings.length===0?null:(this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=this._bindGroup||$(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup)}_getRenderPipelineDescriptor(){let e={module:this.props.vs.handle,entryPoint:this.props.vertexEntryPoint||"main",buffers:ue(this.shaderLayout,this.props.bufferLayout)},t={module:this.props.fs.handle,entryPoint:this.props.fragmentEntryPoint||"main",targets:[{format:C(this.device.getCanvasContext().format)}]},r=this.device.createPipelineLayout({shaderLayout:this.shaderLayout}),i={vertex:e,fragment:t,primitive:{topology:this.props.topology},layout:r.handle};return this.props.parameters.depthWriteEnabled&&this.props.parameters.depthCompare&&(i.depthStencil={format:"depth24plus",depthWriteEnabled:this.props.parameters.depthWriteEnabled,depthCompare:this.props.parameters.depthCompare}),de(i,this.props.parameters),i}};var ce=h(o(),1),A=class extends ce.Framebuffer{device;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t),this.device=e,this.autoCreateAttachmentTextures()}updateAttachments(){}};var me=h(o(),1);var q=class extends me.ComputePipeline{device;handle;_bindGroupLayout=null;_bindGroup=null;_bindings={};constructor(e,t){super(e,t),this.device=e;let r=this.props.shader;this.handle=this.props.handle||this.device.handle.createComputePipeline({label:this.props.id,compute:{module:r.handle,entryPoint:this.props.entryPoint,constants:this.props.constants},layout:"auto"})}setBindings(e){Object.assign(this._bindings,e)}_getBindGroup(){return this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=this._bindGroup||$(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup}};var w=h(o(),1),Q=class extends w.RenderPass{device;handle;pipeline=null;constructor(e,t={}){super(e,t),this.device=e;let r=t.framebuffer||e.getCanvasContext().getCurrentFramebuffer(),i=this.getRenderPassDescriptor(r),s=t.timestampQuerySet;if(s&&(i.occlusionQuerySet=s.handle),e.features.has("timestamp-query")){let a=t.timestampQuerySet;i.timestampWrites=a?{querySet:a.handle,beginningOfPassWriteIndex:t.beginTimestampIndex,endOfPassWriteIndex:t.endTimestampIndex}:void 0}if(!e.commandEncoder)throw new Error("commandEncoder not available");this.device.handle.pushErrorScope("validation"),this.handle=this.props.handle||e.commandEncoder.beginRenderPass(i),this.device.handle.popErrorScope().then(a=>{a&&w.log.error(`${this} creation failed:
11
+ "${a.message}"`,this)()}),this.handle.label=this.props.id,w.log.groupCollapsed(3,`new WebGPURenderPass(${this.id})`)(),w.log.probe(3,JSON.stringify(i,null,2))(),w.log.groupEnd(3)()}destroy(){}end(){this.handle.end()}setPipeline(e){this.pipeline=e,this.handle.setPipeline(this.pipeline.handle)}setBindings(e){this.pipeline?.setBindings(e);let t=this.pipeline?._getBindGroup();t&&this.handle.setBindGroup(0,t)}setIndexBuffer(e,t,r=0,i){this.handle.setIndexBuffer(e.handle,t,r,i)}setVertexBuffer(e,t,r=0){this.handle.setVertexBuffer(e,t.handle,r)}draw(e){e.indexCount?this.handle.drawIndexed(e.indexCount,e.instanceCount,e.firstIndex,e.baseVertex,e.firstInstance):this.handle.draw(e.vertexCount||0,e.instanceCount||1,e.firstIndex,e.firstInstance)}drawIndirect(){}setParameters(e){let{blendConstant:t,stencilReference:r,scissorRect:i,viewport:s}=e;t&&this.handle.setBlendConstant(t),r&&this.handle.setStencilReference(r),i&&this.handle.setScissorRect(i[0],i[1],i[2],i[3]),s&&this.handle.setViewport(s[0],s[1],s[2],s[3],s[4],s[5])}pushDebugGroup(e){this.handle.pushDebugGroup(e)}popDebugGroup(){this.handle.popDebugGroup()}insertDebugMarker(e){this.handle.insertDebugMarker(e)}beginOcclusionQuery(e){this.handle.beginOcclusionQuery(e)}endOcclusionQuery(){this.handle.endOcclusionQuery()}getRenderPassDescriptor(e){let t={colorAttachments:[]};if(t.colorAttachments=e.colorAttachments.map((r,i)=>({loadOp:this.props.clearColor!==!1?"clear":"load",clearValue:Me(this.props.clearColors?.[i]||this.props.clearColor||w.RenderPass.defaultClearColor),storeOp:this.props.discard?"discard":"store",view:r.handle})),e.depthStencilAttachment){t.depthStencilAttachment={view:e.depthStencilAttachment.handle};let{depthStencilAttachment:r}=t;this.props.depthReadOnly&&(r.depthReadOnly=!0),this.props.clearDepth!==!1&&(r.depthClearValue=this.props.clearDepth),!0&&(r.depthLoadOp=this.props.clearDepth!==!1?"clear":"load",r.depthStoreOp="store"),!1&&(r.stencilLoadOp=this.props.clearStencil!==!1?"clear":"load",r.stencilStoreOp="store")}return t}};function Me(n){return{r:n[0],g:n[1],b:n[2],a:n[3]}}var fe=h(o(),1),N=class extends fe.ComputePass{device;handle;_webgpuPipeline=null;constructor(e,t){super(e,t),this.device=e;let r;if(e.features.has("timestamp-query")){let i=t.timestampQuerySet;i&&(r={querySet:i.handle,beginningOfPassWriteIndex:t.beginTimestampIndex,endOfPassWriteIndex:t.endTimestampIndex})}this.handle=this.props.handle||e.commandEncoder?.beginComputePass({label:this.props.id,timestampWrites:r})}destroy(){}end(){this.handle.end()}setPipeline(e){let t=e;this.handle.setPipeline(t.handle),this._webgpuPipeline=t,this.setBindings([])}setBindings(e){let t=this._webgpuPipeline._getBindGroup();this.handle.setBindGroup(0,t)}dispatch(e,t,r){this.handle.dispatchWorkgroups(e,t,r)}dispatchIndirect(e,t=0){let r=e;this.handle.dispatchWorkgroupsIndirect(r.handle,t)}pushDebugGroup(e){this.handle.pushDebugGroup(e)}popDebugGroup(){this.handle.popDebugGroup()}insertDebugMarker(e){this.handle.insertDebugMarker(e)}};var D=h(o(),1);var mt=globalThis.document||{},ft=globalThis.process||{},gt=globalThis.console,ge=globalThis.navigator||{};function j(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return Boolean(t&&t.indexOf("Electron")>=0)}function be(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||j()}function te(n){return!n&&!be()?"Node":j(n)?"Electron":(n||ge.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var Y=class extends D.VertexArray{get[Symbol.toStringTag](){return"WebGPUVertexArray"}device;handle;constructor(e,t){super(e,t),this.device=e}destroy(){}setIndexBuffer(e){this.indexBuffer=e}setBuffer(e,t){this.attributes[e]=t}bindBeforeRender(e,t,r){let i=e,s=this.indexBuffer;s?.handle&&(D.log.info(3,"setting index buffer",s?.handle,s?.indexType)(),i.handle.setIndexBuffer(s?.handle,s?.indexType));for(let a=0;a<this.maxVertexAttributes;a++){let d=this.attributes[a];d?.handle&&(D.log.info(3,`setting vertex buffer ${a}`,d?.handle)(),i.handle.setVertexBuffer(a,d?.handle))}}unbindAfterRender(e){}static isConstantAttributeZeroSupported(e){return te()==="Chrome"}};var X=h(o(),1);var _=class extends X.CanvasContext{device;gpuCanvasContext;format=navigator.gpu.getPreferredCanvasFormat();depthStencilFormat="depth24plus";depthStencilAttachment=null;get[Symbol.toStringTag](){return"WebGPUCanvasContext"}constructor(e,t,r){super(r),this.device=e,this.width=-1,this.height=-1,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.gpuCanvasContext=this.canvas.getContext("webgpu"),this.format="bgra8unorm"}destroy(){this.gpuCanvasContext.unconfigure()}getCurrentFramebuffer(){this.update();let e=this.getCurrentTexture();return this.width=e.width,this.height=e.height,this._createDepthStencilAttachment(),new A(this.device,{colorAttachments:[e],depthStencilAttachment:this.depthStencilAttachment})}update(){let e=this.width,t=this.height,[r,i]=this.getPixelSize();(r!==e||i!==t)&&(this.width=r,this.height=i,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:C(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),X.log.log(1,`${this} Resized ${e}x${t} => ${r}x${i}px`)())}resize(e){if(this.update(),!!this.device.handle&&this.canvas){let t=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(t,e);return}}getCurrentTexture(){return this.device.createTexture({id:`${this.id}#color-texture`,handle:this.gpuCanvasContext.getCurrentTexture(),format:this.format})}_createDepthStencilAttachment(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:`${this.id}#depth-stencil-texture`,format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment}};var xe=h(o(),1),H=class extends xe.QuerySet{device;handle;constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.handle.createQuerySet({type:this.props.type,count:this.props.count}),this.handle.label=this.props.id}destroy(){this.handle?.destroy(),this.handle=null}};var ye=h(o(),1),ke=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,J=class extends ye.PipelineLayout{device;handle;constructor(e,t){super(e,t),this.device=e;let r=this.mapShaderLayoutToBindGroupEntries();this.handle=this.device.handle.createPipelineLayout({label:t?.id??"unnamed-pipeline-layout",bindGroupLayouts:[this.device.handle.createBindGroupLayout({label:"bind-group-layout",entries:r})]})}destroy(){this.handle=null}mapShaderLayoutToBindGroupEntries(){let e=[];for(let t=0;t<this.props.shaderLayout.bindings.length;t++){let r=this.props.shaderLayout.bindings[t],i={};switch(r.type){case"uniform":{i.buffer={type:"uniform",hasDynamicOffset:r.hasDynamicOffset,minBindingSize:r.minBindingSize};break}case"read-only-storage":{i.buffer={type:"read-only-storage",hasDynamicOffset:r.hasDynamicOffset,minBindingSize:r.minBindingSize};break}case"sampler":{i.sampler={type:r.samplerType};break}case"storage":{Ve(r)?i.storageTexture={format:r.format,access:r.access,viewDimension:r.viewDimension}:i.buffer={type:"storage",hasDynamicOffset:r.hasDynamicOffset,minBindingSize:r.minBindingSize};break}case"texture":{i.texture={multisampled:r.multisampled,sampleType:r.sampleType,viewDimension:r.viewDimension};break}default:console.warn("unhandled binding type when creating pipeline descriptor")}e.push({binding:r.location,visibility:r.visibility||ke,...i})}return e}},Ve=n=>n.format!==void 0;var S=class extends I.Device{type="webgpu";handle;adapter;adapterInfo;features;info;limits;lost;canvasContext=null;_isLost=!1;commandEncoder=null;renderPass=null;constructor(e,t,r,i){super({...e,id:e.id||"webgpu-device"}),this.handle=t,this.adapter=r,this.adapterInfo=i,this.info=this._getInfo(),this.features=this._getFeatures(),this.limits=this.handle.limits,t.addEventListener("uncapturederror",a=>{let d=a instanceof GPUUncapturedErrorEvent?a.error.message:"Unknown WebGPU error";if(this.reportError(new Error(d)),this.props.debug)debugger;a.preventDefault()}),this.lost=new Promise(async a=>{let d=await this.handle.lost;this._isLost=!0,a({reason:"destroyed",message:d.message})});let s=I.Device._getCanvasContextProps(e);s&&(this.canvasContext=new _(this,this.adapter,s))}destroy(){this.handle.destroy()}get isLost(){return this._isLost}createBuffer(e){let t=this._normalizeBufferProps(e);return new b(this,t)}createTexture(e){return new E(this,e)}createExternalTexture(e){return new M(this,e)}createShader(e){return new P(this,e)}createSampler(e){return new u(this,e)}createRenderPipeline(e){return new z(this,e)}createFramebuffer(e){return new A(this,e)}createComputePipeline(e){return new q(this,e)}createVertexArray(e){return new Y(this,e)}beginRenderPass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Q(this,e)}beginComputePass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new N(this,e)}createTransformFeedback(e){throw new Error("Transform feedback not supported in WebGPU")}createQuerySet(e){return new H(this,e)}createCanvasContext(e){return new _(this,this.adapter,e)}createPipelineLayout(e){return new J(this,e)}submit(){let e=this.commandEncoder?.finish();e&&(this.handle.pushErrorScope("validation"),this.handle.queue.submit([e]),this.handle.popErrorScope().then(t=>{t&&this.reportError(new Error(`WebGPU command submission failed: ${t.message}`))}))}_getInfo(){let[e,t]=(this.adapterInfo.driver||"").split(" Version "),r=this.adapterInfo.vendor||this.adapter.__brand||"unknown",i=e||"",s=t||"",a=r==="apple"?"apple":"unknown",d=this.adapterInfo.architecture||"unknown",p=this.adapterInfo.backend||"unknown",l=(this.adapterInfo.type||"").split(" ")[0].toLowerCase()||"unknown";return{type:"webgpu",vendor:r,renderer:i,version:s,gpu:a,gpuType:l,gpuBackend:p,gpuArchitecture:d,shadingLanguage:"wgsl",shadingLanguageVersion:100}}_getFeatures(){let e=new Set(this.handle.features);e.has("depth-clamping")&&(e.delete("depth-clamping"),e.add("depth-clip-control")),e.has("texture-compression-bc")&&e.add("texture-compression-bc5-webgl");let t=["timer-query-webgl","compilation-status-async-webgl","float32-renderable-webgl","float16-renderable-webgl","norm16-renderable-webgl","texture-filterable-anisotropic-webgl","shader-noperspective-interpolation-webgl"];for(let r of t)e.add(r);return new I.DeviceFeatures(Array.from(e),this.props._disabledFeatures)}_getDeviceSpecificTextureFormatCapabilities(e){let{format:t}=e;return t.includes("webgl")?{format:t,create:!1,render:!1,filter:!1,blend:!1,store:!1}:e}copyExternalImageToTexture(e){let{source:t,sourceX:r=0,sourceY:i=0,texture:s,mipLevel:a=0,aspect:d="all",colorSpace:p="display-p3",premultipliedAlpha:l=!1,width:g=s.width,height:c=s.height,depth:G=1}=e,Z=s;this.handle?.queue.copyExternalImageToTexture({source:t,origin:[r,i]},{texture:Z.handle,origin:[0,0,0],mipLevel:a,aspect:d,colorSpace:p,premultipliedAlpha:l},[g,c,G])}};var re=class extends f.Adapter{type="webgpu";constructor(){super(),S.adapter=this}isSupported(){return Boolean(typeof navigator<"u"&&navigator.gpu)}async create(e){if(!navigator.gpu)throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");f.log.groupCollapsed(1,"WebGPUDevice created")();let t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw new Error("Failed to request WebGPU adapter");let r=t.info||await t.requestAdapterInfo?.();f.log.probe(2,"Adapter available",r)();let i=[],s={};if(e._requestMaxLimits){i.push(...Array.from(t.features));let p=Object.keys(t.limits).filter(l=>!["minSubgroupSize","maxSubgroupSize"].includes(l));for(let l of p){let g=l,c=t.limits[g];typeof c=="number"&&(s[g]=c)}}let a=await t.requestDevice({requiredFeatures:i,requiredLimits:s});f.log.probe(1,"GPUDevice available")();let d=new S(e,a,t,r);return f.log.probe(1,"Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")(),f.log.table(1,d.info)(),f.log.groupEnd(1)(),d}async attach(e){throw new Error("WebGPUAdapter.attach() not implemented")}},we=new re;return _e(O);})();
12
12
  return __exports__;
13
13
  });
package/dist/index.cjs CHANGED
@@ -29,10 +29,10 @@ __export(dist_exports, {
29
29
  module.exports = __toCommonJS(dist_exports);
30
30
 
31
31
  // dist/adapter/webgpu-adapter.js
32
- var import_core19 = require("@luma.gl/core");
32
+ var import_core20 = require("@luma.gl/core");
33
33
 
34
34
  // dist/adapter/webgpu-device.js
35
- var import_core18 = require("@luma.gl/core");
35
+ var import_core19 = require("@luma.gl/core");
36
36
 
37
37
  // dist/adapter/resources/webgpu-buffer.js
38
38
  var import_core = require("@luma.gl/core");
@@ -580,7 +580,7 @@ function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {
580
580
  });
581
581
  }
582
582
  function getShaderLayoutBinding(shaderLayout, bindingName) {
583
- const bindingLayout = shaderLayout.bindings.find((binding) => binding.name === bindingName || `${binding.name}uniforms` === bindingName.toLocaleLowerCase());
583
+ const bindingLayout = shaderLayout.bindings.find((binding) => binding.name === bindingName || `${binding.name.toLocaleLowerCase()}uniforms` === bindingName.toLocaleLowerCase());
584
584
  if (!bindingLayout) {
585
585
  import_core8.log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
586
586
  }
@@ -810,13 +810,16 @@ var WebGPURenderPipeline = class extends import_core10.RenderPipeline {
810
810
  }
811
811
  ]
812
812
  };
813
+ const layout = this.device.createPipelineLayout({
814
+ shaderLayout: this.shaderLayout
815
+ });
813
816
  const descriptor = {
814
817
  vertex,
815
818
  fragment,
816
819
  primitive: {
817
820
  topology: this.props.topology
818
821
  },
819
- layout: "auto"
822
+ layout: layout.handle
820
823
  };
821
824
  if (this.props.parameters.depthWriteEnabled && this.props.parameters.depthCompare) {
822
825
  descriptor.depthStencil = {
@@ -1289,8 +1292,105 @@ var WebGPUQuerySet = class extends import_core17.QuerySet {
1289
1292
  }
1290
1293
  };
1291
1294
 
1295
+ // dist/adapter/resources/webgpu-pipeline-layout.js
1296
+ var import_core18 = require("@luma.gl/core");
1297
+ var VISIBILITY_ALL = GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE;
1298
+ var WebGPUPipelineLayout = class extends import_core18.PipelineLayout {
1299
+ device;
1300
+ handle;
1301
+ constructor(device, props) {
1302
+ super(device, props);
1303
+ this.device = device;
1304
+ const bindGroupEntries = this.mapShaderLayoutToBindGroupEntries();
1305
+ this.handle = this.device.handle.createPipelineLayout({
1306
+ label: (props == null ? void 0 : props.id) ?? "unnamed-pipeline-layout",
1307
+ bindGroupLayouts: [
1308
+ // TODO (kaapp): We can cache these to re-use them across
1309
+ // layers, particularly if using a separate group for injected
1310
+ // bindings (e.g. project/lighting)
1311
+ this.device.handle.createBindGroupLayout({
1312
+ label: "bind-group-layout",
1313
+ entries: bindGroupEntries
1314
+ })
1315
+ ]
1316
+ });
1317
+ }
1318
+ destroy() {
1319
+ this.handle = null;
1320
+ }
1321
+ mapShaderLayoutToBindGroupEntries() {
1322
+ const bindGroupEntries = [];
1323
+ for (let i = 0; i < this.props.shaderLayout.bindings.length; i++) {
1324
+ const binding = this.props.shaderLayout.bindings[i];
1325
+ const bindingTypeInfo = {};
1326
+ switch (binding.type) {
1327
+ case "uniform": {
1328
+ bindingTypeInfo.buffer = {
1329
+ type: "uniform",
1330
+ hasDynamicOffset: binding.hasDynamicOffset,
1331
+ minBindingSize: binding.minBindingSize
1332
+ };
1333
+ break;
1334
+ }
1335
+ case "read-only-storage": {
1336
+ bindingTypeInfo.buffer = {
1337
+ type: "read-only-storage",
1338
+ hasDynamicOffset: binding.hasDynamicOffset,
1339
+ minBindingSize: binding.minBindingSize
1340
+ };
1341
+ break;
1342
+ }
1343
+ case "sampler": {
1344
+ bindingTypeInfo.sampler = {
1345
+ type: binding.samplerType
1346
+ };
1347
+ break;
1348
+ }
1349
+ case "storage": {
1350
+ if (isStorageTextureBindingLayout(binding)) {
1351
+ bindingTypeInfo.storageTexture = {
1352
+ // TODO (kaapp): Not all formats in the binding layout are supported
1353
+ // by WebGPU, but at least it will provide a clear error for now.
1354
+ format: binding.format,
1355
+ access: binding.access,
1356
+ viewDimension: binding.viewDimension
1357
+ };
1358
+ } else {
1359
+ bindingTypeInfo.buffer = {
1360
+ type: "storage",
1361
+ hasDynamicOffset: binding.hasDynamicOffset,
1362
+ minBindingSize: binding.minBindingSize
1363
+ };
1364
+ }
1365
+ break;
1366
+ }
1367
+ case "texture": {
1368
+ bindingTypeInfo.texture = {
1369
+ multisampled: binding.multisampled,
1370
+ sampleType: binding.sampleType,
1371
+ viewDimension: binding.viewDimension
1372
+ };
1373
+ break;
1374
+ }
1375
+ default: {
1376
+ console.warn("unhandled binding type when creating pipeline descriptor");
1377
+ }
1378
+ }
1379
+ bindGroupEntries.push({
1380
+ binding: binding.location,
1381
+ visibility: binding.visibility || VISIBILITY_ALL,
1382
+ ...bindingTypeInfo
1383
+ });
1384
+ }
1385
+ return bindGroupEntries;
1386
+ }
1387
+ };
1388
+ var isStorageTextureBindingLayout = (maybe) => {
1389
+ return maybe.format !== void 0;
1390
+ };
1391
+
1292
1392
  // dist/adapter/webgpu-device.js
1293
- var WebGPUDevice = class extends import_core18.Device {
1393
+ var WebGPUDevice = class extends import_core19.Device {
1294
1394
  /** type of this device */
1295
1395
  type = "webgpu";
1296
1396
  /** The underlying WebGPU device */
@@ -1328,7 +1428,7 @@ var WebGPUDevice = class extends import_core18.Device {
1328
1428
  this._isLost = true;
1329
1429
  resolve({ reason: "destroyed", message: lostInfo.message });
1330
1430
  });
1331
- const canvasContextProps = import_core18.Device._getCanvasContextProps(props);
1431
+ const canvasContextProps = import_core19.Device._getCanvasContextProps(props);
1332
1432
  if (canvasContextProps) {
1333
1433
  this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
1334
1434
  }
@@ -1396,6 +1496,9 @@ var WebGPUDevice = class extends import_core18.Device {
1396
1496
  createCanvasContext(props) {
1397
1497
  return new WebGPUCanvasContext(this, this.adapter, props);
1398
1498
  }
1499
+ createPipelineLayout(props) {
1500
+ return new WebGPUPipelineLayout(this, props);
1501
+ }
1399
1502
  submit() {
1400
1503
  var _a;
1401
1504
  const commandBuffer = (_a = this.commandEncoder) == null ? void 0 : _a.finish();
@@ -1408,7 +1511,6 @@ var WebGPUDevice = class extends import_core18.Device {
1408
1511
  }
1409
1512
  });
1410
1513
  }
1411
- this.commandEncoder = null;
1412
1514
  }
1413
1515
  // PRIVATE METHODS
1414
1516
  _getInfo() {
@@ -1454,7 +1556,7 @@ var WebGPUDevice = class extends import_core18.Device {
1454
1556
  for (const feature of WEBGPU_ALWAYS_FEATURES) {
1455
1557
  features.add(feature);
1456
1558
  }
1457
- return new import_core18.DeviceFeatures(Array.from(features), this.props._disabledFeatures);
1559
+ return new import_core19.DeviceFeatures(Array.from(features), this.props._disabledFeatures);
1458
1560
  }
1459
1561
  _getDeviceSpecificTextureFormatCapabilities(capabilities) {
1460
1562
  const { format } = capabilities;
@@ -1507,7 +1609,7 @@ var WebGPUDevice = class extends import_core18.Device {
1507
1609
  };
1508
1610
 
1509
1611
  // dist/adapter/webgpu-adapter.js
1510
- var WebGPUAdapter = class extends import_core19.Adapter {
1612
+ var WebGPUAdapter = class extends import_core20.Adapter {
1511
1613
  /** type of device's created by this adapter */
1512
1614
  type = "webgpu";
1513
1615
  constructor() {
@@ -1523,7 +1625,7 @@ var WebGPUAdapter = class extends import_core19.Adapter {
1523
1625
  if (!navigator.gpu) {
1524
1626
  throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");
1525
1627
  }
1526
- import_core19.log.groupCollapsed(1, "WebGPUDevice created")();
1628
+ import_core20.log.groupCollapsed(1, "WebGPUDevice created")();
1527
1629
  const adapter = await navigator.gpu.requestAdapter({
1528
1630
  powerPreference: "high-performance"
1529
1631
  // forceSoftware: false
@@ -1533,7 +1635,7 @@ var WebGPUAdapter = class extends import_core19.Adapter {
1533
1635
  }
1534
1636
  const adapterInfo = adapter.info || // @ts-ignore Chrome has removed this function
1535
1637
  await ((_a = adapter.requestAdapterInfo) == null ? void 0 : _a.call(adapter));
1536
- import_core19.log.probe(2, "Adapter available", adapterInfo)();
1638
+ import_core20.log.probe(2, "Adapter available", adapterInfo)();
1537
1639
  const requiredFeatures = [];
1538
1640
  const requiredLimits = {};
1539
1641
  if (props._requestMaxLimits) {
@@ -1551,11 +1653,11 @@ var WebGPUAdapter = class extends import_core19.Adapter {
1551
1653
  requiredFeatures,
1552
1654
  requiredLimits
1553
1655
  });
1554
- import_core19.log.probe(1, "GPUDevice available")();
1656
+ import_core20.log.probe(1, "GPUDevice available")();
1555
1657
  const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);
1556
- import_core19.log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
1557
- import_core19.log.table(1, device.info)();
1558
- import_core19.log.groupEnd(1)();
1658
+ import_core20.log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
1659
+ import_core20.log.table(1, device.info)();
1660
+ import_core20.log.groupEnd(1)();
1559
1661
  return device;
1560
1662
  }
1561
1663
  async attach(handle) {