Commit Graph

45 Commits

Author SHA1 Message Date
Alyssa Rosenzweig c7bf3b69eb panvk: Clang-format
We're going to enforce clang-format in CI, so get with the program! This doesn't
change a *ton* all considered, because panvk was already aiming for the style we
have in the panfrost clang-format file.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22372>
2023-04-10 21:56:04 +00:00
Rebecca Mckeever f381187b8f panvk: Delete panvk_CmdSetDeviceMask, panvk_GetDeviceGroupPeerMemoryFeatures
Delete panvk_CmdSetDeviceMask and panvk_GetDeviceGroupPeerMemoryFeatures
so that the vk_common_* version will be used instead. This will avoid
repeated code.

Signed-off-by: Rebecca Mckeever <rebecca.mckeever@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20218>
2022-12-09 14:08:14 -06:00
Jason Ekstrand 84cd81e104 panvk: Use common code for command buffer lifecycle management
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16922>
2022-11-11 05:01:24 +00:00
Jason Ekstrand f90e2af996 vulkan: Re-order arguments to vk_command_pool_init
Most other init functions follow the Vulkan API convention of putting
the parent object first.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18324>
2022-09-01 20:17:25 +00:00
Alyssa Rosenzweig 9bdd0854ea panvk: Use common CmdBeginRenderPass
The runtime already handles this.

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/16950>
2022-06-13 17:27:36 +00:00
Jason Ekstrand a463c58e22 panvk: Put SSBO addresses in the descriptor buffer
Instead of storing SSBO pointers in the very limited sysval space, store
them in the UBO we've attached to the descriptor set.  This gives us a
virtually unlimited number of SSBOs.  Dynamic SSBOs still live in the
sysval space so we can update them as part of vkCmdBindDescriptorSets().
Also, the new code (based on the code in ANV) loads those SSBO addresses
in a way that never chases the deref chain back to the variable so we
should now be able to handle all of variable pointers.  The code as
written in this patch is a bit overly generic because it switches on
address modes a bit more than panvk needs but we ended up needing all
that flexibility in ANV so we may as well leave hooks for it in panvk.

Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16276>
2022-05-12 10:53:16 +00:00
Jason Ekstrand c32ddb5e77 panvk: Use a flat sysvals struct
PanVK uses fewer sysvals than the GLES driver, as some data that would
be a data in GLES is instead part of the descriptor set or the pipeline
state in Vulkan. Therefore, it is simpler and more efficient to use a
flat, fixed layout provided by the driver for our sysvals, rather than
the compiler choosing a layout.

This commit switches to a flat sysval layout.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16276>
2022-05-12 10:53:16 +00:00
Jason Ekstrand 763744aa8b panvk: Add address/range helpers for panvk_buffer
The range helper is taken from ANV; the gpu_ptr one is original.  This
also fixes a few more bugs where we weren't adding offsets in properly.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16216>
2022-05-02 17:37:40 -05:00
Jason Ekstrand e248c64f06 panvk: Take buffer offsets into account in BindVertexBuffers
Found by inspection.  No idea what all it fixes.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16183>
2022-04-27 14:18:25 +00:00
Jason Ekstrand 012bfde7f3 panvk: Hook up emulated secondary command buffers
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
2022-03-18 17:29:16 +00:00
Boris Brezillon 58587c32cb panvk: Implement indexed rendering
Since we can do 8-bit index buffers, also advertise VK_EXT_type_uint8.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15295>
2022-03-16 09:58:46 -05:00
Boris Brezillon 02906baba7 panvk: Implement vkCmdDispatch()
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15248>
2022-03-09 04:50:41 +00:00
Boris Brezillon 1056b3e39e panvk: Add support for storage image
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15248>
2022-03-09 04:50:41 +00:00
Boris Brezillon 0e7e1b64fc panvk: Add support for storage/uniform buffers with dynamic offsets
The idea of storing offsets in a separate UBO and lowering accesses to
UBOs/SSBOs with a dynamic offset was not great. Let's apply the offset
at UBO/SSBO emission time instead.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15248>
2022-03-09 04:50:41 +00:00
Boris Brezillon b05ffc9fec panvk: Add support for storage buffers
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15248>
2022-03-09 04:50:41 +00:00
Boris Brezillon 9a20467cf2 panvk: Add support for push constants
Push constants are stored in a separate UBO.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15248>
2022-03-09 04:50:41 +00:00
Jason Ekstrand 2a5ae138b4 panvk: Use vk_command_pool
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>
2022-02-11 08:06:24 +00:00
Alyssa Rosenzweig 6c0d433d19 panfrost: Centralize our model list
Replaces panfrost-quirks.h

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14726>
2022-01-28 17:47:46 +00:00
Jason Ekstrand 708b65f704 panvk: Switch to the new vk_error helpers
Also switch all our calls to use the closest object to the error and let
vk_error sort out which object to actually use.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:36 +00:00
Boris Brezillon 346c6ac221 panvk: Fix stencil clear assignment in panvk_cmd_fb_info_set_subpass()
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>
2021-09-28 14:03:40 +00:00
Boris Brezillon 96f006539f panvk: Fix an overflow on cmdbuf->state.clear
We assume the cmdbuf->state.clear array will have one entry per
attachment, but clearValueCount might be smaller if some attachments
are not cleared.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>
2021-09-28 14:03:40 +00:00
Boris Brezillon 20fe252664 panvk: Fix the pipeline binding logic
Right now, only one pipeline can be bound at any given time, instead of
one per bind-point. Fix the code so we can support compute operations.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>
2021-09-28 14:03:40 +00:00
Boris Brezillon 5360e6240d panvk: Don't invalidate the vertex attributes when binding a new pipeline
This should be done when binding new vertex buffers.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>
2021-09-28 14:03:40 +00:00
Boris Brezillon 8fb22d28d8 panvk: Make panvk_cmd_open_batch() return the new batch
So we can get replace the

   panvk_cmd_open_batch();
   batch = cmdbuf->state.batch;

sequence by

   batch = panvk_cmd_open_batch();

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>
2021-09-28 14:03:40 +00:00
Boris Brezillon 915a41f55a panvk: Fix TLS initialization for multi-draw batches
If we queue multiple draws to the same batch, the TLS size should be
adjusted to cover the maximum TLS size requirement, not just the one
of the pipeline bound when the batch is closed. This requires keeping
TLS info attached to the batch and updating it every time a draw is
issued.

While at it, get rid of the wg_count state: we'll let vkCmdDispatch()
calculate the total WLS size.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>
2021-09-28 14:03:40 +00:00
Boris Brezillon e856386764 panvk: Fix the static scissor/viewport case
Even if we can build a static viewport descriptor, we will need the
static scissor/viewport data to fill the viewport sysvals.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>
2021-09-28 14:03:40 +00:00
Boris Brezillon 165c26b9e1 panvk: Preload FB attachments when required
There are at least three situations where we need to preload FBs:

1. The attachment is flagged VK_ATTACHMENT_LOAD_OP_LOAD and has not been
   accessed in previous subpasses

2. The batch is implicitly split (e.g. too many jobs queued to the
   batch, wait/set events queued, ...)

3. The attachment has been written by a previous subpass

With those changes, we can get rid of panvk_emit_fb() and call
pan_emit_fbd() directly (fb_info is initialized when starting a subpass
and updated when an implicit split happens).

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12095>
2021-09-21 15:00:07 +02:00
Boris Brezillon 81e8a5d83a panvk: Initialize clear values to zero when load_op != OP_CLEAR
This is easier to detect when something goes wrong with this default
initialization in place.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12762>
2021-09-10 11:41:59 +02:00
Boris Brezillon 2c4b8f9168 panvk: Clamp blend constants before copying them to the cmdbuf state
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12762>
2021-09-10 11:41:29 +02:00
Boris Brezillon 792a0ab0b1 panvk: Prepare per-gen split
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12551>
2021-08-26 10:35:17 +02:00
Boris Brezillon 423f67c1bd pan/gen_pack: Add pan_size() and pan_align() macros
And replace all references to MALI_xxx_{LENGTH,ALIGN} by
pan_{size,alignment}(xxx) calls so we can give generic alias to
midgard/bifrost specific descriptors.

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/12551>
2021-08-26 10:35:16 +02:00
Alyssa Rosenzweig 22538b89b3 panfrost: Handle non-dithered clear colours
In b9c095cc2c ("panfrost: Rewrite the clear colour packing code"),
packing of clear colours was corrected to use the tilebuffer's
fractional bits, fixing dithering of the clear colour with formats like
RGB565. Unfortunately, that commit did so unconditionally. If the
framebuffer is dithered, but dithering is disabled at the time of
the clear, we would incorrectly dither the clear.

This is a regression, as the old (broken) code passed the relevant CTS
test. What's the catch? Depending on dither state, there are two
formulas to pack tilebuffer colours. We need to handle both. Fixes
KHR-GLES31.core.draw_buffers_indexed.color_masks.

Fixes: b9c095cc2c ("panfrost: Rewrite the clear colour packing code")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12460>
2021-08-18 23:32:40 +00:00
Alyssa Rosenzweig 62e902101b panvk: Use pan_pack_color
This is in common code now. Inherit all the bug fixes from panfrost.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12365>
2021-08-16 16:35:50 +00:00
Tomeu Vizoso cd97eb123e panvk: Expose panvk_cmd_alloc_fb_desc and panvk_cmd_alloc_tls_desc
For use in panvk_meta.c.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12019>
2021-07-27 15:18:35 +02:00
Tomeu Vizoso f295e7f1d9 panvk: A pipeline might not be bound when the render pass is ended
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12019>
2021-07-27 15:18:34 +02:00
Tomeu Vizoso 7a0acc35af panvk: Move check for fragment requirement up to the draw
As the panvk_cmd_alloc_fb_desc function might be called outside a draw,
without a pipeline having been bound to the command buffer.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12019>
2021-07-27 15:18:34 +02:00
Tomeu Vizoso cef56d5824 panvk: Close batch when ending a command buffer
In some cases, there will be an open batch because an event operation
has been recorded, or a non-rendering command.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12019>
2021-07-27 15:18:34 +02:00
Tomeu Vizoso 616aa3f138 panvk: Start a new batch when the job index gets above the limit
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12019>
2021-07-27 15:18:34 +02:00
Tomeu Vizoso 1e23004600 panvk: Add vkEvents support
Use syncobjs to implement vkEvents (as suggested by Boris).

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11709>
2021-07-05 15:08:05 +02:00
Tomeu Vizoso 9a0e0af497 panvk: Add VkCommandPool support
Mostly just copied from turnip.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11695>
2021-07-05 05:43:49 +00:00
Boris Brezillon d629debaca panvk: Support returning BOs allocated by panvk_pool to a 'free BO' pool
So all CommandBuffers in a given CommandPool can reuse BOs for their
memory pools.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11695>
2021-07-05 05:43:49 +00:00
Tomeu Vizoso d33a3fad64 panfrost: Fork pan_pool for Gallium and Vulkan
This commit adds the actual implementations, allowing to diverge while
still sharing code that depends on pool functionality.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11695>
2021-07-05 05:43:49 +00:00
Boris Brezillon deb4074a54 panfrost: Start splitting the panfrost pool logic
The Gallium and Vulkan drivers will soon use different memory pool
implementation, but some pieces in libpanfrost depend on pan_pool. Let's
split the implementation so we have common bits still available while
letting the drivers implement what really matters: the allocation logic.

All the generic pieces are prefixed pan_pool, and what will become the
gallium implementation is prefixed panfrost_pool. We'll then duplicate
the panfrost_pool bits in panvk and prefix it with panvk_pool, and
implementations will start diverging from there.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11695>
2021-07-05 05:43:49 +00:00
Boris Brezillon 4f0896ea4f panvk: Use the desc alloctor when we can
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11695>
2021-07-05 05:43:49 +00:00
Boris Brezillon d970fe2e9d panfrost: Add a Vulkan driver for Midgard/Bifrost GPUs
Based on turnip.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Kristian H. Kristensen <hoegsberg@google.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11139>
2021-06-22 14:07:34 +00:00