Skip to content

janitor: use fi and di from u_math.h across the tree

Ferdinand Bachmann requested to merge yrlf/mesa:janitor-use-fi-di into main

This MR addresses issue #9847.

This is mostly a relatively straightforward translation from various ad-hoc copies of union fi and union di to the common definition in u_math.h. This MR also removes the last remaining definition (fi_type) from mesa_private.h, removing that header.

Converted usage sites

  • src/util/:
    • format_rgb9e5.h: straightforward conversion from custom union to fi
    • format_r11g11b10f.h: straightforward conversion from custom union to fi
    • format_srgb.h: straightforward conversion from custom union to fi
    • bitpack_helpers.h: straightforward conversion from custom union to fi
    • half_float.c: straightforward conversion from custom union to fi
    • softfloat.c: straightforward conversion from custom unions to fi and di
  • src/intel/isl:
    • isl_emit_depth_stencil.c: straightforward conversion from custom union to fi
  • src/freedreno/rnn:
    • rnndec.c: partially converted; converted use in float float16(uint16_t)
  • src/gallium/drivers/nouveau:
    • nouveau_winsys.h: straightforward conversion from custom union to fi
  • src/gallium/frontends/nine:
    • nine_helpers.h: straightforward conversion from custom union to fi
  • src/mesa/main:
    • mesa_private.h: previously defined fi_type, now everything that used that now uses union fi
      the file became empty by removing that definition, so I removed the file
    • macros.h: some macros required changing to adjust to the different member names of union fi
    • context.c: adjust member name .u to .ui
    • tests/disable_windows_include.c: remove mesa_private.h
  • src/mesa/vbo:
    • vbo.h: switch from fi_type to union fi
    • vbo_save.h: switch from fi_type to union fi
    • vbo_private.h switch from fi_type to union fi
    • vbo_exec.c, vbo_exec_api.c, vbo_exec_draw.c: switch from fi_type to union fi
    • vbo_save_api.c, vbo_save_draw.c, vbo_save_loopback.c: switch form fi_type to union fi

Skipped usage sites

  • src/intel/vulkan/grl:
    • include/GRLOCLCompatibility.h: unsure if this should use fi
      since the header seems to go out of its way not to depend on other mesa things
  • src/freedreno/rnn:
    • rnndec.c: partially converted; skipped use in rnndec_decodeval
      since it uses the same union to pun between uint64_t, float, and double
      while fi and di only support either punning to float or double
  • src/imgui:
    • imgui.h: external library vendored into mesa
      also uses the same union to pun between more types: int, float, void*

This PR is no longer a draft, but I'm still combing through the tree and adding commits as I find instances of this. I will squash the individual commits into one big janitor commit before this is merged, but leave it separated while I'm working on it to keep track of what I have already done.

Edited by Ferdinand Bachmann

Merge request reports