Vixen
02b45cc4
csharp
public struct VfxShaderUniforms

The push-constant block VfxShaderEmitter declares, as the host writes it.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Why this is a struct and not a set of arguments. The emitted shader opens with five push constants in a fixed order, and a push-constant block is laid out by that order. Something has to know it in order to fill the bytes, and the choice is between a host that spells the offsets out by hand and a declaration sitting next to the emitter that writes them. This is the second one: the field order here is the declaration order there, and the two are one file apart rather than one assembly apart.

It is checked rather than trusted. The layout rule is std430's and the compiler applies it, so agreement is a claim about two pieces of code and not something a comment can secure. VfxGpuLayoutTests compiles the emitted source and compares the reflected offsets to these ones, member by member — which is why the fields are ordinary and public rather than packed cleverly.

Eight scalars, each four bytes, each four-byte aligned: Size is thirty-two and there is no padding anywhere in it. That is one reason to prefer scalars here over, say, a float4 of packed parameters — the packed one would be the version with a layout rule worth getting wrong.

⚠ Which is also why the origin is three floats and not a float3. std430 aligns a three-component vector to sixteen bytes, so one here would pad the block after Time and again at its own tail — turning a layout with no rule in it into one with two. Well inside the hundred and twenty-eight bytes of push constants every Vulkan device guarantees either way.

Fields and properties (10)

  • public const int Size

    How big the block is, in bytes, under std430.

  • public float DeltaTime

    The step, in seconds. Zero for an initializer dispatch.

  • public uint Seed

    The system instance's seed.

  • public int First

    The first particle the dispatch touches.

  • public int ParticleCount

    How many it touches.

  • public float Time

    How long the system has been running, in seconds.

  • public float OriginX

    Where the emitter is, x. Added to every position an initializer writes.

  • public float OriginY

    Where the emitter is, y.

  • public float OriginZ

    Where the emitter is, z.

  • public Vector3 Origin

    The three as a vector, and a block carrying one.

Used by (2)

  • VfxGpuSimulationVixen.Rendering
  • VfxShaderUniformTestsVixen.Vfx.Tests