@luma.gl/webgpu 9.1.0-alpha.16 → 9.1.0-alpha.18

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.
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAClF,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAM,MAAM,eAAe,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAG9C,OAAO,EAAC,oBAAoB,EAAC,oCAAiC;AAE9D,OAAO,EAAC,iBAAiB,EAAC,gCAA6B;AAEvD,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAEtC,sBAAsB;IACtB,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAQ;gBAEjC,MAAM,EAAE,YAAY,EAAE,KAAK,GAAE,eAAoB;IAmCpD,OAAO,IAAI,IAAI;IAExB,GAAG,IAAI,IAAI;IAIX,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK3C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQpD,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,MAAM,GAAE,MAAU,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI;IAIP,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI;IAIvE,IAAI,CAAC,OAAO,EAAE;QACZ,WAAW,CAAC,EAAE,MA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;IAmCpD,OAAO,IAAI,IAAI;IAExB,GAAG,IAAI,IAAI;IAIX,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK3C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQpD,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,MAAM,GAAE,MAAU,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI;IAIP,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI;IAIvE,IAAI,CAAC,OAAO,EAAE;QACZ,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IAmBR,YAAY,IAAI,IAAI;IAKpB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAwBrD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAI5C,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAG7C,iBAAiB,IAAI,IAAI;IAQzB;;;OAGG;IACH,SAAS,CAAC,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,GAAG,uBAAuB;CAoD3F"}
@@ -110,10 +110,10 @@ export class WebGPURenderPass extends RenderPass {
110
110
  const renderPassDescriptor = {
111
111
  colorAttachments: []
112
112
  };
113
- renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({
113
+ renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map((colorAttachment, index) => ({
114
114
  // clear values
115
115
  loadOp: this.props.clearColor !== false ? 'clear' : 'load',
116
- colorClearValue: this.props.clearColor || [0, 0, 0, 0],
116
+ colorClearValue: this.props.clearColors?.[index] || this.props.clearColor || RenderPass.defaultClearColor,
117
117
  storeOp: this.props.discard ? 'discard' : 'store',
118
118
  // ...colorAttachment,
119
119
  view: colorAttachment.handle
@@ -127,7 +127,13 @@ export class WebGPURenderPass extends RenderPass {
127
127
  if (this.props.depthReadOnly) {
128
128
  depthStencilAttachment.depthReadOnly = true;
129
129
  }
130
- depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;
130
+ if (this.props.clearDepth !== false) {
131
+ depthStencilAttachment.depthClearValue = this.props.clearDepth;
132
+ }
133
+ // STENCIL
134
+ // if (this.props.clearStencil !== false) {
135
+ // depthStencilAttachment.stencilClearValue = this.props.clearStencil;
136
+ // }
131
137
  // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect
132
138
  const hasDepthAspect = true;
133
139
  if (hasDepthAspect) {
@@ -4,7 +4,7 @@ export type WebGPUSamplerProps = SamplerProps & {
4
4
  handle?: GPUSampler;
5
5
  };
6
6
  /**
7
- *
7
+ * A WebGPU sampler object
8
8
  */
9
9
  export declare class WebGPUSampler extends Sampler {
10
10
  readonly device: WebGPUDevice;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-sampler.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC9C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,kBAAkB;IAclD,OAAO,IAAI,IAAI;CAMzB"}
1
+ {"version":3,"file":"webgpu-sampler.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC9C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,kBAAkB;IAwBlD,OAAO,IAAI,IAAI;CAMzB"}
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) vis.gl contributors
3
3
  import { Sampler } from '@luma.gl/core';
4
4
  /**
5
- *
5
+ * A WebGPU sampler object
6
6
  */
7
7
  export class WebGPUSampler extends Sampler {
8
8
  device;
@@ -10,12 +10,20 @@ export class WebGPUSampler extends Sampler {
10
10
  constructor(device, props) {
11
11
  super(device, props);
12
12
  this.device = device;
13
- // Prepare sampler props
14
- const samplerProps = { ...this.props };
15
- if (samplerProps.type !== 'comparison-sampler') {
16
- delete samplerProps.compare;
13
+ // Prepare sampler props. Mostly identical
14
+ const samplerDescriptor = {
15
+ ...this.props,
16
+ mipmapFilter: undefined
17
+ };
18
+ // props.compare automatically turns this into a comparison sampler
19
+ if (props.type !== 'comparison-sampler') {
20
+ delete samplerDescriptor.compare;
17
21
  }
18
- this.handle = this.handle || this.device.handle.createSampler(samplerProps);
22
+ // disable mipmapFilter if not set
23
+ if (props.mipmapFilter && props.mipmapFilter !== 'none') {
24
+ samplerDescriptor.mipmapFilter = props.mipmapFilter;
25
+ }
26
+ this.handle = this.handle || this.device.handle.createSampler(samplerDescriptor);
19
27
  this.handle.label = this.props.id;
20
28
  }
21
29
  destroy() {
@@ -6,8 +6,6 @@ import { WebGPUTextureView } from "./webgpu-texture-view.js";
6
6
  export declare class WebGPUTexture extends Texture {
7
7
  readonly device: WebGPUDevice;
8
8
  readonly handle: GPUTexture;
9
- height: number;
10
- width: number;
11
9
  sampler: WebGPUSampler;
12
10
  view: WebGPUTextureView;
13
11
  constructor(device: WebGPUDevice, props: TextureProps);
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,EAKZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAGtC,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AACnD,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAC/C,OAAO,EAAC,iBAAiB,EAAC,iCAA8B;AAWxD,qBAAa,aAAc,SAAQ,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAEnB,MAAM,EAAE,MAAM,CAAK;IACnB,KAAK,EAAE,MAAM,CAAK;IAE3B,OAAO,EAAE,aAAa,CAAC;IACvB,IAAI,EAAE,iBAAiB,CAAC;gBASZ,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY;IAO5C,OAAO,IAAI,IAAI;IAMxB,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB;IA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;
16
- height = 1;
17
- width = 1;
18
16
  sampler;
19
17
  view;
20
- // static async createFromImageURL(src, usage = 0) {
21
- // const img = document.createElement('img');
22
- // img.src = src;
23
- // await img.decode();
24
- // return WebGPUTexture(img, usage);
25
- // }
26
18
  constructor(device, props) {
27
- props = Texture._fixProps(props);
28
19
  super(device, props);
29
20
  this.device = device;
30
- this.initialize(props);
21
+ // Texture base class strips out the data prop, so we need to add it back in
22
+ const propsWithData = { ...this.props };
23
+ if (props.data) {
24
+ propsWithData.data = props.data;
25
+ }
26
+ this.initialize(propsWithData);
31
27
  }
32
28
  destroy() {
33
29
  this.handle?.destroy();
@@ -139,13 +135,14 @@ export class WebGPUTexture extends Texture {
139
135
  copyExternalImage(options) {
140
136
  const size = Texture.getExternalImageSize(options.image);
141
137
  const opts = { ...Texture.defaultCopyExternalImageOptions, ...size, ...options };
142
- const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha } = opts;
138
+ const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha, flipY } = opts;
143
139
  // TODO - max out width
144
140
  this.device.handle.queue.copyExternalImageToTexture(
145
141
  // source: GPUImageCopyExternalImage
146
142
  {
147
143
  source: image,
148
- origin: [sourceX, sourceY]
144
+ origin: [sourceX, sourceY],
145
+ flipY
149
146
  },
150
147
  // destination: GPUImageCopyTextureTagged
151
148
  {
package/dist/dist.dev.js CHANGED
@@ -154,11 +154,17 @@ var __exports__ = (() => {
154
154
  constructor(device, props) {
155
155
  super(device, props);
156
156
  this.device = device;
157
- const samplerProps = { ...this.props };
158
- if (samplerProps.type !== "comparison-sampler") {
159
- delete samplerProps.compare;
157
+ const samplerDescriptor = {
158
+ ...this.props,
159
+ mipmapFilter: void 0
160
+ };
161
+ if (props.type !== "comparison-sampler") {
162
+ delete samplerDescriptor.compare;
163
+ }
164
+ if (props.mipmapFilter && props.mipmapFilter !== "none") {
165
+ samplerDescriptor.mipmapFilter = props.mipmapFilter;
160
166
  }
161
- this.handle = this.handle || this.device.handle.createSampler(samplerProps);
167
+ this.handle = this.handle || this.device.handle.createSampler(samplerDescriptor);
162
168
  this.handle.label = this.props.id;
163
169
  }
164
170
  destroy() {
@@ -207,21 +213,16 @@ var __exports__ = (() => {
207
213
  var WebGPUTexture = class extends import_core4.Texture {
208
214
  device;
209
215
  handle;
210
- height = 1;
211
- width = 1;
212
216
  sampler;
213
217
  view;
214
- // static async createFromImageURL(src, usage = 0) {
215
- // const img = document.createElement('img');
216
- // img.src = src;
217
- // await img.decode();
218
- // return WebGPUTexture(img, usage);
219
- // }
220
218
  constructor(device, props) {
221
- props = import_core4.Texture._fixProps(props);
222
219
  super(device, props);
223
220
  this.device = device;
224
- this.initialize(props);
221
+ const propsWithData = { ...this.props };
222
+ if (props.data) {
223
+ propsWithData.data = props.data;
224
+ }
225
+ this.initialize(propsWithData);
225
226
  }
226
227
  destroy() {
227
228
  this.handle?.destroy();
@@ -316,13 +317,15 @@ var __exports__ = (() => {
316
317
  z,
317
318
  aspect,
318
319
  colorSpace,
319
- premultipliedAlpha
320
+ premultipliedAlpha,
321
+ flipY
320
322
  } = opts;
321
323
  this.device.handle.queue.copyExternalImageToTexture(
322
324
  // source: GPUImageCopyExternalImage
323
325
  {
324
326
  source: image,
325
- origin: [sourceX, sourceY]
327
+ origin: [sourceX, sourceY],
328
+ flipY
326
329
  },
327
330
  // destination: GPUImageCopyTextureTagged
328
331
  {
@@ -1087,14 +1090,16 @@ var __exports__ = (() => {
1087
1090
  const renderPassDescriptor = {
1088
1091
  colorAttachments: []
1089
1092
  };
1090
- renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map((colorAttachment) => ({
1091
- // clear values
1092
- loadOp: this.props.clearColor !== false ? "clear" : "load",
1093
- colorClearValue: this.props.clearColor || [0, 0, 0, 0],
1094
- storeOp: this.props.discard ? "discard" : "store",
1095
- // ...colorAttachment,
1096
- view: colorAttachment.handle
1097
- }));
1093
+ renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(
1094
+ (colorAttachment, index) => ({
1095
+ // clear values
1096
+ loadOp: this.props.clearColor !== false ? "clear" : "load",
1097
+ colorClearValue: this.props.clearColors?.[index] || this.props.clearColor || import_core12.RenderPass.defaultClearColor,
1098
+ storeOp: this.props.discard ? "discard" : "store",
1099
+ // ...colorAttachment,
1100
+ view: colorAttachment.handle
1101
+ })
1102
+ );
1098
1103
  if (framebuffer.depthStencilAttachment) {
1099
1104
  renderPassDescriptor.depthStencilAttachment = {
1100
1105
  view: framebuffer.depthStencilAttachment.handle
@@ -1103,7 +1108,9 @@ var __exports__ = (() => {
1103
1108
  if (this.props.depthReadOnly) {
1104
1109
  depthStencilAttachment.depthReadOnly = true;
1105
1110
  }
1106
- depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;
1111
+ if (this.props.clearDepth !== false) {
1112
+ depthStencilAttachment.depthClearValue = this.props.clearDepth;
1113
+ }
1107
1114
  const hasDepthAspect = true;
1108
1115
  if (hasDepthAspect) {
1109
1116
  depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? "clear" : "load";
package/dist/dist.min.js CHANGED
@@ -4,6 +4,6 @@
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 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);})();
7
+ var __exports__=(()=>{var ye=Object.create;var F=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty;var Ee=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Be=(n,e)=>{for(var t in e)F(n,t,{get:e[t],enumerable:!0})},I=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Se(e))!Pe.call(n,i)&&i!==t&&F(n,i,{get:()=>e[i],enumerable:!(r=ve(e,i))||r.enumerable});return n},R=(n,e,t)=>(I(n,e,"default"),t&&I(t,e,"default")),h=(n,e,t)=>(t=n!=null?ye(Ce(n)):{},I(e||!n||!n.__esModule?F(t,"default",{value:n,enumerable:!0}):t,n)),Ae=n=>I(F({},"__esModule",{value:!0}),n);var o=Ee((We,te)=>{te.exports=globalThis.luma});var D={};Be(D,{WebGPUBuffer:()=>b,WebGPUDevice:()=>v,WebGPUSampler:()=>p,WebGPUShader:()=>P,WebGPUTexture:()=>C,webgpuAdapter:()=>fe});R(D,h(o(),1));var f=h(o(),1);var X=h(o(),1);var O=h(o(),1);function Te(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=Te(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 w=h(o(),1);function S(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,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 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 Ge={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},C=class extends w.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 G(this.device,{...e,texture:this})}initialize(e){this.handle=this.props.handle||this.createHandle(),this.handle.label||=this.id,this.props.data&&(w.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||w.Texture.TEXTURE|w.Texture.COPY_DST,dimension:Ge[this.dimension],format:S(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=w.Texture.getExternalImageSize(e.image),r={...w.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,flipY:we}=r;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[s,a],flipY:we},{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),P=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 B=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 Le={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)}},_e={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,{..._e,...n}),De(n,e)}function De(n,e){for(let[t,r]of Object.entries(e)){let i=Le[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 x=h(o(),1);function V(n,e,t,r){let i=Fe(r,t);return n.createBindGroup({layout:e,entries:i})}function Ie(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=Ie(e,r);s&&t.push(Re(i,s.location))}return t}function Re(n,e){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{binding:e,resource:n.handle.createView({label:"bind-group-auto-created"})};throw new Error("invalid binding")}var E=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,E.decodeVertexFormat)(u).byteLength}else{let d=oe(n,i.name,r);if(!d)continue;l=(0,E.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,E.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 E.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 B.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();B.log.groupCollapsed(1,`new WebGPURenderPipeline(${this.id})`)(),B.log.probe(1,JSON.stringify(r,null,2))(),B.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:S(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),A=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 y=h(o(),1),$=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.handle=this.props.handle||e.commandEncoder.beginRenderPass(i),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",colorClearValue: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}};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 ht=globalThis.document||{},dt=globalThis.process||{},lt=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 A(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:S(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 v=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 C(this,e)}createExternalTexture(e){return new W(this,e)}createShader(e){return new P(this,e)}createSampler(e){return new p(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 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(),v.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 v(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 Ae(D);})();
8
8
  return __exports__;
9
9
  });
package/dist/index.cjs CHANGED
@@ -122,11 +122,17 @@ var WebGPUSampler = class extends import_core2.Sampler {
122
122
  constructor(device, props) {
123
123
  super(device, props);
124
124
  this.device = device;
125
- const samplerProps = { ...this.props };
126
- if (samplerProps.type !== "comparison-sampler") {
127
- delete samplerProps.compare;
125
+ const samplerDescriptor = {
126
+ ...this.props,
127
+ mipmapFilter: void 0
128
+ };
129
+ if (props.type !== "comparison-sampler") {
130
+ delete samplerDescriptor.compare;
131
+ }
132
+ if (props.mipmapFilter && props.mipmapFilter !== "none") {
133
+ samplerDescriptor.mipmapFilter = props.mipmapFilter;
128
134
  }
129
- this.handle = this.handle || this.device.handle.createSampler(samplerProps);
135
+ this.handle = this.handle || this.device.handle.createSampler(samplerDescriptor);
130
136
  this.handle.label = this.props.id;
131
137
  }
132
138
  destroy() {
@@ -175,21 +181,16 @@ var BASE_DIMENSIONS = {
175
181
  var WebGPUTexture = class extends import_core4.Texture {
176
182
  device;
177
183
  handle;
178
- height = 1;
179
- width = 1;
180
184
  sampler;
181
185
  view;
182
- // static async createFromImageURL(src, usage = 0) {
183
- // const img = document.createElement('img');
184
- // img.src = src;
185
- // await img.decode();
186
- // return WebGPUTexture(img, usage);
187
- // }
188
186
  constructor(device, props) {
189
- props = import_core4.Texture._fixProps(props);
190
187
  super(device, props);
191
188
  this.device = device;
192
- this.initialize(props);
189
+ const propsWithData = { ...this.props };
190
+ if (props.data) {
191
+ propsWithData.data = props.data;
192
+ }
193
+ this.initialize(propsWithData);
193
194
  }
194
195
  destroy() {
195
196
  var _a;
@@ -273,12 +274,13 @@ var WebGPUTexture = class extends import_core4.Texture {
273
274
  copyExternalImage(options) {
274
275
  const size = import_core4.Texture.getExternalImageSize(options.image);
275
276
  const opts = { ...import_core4.Texture.defaultCopyExternalImageOptions, ...size, ...options };
276
- const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha } = opts;
277
+ const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha, flipY } = opts;
277
278
  this.device.handle.queue.copyExternalImageToTexture(
278
279
  // source: GPUImageCopyExternalImage
279
280
  {
280
281
  source: image,
281
- origin: [sourceX, sourceY]
282
+ origin: [sourceX, sourceY],
283
+ flipY
282
284
  },
283
285
  // destination: GPUImageCopyTextureTagged
284
286
  {
@@ -952,14 +954,17 @@ var WebGPURenderPass = class extends import_core12.RenderPass {
952
954
  const renderPassDescriptor = {
953
955
  colorAttachments: []
954
956
  };
955
- renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map((colorAttachment) => ({
956
- // clear values
957
- loadOp: this.props.clearColor !== false ? "clear" : "load",
958
- colorClearValue: this.props.clearColor || [0, 0, 0, 0],
959
- storeOp: this.props.discard ? "discard" : "store",
960
- // ...colorAttachment,
961
- view: colorAttachment.handle
962
- }));
957
+ renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map((colorAttachment, index) => {
958
+ var _a;
959
+ return {
960
+ // clear values
961
+ loadOp: this.props.clearColor !== false ? "clear" : "load",
962
+ colorClearValue: ((_a = this.props.clearColors) == null ? void 0 : _a[index]) || this.props.clearColor || import_core12.RenderPass.defaultClearColor,
963
+ storeOp: this.props.discard ? "discard" : "store",
964
+ // ...colorAttachment,
965
+ view: colorAttachment.handle
966
+ };
967
+ });
963
968
  if (framebuffer.depthStencilAttachment) {
964
969
  renderPassDescriptor.depthStencilAttachment = {
965
970
  view: framebuffer.depthStencilAttachment.handle
@@ -968,7 +973,9 @@ var WebGPURenderPass = class extends import_core12.RenderPass {
968
973
  if (this.props.depthReadOnly) {
969
974
  depthStencilAttachment.depthReadOnly = true;
970
975
  }
971
- depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;
976
+ if (this.props.clearDepth !== false) {
977
+ depthStencilAttachment.depthClearValue = this.props.clearDepth;
978
+ }
972
979
  const hasDepthAspect = true;
973
980
  if (hasDepthAspect) {
974
981
  depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? "clear" : "load";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "adapter/webgpu-adapter.js", "adapter/webgpu-device.js", "adapter/resources/webgpu-buffer.js", "adapter/resources/webgpu-texture.js", "adapter/helpers/convert-texture-format.js", "adapter/resources/webgpu-sampler.js", "adapter/resources/webgpu-texture-view.js", "adapter/resources/webgpu-external-texture.js", "adapter/resources/webgpu-shader.js", "adapter/resources/webgpu-render-pipeline.js", "adapter/helpers/webgpu-parameters.js", "adapter/helpers/get-bind-group.js", "adapter/helpers/get-vertex-buffer-layout.js", "adapter/resources/webgpu-framebuffer.js", "adapter/resources/webgpu-compute-pipeline.js", "adapter/resources/webgpu-render-pass.js", "adapter/resources/webgpu-compute-pass.js", "adapter/resources/webgpu-vertex-array.js", "adapter/webgpu-canvas-context.js", "adapter/resources/webgpu-query-set.js"],
4
- "sourcesContent": ["// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { webgpuAdapter } from \"./adapter/webgpu-adapter.js\";\n// WEBGPU CLASSES (typically not accessed directly)\nexport { WebGPUDevice } from \"./adapter/webgpu-device.js\";\nexport { WebGPUBuffer } from \"./adapter/resources/webgpu-buffer.js\";\nexport { WebGPUTexture } from \"./adapter/resources/webgpu-texture.js\";\nexport { WebGPUSampler } from \"./adapter/resources/webgpu-sampler.js\";\nexport { WebGPUShader } from \"./adapter/resources/webgpu-shader.js\";\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Adapter, log } from '@luma.gl/core';\nimport { WebGPUDevice } from \"./webgpu-device.js\";\n// / <reference types=\"@webgpu/types\" />\nexport class WebGPUAdapter extends Adapter {\n /** type of device's created by this adapter */\n type = 'webgpu';\n constructor() {\n super();\n // @ts-ignore For backwards compatibility luma.registerDevices\n WebGPUDevice.adapter = this;\n }\n /** Check if WebGPU is available */\n isSupported() {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n async create(props) {\n if (!navigator.gpu) {\n throw new Error('WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu');\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(2, 'Adapter available', adapterInfo)();\n const requiredFeatures = [];\n const requiredLimits = {};\n if (props._requestMaxLimits) {\n // Require all features\n requiredFeatures.push(...Array.from(adapter.features));\n // Require all limits\n // Filter out chrome specific keys (avoid crash)\n const limits = Object.keys(adapter.limits).filter(key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key));\n for (const key of limits) {\n const limit = key;\n const value = adapter.limits[limit];\n if (typeof value === 'number') {\n requiredLimits[limit] = value;\n }\n }\n }\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures,\n requiredLimits\n });\n log.probe(1, 'GPUDevice available')();\n const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);\n log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n async attach(handle) {\n throw new Error('WebGPUAdapter.attach() not implemented');\n }\n}\nexport const webgpuAdapter = new WebGPUAdapter();\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Device, DeviceFeatures } from '@luma.gl/core';\nimport { WebGPUBuffer } from \"./resources/webgpu-buffer.js\";\nimport { WebGPUTexture } from \"./resources/webgpu-texture.js\";\nimport { WebGPUExternalTexture } from \"./resources/webgpu-external-texture.js\";\nimport { WebGPUSampler } from \"./resources/webgpu-sampler.js\";\nimport { WebGPUShader } from \"./resources/webgpu-shader.js\";\nimport { WebGPURenderPipeline } from \"./resources/webgpu-render-pipeline.js\";\nimport { WebGPUFramebuffer } from \"./resources/webgpu-framebuffer.js\";\nimport { WebGPUComputePipeline } from \"./resources/webgpu-compute-pipeline.js\";\nimport { WebGPURenderPass } from \"./resources/webgpu-render-pass.js\";\nimport { WebGPUComputePass } from \"./resources/webgpu-compute-pass.js\";\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport { WebGPUVertexArray } from \"./resources/webgpu-vertex-array.js\";\nimport { WebGPUCanvasContext } from \"./webgpu-canvas-context.js\";\nimport { WebGPUQuerySet } from \"./resources/webgpu-query-set.js\";\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n /** type of this device */\n type = 'webgpu';\n /** The underlying WebGPU device */\n handle;\n /* The underlying WebGPU adapter */\n adapter;\n /* The underlying WebGPU adapter's info */\n adapterInfo;\n features;\n info;\n limits;\n lost;\n canvasContext = null;\n _isLost = false;\n commandEncoder = null;\n renderPass = null;\n constructor(props, device, adapter, adapterInfo) {\n super({ ...props, id: props.id || 'webgpu-device' });\n this.handle = device;\n this.adapter = adapter;\n this.adapterInfo = adapterInfo;\n this.info = this._getInfo();\n this.features = this._getFeatures();\n this.limits = this.handle.limits;\n // Listen for uncaptured WebGPU errors\n device.addEventListener('uncapturederror', (event) => {\n // TODO is this the right way to make sure the error is an Error instance?\n const errorMessage = event instanceof GPUUncapturedErrorEvent ? event.error.message : 'Unknown error';\n this.error(new Error(errorMessage));\n });\n // \"Context\" loss handling\n this.lost = new Promise(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({ reason: 'destroyed', message: lostInfo.message });\n });\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n if (props.createCanvasContext) {\n const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);\n }\n }\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n destroy() {\n this.handle.destroy();\n }\n isTextureFormatSupported(format) {\n return !format.includes('webgl');\n }\n /** @todo implement proper check? */\n isTextureFormatFilterable(format) {\n return (this.isTextureFormatSupported(format) &&\n !format.startsWith('depth') &&\n !format.startsWith('stencil'));\n }\n /** @todo implement proper check? */\n isTextureFormatRenderable(format) {\n return this.isTextureFormatSupported(format);\n }\n get isLost() {\n return this._isLost;\n }\n createBuffer(props) {\n const newProps = this._normalizeBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n createTexture(props) {\n return new WebGPUTexture(this, props);\n }\n createExternalTexture(props) {\n return new WebGPUExternalTexture(this, props);\n }\n createShader(props) {\n return new WebGPUShader(this, props);\n }\n createSampler(props) {\n return new WebGPUSampler(this, props);\n }\n createRenderPipeline(props) {\n return new WebGPURenderPipeline(this, props);\n }\n createFramebuffer(props) {\n return new WebGPUFramebuffer(this, props);\n }\n createComputePipeline(props) {\n return new WebGPUComputePipeline(this, props);\n }\n createVertexArray(props) {\n return new WebGPUVertexArray(this, props);\n }\n // WebGPU specifics\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props) {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n beginComputePass(props) {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n createTransformFeedback(props) {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n createQuerySet(props) {\n return new WebGPUQuerySet(this, props);\n }\n createCanvasContext(props) {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n submit() {\n // this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n // this.renderPass = null;\n }\n // PRIVATE METHODS\n _getInfo() {\n const [driver, driverVersion] = (this.adapterInfo.driver || '').split(' Version ');\n // See https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates\n const vendor = this.adapterInfo.vendor || this.adapter.__brand || 'unknown';\n const renderer = driver || '';\n const version = driverVersion || '';\n const gpu = vendor === 'apple' ? 'apple' : 'unknown'; // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n const gpuArchitecture = this.adapterInfo.architecture || 'unknown';\n const gpuBackend = this.adapterInfo.backend || 'unknown';\n const gpuType = (this.adapterInfo.type || '').split(' ')[0].toLowerCase() || 'unknown';\n return {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu,\n gpuType,\n gpuBackend,\n gpuArchitecture,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n }\n _getFeatures() {\n // Initialize with actual WebGPU Features (note that unknown features may not be in DeviceFeature type)\n const features = new Set(this.handle.features);\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n // Some subsets of WebGPU extensions correspond to WebGL extensions\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n const WEBGPU_ALWAYS_FEATURES = [\n 'timer-query-webgl',\n 'compilation-status-async-webgl',\n 'float32-renderable-webgl',\n 'float16-renderable-webgl',\n 'norm16-renderable-webgl',\n 'texture-filterable-anisotropic-webgl',\n 'shader-noperspective-interpolation-webgl'\n ];\n for (const feature of WEBGPU_ALWAYS_FEATURES) {\n features.add(feature);\n }\n return new DeviceFeatures(Array.from(features), this.props._disabledFeatures);\n }\n copyExternalImageToTexture(options) {\n const { source, sourceX = 0, sourceY = 0, texture, mipLevel = 0, aspect = 'all', colorSpace = 'display-p3', premultipliedAlpha = false, \n // destinationX,\n // destinationY,\n // desitnationZ,\n width = texture.width, height = texture.height, depth = 1 } = options;\n const webGpuTexture = texture;\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n }, \n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n }, \n // copySize: GPUExtent3D\n [width, height, depth]);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer } from '@luma.gl/core';\nfunction getByteLength(props) {\n return props.byteLength || props.data?.byteLength || 0;\n}\nexport class WebGPUBuffer extends Buffer {\n device;\n handle;\n byteLength;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n // WebGPU buffers must be aligned to 4 bytes\n const size = Math.ceil(this.byteLength / 4) * 4;\n this.handle =\n this.props.handle ||\n this.device.handle.createBuffer({\n size,\n // usage defaults to vertex\n usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n // WebGPU provides multiple ways to write a buffer...\n write(data, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(this.handle, byteOffset, data.buffer, data.byteOffset, data.byteLength);\n }\n async readAsync(byteOffset = 0, byteLength = this.byteLength) {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {\n usage: Buffer.MAP_READ | Buffer.COPY_DST,\n byteLength\n });\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n return new Uint8Array(arrayBuffer);\n }\n _writeMapped(typedArray) {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n // WEBGPU API\n mapAsync(mode, offset = 0, size) {\n return this.handle.mapAsync(mode, offset, size);\n }\n getMappedRange(offset = 0, size) {\n return this.handle.getMappedRange(offset, size);\n }\n unmap() {\n this.handle.unmap();\n }\n}\n/*\n// Convenience API\n /** Read data from the buffer *\n async readAsync(options: {\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<ArrayBuffer> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_READ, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n if (options.unmap ?? true) {\n this.unmap();\n }\n return arrayBuffer;\n }\n\n /** Write data to the buffer *\n async writeAsync(options: {\n data: ArrayBuffer,\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<void> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_WRITE, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n const destArray = new Uint8Array(arrayBuffer);\n const srcArray = new Uint8Array(options.data);\n destArray.set(srcArray);\n if (options.unmap ?? true) {\n this.unmap();\n }\n }\n */\n// Mapped API (WebGPU)\n/** Maps the memory so that it can be read *\n // abstract mapAsync(mode, byteOffset, byteLength): Promise<void>\n\n /** Get the mapped range of data for reading or writing *\n // abstract getMappedRange(byteOffset, byteLength): ArrayBuffer;\n\n /** unmap makes the contents of the buffer available to the GPU again *\n // abstract unmap(): void;\n*/\n", "import { Texture } from '@luma.gl/core';\nimport { getWebGPUTextureFormat } from \"../helpers/convert-texture-format.js\";\nimport { WebGPUSampler } from \"./webgpu-sampler.js\";\nimport { WebGPUTextureView } from \"./webgpu-texture-view.js\";\nconst BASE_DIMENSIONS = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n cube: '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\nexport class WebGPUTexture extends Texture {\n device;\n handle;\n height = 1;\n width = 1;\n sampler;\n view;\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n constructor(device, props) {\n props = Texture._fixProps(props);\n super(device, props);\n this.device = device;\n this.initialize(props);\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n createView(props) {\n return new WebGPUTextureView(this.device, { ...props, texture: this });\n }\n initialize(props) {\n // @ts-expect-error\n this.handle = this.props.handle || this.createHandle();\n this.handle.label ||= this.id;\n if (this.props.data) {\n if (Texture.isExternalImage(this.props.data)) {\n this.copyExternalImage({ image: this.props.data });\n }\n else {\n this.setData({ data: this.props.data });\n }\n }\n this.width = this.handle.width;\n this.height = this.handle.height;\n // Why not just read all properties directly from the texture\n // this.depthOrArrayLayers = this.handle.depthOrArrayLayers;\n // this.mipLevelCount = this.handle.mipLevelCount;\n // this.sampleCount = this.handle.sampleCount;\n // this.dimension = this.handle.dimension;\n // this.format = this.handle.format;\n // this.usage = this.handle.usage;\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler =\n props.sampler instanceof WebGPUSampler\n ? props.sampler\n : new WebGPUSampler(this.device, props.sampler || {});\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n // @ts-expect-error\n this.view = new WebGPUTextureView(this.device, { ...this.props, texture: this });\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n }\n createHandle() {\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n return this.device.handle.createTexture({\n label: this.id,\n size: {\n width,\n height,\n depthOrArrayLayers: this.depth\n },\n usage: this.props.usage || Texture.TEXTURE | Texture.COPY_DST,\n dimension: BASE_DIMENSIONS[this.dimension],\n format: getWebGPUTextureFormat(this.format),\n mipLevelCount: this.mipLevels,\n sampleCount: this.props.samples\n });\n }\n /** @deprecated - intention is to use the createView public API */\n createGPUTextureView() {\n return this.handle.createView({ label: this.id });\n }\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler) {\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n setTexture1DData(data) {\n throw new Error('not implemented');\n }\n setTexture2DData(lodData, depth, target) {\n throw new Error('not implemented');\n }\n setTexture3DData(lodData, depth, target) {\n throw new Error('not implemented');\n }\n setTextureCubeData(data, depth) {\n throw new Error('not implemented');\n }\n setTextureArrayData(data) {\n throw new Error('not implemented');\n }\n setTextureCubeArrayData(data) {\n throw new Error('not implemented');\n }\n setData(options) {\n if (ArrayBuffer.isView(options.data)) {\n const clampedArray = new Uint8ClampedArray(options.data.buffer);\n // TODO - pass through src data color space as ImageData Options?\n const image = new ImageData(clampedArray, this.width, this.height);\n return this.copyExternalImage({ image });\n }\n throw new Error('Texture.setData: Use CommandEncoder to upload data to texture in WebGPU');\n }\n copyExternalImage(options) {\n const size = Texture.getExternalImageSize(options.image);\n const opts = { ...Texture.defaultCopyExternalImageOptions, ...size, ...options };\n const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha } = opts;\n // TODO - max out width\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source: image,\n origin: [sourceX, sourceY]\n }, \n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n }, \n // copySize: GPUExtent3D\n [width, height, depth]);\n return { width, height };\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/** Ensure a texture format is WebGPU compatible */\nexport function getWebGPUTextureFormat(format) {\n if (format.includes('webgl')) {\n throw new Error('webgl-only format');\n }\n return format;\n}\n", "// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\nimport { Sampler } from '@luma.gl/core';\n/**\n *\n */\nexport class WebGPUSampler extends Sampler {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Prepare sampler props\n const samplerProps = { ...this.props };\n if (samplerProps.type !== 'comparison-sampler') {\n delete samplerProps.compare;\n }\n this.handle = this.handle || this.device.handle.createSampler(samplerProps);\n this.handle.label = this.props.id;\n }\n destroy() {\n // GPUSampler does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TextureView } from '@luma.gl/core';\n/**\n *\n */\nexport class WebGPUTextureView extends TextureView {\n device;\n handle;\n texture;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.texture = props.texture;\n this.handle =\n this.handle ||\n this.texture.handle.createView({\n format: (props.format || this.texture.format),\n dimension: props.dimension || this.texture.dimension,\n aspect: props.aspect,\n baseMipLevel: props.baseMipLevel,\n mipLevelCount: props.mipLevelCount, // GPUIntegerCoordinate;\n baseArrayLayer: props.baseArrayLayer, // GPUIntegerCoordinate;\n arrayLayerCount: props.arrayLayerCount // GPUIntegerCoordinate;\n });\n this.handle.label = this.props.id;\n }\n destroy() {\n // GPUTextureView does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ExternalTexture } from '@luma.gl/core';\nimport { WebGPUSampler } from \"./webgpu-sampler.js\";\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport class WebGPUExternalTexture extends ExternalTexture {\n device;\n handle;\n sampler;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n // @ts-expect-error\n this.sampler = null;\n }\n destroy() {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n /** Set default sampler */\n setSampler(sampler) {\n // We can accept a sampler instance or set of props;\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Shader, log } from '@luma.gl/core';\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.device.handle.pushErrorScope('validation');\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n get asyncCompilationStatus() {\n return this.getCompilationInfo().then(() => this.compilationStatus);\n }\n async _checkCompilationError(errorScope) {\n const error = (await errorScope);\n if (error) {\n // The `Shader` base class will determine if debug window should be opened based on props\n this.debugShader();\n const shaderLog = await this.getCompilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n destroy() {\n // Note: WebGPU does not offer a method to destroy shaders\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n /** Returns compilation info for this shader */\n async getCompilationInfo() {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n // PRIVATE METHODS\n createHandle() {\n const { source } = this.props;\n const isGLSL = source.includes('#version');\n if (this.props.language === 'glsl' || isGLSL) {\n throw new Error('GLSL shaders are not supported in WebGPU');\n }\n return this.device.handle.createShaderModule({ code: source });\n }\n}\n", "// luma.gl MIT license\nimport { RenderPipeline, log } from '@luma.gl/core';\nimport { applyParametersToRenderPipelineDescriptor } from \"../helpers/webgpu-parameters.js\";\nimport { getWebGPUTextureFormat } from \"../helpers/convert-texture-format.js\";\nimport { getBindGroup } from \"../helpers/get-bind-group.js\";\nimport { getVertexBufferLayout } from \"../helpers/get-vertex-buffer-layout.js\";\n// RENDER PIPELINE\n/** Creates a new render pipeline when parameters change */\nexport class WebGPURenderPipeline extends RenderPipeline {\n device;\n handle;\n vs;\n fs = null;\n /** For internal use to create BindGroups */\n _bindings;\n _bindGroupLayout = null;\n _bindGroup = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle;\n if (!this.handle) {\n const descriptor = this._getRenderPipelineDescriptor();\n log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();\n log.probe(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n this.handle = this.device.handle.createRenderPipeline(descriptor);\n }\n this.handle.label = this.props.id;\n this.vs = props.vs;\n this.fs = props.fs;\n this._bindings = { ...this.props.bindings };\n }\n destroy() {\n // WebGPURenderPipeline has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings) {\n Object.assign(this._bindings, bindings);\n }\n /** @todo - should this be moved to renderpass? */\n draw(options) {\n const webgpuRenderPass = options.renderPass;\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n // Set attributes\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.bindBeforeRender(options.renderPass);\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);\n }\n else {\n webgpuRenderPass.handle.draw(options.vertexCount || 0, options.instanceCount || 1, // If 0, nothing will be drawn\n options.firstInstance);\n }\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.unbindAfterRender(options.renderPass);\n return true;\n }\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n if (this.shaderLayout.bindings.length === 0) {\n return null;\n }\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n // Set up the bindings\n // TODO what if bindings change? We need to rebuild the bind group!\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n return this._bindGroup;\n }\n /**\n * Populate the complex WebGPU GPURenderPipelineDescriptor\n */\n _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex = {\n module: this.props.vs.handle,\n entryPoint: this.props.vertexEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.shaderLayout, this.props.bufferLayout)\n };\n // Set up the fragment stage\n const fragment = {\n module: this.props.fs.handle,\n entryPoint: this.props.fragmentEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device.getCanvasContext().format)\n }\n ]\n };\n // Create a partially populated descriptor\n const descriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: 'auto'\n };\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n return descriptor;\n }\n}\n/**\n_setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.shaderLayout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferLayout)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n *\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nfunction addDepthStencil(descriptor) {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: false,\n depthCompare: 'less-equal'\n };\n return descriptor.depthStencil;\n}\nfunction addDepthStencilFront(descriptor) {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilFront;\n}\nfunction addDepthStencilBack(descriptor) {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilBack;\n}\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\n// @ts-expect-error\nexport const PARAMETER_TABLE = {\n // RASTERIZATION PARAMETERS\n cullMode: (parameter, value, descriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n frontFace: (parameter, value, descriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n // DEPTH\n depthWriteEnabled: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n },\n depthCompare: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n depthFormat: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n depthBias: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n depthBiasSlopeScale: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n depthBiasClamp: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n // STENCIL\n stencilReadMask: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n stencilWriteMask: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n stencilCompare: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.compare = value;\n stencilBack.compare = value;\n },\n stencilPassOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.passOp = value;\n stencilBack.passOp = value;\n },\n stencilFailOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.failOp = value;\n stencilBack.failOp = value;\n },\n stencilDepthFailOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.depthFailOp = value;\n stencilBack.depthFailOp = value;\n },\n // MULTISAMPLE\n sampleCount: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n sampleMask: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n sampleAlphaToCoverageEnabled: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n // COLOR\n colorMask: (parameter, value, descriptor) => {\n const targets = addColorState(descriptor);\n targets[0].writeMask = value;\n },\n blendColorOperation: (parameter, value, descriptor) => {\n addColorState(descriptor);\n // const targets = addColorState(descriptor);\n // const target = targets[0];\n // const blend: GPUBlendState = target.blend || {color: {alpha: 0}};\n // blend.color = blend.color || {};\n // target.blend.color.operation = value;\n }\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n \n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n \n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n \n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n \n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\nconst DEFAULT_PIPELINE_DESCRIPTOR = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n vertex: {\n module: undefined,\n entryPoint: 'main'\n },\n fragment: {\n module: undefined,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n },\n layout: 'auto'\n};\nexport function applyParametersToRenderPipelineDescriptor(pipelineDescriptor, parameters = {}) {\n // Apply defaults\n Object.assign(pipelineDescriptor, { ...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor });\n setParameters(pipelineDescriptor, parameters);\n}\n// Apply any supplied parameters\nfunction setParameters(pipelineDescriptor, parameters) {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\nfunction addColorState(descriptor) {\n // @ts-ignore\n descriptor.fragment.targets = descriptor.fragment?.targets || [];\n if (!Array.isArray(descriptor.fragment?.targets)) {\n throw new Error('colorstate');\n }\n if (descriptor.fragment?.targets?.length === 0) {\n descriptor.fragment.targets?.push({});\n }\n return descriptor.fragment?.targets;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer, Sampler, Texture, log } from '@luma.gl/core';\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(device, layout, bindings) {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {\n const entries = getBindGroupEntries(bindings, shaderLayout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\nexport function getShaderLayoutBinding(shaderLayout, bindingName) {\n const bindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName || `${binding.name}uniforms` === bindingName.toLocaleLowerCase());\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout || null;\n}\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(bindings, shaderLayout) {\n const entries = [];\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n return entries;\n}\nfunction getBindGroupEntry(binding, index) {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: binding.handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: binding.handle\n };\n }\n else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: binding.handle.createView({ label: 'bind-group-auto-created' })\n };\n }\n throw new Error('invalid binding');\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { log, decodeVertexFormat } from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format) {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format;\n}\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(shaderLayout, bufferLayout) {\n const vertexBufferLayouts = [];\n const usedAttributes = new Set();\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes = [];\n // TODO verify that all stepModes for one buffer are the same\n let stepMode = 'vertex';\n let byteStride = 0;\n // @ts-ignore\n const format = mapping.format;\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n // @ts-ignore\n const location = attributeLayout?.location;\n stepMode =\n attributeLayout?.stepMode ||\n (attributeLayout?.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),\n offset: attributeMapping.byteOffset,\n shaderLocation: location\n });\n byteStride += decodeVertexFormat(format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n }\n else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = decodeVertexFormat(format).byteLength;\n stepMode =\n attributeLayout.stepMode ||\n (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode,\n attributes: vertexAttributes\n });\n }\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat('float32x3').byteLength,\n stepMode: attribute.stepMode || (attribute.name.startsWith('instance') ? 'instance' : 'vertex'),\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n return vertexBufferLayouts;\n}\nexport function getBufferSlots(shaderLayout, bufferLayout) {\n const usedAttributes = new Set();\n let bufferSlot = 0;\n const bufferSlots = {};\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes || []) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n }\n else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n return bufferSlots;\n}\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(shaderLayout, name, attributeNames) {\n const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name);\n if (!attribute) {\n log.warn(`Unknown attribute ${name}`)();\n return null;\n }\n if (attributeNames.has(name)) {\n throw new Error(`Duplicate attribute ${name}`);\n }\n attributeNames.add(name);\n return attribute;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Framebuffer } from '@luma.gl/core';\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class WebGPUFramebuffer extends Framebuffer {\n device;\n colorAttachments = [];\n depthStencilAttachment = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n }\n updateAttachments() {\n // WebGPU framebuffers are JS only objects, nothing to update\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ComputePipeline } from '@luma.gl/core';\nimport { getBindGroup } from \"../helpers/get-bind-group.js\";\n// COMPUTE PIPELINE\n/** Creates a new compute pipeline when parameters change */\nexport class WebGPUComputePipeline extends ComputePipeline {\n device;\n handle;\n /** For internal use to create BindGroups */\n _bindGroupLayout = null;\n _bindGroup = null;\n /** For internal use to create BindGroups */\n _bindings = {};\n constructor(device, props) {\n super(device, props);\n this.device = device;\n const webgpuShader = this.props.shader;\n this.handle =\n this.props.handle ||\n this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module: webgpuShader.handle,\n entryPoint: this.props.entryPoint,\n constants: this.props.constants\n },\n layout: 'auto'\n });\n }\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings) {\n Object.assign(this._bindings, bindings);\n }\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n // Set up the bindings\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n return this._bindGroup;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { RenderPass, log } from '@luma.gl/core';\nexport class WebGPURenderPass extends RenderPass {\n device;\n handle;\n /** Active pipeline */\n pipeline = null;\n constructor(device, props = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.getCanvasContext().getCurrentFramebuffer();\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n const webgpuQuerySet = props.timestampQuerySet;\n if (webgpuQuerySet) {\n renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;\n }\n if (device.features.has('timestamp-query')) {\n const webgpuTSQuerySet = props.timestampQuerySet;\n renderPassDescriptor.timestampWrites = webgpuTSQuerySet\n ? {\n querySet: webgpuTSQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n }\n : undefined;\n }\n if (!device.commandEncoder) {\n throw new Error('commandEncoder not available');\n }\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();\n log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();\n log.groupEnd(3)();\n }\n destroy() { }\n end() {\n this.handle.end();\n }\n setPipeline(pipeline) {\n this.pipeline = pipeline;\n this.handle.setPipeline(this.pipeline.handle);\n }\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings) {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n setIndexBuffer(buffer, indexFormat, offset = 0, size) {\n this.handle.setIndexBuffer(buffer.handle, indexFormat, offset, size);\n }\n setVertexBuffer(slot, buffer, offset = 0) {\n this.handle.setVertexBuffer(slot, buffer.handle, offset);\n }\n draw(options) {\n if (options.indexCount) {\n this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);\n }\n else {\n this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);\n }\n }\n drawIndirect() {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n setParameters(parameters) {\n const { blendConstant, stencilReference, scissorRect, viewport } = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);\n }\n }\n pushDebugGroup(groupLabel) {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup() {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel) {\n this.handle.insertDebugMarker(markerLabel);\n }\n beginOcclusionQuery(queryIndex) {\n this.handle.beginOcclusionQuery(queryIndex);\n }\n endOcclusionQuery() {\n this.handle.endOcclusionQuery();\n }\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n // INTERNAL\n /**\n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor.\n */\n getRenderPassDescriptor(framebuffer) {\n const renderPassDescriptor = {\n colorAttachments: []\n };\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({\n // clear values\n loadOp: this.props.clearColor !== false ? 'clear' : 'load',\n colorClearValue: this.props.clearColor || [0, 0, 0, 0],\n storeOp: this.props.discard ? 'discard' : 'store',\n // ...colorAttachment,\n view: colorAttachment.handle\n }));\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n view: framebuffer.depthStencilAttachment.handle\n };\n const { depthStencilAttachment } = renderPassDescriptor;\n // DEPTH\n if (this.props.depthReadOnly) {\n depthStencilAttachment.depthReadOnly = true;\n }\n depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;\n // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect\n const hasDepthAspect = true;\n if (hasDepthAspect) {\n depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';\n depthStencilAttachment.depthStoreOp = 'store'; // TODO - support 'discard'?\n }\n // WebGPU only wants us to set these parameters if the texture format actually has a stencil aspect\n const hasStencilAspect = false;\n if (hasStencilAspect) {\n depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';\n depthStencilAttachment.stencilStoreOp = 'store'; // TODO - support 'discard'?\n }\n }\n return renderPassDescriptor;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ComputePass } from '@luma.gl/core';\nexport class WebGPUComputePass extends ComputePass {\n device;\n handle;\n _webgpuPipeline = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Set up queries\n let timestampWrites;\n if (device.features.has('timestamp-query')) {\n const webgpuQuerySet = props.timestampQuerySet;\n if (webgpuQuerySet) {\n timestampWrites = {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n };\n }\n }\n this.handle =\n this.props.handle ||\n device.commandEncoder?.beginComputePass({\n label: this.props.id,\n timestampWrites\n });\n }\n /** @note no WebGPU destroy method, just gc */\n destroy() { }\n end() {\n this.handle.end();\n }\n setPipeline(pipeline) {\n const wgpuPipeline = pipeline;\n this.handle.setPipeline(wgpuPipeline.handle);\n this._webgpuPipeline = wgpuPipeline;\n this.setBindings([]);\n }\n /**\n * Sets an array of bindings (uniform buffers, samplers, textures, ...)\n * TODO - still some API confusion - does this method go here or on the pipeline?\n */\n setBindings(bindings) {\n // @ts-expect-error\n const bindGroup = this._webgpuPipeline._getBindGroup();\n this.handle.setBindGroup(0, bindGroup);\n }\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of work groups to dispatch.\n * @param y Y dimension of the grid of work groups to dispatch.\n * @param z Z dimension of the grid of work groups to dispatch.\n */\n dispatch(x, y, z) {\n this.handle.dispatchWorkgroups(x, y, z);\n }\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n *\n * Buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectBuffer\n * @param indirectOffset offset in buffer to the beginning of the dispatch data.\n */\n dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {\n const webgpuBuffer = indirectBuffer;\n this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);\n }\n pushDebugGroup(groupLabel) {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup() {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel) {\n this.handle.insertDebugMarker(markerLabel);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { VertexArray, log } from '@luma.gl/core';\nimport { getBrowser } from '@probe.gl/env';\n/** VertexArrayObject wrapper */\nexport class WebGPUVertexArray extends VertexArray {\n get [Symbol.toStringTag]() {\n return 'WebGPUVertexArray';\n }\n device;\n /** Vertex Array is a helper class under WebGPU */\n handle;\n // Create a VertexArray\n constructor(device, props) {\n super(device, props);\n this.device = device;\n }\n destroy() { }\n /**\n * Set an elements buffer, for indexed rendering.\n * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.\n */\n setIndexBuffer(buffer) {\n // assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n this.indexBuffer = buffer;\n }\n /** Set a bufferSlot in vertex attributes array to a buffer, enables the bufferSlot, sets divisor */\n setBuffer(bufferSlot, buffer) {\n // Sanity check target\n // if (buffer.glUsage === GL.ELEMENT_ARRAY_BUFFER) {\n // throw new Error('Use setIndexBuffer');\n // }\n this.attributes[bufferSlot] = buffer;\n }\n bindBeforeRender(renderPass, firstIndex, indexCount) {\n const webgpuRenderPass = renderPass;\n const webgpuIndexBuffer = this.indexBuffer;\n if (webgpuIndexBuffer?.handle) {\n // Note we can't unset an index buffer\n log.warn('setting index buffer', webgpuIndexBuffer?.handle, webgpuIndexBuffer?.indexType)();\n webgpuRenderPass.handle.setIndexBuffer(webgpuIndexBuffer?.handle, \n // @ts-expect-error TODO - we must enforce type\n webgpuIndexBuffer?.indexType);\n }\n for (let location = 0; location < this.maxVertexAttributes; location++) {\n const webgpuBuffer = this.attributes[location];\n if (webgpuBuffer?.handle) {\n log.warn(`setting vertex buffer ${location}`, webgpuBuffer?.handle)();\n webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer?.handle);\n }\n }\n // TODO - emit warnings/errors/throw if constants have been set on this vertex array\n }\n unbindAfterRender(renderPass) {\n // On WebGPU we don't need to unbind.\n // In fact we can't easily do it. setIndexBuffer/setVertexBuffer don't accept null.\n // Unbinding presumably happens automatically when the render pass is ended.\n }\n // DEPRECATED METHODS\n /**\n * @deprecated is this even an issue for WebGPU?\n * Attribute 0 can not be disable on most desktop OpenGL based browsers\n */\n static isConstantAttributeZeroSupported(device) {\n return getBrowser() === 'Chrome';\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { CanvasContext, log } from '@luma.gl/core';\nimport { getWebGPUTextureFormat } from \"./helpers/convert-texture-format.js\";\nimport { WebGPUFramebuffer } from \"./resources/webgpu-framebuffer.js\";\n/**\n * Holds a WebGPU Canvas Context\n * The primary job of the CanvasContext is to generate textures for rendering into the current canvas\n * It also manages canvas sizing calculations and resizing.\n */\nexport class WebGPUCanvasContext extends CanvasContext {\n device;\n gpuCanvasContext;\n /** Format of returned textures: \"bgra8unorm\", \"rgba8unorm\", \"rgba16float\". */\n format = navigator.gpu.getPreferredCanvasFormat();\n /** Default stencil format for depth textures */\n depthStencilFormat = 'depth24plus';\n depthStencilAttachment = null;\n constructor(device, adapter, props) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu');\n // TODO this has been replaced\n // this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n this.format = 'bgra8unorm';\n }\n /** Destroy any textures produced while configured and remove the context configuration. */\n destroy() {\n this.gpuCanvasContext.unconfigure();\n }\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer() {\n // Ensure the canvas context size is updated\n this.update();\n // Wrap the current canvas context texture in a luma.gl texture\n // const currentColorAttachment = this.device.createTexture({\n // id: 'default-render-target',\n // handle: this.gpuCanvasContext.getCurrentTexture(),\n // format: this.format,\n // width: this.width,\n // height: this.height\n // });\n // Wrap the current canvas context texture in a luma.gl texture\n const currentColorAttachment = this.getCurrentTexture();\n this.width = currentColorAttachment.width;\n this.height = currentColorAttachment.height;\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n const sizeChanged = width !== this.width || height !== this.height;\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // Can be used to define e.g. -srgb views\n // viewFormats: [...]\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n }\n resize(options) {\n this.update();\n if (!this.device.handle)\n return;\n // Resize browser context .\n if (this.canvas) {\n const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);\n this.setDevicePixelRatio(devicePixelRatio, options);\n return;\n }\n }\n /** Wrap the current canvas context texture in a luma.gl texture */\n getCurrentTexture() {\n return this.device.createTexture({\n id: `${this.id}#color-texture`,\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format\n });\n }\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: `${this.id}#depth-stencil-texture`,\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { QuerySet } from '@luma.gl/core';\n/**\n * Immutable\n */\nexport class WebGPUQuerySet extends QuerySet {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.createQuerySet({\n type: this.props.type,\n count: this.props.count\n });\n this.handle.label = this.props.id;\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,IAAAA,gBAA6B;;;ACA7B,IAAAC,gBAAuC;;;ACAvC,kBAAuB;AACvB,SAAS,cAAc,OAAO;AAJ9B;AAKI,SAAO,MAAM,gBAAc,WAAM,SAAN,mBAAY,eAAc;AACzD;AACO,IAAM,eAAN,cAA2B,mBAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,QAAQ,OAAO;AACvB,UAAM,QAAQ,KAAK;AACnB,SAAK,SAAS;AACd,SAAK,aAAa,cAAc,KAAK;AACrC,UAAM,YAAY,QAAQ,MAAM,IAAI;AAEpC,UAAM,OAAO,KAAK,KAAK,KAAK,aAAa,CAAC,IAAI;AAC9C,SAAK,SACD,KAAK,MAAM,UACP,KAAK,OAAO,OAAO,aAAa;AAAA,MAC5B;AAAA;AAAA,MAEA,OAAO,KAAK,MAAM,SAAS,eAAe,SAAS,eAAe;AAAA,MAClE,kBAAkB,KAAK,MAAM,oBAAoB;AAAA,MACjD,OAAO,KAAK,MAAM;AAAA,IACtB,CAAC;AACT,QAAI,MAAM,MAAM;AACZ,WAAK,aAAa,MAAM,IAAI;AAAA,IAEhC;AACA,QAAI,aAAa,CAAC,MAAM,kBAAkB;AACtC,WAAK,OAAO,MAAM;AAAA,IACtB;AAAA,EACJ;AAAA,EACA,UAAU;AAnCd;AAoCQ,eAAK,WAAL,mBAAa;AAEb,SAAK,SAAS;AAAA,EAClB;AAAA;AAAA,EAEA,MAAM,MAAM,aAAa,GAAG;AACxB,SAAK,OAAO,OAAO,MAAM,YAAY,KAAK,QAAQ,Y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AAA,EACX;AAAA,EACA,MAAM,OAAO,QAAQ;AACjB,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC5D;AACJ;AACO,IAAM,gBAAgB,IAAI,cAAc;",
4
+ "sourcesContent": ["// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { webgpuAdapter } from \"./adapter/webgpu-adapter.js\";\n// WEBGPU CLASSES (typically not accessed directly)\nexport { WebGPUDevice } from \"./adapter/webgpu-device.js\";\nexport { WebGPUBuffer } from \"./adapter/resources/webgpu-buffer.js\";\nexport { WebGPUTexture } from \"./adapter/resources/webgpu-texture.js\";\nexport { WebGPUSampler } from \"./adapter/resources/webgpu-sampler.js\";\nexport { WebGPUShader } from \"./adapter/resources/webgpu-shader.js\";\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Adapter, log } from '@luma.gl/core';\nimport { WebGPUDevice } from \"./webgpu-device.js\";\n// / <reference types=\"@webgpu/types\" />\nexport class WebGPUAdapter extends Adapter {\n /** type of device's created by this adapter */\n type = 'webgpu';\n constructor() {\n super();\n // @ts-ignore For backwards compatibility luma.registerDevices\n WebGPUDevice.adapter = this;\n }\n /** Check if WebGPU is available */\n isSupported() {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n async create(props) {\n if (!navigator.gpu) {\n throw new Error('WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu');\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(2, 'Adapter available', adapterInfo)();\n const requiredFeatures = [];\n const requiredLimits = {};\n if (props._requestMaxLimits) {\n // Require all features\n requiredFeatures.push(...Array.from(adapter.features));\n // Require all limits\n // Filter out chrome specific keys (avoid crash)\n const limits = Object.keys(adapter.limits).filter(key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key));\n for (const key of limits) {\n const limit = key;\n const value = adapter.limits[limit];\n if (typeof value === 'number') {\n requiredLimits[limit] = value;\n }\n }\n }\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures,\n requiredLimits\n });\n log.probe(1, 'GPUDevice available')();\n const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);\n log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n async attach(handle) {\n throw new Error('WebGPUAdapter.attach() not implemented');\n }\n}\nexport const webgpuAdapter = new WebGPUAdapter();\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Device, DeviceFeatures } from '@luma.gl/core';\nimport { WebGPUBuffer } from \"./resources/webgpu-buffer.js\";\nimport { WebGPUTexture } from \"./resources/webgpu-texture.js\";\nimport { WebGPUExternalTexture } from \"./resources/webgpu-external-texture.js\";\nimport { WebGPUSampler } from \"./resources/webgpu-sampler.js\";\nimport { WebGPUShader } from \"./resources/webgpu-shader.js\";\nimport { WebGPURenderPipeline } from \"./resources/webgpu-render-pipeline.js\";\nimport { WebGPUFramebuffer } from \"./resources/webgpu-framebuffer.js\";\nimport { WebGPUComputePipeline } from \"./resources/webgpu-compute-pipeline.js\";\nimport { WebGPURenderPass } from \"./resources/webgpu-render-pass.js\";\nimport { WebGPUComputePass } from \"./resources/webgpu-compute-pass.js\";\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport { WebGPUVertexArray } from \"./resources/webgpu-vertex-array.js\";\nimport { WebGPUCanvasContext } from \"./webgpu-canvas-context.js\";\nimport { WebGPUQuerySet } from \"./resources/webgpu-query-set.js\";\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n /** type of this device */\n type = 'webgpu';\n /** The underlying WebGPU device */\n handle;\n /* The underlying WebGPU adapter */\n adapter;\n /* The underlying WebGPU adapter's info */\n adapterInfo;\n features;\n info;\n limits;\n lost;\n canvasContext = null;\n _isLost = false;\n commandEncoder = null;\n renderPass = null;\n constructor(props, device, adapter, adapterInfo) {\n super({ ...props, id: props.id || 'webgpu-device' });\n this.handle = device;\n this.adapter = adapter;\n this.adapterInfo = adapterInfo;\n this.info = this._getInfo();\n this.features = this._getFeatures();\n this.limits = this.handle.limits;\n // Listen for uncaptured WebGPU errors\n device.addEventListener('uncapturederror', (event) => {\n // TODO is this the right way to make sure the error is an Error instance?\n const errorMessage = event instanceof GPUUncapturedErrorEvent ? event.error.message : 'Unknown error';\n this.error(new Error(errorMessage));\n });\n // \"Context\" loss handling\n this.lost = new Promise(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({ reason: 'destroyed', message: lostInfo.message });\n });\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n if (props.createCanvasContext) {\n const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);\n }\n }\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n destroy() {\n this.handle.destroy();\n }\n isTextureFormatSupported(format) {\n return !format.includes('webgl');\n }\n /** @todo implement proper check? */\n isTextureFormatFilterable(format) {\n return (this.isTextureFormatSupported(format) &&\n !format.startsWith('depth') &&\n !format.startsWith('stencil'));\n }\n /** @todo implement proper check? */\n isTextureFormatRenderable(format) {\n return this.isTextureFormatSupported(format);\n }\n get isLost() {\n return this._isLost;\n }\n createBuffer(props) {\n const newProps = this._normalizeBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n createTexture(props) {\n return new WebGPUTexture(this, props);\n }\n createExternalTexture(props) {\n return new WebGPUExternalTexture(this, props);\n }\n createShader(props) {\n return new WebGPUShader(this, props);\n }\n createSampler(props) {\n return new WebGPUSampler(this, props);\n }\n createRenderPipeline(props) {\n return new WebGPURenderPipeline(this, props);\n }\n createFramebuffer(props) {\n return new WebGPUFramebuffer(this, props);\n }\n createComputePipeline(props) {\n return new WebGPUComputePipeline(this, props);\n }\n createVertexArray(props) {\n return new WebGPUVertexArray(this, props);\n }\n // WebGPU specifics\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props) {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n beginComputePass(props) {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n createTransformFeedback(props) {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n createQuerySet(props) {\n return new WebGPUQuerySet(this, props);\n }\n createCanvasContext(props) {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n submit() {\n // this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n // this.renderPass = null;\n }\n // PRIVATE METHODS\n _getInfo() {\n const [driver, driverVersion] = (this.adapterInfo.driver || '').split(' Version ');\n // See https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates\n const vendor = this.adapterInfo.vendor || this.adapter.__brand || 'unknown';\n const renderer = driver || '';\n const version = driverVersion || '';\n const gpu = vendor === 'apple' ? 'apple' : 'unknown'; // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n const gpuArchitecture = this.adapterInfo.architecture || 'unknown';\n const gpuBackend = this.adapterInfo.backend || 'unknown';\n const gpuType = (this.adapterInfo.type || '').split(' ')[0].toLowerCase() || 'unknown';\n return {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu,\n gpuType,\n gpuBackend,\n gpuArchitecture,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n }\n _getFeatures() {\n // Initialize with actual WebGPU Features (note that unknown features may not be in DeviceFeature type)\n const features = new Set(this.handle.features);\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n // Some subsets of WebGPU extensions correspond to WebGL extensions\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n const WEBGPU_ALWAYS_FEATURES = [\n 'timer-query-webgl',\n 'compilation-status-async-webgl',\n 'float32-renderable-webgl',\n 'float16-renderable-webgl',\n 'norm16-renderable-webgl',\n 'texture-filterable-anisotropic-webgl',\n 'shader-noperspective-interpolation-webgl'\n ];\n for (const feature of WEBGPU_ALWAYS_FEATURES) {\n features.add(feature);\n }\n return new DeviceFeatures(Array.from(features), this.props._disabledFeatures);\n }\n copyExternalImageToTexture(options) {\n const { source, sourceX = 0, sourceY = 0, texture, mipLevel = 0, aspect = 'all', colorSpace = 'display-p3', premultipliedAlpha = false, \n // destinationX,\n // destinationY,\n // desitnationZ,\n width = texture.width, height = texture.height, depth = 1 } = options;\n const webGpuTexture = texture;\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n }, \n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n }, \n // copySize: GPUExtent3D\n [width, height, depth]);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer } from '@luma.gl/core';\nfunction getByteLength(props) {\n return props.byteLength || props.data?.byteLength || 0;\n}\nexport class WebGPUBuffer extends Buffer {\n device;\n handle;\n byteLength;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n // WebGPU buffers must be aligned to 4 bytes\n const size = Math.ceil(this.byteLength / 4) * 4;\n this.handle =\n this.props.handle ||\n this.device.handle.createBuffer({\n size,\n // usage defaults to vertex\n usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n // WebGPU provides multiple ways to write a buffer...\n write(data, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(this.handle, byteOffset, data.buffer, data.byteOffset, data.byteLength);\n }\n async readAsync(byteOffset = 0, byteLength = this.byteLength) {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {\n usage: Buffer.MAP_READ | Buffer.COPY_DST,\n byteLength\n });\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n return new Uint8Array(arrayBuffer);\n }\n _writeMapped(typedArray) {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n // WEBGPU API\n mapAsync(mode, offset = 0, size) {\n return this.handle.mapAsync(mode, offset, size);\n }\n getMappedRange(offset = 0, size) {\n return this.handle.getMappedRange(offset, size);\n }\n unmap() {\n this.handle.unmap();\n }\n}\n/*\n// Convenience API\n /** Read data from the buffer *\n async readAsync(options: {\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<ArrayBuffer> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_READ, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n if (options.unmap ?? true) {\n this.unmap();\n }\n return arrayBuffer;\n }\n\n /** Write data to the buffer *\n async writeAsync(options: {\n data: ArrayBuffer,\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<void> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_WRITE, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n const destArray = new Uint8Array(arrayBuffer);\n const srcArray = new Uint8Array(options.data);\n destArray.set(srcArray);\n if (options.unmap ?? true) {\n this.unmap();\n }\n }\n */\n// Mapped API (WebGPU)\n/** Maps the memory so that it can be read *\n // abstract mapAsync(mode, byteOffset, byteLength): Promise<void>\n\n /** Get the mapped range of data for reading or writing *\n // abstract getMappedRange(byteOffset, byteLength): ArrayBuffer;\n\n /** unmap makes the contents of the buffer available to the GPU again *\n // abstract unmap(): void;\n*/\n", "import { Texture } from '@luma.gl/core';\nimport { getWebGPUTextureFormat } from \"../helpers/convert-texture-format.js\";\nimport { WebGPUSampler } from \"./webgpu-sampler.js\";\nimport { WebGPUTextureView } from \"./webgpu-texture-view.js\";\nconst BASE_DIMENSIONS = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n cube: '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\nexport class WebGPUTexture extends Texture {\n device;\n handle;\n sampler;\n view;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Texture base class strips out the data prop, so we need to add it back in\n const propsWithData = { ...this.props };\n if (props.data) {\n propsWithData.data = props.data;\n }\n this.initialize(propsWithData);\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n createView(props) {\n return new WebGPUTextureView(this.device, { ...props, texture: this });\n }\n initialize(props) {\n // @ts-expect-error\n this.handle = this.props.handle || this.createHandle();\n this.handle.label ||= this.id;\n if (this.props.data) {\n if (Texture.isExternalImage(this.props.data)) {\n this.copyExternalImage({ image: this.props.data });\n }\n else {\n this.setData({ data: this.props.data });\n }\n }\n this.width = this.handle.width;\n this.height = this.handle.height;\n // Why not just read all properties directly from the texture\n // this.depthOrArrayLayers = this.handle.depthOrArrayLayers;\n // this.mipLevelCount = this.handle.mipLevelCount;\n // this.sampleCount = this.handle.sampleCount;\n // this.dimension = this.handle.dimension;\n // this.format = this.handle.format;\n // this.usage = this.handle.usage;\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler =\n props.sampler instanceof WebGPUSampler\n ? props.sampler\n : new WebGPUSampler(this.device, props.sampler || {});\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n // @ts-expect-error\n this.view = new WebGPUTextureView(this.device, { ...this.props, texture: this });\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n }\n createHandle() {\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n return this.device.handle.createTexture({\n label: this.id,\n size: {\n width,\n height,\n depthOrArrayLayers: this.depth\n },\n usage: this.props.usage || Texture.TEXTURE | Texture.COPY_DST,\n dimension: BASE_DIMENSIONS[this.dimension],\n format: getWebGPUTextureFormat(this.format),\n mipLevelCount: this.mipLevels,\n sampleCount: this.props.samples\n });\n }\n /** @deprecated - intention is to use the createView public API */\n createGPUTextureView() {\n return this.handle.createView({ label: this.id });\n }\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler) {\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n setTexture1DData(data) {\n throw new Error('not implemented');\n }\n setTexture2DData(lodData, depth, target) {\n throw new Error('not implemented');\n }\n setTexture3DData(lodData, depth, target) {\n throw new Error('not implemented');\n }\n setTextureCubeData(data, depth) {\n throw new Error('not implemented');\n }\n setTextureArrayData(data) {\n throw new Error('not implemented');\n }\n setTextureCubeArrayData(data) {\n throw new Error('not implemented');\n }\n setData(options) {\n if (ArrayBuffer.isView(options.data)) {\n const clampedArray = new Uint8ClampedArray(options.data.buffer);\n // TODO - pass through src data color space as ImageData Options?\n const image = new ImageData(clampedArray, this.width, this.height);\n return this.copyExternalImage({ image });\n }\n throw new Error('Texture.setData: Use CommandEncoder to upload data to texture in WebGPU');\n }\n copyExternalImage(options) {\n const size = Texture.getExternalImageSize(options.image);\n const opts = { ...Texture.defaultCopyExternalImageOptions, ...size, ...options };\n const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha, flipY } = opts;\n // TODO - max out width\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source: image,\n origin: [sourceX, sourceY],\n flipY\n }, \n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n }, \n // copySize: GPUExtent3D\n [width, height, depth]);\n return { width, height };\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/** Ensure a texture format is WebGPU compatible */\nexport function getWebGPUTextureFormat(format) {\n if (format.includes('webgl')) {\n throw new Error('webgl-only format');\n }\n return format;\n}\n", "// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\nimport { Sampler } from '@luma.gl/core';\n/**\n * A WebGPU sampler object\n */\nexport class WebGPUSampler extends Sampler {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Prepare sampler props. Mostly identical\n const samplerDescriptor = {\n ...this.props,\n mipmapFilter: undefined\n };\n // props.compare automatically turns this into a comparison sampler\n if (props.type !== 'comparison-sampler') {\n delete samplerDescriptor.compare;\n }\n // disable mipmapFilter if not set\n if (props.mipmapFilter && props.mipmapFilter !== 'none') {\n samplerDescriptor.mipmapFilter = props.mipmapFilter;\n }\n this.handle = this.handle || this.device.handle.createSampler(samplerDescriptor);\n this.handle.label = this.props.id;\n }\n destroy() {\n // GPUSampler does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TextureView } from '@luma.gl/core';\n/**\n *\n */\nexport class WebGPUTextureView extends TextureView {\n device;\n handle;\n texture;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.texture = props.texture;\n this.handle =\n this.handle ||\n this.texture.handle.createView({\n format: (props.format || this.texture.format),\n dimension: props.dimension || this.texture.dimension,\n aspect: props.aspect,\n baseMipLevel: props.baseMipLevel,\n mipLevelCount: props.mipLevelCount, // GPUIntegerCoordinate;\n baseArrayLayer: props.baseArrayLayer, // GPUIntegerCoordinate;\n arrayLayerCount: props.arrayLayerCount // GPUIntegerCoordinate;\n });\n this.handle.label = this.props.id;\n }\n destroy() {\n // GPUTextureView does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ExternalTexture } from '@luma.gl/core';\nimport { WebGPUSampler } from \"./webgpu-sampler.js\";\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport class WebGPUExternalTexture extends ExternalTexture {\n device;\n handle;\n sampler;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n // @ts-expect-error\n this.sampler = null;\n }\n destroy() {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n /** Set default sampler */\n setSampler(sampler) {\n // We can accept a sampler instance or set of props;\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Shader, log } from '@luma.gl/core';\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.device.handle.pushErrorScope('validation');\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n get asyncCompilationStatus() {\n return this.getCompilationInfo().then(() => this.compilationStatus);\n }\n async _checkCompilationError(errorScope) {\n const error = (await errorScope);\n if (error) {\n // The `Shader` base class will determine if debug window should be opened based on props\n this.debugShader();\n const shaderLog = await this.getCompilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n destroy() {\n // Note: WebGPU does not offer a method to destroy shaders\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n /** Returns compilation info for this shader */\n async getCompilationInfo() {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n // PRIVATE METHODS\n createHandle() {\n const { source } = this.props;\n const isGLSL = source.includes('#version');\n if (this.props.language === 'glsl' || isGLSL) {\n throw new Error('GLSL shaders are not supported in WebGPU');\n }\n return this.device.handle.createShaderModule({ code: source });\n }\n}\n", "// luma.gl MIT license\nimport { RenderPipeline, log } from '@luma.gl/core';\nimport { applyParametersToRenderPipelineDescriptor } from \"../helpers/webgpu-parameters.js\";\nimport { getWebGPUTextureFormat } from \"../helpers/convert-texture-format.js\";\nimport { getBindGroup } from \"../helpers/get-bind-group.js\";\nimport { getVertexBufferLayout } from \"../helpers/get-vertex-buffer-layout.js\";\n// RENDER PIPELINE\n/** Creates a new render pipeline when parameters change */\nexport class WebGPURenderPipeline extends RenderPipeline {\n device;\n handle;\n vs;\n fs = null;\n /** For internal use to create BindGroups */\n _bindings;\n _bindGroupLayout = null;\n _bindGroup = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle;\n if (!this.handle) {\n const descriptor = this._getRenderPipelineDescriptor();\n log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();\n log.probe(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n this.handle = this.device.handle.createRenderPipeline(descriptor);\n }\n this.handle.label = this.props.id;\n this.vs = props.vs;\n this.fs = props.fs;\n this._bindings = { ...this.props.bindings };\n }\n destroy() {\n // WebGPURenderPipeline has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings) {\n Object.assign(this._bindings, bindings);\n }\n /** @todo - should this be moved to renderpass? */\n draw(options) {\n const webgpuRenderPass = options.renderPass;\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n // Set attributes\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.bindBeforeRender(options.renderPass);\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);\n }\n else {\n webgpuRenderPass.handle.draw(options.vertexCount || 0, options.instanceCount || 1, // If 0, nothing will be drawn\n options.firstInstance);\n }\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.unbindAfterRender(options.renderPass);\n return true;\n }\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n if (this.shaderLayout.bindings.length === 0) {\n return null;\n }\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n // Set up the bindings\n // TODO what if bindings change? We need to rebuild the bind group!\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n return this._bindGroup;\n }\n /**\n * Populate the complex WebGPU GPURenderPipelineDescriptor\n */\n _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex = {\n module: this.props.vs.handle,\n entryPoint: this.props.vertexEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.shaderLayout, this.props.bufferLayout)\n };\n // Set up the fragment stage\n const fragment = {\n module: this.props.fs.handle,\n entryPoint: this.props.fragmentEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device.getCanvasContext().format)\n }\n ]\n };\n // Create a partially populated descriptor\n const descriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: 'auto'\n };\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n return descriptor;\n }\n}\n/**\n_setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.shaderLayout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferLayout)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n *\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nfunction addDepthStencil(descriptor) {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: false,\n depthCompare: 'less-equal'\n };\n return descriptor.depthStencil;\n}\nfunction addDepthStencilFront(descriptor) {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilFront;\n}\nfunction addDepthStencilBack(descriptor) {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilBack;\n}\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\n// @ts-expect-error\nexport const PARAMETER_TABLE = {\n // RASTERIZATION PARAMETERS\n cullMode: (parameter, value, descriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n frontFace: (parameter, value, descriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n // DEPTH\n depthWriteEnabled: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n },\n depthCompare: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n depthFormat: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n depthBias: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n depthBiasSlopeScale: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n depthBiasClamp: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n // STENCIL\n stencilReadMask: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n stencilWriteMask: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n stencilCompare: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.compare = value;\n stencilBack.compare = value;\n },\n stencilPassOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.passOp = value;\n stencilBack.passOp = value;\n },\n stencilFailOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.failOp = value;\n stencilBack.failOp = value;\n },\n stencilDepthFailOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.depthFailOp = value;\n stencilBack.depthFailOp = value;\n },\n // MULTISAMPLE\n sampleCount: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n sampleMask: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n sampleAlphaToCoverageEnabled: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n // COLOR\n colorMask: (parameter, value, descriptor) => {\n const targets = addColorState(descriptor);\n targets[0].writeMask = value;\n },\n blendColorOperation: (parameter, value, descriptor) => {\n addColorState(descriptor);\n // const targets = addColorState(descriptor);\n // const target = targets[0];\n // const blend: GPUBlendState = target.blend || {color: {alpha: 0}};\n // blend.color = blend.color || {};\n // target.blend.color.operation = value;\n }\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n \n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n \n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n \n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n \n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\nconst DEFAULT_PIPELINE_DESCRIPTOR = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n vertex: {\n module: undefined,\n entryPoint: 'main'\n },\n fragment: {\n module: undefined,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n },\n layout: 'auto'\n};\nexport function applyParametersToRenderPipelineDescriptor(pipelineDescriptor, parameters = {}) {\n // Apply defaults\n Object.assign(pipelineDescriptor, { ...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor });\n setParameters(pipelineDescriptor, parameters);\n}\n// Apply any supplied parameters\nfunction setParameters(pipelineDescriptor, parameters) {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\nfunction addColorState(descriptor) {\n // @ts-ignore\n descriptor.fragment.targets = descriptor.fragment?.targets || [];\n if (!Array.isArray(descriptor.fragment?.targets)) {\n throw new Error('colorstate');\n }\n if (descriptor.fragment?.targets?.length === 0) {\n descriptor.fragment.targets?.push({});\n }\n return descriptor.fragment?.targets;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer, Sampler, Texture, log } from '@luma.gl/core';\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(device, layout, bindings) {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {\n const entries = getBindGroupEntries(bindings, shaderLayout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\nexport function getShaderLayoutBinding(shaderLayout, bindingName) {\n const bindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName || `${binding.name}uniforms` === bindingName.toLocaleLowerCase());\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout || null;\n}\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(bindings, shaderLayout) {\n const entries = [];\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n return entries;\n}\nfunction getBindGroupEntry(binding, index) {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: binding.handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: binding.handle\n };\n }\n else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: binding.handle.createView({ label: 'bind-group-auto-created' })\n };\n }\n throw new Error('invalid binding');\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { log, decodeVertexFormat } from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format) {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format;\n}\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(shaderLayout, bufferLayout) {\n const vertexBufferLayouts = [];\n const usedAttributes = new Set();\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes = [];\n // TODO verify that all stepModes for one buffer are the same\n let stepMode = 'vertex';\n let byteStride = 0;\n // @ts-ignore\n const format = mapping.format;\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n // @ts-ignore\n const location = attributeLayout?.location;\n stepMode =\n attributeLayout?.stepMode ||\n (attributeLayout?.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),\n offset: attributeMapping.byteOffset,\n shaderLocation: location\n });\n byteStride += decodeVertexFormat(format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n }\n else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = decodeVertexFormat(format).byteLength;\n stepMode =\n attributeLayout.stepMode ||\n (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode,\n attributes: vertexAttributes\n });\n }\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat('float32x3').byteLength,\n stepMode: attribute.stepMode || (attribute.name.startsWith('instance') ? 'instance' : 'vertex'),\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n return vertexBufferLayouts;\n}\nexport function getBufferSlots(shaderLayout, bufferLayout) {\n const usedAttributes = new Set();\n let bufferSlot = 0;\n const bufferSlots = {};\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes || []) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n }\n else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n return bufferSlots;\n}\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(shaderLayout, name, attributeNames) {\n const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name);\n if (!attribute) {\n log.warn(`Unknown attribute ${name}`)();\n return null;\n }\n if (attributeNames.has(name)) {\n throw new Error(`Duplicate attribute ${name}`);\n }\n attributeNames.add(name);\n return attribute;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Framebuffer } from '@luma.gl/core';\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class WebGPUFramebuffer extends Framebuffer {\n device;\n colorAttachments = [];\n depthStencilAttachment = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n }\n updateAttachments() {\n // WebGPU framebuffers are JS only objects, nothing to update\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ComputePipeline } from '@luma.gl/core';\nimport { getBindGroup } from \"../helpers/get-bind-group.js\";\n// COMPUTE PIPELINE\n/** Creates a new compute pipeline when parameters change */\nexport class WebGPUComputePipeline extends ComputePipeline {\n device;\n handle;\n /** For internal use to create BindGroups */\n _bindGroupLayout = null;\n _bindGroup = null;\n /** For internal use to create BindGroups */\n _bindings = {};\n constructor(device, props) {\n super(device, props);\n this.device = device;\n const webgpuShader = this.props.shader;\n this.handle =\n this.props.handle ||\n this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module: webgpuShader.handle,\n entryPoint: this.props.entryPoint,\n constants: this.props.constants\n },\n layout: 'auto'\n });\n }\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings) {\n Object.assign(this._bindings, bindings);\n }\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n // Set up the bindings\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n return this._bindGroup;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { RenderPass, log } from '@luma.gl/core';\nexport class WebGPURenderPass extends RenderPass {\n device;\n handle;\n /** Active pipeline */\n pipeline = null;\n constructor(device, props = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.getCanvasContext().getCurrentFramebuffer();\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n const webgpuQuerySet = props.timestampQuerySet;\n if (webgpuQuerySet) {\n renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;\n }\n if (device.features.has('timestamp-query')) {\n const webgpuTSQuerySet = props.timestampQuerySet;\n renderPassDescriptor.timestampWrites = webgpuTSQuerySet\n ? {\n querySet: webgpuTSQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n }\n : undefined;\n }\n if (!device.commandEncoder) {\n throw new Error('commandEncoder not available');\n }\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();\n log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();\n log.groupEnd(3)();\n }\n destroy() { }\n end() {\n this.handle.end();\n }\n setPipeline(pipeline) {\n this.pipeline = pipeline;\n this.handle.setPipeline(this.pipeline.handle);\n }\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings) {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n setIndexBuffer(buffer, indexFormat, offset = 0, size) {\n this.handle.setIndexBuffer(buffer.handle, indexFormat, offset, size);\n }\n setVertexBuffer(slot, buffer, offset = 0) {\n this.handle.setVertexBuffer(slot, buffer.handle, offset);\n }\n draw(options) {\n if (options.indexCount) {\n this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);\n }\n else {\n this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);\n }\n }\n drawIndirect() {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n setParameters(parameters) {\n const { blendConstant, stencilReference, scissorRect, viewport } = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);\n }\n }\n pushDebugGroup(groupLabel) {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup() {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel) {\n this.handle.insertDebugMarker(markerLabel);\n }\n beginOcclusionQuery(queryIndex) {\n this.handle.beginOcclusionQuery(queryIndex);\n }\n endOcclusionQuery() {\n this.handle.endOcclusionQuery();\n }\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n // INTERNAL\n /**\n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor.\n */\n getRenderPassDescriptor(framebuffer) {\n const renderPassDescriptor = {\n colorAttachments: []\n };\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map((colorAttachment, index) => ({\n // clear values\n loadOp: this.props.clearColor !== false ? 'clear' : 'load',\n colorClearValue: this.props.clearColors?.[index] || this.props.clearColor || RenderPass.defaultClearColor,\n storeOp: this.props.discard ? 'discard' : 'store',\n // ...colorAttachment,\n view: colorAttachment.handle\n }));\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n view: framebuffer.depthStencilAttachment.handle\n };\n const { depthStencilAttachment } = renderPassDescriptor;\n // DEPTH\n if (this.props.depthReadOnly) {\n depthStencilAttachment.depthReadOnly = true;\n }\n if (this.props.clearDepth !== false) {\n depthStencilAttachment.depthClearValue = this.props.clearDepth;\n }\n // STENCIL\n // if (this.props.clearStencil !== false) {\n // depthStencilAttachment.stencilClearValue = this.props.clearStencil;\n // }\n // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect\n const hasDepthAspect = true;\n if (hasDepthAspect) {\n depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';\n depthStencilAttachment.depthStoreOp = 'store'; // TODO - support 'discard'?\n }\n // WebGPU only wants us to set these parameters if the texture format actually has a stencil aspect\n const hasStencilAspect = false;\n if (hasStencilAspect) {\n depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';\n depthStencilAttachment.stencilStoreOp = 'store'; // TODO - support 'discard'?\n }\n }\n return renderPassDescriptor;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ComputePass } from '@luma.gl/core';\nexport class WebGPUComputePass extends ComputePass {\n device;\n handle;\n _webgpuPipeline = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Set up queries\n let timestampWrites;\n if (device.features.has('timestamp-query')) {\n const webgpuQuerySet = props.timestampQuerySet;\n if (webgpuQuerySet) {\n timestampWrites = {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n };\n }\n }\n this.handle =\n this.props.handle ||\n device.commandEncoder?.beginComputePass({\n label: this.props.id,\n timestampWrites\n });\n }\n /** @note no WebGPU destroy method, just gc */\n destroy() { }\n end() {\n this.handle.end();\n }\n setPipeline(pipeline) {\n const wgpuPipeline = pipeline;\n this.handle.setPipeline(wgpuPipeline.handle);\n this._webgpuPipeline = wgpuPipeline;\n this.setBindings([]);\n }\n /**\n * Sets an array of bindings (uniform buffers, samplers, textures, ...)\n * TODO - still some API confusion - does this method go here or on the pipeline?\n */\n setBindings(bindings) {\n // @ts-expect-error\n const bindGroup = this._webgpuPipeline._getBindGroup();\n this.handle.setBindGroup(0, bindGroup);\n }\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of work groups to dispatch.\n * @param y Y dimension of the grid of work groups to dispatch.\n * @param z Z dimension of the grid of work groups to dispatch.\n */\n dispatch(x, y, z) {\n this.handle.dispatchWorkgroups(x, y, z);\n }\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n *\n * Buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectBuffer\n * @param indirectOffset offset in buffer to the beginning of the dispatch data.\n */\n dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {\n const webgpuBuffer = indirectBuffer;\n this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);\n }\n pushDebugGroup(groupLabel) {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup() {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel) {\n this.handle.insertDebugMarker(markerLabel);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { VertexArray, log } from '@luma.gl/core';\nimport { getBrowser } from '@probe.gl/env';\n/** VertexArrayObject wrapper */\nexport class WebGPUVertexArray extends VertexArray {\n get [Symbol.toStringTag]() {\n return 'WebGPUVertexArray';\n }\n device;\n /** Vertex Array is a helper class under WebGPU */\n handle;\n // Create a VertexArray\n constructor(device, props) {\n super(device, props);\n this.device = device;\n }\n destroy() { }\n /**\n * Set an elements buffer, for indexed rendering.\n * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.\n */\n setIndexBuffer(buffer) {\n // assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n this.indexBuffer = buffer;\n }\n /** Set a bufferSlot in vertex attributes array to a buffer, enables the bufferSlot, sets divisor */\n setBuffer(bufferSlot, buffer) {\n // Sanity check target\n // if (buffer.glUsage === GL.ELEMENT_ARRAY_BUFFER) {\n // throw new Error('Use setIndexBuffer');\n // }\n this.attributes[bufferSlot] = buffer;\n }\n bindBeforeRender(renderPass, firstIndex, indexCount) {\n const webgpuRenderPass = renderPass;\n const webgpuIndexBuffer = this.indexBuffer;\n if (webgpuIndexBuffer?.handle) {\n // Note we can't unset an index buffer\n log.warn('setting index buffer', webgpuIndexBuffer?.handle, webgpuIndexBuffer?.indexType)();\n webgpuRenderPass.handle.setIndexBuffer(webgpuIndexBuffer?.handle, \n // @ts-expect-error TODO - we must enforce type\n webgpuIndexBuffer?.indexType);\n }\n for (let location = 0; location < this.maxVertexAttributes; location++) {\n const webgpuBuffer = this.attributes[location];\n if (webgpuBuffer?.handle) {\n log.warn(`setting vertex buffer ${location}`, webgpuBuffer?.handle)();\n webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer?.handle);\n }\n }\n // TODO - emit warnings/errors/throw if constants have been set on this vertex array\n }\n unbindAfterRender(renderPass) {\n // On WebGPU we don't need to unbind.\n // In fact we can't easily do it. setIndexBuffer/setVertexBuffer don't accept null.\n // Unbinding presumably happens automatically when the render pass is ended.\n }\n // DEPRECATED METHODS\n /**\n * @deprecated is this even an issue for WebGPU?\n * Attribute 0 can not be disable on most desktop OpenGL based browsers\n */\n static isConstantAttributeZeroSupported(device) {\n return getBrowser() === 'Chrome';\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { CanvasContext, log } from '@luma.gl/core';\nimport { getWebGPUTextureFormat } from \"./helpers/convert-texture-format.js\";\nimport { WebGPUFramebuffer } from \"./resources/webgpu-framebuffer.js\";\n/**\n * Holds a WebGPU Canvas Context\n * The primary job of the CanvasContext is to generate textures for rendering into the current canvas\n * It also manages canvas sizing calculations and resizing.\n */\nexport class WebGPUCanvasContext extends CanvasContext {\n device;\n gpuCanvasContext;\n /** Format of returned textures: \"bgra8unorm\", \"rgba8unorm\", \"rgba16float\". */\n format = navigator.gpu.getPreferredCanvasFormat();\n /** Default stencil format for depth textures */\n depthStencilFormat = 'depth24plus';\n depthStencilAttachment = null;\n constructor(device, adapter, props) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu');\n // TODO this has been replaced\n // this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n this.format = 'bgra8unorm';\n }\n /** Destroy any textures produced while configured and remove the context configuration. */\n destroy() {\n this.gpuCanvasContext.unconfigure();\n }\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer() {\n // Ensure the canvas context size is updated\n this.update();\n // Wrap the current canvas context texture in a luma.gl texture\n // const currentColorAttachment = this.device.createTexture({\n // id: 'default-render-target',\n // handle: this.gpuCanvasContext.getCurrentTexture(),\n // format: this.format,\n // width: this.width,\n // height: this.height\n // });\n // Wrap the current canvas context texture in a luma.gl texture\n const currentColorAttachment = this.getCurrentTexture();\n this.width = currentColorAttachment.width;\n this.height = currentColorAttachment.height;\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n const sizeChanged = width !== this.width || height !== this.height;\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // Can be used to define e.g. -srgb views\n // viewFormats: [...]\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n }\n resize(options) {\n this.update();\n if (!this.device.handle)\n return;\n // Resize browser context .\n if (this.canvas) {\n const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);\n this.setDevicePixelRatio(devicePixelRatio, options);\n return;\n }\n }\n /** Wrap the current canvas context texture in a luma.gl texture */\n getCurrentTexture() {\n return this.device.createTexture({\n id: `${this.id}#color-texture`,\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format\n });\n }\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: `${this.id}#depth-stencil-texture`,\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { QuerySet } from '@luma.gl/core';\n/**\n * Immutable\n */\nexport class WebGPUQuerySet extends QuerySet {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.createQuerySet({\n type: this.props.type,\n count: this.props.count\n });\n this.handle.label = this.props.id;\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,IAAAA,gBAA6B;;;ACA7B,IAAAC,gBAAuC;;;ACAvC,kBAAuB;AACvB,SAAS,cAAc,OAAO;AAJ9B;AAKI,SAAO,MAAM,gBAAc,WAAM,SAAN,mBAAY,eAAc;AACzD;AACO,IAAM,eAAN,cAA2B,mBAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,QAAQ,OAAO;AACvB,UAAM,QAAQ,KAAK;AACnB,SAAK,SAAS;AACd,SAAK,aAAa,cAAc,KAAK;AACrC,UAAM,YAAY,QAAQ,MAAM,IAAI;AAEpC,UAAM,OAAO,KAAK,KAAK,KAAK,aAAa,CAAC,IAAI;AAC9C,SAAK,SACD,KAAK,MAAM,UACP,KAAK,OAAO,OAAO,aAAa;AAAA,MAC5B;AAAA;AAAA,MAEA,OAAO,KAAK,MAAM,SAAS,eAAe,SAAS,eAAe;AAAA,MAClE,kBAAkB,KAAK,MAAM,oBAAoB;AAAA,MACjD,OAAO,KAAK,MAAM;AAAA,IACtB,CAAC;AACT,QAAI,MAAM,MAAM;AACZ,WAAK,aAAa,MAAM,IAAI;AAAA,IAEhC;AACA,QAAI,aAAa,CAAC,MAAM,kBAAkB;AACtC,WAAK,OAAO,MAAM;AAAA,IACtB;AAAA,EACJ;AAAA,EACA,UAAU;AAnCd;AAoCQ,eAAK,WAAL,mBAAa;AAEb,SAAK,SAAS;AAAA,EAClB;AAAA;AAAA,EAEA,MAAM,MAAM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AM,YAAY,MAAM,QAAQ,cAAc;AAAA,MAC1C;AAAA,MACA;AAAA,IACJ,CAAC;AACD,sBAAI,MAAM,GAAG,qBAAqB,EAAE;AACpC,UAAM,SAAS,IAAI,aAAa,OAAO,WAAW,SAAS,WAAW;AACtE,sBAAI,MAAM,GAAG,qFAAqF,EAAE;AACpG,sBAAI,MAAM,GAAG,OAAO,IAAI,EAAE;AAC1B,sBAAI,SAAS,CAAC,EAAE;AAChB,WAAO;AAAA,EACX;AAAA,EACA,MAAM,OAAO,QAAQ;AACjB,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC5D;AACJ;AACO,IAAM,gBAAgB,IAAI,cAAc;",
6
6
  "names": ["import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgpu",
3
- "version": "9.1.0-alpha.16",
3
+ "version": "9.1.0-alpha.18",
4
4
  "description": "WebGPU adapter for the luma.gl core API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,11 +37,11 @@
37
37
  "prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
38
38
  },
39
39
  "peerDependencies": {
40
- "@luma.gl/core": "9.1.0-alpha.14"
40
+ "@luma.gl/core": "9.1.0-alpha.17"
41
41
  },
42
42
  "dependencies": {
43
43
  "@probe.gl/env": "^4.0.8",
44
44
  "@webgpu/types": "^0.1.34"
45
45
  },
46
- "gitHead": "39eec40d12c826548b636c057fdb8572adfe611f"
46
+ "gitHead": "61c927cfdc3b96eb71aa014cbeac2bfe9375c0f6"
47
47
  }
@@ -172,14 +172,17 @@ export class WebGPURenderPass extends RenderPass {
172
172
  colorAttachments: []
173
173
  };
174
174
 
175
- renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({
176
- // clear values
177
- loadOp: this.props.clearColor !== false ? 'clear' : 'load',
178
- colorClearValue: this.props.clearColor || [0, 0, 0, 0],
179
- storeOp: this.props.discard ? 'discard' : 'store',
180
- // ...colorAttachment,
181
- view: colorAttachment.handle
182
- }));
175
+ renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(
176
+ (colorAttachment, index) => ({
177
+ // clear values
178
+ loadOp: this.props.clearColor !== false ? 'clear' : 'load',
179
+ colorClearValue:
180
+ this.props.clearColors?.[index] || this.props.clearColor || RenderPass.defaultClearColor,
181
+ storeOp: this.props.discard ? 'discard' : 'store',
182
+ // ...colorAttachment,
183
+ view: colorAttachment.handle
184
+ })
185
+ );
183
186
 
184
187
  if (framebuffer.depthStencilAttachment) {
185
188
  renderPassDescriptor.depthStencilAttachment = {
@@ -191,7 +194,13 @@ export class WebGPURenderPass extends RenderPass {
191
194
  if (this.props.depthReadOnly) {
192
195
  depthStencilAttachment.depthReadOnly = true;
193
196
  }
194
- depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;
197
+ if (this.props.clearDepth !== false) {
198
+ depthStencilAttachment.depthClearValue = this.props.clearDepth;
199
+ }
200
+ // STENCIL
201
+ // if (this.props.clearStencil !== false) {
202
+ // depthStencilAttachment.stencilClearValue = this.props.clearStencil;
203
+ // }
195
204
 
196
205
  // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect
197
206
  const hasDepthAspect = true;
@@ -9,7 +9,7 @@ export type WebGPUSamplerProps = SamplerProps & {
9
9
  };
10
10
 
11
11
  /**
12
- *
12
+ * A WebGPU sampler object
13
13
  */
14
14
  export class WebGPUSampler extends Sampler {
15
15
  readonly device: WebGPUDevice;
@@ -19,13 +19,23 @@ export class WebGPUSampler extends Sampler {
19
19
  super(device, props);
20
20
  this.device = device;
21
21
 
22
- // Prepare sampler props
23
- const samplerProps: Partial<WebGPUSamplerProps> = {...this.props};
24
- if (samplerProps.type !== 'comparison-sampler') {
25
- delete samplerProps.compare;
22
+ // Prepare sampler props. Mostly identical
23
+ const samplerDescriptor: Partial<GPUSamplerDescriptor> = {
24
+ ...this.props,
25
+ mipmapFilter: undefined
26
+ };
27
+
28
+ // props.compare automatically turns this into a comparison sampler
29
+ if (props.type !== 'comparison-sampler') {
30
+ delete samplerDescriptor.compare;
31
+ }
32
+
33
+ // disable mipmapFilter if not set
34
+ if (props.mipmapFilter && props.mipmapFilter !== 'none') {
35
+ samplerDescriptor.mipmapFilter = props.mipmapFilter;
26
36
  }
27
37
 
28
- this.handle = this.handle || this.device.handle.createSampler(samplerProps);
38
+ this.handle = this.handle || this.device.handle.createSampler(samplerDescriptor);
29
39
  this.handle.label = this.props.id;
30
40
  }
31
41
 
@@ -37,24 +37,20 @@ export class WebGPUTexture extends Texture {
37
37
  readonly device: WebGPUDevice;
38
38
  readonly handle: GPUTexture;
39
39
 
40
- override height: number = 1;
41
- override width: number = 1;
42
-
43
40
  sampler: WebGPUSampler;
44
41
  view: WebGPUTextureView;
45
42
 
46
- // static async createFromImageURL(src, usage = 0) {
47
- // const img = document.createElement('img');
48
- // img.src = src;
49
- // await img.decode();
50
- // return WebGPUTexture(img, usage);
51
- // }
52
-
53
43
  constructor(device: WebGPUDevice, props: TextureProps) {
54
- props = Texture._fixProps(props);
55
44
  super(device, props);
56
45
  this.device = device;
57
- this.initialize(props);
46
+
47
+ // Texture base class strips out the data prop, so we need to add it back in
48
+ const propsWithData = {...this.props};
49
+ if (props.data) {
50
+ propsWithData.data = props.data;
51
+ }
52
+
53
+ this.initialize(propsWithData);
58
54
  }
59
55
 
60
56
  override destroy(): void {
@@ -213,7 +209,8 @@ export class WebGPUTexture extends Texture {
213
209
  z,
214
210
  aspect,
215
211
  colorSpace,
216
- premultipliedAlpha
212
+ premultipliedAlpha,
213
+ flipY
217
214
  } = opts;
218
215
 
219
216
  // TODO - max out width
@@ -222,7 +219,8 @@ export class WebGPUTexture extends Texture {
222
219
  // source: GPUImageCopyExternalImage
223
220
  {
224
221
  source: image,
225
- origin: [sourceX, sourceY]
222
+ origin: [sourceX, sourceY],
223
+ flipY
226
224
  },
227
225
  // destination: GPUImageCopyTextureTagged
228
226
  {