Image of character from Team Fortress 2 saying “I fear no man” labelled Opengl Programmers “But that thing…” Tranparency “It scares me.”

  • deegeese@sopuli.xyz
    link
    fedilink
    arrow-up
    36
    ·
    1 年前

    You can use an O(n) radix sort on the Z-values because IEEE-754 floats share the integer property that leftmost bits always have higher values than rightward ones.

    • Kevin@programming.dev
      link
      fedilink
      English
      arrow-up
      26
      ·
      1 年前

      Oh that just made it click in my head why they would do it as sign, exponent, mantissa and not sign, mantissa, exponent. I mean yes I’ve been taught it’s for sorting purposes, but this really helped it fit better. Thanks!

    • 257m@lemmy.mlOP
      link
      fedilink
      arrow-up
      10
      ·
      1 年前

      Thanks man, I’ll look into it when I have the time. This should work on all IEEE compliant systems right?

      • jarfil@beehaw.org
        link
        fedilink
        arrow-up
        3
        ·
        1 年前

        Yes, but… “leftmost” in this case means MSB-sidemost, so little-endian systems will start sorting from the MSB only after loading the full value in a register; if you try sorting directly from memory in binary chunks smaller than the float size, first locate where the MSB is stored.