Commit Graph

59 Commits

Author SHA1 Message Date
Marek Olšák c9ca8abe4f Change all debug_assert calls to assert
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Acked-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17403>
2022-07-10 00:50:35 +00:00
Rob Clark cd38b3ec54 Revert "freedreno: Move the batch cache to the context."
This reverts commit b2349a4671.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5441
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13159>
2021-10-04 20:24:59 +00:00
Emma Anholt b2349a4671 freedreno: Move the batch cache to the context.
Our draw call rate was significantly limited by the atomics we had to do
to manage access to the batch cache.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11511>
2021-09-17 17:07:43 +00:00
Emma Anholt c3d6493122 freedreno: Use TC's flag for whether get_query is in the driver thread.
In moving batch cache to the context, the check for whether there's
pending work being done to this resources ends up accessing the context,
so we can't do it outside of the fd_context_access_begin().  This flag
lets us do the driver-thread asserts before we've decided whether we need
to flush.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11511>
2021-09-17 17:07:43 +00:00
Emma Anholt 591a3c738d freedreno: Be more strict about QUERY_AVAILABLE to simplify the code.
ARB_oq doesn't just say "polling in a loop will make it complete
eventually", it says "querying will make it complete in finite time."

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11368>
2021-06-15 20:42:26 +00:00
Rob Clark a9c9a9938d freedreno: Consolidate needs_flush and clearing last_fence
Add a helper to both set batch->needs_flush and clear ctx->last_fence so
that the two related bits of state do not get out of sync.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10599>
2021-05-03 23:27:31 +00:00
Rob Clark c98ada6ad1 freedreno/drm: Add FD_BO_PREP_FLUSH
There are a couple cases where we want to use _NOSYNC, but at the same
time we want to ensure that rendering related to a bo is actually
flushed.

This doesn't do anything yet, but when we start deferring/merging
submits we'll need a way to trigger anything deferred to flush.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10444>
2021-04-28 15:36:42 +00:00
Rob Clark 8ab227c373 freedreno/drm: Cleanup bo cpu_prep flags
Also add some STATIC_ASSERT()

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10444>
2021-04-28 15:36:42 +00:00
Rob Clark 2d439343ea freedreno: Re-indent
clang-format -fallback-style=none --style=file -i src/gallium/drivers/freedreno/*.[ch] src/gallium/drivers/freedreno/*/*.[ch]

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8883>
2021-04-14 19:52:21 +00:00
Rob Clark 9dbe2405a3 freedreno: threaded_context support
Currently only initialized for a6xx, mostly because that is the easiest
setup for me to test and debug at the moment.  But the couple a6xx changes
should not require counterparts in older gens.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9323>
2021-03-11 04:42:16 +00:00
Rob Clark 39d6343a3e freedreno: Split out batch/resource tracking
For threaded_context, to properly handle replace_buffer_storage, we'll
need to handle multiple "iterations" of a resource using the same
tracking in order to implement transfer_map() correctly.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9323>
2021-03-11 04:42:16 +00:00
Rob Clark dabec19b05 freedreno: Add perf_debug logging for bo stalls
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9223>
2021-02-24 00:19:33 +00:00
Rob Clark 3f77604623 freedreno: driver-thread annotations
Use clangs thread-safety annotations to implement a virtual lock
protecting context fields that should only be accessed from driver-
thread.  This should let the compiler help us detect problems where
ctx is used unsafely from things that could be called by the fe/st
thread.

This does end up sprinkled far and wide, it would be nice if the
compiler could be a bit smarter about understanding call-graphs
(at least with static fxns), but at least it makes it clear where
things are called from which thread.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9061>
2021-02-18 00:27:49 +00:00
Eric Anholt 881ce0f0a4 freedreno: Remove FD_STAGE_* in favor of a "disable_all" flag.
The only paths are "prepare queries for rendering" and "finish all
queries", everything else is handled by set_active_query_state().

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8873>
2021-02-10 03:46:25 +00:00
Eric Anholt 3aeb029728 freedreno: Drop pointless clear of used providers.
We don't reuse batches, no need to do anything special here.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8789>
2021-02-04 19:31:30 +00:00
Eric Anholt 4338cafd7f freedreno: Backport a5xx/a6xx fix for active query handling.
The batch might not have stage == FD_STAGE_BLIT set because
fd_blitter_pipe_begin was sticking the stage on some random batch (or none
at all) rather than the one that would be used in the meta operation.

What we actually wanted to be looking at was set_active_query_state(),
which is already called by util_blitter and whose state we just needed to
track.

Fixes these piglit tests on a307:
occlusion_query_meta_fragments
occlusion_query_meta_save

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8789>
2021-02-04 19:31:30 +00:00
Eric Anholt b709efeb09 freedreno: rename batch->active_providers to query_providers_used.
It's not the set of currently active providers, it's what's been used at
all in the current batch (this is used for doing the initialization of
query providers at initial HW setup in a submit).

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8789>
2021-02-04 19:31:30 +00:00
Eric Anholt 3390870cec freedreno: Fix release build warnings for asserted temp vars.
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7664>
2020-11-18 18:15:02 +00:00
Rob Clark 02298ed1fc freedreno: Add submit lock
Add a lock to synchronize batch flush (which can be triggered from a
different ctx) with cmdstream emit.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7342>
2020-11-10 17:58:44 +00:00
Rob Clark 290f827928 freedreno: Make fd_context_batch() return a reference
This protects better against another context triggering a batch flush
and unref while the first context is doing resource tracking.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7342>
2020-11-10 17:58:44 +00:00
Eric Anholt 51d7a71bd4 freedreno: Replace OUT_RELOCW with OUT_RELOC.
Final cleanup commit now that they're the same.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4967>
2020-05-12 16:30:57 +00:00
Eric Anholt d0b3ccb060 freedreno: Fix detection of being in a blit for acc queries.
The batch might not have stage == FD_STAGE_BLIT set because
fd_blitter_pipe_begin was sticking the stage on some random batch (or none
at all) rather than the one that would be used in the meta operation.

What we actually wanted to be looking at was set_active_query_state(),
which is already called by util_blitter and whose state we just needed to
track.

Fixes piglit occlusion_query_meta_no_fragments.  I haven't changed
query_hw.c's stage handling to clean the rest up because I don't have a
db410c/db820c at home to iterate over the piglit tests.

Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4356>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4356>
2020-03-30 21:35:21 +00:00
Eric Anholt a99ff93374 freedreno: Remove the "active" member of queries.
The state tracker only gets to begin/query/destroy when !active and end
when active, so we have no need to try to track this ourselves.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4356>
2020-03-30 21:35:21 +00:00
Eric Anholt b7fe793869 freedreno: Remove always-true return from per-gen begin_query.
You should do failure-prone allocation in create_query, not begin, anyway.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4356>
2020-03-30 21:35:21 +00:00
Rob Clark 5b9fe18485 freedreno: remove flush-queue
Signed-off-by: Rob Clark <robdclark@chromium.org>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3503>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3503>
2020-01-29 21:19:41 +00:00
Timothy Arceri 1909bc526d util: remove LIST_IS_EMPTY macro
Just use the inlined function directly. The new function was introduced
in addcf410.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2019-10-28 11:24:39 +00:00
Timothy Arceri 7f106a2b5d util: rename list_empty() to list_is_empty()
This makes it clear that it's a boolean test and not an action
(eg. "empty the list").

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2019-10-28 11:24:38 +00:00
Kristian H. Kristensen 30ab3e39fd freedreno/a6xx: Implement primitive count queries on GPU
The driver can't determine PIPE_QUERY_PRIMITIVES_GENERATED or
PIPE_QUERY_PRIMITIVES_EMITTED once we support geometry or
tessellation, since these stages add primitives at runtime.  Use the
WRITE_PRIMITIVE_COUNTS event to write back the primitive counts and
implement a hw query for this.

Reviewed-by: Rob Clark <robdclark@gmail.com>
2019-09-06 09:53:28 -07:00
Ilia Mirkin 0e30c6b8a7 gallium: switch boolean -> bool at the interface definitions
This is a relatively minimal change to adjust all the gallium interfaces
to use bool instead of boolean. I tried to avoid making unrelated
changes inside of drivers to flip boolean -> bool to reduce the risk of
regressions (the compiler will much more easily allow "dirty" values
inside a char-based boolean than a C99 _Bool).

This has been build-tested on amd64 with:

Gallium drivers: nouveau r300 r600 radeonsi freedreno swrast etnaviv v3d
                 vc4 i915 svga virgl swr panfrost iris lima kmsro
Gallium st:      mesa xa xvmc xvmc vdpau va

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
2019-07-22 22:13:51 -04:00
Rob Clark 2b10bb6e5e freedreno: drop unused arg from fd_batch_flush()
The `force` arg has been unused for a while.. but apparently I forgot to
garbage collect it.

Signed-off-by: Rob Clark <robdclark@chromium.org>
2019-06-26 08:43:02 -07:00
Neil Roberts ee61790daf freedreno: Remove the Emacs mode lines
These are not necessary because the corresponding settings are set via
the .dir-locals.el file anyway. Most of them were missing a ‘:’ after
“tab-width” which was making Emacs display an annoying warning
whenever you open the file.

This patch was made with:

sed -ri '/-\*- mode:/,/^$/d' \
    $(find src/gallium/{drivers,winsys} -name \*.\[ch\] \
               -exec grep -l -- '-\*- mode:' {} \+)

Signed-off-by: Rob Clark <robdclark@gmail.com>
2018-10-17 12:44:48 -04:00
Rob Clark a122118c14 freedreno: add fd_context_batch() accessor
For cases in which (after the following commit) ctx->batch may be null.
Prep work for following commit.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2018-09-05 13:38:43 -04:00
Ian Romanick d76c204d05 util: Move util_is_power_of_two to bitscan.h and rename to util_is_power_of_two_or_zero
The new name make the zero-input behavior more obvious.  The next
patch adds a new function with different zero-input behavior.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Suggested-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
2018-03-29 14:09:23 -07:00
Rob Clark 15ebf387fc freedreno: rework fence tracking
ctx->last_fence isn't such a terribly clever idea, if batches can be
flushed out of order.  Instead, each batch now holds a fence, which is
created before the batch is flushed (useful for next patch), that later
gets populated after the batch is actually flushed.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-12-03 14:17:40 -05:00
Rob Clark eed9685dd6 freedreno: per-context fd_pipe
To enable per-context priorities, we need to have per-context pipe's.
Unfortunately we still need to keep the global screen pipe, mostly just
for screen->get_timestamp().

Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-10-24 12:56:51 -04:00
Rob Clark 52d2fa37f5 freedreno: drop ring arg from _set_stage()
It is always the draw ring.  Except for a5xx queries like time-elapsed,
where we will eventually want to emit cmds into both binning and draw
rings.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-04-22 10:03:02 -04:00
Rob Clark d310ea0f32 freedreno: add support for hw accumulating queries
Some queries on a4xx and all queries on a5xx can do result accumulation
on CP so we don't need to track per-tile samples.  We do still need to
handle pausing/resuming while switching batches (in case the query is
active over multiple draws which are executed out of order).

So introduce new accumulated-query helpers for these sorts of queries,
since it doesn't really fit in cleanly with the original query infra-
structure.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-04-22 10:03:02 -04:00
Rob Clark 935623af14 freedreno: a bit of query refactor
Move a bit more of the logic shared by all query types (active tracking,
etc) into common code.  This avoids introducing a 3rd copy of that logic
for a5xx.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-04-22 10:03:02 -04:00
Marek Olšák e7a73b75a0 gallium: switch drivers to the slab allocator in src/util 2016-09-06 14:24:04 +02:00
Rob Clark 4175606474 freedreno: add some hw query traces
Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Rob Clark e6bfe1c773 freedreno: move needs_wfi into batch
This is also used in gmem code, which executes from the "bottom half"
(ie. from the flush_queue worker thread), so it cannot be in fd_context.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Rob Clark 00bed8a794 freedreno: threaded batch flush
With the state accessed from GMEM+submit factored out of fd_context and
into fd_batch, now it is possible to punt this off to a helper thread.
And more importantly, since there are cases where one context might
force the batch-cache to flush another context's batches (ie. when there
are too many in-flight batches), using a per-context helper thread keeps
various different flushes for a given context serialized.

TODO as with batch-cache, there are a few places where we'll need a
mutex to protect critical sections, which is completely missing at the
moment.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Rob Clark 7f8fd02dc7 freedreno: re-order support for hw queries
Push query state down to batch, and use the resource tracking to figure
out which batch(es) need to be flushed to get the query result.

This means we actually need to allocate the prsc up front, before we
know the size.  So we have to add a special way to allocate an un-
backed resource, and then later allocate the backing storage.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Rob Clark 10baf05b2c freedreno: use prsc for hw queries
Switch to using a pipe_resource (rather than an fd_bo directly) for hw
query result buffers.  This is first step towards making queries work
properly with reordered batches, since we'll need the additional
dependency tracking to know which batches to flush.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Rob Clark 9f219c7047 freedreno: add batch-cache and batch reordering
Note that I originally also had a entry-point that would construct a key
and do lookup from a pipe_surface.  I ended up not needing that (yet?)
but it is easy-enough to re-introduce later if we need it for the blit
path.

For now, not enabled by default, but can be enabled (on a3xx/a4xx) with
FD_MESA_DEBUG=reorder.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Rob Clark f02a64dbdd freedreno: move more batch related tracking to fd_batch
To flush batches out of order, the gmem code needs to not depend on
state from fd_context (since that may apply to a more recent batch).
So this all moves into batch.

The one exception is the gmem/pipe/tile state itself.  But this is
only used from gmem code (and batches are flushed serially).  The
alternative would be having to re-calculate GMEM layout on every
batch, even if the dimensions of the render targets are the same.

Note: This opens up the possibility of pushing gmem/submit into a
helper thread.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Rob Clark 9bbd239a40 freedreno: introduce fd_batch
Introduce the batch object, to track a batch/submit's worth of
ringbuffers and other bookkeeping.  In this first step, just move
the ringbuffers into batch, since that is mostly uninteresting
churn.

For now there is just a single batch at a time.  Note that one
outcome of this change is that rb's are allocated/freed on each
use.  But the expectation is that the bo pool in libdrm_freedreno
will save us the GEM bo alloc/free which was the initial reason
to implement a rb pool in gallium.

The purpose of the batch is to eventually facilitate out-of-order
rendering, with batches associated to framebuffer state, and
tracking the dependencies on other batches.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Rob Clark 9253dcde58 freedreno/a4xx: timestamp queries
Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-23 13:39:30 -04:00
Rob Clark 6a4b052820 freedreno: prep work for timestamp queries
We need "NULL" state to be a valid bit in the bitmask, because timestamp
queries are not restricted to draw/etc stages (ie. the only commands to
submit may just be to read the timestamp).  And just because there are
no draws, isn't a reason to skip the flush and return zero.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-23 13:39:30 -04:00
Rob Clark 94d8fbd217 freedreno: fix bad bitshift warnings
Coverity doesn't realize idx will never be negative.  Throw in some
assert()s to help it out.

(Hopefully assert() isn't getting compiled out for coverity build.. but
there seems to be just one way to find out.  We might have to change
these to assume())

Fixes CID 1362442, 1362443

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-06-02 16:29:32 -04:00