Commit Graph

385 Commits

Author SHA1 Message Date
Alyssa Rosenzweig 1fb681e51d pan/bi: Emit int CSEL instead of float by default
Will be needed when we use 1-bit booleans.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10392>
2021-05-03 15:10:20 +00:00
Alyssa Rosenzweig cf2d575d63 pan/bi: Support 16-bit load_interpolated_input
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10392>
2021-05-03 15:10:20 +00:00
Alyssa Rosenzweig 68c4a30434 pan/bi: Don't reference nir_lower_mediump_outputs
Nonexistant.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10392>
2021-05-03 15:10:20 +00:00
Alyssa Rosenzweig 1cb11969be pan/bi: Add simple constant folding pass
Cleans up swizzle lowering, and will be used for other cleanup as
well (fancy texturing tends to create a lot of foldable code).

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10392>
2021-05-03 15:10:20 +00:00
Alyssa Rosenzweig f9070f937f pan/bi: Add missing sr_count to pseudo-atomics
Fixes missing prints for these.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10392>
2021-05-03 15:10:20 +00:00
Icecream95 ab3a72cc20 pan/bi: Skip nir_opt_move/sink for blend shaders
Otherwise the dual-source input load is moved further down in the
shader, so the registers can get clobbered before then.

Fixes text not being visible in Alacritty.

Fixes: 52863f2e60 ("pan/bi: Enable all nir_opt_move/sink optimizations")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10089>
2021-04-22 23:13:27 +00:00
Michel Dänzer 2928c21eb7 Convert most remaining free-form fall-through comments to FALLTHROUGH
One exception is src/amd/addrlib/, for which -Wimplicit-fallthrough is
explicitly disabled.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10220>
2021-04-15 16:01:22 +00:00
Rhys Perry a2619b97f5 nir/lower_idiv: add options to use fp32 for 8-bit division lowering
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10081>
2021-04-12 16:19:46 +00:00
Icecream95 51a812bb60 panfrost: Flush output after disassembling shaders
Fixes text printed to stderr appearing in the middle of disassembly
when piping stdout and stderr to the same place.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10088>
2021-04-09 23:45:26 +00:00
Alyssa Rosenzweig 266de379c2 pan/bi: Generalize f2i16, f2u16
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10065>
2021-04-06 19:35:33 +00:00
Alyssa Rosenzweig be74b84e6f pan/bi: Fill in some more conversions
The trick is that downcasts are just swizzling out what you don't want,
so things like U32_TO_F16 can be synthesized as V2U16_TO_V2F16 with
src.h00

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10065>
2021-04-06 19:35:33 +00:00
Alyssa Rosenzweig 435800e750 pan/bi: Lower swizzles
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10065>
2021-04-06 19:35:33 +00:00
Alyssa Rosenzweig e3e2c5b594 pan/bi: Optimize MKVEC.v2i16 generation
Prefer SWZ.v2i16 in cases where that's possible, it will be easier to
optimize later.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10065>
2021-04-06 19:35:33 +00:00
Alyssa Rosenzweig 11010b932b pan/bi: Lower large arrays to scratch
No shader-db changes.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10020>
2021-04-03 19:18:55 +00:00
Alyssa Rosenzweig f5d1a8bf6f pan/bi: Split writemasks for memory stores
Will avoid a regression in the following commit, and probably fixes some
GLES3.1 stuff.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10020>
2021-04-03 19:18:55 +00:00
Alyssa Rosenzweig 52863f2e60 pan/bi: Enable all nir_opt_move/sink optimizations
total instructions in shared programs: 116716 -> 116716 (0.00%)

total nops in shared programs: 86280 -> 84996 (-1.49%)
nops in affected programs: 50485 -> 49201 (-2.54%)
Nops are helped.

total clauses in shared programs: 20993 -> 20732 (-1.24%)
clauses in affected programs: 7737 -> 7476 (-3.37%)
Clauses are helped.

total quadwords in shared programs: 91697 -> 91155 (-0.59%)
quadwords in affected programs: 52123 -> 51581 (-1.04%)
Quadwords are helped.

total spills in shared programs: 0 -> 0
total fills in shared programs: 0 -> 0

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10020>
2021-04-03 19:18:55 +00:00
Alyssa Rosenzweig 6a9936f5b5 pan/bi: Remove stale todo/assert
Was already handled, just untested.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9421>
2021-04-03 12:47:29 -04:00
Alyssa Rosenzweig 10b736f160 pan/bi: Remove TODO: RA warnings
We'll make this perfectly valid syntax for precolouring.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9421>
2021-04-03 12:47:29 -04:00
Alyssa Rosenzweig 93cdb072a8 pan/bi: Only run DCE once
No more progress loop needed. I'm skeptical we really want a dataflow
approach long-term, though, this is annoyingly expensive.

No shader-db changes.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9421>
2021-04-03 12:47:29 -04:00
Alyssa Rosenzweig b7a339bc97 pan/bi: Only run copyprop once
We need to update `replacement` with the results of copyprop earlier
within the pass, but after that there's no point running more than once
if we're not going to materialize any new moves.

No shader-db changes.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9421>
2021-04-03 12:47:29 -04:00
Alyssa Rosenzweig 69666723f8 pan/bi: Handle 16-bit blend sr_count
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9421>
2021-04-03 12:47:29 -04:00
Timur Kristóf 1d571c6bc1 pan/bi: Use correct enum type for NIR intrinsics.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9632>
2021-03-16 21:46:52 +00:00
Boris Brezillon 3559efb9bf panfrost: Allow passing an explicit UBO index for the sysval UBO
UBO index assignment is a bit special in Vulkan, it's based on the
descriptor set layout, which doesn't know about shaders' internal UBOs
(our sysval UBOs). Extend the backend compilers so we can place sysval
UBOs where we want: after all explicit UBOs.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9517>
2021-03-11 15:10:58 +00:00
Alyssa Rosenzweig 5487847d8c pan/bi: Implement u{add, sub}_sat
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9520>
2021-03-11 14:30:19 +00:00
Boris Brezillon 3c7634f7d2 pan/bi: Extend the bi_builder to support type variants correctly
Some opcodes come with both type and size variants. Right now, only the
size is taken into account. Extend the builder to provide wrappers that
take a nir_type in addition to the bitsize.

While at it, fix wrappers taking a compare operator to use the proper
.{i,s,u} variant based on the comparison (equal and non-equal should
use .i, other comparisons should use .{u,s}).

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/9520>
2021-03-11 14:30:19 +00:00
Boris Brezillon 691c47dd6c pan/bi: Move int64 lowering before idiv lowering
Otherwise all 64 divisions will be skipped.

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/9520>
2021-03-11 14:30:19 +00:00
Boris Brezillon f7bbfbaeb5 Revert "pan/bi: Optimize out redundant jumps to #0x0"
A block that has all its successors empty is not necessarily a leaf
block in the CFG, and removing the JUMP in that causes the shader
to continue executing code from another block instead of exiting.

This reverts commit a496b41d50.

Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9520>
2021-03-11 14:30:19 +00:00
Alyssa Rosenzweig 718bfdb3da pan/bi: Implement fsin/fcos
Instead of lowering it in NIR, use the lookup tables as inputs to a
second-order Taylor expansion. shader-db results aren't amazing but keep
in mind this is without backend CSE yet.

total instructions in shared programs: 115913 -> 115707 (-0.18%)
instructions in affected programs: 3151 -> 2945 (-6.54%)
helped: 12
HURT: 0
Instructions are helped.

total nops in shared programs: 84045 -> 84041 (<.01%)
nops in affected programs: 1571 -> 1567 (-0.25%)
helped: 1
HURT: 7
Inconclusive result (value mean confidence interval includes 0).

total clauses in shared programs: 20498 -> 20489 (-0.04%)
clauses in affected programs: 188 -> 179 (-4.79%)
helped: 6
HURT: 0
Clauses are helped.

total quadwords in shared programs: 90395 -> 90291 (-0.12%)
quadwords in affected programs: 2287 -> 2183 (-4.55%)
helped: 12
HURT: 0
Quadwords are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9420>
2021-03-05 15:15:10 +00:00
Alyssa Rosenzweig 4f71801aa2 pan/bi: Adapt builder to dest count
If there are no destinations, don't produce a _to version, and let the
bare version return the bi_instr.

If there are multiple destinations, take each in the _to version and
don't produce a bare version.

Both cares are probably what you wanted anyway.

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/9164>
2021-02-22 19:17:50 +00:00
Alyssa Rosenzweig 9882a59a2f pan/bi: Reduce liveness calculations in DCE
Forward port of fc06b8b7 ("pan/mdg: Optimize liveness computation in
DCE")

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9164>
2021-02-22 19:17:50 +00:00
Alyssa Rosenzweig 3a4d985997 pan/bi: Use nir_opt_sink/move for constants
Fixes excessive (and failing) spilling in dEQP-GLES31.functional.ssbo.layout.*

shader-db results are a toss up (I suspect we'd see better results if we
tracked register pressure directly):

total instructions in shared programs: 161377 -> 161377 (0.00%)

total nops in shared programs: 121159 -> 121203 (0.04%)
nops in affected programs: 1839 -> 1883 (2.39%)
Nops are HURT.

total clauses in shared programs: 31604 -> 31606 (<.01%)
clauses in affected programs: 38 -> 40 (5.26%)
Inconclusive result (value mean confidence interval includes 0).

total quadwords in shared programs: 130847 -> 130845 (<.01%)
quadwords in affected programs: 1246 -> 1244 (-0.16%)
Inconclusive result (value mean confidence interval includes 0).

total loops in shared programs: 18 -> 18 (0.00%)
total spills in shared programs: 705 -> 705 (0.00%)
total fills in shared programs: 1645 -> 1645 (0.00%)

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9164>
2021-02-22 19:17:50 +00:00
Alyssa Rosenzweig 04be7934df pan/bi: Fix elimination of repeated branches
How many times can I break such a small pass?

Fixes: a805d999c0 ("pan/bi: Fix jumps to terminal block again")
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/9137>
2021-02-22 17:12:55 +00:00
Alyssa Rosenzweig a496b41d50 pan/bi: Optimize out redundant jumps to #0x0
If it's the last instruction, that's silly.

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/9137>
2021-02-22 17:12:55 +00:00
Alyssa Rosenzweig 46384d0dcc pan/bi: Fix more jumps to terminal blocks
Here's another edge case: there could be instructions in the last block
after NIR->BIR but they could be optimized out by backend DCE, causing
the block to become a terminal block.

Noticed while toying with geometry shaders.

Fixes: a805d999c0 ("pan/bi: Fix jumps to terminal block again")
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/9137>
2021-02-22 17:12:55 +00:00
Alyssa Rosenzweig ed29a2beb8 pan/bi: Use explicit move even for RT#0 of MRT
Otherwise we get a bad RA if RT 0 = RT 3 (for example), fixes
dEQP-GLES31.functional.shaders.opaque_type_indexing.sampler.const_literal.fragment.sampler2d

Fixes: a6f1500bed ("pan/bi: Workaround BLEND precolour with explicit moves")
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig 02d68b9b83 pan/bi: Allow dynamically uniform tex indices
Passes the relevant tests of
dEQP-GLES31.functional.shaders.opaque_type_indexing.sampler.*, a few
failures that seem to relate to MRT instead of this.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig dfe309e707 pan/bi: Implement interpolateAtOffset
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig e4ae458df8 pan/bi: Implement interpolateAtSample
Passes dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.*

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig 7f2d618867 pan/bi: Flesh out LD_TILE emit
Needs to support non-blend shader operation (conversion descriptor
sourced from a sysval), as well as MRT. Fixes fbfetch on Bifrost.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig cff5c40fc3 pan/bi: Fix blend shaders using LD_TILE with MRT
Don't hardcode the RT to 0. Affects ES3.0 which already exposes MRT --
despite no dEQP coverage of this particular corner case, apps could hit
this in the wild on 21.0. Fixes

dEQP-GLES31.functional.draw_buffers_indexed.overwrite_indexed.common_blend_func_buffer_blend_func

Fixes: c7e1ef7c0c ("panfrost: Advertise ES3.0 on Bifrost")
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig 9151329fd2 pan/bi: Implement shader_clock intrinsic
Trivial.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig 8081811f2e pan/bi: Implement image_atomic_comp_swap
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig 078a84f474 pan/bi: Implement image_atomic_exchange
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Icecream95 afe4f0e6b1 pan/bi: nir_intrinsic_image_size support
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Icecream95 075d9a1084 pan/bi: Implement image load/store
v2 (Alyssa): Split out functions, support 3D/array

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Icecream95 71f849a292 pan/bi: Remove check for first_ubo_is_default_ubo
It won't be set for OpenCL.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig cd21f0e1c5 pan/bi: Handle computational atomics
All the same formula: calculate an address, emit a pseudoinstruction for
the atomic, emit a postprocess that can be DCE'd if not needed.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig 8358321801 pan/bi: Add ATOM_C1 promotion check
Optimizes atomic counters.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig b9d277f644 pan/bi: Extract bi_atom_opc from NIR intrinsic
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00
Alyssa Rosenzweig 111255512a pan/bi: Don't read alpha out of bounds
RT#0 may not have alpha, do something safe instead of risking issues
with RA later.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
2021-02-18 21:48:22 +00:00