wgsl-renderer 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -322,12 +322,13 @@ var TextureManager = class {
322
322
  this.width = width;
323
323
  this.height = height;
324
324
  }
325
- createTexture(name, format) {
325
+ createTexture(name, format, mipLevelCount) {
326
326
  if (this.textures.has(name)) this.textures.get(name).destroy();
327
327
  const texture = this.device.createTexture({
328
328
  size: [this.width, this.height],
329
329
  format: format || "bgra8unorm",
330
- usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
330
+ usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,
331
+ mipLevelCount: mipLevelCount || 1
331
332
  });
332
333
  this.textures.set(name, texture);
333
334
  return texture;
@@ -483,7 +484,8 @@ var WGSLRenderer = class {
483
484
  size: [size.width, size.height],
484
485
  format,
485
486
  usage,
486
- sampleCount: actualSampleCount
487
+ sampleCount: actualSampleCount,
488
+ mipLevelCount: ref.options?.mipLevelCount || 1
487
489
  });
488
490
  this.textureManager.setTexture(textureName, texture);
489
491
  }
@@ -8,12 +8,14 @@ declare class PassTextureRef {
8
8
  mipmaps?: boolean;
9
9
  sampleCount?: number;
10
10
  usage?: GPUTextureUsageFlags;
11
+ mipLevelCount?: number;
11
12
  };
12
13
  constructor(passName: string, options?: {
13
14
  format?: GPUTextureFormat;
14
15
  mipmaps?: boolean;
15
16
  sampleCount?: number;
16
17
  usage?: GPUTextureUsageFlags;
18
+ mipLevelCount?: number;
17
19
  });
18
20
  static is(obj: any): obj is PassTextureRef;
19
21
  static fromGPUBindingResource(resource: GPUBindingResource): PassTextureRef | null;
@@ -22,6 +24,7 @@ declare class PassTextureRef {
22
24
  mipmaps?: boolean;
23
25
  sampleCount?: number;
24
26
  usage?: GPUTextureUsageFlags;
27
+ mipLevelCount?: number;
25
28
  }): PassTextureRef;
26
29
  }
27
30
  //#endregion
@@ -172,6 +175,7 @@ declare class WGSLRenderer {
172
175
  mipmaps?: boolean;
173
176
  sampleCount?: number;
174
177
  usage?: GPUTextureUsageFlags;
178
+ mipLevelCount?: number;
175
179
  }): PassTextureRef;
176
180
  /**
177
181
  * Resolve a PassTextureRef to actual GPUTextureView with validation
package/dist/esm/index.js CHANGED
@@ -321,12 +321,13 @@ var TextureManager = class {
321
321
  this.width = width;
322
322
  this.height = height;
323
323
  }
324
- createTexture(name, format) {
324
+ createTexture(name, format, mipLevelCount) {
325
325
  if (this.textures.has(name)) this.textures.get(name).destroy();
326
326
  const texture = this.device.createTexture({
327
327
  size: [this.width, this.height],
328
328
  format: format || "bgra8unorm",
329
- usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
329
+ usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,
330
+ mipLevelCount: mipLevelCount || 1
330
331
  });
331
332
  this.textures.set(name, texture);
332
333
  return texture;
@@ -482,7 +483,8 @@ var WGSLRenderer = class {
482
483
  size: [size.width, size.height],
483
484
  format,
484
485
  usage,
485
- sampleCount: actualSampleCount
486
+ sampleCount: actualSampleCount,
487
+ mipLevelCount: ref.options?.mipLevelCount || 1
486
488
  });
487
489
  this.textureManager.setTexture(textureName, texture);
488
490
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgsl-renderer",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "A multi-pass renderer based on WebGPU and WGSL.",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",