wgsl-renderer 0.2.1 → 0.3.1
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 +7 -4
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -4
- package/package.json +1 -1
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;
|
|
@@ -461,7 +462,8 @@ var WGSLRenderer = class {
|
|
|
461
462
|
getPassTexture(passName, options) {
|
|
462
463
|
const pass = this.passes.find((pass$1) => pass$1.name === passName);
|
|
463
464
|
if (!pass) throw new Error(`Cannot find pass named '${passName}'. Available passes: [${this.passes.map((p) => p.name).join(", ")}]`);
|
|
464
|
-
|
|
465
|
+
const f = options?.format ?? "rgba8unorm";
|
|
466
|
+
if (pass.format && f !== pass.format) throw new Error(`Format must be set to ${pass.format}, pass name: '${passName}'`);
|
|
465
467
|
return PassTextureRef.create(passName, options);
|
|
466
468
|
}
|
|
467
469
|
/**
|
|
@@ -483,7 +485,8 @@ var WGSLRenderer = class {
|
|
|
483
485
|
size: [size.width, size.height],
|
|
484
486
|
format,
|
|
485
487
|
usage,
|
|
486
|
-
sampleCount: actualSampleCount
|
|
488
|
+
sampleCount: actualSampleCount,
|
|
489
|
+
mipLevelCount: ref.options?.mipLevelCount || 1
|
|
487
490
|
});
|
|
488
491
|
this.textureManager.setTexture(textureName, texture);
|
|
489
492
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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;
|
|
@@ -460,7 +461,8 @@ var WGSLRenderer = class {
|
|
|
460
461
|
getPassTexture(passName, options) {
|
|
461
462
|
const pass = this.passes.find((pass$1) => pass$1.name === passName);
|
|
462
463
|
if (!pass) throw new Error(`Cannot find pass named '${passName}'. Available passes: [${this.passes.map((p) => p.name).join(", ")}]`);
|
|
463
|
-
|
|
464
|
+
const f = options?.format ?? "rgba8unorm";
|
|
465
|
+
if (pass.format && f !== pass.format) throw new Error(`Format must be set to ${pass.format}, pass name: '${passName}'`);
|
|
464
466
|
return PassTextureRef.create(passName, options);
|
|
465
467
|
}
|
|
466
468
|
/**
|
|
@@ -482,7 +484,8 @@ var WGSLRenderer = class {
|
|
|
482
484
|
size: [size.width, size.height],
|
|
483
485
|
format,
|
|
484
486
|
usage,
|
|
485
|
-
sampleCount: actualSampleCount
|
|
487
|
+
sampleCount: actualSampleCount,
|
|
488
|
+
mipLevelCount: ref.options?.mipLevelCount || 1
|
|
486
489
|
});
|
|
487
490
|
this.textureManager.setTexture(textureName, texture);
|
|
488
491
|
}
|