Commit Graph

143 Commits

Author SHA1 Message Date
Alyssa Rosenzweig 77fcb4b291 pan/bi: Strip negate when lowering swizzles
When we lower swizzles, we move source modifiers (except for the swizzle) after
the swizzle operation. In particular, we change the order of composition for
negates and abs. However, copying the source will copy the modifiers unless we
specifically strip the extra modifiers. That's harmless in practice on Bifrost,
which doesn't check for extraneous modifiers, but is incorrect IR and trips an
assertion in the Valhall packing code.

Fixes test_relations.relational_bitselect.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18656>
2022-09-19 17:22:58 +00:00
Alyssa Rosenzweig 377bf3a5a4 pan/bi: Lower swizzles for 8-bit shifts
Fixes integers_ops.integer_ctz

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18656>
2022-09-19 17:22:58 +00:00
Alyssa Rosenzweig 2e1b02e6a3 pan/bi: Test some 8-bit swizzle lowering
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18656>
2022-09-19 17:22:58 +00:00
Alyssa Rosenzweig d471b386c1 pan/bi: Unit test swizzle lowering
We're about to extend this pass to support 8-bit swizzles. That will be a
nontrivial change, so let's get some testing for what's already in the pass.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18656>
2022-09-19 17:22:58 +00:00
Alyssa Rosenzweig 29f53ee8bb pan/bi: Don't write registers in optimizer tests
The new SSA-based dead code elimination won't know how to deal with code of that
funny form. In actuality it doesn't have to, so we just make sure the optimizer
tests produce valid IR so this works as expected.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>
2022-09-02 16:03:23 +00:00
Alyssa Rosenzweig 9c45ce309d pan/bi: Use variable src/dest for collect/split
This avoids the nr_srcs/nr_dests setting dance, and will allow the builder to
handle the required memory allocation when we switch to dynamic src/dest
allocation.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>
2022-09-02 16:03:23 +00:00
Alyssa Rosenzweig 9ec157c482 pan/bi: Introduce TEXC_DUAL psuedoinstruction
There are two "shapes" of TEXC in the IR:

* Regular texturing. This TEXC writes a single set of staging registers.
* Dual texturing. This TEXC writes two sets of staging registers.

Currently we model both with a 2-destination TEXC, with a null second
destination for the usual case where dual texturing isn't used. This is awkward.
To make the "shapes" of instructions more predictable, make TEXC only write a
single set of staging registers (like the hardware instruction) and split off a
TEXC_DUAL pseudoinstruction for the second case, lowered late.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>
2022-09-02 16:03:23 +00:00
Alyssa Rosenzweig 718748fe61 pan/bi: Test int8/16 -> float32 opts
These are easy, since round modes don't matter.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17857>
2022-08-19 17:25:58 +00:00
Alyssa Rosenzweig 10301885ab pan/bi: Constant fold MKVEC.v2i8
Constant MKVEC.v2i8 will be generated during texturing on Valhall, just like
constant MKVEC.v4i8 is currently generated.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17101>
2022-06-21 22:42:34 +00:00
Alyssa Rosenzweig e898e2466b pan/bi: Add VAR_TEX fusing unit test
As fusing VAR_TEX is an optimization, it's helpful to have unit tests since
functional tests won't check that the optimization triggers when expected.
Originally written when I was touching the VAR_TEX code. Those changes have
since been dropped by the unit test remains useful.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16752>
2022-05-30 17:48:59 -04:00
Alyssa Rosenzweig 01ba3460a9 pan/bi: Test CMP result_type optimization
Add unit tests ensuring the optimization applies in all the cases we care about,
as functional integration tests (CTS and Piglit) won't test this. Also add unit
tests for a few cases where we specifically cannot fuse, in case these cases are
missed by the tests.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16725>
2022-05-27 12:14:22 +00:00
Alyssa Rosenzweig 3df5446cbd pan/bi: Simplify register precolouring in the IR
In the current IR, any register may be preloaded by reading it anywhere, and any
register may be precoloured by writing it anywhere. This is convenient for
instruction selection, but requires the register allocator to do considerable
gymnastics to ensure it doesn't clobber precoloured registers. It also breaks
the purity of our SSA representation, which complicates optimization passes
(e.g. copyprop).

Let's trade some instruction selection complexity for simplifying register
allocation by constraining how register precolouring works. Under the new model:

* Registers may only be preloaded at the start of the program.
* Precoloured destinations are handled explicitly by RA.

Internally, a stronger invariant is placed for preloading: registers may only be
preloaded by MOV.i32 instructions at the beginning of the block, and these moves
must be unique. These invariants ensure RA can trivially coalesce the moves.

A bi_preload helper is added as a safe version of bi_register respecting these
invariants, allowing a smooth transition for instruction selection.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16585>
2022-05-19 16:08:26 +00:00
Alyssa Rosenzweig 8fdb01b96f pan/bi: Create COLLECT during isel
This transitions us away from the fake SSA we currently use for vectors.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16585>
2022-05-19 16:08:26 +00:00
Alyssa Rosenzweig c8882ee115 pan/bi: +JUMP can't read same-cycle temp
Minor ISA detail missed in the Bifrost scheduler. I hit this in an early version
of this series (where a move feeding into a blend shader return was not
coalesced). Let's get it fixed in the scheduler.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16585>
2022-05-19 16:08:26 +00:00
Alyssa Rosenzweig 1fb4427a7a pan/bi: Imply round mode most of the time
Much less noisy, and provides a path to further improvements. There is a slight
behaviour change: int-to-float conversions now use RTE instead of RTZ. For
32-bit opcodes, this affects conversions of integers with magnitude greater than
2^23 by at most 1 ulp. As this behaviour is unspecified in GLSL, this change is
believed to be acceptable.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15187>
2022-04-07 18:03:57 +00:00
Alyssa Rosenzweig 24d072fd6a pan/bi: Don't use funny round modes in tests
To prepare for defeaturing round modes, replace uses of round-to-positive with
round-to-even in our unit tests. This doesn't meaningfully impact test coverage;
there is no way to generate that round mode.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15187>
2022-04-07 18:03:57 +00:00
Alyssa Rosenzweig 5796777889 pan/bi: Model offset for LOAD/STORE
Needed to model the immediate offset on Valhall.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15216>
2022-03-03 00:41:43 +00:00
Alyssa Rosenzweig 20891e75c2 pan/bi: Extend BLEND to take a register format
Needed on Valhall.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15216>
2022-03-03 00:41:43 +00:00
Alyssa Rosenzweig eda00fd39d pan/bi: Extract INSTRUCTION_CASE macro
Useful across multiple optimization tests.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15204>
2022-03-01 19:43:23 +00:00
Alyssa Rosenzweig cd2a4cc47c pan/bi: Unit test message preloading optimization
To make sure it is applied in the cases we expect it to be, to avoid code
generation regressions. Functional regressions are expected to be caught by
integration-testing, so that is not focused on here.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9438>
2022-02-24 14:13:21 -05:00
Alyssa Rosenzweig 8f4b3c749e pan/bi: Test avoiding FADD.v2f16 hazards in scheduler
There are many of them, and integration testing of the scheduler won't hit every
case. Add targeted unit tests for the various scheduling hazards of this funny
instruction.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15072>
2022-02-18 16:15:04 +00:00
Alyssa Rosenzweig 9d95561c93 pan/bi: Test avoiding *FADD.v2f16 hazard in optimizer
This hazard exists but is obscure enough to be missed on our existing test
coverage (e.g the conformance tests). Add piles of unit tests for it.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15072>
2022-02-18 16:15:04 +00:00
Alyssa Rosenzweig 795638767d pan/bi: Use fused dual source blending
Instead of emitting a pile of moves to fixed registers at codegen time
and hoping everything works out, add a second staging source to the
BLEND instruction in the intermediate representation containing the dual
source colour, and modify register allocation appropriately. This better
models the operation of blending render target #0 with two sources.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13714>
2022-01-02 01:12:05 +00:00
Alyssa Rosenzweig 0c215813f7 pan/bi: Test dual texture fusing
These patterns are quite tricky, so let's make sure we're testing
adequately.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13723>
2021-11-12 16:30:02 +00:00
Caio Oliveira baa405f02a pan/bi: Use gtest for test-constant-fold
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13684>
2021-11-08 19:02:02 +00:00
Caio Oliveira 4554cd03f0 pan/bi: Use gtest for test-optimizer
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13684>
2021-11-08 19:02:01 +00:00
Caio Oliveira 06b3b53768 pan/bi: Use gtest for test-pack-formats
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13684>
2021-11-08 19:02:01 +00:00
Caio Oliveira 71cbb9c4f0 pan/bi: Use gtest for test-packing
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13684>
2021-11-08 19:02:01 +00:00
Caio Oliveira fecb299b81 pan/bi: Use gtest for test-scheduler-predicates
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13684>
2021-11-08 19:02:01 +00:00
Alyssa Rosenzweig cb2e712b9e pan/bi: Unit test DISCARD+FCMP fusing
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12205>
2021-08-11 14:59:26 -04:00
Alyssa Rosenzweig 4f347e96b8 pan/bi: Add fclamp unit tests
The negative cases here did not pass before this series, showing the bug
in the clamp optimization. By introducing the FCLAMP pseudo op, the bug
is fixed. Let's ensure we don't regress.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12205>
2021-08-11 14:59:26 -04:00
Alyssa Rosenzweig a98790fa96 pan/bi: Add optimizer unit tests
Writing these tests brought to light the cluster of bugs fixed in the
previous commits. Now that things work, let's ensure they stay working.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12205>
2021-08-11 14:59:26 -04:00
Alyssa Rosenzweig cfd73b4542 pan/bi: Unit test new constant folding patterns
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12205>
2021-08-11 14:59:25 -04:00
Alyssa Rosenzweig 67b9b73f9f pan/bi: Test restrictions on same-cycle temporaries
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12114>
2021-07-29 19:33:32 +00:00
Alyssa Rosenzweig d972326c45 pan/bi: Teach meson about format pack tests
Now we have all our Bifrost unit tests under meson and can remove the
test entrypoint from bifrost_compiler. This does require a small
refactoring for our util_dynarray handling to make sure we don't leak
memory. Otherwise meson-arm64-asan complains.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12109>
2021-07-28 22:16:14 +00:00
Alyssa Rosenzweig 8a6c214b6a pan/bi: Teach meson about Bifrost packing test
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12109>
2021-07-28 22:16:14 +00:00
Alyssa Rosenzweig 9bb731012e pan/bi: Teach meson about scheduler predicate test
One step of 3 to getting all our tests in meson test.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12109>
2021-07-28 22:16:14 +00:00
Alyssa Rosenzweig 16579ca4b7 pan/bi: Add constant folding unit test
I just played with the implementation, let's ensure I didn't break it.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12026>
2021-07-28 00:26:06 +00:00
Alyssa Rosenzweig bcd0a285bb pan/bi: Drop on-board packing tests
These tests were designed before having access to canonical information
about the hardware and thus had two purposes:

* Validating that our understanding of an instruction (as defined by IR
  semantics) matches hardware behaviour -- obsoleted by new information.

* Validating that the IR packing code is correct -- obsoleted by
  rewriting the IR and rewriting the packing.

I dislike removing tests as much as the next person, but the value of
these will be nil by the end of the series, and will prove burdensome.
Proper unit tests will be useful, however.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8213>
2020-12-23 17:06:56 +00:00
Boris Brezillon 0ed8eee706 pan/bi: Split special class in two
Some special instructions are scheduled on the FMA unit, let's add a
new class for this case and rename the old one accordingly.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7408>
2020-11-03 14:42:42 +00:00
Boris Brezillon 1b3b289c5c panfrost: Rename panfrost_transfer to panfrost_ptr
And use it in panfrost_bo to store a GPU/CPU pointer tuple.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
2020-10-23 14:48:22 +00:00
Boris Brezillon bf3cd28319 panfrost: Use real name for attribute's unknown field
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
2020-10-23 14:48:22 +00:00
Boris Brezillon 69c864b0b9 panfrost: Make {midgard,bifrost}_compile_shader_nir() return a program object
Letting the caller zero-initialize the program object is error prone,
not to mention that resources attached to the program might not be freed
by the caller. Let's simplify that by letting the compiler allocate the
panfrost_program object. Those objects should be freed with ralloc_free().

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
2020-10-23 14:48:22 +00:00
Boris Brezillon 7486b5d91e panfrost: Add specialized preload descriptors
It's just easier to identify the different layouts this way.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
2020-10-23 14:48:22 +00:00
Boris Brezillon 519643bbe0 panfrost: Adjust the renderer state definition
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
2020-10-23 14:48:22 +00:00
Alyssa Rosenzweig 6ed1bdfee4 pan/bi: Use canonical texture op names in IR
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7081>
2020-10-10 16:53:13 -04:00
Alyssa Rosenzweig 2b9484c2c8 pan/bi: Use canonical term "message type"
These identify the type of message produced by a message-passing
instruction, rather than information about the clause per se.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7081>
2020-10-10 16:53:11 -04:00
Alyssa Rosenzweig 77a4e39100 pan/bi: Add missing message types
Names are not canonical but that's ok.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7081>
2020-10-10 16:53:11 -04:00
Alyssa Rosenzweig 785344e655 pan/bi: Use canonical name for staging registers
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7081>
2020-10-10 16:53:10 -04:00
Boris Brezillon 7bb85eadeb panfrost: Get rid of the with_opaque qualifier on the renderer state desc
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6980>
2020-10-07 17:54:57 +02:00