Vixen
02b45cc4
csharp
public readonly record struct SortKey

What a stage sorts by, packed so the sort is one integer comparison.

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

Remarks

Grouping in the high bits, depth in the low ones. That single decision is what makes a front-to-back sort also a state-change-minimising sort: comparing the whole 64 bits orders by group first and by depth within a group, with no branch and no second pass. Sorting by depth alone is the classic mistake — it makes a scene slower the better it is culled, because the draw order stops correlating with pipeline state.

Depth is quantised to 32 bits, which at any real draw distance is far finer than the depth buffer it feeds. Two objects landing on the same value sort by their id, which costs nothing and makes the order deterministic — a frame that draws in a different order run to run is one that cannot be compared against a golden image.

Fields and properties (1)

  • public ulong Value

Methods (10)

  • public SortKey(ulong Value)

    What a stage sorts by, packed so the sort is one integer comparison.

  • public static SortKey FrontToBack(uint group, float distance)

    Builds a key that orders near objects before far ones, grouped first.

  • public static SortKey BackToFront(float distance)

    Builds a key that orders far objects before near ones.

  • public static SortKey ByGroup(uint group)

    Builds a key that orders by group alone, leaving depth out.

  • public int CompareTo(SortKey other)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

  • public static bool operator <(SortKey left, SortKey right)

    Whether sorts before .

  • public static bool operator >(SortKey left, SortKey right)

    Whether sorts after .

  • public static bool operator <=(SortKey left, SortKey right)

    Whether sorts no later than .

  • public static bool operator >=(SortKey left, SortKey right)

    Whether sorts no earlier than .

  • public override string ToString()

    Returns the fully qualified type name of this instance.

Used by (2)

  • RenderNodeVixen.Rendering
  • RenderSystemVixen.Rendering