public static class VfxShaderPackingMoves one attribute between ParticleBuffer and the bytes a storage buffer holds.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Here rather than in the host, because the layout is decided here. VfxShaderEmitter chose to declare a three-component attribute as float4 — std430 gives a vec3 array a stride of sixteen either way, so declaring the padding is cheaper than pretending it is not there. That decision has a consequence for whoever fills the buffer, and the consequence belongs next to the decision. A renderer that wrote a packed Vector3[] straight into the buffer would read every particle after the first from the wrong offset, and nothing would say so.
Both directions, because the interesting test needs both. Uploading is what a spawn does; downloading is what the CPU/GPU agreement test does, and it is the only way to ask the two backends whether they agree. It is a stall by construction — see VfxGpuSimulation, which says when that is worth paying.
Methods (3)
public static int Size(in VfxShaderBinding binding, int count)How many bytes a run of particles occupies in one binding's buffer.
public static void Pack(ParticleBuffer particles, in VfxShaderBinding binding, int count, Span<byte> destination)Writes the first particles of one attribute into bytes.
public static void Unpack(ReadOnlySpan<byte> source, in VfxShaderBinding binding, int count, ParticleBuffer particles)Reads bytes back into the first particles of one attribute.
Used by (1)
- VfxGpuSimulationVixen.Rendering