@vgpu/render 0.0.1 → 0.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vgpu/render",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Render pipeline + render pass abstractions for vgpu.",
5
5
  "keywords": [
6
6
  "webgpu",
@@ -58,7 +58,7 @@
58
58
  ],
59
59
  "dependencies": {
60
60
  "wgpu-matrix": "^3.4.2",
61
- "@vgpu/core": "0.0.1"
61
+ "@vgpu/core": "0.0.2"
62
62
  },
63
63
  "vgpuExportBundleBudgetsGzipBytes": {
64
64
  ".": 49152,
@@ -1,4 +0,0 @@
1
- import type { ColorAttachmentSpec, RenderTargetMultiSpec, RenderTargetN } from "./types.ts";
2
- /** Creates an offscreen render target with N color textures and optional shared depth. */
3
- export declare function renderTargetMulti<const Specs extends readonly ColorAttachmentSpec[]>(spec: RenderTargetMultiSpec<Specs>): Promise<RenderTargetN<Specs>>;
4
- //# sourceMappingURL=render-target-multi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-target-multi.d.ts","sourceRoot":"","sources":["../../src/render-target/render-target-multi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAmB,qBAAqB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAU7G,0FAA0F;AAC1F,wBAAsB,iBAAiB,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,mBAAmB,EAAE,EACxF,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,GACjC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAkD/B"}
@@ -1,90 +0,0 @@
1
- import { ValidationError } from "@vgpu/core";
2
- const DEFAULT_CLEAR_COLOR = Object.freeze({ r: 0, g: 0, b: 0, a: 1 });
3
- const COLOR_RENDERABLE_FORMATS = new Set([
4
- "r8unorm", "r8snorm", "r8uint", "r8sint", "rg8unorm", "rg8snorm", "rg8uint", "rg8sint",
5
- "rgba8unorm", "rgba8unorm-srgb", "rgba8snorm", "rgba8uint", "rgba8sint", "bgra8unorm", "bgra8unorm-srgb",
6
- "rgb10a2uint", "rgb10a2unorm", "rg11b10ufloat", "rg32uint", "rg32sint", "rg32float",
7
- "rgba16uint", "rgba16sint", "rgba16float", "rgba32uint", "rgba32sint", "rgba32float",
8
- ]);
9
- /** Creates an offscreen render target with N color textures and optional shared depth. */
10
- export async function renderTargetMulti(spec) {
11
- validateSpec(spec);
12
- const size = [spec.size[0], spec.size[1]];
13
- const depthFormat = spec.depth === true ? "depth24plus" : spec.depth || undefined;
14
- const colors = spec.colors.map((color, index) => spec.device.createTexture({
15
- size,
16
- format: color.format,
17
- usage: ["render_attachment", "texture_binding"],
18
- sampleCount: 1,
19
- label: color.label ?? childLabel(spec.label, `color${index}`),
20
- }));
21
- const depth = depthFormat ? spec.device.createTexture({
22
- size,
23
- format: depthFormat,
24
- usage: ["render_attachment"],
25
- sampleCount: 1,
26
- label: childLabel(spec.label, "depth"),
27
- }) : undefined;
28
- const colorAttachments = Object.freeze(colors.map((color, index) => ({
29
- view: color.createView(),
30
- loadOp: "clear",
31
- storeOp: "store",
32
- clearValue: colorDict(spec.colors[index]?.clearColor),
33
- })));
34
- const depthStencilAttachment = depth ? {
35
- view: depth.createView(),
36
- depthLoadOp: "clear",
37
- depthStoreOp: "store",
38
- depthClearValue: 1,
39
- } : undefined;
40
- const colorTextures = Object.freeze(colors.map((color) => color.gpu));
41
- const gpu = Object.freeze({
42
- colorAttachments,
43
- colorAttachment: colorAttachments[0],
44
- depthStencilAttachment,
45
- colorTexture: colorTextures[0],
46
- colorTextures,
47
- depthTexture: depth?.gpu,
48
- });
49
- const frozenColors = Object.freeze(colors);
50
- return Object.freeze({
51
- color: colors[0],
52
- colors: frozenColors,
53
- depth,
54
- size,
55
- format: spec.colors[0]?.format,
56
- sampleCount: 1,
57
- label: spec.label,
58
- gpu,
59
- });
60
- }
61
- function validateSpec(spec) {
62
- const maybeMsaa = spec.msaa;
63
- if (maybeMsaa !== undefined && maybeMsaa !== false)
64
- throw invalidUsage("RenderTargetMultiSpec.msaa is not supported for MRT v2.");
65
- const size = spec.size;
66
- if (size.length !== 2 || !size.every((value) => Number.isInteger(value) && value > 0)) {
67
- throw invalidUsage("RenderTargetMultiSpec.size must be [width, height] with positive integer values.");
68
- }
69
- if (spec.colors.length < 1)
70
- throw invalidUsage("RenderTargetMultiSpec.colors must contain at least one color attachment.");
71
- for (const [index, color] of spec.colors.entries()) {
72
- if (!COLOR_RENDERABLE_FORMATS.has(color.format)) {
73
- throw invalidUsage(`RenderTargetMultiSpec.colors[${index}].format must be color-renderable; received ${color.format}.`);
74
- }
75
- }
76
- }
77
- function colorDict(color) {
78
- if (!color)
79
- return DEFAULT_CLEAR_COLOR;
80
- if (Array.isArray(color))
81
- return { r: color[0], g: color[1], b: color[2], a: color[3] };
82
- return color;
83
- }
84
- function childLabel(label, suffix) {
85
- return label ? `${label}.${suffix}` : undefined;
86
- }
87
- function invalidUsage(message) {
88
- return new ValidationError({ code: "VGPU-CORE-INVALID-USAGE", message, where: "renderTargetMulti" });
89
- }
90
- //# sourceMappingURL=render-target-multi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-target-multi.js","sourceRoot":"","sources":["../../src/render-target/render-target-multi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgB,MAAM,YAAY,CAAC;AAG3D,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACtE,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAmB;IACzD,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE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