@forgeax/engine-vfx-render 0.1.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.
Files changed (91) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +163 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/__tests__/billboard-advanced.integration.test.d.ts +2 -0
  5. package/dist/__tests__/billboard-advanced.integration.test.d.ts.map +1 -0
  6. package/dist/__tests__/data-interface-providers.unit.test.d.ts +2 -0
  7. package/dist/__tests__/data-interface-providers.unit.test.d.ts.map +1 -0
  8. package/dist/__tests__/data-interface-public-api.test-d.d.ts +2 -0
  9. package/dist/__tests__/data-interface-public-api.test-d.d.ts.map +1 -0
  10. package/dist/__tests__/event-resources.unit.test.d.ts +2 -0
  11. package/dist/__tests__/event-resources.unit.test.d.ts.map +1 -0
  12. package/dist/__tests__/fog-producer.integration.test.d.ts +2 -0
  13. package/dist/__tests__/fog-producer.integration.test.d.ts.map +1 -0
  14. package/dist/__tests__/gpu-host.integration.test.d.ts +2 -0
  15. package/dist/__tests__/gpu-host.integration.test.d.ts.map +1 -0
  16. package/dist/__tests__/inspect-snapshot.integration.test.d.ts +2 -0
  17. package/dist/__tests__/inspect-snapshot.integration.test.d.ts.map +1 -0
  18. package/dist/__tests__/particle-resources.unit.test.d.ts +2 -0
  19. package/dist/__tests__/particle-resources.unit.test.d.ts.map +1 -0
  20. package/dist/__tests__/render-vocabulary-owner.test-d.d.ts +2 -0
  21. package/dist/__tests__/render-vocabulary-owner.test-d.d.ts.map +1 -0
  22. package/dist/__tests__/stage-plan.integration.test.d.ts +2 -0
  23. package/dist/__tests__/stage-plan.integration.test.d.ts.map +1 -0
  24. package/dist/__tests__/stage-recovery.integration.test.d.ts +2 -0
  25. package/dist/__tests__/stage-recovery.integration.test.d.ts.map +1 -0
  26. package/dist/__tests__/stage-resource-access-owner.test-d.d.ts +2 -0
  27. package/dist/__tests__/stage-resource-access-owner.test-d.d.ts.map +1 -0
  28. package/dist/__tests__/stage-resource-layout.unit.test.d.ts +2 -0
  29. package/dist/__tests__/stage-resource-layout.unit.test.d.ts.map +1 -0
  30. package/dist/__tests__/topology-capacity.unit.test.d.ts +2 -0
  31. package/dist/__tests__/topology-capacity.unit.test.d.ts.map +1 -0
  32. package/dist/__tests__/topology-resources.unit.test.d.ts +2 -0
  33. package/dist/__tests__/topology-resources.unit.test.d.ts.map +1 -0
  34. package/dist/feature/camera.d.ts +11 -0
  35. package/dist/feature/camera.d.ts.map +1 -0
  36. package/dist/feature/event-resources.d.ts +9 -0
  37. package/dist/feature/event-resources.d.ts.map +1 -0
  38. package/dist/feature/gpu-particle-feature.d.ts +96 -0
  39. package/dist/feature/gpu-particle-feature.d.ts.map +1 -0
  40. package/dist/feature/particle-resources.d.ts +66 -0
  41. package/dist/feature/particle-resources.d.ts.map +1 -0
  42. package/dist/feature/stage-plan.d.ts +54 -0
  43. package/dist/feature/stage-plan.d.ts.map +1 -0
  44. package/dist/feature/topologies/beam.d.ts +16 -0
  45. package/dist/feature/topologies/beam.d.ts.map +1 -0
  46. package/dist/feature/topologies/ribbon.d.ts +15 -0
  47. package/dist/feature/topologies/ribbon.d.ts.map +1 -0
  48. package/dist/feature/topologies/trail.d.ts +19 -0
  49. package/dist/feature/topologies/trail.d.ts.map +1 -0
  50. package/dist/host/data-interface-providers.d.ts +19 -0
  51. package/dist/host/data-interface-providers.d.ts.map +1 -0
  52. package/dist/host/vfx-runtime-host.d.ts +87 -0
  53. package/dist/host/vfx-runtime-host.d.ts.map +1 -0
  54. package/dist/index.d.ts +12 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.mjs +1572 -0
  57. package/dist/index.mjs.map +1 -0
  58. package/package.json +63 -0
  59. package/src/__tests__/billboard-advanced.integration.test.ts +69 -0
  60. package/src/__tests__/data-interface-providers.unit.test.ts +55 -0
  61. package/src/__tests__/data-interface-public-api.test-d.ts +58 -0
  62. package/src/__tests__/event-resources.unit.test.ts +71 -0
  63. package/src/__tests__/fog-producer.integration.test.ts +59 -0
  64. package/src/__tests__/gpu-host.integration.test.ts +441 -0
  65. package/src/__tests__/inspect-snapshot.integration.test.ts +26 -0
  66. package/src/__tests__/particle-resources.unit.test.ts +75 -0
  67. package/src/__tests__/render-vocabulary-owner.test-d.ts +81 -0
  68. package/src/__tests__/stage-plan.integration.test.ts +16 -0
  69. package/src/__tests__/stage-recovery.integration.test.ts +24 -0
  70. package/src/__tests__/stage-resource-access-owner.test-d.ts +26 -0
  71. package/src/__tests__/stage-resource-layout.unit.test.ts +40 -0
  72. package/src/__tests__/topology-capacity.unit.test.ts +59 -0
  73. package/src/__tests__/topology-resources.unit.test.ts +29 -0
  74. package/src/feature/camera.ts +12 -0
  75. package/src/feature/event-resources.ts +62 -0
  76. package/src/feature/gpu-particle-feature.ts +1225 -0
  77. package/src/feature/particle-resources.ts +203 -0
  78. package/src/feature/stage-plan.ts +282 -0
  79. package/src/feature/topologies/beam.ts +41 -0
  80. package/src/feature/topologies/ribbon.ts +31 -0
  81. package/src/feature/topologies/trail.ts +43 -0
  82. package/src/host/data-interface-providers.ts +119 -0
  83. package/src/host/vfx-runtime-host.ts +402 -0
  84. package/src/index.ts +57 -0
  85. package/src/shaders/beam.wgsl +69 -0
  86. package/src/shaders/billboard.wgsl +132 -0
  87. package/src/shaders/event.wgsl +11 -0
  88. package/src/shaders/mesh.wgsl +98 -0
  89. package/src/shaders/ribbon.wgsl +69 -0
  90. package/src/shaders/stage.wgsl +5 -0
  91. package/src/shaders/trail.wgsl +77 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/feature/event-resources.ts","../src/feature/particle-resources.ts","../src/feature/stage-plan.ts","../src/feature/gpu-particle-feature.ts","../src/host/data-interface-providers.ts","../src/host/vfx-runtime-host.ts"],"names":["target","err","ok","observation","vertexData","failure","VFX_GPU_RUNTIME_RESOURCE_KEY"],"mappings":";;;;;;;;;AAEO,IAAM,qBAAA,GAAwB;AAC9B,IAAM,eAAA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AAA,QAAA,CAAS,eAAe,QAAA,CAAS,KAAA;AACjC,UAAA,QAAA,CAAS,aAAa,KAAA,EAAM;AAC5B,UAAA,QAAA,CAAS,oBAAoB,KAAA,EAAM;AAAA,QACrC,CAAC,CAAA;AAAA,MACH;AACA,MAAA,MAAA,CAAO,GAAA,CAAI,OAAO,QAAQ,CAAA;AAC1B,MAAA,OAAOH,EAAAA,CAAG,EAAE,KAAA,EAAO,UAAA,EAAY,CAAA;AAAA,IACjC,CAAA;AAAA,IACA,WAAA,EAAa,OAAO,EAAE,KAAA,EAAM,KAAM;AAChC,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,GAAA,CAAI,KAAK,CAAA;AACjC,MAAA,IAAI,aAAa,MAAA,EAAW,OAAOA,GAAG,EAAE,KAAA,EAAO,gBAAgB,CAAA;AAC/D,MAAA,IAAI;AACF,QAAA,MAAM,QAAA,CAAS,aAAA,CAAc,KAAA,CAAM,OAAA,EAAQ;AAAA,MAC7C,SAAS,KAAA,EAAO;AACd,QAAA,OAAOD,GAAAA;AAAA,UACLI,QAAAA;AAAA,YACE,8BAAA;AAAA,YACA,qDAAA;AAAA,YACA,kDAAA;AAAA,YACA;AAAA;AACF,SACF;AAAA,MACF;AACA,MAAA,aAAA,CAAc,OAAO,KAAK,CAAA;AAC1B,MAAA,QAAA,CAAS,iBAAA,EAAkB;AAC3B,MAAA,QAAA,CAAS,aAAa,KAAA,EAAM;AAC5B,MAAA,QAAA,CAAS,oBAAoB,KAAA,EAAM;AACnC,MAAA,MAAA,CAAO,OAAO,KAAK,CAAA;AACnB,MAAA,OAAOH,EAAAA,CAAG,EAAE,KAAA,EAAO,UAAA,EAAY,CAAA;AAAA,IACjC;AAAA,GACF;AACF","file":"index.mjs","sourcesContent":["import type { VfxGpuEmitterProgram, VfxGpuTickIntent } from '@forgeax/engine-vfx';\n\nexport const VFX_EVENT_INPUT_BYTES = 32;\nexport const VFX_EVENT_BYTES = 32;\nexport const VFX_EVENT_COUNTER_BYTES = 16;\n\nfunction channelFanOut(emitter: VfxGpuEmitterProgram, channel: string): number {\n return Math.max(\n 1,\n ...(emitter.events ?? [])\n .filter((event) => event.channel === channel)\n .map((event) => event.fanOut),\n );\n}\n\nexport function eventInputCapacity(emitter: VfxGpuEmitterProgram): number {\n return Math.max(\n 1,\n (emitter.channels ?? []).reduce((total, channel) => total + channel.capacity, 0),\n );\n}\n\nexport function eventCapacity(emitter: VfxGpuEmitterProgram): number {\n const capacity = (emitter.channels ?? []).reduce(\n (total, channel) => total + channel.capacity * channelFanOut(emitter, channel.id),\n 0,\n );\n return Math.max(1, Math.min(emitter.capacity, capacity));\n}\n\nfunction channelKey(channel: string): number {\n let hash = 2166136261;\n for (const code of channel) {\n hash ^= code.codePointAt(0) ?? 0;\n hash = Math.imul(hash, 16777619);\n }\n return hash >>> 0;\n}\n\nexport function encodeEventInputs(intent: VfxGpuTickIntent): Uint8Array {\n const capacity = eventInputCapacity(intent.emitter);\n const data = new ArrayBuffer(capacity * VFX_EVENT_INPUT_BYTES);\n const bytes = new Uint8Array(data);\n bytes.fill(0xff);\n const view = new DataView(data);\n for (const [index, input] of intent.channelInputs.entries()) {\n if (index >= capacity) break;\n const offset = index * VFX_EVENT_INPUT_BYTES;\n view.setFloat32(offset, input.payload.position[0], true);\n view.setFloat32(offset + 4, input.payload.position[1], true);\n view.setFloat32(offset + 8, input.payload.position[2], true);\n view.setFloat32(offset + 16, input.payload.strength, true);\n view.setUint32(offset + 20, input.sequence, true);\n view.setUint32(offset + 24, channelKey(input.channel), true);\n view.setUint32(offset + 28, channelFanOut(intent.emitter, input.channel), true);\n }\n return bytes;\n}\n\nexport function eventCounterData(): Uint8Array {\n return new Uint8Array(VFX_EVENT_COUNTER_BYTES);\n}\n","import type { RenderFeatureMaterialShaderBindingContract } from '@forgeax/engine-render';\nimport {\n err,\n type MaterialAsset,\n type MaterialRenderState,\n type MeshAsset,\n ok,\n type Result,\n} from '@forgeax/engine-types';\nimport type { ParticleRendererSource } from '@forgeax/engine-vfx';\n\ntype ParticleRendererKind = ParticleRendererSource['kind'];\ntype ParticleTopologyRenderer = Extract<ParticleRendererSource, { readonly capacity: number }>;\ntype ParticleTopologyKind = ParticleTopologyRenderer['kind'];\n\nexport const PARTICLE_SHADER_IDENTIFIERS = Object.freeze({\n billboard: 'forgeax::vfx-render.particles.billboard',\n mesh: 'forgeax::vfx-render.particles.mesh',\n ribbon: 'forgeax::vfx-render.particles.ribbon',\n trail: 'forgeax::vfx-render.particles.trail',\n beam: 'forgeax::vfx-render.particles.beam',\n});\n\nexport interface TopologyResourcePlan {\n readonly topology: ParticleTopologyKind;\n readonly capacity: number;\n readonly vertexBytes: number;\n readonly indexBytes: number;\n readonly indirectBytes: number;\n readonly resourceKey: string;\n readonly historyLength?: number;\n readonly stripKey?: 'alive-index';\n readonly endpointField?: 'velocity';\n}\n\nexport interface TopologyResourceError {\n readonly code: 'vfx-topology-resource-invalid';\n readonly expected: string;\n readonly hint: string;\n readonly detail: { readonly path: string };\n}\n\nexport function createTopologyResourcePlan(\n renderer: unknown,\n): Result<TopologyResourcePlan, TopologyResourceError> {\n if (renderer === null || typeof renderer !== 'object' || Array.isArray(renderer))\n return err({\n code: 'vfx-topology-resource-invalid',\n expected: 'a topology renderer object',\n hint: 'declare a ribbon, trail, or beam renderer',\n detail: { path: 'renderer' },\n });\n const value = renderer as Partial<ParticleRendererSource> & Record<string, unknown>;\n if (value.kind !== 'ribbon' && value.kind !== 'trail' && value.kind !== 'beam')\n return err({\n code: 'vfx-topology-resource-invalid',\n expected: 'ribbon, trail, or beam',\n hint: 'do not alias topology output to billboard or mesh',\n detail: { path: 'renderer.kind' },\n });\n if (\n typeof value.capacity !== 'number' ||\n !Number.isInteger(value.capacity) ||\n value.capacity <= 0 ||\n value.capacity > 65536\n )\n return err({\n code: 'vfx-topology-resource-invalid',\n expected: 'capacity in the range 1..65536',\n hint: 'bound topology resources before allocating them',\n detail: { path: 'renderer.capacity' },\n });\n const capacity = value.capacity;\n if (value.kind === 'ribbon' && value.stripKey !== 'alive-index')\n return err({\n code: 'vfx-topology-resource-invalid',\n expected: \"stripKey 'alive-index'\",\n hint: 'use the managed alive-list order until a custom WGSL topology stage owns grouping',\n detail: { path: 'renderer.stripKey' },\n });\n if (\n value.kind === 'trail' &&\n (typeof value.historyLength !== 'number' ||\n !Number.isInteger(value.historyLength) ||\n value.historyLength <= 0 ||\n value.historyLength > 256)\n )\n return err({\n code: 'vfx-topology-resource-invalid',\n expected: 'historyLength in the range 1..256',\n hint: 'bound trail history storage',\n detail: { path: 'renderer.historyLength' },\n });\n if (value.kind === 'beam' && value.endpointField !== 'velocity')\n return err({\n code: 'vfx-topology-resource-invalid',\n expected: \"endpointField 'velocity'\",\n hint: 'use the managed velocity endpoint until a custom WGSL topology stage owns endpoints',\n detail: { path: 'renderer.endpointField' },\n });\n const vertexStride = 12 * 4;\n const segments =\n value.kind === 'trail' ? capacity * Math.max(1, (value.historyLength as number) - 1) : capacity;\n return ok({\n topology: value.kind,\n capacity,\n vertexBytes: Math.max(vertexStride, segments * vertexStride),\n indexBytes: 0,\n indirectBytes: 20,\n resourceKey: `vfx-topology-${value.kind}`,\n ...(value.kind === 'ribbon' ? { stripKey: 'alive-index' as const } : {}),\n ...(value.kind === 'trail' ? { historyLength: value.historyLength as number } : {}),\n ...(value.kind === 'beam' ? { endpointField: 'velocity' as const } : {}),\n });\n}\n\nexport interface TopologyCapacityInput {\n readonly requested: number;\n readonly produced: number;\n readonly degenerate?: number;\n}\n\nexport function topologyCapacitySnapshot(plan: TopologyResourcePlan, input: TopologyCapacityInput) {\n const produced = Math.max(0, Math.min(plan.capacity, input.produced));\n const requested = Math.max(0, input.requested);\n return {\n topology: plan.topology,\n capacity: plan.capacity,\n produced,\n dropped: Math.max(0, requested - produced),\n overflow: Math.max(0, requested - plan.capacity),\n degenerate: Math.max(0, input.degenerate ?? 0),\n } as const;\n}\n\nexport interface ParticleMaterialPass {\n readonly shader: string;\n readonly renderState?: MaterialRenderState;\n}\n\n/**\n * Resolve the one material pass that is meaningful for a particle projection.\n * A regular Forward pass is intentionally ignored: VFX vertex layouts are a\n * different contract, so silently accepting it would compile the wrong input\n * shape and make authored particle shaders appear to work while never running.\n */\nexport function particleMaterialPass(\n kind: ParticleRendererKind,\n material: MaterialAsset | undefined,\n): ParticleMaterialPass {\n const pass = material?.passes?.find((candidate) => candidate.name === `particle-${kind}`);\n return {\n shader: pass?.program.module ?? PARTICLE_SHADER_IDENTIFIERS[kind],\n ...(pass?.renderState === undefined\n ? {}\n : { renderState: pass.renderState as MaterialRenderState }),\n };\n}\n\n/** Scene-depth is a shader binding contract, not a renderer-kind convention. */\nexport function particleMaterialUsesSceneDepth(\n contract: RenderFeatureMaterialShaderBindingContract | 'view-with-resource',\n): boolean {\n return contract === 'group-0-resource' || contract === 'view-with-resource';\n}\n\n/** True when the authored particle shader consumes the standard material bind group. */\nexport function particleMaterialUsesBindings(material: MaterialAsset | undefined): boolean {\n return (material?.parameters?.length ?? 0) > 0;\n}\n\nfunction floatAttribute(value: ArrayBuffer | Float32Array | Uint16Array | undefined): Float32Array {\n if (value instanceof Float32Array) return value;\n if (value instanceof Uint16Array) return Float32Array.from(value);\n return value === undefined ? new Float32Array() : new Float32Array(value);\n}\n\nexport function canonicalMeshVertices(mesh: MeshAsset): Float32Array {\n if (mesh.vertices.length > 0 && mesh.vertices.length % 12 === 0) return mesh.vertices;\n const positions = floatAttribute(mesh.attributes.position);\n const vertexCount = Math.floor(positions.length / 3);\n const normals = floatAttribute(mesh.attributes.normal);\n const uvs = floatAttribute(mesh.attributes.uv);\n const tangents = floatAttribute(mesh.attributes.tangent);\n const result = new Float32Array(vertexCount * 12);\n for (let index = 0; index < vertexCount; index += 1) {\n const target = index * 12;\n result.set(positions.subarray(index * 3, index * 3 + 3), target);\n result.set(\n normals.length >= index * 3 + 3 ? normals.subarray(index * 3, index * 3 + 3) : [0, 0, 1],\n target + 3,\n );\n result.set(\n uvs.length >= index * 2 + 2 ? uvs.subarray(index * 2, index * 2 + 2) : [0, 0],\n target + 6,\n );\n result.set(\n tangents.length >= index * 4 + 4 ? tangents.subarray(index * 4, index * 4 + 4) : [1, 0, 0, 1],\n target + 8,\n );\n }\n return result;\n}\n","import type { RenderFeatureGpuBindingsRef, RenderFeatureGpuDispatch } from '@forgeax/engine-render';\nimport type { VfxGpuStageReflection } from '@forgeax/engine-vfx';\n\nconst MANAGED_STAGES = new Set(['spawn', 'update', 'scan', 'compact']);\nconst RESOURCE_NAMES = new Set([\n 'particles',\n 'runtime',\n 'aliveIndices',\n 'counters',\n 'indirect',\n 'scratch',\n 'billboardInstances',\n 'channelInputs',\n 'events',\n 'eventCounters',\n]);\nconst STAGE_ID = /^[a-z][a-z0-9-]{0,31}$/;\nconst ENTRY_POINT = /^forgeax_vfx_stage_[a-z][a-z0-9-]{0,31}_main$/;\nconst MAX_ITERATIONS = 64;\n\nexport interface VfxValidatedStage {\n readonly id: string;\n readonly entry: string;\n readonly entryPoint: string;\n readonly domain: 'particle';\n readonly resources: readonly {\n readonly name: string;\n readonly access: VfxGpuStageReflection['resources'][number]['access'];\n }[];\n readonly dependsOn: readonly string[];\n readonly iterationBudget: number;\n}\n\nexport interface VfxStageReadiness {\n readonly id: string;\n readonly state: 'ready' | 'candidate-rejected' | 'stale' | 'rebuilding';\n readonly generation: number;\n readonly lastKnownGoodGeneration?: number;\n readonly retryable: boolean;\n readonly error?: string;\n}\n\nexport interface VfxStagePlanObservation {\n readonly validatedStagePlan: VfxValidatedStagePlan;\n readonly stageReadiness: readonly VfxStageReadiness[];\n readonly stageOutput: 'active' | 'last-known-good' | 'empty';\n readonly lastKnownGoodStage:\n | { readonly fingerprint: string; readonly generation: number }\n | undefined;\n}\n\nexport interface VfxValidatedStagePlan {\n readonly stages: readonly VfxValidatedStage[];\n readonly fingerprint: string;\n readonly generation: number;\n}\n\nexport interface VfxStagePlanError {\n readonly code:\n | 'stage-id-invalid'\n | 'stage-entry-point-invalid'\n | 'stage-domain-invalid'\n | 'stage-resource-invalid'\n | 'stage-dependency-invalid'\n | 'stage-cycle'\n | 'stage-budget-invalid';\n readonly stageId: string;\n readonly hint: string;\n}\n\nexport type VfxStageRecovery = 'device-loss' | 'stale';\n\nfunction failure(\n code: VfxStagePlanError['code'],\n stageId: string,\n hint: string,\n): { ok: false; error: VfxStagePlanError } {\n return { ok: false, error: { code, stageId, hint } };\n}\n\nfunction stableStage(stage: VfxGpuStageReflection): VfxValidatedStage {\n return {\n id: stage.id,\n entry: stage.entry,\n entryPoint: stage.entryPoint,\n domain: stage.domain,\n resources: Object.freeze(\n stage.resources.map((resource) => ({ name: resource.name, access: resource.access })),\n ),\n dependsOn: Object.freeze([...stage.dependsOn]),\n iterationBudget: stage.iterationBudget,\n };\n}\n\n/** Validate the compiler reflection before a RenderFeature can contribute it. */\nexport function validatedStagePlan(\n reflection: VfxGpuStageReflection[] | readonly VfxGpuStageReflection[] | undefined,\n generation: number,\n):\n | { readonly ok: true; readonly value: VfxValidatedStagePlan }\n | { readonly ok: false; readonly error: VfxStagePlanError } {\n const source = reflection ?? [];\n const ids = new Set<string>();\n const stages: VfxValidatedStage[] = [];\n for (const stage of source) {\n if (!STAGE_ID.test(stage.id) || ids.has(stage.id)) {\n return failure(\n 'stage-id-invalid',\n stage.id,\n 'recook the effect with unique bounded stage ids',\n );\n }\n ids.add(stage.id);\n if (stage.domain !== 'particle' || MANAGED_STAGES.has(stage.domain)) {\n return failure('stage-domain-invalid', stage.id, 'use the managed particle dispatch domain');\n }\n if (!ENTRY_POINT.test(stage.entryPoint)) {\n return failure(\n 'stage-entry-point-invalid',\n stage.id,\n 'use the compiler-generated stage entry point',\n );\n }\n if (\n !Number.isInteger(stage.iterationBudget) ||\n stage.iterationBudget < 1 ||\n stage.iterationBudget > MAX_ITERATIONS\n ) {\n return failure(\n 'stage-budget-invalid',\n stage.id,\n 'use an integer iteration budget from 1 through 64',\n );\n }\n const resources = new Set<string>();\n for (const resource of stage.resources) {\n if (\n !RESOURCE_NAMES.has(resource.name) ||\n !['read', 'write', 'read-write'].includes(resource.access)\n ) {\n return failure(\n 'stage-resource-invalid',\n stage.id,\n 'declare only managed VFX resources with a supported access mode',\n );\n }\n if (resources.has(resource.name)) {\n return failure(\n 'stage-resource-invalid',\n stage.id,\n 'declare each managed VFX resource once',\n );\n }\n resources.add(resource.name);\n }\n stages.push(stableStage(stage));\n }\n const byId = new Map(stages.map((stage) => [stage.id, stage]));\n const visiting = new Set<string>();\n const visited = new Set<string>();\n const ordered: VfxValidatedStage[] = [];\n const visit = (stage: VfxValidatedStage): VfxStagePlanError | undefined => {\n if (visited.has(stage.id)) return undefined;\n if (visiting.has(stage.id))\n return {\n code: 'stage-cycle',\n stageId: stage.id,\n hint: 'remove the stage dependency cycle and recook the effect',\n };\n visiting.add(stage.id);\n for (const dependency of stage.dependsOn) {\n if (MANAGED_STAGES.has(dependency)) continue;\n const dependencyStage = byId.get(dependency);\n if (dependencyStage === undefined) {\n return {\n code: 'stage-dependency-invalid',\n stageId: stage.id,\n hint: 'declare every stage dependency or use a managed stage',\n };\n }\n const error = visit(dependencyStage);\n if (error !== undefined) return error;\n }\n visiting.delete(stage.id);\n visited.add(stage.id);\n ordered.push(stage);\n return undefined;\n };\n for (const stage of stages) {\n const error = visit(stage);\n if (error !== undefined) return { ok: false, error };\n }\n const normalized = Object.freeze(ordered);\n return {\n ok: true,\n value: Object.freeze({\n stages: normalized,\n fingerprint: JSON.stringify(normalized),\n generation,\n }),\n };\n}\n\nexport function stageDispatches(\n plan: VfxValidatedStagePlan,\n workgroups: number,\n bindings: RenderFeatureGpuBindingsRef,\n): readonly RenderFeatureGpuDispatch[] {\n return plan.stages.map((stage) => ({\n entryPoint: stage.entryPoint,\n workgroups: [workgroups] as const,\n bindings,\n }));\n}\n\nexport function observeStagePlan(\n candidate: ReturnType<typeof validatedStagePlan>,\n generation: number,\n lastKnownGoodStage: VfxValidatedStagePlan | undefined,\n): VfxStagePlanObservation {\n if (candidate.ok) {\n return {\n validatedStagePlan: candidate.value,\n stageReadiness: candidate.value.stages.map((stage) => ({\n id: stage.id,\n state: 'ready' as const,\n generation,\n lastKnownGoodGeneration: generation,\n retryable: false,\n })),\n stageOutput: candidate.value.stages.length === 0 ? 'empty' : 'active',\n lastKnownGoodStage:\n candidate.value.stages.length === 0\n ? lastKnownGoodStage === undefined\n ? undefined\n : {\n fingerprint: lastKnownGoodStage.fingerprint,\n generation: lastKnownGoodStage.generation,\n }\n : { fingerprint: candidate.value.fingerprint, generation },\n };\n }\n const retained = lastKnownGoodStage ?? { stages: [], fingerprint: '', generation };\n return {\n validatedStagePlan: retained,\n stageReadiness: [\n {\n id: candidate.error.stageId,\n state: 'candidate-rejected',\n generation,\n ...(lastKnownGoodStage === undefined\n ? {}\n : { lastKnownGoodGeneration: lastKnownGoodStage.generation }),\n retryable: true,\n error: candidate.error.code,\n },\n ],\n stageOutput: lastKnownGoodStage === undefined ? 'empty' : 'last-known-good',\n lastKnownGoodStage:\n lastKnownGoodStage === undefined\n ? undefined\n : {\n fingerprint: lastKnownGoodStage.fingerprint,\n generation: lastKnownGoodStage.generation,\n },\n };\n}\n\nexport function stageRecoveryReadiness(\n plan: VfxValidatedStagePlan,\n generation: number,\n recovery: VfxStageRecovery,\n): readonly VfxStageReadiness[] {\n return plan.stages.map((stage) => ({\n id: stage.id,\n state: recovery === 'stale' ? ('stale' as const) : ('rebuilding' as const),\n generation,\n lastKnownGoodGeneration: plan.generation,\n retryable: true,\n error: recovery,\n }));\n}\n","import type { EntityHandle, World } from '@forgeax/engine-ecs';\nimport { frustum } from '@forgeax/engine-math';\nimport {\n RENDER_FEATURE_VERTEX_LAYOUTS,\n type RenderError,\n type RenderFeature,\n type RenderFeatureDrawRecord,\n type RenderFeatureGpuBindingsRef,\n type RenderFeatureGpuBufferRef,\n type RenderFeatureGpuProgramRef,\n RenderFeaturePreparationFailedError,\n RenderFeatureStageFailedError,\n type RenderFeatureTargetHandle,\n} from '@forgeax/engine-render';\nimport { Transform } from '@forgeax/engine-scene';\nimport { err, type MaterialAsset, type MeshAsset, ok } from '@forgeax/engine-types';\nimport type { ParticleRendererSource } from '@forgeax/engine-vfx';\nimport {\n VFX_GPU_RUNTIME_RESOURCE_KEY,\n type VfxGpuRuntime,\n type VfxGpuTickIntent,\n} from '@forgeax/engine-vfx';\nimport type { VfxDataInterfaceRegistry } from '../host/data-interface-providers.js';\nimport type { ParticleRenderCamera } from './camera.js';\nimport {\n encodeEventInputs,\n eventCapacity,\n eventInputCapacity,\n VFX_EVENT_BYTES,\n VFX_EVENT_INPUT_BYTES,\n} from './event-resources.js';\nimport {\n canonicalMeshVertices,\n createTopologyResourcePlan,\n PARTICLE_SHADER_IDENTIFIERS,\n particleMaterialPass,\n particleMaterialUsesBindings,\n particleMaterialUsesSceneDepth,\n} from './particle-resources.js';\nimport {\n observeStagePlan,\n stageDispatches,\n type VfxStagePlanObservation,\n type VfxStageReadiness,\n type VfxValidatedStagePlan,\n validatedStagePlan,\n} from './stage-plan.js';\n\nconst IDENTITY = 'forgeax.vfx-render.gpu-particles';\nconst WORKGROUP_SIZE = 256;\nconst PARTICLE_BYTES = 80;\nconst BILLBOARD_INSTANCE_BYTES = 31 * 4;\nconst MESH_INSTANCE_BYTES = 28 * 4;\nconst COUNTERS_BYTES = 24;\nconst RUNTIME_BYTES = 72 * 4;\nconst MAX_TICK_RINGS = 8;\nconst IDENTITY_MATRIX = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);\n\ntype ParticleRendererKind = ParticleRendererSource['kind'];\ntype ParticleTopologyRenderer = Extract<ParticleRendererSource, { readonly capacity: number }>;\ntype ParticleTopologyKind = ParticleTopologyRenderer['kind'];\ntype VfxStageOutput = VfxStagePlanObservation['stageOutput'];\n\nexport interface VfxRenderInspectInput {\n readonly topology: ParticleRendererKind;\n readonly capacity: number;\n readonly produced: number;\n readonly dropped: number;\n readonly stageReadiness: readonly unknown[];\n readonly providerReadiness: unknown;\n readonly gpuTiming: unknown;\n}\n\nexport function createVfxRenderInspectSnapshot(input: VfxRenderInspectInput) {\n return {\n topology: input.topology,\n counters: { capacity: input.capacity, produced: input.produced, dropped: input.dropped },\n stageReadiness: input.stageReadiness,\n providerReadiness: input.providerReadiness,\n gpuTiming: input.gpuTiming,\n } as const;\n}\n\nexport interface BillboardAdvancedSample {\n readonly age: number;\n readonly lifetime: number;\n readonly particleDepth: number;\n readonly sceneDepth: number;\n readonly depthAvailable: boolean;\n}\n\nexport function resolveBillboardAdvancedState(\n renderer: Extract<ParticleRendererSource, { readonly kind: 'billboard' }>,\n sample: BillboardAdvancedSample,\n) {\n if (renderer.softParticle !== undefined && !sample.depthAvailable) {\n return err({\n code: 'vfx-renderer-depth-missing' as const,\n expected: 'a scene-depth provider for soft particles',\n hint: 'attach the scene-depth data interface or disable soft particles',\n detail: { path: 'renderer.softParticle' },\n });\n }\n const sheet = renderer.textureSheet;\n const frameCount = sheet?.frameCount ?? (sheet === undefined ? 1 : sheet.columns * sheet.rows);\n const frameIndex =\n sheet === undefined || sheet.frameRate === 0\n ? 0\n : Math.min(\n frameCount - 1,\n Math.max(0, Math.floor(Math.max(0, sample.age) * sheet.frameRate)),\n );\n const softParticleFade =\n renderer.softParticle === undefined\n ? 1\n : Math.max(\n 0,\n Math.min(\n 1,\n (sample.sceneDepth - sample.particleDepth) / renderer.softParticle.fadeDistance,\n ),\n );\n return ok({\n frameIndex,\n pivot: renderer.pivot ?? ([0, 0] as const),\n softParticleFade,\n sortingKey: renderer.sorting === 'back-to-front' ? sample.particleDepth : 0,\n });\n}\n\nexport function topologyRecoveryHint(\n topology: ParticleTopologyKind,\n reason: 'capacity' | 'broken' | 'degenerate' | 'device',\n): string {\n if (reason === 'capacity')\n return `${topology} capacity overflow was bounded; increase its explicit capacity`;\n if (reason === 'broken')\n return `${topology} continuity broke; inspect its explicit source key and keep the last valid segment`;\n if (reason === 'degenerate')\n return `${topology} produced no drawable segment; preserve zero output and inspect source endpoints`;\n return `${topology} device resources recovered from the last known good generation`;\n}\n\ninterface GpuParticleFeatureOptions {\n readonly camera: { read(world: World): ParticleRenderCamera | undefined };\n readonly dataInterfaces?: Pick<VfxDataInterfaceRegistry, 'resolve'>;\n readonly material?: { read(world: World, guid: string): MaterialAsset | undefined };\n readonly mesh?: { read(world: World, guid: string): MeshAsset | undefined };\n readonly playerConsumption?: {\n readonly isEnabled: (world: World, player: EntityHandle) => boolean;\n };\n}\n\n/**\n * GPU work observed from the producer-owned VFX feature for the last frame.\n * Counts are published only after the feature stages its real compute and\n * indirect graphics passes; preview consumers must not manufacture them.\n */\nexport interface VfxGpuRenderObservation {\n readonly frameNumber: number;\n readonly dispatches: number;\n readonly indirectDraws: number;\n readonly subjectOutputs: number;\n}\n\ninterface ExtractedWorld {\n readonly world: World;\n readonly runtime: VfxGpuRuntime;\n readonly camera: ParticleRenderCamera;\n readonly intents: readonly VfxGpuTickIntent[];\n}\n\ninterface ExtractedFrame {\n readonly worlds: readonly ExtractedWorld[];\n readonly frameNumber: number;\n}\n\ninterface GpuRefs {\n readonly program: RenderFeatureGpuProgramRef;\n readonly particles: RenderFeatureGpuBufferRef;\n readonly aliveIndices: RenderFeatureGpuBufferRef;\n readonly counters: RenderFeatureGpuBufferRef;\n readonly indirect: RenderFeatureGpuBufferRef;\n readonly scratch: RenderFeatureGpuBufferRef;\n readonly billboardInstances: RenderFeatureGpuBufferRef;\n readonly eventInputs: RenderFeatureGpuBufferRef;\n readonly events: RenderFeatureGpuBufferRef;\n}\n\ninterface TickRing {\n readonly runtime: RenderFeatureGpuBufferRef;\n readonly bindings: RenderFeatureGpuBindingsRef;\n}\n\ninterface RendererProjection {\n readonly kind: ParticleRendererSource['kind'];\n readonly ring: TickRing;\n readonly instances: RenderFeatureGpuBufferRef;\n readonly workgroups: number;\n readonly historyWorkgroups?: number;\n readonly sorting?: 'none' | 'emitter' | 'back-to-front';\n}\n\ninterface EmitterState {\n readonly world: World;\n readonly player: EntityHandle;\n readonly emitterId: string;\n readonly fingerprint: string;\n readonly capacity: number;\n readonly names: string;\n refs?: GpuRefs;\n rings: TickRing[];\n projections: RendererProjection[];\n colorTarget: RenderFeatureTargetHandle | undefined;\n depthTarget: RenderFeatureTargetHandle | undefined;\n indirectInitialized: boolean;\n culled: boolean;\n lastIntent?: VfxGpuTickIntent;\n draws: RenderFeatureDrawRecord[];\n depthSampledDraws: RenderFeatureDrawRecord[];\n stagePlan?: VfxValidatedStagePlan;\n lastKnownGoodStage?: VfxValidatedStagePlan;\n stageReadiness: readonly VfxStageReadiness[];\n stageOutput: VfxStageOutput;\n}\n\nfunction finite(value: unknown, fallback: number): number {\n return typeof value === 'number' && Number.isFinite(value) ? value : fallback;\n}\n\nfunction vector(value: unknown, fallback: readonly number[], size: number): readonly number[] {\n return Array.isArray(value)\n ? Array.from({ length: size }, (_, index) => finite(value[index], fallback[index] ?? 0))\n : fallback;\n}\n\nfunction runtimeData(\n intent: VfxGpuTickIntent,\n camera: ParticleRenderCamera,\n material: MaterialAsset | undefined,\n localToWorld: Float32Array,\n renderer?: ParticleRendererSource,\n rendererIndex = 0,\n): Uint8Array {\n const storage = new ArrayBuffer(RUNTIME_BYTES);\n const floats = new Float32Array(storage);\n const words = new Uint32Array(storage);\n floats[0] = intent.fixedDelta;\n words[1] = intent.phaseTick;\n words[2] = intent.seed;\n words[3] = intent.playCycle;\n words[4] = intent.emitter.capacity;\n words[5] = intent.spawnCount;\n words[6] = intent.firstParticleId;\n words[7] = intent.emitter.renderers.length;\n floats.set(camera.viewProjection, 8);\n floats.set(camera.right, 24);\n floats.set(camera.up, 28);\n const values = material?.values ?? {};\n floats.set(vector(values.baseColor, [1, 1, 1, 1], 4), 32);\n const emissive = vector(values.emissive, [0, 0, 0], 3);\n floats.set(emissive, 36);\n floats[39] = finite(values.emissiveIntensity, 0);\n floats[40] = finite(values.metallic, 0);\n floats[41] = finite(values.roughness, 0.5);\n floats[42] = finite(values.clearcoat, 0);\n floats[43] = finite(values.clearcoatRoughness, 0.5);\n floats.set(localToWorld, 44);\n words[60] = rendererIndex;\n words[61] = renderer?.kind === 'trail' ? renderer.historyLength : 0;\n words[62] =\n renderer?.kind === 'ribbon' || renderer?.kind === 'trail' || renderer?.kind === 'beam'\n ? renderer.capacity\n : intent.emitter.capacity;\n words[63] =\n renderer?.kind === 'billboard' && renderer.sorting === 'back-to-front'\n ? 2\n : renderer?.kind === 'billboard' && renderer.sorting === 'emitter'\n ? 1\n : 0;\n floats[64] =\n renderer?.kind === 'billboard'\n ? (renderer.pivot?.[0] ?? 0)\n : renderer?.kind === 'ribbon' || renderer?.kind === 'trail' || renderer?.kind === 'beam'\n ? (renderer.width ?? 0.1)\n : 0.1;\n floats[65] = renderer?.kind === 'billboard' ? (renderer.pivot?.[1] ?? 0) : 0;\n floats[66] = renderer?.kind === 'billboard' ? (renderer.softParticle?.fadeDistance ?? 0) : 0;\n const sheet = renderer?.kind === 'billboard' ? renderer.textureSheet : undefined;\n floats[68] = sheet?.columns ?? 1;\n floats[69] = sheet?.rows ?? 1;\n floats[70] = sheet?.frameRate ?? 0;\n floats[71] = sheet?.frameCount ?? (sheet === undefined ? 1 : sheet.columns * sheet.rows);\n return new Uint8Array(storage);\n}\n\nfunction emitterTransform(world: World, intent: VfxGpuTickIntent): Float32Array {\n if (intent.emitter.space === 'world') return IDENTITY_MATRIX;\n const transform = world.get(intent.player, Transform);\n return transform.ok ? transform.value.world : IDENTITY_MATRIX;\n}\n\nfunction emitterVisible(\n intent: VfxGpuTickIntent,\n camera: ParticleRenderCamera,\n localToWorld: Float32Array,\n): boolean {\n const bounds = intent.emitter.bounds;\n const center =\n bounds.kind === 'sphere'\n ? bounds.center\n : ([\n (bounds.min[0] + bounds.max[0]) * 0.5,\n (bounds.min[1] + bounds.max[1]) * 0.5,\n (bounds.min[2] + bounds.max[2]) * 0.5,\n ] as const);\n const radius =\n bounds.kind === 'sphere'\n ? bounds.radius\n : Math.hypot(\n (bounds.max[0] - bounds.min[0]) * 0.5,\n (bounds.max[1] - bounds.min[1]) * 0.5,\n (bounds.max[2] - bounds.min[2]) * 0.5,\n );\n const matrix = (index: number): number => localToWorld[index] ?? 0;\n const worldPosition = new Float32Array([\n matrix(0) * center[0] + matrix(4) * center[1] + matrix(8) * center[2] + matrix(12),\n matrix(1) * center[0] + matrix(5) * center[1] + matrix(9) * center[2] + matrix(13),\n matrix(2) * center[0] + matrix(6) * center[1] + matrix(10) * center[2] + matrix(14),\n ]);\n const scale = Math.max(\n Math.hypot(matrix(0), matrix(1), matrix(2)),\n Math.hypot(matrix(4), matrix(5), matrix(6)),\n Math.hypot(matrix(8), matrix(9), matrix(10)),\n );\n const planes = frustum.fromViewProjection(frustum.create(), camera.viewProjection);\n return frustum.intersectsSphere(planes, worldPosition, radius * scale);\n}\n\nfunction resetData(size: number): Uint8Array {\n return new Uint8Array(size);\n}\n\nfunction target(\n targets: readonly RenderFeatureTargetHandle[],\n kind: 'scene-color' | 'scene-depth',\n): RenderFeatureTargetHandle | undefined {\n return targets.find((entry) => entry.kind === kind);\n}\n\nfunction missingMeshPreparation(guid: string): RenderFeaturePreparationFailedError {\n return new RenderFeaturePreparationFailedError(\n IDENTITY,\n -1,\n 'asset-load',\n 'vertex-data',\n `mesh:${guid}`,\n 'asset-not-ready',\n 'next-frame',\n );\n}\n\nfunction materialResourceKey(shader: string): string {\n return shader.replaceAll(/[^a-zA-Z0-9_.:-]/g, '_');\n}\n\nfunction requiresSceneDepth(intent: VfxGpuTickIntent): boolean {\n return (intent.emitter.reflection.dataInterfaces ?? []).some(\n (requirement) => requirement.kind === 'scene-depth',\n );\n}\n\nexport function gpuParticleRenderFeature(\n options: GpuParticleFeatureOptions,\n): RenderFeature<ExtractedFrame> & { readonly inspect: () => VfxGpuRenderObservation } {\n const worldIds = new WeakMap<World, number>();\n let nextWorldId = 0;\n const states = new Map<string, EmitterState>();\n let lastObservation: VfxGpuRenderObservation = Object.freeze({\n frameNumber: -1,\n dispatches: 0,\n indirectDraws: 0,\n subjectOutputs: 0,\n });\n const keyOf = (world: World, intent: VfxGpuTickIntent): string => {\n let worldId = worldIds.get(world);\n if (worldId === undefined) {\n worldId = nextWorldId++;\n worldIds.set(world, worldId);\n }\n return `${worldId}:${intent.player}:${intent.emitter.id}`;\n };\n const stateFor = (world: World, intent: VfxGpuTickIntent): EmitterState => {\n const key = keyOf(world, intent);\n let state = states.get(key);\n if (state !== undefined && state.fingerprint !== intent.programFingerprint) {\n states.delete(key);\n state = undefined;\n }\n if (state !== undefined) return state;\n const fingerprint = intent.programFingerprint.slice(0, 12).replaceAll(':', '_');\n state = {\n world,\n player: intent.player,\n emitterId: intent.emitter.id,\n fingerprint: intent.programFingerprint,\n capacity: intent.emitter.capacity,\n names: `gpu.${key.replaceAll(':', '.')}.${fingerprint}`,\n rings: [],\n projections: [],\n draws: [],\n depthSampledDraws: [],\n colorTarget: undefined,\n depthTarget: undefined,\n indirectInitialized: false,\n culled: false,\n stageReadiness: [],\n stageOutput: 'empty',\n };\n states.set(key, state);\n return state;\n };\n\n return {\n identity: IDENTITY,\n requiredCapabilities: ['compute', 'indirectDrawing'],\n requiredMaterialShaders: Object.values(PARTICLE_SHADER_IDENTIFIERS),\n extract: (context) => {\n const extracted: ExtractedWorld[] = [];\n for (const world of context.worlds) {\n if (!world.hasResource(VFX_GPU_RUNTIME_RESOURCE_KEY)) continue;\n const camera = options.camera.read(world);\n if (camera === undefined) continue;\n const runtime = world.getResource<VfxGpuRuntime>(VFX_GPU_RUNTIME_RESOURCE_KEY);\n const intents = runtime.snapshot().filter((intent) => {\n if (options.playerConsumption?.isEnabled(world, intent.player) === false) return false;\n const requirements = intent.emitter.reflection.dataInterfaces ?? [];\n if (requirements.length === 0) return true;\n return (\n options.dataInterfaces?.resolve(requirements, intent.instanceGeneration).ok === true\n );\n });\n extracted.push({ world, runtime, camera, intents });\n }\n return ok({ worlds: extracted, frameNumber: context.frameNumber });\n },\n prepare: (frame, context) => {\n const gpu = context.gpu;\n if (gpu === undefined) {\n return err(new RenderFeatureStageFailedError(IDENTITY, -1, 'prepare', 'renderer-recover'));\n }\n // Kick every newly observed WGSL module before awaiting the next frame.\n // Shader-module creation is asynchronous in the browser RHI; returning on\n // the first pending module serialized effect startup across emitters and\n // could outlive a short authored burst on a slow runner.\n let pendingProgramError: RenderFeaturePreparationFailedError | undefined;\n const preparedIntents: Array<{\n readonly entry: ExtractedWorld;\n readonly intent: VfxGpuTickIntent;\n readonly state: EmitterState;\n }> = [];\n for (const entry of frame.worlds) {\n for (const intent of entry.intents) {\n const key = keyOf(entry.world, intent);\n let state = states.get(key);\n const candidate = validatedStagePlan(\n intent.emitter.reflection.stages,\n intent.instanceGeneration,\n );\n if (!candidate.ok) {\n if (state === undefined) {\n return err(new RenderFeatureStageFailedError(IDENTITY, -1, 'prepare', 'next-frame'));\n }\n const observation = observeStagePlan(\n candidate,\n intent.instanceGeneration,\n state.lastKnownGoodStage,\n );\n state.stagePlan = observation.validatedStagePlan;\n state.stageReadiness = observation.stageReadiness;\n state.stageOutput = observation.stageOutput;\n continue;\n }\n if (state !== undefined && state.fingerprint !== intent.programFingerprint) {\n states.delete(key);\n state = undefined;\n }\n state ??= stateFor(entry.world, intent);\n const observation = observeStagePlan(\n candidate,\n intent.instanceGeneration,\n state.lastKnownGoodStage,\n );\n state.stagePlan = observation.validatedStagePlan;\n state.lastKnownGoodStage = candidate.value;\n state.stageReadiness = observation.stageReadiness;\n state.stageOutput = observation.stageOutput;\n const program = gpu.prepareProgram(`${state.names}.program`, {\n wgsl: intent.emitter.wgsl,\n entryPoints: intent.emitter.reflection.entryPoints,\n bindings: intent.emitter.reflection.bindings,\n });\n if (!program.ok) {\n if (\n program.error.code !== 'render-feature-preparation-failed' ||\n program.error.detail.recovery !== 'next-frame'\n ) {\n return program;\n }\n pendingProgramError ??= program.error;\n }\n preparedIntents.push({ entry, intent, state });\n }\n }\n if (pendingProgramError !== undefined) return err(pendingProgramError);\n let pendingGraphicsError: RenderError | undefined;\n for (const { entry, intent, state } of preparedIntents) {\n if (intent.reset) state.indirectInitialized = false;\n state.lastIntent = intent;\n const base = state.names;\n const program = gpu.prepareProgram(`${base}.program`, {\n wgsl: intent.emitter.wgsl,\n entryPoints: intent.emitter.reflection.entryPoints,\n bindings: intent.emitter.reflection.bindings,\n });\n if (!program.ok) return program;\n const prepare = (\n name: string,\n size: number,\n usage: readonly ('storage' | 'uniform' | 'indirect' | 'vertex')[],\n data?: ArrayBufferView,\n ) =>\n gpu.prepareBuffer(`${base}.${name}`, {\n size,\n usage,\n ...(data === undefined ? {} : { data }),\n });\n const particles = prepare(\n 'particles',\n state.capacity * PARTICLE_BYTES,\n ['storage'],\n intent.reset ? resetData(state.capacity * PARTICLE_BYTES) : undefined,\n );\n if (!particles.ok) return particles;\n const aliveIndices = prepare('alive-indices', state.capacity * 4, ['storage']);\n if (!aliveIndices.ok) return aliveIndices;\n const counters = prepare(\n 'counters',\n COUNTERS_BYTES,\n ['storage'],\n intent.reset ? resetData(COUNTERS_BYTES) : undefined,\n );\n if (!counters.ok) return counters;\n const indirect = prepare('indirect', Math.max(1, intent.emitter.renderers.length) * 20, [\n 'storage',\n 'indirect',\n ]);\n if (!indirect.ok) return indirect;\n const scratchBytes = (state.capacity * 2 + Math.ceil(state.capacity / WORKGROUP_SIZE)) * 4;\n const scratch = prepare(\n 'scratch',\n scratchBytes,\n ['storage'],\n intent.reset ? resetData(scratchBytes) : undefined,\n );\n if (!scratch.ok) return scratch;\n const billboardInstances = prepare(\n 'billboard-instances',\n state.capacity * Math.max(BILLBOARD_INSTANCE_BYTES, MESH_INSTANCE_BYTES),\n ['storage', 'vertex'],\n );\n if (!billboardInstances.ok) return billboardInstances;\n const events = prepare(\n 'events',\n eventCapacity(intent.emitter) * VFX_EVENT_BYTES,\n ['storage'],\n intent.reset ? resetData(eventCapacity(intent.emitter) * VFX_EVENT_BYTES) : undefined,\n );\n if (!events.ok) return events;\n const initialEventInputs = prepare(\n 'event-inputs',\n eventInputCapacity(intent.emitter) * VFX_EVENT_INPUT_BYTES,\n ['storage'],\n encodeEventInputs(intent),\n );\n if (!initialEventInputs.ok) return initialEventInputs;\n state.refs = {\n program: program.value,\n particles: particles.value,\n aliveIndices: aliveIndices.value,\n counters: counters.value,\n indirect: indirect.value,\n scratch: scratch.value,\n billboardInstances: billboardInstances.value,\n eventInputs: initialEventInputs.value,\n events: events.value,\n };\n const ringIndex = intent.tick % MAX_TICK_RINGS;\n const runtime = gpu.prepareBuffer(`${base}.runtime.${ringIndex}`, {\n size: RUNTIME_BYTES,\n usage: ['uniform'],\n data: runtimeData(intent, entry.camera, undefined, emitterTransform(entry.world, intent)),\n });\n if (!runtime.ok) return runtime;\n const refs = state.refs;\n const updatedEventInputs = gpu.prepareBuffer(`${base}.event-inputs`, {\n size: eventInputCapacity(intent.emitter) * VFX_EVENT_INPUT_BYTES,\n usage: ['storage'],\n data: encodeEventInputs(intent),\n });\n if (!updatedEventInputs.ok) return updatedEventInputs;\n const bindings = gpu.prepareBindings(`${base}.bindings.${ringIndex}`, {\n program: refs.program,\n entries: [\n { binding: 0, buffer: refs.particles },\n { binding: 1, buffer: runtime.value },\n { binding: 2, buffer: refs.aliveIndices },\n { binding: 3, buffer: refs.counters },\n { binding: 4, buffer: refs.indirect },\n { binding: 5, buffer: refs.scratch },\n { binding: 6, buffer: refs.billboardInstances },\n { binding: 8, buffer: updatedEventInputs.value },\n { binding: 9, buffer: refs.events },\n ],\n });\n if (!bindings.ok) return bindings;\n state.rings[ringIndex] = {\n runtime: runtime.value,\n bindings: bindings.value,\n };\n }\n\n for (const [key, state] of states) {\n const extracted = frame.worlds.find((entry) => entry.world === state.world);\n if (extracted === undefined || !extracted.runtime.hasPlayer(state.player)) {\n states.delete(key);\n continue;\n }\n if (options.playerConsumption?.isEnabled(state.world, state.player) === false) {\n // A render-consumption fence must also suppress the retained\n // lastIntent fallback below. The authored player may be despawned\n // after FixedUpdate, so reading its Transform here would otherwise\n // produce an identity matrix and one final frame at world origin.\n state.projections = [];\n state.draws = [];\n state.depthSampledDraws = [];\n state.colorTarget = undefined;\n state.depthTarget = undefined;\n continue;\n }\n const intent = state.lastIntent;\n const refs = state.refs;\n if (intent === undefined || refs === undefined) continue;\n const retained = gpu.retainBindings([\n ...state.rings.flatMap((ring) => (ring === undefined ? [] : [ring.bindings])),\n ...state.projections.map((projection) => projection.ring.bindings),\n ]);\n if (!retained.ok) return retained;\n if (!extracted.runtime.isEmitterSessionEnabled(state.player, state.emitterId)) {\n // Session isolation is transient preview state, not a resource\n // lifetime boundary. Keep prepared bindings warm while suppressing\n // every contribution: a paused player may be re-enabled without a\n // fresh simulation intent that could rebuild those bindings.\n state.projections = [];\n state.draws = [];\n state.depthSampledDraws = [];\n continue;\n }\n const renderers = intent.emitter.renderers;\n if (renderers.length === 0) continue;\n const localToWorld = emitterTransform(state.world, intent);\n const visible = emitterVisible(intent, extracted.camera, localToWorld);\n extracted.runtime.setEmitterCameraVisibility(state.player, state.emitterId, visible);\n const currentIntents = extracted.intents.filter(\n (candidate) =>\n candidate.player === state.player && candidate.emitter.id === state.emitterId,\n );\n if (!visible) {\n state.culled = true;\n state.projections = [];\n state.draws = [];\n state.depthSampledDraws = [];\n continue;\n }\n if (\n state.culled &&\n intent.emitter.simulationWhenCulled === 'restart-on-visible' &&\n !currentIntents.some((candidate) => candidate.reset)\n ) {\n state.projections = [];\n state.draws = [];\n state.depthSampledDraws = [];\n continue;\n }\n state.culled = false;\n const colorTarget = target(context.targets, 'scene-color');\n const depthTarget = target(context.targets, 'scene-depth');\n const softParticle = requiresSceneDepth(intent);\n if (softParticle && depthTarget === undefined) continue;\n const eventRing = state.rings[intent.tick % MAX_TICK_RINGS];\n if (eventRing === undefined) continue;\n const meshes = renderers.map((renderer) =>\n renderer.kind === 'mesh' ? options.mesh?.read(state.world, renderer.mesh) : undefined,\n );\n const missingMesh = renderers.find(\n (renderer, index) =>\n renderer.kind === 'mesh' &&\n meshes[index]?.submeshes[renderer.submesh ?? 0] === undefined,\n );\n if (missingMesh?.kind === 'mesh') {\n pendingGraphicsError ??= missingMeshPreparation(missingMesh.mesh);\n continue;\n }\n const indirectWords = new Uint32Array(renderers.length * 5);\n for (const [index, renderer] of renderers.entries()) {\n const mesh = meshes[index];\n const submesh =\n renderer.kind === 'mesh' ? mesh?.submeshes[renderer.submesh ?? 0] : undefined;\n const topologyPlan =\n renderer.kind === 'ribbon' || renderer.kind === 'trail' || renderer.kind === 'beam'\n ? createTopologyResourcePlan(renderer)\n : undefined;\n if (topologyPlan !== undefined && !topologyPlan.ok)\n return err(new RenderFeatureStageFailedError(IDENTITY, -1, 'prepare', 'next-frame'));\n indirectWords[index * 5] =\n renderer.kind === 'billboard'\n ? 6\n : renderer.kind === 'ribbon' || renderer.kind === 'trail' || renderer.kind === 'beam'\n ? 6\n : mesh?.indices === undefined\n ? (submesh?.vertexCount ?? 0)\n : (submesh?.indexCount ?? 0);\n indirectWords[index * 5 + 2] =\n renderer.kind === 'mesh' && mesh?.indices !== undefined\n ? (submesh?.indexOffset ?? 0)\n : 0;\n }\n const indirectInit = gpu.prepareBuffer(`${state.names}.indirect`, {\n size: Math.max(1, renderers.length) * 20,\n usage: ['storage', 'indirect'],\n ...(state.indirectInitialized ? {} : { data: indirectWords }),\n });\n if (!indirectInit.ok) return indirectInit;\n state.indirectInitialized = true;\n const draws: RenderFeatureDrawRecord[] = [];\n const depthSampledDraws: RenderFeatureDrawRecord[] = [];\n const projections: RendererProjection[] = [];\n for (const [rendererIndex, renderer] of renderers.entries()) {\n const isBillboard = renderer.kind === 'billboard';\n const isTopology =\n renderer.kind === 'ribbon' || renderer.kind === 'trail' || renderer.kind === 'beam';\n const topologyPlan = isTopology ? createTopologyResourcePlan(renderer) : undefined;\n if (topologyPlan !== undefined && !topologyPlan.ok)\n return err(new RenderFeatureStageFailedError(IDENTITY, -1, 'prepare', 'next-frame'));\n const mesh = meshes[rendererIndex];\n const submesh =\n renderer.kind === 'mesh' ? mesh?.submeshes[renderer.submesh ?? 0] : undefined;\n const indexFormat =\n mesh?.indices instanceof Uint32Array ? ('uint32' as const) : ('uint16' as const);\n let material = options.material?.read(state.world, renderer.material);\n if (material !== undefined) {\n const resolvedMaterial = context.graphics.resolveMaterialAsset(material);\n if (!resolvedMaterial.ok) {\n pendingGraphicsError ??= resolvedMaterial.error;\n continue;\n }\n material = resolvedMaterial.value;\n }\n const materialPass = particleMaterialPass(renderer.kind, material);\n const materialKey = materialResourceKey(materialPass.shader);\n const samplesSceneDepth = particleMaterialUsesSceneDepth(\n context.graphics.getMaterialShaderBindingContract(materialPass.shader),\n );\n const particleBlend = renderer.kind === 'billboard' ? renderer.blend : 'alpha';\n const projectionInstances = gpu.prepareBuffer(\n `${state.names}.renderer.${rendererIndex}.instances`,\n {\n size: isTopology\n ? topologyPlan?.ok\n ? topologyPlan.value.vertexBytes\n : 0\n : state.capacity * (isBillboard ? BILLBOARD_INSTANCE_BYTES : MESH_INSTANCE_BYTES),\n usage: ['storage', 'vertex'],\n },\n );\n if (!projectionInstances.ok) return projectionInstances;\n const projectionHistory = gpu.prepareBuffer(\n `${state.names}.renderer.${rendererIndex}.history`,\n {\n size:\n renderer.kind === 'trail'\n ? Math.max(16, renderer.capacity * renderer.historyLength * 16)\n : 16,\n usage: ['storage'],\n ...(intent.reset\n ? {\n data: resetData(\n renderer.kind === 'trail'\n ? Math.max(16, renderer.capacity * renderer.historyLength * 16)\n : 16,\n ),\n }\n : {}),\n },\n );\n if (!projectionHistory.ok) return projectionHistory;\n const projectionRuntime = gpu.prepareBuffer(\n `${state.names}.renderer.${rendererIndex}.runtime`,\n {\n size: RUNTIME_BYTES,\n usage: ['uniform'],\n data: runtimeData(\n { ...intent, fixedDelta: 0, spawnCount: 0 },\n extracted.camera,\n material,\n localToWorld,\n renderer,\n rendererIndex,\n ),\n },\n );\n if (!projectionRuntime.ok) return projectionRuntime;\n const projectionBindings = gpu.prepareBindings(\n `${state.names}.renderer.${rendererIndex}.bindings`,\n {\n program: refs.program,\n entries: [\n { binding: 0, buffer: refs.particles },\n { binding: 1, buffer: projectionRuntime.value },\n { binding: 2, buffer: refs.aliveIndices },\n { binding: 3, buffer: refs.counters },\n { binding: 4, buffer: refs.indirect },\n { binding: 5, buffer: projectionHistory.value },\n { binding: 6, buffer: projectionInstances.value },\n { binding: 8, buffer: refs.eventInputs },\n { binding: 9, buffer: refs.events },\n ],\n },\n );\n if (!projectionBindings.ok) return projectionBindings;\n projections.push({\n kind: renderer.kind,\n instances: projectionInstances.value,\n ring: {\n runtime: projectionRuntime.value,\n bindings: projectionBindings.value,\n },\n workgroups: Math.ceil(\n (renderer.kind === 'trail'\n ? renderer.capacity * Math.max(1, renderer.historyLength - 1)\n : renderer.kind === 'ribbon' || renderer.kind === 'beam'\n ? renderer.capacity\n : state.capacity) / WORKGROUP_SIZE,\n ),\n ...(renderer.kind === 'trail'\n ? { historyWorkgroups: Math.ceil(renderer.capacity / WORKGROUP_SIZE) }\n : {}),\n ...(renderer.kind === 'billboard' ? { sorting: renderer.sorting ?? 'none' } : {}),\n });\n const pipeline = context.graphics.preparePipeline(\n `${state.names}.renderer.${rendererIndex}.${renderer.kind}.pipeline.${materialKey}`,\n {\n shader: materialPass.shader,\n vertexLayout: isBillboard\n ? RENDER_FEATURE_VERTEX_LAYOUTS.billboardMaterialInstance\n : isTopology\n ? RENDER_FEATURE_VERTEX_LAYOUTS.topologySegmentInstance\n : RENDER_FEATURE_VERTEX_LAYOUTS.meshGeometryMaterialInstance,\n colorFormats: [colorTarget?.format ?? 'rgba8unorm-srgb'],\n ...(depthTarget === undefined ? {} : { depthFormat: depthTarget.format }),\n sampleCount: colorTarget?.sampleCount ?? 1,\n topology: submesh?.topology ?? 'triangle-list',\n ...(mesh?.indices === undefined ? {} : { indexFormat }),\n ...(materialPass.renderState !== undefined\n ? { renderState: materialPass.renderState }\n : isBillboard || isTopology\n ? {\n renderState: {\n cullMode: 'none',\n depthCompare: 'less-equal',\n depthWriteEnabled:\n softParticle || isTopology ? false : particleBlend === 'opaque-cutout',\n ...(particleBlend === 'opaque-cutout'\n ? {}\n : {\n blend: {\n color: {\n srcFactor: 'one',\n dstFactor:\n particleBlend === 'additive' ? 'one' : 'one-minus-src-alpha',\n operation: 'add',\n },\n alpha: {\n srcFactor: 'one',\n dstFactor: 'one-minus-src-alpha',\n operation: 'add',\n },\n },\n }),\n },\n }\n : {}),\n },\n );\n if (!pipeline.ok) {\n if (\n pipeline.error.code !== 'render-feature-preparation-failed' ||\n pipeline.error.detail.recovery !== 'next-frame'\n ) {\n return pipeline;\n }\n pendingGraphicsError ??= pipeline.error;\n continue;\n }\n const graphicsBindings = context.graphics.prepareBindings(\n `${state.names}.renderer.${rendererIndex}.${renderer.kind}.binding.${materialKey}`,\n {\n pipeline: pipeline.value,\n values: {\n group: 0,\n shader: materialPass.shader,\n ...(samplesSceneDepth && depthTarget !== undefined\n ? { sceneDepth: depthTarget }\n : {}),\n },\n },\n );\n if (!graphicsBindings.ok) return graphicsBindings;\n const materialBindings = !particleMaterialUsesBindings(material)\n ? undefined\n : context.graphics.prepareBindings(\n `${state.names}.renderer.${rendererIndex}.${renderer.kind}.material-binding.${materialKey}`,\n {\n pipeline: pipeline.value,\n values: {\n group: 1,\n material: {\n world: frame.worlds.findIndex((entry) => entry.world === state.world),\n guid: renderer.material,\n },\n },\n },\n );\n if (materialBindings !== undefined && !materialBindings.ok) return materialBindings;\n const drawBindings = [\n graphicsBindings.value,\n ...(materialBindings === undefined ? [] : [materialBindings.value]),\n ];\n if (isBillboard || isTopology) {\n const vertexData = context.graphics.prepareVertexData(\n `${state.names}.${isTopology ? renderer.kind : 'billboard'}.vertices`,\n {\n layout: isTopology\n ? RENDER_FEATURE_VERTEX_LAYOUTS.topologySegmentInstance\n : RENDER_FEATURE_VERTEX_LAYOUTS.billboardMaterialInstance,\n buffer: projectionInstances.value,\n },\n );\n if (!vertexData.ok) return vertexData;\n const draw: RenderFeatureDrawRecord = {\n kind: 'draw-indirect',\n pipeline: pipeline.value,\n bindings: drawBindings,\n vertexData: [{ slot: 0, resource: vertexData.value }],\n command: { buffer: refs.indirect, offset: rendererIndex * 20 },\n };\n (samplesSceneDepth ? depthSampledDraws : draws).push(draw);\n continue;\n }\n if (mesh === undefined) {\n return err(new RenderFeatureStageFailedError(IDENTITY, -1, 'prepare', 'next-frame'));\n }\n const geometryData = canonicalMeshVertices(mesh);\n const geometryBuffer = gpu.prepareBuffer(\n `${state.names}.renderer.${rendererIndex}.mesh.geometry-buffer`,\n {\n size: geometryData.byteLength,\n usage: ['vertex'],\n data: geometryData,\n },\n );\n if (!geometryBuffer.ok) return geometryBuffer;\n const geometry = context.graphics.prepareVertexData(\n `${state.names}.renderer.${rendererIndex}.mesh.geometry`,\n {\n layout: RENDER_FEATURE_VERTEX_LAYOUTS.meshGeometryMaterialInstance,\n buffer: geometryBuffer.value,\n },\n );\n if (!geometry.ok) return geometry;\n const instances = context.graphics.prepareVertexData(\n `${state.names}.renderer.${rendererIndex}.mesh.instances`,\n {\n layout: RENDER_FEATURE_VERTEX_LAYOUTS.meshGeometryMaterialInstance,\n buffer: projectionInstances.value,\n },\n );\n if (!instances.ok) return instances;\n const indexBuffer =\n mesh.indices === undefined\n ? undefined\n : gpu.prepareBuffer(`${state.names}.renderer.${rendererIndex}.mesh.index-buffer`, {\n size: mesh.indices.byteLength,\n usage: ['index'],\n data: mesh.indices,\n });\n if (indexBuffer !== undefined && !indexBuffer.ok) return indexBuffer;\n const indices =\n indexBuffer === undefined\n ? undefined\n : context.graphics.prepareIndexData(\n `${state.names}.renderer.${rendererIndex}.mesh.indices`,\n {\n format: indexFormat,\n buffer: indexBuffer.value,\n },\n );\n if (indices !== undefined && !indices.ok) return indices;\n const vertexData = [\n { slot: 0, resource: geometry.value },\n { slot: 1, resource: instances.value },\n ];\n draws.push(\n indices === undefined\n ? {\n kind: 'draw-indirect',\n pipeline: pipeline.value,\n bindings: drawBindings,\n vertexData,\n command: { buffer: refs.indirect, offset: rendererIndex * 20 },\n }\n : {\n kind: 'draw-indexed-indirect',\n pipeline: pipeline.value,\n bindings: drawBindings,\n vertexData,\n indexData: { resource: indices.value, format: indexFormat },\n command: { buffer: refs.indirect, offset: rendererIndex * 20 },\n },\n );\n }\n state.projections = projections;\n state.draws = draws;\n state.depthSampledDraws = depthSampledDraws;\n state.colorTarget = colorTarget;\n state.depthTarget = depthTarget;\n }\n if (pendingGraphicsError !== undefined) return err(pendingGraphicsError);\n return ok(undefined);\n },\n contribute: (frame, context) => {\n let dispatchCount = 0;\n let indirectDrawCount = 0;\n let subjectOutputCount = 0;\n for (const state of states.values()) {\n const refs = state.refs;\n const firstProjection = state.projections[0];\n if (refs === undefined) continue;\n const extracted = frame.worlds.find((entry) => entry.world === state.world);\n if (extracted === undefined) continue;\n if (options.playerConsumption?.isEnabled(state.world, state.player) === false) continue;\n if (!extracted.runtime.isEmitterSessionEnabled(state.player, state.emitterId)) continue;\n const currentIntents = extracted.intents.filter(\n (intent) => intent.player === state.player && intent.emitter.id === state.emitterId,\n );\n const intents = currentIntents.some(\n (intent) => intent.programFingerprint === state.fingerprint,\n )\n ? currentIntents.filter((intent) => intent.programFingerprint === state.fingerprint)\n : state.lastIntent === undefined\n ? []\n : [state.lastIntent];\n const groups = Math.ceil(state.capacity / WORKGROUP_SIZE);\n const dispatches = intents.flatMap((intent) => {\n const bindings = state.rings[intent.tick % MAX_TICK_RINGS]?.bindings;\n if (bindings === undefined) return [];\n return [\n { entryPoint: 'forgeax_vfx_spawn_main', workgroups: [groups] as const, bindings },\n { entryPoint: 'forgeax_vfx_update_main', workgroups: [groups] as const, bindings },\n ...stageDispatches(\n state.stagePlan ?? {\n stages: [],\n fingerprint: '',\n generation: intent.instanceGeneration,\n },\n groups,\n bindings,\n ),\n { entryPoint: 'forgeax_vfx_scan_blocks_main', workgroups: [groups] as const, bindings },\n {\n entryPoint: 'forgeax_vfx_scan_block_offsets_main',\n workgroups: [1] as const,\n bindings,\n },\n { entryPoint: 'forgeax_vfx_add_offsets_main', workgroups: [groups] as const, bindings },\n { entryPoint: 'forgeax_vfx_compact_main', workgroups: [groups] as const, bindings },\n {\n entryPoint: 'forgeax_vfx_event_main',\n workgroups: [Math.ceil(eventInputCapacity(intent.emitter) / 64)] as const,\n bindings,\n },\n ];\n });\n for (const projection of state.projections) {\n if (projection.kind === 'billboard' && projection.sorting === 'back-to-front') {\n dispatches.push({\n entryPoint: 'forgeax_vfx_sort_main',\n workgroups: [1],\n bindings: projection.ring.bindings,\n });\n }\n if (projection.kind === 'trail') {\n dispatches.push({\n entryPoint: 'forgeax_vfx_trail_history_main',\n workgroups: [projection.historyWorkgroups ?? 1],\n bindings: projection.ring.bindings,\n });\n }\n dispatches.push({\n entryPoint:\n projection.kind === 'billboard'\n ? 'forgeax_vfx_billboard_main'\n : projection.kind === 'mesh'\n ? 'forgeax_vfx_mesh_main'\n : `forgeax_vfx_${projection.kind}_main`,\n workgroups: [projection.workgroups],\n bindings: projection.ring.bindings,\n });\n }\n const passBindings =\n firstProjection?.ring.bindings ??\n intents\n .map((intent) => state.rings[intent.tick % MAX_TICK_RINGS]?.bindings)\n .find((bindings) => bindings !== undefined);\n if (passBindings === undefined || dispatches.length === 0) continue;\n const computePassIdentity = `${state.names}.simulate-and-project`;\n const compute = context.staging.addComputePass(computePassIdentity, {\n program: refs.program,\n bindings: passBindings,\n dispatches,\n });\n if (!compute.ok) return compute;\n dispatchCount += dispatches.length;\n for (const intent of intents) {\n extracted.runtime.markEventDispatched(state.player, intent.eventCounters);\n }\n for (const [drawKind, passDraws] of [\n ['regular', state.draws],\n ['depth-sampled', state.depthSampledDraws],\n ] as const) {\n if (passDraws.length === 0) continue;\n const samplesDepth = drawKind === 'depth-sampled';\n const draw = context.staging.addGraphicsPass(\n `${state.names}.draw.${drawKind}`,\n {\n attachments: {\n colors: [\n {\n resource: state.colorTarget ?? 'swapchain',\n format: state.colorTarget?.format ?? 'rgba8unorm-srgb',\n loadOp: 'load',\n storeOp: 'store',\n },\n ],\n ...(state.depthTarget === undefined\n ? {}\n : {\n depthStencil: {\n resource: state.depthTarget,\n format: state.depthTarget.format,\n depthLoadOp: 'load' as const,\n depthStoreOp: 'store' as const,\n },\n }),\n },\n ...(state.depthTarget === undefined || !samplesDepth\n ? {}\n : { sampledTargets: [state.depthTarget] }),\n temporalCoverage: 'reactive',\n draws: passDraws,\n },\n { dependsOn: [{ featureIdentity: IDENTITY, passIdentity: computePassIdentity }] },\n );\n if (!draw.ok) return draw;\n indirectDrawCount += passDraws.filter(\n (record) => record.kind === 'draw-indirect' || record.kind === 'draw-indexed-indirect',\n ).length;\n subjectOutputCount += passDraws.length;\n }\n }\n for (const entry of frame.worlds) {\n const last = entry.intents.at(-1);\n if (last !== undefined) entry.runtime.commit(last.sequence);\n }\n lastObservation = Object.freeze({\n frameNumber: frame.frameNumber,\n dispatches: dispatchCount,\n indirectDraws: indirectDrawCount,\n subjectOutputs: subjectOutputCount,\n });\n return ok(undefined);\n },\n recover: () => {\n const runtimes = new Set<VfxGpuRuntime>();\n for (const state of states.values()) {\n if (!state.world.hasResource(VFX_GPU_RUNTIME_RESOURCE_KEY)) continue;\n runtimes.add(state.world.getResource<VfxGpuRuntime>(VFX_GPU_RUNTIME_RESOURCE_KEY));\n }\n for (const runtime of runtimes) runtime.recover();\n states.clear();\n return ok(undefined);\n },\n dispose: () => {\n states.clear();\n lastObservation = Object.freeze({\n frameNumber: -1,\n dispatches: 0,\n indirectDraws: 0,\n subjectOutputs: 0,\n });\n return ok(undefined);\n },\n inspect: () => lastObservation,\n };\n}\n","import { err, ok, type Result } from '@forgeax/engine-types';\nimport {\n resolveVfxDataInterfaces,\n type VfxDataInterfaceError,\n type VfxDataInterfaceKind,\n type VfxDataInterfaceProvider,\n type VfxDataInterfaceRequirement,\n type VfxDataInterfaceResolution,\n type VfxDataInterfaceResource,\n type VfxDataInterfaceToken,\n} from '@forgeax/engine-vfx';\n\nexport type { VfxDataInterfaceProvider } from '@forgeax/engine-vfx';\n\nexport interface VfxDataInterfaceAvailabilitySource {\n readonly available: (generation: number) => boolean;\n}\n\nexport interface VfxDataInterfaceRegistry {\n readonly providers: readonly VfxDataInterfaceProvider[];\n readonly snapshot:\n | {\n readonly generation: number;\n readonly result: Result<VfxDataInterfaceResolution, VfxDataInterfaceError>;\n }\n | undefined;\n register(provider: VfxDataInterfaceProvider): Result<void, VfxDataInterfaceError>;\n resolve(\n requirements: readonly VfxDataInterfaceRequirement[],\n generation: number,\n ): Result<VfxDataInterfaceResolution, VfxDataInterfaceError>;\n}\n\nfunction duplicate(token: VfxDataInterfaceToken, providerId: string): VfxDataInterfaceError {\n return {\n code: 'vfx-data-interface-duplicate',\n expected: 'at most one provider for each reflected Data Interface token',\n hint: `remove provider ${providerId} or the existing provider for ${token} and retry`,\n detail: { token, providerId },\n };\n}\n\nfunction availableProvider<K extends VfxDataInterfaceKind>(\n token: VfxDataInterfaceProvider<K>['token'],\n kind: K,\n bindingType: VfxDataInterfaceProvider<K>['bindingType'],\n source: VfxDataInterfaceAvailabilitySource,\n): VfxDataInterfaceProvider<K> {\n return {\n id: `${token}-provider`,\n token,\n kind,\n bindingType,\n provide: (generation) => {\n if (!source.available(generation)) {\n return err({\n code: 'vfx-data-interface-missing',\n expected: `an available ${kind} provider for ${token}`,\n hint: `make ${token} available for generation ${generation} and retry rendering`,\n detail: { token, providerId: `${token}-provider` },\n });\n }\n const resource: VfxDataInterfaceResource = {\n token,\n kind,\n bindingType,\n generation,\n };\n return ok(resource);\n },\n };\n}\n\nexport function createCameraProvider(\n source: VfxDataInterfaceAvailabilitySource,\n): VfxDataInterfaceProvider<'camera'> {\n return availableProvider('vfx:camera', 'camera', 'uniform', source);\n}\n\nexport function createSceneDepthProvider(\n source: VfxDataInterfaceAvailabilitySource,\n): VfxDataInterfaceProvider<'scene-depth'> {\n return availableProvider('vfx:scene-depth', 'scene-depth', 'sampled-depth', source);\n}\n\nexport function createVfxDataInterfaceRegistry(\n initialProviders: readonly VfxDataInterfaceProvider[] = [],\n): VfxDataInterfaceRegistry {\n const entries = new Map<VfxDataInterfaceToken, VfxDataInterfaceProvider>();\n let registrationError: VfxDataInterfaceError | undefined;\n let lastSnapshot: VfxDataInterfaceRegistry['snapshot'];\n const registry: VfxDataInterfaceRegistry = {\n get providers() {\n return Object.freeze([...entries.values()]);\n },\n get snapshot() {\n return lastSnapshot;\n },\n register(provider) {\n if (entries.has(provider.token)) {\n const error = duplicate(provider.token, provider.id);\n registrationError ??= error;\n return err(error);\n }\n entries.set(provider.token, provider);\n return ok(undefined);\n },\n resolve(requirements, generation) {\n const result =\n registrationError === undefined\n ? resolveVfxDataInterfaces(requirements, [...entries.values()], generation)\n : err(registrationError);\n lastSnapshot = Object.freeze({ generation, result });\n return result;\n },\n };\n for (const provider of initialProviders) registry.register(provider);\n return registry;\n}\n","import type { AssetRegistry } from '@forgeax/engine-assets-runtime';\nimport {\n type AssetRegistryResolver,\n getAssetRegistryResolver,\n} from '@forgeax/engine-assets-runtime/internal';\nimport { createWorldContext, type EntityHandle, type World } from '@forgeax/engine-ecs';\nimport type { AssetDecoderLease, MaterialAsset, MeshAsset, Result } from '@forgeax/engine-types';\nimport { err, ok } from '@forgeax/engine-types';\nimport type {\n VfxDataInterfaceError,\n VfxDataInterfaceProvider,\n VfxDataInterfaceRequirement,\n VfxDataInterfaceResolution,\n VfxGpuPlayerInspectSnapshot,\n VfxGpuRuntimeDiagnostic,\n VfxReplayInput,\n VfxValueMap,\n} from '@forgeax/engine-vfx';\nimport {\n ParticleEffectPlayer,\n VFX_GPU_RUNTIME_RESOURCE_KEY,\n type VfxGpuRuntime,\n vfxGpuEffectContribution,\n vfxGpuRuntimePlugin,\n} from '@forgeax/engine-vfx';\nimport type { ParticleRenderCameraSource } from '../feature/camera.js';\nimport { gpuParticleRenderFeature } from '../feature/gpu-particle-feature.js';\nimport {\n createVfxDataInterfaceRegistry,\n type VfxDataInterfaceRegistry,\n} from './data-interface-providers.js';\n\nexport interface VfxRuntimeHostOptions {\n readonly camera: ParticleRenderCameraSource;\n readonly maxQueuedTicks?: number;\n readonly providers?: readonly VfxDataInterfaceProvider[];\n}\n\nexport interface VfxRuntimeHostError {\n readonly code:\n | 'vfx-host-loader-install-failed'\n | 'vfx-host-world-attach-failed'\n | 'vfx-host-world-detach-failed';\n readonly expected: string;\n readonly hint: string;\n readonly detail: { readonly cause: unknown };\n}\n\nexport interface VfxRuntimeHostControlError {\n readonly code:\n | 'vfx-host-control-world-detached'\n | 'vfx-host-control-stale-generation'\n | 'vfx-host-control-runtime-unavailable'\n | 'vfx-host-control-player-unavailable';\n readonly expected: string;\n readonly hint: string;\n readonly detail: {\n readonly requestedGeneration?: number;\n readonly currentGeneration?: number;\n readonly player?: EntityHandle;\n };\n}\n\nexport interface VfxRuntimeHostControl {\n readonly generation: number;\n replay(input: {\n readonly player: EntityHandle;\n readonly replayInput?: VfxReplayInput<VfxValueMap>;\n }): Result<{ readonly state: 'queued'; readonly generation: number }, VfxRuntimeHostControlError>;\n setEmitterSessionEnabled(input: {\n readonly player: EntityHandle;\n readonly emitterId: string;\n readonly enabled: boolean;\n }): Result<\n {\n readonly state: 'enabled' | 'disabled';\n readonly generation: number;\n },\n VfxRuntimeHostControlError\n >;\n setPlayerRenderConsumption(input: {\n readonly player: EntityHandle;\n readonly enabled: boolean;\n }): Result<\n {\n readonly state: 'enabled' | 'paused';\n readonly generation: number;\n },\n VfxRuntimeHostControlError\n >;\n}\n\nexport interface VfxRuntimeHost {\n readonly feature: ReturnType<typeof gpuParticleRenderFeature>;\n readonly dataInterfaces: VfxDataInterfaceRegistry;\n inspect(world: World): VfxRuntimeHostInspectSnapshot | undefined;\n acquireControl(world: World): Result<VfxRuntimeHostControl, VfxRuntimeHostControlError>;\n resolveDataInterfaces(input: {\n readonly requirements: readonly VfxDataInterfaceRequirement[];\n readonly generation: number;\n }): Result<VfxDataInterfaceResolution, VfxDataInterfaceError>;\n attachWorld(input: {\n readonly world: World;\n readonly assets: AssetRegistry;\n }): Promise<Result<{ readonly state: 'attached' | 'already-attached' }, VfxRuntimeHostError>>;\n detachWorld(input: {\n readonly world: World;\n }): Promise<Result<{ readonly state: 'detached' | 'not-attached' }, VfxRuntimeHostError>>;\n}\n\n/** Install the VFX owner decoder into the one host registry. */\nexport function installVfxRuntimeDecoder(registry: AssetRegistry): AssetDecoderLease {\n return registry.installDecoder(vfxGpuEffectContribution.kind, vfxGpuEffectContribution.decoder);\n}\n\nexport interface VfxRuntimeHostInspectSnapshot {\n readonly generation: number;\n /** VFX GPU resource generation; distinct from host attachment generation. */\n readonly renderGeneration: number;\n readonly players: readonly VfxGpuPlayerInspectSnapshot[];\n readonly diagnostics: readonly VfxGpuRuntimeDiagnostic[];\n}\n\ntype PluginContext = Awaited<ReturnType<typeof createWorldContext>>;\n\nfunction failure(\n code: VfxRuntimeHostError['code'],\n expected: string,\n hint: string,\n cause: unknown,\n): VfxRuntimeHostError {\n return { code, expected, hint, detail: { cause } };\n}\n\nfunction controlFailure(\n code: VfxRuntimeHostControlError['code'],\n expected: string,\n hint: string,\n detail: VfxRuntimeHostControlError['detail'] = {},\n): VfxRuntimeHostControlError {\n return { code, expected, hint, detail };\n}\n\nexport function createVfxRuntimeHost(options: VfxRuntimeHostOptions): VfxRuntimeHost {\n const decoderLeases = new WeakMap<AssetRegistry, AssetDecoderLease>();\n const worlds = new WeakMap<\n World,\n {\n readonly assets: AssetRegistry;\n readonly resolver: AssetRegistryResolver | undefined;\n readonly generation: number;\n readonly pluginContext: PluginContext;\n readonly renderAssets: Map<string, MaterialAsset | MeshAsset>;\n readonly pendingRenderAssets: Map<string, Promise<void>>;\n readonly unsubscribeAssets: () => void;\n catalogEpoch: number;\n }\n >();\n const pausedPlayers = new WeakMap<World, Set<EntityHandle>>();\n let nextGeneration = 1;\n const dataInterfaces = createVfxDataInterfaceRegistry(options.providers);\n const readRenderAsset = <Kind extends 'material' | 'mesh'>(\n world: World,\n guid: string,\n kind: Kind,\n ): (Kind extends 'material' ? MaterialAsset : MeshAsset) | undefined => {\n const attached = worlds.get(world);\n if (attached === undefined) return undefined;\n const key = `${kind}:${guid.toLowerCase()}`;\n const cached = attached.renderAssets.get(key);\n if (cached?.kind === kind) return cached as Kind extends 'material' ? MaterialAsset : MeshAsset;\n const resolved = attached.resolver?.lookup<MaterialAsset | MeshAsset>(guid);\n if (resolved?.kind === kind) {\n attached.renderAssets.set(key, resolved);\n return resolved as Kind extends 'material' ? MaterialAsset : MeshAsset;\n }\n if (!attached.pendingRenderAssets.has(key)) {\n const epoch = attached.catalogEpoch;\n const request = attached.assets\n .load(guid, kind)\n .then((result) => {\n if (!result.ok || worlds.get(world) !== attached || attached.catalogEpoch !== epoch)\n return;\n attached.renderAssets.set(key, result.value);\n })\n .catch(() => undefined);\n attached.pendingRenderAssets.set(key, request);\n void request.finally(() => {\n if (attached.pendingRenderAssets.get(key) === request) {\n attached.pendingRenderAssets.delete(key);\n }\n });\n }\n return undefined;\n };\n const feature = gpuParticleRenderFeature({\n camera: options.camera,\n dataInterfaces,\n material: { read: (world, guid) => readRenderAsset(world, guid, 'material') },\n mesh: { read: (world, guid) => readRenderAsset(world, guid, 'mesh') },\n playerConsumption: {\n isEnabled: (world, player) => !pausedPlayers.get(world)?.has(player),\n },\n });\n return {\n feature,\n dataInterfaces,\n inspect: (world) => {\n const attached = worlds.get(world);\n if (attached === undefined || !world.hasResource(VFX_GPU_RUNTIME_RESOURCE_KEY))\n return undefined;\n const runtime = world.getResource<VfxGpuRuntime>(VFX_GPU_RUNTIME_RESOURCE_KEY);\n return Object.freeze({\n generation: attached.generation,\n renderGeneration: runtime.renderGeneration,\n players: runtime.inspectPlayers(),\n diagnostics: runtime.diagnostics(),\n });\n },\n acquireControl: (world) => {\n const attached = worlds.get(world);\n if (attached === undefined) {\n return err(\n controlFailure(\n 'vfx-host-control-world-detached',\n 'an attached VFX Runtime World',\n 'attach the World to this VfxRuntimeHost before acquiring controls',\n ),\n );\n }\n const requestedGeneration = attached.generation;\n const withRuntime = <T>(\n player: EntityHandle,\n action: (runtime: VfxGpuRuntime) => T,\n ): Result<T, VfxRuntimeHostControlError> => {\n const current = worlds.get(world);\n if (current === undefined) {\n return err(\n controlFailure(\n 'vfx-host-control-world-detached',\n `VFX host generation ${requestedGeneration} to remain attached`,\n 'reacquire controls after the World is attached again',\n { requestedGeneration },\n ),\n );\n }\n if (current.generation !== requestedGeneration) {\n return err(\n controlFailure(\n 'vfx-host-control-stale-generation',\n `VFX host generation ${requestedGeneration}`,\n 'discard this stale control lease and acquire one from the current host generation',\n { requestedGeneration, currentGeneration: current.generation },\n ),\n );\n }\n if (!world.hasResource(VFX_GPU_RUNTIME_RESOURCE_KEY)) {\n return err(\n controlFailure(\n 'vfx-host-control-runtime-unavailable',\n 'the attached World to own its VFX GPU runtime resource',\n 'repair the host attachment before retrying the preview command',\n { requestedGeneration, currentGeneration: current.generation },\n ),\n );\n }\n if (!world.get(player, ParticleEffectPlayer).ok) {\n return err(\n controlFailure(\n 'vfx-host-control-player-unavailable',\n 'a live entity with ParticleEffectPlayer in the attached World',\n 'discard the stale player handle or target a VFX player owned by this World',\n { requestedGeneration, currentGeneration: current.generation, player },\n ),\n );\n }\n return ok(action(world.getResource<VfxGpuRuntime>(VFX_GPU_RUNTIME_RESOURCE_KEY)));\n };\n const control: VfxRuntimeHostControl = {\n generation: requestedGeneration,\n replay: ({ player, replayInput }) =>\n withRuntime(player, (runtime) => {\n runtime.replay(player, replayInput);\n return Object.freeze({ state: 'queued' as const, generation: requestedGeneration });\n }),\n setEmitterSessionEnabled: ({ player, emitterId, enabled }) =>\n withRuntime(player, (runtime) => {\n runtime.setEmitterSessionEnabled(player, emitterId, enabled);\n return Object.freeze({\n state: enabled ? ('enabled' as const) : ('disabled' as const),\n generation: requestedGeneration,\n });\n }),\n setPlayerRenderConsumption: ({ player, enabled }) =>\n withRuntime(player, () => {\n let paused = pausedPlayers.get(world);\n if (enabled) {\n paused?.delete(player);\n if (paused !== undefined && paused.size === 0) pausedPlayers.delete(world);\n } else {\n paused ??= new Set();\n paused.add(player);\n pausedPlayers.set(world, paused);\n }\n return Object.freeze({\n state: enabled ? ('enabled' as const) : ('paused' as const),\n generation: requestedGeneration,\n });\n }),\n };\n return ok(Object.freeze(control));\n },\n resolveDataInterfaces: ({ requirements, generation }) =>\n dataInterfaces.resolve(requirements, generation),\n attachWorld: async ({ world, assets }) => {\n if (worlds.has(world)) return ok({ state: 'already-attached' });\n if (!decoderLeases.has(assets)) {\n try {\n decoderLeases.set(assets, installVfxRuntimeDecoder(assets));\n } catch (cause) {\n return err(\n failure(\n 'vfx-host-loader-install-failed',\n 'the VFX owner decoder to be installed once in the runtime core',\n 'remove a conflicting particle-effect decoder and retry attachWorld',\n cause,\n ),\n );\n }\n }\n let pluginContext: PluginContext;\n try {\n pluginContext = await createWorldContext(world, [\n vfxGpuRuntimePlugin(\n options.maxQueuedTicks === undefined ? {} : { maxQueuedTicks: options.maxQueuedTicks },\n ),\n ]);\n } catch (cause) {\n return err(\n failure(\n 'vfx-host-world-attach-failed',\n 'the World FixedUpdate VFX intent producer to install',\n 'repair the reported World registration conflict and retry',\n cause,\n ),\n );\n }\n let resolver: AssetRegistryResolver | undefined;\n try {\n resolver = getAssetRegistryResolver(assets);\n } catch {\n resolver = undefined;\n }\n const attached = {\n assets,\n resolver,\n pluginContext,\n generation: nextGeneration++,\n renderAssets: new Map<string, MaterialAsset | MeshAsset>(),\n pendingRenderAssets: new Map<string, Promise<void>>(),\n catalogEpoch:\n typeof (assets as { readonly snapshot?: unknown }).snapshot === 'function'\n ? assets.snapshot().epoch\n : 0,\n unsubscribeAssets: () => {},\n };\n const subscribe = (assets as { readonly subscribe?: AssetRegistry['subscribe'] }).subscribe;\n if (subscribe !== undefined) {\n attached.unsubscribeAssets = subscribe((snapshot) => {\n if (snapshot.epoch === attached.catalogEpoch) return;\n attached.catalogEpoch = snapshot.epoch;\n attached.renderAssets.clear();\n attached.pendingRenderAssets.clear();\n });\n }\n worlds.set(world, attached);\n return ok({ state: 'attached' });\n },\n detachWorld: async ({ world }) => {\n const attached = worlds.get(world);\n if (attached === undefined) return ok({ state: 'not-attached' });\n try {\n await attached.pluginContext.fiber.dispose();\n } catch (cause) {\n return err(\n failure(\n 'vfx-host-world-detach-failed',\n 'the VFX FixedUpdate producer to detach exactly once',\n 'inspect the World schedule and retry detachWorld',\n cause,\n ),\n );\n }\n pausedPlayers.delete(world);\n attached.unsubscribeAssets();\n attached.renderAssets.clear();\n attached.pendingRenderAssets.clear();\n worlds.delete(world);\n return ok({ state: 'detached' });\n },\n };\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@forgeax/engine-vfx-render",
3
+ "version": "0.1.2",
4
+ "private": false,
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "sideEffects": false,
8
+ "description": "Downstream persistent GPU simulation and indirect renderer for cooked code-first particle effects.",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "main": "./dist/index.mjs",
17
+ "types": "./dist/index.d.ts",
18
+ "files": [
19
+ "dist",
20
+ "src",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "dependencies": {
25
+ "@forgeax/engine-assets-runtime": "0.1.2",
26
+ "@forgeax/engine-ecs": "0.1.2",
27
+ "@forgeax/engine-math": "0.1.2",
28
+ "@forgeax/engine-render": "0.1.2",
29
+ "@forgeax/engine-scene": "0.1.2",
30
+ "@forgeax/engine-types": "0.1.2",
31
+ "@forgeax/engine-vfx": "0.1.2"
32
+ },
33
+ "devDependencies": {},
34
+ "forgeax": {
35
+ "metrics": {
36
+ "bundle-size": {
37
+ "enabled": true,
38
+ "path": "dist/index.mjs",
39
+ "compression": "gzip"
40
+ },
41
+ "fps": {
42
+ "enabled": false,
43
+ "reason": "renderer feature package has no host frame loop"
44
+ },
45
+ "bench": {
46
+ "enabled": true,
47
+ "reportSchema": "vfx-batch-b"
48
+ },
49
+ "gate": {
50
+ "enabled": true,
51
+ "reason": "public feature and dependency boundary checks"
52
+ },
53
+ "spike-report": {
54
+ "enabled": false,
55
+ "reason": "not a spike package"
56
+ }
57
+ }
58
+ },
59
+ "scripts": {
60
+ "build": "tsup",
61
+ "test": "vitest run"
62
+ }
63
+ }
@@ -0,0 +1,69 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { resolveBillboardAdvancedState } from '../feature/gpu-particle-feature.js';
3
+
4
+ const renderer = {
5
+ kind: 'billboard',
6
+ material: 'vfx',
7
+ textureSheet: { columns: 4, rows: 2, frameRate: 12, frameCount: 8 },
8
+ pivot: [0.2, 0.8],
9
+ softParticle: { fadeDistance: 0.5 },
10
+ sorting: 'back-to-front',
11
+ } as const;
12
+
13
+ describe('billboard advanced executable inputs', () => {
14
+ it('selects a bounded frame and changes the GPU-facing state', () => {
15
+ const state = resolveBillboardAdvancedState(renderer, {
16
+ age: 0.31,
17
+ lifetime: 1,
18
+ particleDepth: 0.2,
19
+ sceneDepth: 0.8,
20
+ depthAvailable: true,
21
+ });
22
+
23
+ expect(state.ok).toBe(true);
24
+ if (state.ok) {
25
+ expect(state.value.frameIndex).toBe(3);
26
+ expect(state.value.pivot).toEqual([0.2, 0.8]);
27
+ expect(state.value.softParticleFade).toBeGreaterThan(0);
28
+ expect(state.value.sortingKey).toBe(0.2);
29
+ }
30
+ });
31
+
32
+ it('fails closed when soft particles have no depth provider', () => {
33
+ const state = resolveBillboardAdvancedState(renderer, {
34
+ age: 0.1,
35
+ lifetime: 1,
36
+ particleDepth: 0.2,
37
+ sceneDepth: 0.8,
38
+ depthAvailable: false,
39
+ });
40
+
41
+ expect(state).toMatchObject({
42
+ ok: false,
43
+ error: { code: 'vfx-renderer-depth-missing' },
44
+ });
45
+ });
46
+
47
+ it('changes soft-particle alpha when scene depth changes before Fog mixing', () => {
48
+ const nearDepth = resolveBillboardAdvancedState(renderer, {
49
+ age: 0.1,
50
+ lifetime: 1,
51
+ particleDepth: 0.7,
52
+ sceneDepth: 0.75,
53
+ depthAvailable: true,
54
+ });
55
+ const farDepth = resolveBillboardAdvancedState(renderer, {
56
+ age: 0.1,
57
+ lifetime: 1,
58
+ particleDepth: 0.7,
59
+ sceneDepth: 1.0,
60
+ depthAvailable: true,
61
+ });
62
+
63
+ expect(nearDepth.ok).toBe(true);
64
+ expect(farDepth.ok).toBe(true);
65
+ if (nearDepth.ok && farDepth.ok) {
66
+ expect(farDepth.value.softParticleFade).toBeGreaterThan(nearDepth.value.softParticleFade);
67
+ }
68
+ });
69
+ });
@@ -0,0 +1,55 @@
1
+ import { ok } from '@forgeax/engine-types';
2
+ import { describe, expect, it } from 'vitest';
3
+ import {
4
+ createVfxDataInterfaceRegistry,
5
+ type VfxDataInterfaceProvider,
6
+ } from '../host/data-interface-providers.js';
7
+
8
+ function provider(token: VfxDataInterfaceProvider['token']): VfxDataInterfaceProvider {
9
+ return {
10
+ id: `${token}-provider`,
11
+ token,
12
+ kind: token.slice(4) as VfxDataInterfaceProvider['kind'],
13
+ bindingType: token === 'vfx:scene-depth' ? 'sampled-depth' : 'uniform',
14
+ provide: (generation) =>
15
+ ok({
16
+ token,
17
+ kind: token.slice(4) as VfxDataInterfaceProvider['kind'],
18
+ bindingType: token === 'vfx:scene-depth' ? 'sampled-depth' : 'uniform',
19
+ generation,
20
+ }),
21
+ };
22
+ }
23
+
24
+ describe('VFX host Data Interface providers', () => {
25
+ it('rejects duplicate tokens before a second provider can replace the first', () => {
26
+ const registry = createVfxDataInterfaceRegistry();
27
+ expect(registry.register(provider('vfx:camera'))).toMatchObject({ ok: true });
28
+ const duplicate = registry.register(provider('vfx:camera'));
29
+ expect(duplicate).toMatchObject({
30
+ ok: false,
31
+ error: {
32
+ code: 'vfx-data-interface-duplicate',
33
+ detail: { token: 'vfx:camera' },
34
+ },
35
+ });
36
+ });
37
+
38
+ it('projects readiness and errors by reflected token', () => {
39
+ const registry = createVfxDataInterfaceRegistry();
40
+ registry.register(provider('vfx:camera'));
41
+ const result = registry.resolve(
42
+ [
43
+ {
44
+ token: 'vfx:camera',
45
+ kind: 'camera',
46
+ binding: 8,
47
+ bindingType: 'uniform',
48
+ lifetime: 'generation',
49
+ },
50
+ ],
51
+ 11,
52
+ );
53
+ expect(result).toMatchObject({ ok: true, value: { readiness: 'ready', generation: 11 } });
54
+ });
55
+ });
@@ -0,0 +1,58 @@
1
+ import { ok, type Result } from '@forgeax/engine-types';
2
+ import type {
3
+ VfxDataInterfaceError,
4
+ VfxDataInterfaceRequirement,
5
+ VfxDataInterfaceResolution,
6
+ } from '@forgeax/engine-vfx';
7
+ import { describe, expectTypeOf, it } from 'vitest';
8
+ import {
9
+ createCameraProvider,
10
+ createSceneDepthProvider,
11
+ createVfxDataInterfaceRegistry,
12
+ type VfxDataInterfaceProvider,
13
+ type VfxDataInterfaceRegistry,
14
+ } from '../index.js';
15
+
16
+ describe('VFX Data Interface public types', () => {
17
+ it('keeps factories and readiness on the public provider protocol', () => {
18
+ const camera = createCameraProvider({ available: () => true });
19
+ const depth = createSceneDepthProvider({ available: () => true });
20
+ const registry = createVfxDataInterfaceRegistry([camera, depth]);
21
+ const requirements: VfxDataInterfaceRequirement[] = [
22
+ {
23
+ token: 'vfx:scene-depth',
24
+ kind: 'scene-depth',
25
+ binding: 9,
26
+ bindingType: 'sampled-depth',
27
+ lifetime: 'generation',
28
+ },
29
+ ];
30
+ const result = registry.resolve(requirements, 4);
31
+
32
+ expectTypeOf(camera).toMatchTypeOf<VfxDataInterfaceProvider>();
33
+ expectTypeOf(depth).toMatchTypeOf<VfxDataInterfaceProvider>();
34
+ expectTypeOf(registry).toMatchTypeOf<VfxDataInterfaceRegistry>();
35
+ expectTypeOf(result).toEqualTypeOf<Result<VfxDataInterfaceResolution, VfxDataInterfaceError>>();
36
+ expectTypeOf(registry.snapshot?.result).toEqualTypeOf<
37
+ Result<VfxDataInterfaceResolution, VfxDataInterfaceError> | undefined
38
+ >();
39
+ });
40
+
41
+ it('rejects a provider with binding metadata outside its reflected kind', () => {
42
+ const invalid: VfxDataInterfaceProvider<'scene-depth'> = {
43
+ id: 'invalid',
44
+ token: 'vfx:scene-depth',
45
+ kind: 'scene-depth',
46
+ // @ts-expect-error Scene depth is sampled-depth, not uniform.
47
+ bindingType: 'uniform',
48
+ provide: () =>
49
+ ok({
50
+ token: 'vfx:scene-depth',
51
+ kind: 'scene-depth',
52
+ bindingType: 'sampled-depth',
53
+ generation: 1,
54
+ }),
55
+ };
56
+ expectTypeOf(invalid).toMatchTypeOf<VfxDataInterfaceProvider>();
57
+ });
58
+ });