platform/upstream/mesa.git
22 months agoradeonsi: replace llvm load_ssbo abi with nir lower
Qiang Yu [Wed, 17 Aug 2022 09:40:59 +0000 (17:40 +0800)]
radeonsi: replace llvm load_ssbo abi with nir lower

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18666>

22 months agoac/llvm: check load_ssbo present before call it
Qiang Yu [Tue, 16 Aug 2022 10:47:03 +0000 (18:47 +0800)]
ac/llvm: check load_ssbo present before call it

radeonsi will remove it later.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18666>

22 months agoradeonsi: add si_nir_lower_resource pass
Qiang Yu [Tue, 16 Aug 2022 10:29:03 +0000 (18:29 +0800)]
radeonsi: add si_nir_lower_resource pass

Replace the load_ubo abi.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18666>

22 months agoradv/rt: Refactor exiting PLOC
Friedrich Vock [Sun, 18 Dec 2022 19:37:33 +0000 (20:37 +0100)]
radv/rt: Refactor exiting PLOC

The previous approach was susceptible to sync hazards, causing hangs in Doom Eternal.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7897
Fixes: 271865373 ("radv: Add PLOC shader")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20377>

22 months agoradv/rt: Execute memory barrier before updating the phase end count
Friedrich Vock [Sun, 18 Dec 2022 19:34:09 +0000 (20:34 +0100)]
radv/rt: Execute memory barrier before updating the phase end count

We want to be sure that the values were updated before letting other invocations continue.

Fixes: 271865373 ("radv: Add PLOC shader")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20377>

22 months agoradv/rt: PLOC fixes for active_leaf_count
Friedrich Vock [Thu, 15 Dec 2022 20:04:38 +0000 (21:04 +0100)]
radv/rt: PLOC fixes for active_leaf_count

Fixes: 271865373 ("radv: Add PLOC shader")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20377>

22 months agoutil/tools: add the tool that generates perfect hash functions for GLenums
Marek Olšák [Mon, 12 Dec 2022 20:34:08 +0000 (15:34 -0500)]
util/tools: add the tool that generates perfect hash functions for GLenums

The big comment explains it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agomesa: optimize _mesa_bytes_per_vertex_attrib using a hash-based translation
Marek Olšák [Mon, 12 Dec 2022 04:47:29 +0000 (23:47 -0500)]
mesa: optimize _mesa_bytes_per_vertex_attrib using a hash-based translation

This reduces time spent in gl*Pointer for viewperf.

Generated by find_hash_func.c.

Reviewed-by: Rob Clark <robclark@freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agomesa: compute _PipeFormat and _ElementSize after checking if the format changed
Marek Olšák [Mon, 12 Dec 2022 05:45:11 +0000 (00:45 -0500)]
mesa: compute _PipeFormat and _ElementSize after checking if the format changed

Split _mesa_set_vertex_format into 2 functions and set the derived fields
after we know that the format is different.

This skips _PipeFormat and _ElementSize recomputation every time we get
gl*Pointer with the same format.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agomesa: move user-specified vertex format fields into gl_vertex_format_user
Marek Olšák [Mon, 12 Dec 2022 05:35:31 +0000 (00:35 -0500)]
mesa: move user-specified vertex format fields into gl_vertex_format_user

to be used in the next commit

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agomesa: change gl_vertex_format::Format to bool Bgra to free bits
Marek Olšák [Mon, 12 Dec 2022 05:28:16 +0000 (00:28 -0500)]
mesa: change gl_vertex_format::Format to bool Bgra to free bits

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agost/mesa: simplify prepare_indexed_draw
Marek Olšák [Sun, 11 Dec 2022 23:51:11 +0000 (18:51 -0500)]
st/mesa: simplify prepare_indexed_draw

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agost/mesa: optimize index buffer reference counting in st_indirect_draw_vbo
Marek Olšák [Sun, 11 Dec 2022 23:08:45 +0000 (18:08 -0500)]
st/mesa: optimize index buffer reference counting in st_indirect_draw_vbo

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agomesa: set pipe_draw_info::index::resource directly and remove gl_bo
Marek Olšák [Sun, 11 Dec 2022 22:53:59 +0000 (17:53 -0500)]
mesa: set pipe_draw_info::index::resource directly and remove gl_bo

The motivation is to remove branching from prepare_indexed_draw
and remove the unsafe hack in vbo_save_playback_vertex_list.

There is some duplication that is not identical in all 3 cases.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agost/mesa: fold GLThread.enabled into pin_thread_counter to skip that checking
Marek Olšák [Sun, 11 Dec 2022 22:16:39 +0000 (17:16 -0500)]
st/mesa: fold GLThread.enabled into pin_thread_counter to skip that checking

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agost/mesa: use u_bit_scan64 only for 64-bit CPUs in st_validate_state
Marek Olšák [Sun, 11 Dec 2022 22:00:28 +0000 (17:00 -0500)]
st/mesa: use u_bit_scan64 only for 64-bit CPUs in st_validate_state

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

22 months agodocs: update to latest venus driver support
Yiwei Zhang [Fri, 16 Dec 2022 19:51:01 +0000 (11:51 -0800)]
docs: update to latest venus driver support

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20310>

22 months agovenus: fix VK_EXT_pci_bus_info support
Yiwei Zhang [Tue, 13 Dec 2022 22:24:25 +0000 (14:24 -0800)]
venus: fix VK_EXT_pci_bus_info support

Natively support it for virtgpu while passthrough renderer support for
vtest. This is a must support to avoid prime blit in common wsi.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20310>

22 months agovenus: sync protocol fixes and support for VK_EXT_pci_bus_info
Yiwei Zhang [Fri, 16 Dec 2022 08:21:47 +0000 (00:21 -0800)]
venus: sync protocol fixes and support for VK_EXT_pci_bus_info

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20310>

22 months agoetnaviv: Do expose 2D texture support on pre-halti GPUs
Marek Vasut [Sat, 17 Dec 2022 21:10:22 +0000 (22:10 +0100)]
etnaviv: Do expose 2D texture support on pre-halti GPUs

Commit d08bd9a8d8b ("etnaviv: don't expose array and 3D texture support on pre-halti GPUs")
started returning 0 from PIPE_CAP_MAX_TEXTURE_2D_SIZE as well due to switch
case fallthrough. Reinstate the behavior of PIPE_CAP_MAX_TEXTURE_2D_SIZE,
while at the same time, retain the new behavior introduced by commit
d08bd9a8d8b , Otherwise not even kmscube displays the spinning cube,
weston does not display desktop and so on.

Triggered on "Vivante GC600 rev 4653" , i.MX8M Mini .

Fixes: d08bd9a8d8b ("etnaviv: don't expose array and 3D texture support on pre-halti GPUs")
Closes: #7898
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20373>

22 months agopanfrost: Add architecture description XML for v10
Alyssa Rosenzweig [Wed, 14 Dec 2022 21:22:41 +0000 (21:22 +0000)]
panfrost: Add architecture description XML for v10

Add the GenXML hardware description for Mali architecture v10, as implemented in
Mali-G610. This is not 100% complete but it should be good enough for parity
with v9.

The XML itself is forked off of v9, with all Job Managerisms replaced with
CSFisms. This notably includes a large number of new structures defining the
instructions that run on the Command Execution Unit (CEU).

This is the first step towards supporting Mali-G610 (i.e. RK3588) upstream. Next
up will be pandecode support.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20360>

22 months agofreedreno/drm: Short-circuit kernel for timeout=0 waits
Rob Clark [Thu, 15 Dec 2022 19:14:58 +0000 (11:14 -0800)]
freedreno/drm: Short-circuit kernel for timeout=0 waits

We already know from the userspace fence whether the fence has signaled
or not.  No need to do a syscall if we aren't going to wait.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm/virtio: Guest side fence waits
Rob Clark [Thu, 15 Dec 2022 16:48:00 +0000 (08:48 -0800)]
freedreno/drm/virtio: Guest side fence waits

Now that fd_fence and fd_submit_fence are unified, we can wait on the
fence fd rather than needing to poll the host.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm/virtio: More tracepoints
Rob Clark [Thu, 15 Dec 2022 16:43:37 +0000 (08:43 -0800)]
freedreno/drm/virtio: More tracepoints

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno: Limit cached staging BOs to PIPE_MAP_READ
Rob Clark [Mon, 12 Dec 2022 22:20:53 +0000 (14:20 -0800)]
freedreno: Limit cached staging BOs to PIPE_MAP_READ

WC is fine for staging upload buffers, and will let us hit the default
heap.  Probably introducing a separate cached-coherent heap is overkill,
and given that staging uploads are common (but downloads uncommon, out-
side of dEQP/piglit), it is better to just ask for WC.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm/virtio: Remove prealloc_list
Rob Clark [Sat, 10 Dec 2022 23:17:12 +0000 (15:17 -0800)]
freedreno/drm/virtio: Remove prealloc_list

Now that we are allocating cmdstream from the heap, we shouldn't need
this.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Add sub-allocator
Rob Clark [Sat, 3 Dec 2022 02:42:42 +0000 (18:42 -0800)]
freedreno/drm: Add sub-allocator

Add a heap that we can use for allocations of small mappable buffers.
This avoids the churn of mmap/unmap, which is especially expensive in
a VM.  It also allows packing more smaller allocations together in a
page, which is useful for PIPE_BUFFERs (which are also mappable).

This avoid jank caused by the overhead of setting up or tearing down
guest mappings when running in a VM.  And also significantly reduces
the # of BOs referenced on a submit.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agoutil/vma: Add "nospan"
Rob Clark [Wed, 7 Dec 2022 23:04:29 +0000 (15:04 -0800)]
util/vma: Add "nospan"

Add a way to request that allocations do not span a specified PoT
boundary.  This can be used, for ex, to ensure that allocations do
not span 4GB boundaries to work around hw/fw bugs.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Merge in_fence_fd's
Rob Clark [Tue, 13 Dec 2022 22:52:03 +0000 (14:52 -0800)]
freedreno/drm: Merge in_fence_fd's

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Move no_implicit_sync accounting
Rob Clark [Tue, 13 Dec 2022 18:57:42 +0000 (10:57 -0800)]
freedreno/drm: Move no_implicit_sync accounting

No need to duplicate this.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Drop fd_bo_fence
Rob Clark [Wed, 14 Dec 2022 21:58:05 +0000 (13:58 -0800)]
freedreno/drm: Drop fd_bo_fence

Remove the last fence-like-struct that isn't fd_fence.  Now that
fences are refcnt'd we can just attach them directly to BOs.  This
will simplify busy-ness tracking for suballoc BOs.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Re-enable submit fence merging
Rob Clark [Wed, 14 Dec 2022 21:34:43 +0000 (13:34 -0800)]
freedreno/drm: Re-enable submit fence merging

Now that we (a) create the fence ourselves, returning a reference from
fd_submit_flush(), and (b) refcnt the fences, we can now merge submits
with on out-fence by just attaching the same fence to all the submits.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Simplify deferred submit flushing
Rob Clark [Wed, 14 Dec 2022 21:18:14 +0000 (13:18 -0800)]
freedreno/drm: Simplify deferred submit flushing

Once we are sharing an out-fence for multiple deferred/merged submits
the complicated logic in fd_pipe_sp_flush() no longer works (or makes
sense), so just simplify all the paths into a single helper.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Return fence from submit flush
Rob Clark [Wed, 14 Dec 2022 19:18:15 +0000 (11:18 -0800)]
freedreno/drm: Return fence from submit flush

This moves away from embedding the submit fence inside the pipe fence,
which lets us start refcnt'ing the fence.  This will enable several
cleanups and improvements:

1. Get rid of fd_bo_fence, and just have fd_bo hold pending fd_fence
   refs instead, which will be needed for cpu_prep implementation of
   sub-allocated buffers.
2. For merged submits, we can just return a new reference to an
   existing fence.

Note that this temporarily defeats submit-merging, which will be
fixed (and improved) in a following commit.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno: Rename fd_fence -> fd_pipe_fence
Rob Clark [Wed, 14 Dec 2022 18:49:34 +0000 (10:49 -0800)]
freedreno: Rename fd_fence -> fd_pipe_fence

So we don't have namespace clashes in the next commit.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Combine fd_fence and fd_submit_fence
Rob Clark [Wed, 14 Dec 2022 17:06:59 +0000 (09:06 -0800)]
freedreno/drm: Combine fd_fence and fd_submit_fence

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Replace shared/nosync fields
Rob Clark [Mon, 5 Dec 2022 18:33:28 +0000 (10:33 -0800)]
freedreno/drm: Replace shared/nosync fields

These are redundent with the alloc_flags.  A following commit will map
alloc_flags directly to bo heap that should be used, and adding the
FD_BO_SHARED bit when a BO is exported neatly avoids returning it to
the pool to be potentially erroneously reused.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Reorg BO alloc flags
Rob Clark [Mon, 5 Dec 2022 17:49:59 +0000 (09:49 -0800)]
freedreno/drm: Reorg BO alloc flags

And drop the unneeded _FD_BO_RING flag.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Invert BO destruction
Rob Clark [Wed, 7 Dec 2022 23:27:04 +0000 (15:27 -0800)]
freedreno/drm: Invert BO destruction

Sub-alloc'd heap BOs will need to do something a bit more special, ie.
not immediately cleanup fences (because those will be needed to know
when the BO is actually idle and vma node can be released), not tear
down the mmap (because the BO doesn't own it), and not close the handle
(also because the BO doesn't own it).

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Shuffle around BO init
Rob Clark [Sat, 10 Dec 2022 17:33:51 +0000 (09:33 -0800)]
freedreno/drm: Shuffle around BO init

Suballocated heap BOs will bypass the rest of bo_new() (as they skip the
BO cache, don't get an entry in the handle table, etc).  So move more of
the initialization into fd_bo_init_common().

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Drop pipe ref to device
Rob Clark [Sat, 10 Dec 2022 20:39:40 +0000 (12:39 -0800)]
freedreno/drm: Drop pipe ref to device

The context and screen already holds refs to the device.  But since
fd_bo_fence holds a ref to the pipe, anyone anywhere leaking a single
bo with unwaited fences could cause the device to leak indirectly.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Get rid of fd_bo_del_locked()
Rob Clark [Thu, 8 Dec 2022 23:59:12 +0000 (15:59 -0800)]
freedreno/drm: Get rid of fd_bo_del_locked()

This moves the table_lock into a small critical section in the BO delete
path when we are actually removing the entries from the handle/name
tables, so finally table_lock isn't the big-bo-lock!

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Rework batch BO delete
Rob Clark [Thu, 8 Dec 2022 23:41:07 +0000 (15:41 -0800)]
freedreno/drm: Rework batch BO delete

Get rid of the per-device table of deferred handles, and instead keep
this on the stack so that no additional locking is needed.  This will
simplify getting rid of table_lock in the bo delete path.  For the BO
cache, add fd_bo_del_list_nocache() which works like fd_bo_del_array()
except that it bypasses returning BOs to the cache.  This gets rid of
the BO cache calls to private fd_bo fxns (which is useful now that the
bo_del/close_handles() dance has become a bit more complicated).

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Start prying apart table_lock
Rob Clark [Thu, 8 Dec 2022 22:35:28 +0000 (14:35 -0800)]
freedreno/drm: Start prying apart table_lock

We want to get back to the point where table_lock is only doing what
it's named for (ie. protecting handle/name tables).  This is the first
step.  Add new locks to protect fencing and the bo caches.  A single
global lock for fences, to avoid atomic instructions in the loop per
submit bo attaching fences.

This couldn't be broken appart into different commits, otherwise there
would have been an ABBA deadlock in BO cache's call to fd_bo_state()
to check if a BO is idle.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Simplify cleanup_fences()
Rob Clark [Thu, 8 Dec 2022 21:33:55 +0000 (13:33 -0800)]
freedreno/drm: Simplify cleanup_fences()

To prepare for moving fence state out from under table_lock, simplify
cleanup_fences() and stop trying to re-use it in the bo destruction
path (which otherwise wouldn't need the fence lock, since there is
no other owner of the bo ref at that point, and simply needs to drop
pipe refs).

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Add bo list iterator macros
Rob Clark [Thu, 8 Dec 2022 20:47:51 +0000 (12:47 -0800)]
freedreno/drm: Add bo list iterator macros

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Add BO cache stats
Rob Clark [Wed, 9 Nov 2022 17:03:20 +0000 (09:03 -0800)]
freedreno/drm: Add BO cache stats

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Allow submit merging with explicit sync
Rob Clark [Sat, 3 Dec 2022 16:23:05 +0000 (08:23 -0800)]
freedreno/drm: Allow submit merging with explicit sync

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Move no_implicit_sync to base
Rob Clark [Sat, 3 Dec 2022 16:19:23 +0000 (08:19 -0800)]
freedreno/drm: Move no_implicit_sync to base

No need to duplicate between backends.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno/drm: Remove cpu_fini
Rob Clark [Sat, 3 Dec 2022 16:08:34 +0000 (08:08 -0800)]
freedreno/drm: Remove cpu_fini

It has been unused since nearly forever.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agofreedreno: Update obsolete comment
Rob Clark [Sat, 10 Dec 2022 16:45:07 +0000 (08:45 -0800)]
freedreno: Update obsolete comment

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

22 months agovenus: fix signaled fence creation under multiple timeline
Yiwei Zhang [Sat, 17 Dec 2022 07:41:52 +0000 (07:41 +0000)]
venus: fix signaled fence creation under multiple timeline

Fixes: 3beb4f055e17 ("venus: allow renderer submissions on per-context virtgpu rings")

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20366>

22 months agoasahi: Implement anisotropy
Alyssa Rosenzweig [Wed, 23 Nov 2022 20:24:21 +0000 (15:24 -0500)]
asahi: Implement anisotropy

Passes KHR-GLES3.texture_filter_anisotropic.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Identify seamful cube map bit
Alyssa Rosenzweig [Sun, 4 Sep 2022 18:21:04 +0000 (14:21 -0400)]
asahi: Identify seamful cube map bit

Fixes

   dEQP-GLES2.functional.texture.mipmap.cube.basic.linear_nearest

when run with a GLES2 version.

We wire up seamless cube maps for GLES3+ only, working around an obscure
mesa/st limitation. See 6148e3aae7e ("mesa: Fix
ctx->Texture.CubeMapSeamless") for the full context.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Set flatshading controls appropriately
Alyssa Rosenzweig [Fri, 2 Dec 2022 17:54:42 +0000 (12:54 -0500)]
asahi: Set flatshading controls appropriately

Fixes dEQP-GLES3.functional.rasterization.flatshading.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Identify XML for more flatshading controls
Alyssa Rosenzweig [Fri, 2 Dec 2022 17:53:02 +0000 (12:53 -0500)]
asahi: Identify XML for more flatshading controls

Names from PowerVR <3

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Enable VS_INSTANCEID and VERTEX_ELEMENT_INSTANCE_DIVISOR caps
Asahi Lina [Wed, 14 Dec 2022 09:46:37 +0000 (18:46 +0900)]
asahi: Enable VS_INSTANCEID and VERTEX_ELEMENT_INSTANCE_DIVISOR caps

These two should be functional at this point. The latter is required
(and quite well tested) by Darwinia.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Implement depth and stencil export
Alyssa Rosenzweig [Sat, 17 Dec 2022 04:39:01 +0000 (23:39 -0500)]
asahi: Implement depth and stencil export

For gl_FragDepth, passes dEQP-GLES3.functional.shaders.fragdepth.* and piglit
fragdepth_gles2.

For stencil export, passes piglit glsl-fs-shader-stencil-export.

For gl_FragDepth together with stencil export, passes
dEQP-GLES3.functional.fbo.blit.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoagx: Implement depth and stencil export
Alyssa Rosenzweig [Sat, 17 Dec 2022 04:38:07 +0000 (23:38 -0500)]
agx: Implement depth and stencil export

Lower FRAG_RESULT_DEPTH and FRAG_RESULT_STENCIL writes to a combnied zs_emit
instruction with a multisampling index. To be used in the following commit.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Allow texturing S8 portion of combined Z/S
Alyssa Rosenzweig [Sat, 17 Dec 2022 04:24:48 +0000 (23:24 -0500)]
asahi: Allow texturing S8 portion of combined Z/S

Comes up in gles3.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Put meta shader keys into the meta shader itself
Asahi Lina [Wed, 14 Dec 2022 04:28:26 +0000 (13:28 +0900)]
asahi: Put meta shader keys into the meta shader itself

The hash table needs a key pointer with at least the lifetime of the
hash entry, which the key pointer we get does not have (since it is
stack-allocated by agx_build_meta). Copy it into the shader struct
itself and use that for the hash table.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Identify & disable triangle merging for shaders using derivatives
Asahi Lina [Fri, 9 Dec 2022 12:47:29 +0000 (21:47 +0900)]
asahi: Identify & disable triangle merging for shaders using derivatives

It seems triangle merging is incompatible with calculating derivatives
along primitive edges correctly. Take the appropriate NIR shader info
flags in the compiler and pass them down as a flag to the driver, so it
can set the disable triangle merging flag (formerly called "lines or
points").

TODO: Is this what macOS does when you set a sample mask there (which
apparently fixes the same bug on the Darwinia Metal backend)? Do we
also need to set this when sample masks are used?

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fixes Darwinia and dEQP2 projected tests.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Fix include guard comment on decode.h
Asahi Lina [Fri, 9 Dec 2022 10:30:21 +0000 (19:30 +0900)]
asahi: Fix include guard comment on decode.h

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Allocate enough push ranges for the worst possible case
Asahi Lina [Fri, 9 Dec 2022 09:08:04 +0000 (18:08 +0900)]
asahi: Allocate enough push ranges for the worst possible case

We need one for every possible sysval, plus up to 16 VBOs.

Fixes plasma-systemmonitor.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Fix off-by-one assert in agx_create_vertex_elements
Asahi Lina [Fri, 9 Dec 2022 09:07:49 +0000 (18:07 +0900)]
asahi: Fix off-by-one assert in agx_create_vertex_elements

Needed to fix plasma-systemmonitor.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Consider shared resources always valid
Asahi Lina [Wed, 7 Dec 2022 07:00:59 +0000 (16:00 +0900)]
asahi: Consider shared resources always valid

Shared resources are in an unknown state, so we have to assume they
may contain valid data.

Fixes Xorg+Kwin random full-screen garbage on mouse cursor present.

However, we still get black flashing in some circumstances (that was
garbage flashing before this commit), which indicates that something
is reading an uninitialized/fresh shared framebuffer and expecting
valid data (prior screen contents?) TBD.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Ensure we always have space for stream links + padding
Asahi Lina [Fri, 9 Dec 2022 06:56:26 +0000 (15:56 +0900)]
asahi: Ensure we always have space for stream links + padding

It seems VDM can overread (maybe it does blockwise transfers?), so we
always need to leave space at the end of encoder buffers to avoid
faults.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Don't crash on VBOs without resources
Asahi Lina [Wed, 7 Dec 2022 12:43:43 +0000 (21:43 +0900)]
asahi: Don't crash on VBOs without resources

There's a Firefox QuakeJS heisenbug that triggers this sometimes, by
binding vertex attributes with no buffer...

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoasahi: Do not leak staging resources for PIPE_MAP_READ
Asahi Lina [Wed, 7 Dec 2022 09:33:46 +0000 (18:33 +0900)]
asahi: Do not leak staging resources for PIPE_MAP_READ

We were only dereferencing the resource in the PIPE_MAP_WRITE path of
agx_transfer_unmap, which means that read-only transfers leaked the
staging resource/BO. Always free the staging resource unconditionally.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoagx: Fix packing of extension for block image stores
Alyssa Rosenzweig [Sun, 4 Dec 2022 02:19:22 +0000 (21:19 -0500)]
agx: Fix packing of extension for block image stores

Probably impossible to hit in practice but let's get it right. Found when
forcing RA to use the upper half of the reg file.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoagx: Coalesce i2i16 and u2u16
Alyssa Rosenzweig [Fri, 2 Dec 2022 16:36:42 +0000 (11:36 -0500)]
agx: Coalesce i2i16 and u2u16

Extract out the code for unpack_64_2x32_split_x and use it for other integer
downcasts too to coalesce out a move. Pointless, but I wanted to have a little
RA fun after getting stencil export working.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoail: Assert that the mip level is in bounds
Asahi Lina [Fri, 9 Dec 2022 11:15:42 +0000 (20:15 +0900)]
ail: Assert that the mip level is in bounds

This preempts possible out-of-bounds accesses and later asserts when
trying to get the tile size.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoail: Fix tile sizes
Alyssa Rosenzweig [Tue, 29 Nov 2022 03:00:52 +0000 (22:00 -0500)]
ail: Fix tile sizes

Fixes dEQP-GLES3.functional.texture.filtering.2d.sizes.3x7_nearest_mipmap_linear.

Tested for all sizes 1..256x1..256.

Tested-by: Asahi Lina <lina@asahilina.net>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoail: Fix typo
Asahi Lina [Wed, 7 Dec 2022 08:00:14 +0000 (17:00 +0900)]
ail: Fix typo

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoail: Always allocate the full miptree
Asahi Lina [Wed, 7 Dec 2022 07:55:19 +0000 (16:55 +0900)]
ail: Always allocate the full miptree

Layer strides are based on the full miptree, and even for single-layer
images macOS always allocates a full one (possibly relevant for
compression). Make sure we do the same, regardless of how many mip
levels the user asked for.

Fixes Darwinia.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agodocs/features: Mark ARB_occlusion_query2 as done on asahi
Alyssa Rosenzweig [Sun, 4 Dec 2022 01:47:34 +0000 (20:47 -0500)]
docs/features: Mark ARB_occlusion_query2 as done on asahi

Part of GLES.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agodocs/features: Mark panfrost supporting aniso
Alyssa Rosenzweig [Sun, 4 Dec 2022 01:38:37 +0000 (20:38 -0500)]
docs/features: Mark panfrost supporting aniso

On Mali-G72+ (except for some buggy early G72 models).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agonir: Add store_zs_agx intrinsic
Alyssa Rosenzweig [Sat, 17 Dec 2022 04:23:58 +0000 (23:23 -0500)]
nir: Add store_zs_agx intrinsic

Will be used for frag depth/stencil export with multisampling.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

22 months agoci: Lima farm maintenance
Erico Nunes [Thu, 15 Dec 2022 19:04:36 +0000 (20:04 +0100)]
ci: Lima farm maintenance

General lab maintenance and addressing
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20051

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20343>

22 months agor600/sfn: Fix test compilation with -fno-rtti
Michał Górny [Thu, 8 Dec 2022 19:07:51 +0000 (20:07 +0100)]
r600/sfn: Fix test compilation with -fno-rtti

79ca456b4837b3bc21cf9ef3c03c505c4b4909f6 reintroduced the use
of dynamic_cast<> in r600/sfn tests.  This breaks compilation with
-fno-rtti, as required to build against the LLVM configuration
recommended upstream.  Use static_cast<> instead to fix this.

Fixes: #7820
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20239>

22 months agor600/sfn: Fix test for possible dest slot
Gert Wollny [Sat, 17 Dec 2022 10:15:17 +0000 (11:15 +0100)]
r600/sfn: Fix test for possible dest slot

Fixes Coverity CID 1517721

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20367>

22 months agor600/sfn: don't use a return register when shader doesn't read it
Gert Wollny [Wed, 14 Dec 2022 16:16:09 +0000 (17:16 +0100)]
r600/sfn: don't use a return register when shader doesn't read it

This reduces register pressure.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20367>

22 months agoiris: Limit DG2 modifiers to DG2
Jianxun Zhang [Fri, 16 Dec 2022 19:25:35 +0000 (11:25 -0800)]
iris: Limit DG2 modifiers to DG2

These DG2 modifiers should be disabled on other devices.

Signed-off-by: Jianxun Zhang <jianxun.zhang@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20363>

22 months agovenus: rename sync_queue -> timeline
Ryan Neph [Wed, 14 Dec 2022 21:34:47 +0000 (13:34 -0800)]
venus: rename sync_queue -> timeline

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: support vtest+multiple_timelines and enable
Ryan Neph [Tue, 13 Dec 2022 23:13:02 +0000 (15:13 -0800)]
venus: support vtest+multiple_timelines and enable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: add supports_multiple_timelines capset and enable
Ryan Neph [Tue, 8 Nov 2022 01:14:23 +0000 (17:14 -0800)]
venus: add supports_multiple_timelines capset and enable

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: support external fencing with multiple timelines
Ryan Neph [Wed, 24 Aug 2022 17:38:51 +0000 (10:38 -0700)]
venus: support external fencing with multiple timelines

Without globalFencing, exportable fences and semaphores must instead
have their proxy vn_renderer_sync installed in the same renderer
ring_idx as ther last queue submissions to ensure they signal after
all work previously submitted to the same ring_idx. Exportable
fences/semaphores with a temporary (imported) payload don't need a proxy
vn_renderer_sync, since they already have a `poll()`able fd available.

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: place wsi submissions on corresponding ring_idx
Ryan Neph [Mon, 22 Aug 2022 23:32:14 +0000 (16:32 -0700)]
venus: place wsi submissions on corresponding ring_idx

With implicit fencing, the image has a fence that blocks scanout until
rendering is complete. virtgpu doesn't support implicit fencing yet, but
Sommelier (a VM Wayland compositor) does the wait by exposing the bo as
a GEM handle and waiting on all fences in userspace with a
DRM_IOCTL_VIRTGPU_WAIT before issuing the wl_surface commit.
During vkQueueSubmit involving wsi images, we follow with an empty
renderer submission on the corresonding ring_idx to install a fence
on the appropriate virtgpu fence context after the last rendering
submission.

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: remove workaround for empty renderer submissions
Ryan Neph [Thu, 15 Dec 2022 23:33:37 +0000 (15:33 -0800)]
venus: remove workaround for empty renderer submissions

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: allow renderer submissions on per-context virtgpu rings
Ryan Neph [Wed, 10 Aug 2022 00:12:07 +0000 (17:12 -0700)]
venus: allow renderer submissions on per-context virtgpu rings

For submissions to renderers that support multiple timelines, put
them on the virtgpu fencing timeline (dma fence context) specified by
the VkQueue's bound ring_idx. CPU-sync'd renderer submissions
can be sent in the same manner by using ring_idx = 0.

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: bind VkQueue to available ring_idx at creation
Ryan Neph [Wed, 9 Nov 2022 22:37:10 +0000 (14:37 -0800)]
venus: bind VkQueue to available ring_idx at creation

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: use upstream DRM_IOCTL_VIRTGPU_CONTEXT_INIT
Ryan Neph [Wed, 15 Dec 2021 01:10:36 +0000 (17:10 -0800)]
venus: use upstream DRM_IOCTL_VIRTGPU_CONTEXT_INIT

And remove SIMULATE_CONTEXT_INIT and PARAM_MAX_SYNC_QUEUE_COUNT now that
we expect guest kernel support for CONTEXT_INIT with standard support
for up to 64 rings.

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: update venus-protocol for multiple timelines
Ryan Neph [Wed, 9 Nov 2022 22:05:18 +0000 (14:05 -0800)]
venus: update venus-protocol for multiple timelines

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agovenus: formatting fixes
Ryan Neph [Wed, 7 Dec 2022 21:45:40 +0000 (13:45 -0800)]
venus: formatting fixes

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19691>

22 months agoCI: Overwrite valve infra's registry
Benjamin Tissoires [Fri, 16 Dec 2022 18:44:05 +0000 (19:44 +0100)]
CI: Overwrite valve infra's registry

This is a temporary workaround wihle we wait for valve-infra to sort
out this issue.

It is safe to do because registry.freedesktop.org is a mirror of
harbor.freedesktop.org.

Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7913
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20362>

22 months agoutil: Fixes thread safety of DEBUG_GET_ONCE_*_OPTION macros
Yonggang Luo [Sat, 5 Nov 2022 20:32:05 +0000 (04:32 +0800)]
util: Fixes thread safety of DEBUG_GET_ONCE_*_OPTION macros

Pick DEBUG_GET_ONCE_BOOL_OPTION as a example:
The intention of DEBUG_GET_ONCE_BOOL_OPTION are returned the same value across
thread, before this commit, on different thread call the function generated by
DEBUG_GET_ONCE_BOOL_OPTION may return different value if called setenv in the
middle of debug_get_bool_option, so use debug_get_option_cached along with
new exposed function debug_parse_bool_option to solve this issue

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19554>

22 months agoutil: Add function debug_get_option_cached os_get_option_cached
Yonggang Luo [Sat, 5 Nov 2022 20:26:38 +0000 (04:26 +0800)]
util: Add function debug_get_option_cached os_get_option_cached

This is used to fixes DEBUG_GET_ONCE_*_OPTION macros latter

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19554>

22 months agoutil: Improve os_get_android_option to be thread-safe
Yonggang Luo [Sun, 23 Oct 2022 16:30:38 +0000 (00:30 +0800)]
util: Improve os_get_android_option to be thread-safe

struct hash_table is not thread-safety, need guard by mutex,
but with thread local storage, we can simplify the code and also
got the thread safety without the need of mutex.
Another advantage is by using thread local storage, os_get_android_option
will have the same actions like getenv does, that it's not cached the
value, each call will access the property_get, like getenv will be affected
by putenv

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19554>

22 months agoutil: Improve prototype of debug_get_num_option and debug_get_flags_option
Yonggang Luo [Wed, 2 Nov 2022 06:46:16 +0000 (14:46 +0800)]
util: Improve prototype of debug_get_num_option and debug_get_flags_option

Getting debug_get_num_option to return int64_t, as long under 64 bit Linux are 64 bit size,
 so using fixed int64_t for cross platform consistence, as long under win32 is 32 bit size.

Getting DEBUG_GET_ONCE_FLAGS_OPTION to return uint64_t to getting it to be
consistence with debug_get_flags_option.

DEBUG_GET_ONCE_NUM_OPTION is not accessed in codebase, so add unittest for it, it maybe
used in future, remove it is not consistence

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19554>

22 months agoutil: Indent u_debug.c with 3 space instead of tab
Yonggang Luo [Wed, 2 Nov 2022 09:58:36 +0000 (17:58 +0800)]
util: Indent u_debug.c with 3 space instead of tab

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19554>