@zephyr3d/editor 0.3.0 → 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/README.md +143 -0
- package/dist/assets/{index-BaUzUcND.js → index-IISR7uQv.js} +1 -1
- package/dist/assistant/zephyr-types-index.json +1 -1
- package/dist/index.html +2 -2
- package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
- package/dist/modules/zephyr3d_imgui.js +3 -3
- package/dist/modules/zephyr3d_imgui.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +1439 -1439
- package/dist/modules/zephyr3d_scene.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/bindgroup_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/buffer_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/commandqueue.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/uploadringbuffer.js.map +1 -1
- package/dist/vendor/zephyr3d/imgui/dist/imgui_impl.js.map +1 -1
- package/dist/vendor/zephyr3d/imgui/dist/renderer.js +3 -3
- package/dist/vendor/zephyr3d/imgui/dist/renderer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +135 -135
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/controller.js +146 -146
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/spring/spring_system.js +75 -75
- package/dist/vendor/zephyr3d/scene/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +184 -184
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/material.js +288 -288
- package/dist/vendor/zephyr3d/scene/dist/material/material.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resource_manager.js +93 -93
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resources.js +3 -3
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/types.js +22 -22
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/types.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/blueprint/material/ir.js +489 -489
- package/dist/vendor/zephyr3d/scene/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/types.js +4 -4
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\n\n// ─── Resource Descriptors ───────────────────────────────────────────────\n\n/**\n * Sizing mode for render graph textures.\n *\n * - 'absolute': fixed pixel dimensions\n * - 'backbuffer-relative': scaled relative to the backbuffer size\n *\n * @public\n */\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\n\n/**\n * Descriptor for a transient texture resource within the render graph.\n *\n * Transient textures are allocated and released automatically by the graph compiler.\n *\n * @public\n */\nexport interface RGTextureDesc {\n /** Debug label for this resource. */\n label?: string;\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\n format: TextureFormat;\n /** Sizing mode. Default 'backbuffer-relative'. */\n sizeMode?: RGSizeMode;\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\n width?: number;\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\n height?: number;\n /** Number of mip levels. Default 1. */\n mipLevels?: number;\n}\n\n// ─── Handles ────────────────────────────────────────────────────────────\n\n/**\n * Opaque handle referencing a resource within the render graph.\n *\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},\n * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers\n * used to declare dependencies between passes.\n *\n * @public\n */\nexport class RGHandle {\n /** @internal */\n readonly _id: number;\n /** @internal */\n readonly _name: string;\n\n /** @internal */\n constructor(id: number, name: string) {\n this._id = id;\n this._name = name;\n }\n\n /** Debug-friendly name of the referenced resource. */\n get name(): string {\n return this._name;\n }\n}\n\n// ─── Internal Resource Tracking ─────────────────────────────────────────\n\n/** @public */\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\n\n/**\n * Internal bookkeeping for a resource within the render graph.\n * @public\n */\nexport class RGResource {\n readonly id: number;\n readonly name: string;\n readonly kind: RGResourceKind;\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\n /** Resource ID of the physical backing resource used by imported versions. */\n readonly physicalId: number;\n /** The pass that creates / writes this resource (null for imported until written). */\n producer: RGPass | null = null;\n /** Passes that read this resource. */\n readonly consumers: RGPass[] = [];\n\n constructor(\n id: number,\n name: string,\n kind: RGResourceKind,\n desc: RGTextureDesc | RGFramebufferDesc | null,\n physicalId = id\n ) {\n this.id = id;\n this.name = name;\n this.kind = kind;\n this.desc = desc;\n this.physicalId = physicalId;\n }\n}\n\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\n\n// ─── Execution Context ──────────────────────────────────────────────\n\n/**\n * Context passed to pass execute callbacks during graph execution.\n *\n * Provides access to resolved GPU resources by their handles.\n *\n * @public\n */\nexport interface RGExecuteContext {\n /**\n * Resolve a handle to the actual GPU texture object.\n *\n * For transient resources, this returns the texture allocated by the executor.\n * For imported resources, this returns the texture registered via\n * {@link RenderGraphExecutor.setImportedTexture}. The handle must be declared\n * by the current pass with {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\n *\n * @param handle - Handle of the resource to resolve.\n * @returns The resolved texture object (type depends on the allocator).\n */\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\n\n /**\n * Resolve a framebuffer handle to the actual backend framebuffer object.\n *\n * The handle must be declared by the current pass with {@link RGPassBuilder.read}\n * or created by the same pass with {@link RGPassBuilder.createFramebuffer}.\n *\n * @param handle - Handle returned from {@link RGPassBuilder.createFramebuffer}.\n * @returns The resolved framebuffer object (type depends on the allocator).\n */\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle): TFramebuffer;\n\n /**\n * Create a temporary framebuffer managed by the graph executor.\n *\n * The framebuffer is released automatically when graph execution finishes or\n * aborts. Attachments may be actual backend resources or texture formats,\n * depending on the allocator implementation. If an attachment is an\n * {@link RGHandle}, the current pass must declare it with\n * {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\n *\n * @param desc - Framebuffer descriptor.\n * @returns The allocated framebuffer object (type depends on the allocator).\n */\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\n\n /**\n * Register a cleanup callback to run when graph execution finishes or aborts.\n *\n * Callbacks run in reverse registration order. Use this for temporary objects\n * created inside pass execution that are not graph resources, such as pooled\n * framebuffers wrapping graph-managed textures. If pass execution throws, the\n * executor still runs cleanup callbacks and preserves the original pass error\n * ahead of cleanup errors.\n *\n * @param callback - Cleanup function to invoke after execution.\n */\n deferCleanup(callback: () => void): void;\n}\n\n/**\n * Execute callback signature.\n *\n * The callback receives a context for resolving handles to GPU resources,\n * plus the user data returned from the setup function.\n *\n * @public\n */\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\n\n/**\n * Ordered execution step inside a render graph pass.\n *\n * Subpasses share the parent pass's resource declarations, lifetime, culling,\n * and access validation. They are intended to make multi-step pass bodies\n * explicit without splitting graph-level resource dependencies.\n *\n * @public\n */\nexport class RGSubpass<T = unknown> {\n readonly name: string;\n readonly executeFn: RGExecuteFn<T>;\n\n constructor(name: string, executeFn: RGExecuteFn<T>) {\n this.name = name;\n this.executeFn = executeFn;\n }\n}\n\n/**\n * Internal bookkeeping for a pass within the render graph.\n * @public\n */\nexport class RGPass<T = unknown> {\n readonly index: number;\n readonly name: string;\n /** Resources this pass reads (dependencies). */\n readonly reads: RGResource[] = [];\n /** Resources this pass creates or writes. */\n readonly writes: RGResource[] = [];\n /** Passes that must complete before this pass due to non-resource hazards. */\n readonly dependencies: RGPass[] = [];\n /** Whether this pass has side effects and must not be culled. */\n hasSideEffect = false;\n /** User data returned from the setup function. */\n data: T | null = null;\n /** Execute callback. */\n executeFn: RGExecuteFn<T> | null = null;\n /** Ordered subpasses for passes with multiple logical execution steps. */\n readonly subpasses: RGSubpass<T>[] = [];\n /** Set during compilation: true if this pass is needed. */\n alive = true;\n\n constructor(index: number, name: string) {\n this.index = index;\n this.name = name;\n }\n}\n\n// ─── Pass Builder ───────────────────────────────────────────────────────\n\n/**\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\n * to declare a pass's resource requirements.\n *\n * @public\n */\nexport interface RGPassBuilder {\n /**\n * Declare a read dependency on an existing resource.\n *\n * The resource must have been created by a prior pass or imported into the graph.\n *\n * @param handle - Handle of the resource to read.\n */\n read(handle: RGHandle): void;\n\n /**\n * Declare that this pass writes a new version of an existing resource.\n *\n * The returned handle represents the post-write version. Use it for subsequent\n * reads and as the graph output passed to {@link RenderGraph.compile}. Passing\n * an older version of the same resource to `compile()` is rejected because it\n * usually means the caller ignored the handle returned by `write()`. If the pass\n * needs the previous contents, call {@link RGPassBuilder.read} on the input handle explicitly\n * before writing.\n *\n * @param handle - Handle of the resource to write to.\n * @returns A handle referencing the newly written version.\n */\n write(handle: RGHandle): RGHandle;\n\n /**\n * Create a new transient texture resource that this pass will produce.\n *\n * @param desc - Texture descriptor.\n * @returns A handle referencing the newly created resource.\n */\n createTexture(desc: RGTextureDesc): RGHandle;\n\n /**\n * Create a logical dependency token produced by this pass.\n *\n * Tokens do not resolve to GPU resources and are not allocated by the executor.\n * They are useful for ordering passes whose dependencies are side effects rather\n * than texture reads/writes.\n *\n * @param name - Debug label for this token.\n * @returns A handle referencing the newly created token.\n */\n createToken(name?: string): RGHandle;\n\n /**\n * Create a graph-managed framebuffer view.\n *\n * The graph compiler infers dependencies from any attachment handles in the\n * descriptor. The executor creates and releases the framebuffer automatically.\n *\n * @param desc - Framebuffer descriptor.\n * @returns A handle referencing the framebuffer view.\n */\n createFramebuffer(desc: RGFramebufferDesc): RGHandle;\n\n /**\n * Mark this pass as having side effects.\n *\n * Side-effect passes are never culled by the graph compiler, regardless of\n * whether their outputs are consumed. Use this for GPU readback, picking,\n * debug overlays, etc.\n */\n sideEffect(): void;\n\n /**\n * Add an ordered logical subpass to this pass.\n *\n * Subpasses execute in registration order and share the parent pass's declared\n * reads, writes, framebuffer views, and user data. A pass may use either\n * subpasses or {@link RGPassBuilder.setExecute}, but not both.\n *\n * @param name - Debug label for the subpass.\n * @param fn - Callback invoked when this subpass executes.\n */\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void;\n\n /**\n * Set the execution callback for this pass.\n *\n * A pass may use either this method or {@link RGPassBuilder.addSubpass}, but not both.\n *\n * @param fn - Callback invoked during graph execution.\n */\n setExecute<D>(fn: RGExecuteFn<D>): void;\n}\n\n// ─── Compiled Graph ─────────────────────────────────────────────────────\n\n/**\n * Lifetime information for a resource within the compiled graph.\n *\n * @public\n */\nexport interface RGResourceLifetime {\n /** The resource. */\n readonly resource: RGResource;\n /** Index of the first pass that uses (produces or reads) this resource. */\n readonly firstUse: number;\n /** Index of the last pass that uses this resource. */\n readonly lastUse: number;\n}\n\n/**\n * Result of compiling a render graph.\n *\n * Contains the ordered list of passes to execute and lifetime information\n * for automatic resource management.\n *\n * @public\n */\nexport interface CompiledRenderGraph {\n /** Topologically sorted passes (only non-culled passes). */\n readonly orderedPasses: ReadonlyArray<RGPass>;\n /** Resource lifetime information keyed by resource ID. */\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\n}\n\n// ─── Texture Allocator ──────────────────────────────────────────────\n\n/**\n * Resolved dimensions for a texture allocation.\n * @public\n */\nexport interface RGResolvedSize {\n width: number;\n height: number;\n}\n\n/**\n * Descriptor for a framebuffer view managed by the graph or created temporarily during pass execution.\n *\n * This is intentionally backend-agnostic: graph-managed descriptors may use\n * {@link RGHandle} attachments, and executor-created descriptors use resolved\n * resources or texture formats understood by the allocator.\n *\n * @public\n */\nexport interface RGFramebufferDesc {\n /** Debug label for this framebuffer. */\n label?: string;\n /** Framebuffer width. Required when attachments are formats. */\n width?: number;\n /** Framebuffer height. Required when attachments are formats. */\n height?: number;\n /** Color attachments or formats. */\n colorAttachments: unknown | unknown[] | null;\n /** Depth/stencil attachment or format. */\n depthAttachment?: unknown | null;\n /** Whether color attachments created from formats should support mipmapping. */\n mipmapping?: boolean;\n /** Framebuffer sample count. */\n sampleCount?: number;\n /** Whether to ignore depth/stencil during MSAA resolve. */\n ignoreDepthStencil?: boolean;\n /** Attachment mip level. */\n attachmentMipLevel?: number;\n /** Attachment cubemap face. */\n attachmentCubeface?: number;\n /** Attachment array layer. */\n attachmentLayer?: number;\n}\n\n/**\n * Interface for allocating and releasing transient textures.\n *\n * Implement this to bridge the render graph with your GPU device's resource pool.\n * The executor calls `allocate()` before a resource's first use and\n * `release()` after its last use.\n *\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\n * @public\n */\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\n /**\n * Allocate a transient texture matching the given descriptor and resolved size.\n *\n * @param desc - The texture descriptor from the pass builder.\n * @param size - The resolved pixel dimensions.\n * @returns The allocated texture object.\n */\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\n\n /**\n * Release a previously allocated transient texture back to the pool.\n *\n * @param texture - The texture to release.\n */\n release(texture: TTexture): void;\n\n /**\n * Allocate a temporary framebuffer matching the given descriptor.\n *\n * Implementations should not auto-release this framebuffer; the graph executor\n * calls {@link RGTextureAllocator.releaseFramebuffer} when execution completes or aborts.\n *\n * @param desc - Framebuffer descriptor.\n * @returns The allocated framebuffer object.\n */\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\n\n /**\n * Release a previously allocated temporary framebuffer.\n *\n * @param framebuffer - The framebuffer to release.\n */\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\n}\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","physicalId","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","hasSideEffect","data","subpasses","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA+C;mFAExD,UAA4B;2FAE5BC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;IAEjC,WACER,CAAAA,EAAU,EACVC,IAAY,EACZI,IAAoB,EACpBC,IAA8C,EAC9CG,UAAaT,GAAAA,EAAE,CACf;QACA,IAAI,CAACA,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACG,UAAU,GAAGA,UAAAA;AACpB;AACF;AA4EA;;;;;;;;AAQC,IACM,MAAMC,SAAAA,CAAAA;IACFT,IAAa;IACbU,SAA0B;IAEnC,WAAYV,CAAAA,IAAY,EAAEU,SAAyB,CAAE;QACnD,IAAI,CAACV,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACU,SAAS,GAAGA,SAAAA;AACnB;AACF;AAEA;;;AAGC,IACM,MAAMC,MAAAA,CAAAA;IACFC,KAAc;IACdZ,IAAa;AACtB,qDACSa,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;AAClC,mFACSC,YAAyB,GAAA,EAAE;sEAEpCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBP,YAAmC,IAAK;AACxC,+EACSQ,SAA4B,GAAA,EAAE;gEAEvCC,QAAQ,IAAK;IAEb,WAAYP,CAAAA,KAAa,EAAEZ,IAAY,CAAE;QACvC,IAAI,CAACY,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACZ,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},\r\n * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers\r\n * used to declare dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @public\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\r\n /** Resource ID of the physical backing resource used by imported versions. */\r\n readonly physicalId: number;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(\r\n id: number,\r\n name: string,\r\n kind: RGResourceKind,\r\n desc: RGTextureDesc | RGFramebufferDesc | null,\r\n physicalId = id\r\n ) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n this.physicalId = physicalId;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}. The handle must be declared\r\n * by the current pass with {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n\r\n /**\r\n * Resolve a framebuffer handle to the actual backend framebuffer object.\r\n *\r\n * The handle must be declared by the current pass with {@link RGPassBuilder.read}\r\n * or created by the same pass with {@link RGPassBuilder.createFramebuffer}.\r\n *\r\n * @param handle - Handle returned from {@link RGPassBuilder.createFramebuffer}.\r\n * @returns The resolved framebuffer object (type depends on the allocator).\r\n */\r\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle): TFramebuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer managed by the graph executor.\r\n *\r\n * The framebuffer is released automatically when graph execution finishes or\r\n * aborts. Attachments may be actual backend resources or texture formats,\r\n * depending on the allocator implementation. If an attachment is an\r\n * {@link RGHandle}, the current pass must declare it with\r\n * {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object (type depends on the allocator).\r\n */\r\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Register a cleanup callback to run when graph execution finishes or aborts.\r\n *\r\n * Callbacks run in reverse registration order. Use this for temporary objects\r\n * created inside pass execution that are not graph resources, such as pooled\r\n * framebuffers wrapping graph-managed textures. If pass execution throws, the\r\n * executor still runs cleanup callbacks and preserves the original pass error\r\n * ahead of cleanup errors.\r\n *\r\n * @param callback - Cleanup function to invoke after execution.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Ordered execution step inside a render graph pass.\r\n *\r\n * Subpasses share the parent pass's resource declarations, lifetime, culling,\r\n * and access validation. They are intended to make multi-step pass bodies\r\n * explicit without splitting graph-level resource dependencies.\r\n *\r\n * @public\r\n */\r\nexport class RGSubpass<T = unknown> {\r\n readonly name: string;\r\n readonly executeFn: RGExecuteFn<T>;\r\n\r\n constructor(name: string, executeFn: RGExecuteFn<T>) {\r\n this.name = name;\r\n this.executeFn = executeFn;\r\n }\r\n}\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @public\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Passes that must complete before this pass due to non-resource hazards. */\r\n readonly dependencies: RGPass[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Ordered subpasses for passes with multiple logical execution steps. */\r\n readonly subpasses: RGSubpass<T>[] = [];\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes a new version of an existing resource.\r\n *\r\n * The returned handle represents the post-write version. Use it for subsequent\r\n * reads and as the graph output passed to {@link RenderGraph.compile}. Passing\r\n * an older version of the same resource to `compile()` is rejected because it\r\n * usually means the caller ignored the handle returned by `write()`. If the pass\r\n * needs the previous contents, call {@link RGPassBuilder.read} on the input handle explicitly\r\n * before writing.\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n * @returns A handle referencing the newly written version.\r\n */\r\n write(handle: RGHandle): RGHandle;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Create a logical dependency token produced by this pass.\r\n *\r\n * Tokens do not resolve to GPU resources and are not allocated by the executor.\r\n * They are useful for ordering passes whose dependencies are side effects rather\r\n * than texture reads/writes.\r\n *\r\n * @param name - Debug label for this token.\r\n * @returns A handle referencing the newly created token.\r\n */\r\n createToken(name?: string): RGHandle;\r\n\r\n /**\r\n * Create a graph-managed framebuffer view.\r\n *\r\n * The graph compiler infers dependencies from any attachment handles in the\r\n * descriptor. The executor creates and releases the framebuffer automatically.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns A handle referencing the framebuffer view.\r\n */\r\n createFramebuffer(desc: RGFramebufferDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Add an ordered logical subpass to this pass.\r\n *\r\n * Subpasses execute in registration order and share the parent pass's declared\r\n * reads, writes, framebuffer views, and user data. A pass may use either\r\n * subpasses or {@link RGPassBuilder.setExecute}, but not both.\r\n *\r\n * @param name - Debug label for the subpass.\r\n * @param fn - Callback invoked when this subpass executes.\r\n */\r\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * A pass may use either this method or {@link RGPassBuilder.addSubpass}, but not both.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Descriptor for a framebuffer view managed by the graph or created temporarily during pass execution.\r\n *\r\n * This is intentionally backend-agnostic: graph-managed descriptors may use\r\n * {@link RGHandle} attachments, and executor-created descriptors use resolved\r\n * resources or texture formats understood by the allocator.\r\n *\r\n * @public\r\n */\r\nexport interface RGFramebufferDesc {\r\n /** Debug label for this framebuffer. */\r\n label?: string;\r\n /** Framebuffer width. Required when attachments are formats. */\r\n width?: number;\r\n /** Framebuffer height. Required when attachments are formats. */\r\n height?: number;\r\n /** Color attachments or formats. */\r\n colorAttachments: unknown | unknown[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: unknown | null;\r\n /** Whether color attachments created from formats should support mipmapping. */\r\n mipmapping?: boolean;\r\n /** Framebuffer sample count. */\r\n sampleCount?: number;\r\n /** Whether to ignore depth/stencil during MSAA resolve. */\r\n ignoreDepthStencil?: boolean;\r\n /** Attachment mip level. */\r\n attachmentMipLevel?: number;\r\n /** Attachment cubemap face. */\r\n attachmentCubeface?: number;\r\n /** Attachment array layer. */\r\n attachmentLayer?: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls `allocate()` before a resource's first use and\r\n * `release()` after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Allocate a temporary framebuffer matching the given descriptor.\r\n *\r\n * Implementations should not auto-release this framebuffer; the graph executor\r\n * calls {@link RGTextureAllocator.releaseFramebuffer} when execution completes or aborts.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object.\r\n */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Release a previously allocated temporary framebuffer.\r\n *\r\n * @param framebuffer - The framebuffer to release.\r\n */\r\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","physicalId","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","hasSideEffect","data","subpasses","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA+C;mFAExD,UAA4B;2FAE5BC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;IAEjC,WACER,CAAAA,EAAU,EACVC,IAAY,EACZI,IAAoB,EACpBC,IAA8C,EAC9CG,UAAaT,GAAAA,EAAE,CACf;QACA,IAAI,CAACA,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACG,UAAU,GAAGA,UAAAA;AACpB;AACF;AA4EA;;;;;;;;AAQC,IACM,MAAMC,SAAAA,CAAAA;IACFT,IAAa;IACbU,SAA0B;IAEnC,WAAYV,CAAAA,IAAY,EAAEU,SAAyB,CAAE;QACnD,IAAI,CAACV,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACU,SAAS,GAAGA,SAAAA;AACnB;AACF;AAEA;;;AAGC,IACM,MAAMC,MAAAA,CAAAA;IACFC,KAAc;IACdZ,IAAa;AACtB,qDACSa,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;AAClC,mFACSC,YAAyB,GAAA,EAAE;sEAEpCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBP,YAAmC,IAAK;AACxC,+EACSQ,SAA4B,GAAA,EAAE;gEAEvCC,QAAQ,IAAK;IAEb,WAAYP,CAAAA,KAAa,EAAEZ,IAAY,CAAE;QACvC,IAAI,CAACY,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACZ,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
|