glsl: Write a new test for GLSL and NIR mediump lowering.
authorEmma Anholt <emma@anholt.net>
Mon, 27 Feb 2023 20:50:22 +0000 (12:50 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 22 Mar 2023 22:52:45 +0000 (22:52 +0000)
commit772cacff32b2ed22799a1dbaeac6857824400f53
treed3908d73f44f08f977a7596bb96af13ed2d44a92
parent41f51fe815c74c2bcd2611c47e228236c3e827e4
glsl: Write a new test for GLSL and NIR mediump lowering.

The mediump lowering tests are important for poking at the lowering pass
behavior, since you can't really assert the behavior in any given driver,
given that the GLSL spec allows any mediump op to be done in highp.

But, in hacking on mediump lowering, I wanted several things that the old
test couldn't do:

- Be able to assert about the actual NIR code we expect to generate for a
  hypothetical driver (important if other compiler stages might do invalid
  transformations like eliminating highp temps, or if we were to move the
  lowering after GLSL IR)
- Run faster (gtest unit tests rather than python forking off the standalone
  glsl compiler per testcase).
- Express expectations with a lot less escaping of typical syntax.
- High-quality logs for displaying failures.

This new test does all of that, I think, though I haven't converted all of
the unit tests over yet.  In converting, I dropped some of the
combinatorial explosion for float/int variations, instead only doing so
when it gets at some different code path (default precision flags).  I've
also included some new tests I wrote in the process of writing my proposed
gl_nir mediump lowering.

Even if the conversion isn't complete, getting these tests to run faster
is probably a good idea on its own, for anyone iterating running Mesa's
unit tests (80 tests in 25ms, compared to 109 tests in 1.5s!).

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21886>
meson.build
src/compiler/glsl/tests/lower_precision_test.py
src/compiler/glsl/tests/meson.build
src/compiler/glsl/tests/test_gl_lower_mediump.cpp [new file with mode: 0644]