public sealed class VfxGpuSimulationThe device-side half of a particle system: its storage, its descriptors, and its dispatches.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
What this owns and what it does not. It owns the buffers a VfxShaderEmitter-emitted shader binds, the descriptor set that names them, and the pipeline layout the two kernels share. It does not own the pipelines: turning Raven source into a module is the shader compiler's job, and a runtime that linked against one would be a runtime that shipped a compiler. The caller compiles and hands the PipelineHandle to Initialize and Update.
Why it lives here rather than in Vixen.Vfx. The particle runtime is device-free by design — it is testable, jobifiable and shippable without a graphics API, and its README says so. This is the module that already owns an IGraphicsDevice. What crosses the line is the layout, and that stayed behind: this file asks VfxShaderPacking what the bytes look like rather than knowing.
Upload and download are stalls, and are meant to be rare. A GPU effect exists so that particle state never leaves the device; the two transfer paths are here for the two cases where it must — seeding a system from a CPU spawn, and reading the result back to compare it against the CPU backend, which is the only way to ask whether the two agree. Neither belongs in a frame. The dispatches do, and they touch neither.
The push constants are the whole per-dispatch state. Twenty bytes written into the command buffer, so an initialize and an update can be recorded into one list with different values — which a uniform buffer could not do without being two buffers. See VfxShaderUniforms, whose field order is the shader's declaration order.
Fields and properties (9)
public const int DrawArgumentsSizeHow many bytes a DrawIndexedIndirect command occupies.
public int CapacityThe most particles that can be alive at once.
public long BytesHow much one set of the attributes occupies, in bytes.
public bool HasReapWhether the shader has a reap kernel, and so whether this has the storage for one.
public IReadOnlyList<VfxShaderBinding> BindingsThe buffers, in the order the shader declares them.
public PipelineLayoutHandle LayoutThe layout every kernel is created against.
public DescriptorSetHandle DescriptorsThe set naming the live buffers as the source and the spare as the destination.
public BufferHandle DrawArgumentsThe indirect draw command WriteDrawArguments keeps up to date.
public int IndicesPerParticleHow many indices one particle's geometry uses.
Methods (13)
public VfxGpuSimulation(IGraphicsDevice device, VfxShader shader, int capacity)Allocates the storage one emitted shader expects, and the descriptors naming it.
public BufferHandle Storage(VfxAttribute attribute)The buffer holding one attribute, for a renderer that wants to draw from it.
public BufferHandle Custom(int slot)The buffer holding one custom attribute.
public static int Groups(int count)How many workgroups cover a run of particles.
public void Upload(ICommandList list, ParticleBuffer particles, int count)Records the copies that put a CPU buffer's particles on the device.
public void Initialize(ICommandList list, PipelineHandle pipeline, int first, int count, uint seed, float time, Vector3 origin = default(Vector3))Records the initializer dispatch over one run of newly spawned particles.
public void Update(ICommandList list, PipelineHandle pipeline, int count, float deltaTime, uint seed, float time)Records the update dispatch over every live particle.
public void Download(ICommandList list, int count)Records the copies that bring the device's particles back.
public void Read(ParticleBuffer particles, int count)Puts a completed Download into a CPU buffer.
public void Reap(ICommandList list, PipelineHandle pipeline, int count)Records the compaction: every survivor claims a slot, and the dead leave no hole.
public int ReadSurvivors()How many particles the last Reap kept.
public void WriteDrawArguments(ICommandList list)Records the copies that put the survivor count into the indirect draw command.
public void Dispose()Frees every device object it made.
Used by (4)
- VfxAgreementTestsVixen.Vfx.Gpu.Tests
- VfxGpuSortVixen.Rendering
- VfxReapTestsVixen.Vfx.Gpu.Tests
- VfxSortTestsVixen.Vfx.Gpu.Tests