@luma.gl/webgpu
Advanced tools
Comparing version 9.1.0-alpha.15 to 9.1.0-alpha.16
@@ -125,3 +125,3 @@ // luma.gl | ||
function findAttributeLayout(shaderLayout, name, attributeNames) { | ||
const attribute = shaderLayout.attributes.find(attribute => attribute.name === name); | ||
const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name); | ||
if (!attribute) { | ||
@@ -128,0 +128,0 @@ log.warn(`Unknown attribute ${name}`)(); |
@@ -14,5 +14,5 @@ import { CommandEncoder, CommandEncoderProps, Buffer, Texture } from '@luma.gl/core'; | ||
copyBufferToBuffer(options: { | ||
source: Buffer; | ||
sourceBuffer: Buffer; | ||
sourceOffset?: number; | ||
destination: Buffer; | ||
destinationBuffer: Buffer; | ||
destinationOffset?: number; | ||
@@ -22,7 +22,7 @@ size?: number; | ||
copyBufferToTexture(options: { | ||
source: Buffer; | ||
sourceBuffer: Buffer; | ||
offset?: number; | ||
bytesPerRow: number; | ||
rowsPerImage: number; | ||
destination: Texture; | ||
destinationTexture: Texture; | ||
mipLevel?: number; | ||
@@ -29,0 +29,0 @@ aspect?: 'all' | 'stencil-only' | 'depth-only'; |
@@ -26,9 +26,9 @@ // luma.gl | ||
copyBufferToBuffer(options) { | ||
const webgpuSourceBuffer = options.source; | ||
const WebGPUDestinationBuffer = options.destination; | ||
const webgpuSourceBuffer = options.sourceBuffer; | ||
const WebGPUDestinationBuffer = options.destinationBuffer; | ||
this.handle.copyBufferToBuffer(webgpuSourceBuffer.handle, options.sourceOffset ?? 0, WebGPUDestinationBuffer.handle, options.destinationOffset ?? 0, options.size ?? 0); | ||
} | ||
copyBufferToTexture(options) { | ||
const webgpuSourceBuffer = options.source; | ||
const WebGPUDestinationTexture = options.destination; | ||
const webgpuSourceBuffer = options.sourceBuffer; | ||
const WebGPUDestinationTexture = options.destinationTexture; | ||
this.handle.copyBufferToTexture({ | ||
@@ -35,0 +35,0 @@ buffer: webgpuSourceBuffer.handle, |
@@ -20,6 +20,6 @@ // luma.gl | ||
if (device.features.has('timestamp-query')) { | ||
const webgpuQuerySet = props.timestampQuerySet; | ||
renderPassDescriptor.timestampWrites = webgpuQuerySet | ||
const webgpuTSQuerySet = props.timestampQuerySet; | ||
renderPassDescriptor.timestampWrites = webgpuTSQuerySet | ||
? { | ||
querySet: webgpuQuerySet.handle, | ||
querySet: webgpuTSQuerySet.handle, | ||
beginningOfPassWriteIndex: props.beginTimestampIndex, | ||
@@ -26,0 +26,0 @@ endOfPassWriteIndex: props.endTimestampIndex |
@@ -11,2 +11,3 @@ import type { ShaderProps, CompilerMessage } from '@luma.gl/core'; | ||
constructor(device: WebGPUDevice, props: ShaderProps); | ||
get asyncCompilationStatus(): Promise<any>; | ||
_checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void>; | ||
@@ -13,0 +14,0 @@ destroy(): void; |
@@ -19,2 +19,5 @@ // luma.gl | ||
} | ||
get asyncCompilationStatus() { | ||
return this.getCompilationInfo().then(() => this.compilationStatus); | ||
} | ||
async _checkCompilationError(errorScope) { | ||
@@ -21,0 +24,0 @@ const error = (await errorScope); |
// luma.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
import { Adapter, CanvasContext, log } from '@luma.gl/core'; | ||
import { Adapter, log } from '@luma.gl/core'; | ||
import { WebGPUDevice } from "./webgpu-device.js"; | ||
@@ -35,3 +35,3 @@ // / <reference types="@webgpu/types" /> | ||
const requiredLimits = {}; | ||
if (props.requestMaxLimits) { | ||
if (props._requestMaxLimits) { | ||
// Require all features | ||
@@ -55,6 +55,2 @@ requiredFeatures.push(...Array.from(adapter.features)); | ||
log.probe(1, 'GPUDevice available')(); | ||
if (typeof props.canvas === 'string') { | ||
await CanvasContext.pageLoaded; | ||
log.probe(1, 'DOM is loaded')(); | ||
} | ||
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo); | ||
@@ -61,0 +57,0 @@ log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')(); |
@@ -1,2 +0,2 @@ | ||
import type { DeviceProps, DeviceInfo, DeviceLimits, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps, TransformFeedback, TransformFeedbackProps, QuerySet, QuerySetProps } from '@luma.gl/core'; | ||
import type { DeviceInfo, DeviceLimits, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps, TransformFeedback, TransformFeedbackProps, QuerySet, QuerySetProps, DeviceProps } from '@luma.gl/core'; | ||
import { Device, DeviceFeatures } from '@luma.gl/core'; | ||
@@ -3,0 +3,0 @@ import { WebGPUBuffer } from "./resources/webgpu-buffer.js"; |
@@ -58,10 +58,6 @@ // luma.gl | ||
// Note: WebGPU devices can be created without a canvas, for compute shader purposes | ||
// if (props.canvas) { | ||
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, { | ||
canvas: props.canvas, | ||
height: props.height, | ||
width: props.width, | ||
container: props.container | ||
}); | ||
// } | ||
if (props.createCanvasContext) { | ||
const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext; | ||
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps); | ||
} | ||
} | ||
@@ -92,3 +88,3 @@ // TODO | ||
createBuffer(props) { | ||
const newProps = this._getBufferProps(props); | ||
const newProps = this._normalizeBufferProps(props); | ||
return new WebGPUBuffer(this, newProps); | ||
@@ -204,3 +200,3 @@ } | ||
} | ||
return new DeviceFeatures(Array.from(features), this.props.disabledFeatures); | ||
return new DeviceFeatures(Array.from(features), this.props._disabledFeatures); | ||
} | ||
@@ -207,0 +203,0 @@ copyExternalImageToTexture(options) { |
@@ -448,2 +448,5 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
} | ||
get asyncCompilationStatus() { | ||
return this.getCompilationInfo().then(() => this.compilationStatus); | ||
} | ||
async _checkCompilationError(errorScope) { | ||
@@ -794,3 +797,3 @@ const error = await errorScope; | ||
function findAttributeLayout(shaderLayout, name, attributeNames) { | ||
const attribute = shaderLayout.attributes.find((attribute2) => attribute2.name === name); | ||
const attribute = shaderLayout.attributes.find((attribute_) => attribute_.name === name); | ||
if (!attribute) { | ||
@@ -983,5 +986,5 @@ import_core8.log.warn(`Unknown attribute ${name}`)(); | ||
if (device.features.has("timestamp-query")) { | ||
const webgpuQuerySet2 = props.timestampQuerySet; | ||
renderPassDescriptor.timestampWrites = webgpuQuerySet2 ? { | ||
querySet: webgpuQuerySet2.handle, | ||
const webgpuTSQuerySet = props.timestampQuerySet; | ||
renderPassDescriptor.timestampWrites = webgpuTSQuerySet ? { | ||
querySet: webgpuTSQuerySet.handle, | ||
beginningOfPassWriteIndex: props.beginTimestampIndex, | ||
@@ -1455,8 +1458,6 @@ endOfPassWriteIndex: props.endTimestampIndex | ||
}); | ||
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, { | ||
canvas: props.canvas, | ||
height: props.height, | ||
width: props.width, | ||
container: props.container | ||
}); | ||
if (props.createCanvasContext) { | ||
const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext; | ||
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps); | ||
} | ||
} | ||
@@ -1485,3 +1486,3 @@ // TODO | ||
createBuffer(props) { | ||
const newProps = this._getBufferProps(props); | ||
const newProps = this._normalizeBufferProps(props); | ||
return new WebGPUBuffer(this, newProps); | ||
@@ -1589,3 +1590,3 @@ } | ||
} | ||
return new import_core17.DeviceFeatures(Array.from(features), this.props.disabledFeatures); | ||
return new import_core17.DeviceFeatures(Array.from(features), this.props._disabledFeatures); | ||
} | ||
@@ -1662,3 +1663,3 @@ copyExternalImageToTexture(options) { | ||
const requiredLimits = {}; | ||
if (props.requestMaxLimits) { | ||
if (props._requestMaxLimits) { | ||
requiredFeatures.push(...Array.from(adapter.features)); | ||
@@ -1681,6 +1682,2 @@ const limits = Object.keys(adapter.limits).filter( | ||
import_core18.log.probe(1, "GPUDevice available")(); | ||
if (typeof props.canvas === "string") { | ||
await import_core18.CanvasContext.pageLoaded; | ||
import_core18.log.probe(1, "DOM is loaded")(); | ||
} | ||
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo); | ||
@@ -1687,0 +1684,0 @@ import_core18.log.probe( |
@@ -7,4 +7,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
else root['luma'] = factory();})(globalThis, function () { | ||
var __exports__=(()=>{var we=Object.create;var R=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Pe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ee=(n,e)=>{for(var t in e)R(n,t,{get:e[t],enumerable:!0})},I=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ve(e))!Ce.call(n,i)&&i!==t&&R(n,i,{get:()=>e[i],enumerable:!(r=ye(e,i))||r.enumerable});return n},O=(n,e,t)=>(I(n,e,"default"),t&&I(t,e,"default")),h=(n,e,t)=>(t=n!=null?we(Se(n)):{},I(e||!n||!n.__esModule?R(t,"default",{value:n,enumerable:!0}):t,n)),Be=n=>I(R({},"__esModule",{value:!0}),n);var o=Pe((Fe,te)=>{te.exports=globalThis.luma});var D={};Ee(D,{WebGPUBuffer:()=>b,WebGPUDevice:()=>y,WebGPUSampler:()=>p,WebGPUShader:()=>C,WebGPUTexture:()=>S,webgpuAdapter:()=>fe});O(D,h(o(),1));var c=h(o(),1);var X=h(o(),1);var F=h(o(),1);function Ae(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=Ae(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 x=h(o(),1);function v(n){if(n.includes("webgl"))throw new Error("webgl-only format");return n}var re=h(o(),1),p=class extends re.Sampler{device;handle;constructor(e,t){super(e,t),this.device=e;let r={...this.props};r.type!=="comparison-sampler"&&delete r.compare,this.handle=this.handle||this.device.handle.createSampler(r),this.handle.label=this.props.id}destroy(){this.handle=null}};var ne=h(o(),1),G=class extends ne.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 Te={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},S=class extends x.Texture{device;handle;height=1;width=1;sampler;view;constructor(e,t){t=x.Texture._fixProps(t),super(e,t),this.device=e,this.initialize(t)}destroy(){this.handle?.destroy(),this.handle=null}createView(e){return new G(this.device,{...e,texture:this})}initialize(e){this.handle=this.props.handle||this.createHandle(),this.handle.label||=this.id,this.props.data&&(x.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 p?e.sampler:new p(this.device,e.sampler||{}),this.view=new G(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||x.Texture.TEXTURE|x.Texture.COPY_DST,dimension:Te[this.dimension],format:v(this.format),mipLevelCount:this.mipLevels,sampleCount:this.props.samples})}createGPUTextureView(){return this.handle.createView({label:this.id})}setSampler(e){return this.sampler=e instanceof p?e:new p(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=x.Texture.getExternalImageSize(e.image),r={...x.Texture.defaultCopyExternalImageOptions,...t,...e},{image:i,sourceX:s,sourceY:a,width:l,height:u,depth:d,mipLevel:g,x:m,y:T,z:J,aspect:ge,colorSpace:be,premultipliedAlpha:xe}=r;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[s,a]},{texture:this.handle,origin:[m,T,J],mipLevel:g,aspect:ge,colorSpace:be,premultipliedAlpha:xe},[l,u,d]),{width:l,height:u}}};var ie=h(o(),1);var M=class extends ie.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 p?e:new p(this.device,e),this}};var W=h(o(),1),C=class extends W.Shader{device;handle;constructor(e,t){super(e,t),this.device=e,this.device.handle.pushErrorScope("validation"),this.handle=this.props.handle||this.createHandle(),this.handle.label=this.props.id,this._checkCompilationError(this.device.handle.popErrorScope())}async _checkCompilationError(e){let t=await e;if(t){this.debugShader();let r=await this.getCompilationInfo();throw W.log.error(`Shader compilation error: ${t.message}`,r)(),new Error(`Shader compilation error: ${t.message}`)}}destroy(){this.handle=null}async getCompilationInfo(){return(await this.handle.getCompilationInfo()).messages}createHandle(){let{source:e}=this.props,t=e.includes("#version");if(this.props.language==="glsl"||t)throw new Error("GLSL shaders are not supported in WebGPU");return this.device.handle.createShaderModule({code:e})}};var E=h(o(),1);function f(n){return n.depthStencil=n.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:!1,depthCompare:"less-equal"},n.depthStencil}function U(n){return f(n).stencilFront}function k(n){return f(n).stencilBack}var Ge={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=f(t);r.depthWriteEnabled=e},depthCompare:(n,e,t)=>{let r=f(t);r.depthCompare=e},depthFormat:(n,e,t)=>{let r=f(t);r.format=e},depthBias:(n,e,t)=>{let r=f(t);r.depthBias=e},depthBiasSlopeScale:(n,e,t)=>{let r=f(t);r.depthBiasSlopeScale=e},depthBiasClamp:(n,e,t)=>{let r=f(t);r.depthBiasClamp=e},stencilReadMask:(n,e,t)=>{let r=f(t);r.stencilReadMask=e},stencilWriteMask:(n,e,t)=>{let r=f(t);r.stencilWriteMask=e},stencilCompare:(n,e,t)=>{let r=U(t),i=k(t);r.compare=e,i.compare=e},stencilPassOperation:(n,e,t)=>{let r=U(t),i=k(t);r.passOp=e,i.passOp=e},stencilFailOperation:(n,e,t)=>{let r=U(t),i=k(t);r.failOp=e,i.failOp=e},stencilDepthFailOperation:(n,e,t)=>{let r=U(t),i=k(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=se(t);r[0].writeMask=e},blendColorOperation:(n,e,t)=>{se(t)}},Le={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function ae(n,e={}){Object.assign(n,{...Le,...n}),_e(n,e)}function _e(n,e){for(let[t,r]of Object.entries(e)){let i=Ge[t];if(!i)throw new Error(`Illegal parameter ${t}`);i(t,r,n)}}function se(n){if(n.fragment.targets=n.fragment?.targets||[],!Array.isArray(n.fragment?.targets))throw new Error("colorstate");return n.fragment?.targets?.length===0&&n.fragment.targets?.push({}),n.fragment?.targets}var w=h(o(),1);function V(n,e,t,r){let i=Ie(r,t);return n.createBindGroup({layout:e,entries:i})}function De(n,e){let t=n.bindings.find(r=>r.name===e||`${r.name}uniforms`===e.toLocaleLowerCase());return t||w.log.warn(`Binding ${e} not set: Not found in shader layout.`)(),t||null}function Ie(n,e){let t=[];for(let[r,i]of Object.entries(n)){let s=De(e,r);s&&t.push(Re(i,s.location))}return t}function Re(n,e){if(n instanceof w.Buffer)return{binding:e,resource:{buffer:n.handle}};if(n instanceof w.Sampler)return{binding:e,resource:n.handle};if(n instanceof w.Texture)return{binding:e,resource:n.handle.createView({label:"bind-group-auto-created"})};throw new Error("invalid binding")}var P=h(o(),1);function Z(n){if(n.endsWith("-webgl"))throw new Error(`WebGPU does not support vertex format ${n}`);return n}function he(n,e){let t=[],r=new Set;for(let i of e){let s=[],a="vertex",l=0,u=i.format;if(i.attributes)for(let d of i.attributes){let g=d.attribute,m=oe(n,g,r),T=m?.location;a=m?.stepMode||(m?.name.startsWith("instance")?"instance":"vertex"),s.push({format:Z(d.format||i.format),offset:d.byteOffset,shaderLocation:T}),l+=(0,P.decodeVertexFormat)(u).byteLength}else{let d=oe(n,i.name,r);if(!d)continue;l=(0,P.decodeVertexFormat)(u).byteLength,a=d.stepMode||(d.name.startsWith("instance")?"instance":"vertex"),s.push({format:Z(u),offset:0,shaderLocation:d.location})}t.push({arrayStride:i.byteStride||l,stepMode:a,attributes:s})}for(let i of n.attributes)r.has(i.name)||t.push({arrayStride:(0,P.decodeVertexFormat)("float32x3").byteLength,stepMode:i.stepMode||(i.name.startsWith("instance")?"instance":"vertex"),attributes:[{format:Z("float32x3"),offset:0,shaderLocation:i.location}]});return t}function oe(n,e,t){let r=n.attributes.find(i=>i.name===e);if(!r)return P.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 E.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();E.log.groupCollapsed(1,`new WebGPURenderPipeline(${this.id})`)(),E.log.probe(1,JSON.stringify(r,null,2))(),E.log.groupEnd(1)(),this.handle=this.device.handle.createRenderPipeline(r)}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;t.handle.setPipeline(this.handle);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||V(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:he(this.shaderLayout,this.props.bufferLayout)},t={module:this.props.fs.handle,entryPoint:this.props.fragmentEntryPoint||"main",targets:[{format:v(this.device.getCanvasContext().format)}]},r={vertex:e,fragment:t,primitive:{topology:this.props.topology},layout:"auto"};return ae(r,this.props.parameters),r}};var de=h(o(),1),B=class extends de.Framebuffer{device;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t),this.device=e,this.autoCreateAttachmentTextures()}updateAttachments(){}};var le=h(o(),1);var $=class extends le.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||V(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup}};var A=h(o(),1),z=class extends A.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.handle=this.props.handle||e.commandEncoder.beginRenderPass(i),this.handle.label=this.props.id,A.log.groupCollapsed(3,`new WebGPURenderPass(${this.id})`)(),A.log.probe(3,JSON.stringify(i,null,2))(),A.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=>({loadOp:this.props.clearColor!==!1?"clear":"load",colorClearValue:this.props.clearColor||[0,0,0,0],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),r.depthClearValue=this.props.clearDepth||0,!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}};var pe=h(o(),1),Q=class extends pe.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 L=h(o(),1);var ot=globalThis.document||{},ht=globalThis.process||{},dt=globalThis.console,ue=globalThis.navigator||{};function N(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 ce(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||N()}function K(n){return!n&&!ce()?"Node":N(n)?"Electron":(n||ue.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var j=class extends L.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&&(L.log.warn("setting index buffer",s?.handle,s?.indexType)(),i.handle.setIndexBuffer(s?.handle,s?.indexType));for(let a=0;a<this.maxVertexAttributes;a++){let l=this.attributes[a];l?.handle&&(L.log.warn(`setting vertex buffer ${a}`,l?.handle)(),i.handle.setVertexBuffer(a,l?.handle))}}unbindAfterRender(e){}static isConstantAttributeZeroSupported(e){return K()==="Chrome"}};var Y=h(o(),1);var _=class extends Y.CanvasContext{device;gpuCanvasContext;format=navigator.gpu.getPreferredCanvasFormat();depthStencilFormat="depth24plus";depthStencilAttachment=null;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 B(this.device,{colorAttachments:[e],depthStencilAttachment:this.depthStencilAttachment})}update(){let[e,t]=this.getPixelSize();(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:v(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),Y.log.log(1,`Resized to ${this.width}x${this.height}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 me=h(o(),1),H=class extends me.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 y=class extends X.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",s=>{let a=s instanceof GPUUncapturedErrorEvent?s.error.message:"Unknown error";this.error(new Error(a))}),this.lost=new Promise(async s=>{let a=await this.handle.lost;this._isLost=!0,s({reason:"destroyed",message:a.message})}),this.canvasContext=new _(this,this.adapter,{canvas:e.canvas,height:e.height,width:e.width,container:e.container})}destroy(){this.handle.destroy()}isTextureFormatSupported(e){return!e.includes("webgl")}isTextureFormatFilterable(e){return this.isTextureFormatSupported(e)&&!e.startsWith("depth")&&!e.startsWith("stencil")}isTextureFormatRenderable(e){return this.isTextureFormatSupported(e)}get isLost(){return this._isLost}createBuffer(e){let t=this._getBufferProps(e);return new b(this,t)}createTexture(e){return new S(this,e)}createExternalTexture(e){return new M(this,e)}createShader(e){return new C(this,e)}createSampler(e){return new p(this,e)}createRenderPipeline(e){return new q(this,e)}createFramebuffer(e){return new B(this,e)}createComputePipeline(e){return new $(this,e)}createVertexArray(e){return new j(this,e)}beginRenderPass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new z(this,e)}beginComputePass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Q(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)}submit(){let e=this.commandEncoder?.finish();e&&this.handle.queue.submit([e]),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",l=this.adapterInfo.architecture||"unknown",u=this.adapterInfo.backend||"unknown",d=(this.adapterInfo.type||"").split(" ")[0].toLowerCase()||"unknown";return{type:"webgpu",vendor:r,renderer:i,version:s,gpu:a,gpuType:d,gpuBackend:u,gpuArchitecture:l,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 X.DeviceFeatures(Array.from(e),this.props.disabledFeatures)}copyExternalImageToTexture(e){let{source:t,sourceX:r=0,sourceY:i=0,texture:s,mipLevel:a=0,aspect:l="all",colorSpace:u="display-p3",premultipliedAlpha:d=!1,width:g=s.width,height:m=s.height,depth:T=1}=e,J=s;this.handle?.queue.copyExternalImageToTexture({source:t,origin:[r,i]},{texture:J.handle,origin:[0,0,0],mipLevel:a,aspect:l,colorSpace:u,premultipliedAlpha:d},[g,m,T])}};var ee=class extends c.Adapter{type="webgpu";constructor(){super(),y.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");c.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=await t.requestAdapterInfo();c.log.probe(2,"Adapter available",r)();let i=[],s={};if(e.requestMaxLimits){i.push(...Array.from(t.features));let u=Object.keys(t.limits).filter(d=>!["minSubgroupSize","maxSubgroupSize"].includes(d));for(let d of u){let g=d,m=t.limits[g];typeof m=="number"&&(s[g]=m)}}let a=await t.requestDevice({requiredFeatures:i,requiredLimits:s});c.log.probe(1,"GPUDevice available")(),typeof e.canvas=="string"&&(await c.CanvasContext.pageLoaded,c.log.probe(1,"DOM is loaded")());let l=new y(e,a,t,r);return c.log.probe(1,"Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")(),c.log.table(1,l.info)(),c.log.groupEnd(1)(),l}async attach(e){throw new Error("WebGPUAdapter.attach() not implemented")}},fe=new ee;return Be(D);})(); | ||
var __exports__=(()=>{var we=Object.create;var R=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Pe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ee=(n,e)=>{for(var t in e)R(n,t,{get:e[t],enumerable:!0})},I=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ve(e))!Ce.call(n,i)&&i!==t&&R(n,i,{get:()=>e[i],enumerable:!(r=ye(e,i))||r.enumerable});return n},F=(n,e,t)=>(I(n,e,"default"),t&&I(t,e,"default")),h=(n,e,t)=>(t=n!=null?we(Se(n)):{},I(e||!n||!n.__esModule?R(t,"default",{value:n,enumerable:!0}):t,n)),Be=n=>I(R({},"__esModule",{value:!0}),n);var o=Pe((Oe,te)=>{te.exports=globalThis.luma});var D={};Ee(D,{WebGPUBuffer:()=>b,WebGPUDevice:()=>y,WebGPUSampler:()=>p,WebGPUShader:()=>C,WebGPUTexture:()=>S,webgpuAdapter:()=>fe});F(D,h(o(),1));var f=h(o(),1);var X=h(o(),1);var O=h(o(),1);function Ae(n){return n.byteLength||n.data?.byteLength||0}var b=class extends O.Buffer{device;handle;byteLength;constructor(e,t){super(e,t),this.device=e,this.byteLength=Ae(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:O.Buffer.MAP_READ|O.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 x=h(o(),1);function v(n){if(n.includes("webgl"))throw new Error("webgl-only format");return n}var re=h(o(),1),p=class extends re.Sampler{device;handle;constructor(e,t){super(e,t),this.device=e;let r={...this.props};r.type!=="comparison-sampler"&&delete r.compare,this.handle=this.handle||this.device.handle.createSampler(r),this.handle.label=this.props.id}destroy(){this.handle=null}};var ne=h(o(),1),G=class extends ne.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 Te={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},S=class extends x.Texture{device;handle;height=1;width=1;sampler;view;constructor(e,t){t=x.Texture._fixProps(t),super(e,t),this.device=e,this.initialize(t)}destroy(){this.handle?.destroy(),this.handle=null}createView(e){return new G(this.device,{...e,texture:this})}initialize(e){this.handle=this.props.handle||this.createHandle(),this.handle.label||=this.id,this.props.data&&(x.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 p?e.sampler:new p(this.device,e.sampler||{}),this.view=new G(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||x.Texture.TEXTURE|x.Texture.COPY_DST,dimension:Te[this.dimension],format:v(this.format),mipLevelCount:this.mipLevels,sampleCount:this.props.samples})}createGPUTextureView(){return this.handle.createView({label:this.id})}setSampler(e){return this.sampler=e instanceof p?e:new p(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=x.Texture.getExternalImageSize(e.image),r={...x.Texture.defaultCopyExternalImageOptions,...t,...e},{image:i,sourceX:s,sourceY:a,width:l,height:u,depth:d,mipLevel:g,x:c,y:T,z:J,aspect:ge,colorSpace:be,premultipliedAlpha:xe}=r;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[s,a]},{texture:this.handle,origin:[c,T,J],mipLevel:g,aspect:ge,colorSpace:be,premultipliedAlpha:xe},[l,u,d]),{width:l,height:u}}};var ie=h(o(),1);var W=class extends ie.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 p?e:new p(this.device,e),this}};var M=h(o(),1),C=class extends M.Shader{device;handle;constructor(e,t){super(e,t),this.device=e,this.device.handle.pushErrorScope("validation"),this.handle=this.props.handle||this.createHandle(),this.handle.label=this.props.id,this._checkCompilationError(this.device.handle.popErrorScope())}get asyncCompilationStatus(){return this.getCompilationInfo().then(()=>this.compilationStatus)}async _checkCompilationError(e){let t=await e;if(t){this.debugShader();let r=await this.getCompilationInfo();throw M.log.error(`Shader compilation error: ${t.message}`,r)(),new Error(`Shader compilation error: ${t.message}`)}}destroy(){this.handle=null}async getCompilationInfo(){return(await this.handle.getCompilationInfo()).messages}createHandle(){let{source:e}=this.props,t=e.includes("#version");if(this.props.language==="glsl"||t)throw new Error("GLSL shaders are not supported in WebGPU");return this.device.handle.createShaderModule({code:e})}};var E=h(o(),1);function m(n){return n.depthStencil=n.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:!1,depthCompare:"less-equal"},n.depthStencil}function U(n){return m(n).stencilFront}function k(n){return m(n).stencilBack}var Ge={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=U(t),i=k(t);r.compare=e,i.compare=e},stencilPassOperation:(n,e,t)=>{let r=U(t),i=k(t);r.passOp=e,i.passOp=e},stencilFailOperation:(n,e,t)=>{let r=U(t),i=k(t);r.failOp=e,i.failOp=e},stencilDepthFailOperation:(n,e,t)=>{let r=U(t),i=k(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=se(t);r[0].writeMask=e},blendColorOperation:(n,e,t)=>{se(t)}},Le={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function ae(n,e={}){Object.assign(n,{...Le,...n}),_e(n,e)}function _e(n,e){for(let[t,r]of Object.entries(e)){let i=Ge[t];if(!i)throw new Error(`Illegal parameter ${t}`);i(t,r,n)}}function se(n){if(n.fragment.targets=n.fragment?.targets||[],!Array.isArray(n.fragment?.targets))throw new Error("colorstate");return n.fragment?.targets?.length===0&&n.fragment.targets?.push({}),n.fragment?.targets}var w=h(o(),1);function V(n,e,t,r){let i=Ie(r,t);return n.createBindGroup({layout:e,entries:i})}function De(n,e){let t=n.bindings.find(r=>r.name===e||`${r.name}uniforms`===e.toLocaleLowerCase());return t||w.log.warn(`Binding ${e} not set: Not found in shader layout.`)(),t||null}function Ie(n,e){let t=[];for(let[r,i]of Object.entries(n)){let s=De(e,r);s&&t.push(Re(i,s.location))}return t}function Re(n,e){if(n instanceof w.Buffer)return{binding:e,resource:{buffer:n.handle}};if(n instanceof w.Sampler)return{binding:e,resource:n.handle};if(n instanceof w.Texture)return{binding:e,resource:n.handle.createView({label:"bind-group-auto-created"})};throw new Error("invalid binding")}var P=h(o(),1);function Z(n){if(n.endsWith("-webgl"))throw new Error(`WebGPU does not support vertex format ${n}`);return n}function he(n,e){let t=[],r=new Set;for(let i of e){let s=[],a="vertex",l=0,u=i.format;if(i.attributes)for(let d of i.attributes){let g=d.attribute,c=oe(n,g,r),T=c?.location;a=c?.stepMode||(c?.name.startsWith("instance")?"instance":"vertex"),s.push({format:Z(d.format||i.format),offset:d.byteOffset,shaderLocation:T}),l+=(0,P.decodeVertexFormat)(u).byteLength}else{let d=oe(n,i.name,r);if(!d)continue;l=(0,P.decodeVertexFormat)(u).byteLength,a=d.stepMode||(d.name.startsWith("instance")?"instance":"vertex"),s.push({format:Z(u),offset:0,shaderLocation:d.location})}t.push({arrayStride:i.byteStride||l,stepMode:a,attributes:s})}for(let i of n.attributes)r.has(i.name)||t.push({arrayStride:(0,P.decodeVertexFormat)("float32x3").byteLength,stepMode:i.stepMode||(i.name.startsWith("instance")?"instance":"vertex"),attributes:[{format:Z("float32x3"),offset:0,shaderLocation:i.location}]});return t}function oe(n,e,t){let r=n.attributes.find(i=>i.name===e);if(!r)return P.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 E.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();E.log.groupCollapsed(1,`new WebGPURenderPipeline(${this.id})`)(),E.log.probe(1,JSON.stringify(r,null,2))(),E.log.groupEnd(1)(),this.handle=this.device.handle.createRenderPipeline(r)}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;t.handle.setPipeline(this.handle);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||V(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:he(this.shaderLayout,this.props.bufferLayout)},t={module:this.props.fs.handle,entryPoint:this.props.fragmentEntryPoint||"main",targets:[{format:v(this.device.getCanvasContext().format)}]},r={vertex:e,fragment:t,primitive:{topology:this.props.topology},layout:"auto"};return ae(r,this.props.parameters),r}};var de=h(o(),1),B=class extends de.Framebuffer{device;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t),this.device=e,this.autoCreateAttachmentTextures()}updateAttachments(){}};var le=h(o(),1);var z=class extends le.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||V(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup}};var A=h(o(),1),$=class extends A.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.handle=this.props.handle||e.commandEncoder.beginRenderPass(i),this.handle.label=this.props.id,A.log.groupCollapsed(3,`new WebGPURenderPass(${this.id})`)(),A.log.probe(3,JSON.stringify(i,null,2))(),A.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=>({loadOp:this.props.clearColor!==!1?"clear":"load",colorClearValue:this.props.clearColor||[0,0,0,0],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),r.depthClearValue=this.props.clearDepth||0,!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}};var pe=h(o(),1),Q=class extends pe.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 L=h(o(),1);var ot=globalThis.document||{},ht=globalThis.process||{},dt=globalThis.console,ue=globalThis.navigator||{};function N(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 ce(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||N()}function K(n){return!n&&!ce()?"Node":N(n)?"Electron":(n||ue.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var j=class extends L.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&&(L.log.warn("setting index buffer",s?.handle,s?.indexType)(),i.handle.setIndexBuffer(s?.handle,s?.indexType));for(let a=0;a<this.maxVertexAttributes;a++){let l=this.attributes[a];l?.handle&&(L.log.warn(`setting vertex buffer ${a}`,l?.handle)(),i.handle.setVertexBuffer(a,l?.handle))}}unbindAfterRender(e){}static isConstantAttributeZeroSupported(e){return K()==="Chrome"}};var Y=h(o(),1);var _=class extends Y.CanvasContext{device;gpuCanvasContext;format=navigator.gpu.getPreferredCanvasFormat();depthStencilFormat="depth24plus";depthStencilAttachment=null;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 B(this.device,{colorAttachments:[e],depthStencilAttachment:this.depthStencilAttachment})}update(){let[e,t]=this.getPixelSize();(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:v(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),Y.log.log(1,`Resized to ${this.width}x${this.height}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 me=h(o(),1),H=class extends me.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 y=class extends X.Device{type="webgpu";handle;adapter;adapterInfo;features;info;limits;lost;canvasContext=null;_isLost=!1;commandEncoder=null;renderPass=null;constructor(e,t,r,i){if(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",s=>{let a=s instanceof GPUUncapturedErrorEvent?s.error.message:"Unknown error";this.error(new Error(a))}),this.lost=new Promise(async s=>{let a=await this.handle.lost;this._isLost=!0,s({reason:"destroyed",message:a.message})}),e.createCanvasContext){let s=e.createCanvasContext===!0?{}:e.createCanvasContext;this.canvasContext=new _(this,this.adapter,s)}}destroy(){this.handle.destroy()}isTextureFormatSupported(e){return!e.includes("webgl")}isTextureFormatFilterable(e){return this.isTextureFormatSupported(e)&&!e.startsWith("depth")&&!e.startsWith("stencil")}isTextureFormatRenderable(e){return this.isTextureFormatSupported(e)}get isLost(){return this._isLost}createBuffer(e){let t=this._normalizeBufferProps(e);return new b(this,t)}createTexture(e){return new S(this,e)}createExternalTexture(e){return new W(this,e)}createShader(e){return new C(this,e)}createSampler(e){return new p(this,e)}createRenderPipeline(e){return new q(this,e)}createFramebuffer(e){return new B(this,e)}createComputePipeline(e){return new z(this,e)}createVertexArray(e){return new j(this,e)}beginRenderPass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new $(this,e)}beginComputePass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Q(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)}submit(){let e=this.commandEncoder?.finish();e&&this.handle.queue.submit([e]),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",l=this.adapterInfo.architecture||"unknown",u=this.adapterInfo.backend||"unknown",d=(this.adapterInfo.type||"").split(" ")[0].toLowerCase()||"unknown";return{type:"webgpu",vendor:r,renderer:i,version:s,gpu:a,gpuType:d,gpuBackend:u,gpuArchitecture:l,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 X.DeviceFeatures(Array.from(e),this.props._disabledFeatures)}copyExternalImageToTexture(e){let{source:t,sourceX:r=0,sourceY:i=0,texture:s,mipLevel:a=0,aspect:l="all",colorSpace:u="display-p3",premultipliedAlpha:d=!1,width:g=s.width,height:c=s.height,depth:T=1}=e,J=s;this.handle?.queue.copyExternalImageToTexture({source:t,origin:[r,i]},{texture:J.handle,origin:[0,0,0],mipLevel:a,aspect:l,colorSpace:u,premultipliedAlpha:d},[g,c,T])}};var ee=class extends f.Adapter{type="webgpu";constructor(){super(),y.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=await t.requestAdapterInfo();f.log.probe(2,"Adapter available",r)();let i=[],s={};if(e._requestMaxLimits){i.push(...Array.from(t.features));let u=Object.keys(t.limits).filter(d=>!["minSubgroupSize","maxSubgroupSize"].includes(d));for(let d of u){let g=d,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 l=new y(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,l.info)(),f.log.groupEnd(1)(),l}async attach(e){throw new Error("WebGPUAdapter.attach() not implemented")}},fe=new ee;return Be(D);})(); | ||
return __exports__; | ||
}); |
{ | ||
"name": "@luma.gl/webgpu", | ||
"version": "9.1.0-alpha.15", | ||
"version": "9.1.0-alpha.16", | ||
"description": "WebGPU adapter for the luma.gl core API", | ||
@@ -46,3 +46,3 @@ "type": "module", | ||
}, | ||
"gitHead": "41af576ca655cb749a5567cf903f9e9242793c77" | ||
"gitHead": "39eec40d12c826548b636c057fdb8572adfe611f" | ||
} |
@@ -153,3 +153,3 @@ // luma.gl | ||
): AttributeDeclaration | null { | ||
const attribute = shaderLayout.attributes.find(attribute => attribute.name === name); | ||
const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name); | ||
if (!attribute) { | ||
@@ -156,0 +156,0 @@ log.warn(`Unknown attribute ${name}`)(); |
@@ -39,10 +39,10 @@ // luma.gl | ||
{ | ||
source: Buffer; | ||
sourceBuffer: Buffer; | ||
sourceOffset?: number; | ||
destination: Buffer; | ||
destinationBuffer: Buffer; | ||
destinationOffset?: number; | ||
size?: number; | ||
}): void { | ||
const webgpuSourceBuffer = options.source as WebGPUBuffer; | ||
const WebGPUDestinationBuffer = options.destination as WebGPUBuffer; | ||
const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer; | ||
const WebGPUDestinationBuffer = options.destinationBuffer as WebGPUBuffer; | ||
this.handle.copyBufferToBuffer( | ||
@@ -59,3 +59,3 @@ webgpuSourceBuffer.handle, | ||
{ | ||
source: Buffer; | ||
sourceBuffer: Buffer; | ||
offset?: number; | ||
@@ -65,3 +65,3 @@ bytesPerRow: number; | ||
destination: Texture; | ||
destinationTexture: Texture; | ||
mipLevel?: number; | ||
@@ -73,4 +73,4 @@ aspect?: 'all' | 'stencil-only' | 'depth-only'; | ||
}): void { | ||
const webgpuSourceBuffer = options.source as WebGPUBuffer; | ||
const WebGPUDestinationTexture = options.destination as WebGPUTexture; | ||
const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer; | ||
const WebGPUDestinationTexture = options.destinationTexture as WebGPUTexture; | ||
this.handle.copyBufferToTexture( | ||
@@ -77,0 +77,0 @@ { |
@@ -35,6 +35,6 @@ // luma.gl | ||
if (device.features.has('timestamp-query')) { | ||
const webgpuQuerySet = props.timestampQuerySet as WebGPUQuerySet; | ||
renderPassDescriptor.timestampWrites = webgpuQuerySet | ||
const webgpuTSQuerySet = props.timestampQuerySet as WebGPUQuerySet; | ||
renderPassDescriptor.timestampWrites = webgpuTSQuerySet | ||
? ({ | ||
querySet: webgpuQuerySet.handle, | ||
querySet: webgpuTSQuerySet.handle, | ||
beginningOfPassWriteIndex: props.beginTimestampIndex, | ||
@@ -41,0 +41,0 @@ endOfPassWriteIndex: props.endTimestampIndex |
@@ -28,2 +28,6 @@ // luma.gl | ||
get asyncCompilationStatus(): Promise<any> { | ||
return this.getCompilationInfo().then(() => this.compilationStatus); | ||
} | ||
async _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void> { | ||
@@ -30,0 +34,0 @@ const error = (await errorScope) as GPUValidationError; |
@@ -5,3 +5,3 @@ // luma.gl | ||
import {Adapter, DeviceProps, CanvasContext, log} from '@luma.gl/core'; | ||
import {Adapter, DeviceProps, log} from '@luma.gl/core'; | ||
import {WebGPUDevice} from './webgpu-device'; | ||
@@ -48,3 +48,3 @@ | ||
if (props.requestMaxLimits) { | ||
if (props._requestMaxLimits) { | ||
// Require all features | ||
@@ -74,7 +74,2 @@ requiredFeatures.push(...(Array.from(adapter.features) as GPUFeatureName[])); | ||
if (typeof props.canvas === 'string') { | ||
await CanvasContext.pageLoaded; | ||
log.probe(1, 'DOM is loaded')(); | ||
} | ||
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo); | ||
@@ -81,0 +76,0 @@ |
@@ -9,3 +9,2 @@ // luma.gl | ||
import type { | ||
DeviceProps, | ||
DeviceInfo, | ||
@@ -32,3 +31,4 @@ DeviceLimits, | ||
QuerySet, | ||
QuerySetProps | ||
QuerySetProps, | ||
DeviceProps | ||
} from '@luma.gl/core'; | ||
@@ -106,10 +106,7 @@ import {Device, DeviceFeatures} from '@luma.gl/core'; | ||
// Note: WebGPU devices can be created without a canvas, for compute shader purposes | ||
// if (props.canvas) { | ||
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, { | ||
canvas: props.canvas, | ||
height: props.height, | ||
width: props.width, | ||
container: props.container | ||
}); | ||
// } | ||
if (props.createCanvasContext) { | ||
const canvasContextProps = | ||
props.createCanvasContext === true ? {} : props.createCanvasContext; | ||
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps); | ||
} | ||
} | ||
@@ -149,3 +146,3 @@ | ||
createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer { | ||
const newProps = this._getBufferProps(props); | ||
const newProps = this._normalizeBufferProps(props); | ||
return new WebGPUBuffer(this, newProps); | ||
@@ -287,3 +284,3 @@ } | ||
return new DeviceFeatures(Array.from(features), this.props.disabledFeatures); | ||
return new DeviceFeatures(Array.from(features), this.props._disabledFeatures); | ||
} | ||
@@ -290,0 +287,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
449391
8302