public static class VfxShaderEmitterThe GPU backend's front half: a compiled graph turned into a Raven compute shader.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Why this is a translation and not a second implementation. The compiled graph was given the shape it has — an array of fixed-size operations, no delegates, no pointers, nothing to walk — precisely so that this file could be a switch that writes a line of source per operation. Every decision that would otherwise have to be made twice was made once, in VfxCompiledGraph: which attributes exist, what each operation reads and writes, and which salt each draws on. What is left here is spelling.
The order is inverted, and that is the one real difference. VfxSimulation sweeps per operation across every particle, because on a CPU that keeps the opcode dispatch out of the inner loop and walks each attribute array end to end. A dispatch has no inner loop to keep anything out of: one invocation owns one particle and runs the whole graph on it, so every intermediate stays in registers and the buffer is touched once at each end. Sweeping per operation on the GPU would mean one dispatch per operation and a round trip through memory between each — the same arithmetic at several times the bandwidth. Both orders are correct because no operation reads another particle.
The graph is unrolled, not interpreted. The operation array could have been uploaded and stepped through by a shader with a switch in it, which would need one shader for every graph instead of one per graph. It would also put a branch on every instruction in the hot path of the one processor that most dislikes them. The graph is known when the effect is compiled, so it is spelled out.
What agrees exactly and what agrees closely. The hash is integer arithmetic throughout and is exact on both sides — that is what VfxRandom is built for, and it is the part that has to be exact, because a random value that differs by one bit puts a particle somewhere else entirely. The arithmetic downstream of it is ordinary floating point: a sine, a cube root or an exponential is accurate to a fraction of an ulp and the two libraries need not choose the same fraction. So the agreement test is exact on the hash and a tolerance on positions, which is the honest form of that claim.
Methods (1)
public static VfxShader Emit(VfxCompiledGraph graph, string name = "Effect")Turns a compiled graph into Raven source.
Used by (7)
- VfxAgreementTestsVixen.Vfx.Gpu.Tests
- VfxCustomAttributeTestsVixen.Vfx.Tests
- VfxReapTestsVixen.Vfx.Gpu.Tests
- VfxShaderEmitterTestsVixen.Vfx.Tests
- VfxShaderUniformTestsVixen.Vfx.Tests
- VfxSortTestsVixen.Vfx.Gpu.Tests
- VfxGraphCompilerVixen.Editor.VfxGraph