Commit graph

490 commits

Author SHA1 Message Date
Julia Tatz
e20e8f2243 zink: trival renames heap_idx -> memoryTypeIndex
Trival renames to correctly identify vulkan memory type indices aren't
the same as zink heaps

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20264>
2023-01-19 17:20:00 +00:00
Mike Blumenkrantz
072e29a22e zink: store drm format as internal_format for imported resources
internal_format is the "real" format of a resource, and the "real" format
of imported resources is the external-facing format, not the pipe format

this ensures the correct format is available for internal ops, such as nplanes queries

Fixes: 2e2775c11b ("zink: fix PIPE_RESOURCE_PARAM_NPLANES with format modifier")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20753>
2023-01-19 16:01:14 +00:00
Simon Ser
2e2775c11b zink: fix PIPE_RESOURCE_PARAM_NPLANES with format modifier
Some format modifiers change the number of planes used by an image.
For instance AMD DCC modifiers uses 2 or 3 planes. However the
format modifier was ignored in the PIPE_RESOURCE_PARAM_NPLANES
get_param hook.

Fix this by using get_dmabuf_modifier_planes() instead of
util_format_get_num_planes().

This fixes wlroots-based compositors under zink.

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: c025cb9ee9 ("zink: fix dmabuf plane returns")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20395>
2023-01-12 14:40:30 +00:00
Emma Anholt
f74bbcd8a0 zink: Have u_transfer_helper resolve MSAA surfaces when mapping.
This fixes all the dEQP winsys multisampling failures (like
dEQP-GLES3.functional.multisample.default_framebuffer.depth) I've found so
far.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20523>
2023-01-06 19:00:17 +00:00
Mike Blumenkrantz
7ab5c5d36d zink: use EXT_descriptor_buffer with ZINK_DESCRIPTORS=db
this should be bug-free, as it passes cts/piglit/gaming on multiple drivers,
but since it's new, it stays behind an env var for at least one release

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20489>
2023-01-03 09:20:45 -05:00
Mike Blumenkrantz
c128cbb5bb zink: always add MUTABLE with EXTENDED_USAGE for image creation
this otherwise makes little sense

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19018>
2022-10-28 00:51:48 +00:00
Mike Blumenkrantz
f2d3826dac zink: don't force attachment usage for images when unsupported
this is illegal even with EXTENDED_USAGE, but it will also probably
explode later when trying to populate the image

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19018>
2022-10-28 00:51:48 +00:00
Mike Blumenkrantz
8de17393f5 zink: fix weird formatting
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19018>
2022-10-28 00:51:48 +00:00
Mike Blumenkrantz
8dd314d203 zink: handle broken resource mapping deadlocks
some apps (most notably Wolfenstein: The New Order) have broken multi-context
buffer usage in which one context will attempt to write to a buffer while
another context holds unflushed usage, and the unflushed context will never
flush until the buffer write completes

it's impossible to handle this scenario correctly without deadlocking,
so add some handling to try waiting and then yolo the buffer write if
a deadlock would occur

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19141>
2022-10-26 18:29:16 +00:00
Mike Blumenkrantz
d702a503ad zink: support multiple heaps per memory type
some allocations require a different memory heap even when using the
same memory bits, so allow iterating over heaps of the same memory type
to find the one that works

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19281>
2022-10-25 02:06:24 +00:00
Mike Blumenkrantz
f9515d9376 zink: allocate/place memory using memoryTypeIndex directly
it's possible for drivers to have multiple heaps with identical flags,
so this will enable passing the heap that should actually be used for
allocation

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19281>
2022-10-25 02:06:23 +00:00
Mike Blumenkrantz
a3552048c7 zink: allow direct memory mapping for any COHERENT+CACHED buffer
some drivers may provide this in heaps that get used by non-staging resources,
so avoid extra copies in that case

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19281>
2022-10-25 02:06:23 +00:00
Mike Blumenkrantz
bf3edad94c zink: enable tc cpu storage on some buffers
matching freedreno usage

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19142>
2022-10-19 05:43:40 +00:00
Mike Blumenkrantz
2710ef4c2a zink: don't add other usage bits for transient images
this is illegal

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19065>
2022-10-14 01:16:30 +00:00
Mike Blumenkrantz
19a74229c9 zink: add some bda handling
will be useful in the near future

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19044>
2022-10-11 22:26:00 -04:00
Mike Blumenkrantz
97c7eaf17f zink: use feedback loop layout to correctly handle implicit feedback loops
an implicit feedback loop occurs when an app happens to bind the same image
as both a framebuffer attachment and a sampler for the same draw

an explicit feedback loop occurs when an app uses fbfetch to read data back
from the framebuffer using input attachments

fbfetch is already handled, but implicit feedback loops require more work:
* detecting them happens on-the-fly
* pipeline variants are required

this handles implicit feedback loops by detecting them at draw time during
barrier updates and then flagging pipeline state change to trigger variant creation.
the bits are then unset when the framebuffer/sampler binds are removed

fixes #7309

fixes (tu):
KHR-GL46.texture_barrier.disjoint-texels
KHR-GL46.texture_barrier.overlapping-texels
KHR-GL46.texture_barrier.same-texel-rw-multipass
KHR-GL46.texture_barrier_ARB.disjoint-texels
KHR-GL46.texture_barrier_ARB.overlapping-texels
KHR-GL46.texture_barrier_ARB.same-texel-rw-multipass

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18787>
2022-09-27 17:32:56 +00:00
Mike Blumenkrantz
630967b252 zink: rename fb_binds -> fb_bind_count
this is more accurate

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18787>
2022-09-27 17:32:56 +00:00
Mike Blumenkrantz
f6bbd7875a zink: remove batch tracking/usage from view types
instead of incurring all the overhead of tracking lifetimes for these,
it makes more sense to just let them delete whenever and then store
the vk object onto its parent image/buffer to be deleted when that gets
freed, as the parent object's lifetime will always be >= the view's lifetime

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18664>
2022-09-22 21:38:47 +00:00
Mike Blumenkrantz
73797c2f46 zink: use screen interfaces for pipeline barriers
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18628>
2022-09-19 01:42:28 +00:00
Mike Blumenkrantz
fe05daeea7 zink: don't set MUTABLE by default
this is only used by texture views, so use the same mechanism as STORAGE
to add the flag only as-needed

the mutable flag must be set before create_ivci is called for the imageview,
so zink_resource_object_init_mutable() is moved out to the callers of
zink_get_surface instead of being conveniently located in that function

fixes #7174

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18358>
2022-09-01 23:27:28 +00:00
Mike Blumenkrantz
cd00a36d47 zink: only add srgb mutable for images with modifiers
these are supposed to be for dmabuf handling, so checking for mutable
swapchain is both pointless and wrong

Fixes: 28ee911ad6 ("zink: handle mutable swapchain images with dmabuf")

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18358>
2022-09-01 23:27:28 +00:00
Erik Faye-Lund
c033a12c52 zink: use full transfer-helper api
This is going to make it easier to maintain u_transfer_helper in the
future.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17959>
2022-08-30 14:36:32 +00:00
Erik Faye-Lund
c5a01854df gallium/u_transfer_helper: clean up boolean flags
Whenever we add or remove a flag here, we need to update a bunch of
drivers in a fragile way. Moving to flags here instead should make this
a bit easier to maintain in the future.

Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17959>
2022-08-30 14:36:32 +00:00
Mike Blumenkrantz
43703d8265 Revert "zink: add all format modifiers when adding for dmabuf export"
This reverts commit 247b8f2924.

this attempted to work around what is likely a bug in nvidia's modifier
support, namely their refusal to expose LINEAR as a valid modifier for
some bizarre reason

cc: mesa-stable

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18148>
2022-08-19 18:55:26 +00:00
Mike Blumenkrantz
5b7c2dffc4 Revert "zink: try to reuse swapchain modifier for dmabuf export"
This reverts commit 49efa73ba1.

this happens to work with mesa (sometimes), but it's going to be
illegal most of the time since swapchain images are treated as though
they are created with OPTIMAL tiling

cc: mesa-stable

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18148>
2022-08-19 18:55:26 +00:00
Mike Blumenkrantz
49efa73ba1 zink: try to reuse swapchain modifier for dmabuf export
the non-negotiated path assumes that drivers know what implicit modifiers they're
using, but zink doesn't know what it's doing, so instead try to copy the
swapchain's modifier and reuse that since in theory it should work

Fixes: 247b8f2924 ("zink: add all format modifiers when adding for dmabuf export")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18095>
2022-08-18 14:38:15 +00:00
Mike Blumenkrantz
f7b1ef37c0 zink: iterate over all modifiers and nuke the ones that aren't supported
the spec mandates that all modifiers passed to the driver be valid, so
iterate through all of them and delete the invalid ones

Fixes: 247b8f2924 ("zink: add all format modifiers when adding for dmabuf export")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18095>
2022-08-18 14:38:15 +00:00
Mike Blumenkrantz
63d70d6dd9 zink: bail out of dmabuf resource creation when srgb explosion is expected
if srgb-ness isn't supported by the driver for dmabuf, bail out early with an
error message with the assumption that this would later (maybe) explode when
trying to create a view for srgb framebuffer

ref !17900

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18095>
2022-08-18 14:38:15 +00:00
Mike Blumenkrantz
30c51abd0b zink: move all types/enums into zink_types.h
this significantly untangles all the header includes and fixes an issue
where zink_descriptors.h couldn't be included by certain files due to
type conflicts

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18051>
2022-08-14 18:38:04 -04:00
Mike Blumenkrantz
8b0447eec7 zink: delete a lot of descriptor code
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18051>
2022-08-14 18:38:04 -04:00
Emma Anholt
8dda0a01bb zink: Make sure that we keep the existing ici pNext chain on inserts.
For external image imports, we'd lose the mutable image format list,
causing turnip to get angry that we try to do UBWC despite not having a
UBWC-compatible format list.

Cc: mesa-stable
Fixes: 28ee911ad6 ("zink: handle mutable swapchain images with dmabuf")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17900>
2022-08-09 18:15:45 +00:00
Mike Blumenkrantz
1911dc5abb zink: remove an old RGBA4 nvidia workaround
this should be automatically handled

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17775>
2022-08-05 03:51:05 +00:00
Mike Blumenkrantz
247b8f2924 zink: add all format modifiers when adding for dmabuf export
adding LINEAR before was a good starter step, but LINEAR
might not actually be supported (e.g., nvidia)

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17775>
2022-08-05 03:51:05 +00:00
Mike Blumenkrantz
5e8ec87b68 zink: don't add modifiers if EXT_image_drm_format_modifier isn't present
cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17775>
2022-08-05 03:51:04 +00:00
Mike Blumenkrantz
c824a53f35 zink: use modifier_aspect to check for modifier plane in zink_resource_get_param
cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17775>
2022-08-05 03:51:04 +00:00
Mike Blumenkrantz
b59eb9c8b7 zink: demote dmabuf tiling to linear if modifiers aren't supported
this is effectively the same as LINEAR, and it still allows dmabuf creation

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17775>
2022-08-05 03:51:04 +00:00
Emma Anholt
a3113fbcfc zink: Replace the "optimal_tiling" flag with a "linear" flag instead.
That's what it actually means now.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17549>
2022-08-05 00:23:16 +00:00
Emma Anholt
01ce65da72 zink: Take the tiling path for resources with modifiers.
transfer_map (the only consumer of the flag now) was doing direct mapping
on resources with modifiers (UBWC compressed images on turnip) and
accessing them as linear.  We definitely want the staging blit path
instead.

Fixes glReadPixels() from gbm surfaces on turnip.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17549>
2022-08-05 00:23:16 +00:00
Mike Blumenkrantz
fffd57ef61 zink: store VkFormatFeatureFlags on creation
Acked-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17773>
2022-08-03 17:25:27 +00:00
Mike Blumenkrantz
28ee911ad6 zink: handle mutable swapchain images with dmabuf
if a non-kopper swapchain image supports srgb, add a VkImageFormatListCreateInfo
to permit srgb mutability and avoid violating spec

cc: mesa-stable

Acked-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17773>
2022-08-03 17:25:27 +00:00
TSnake41
a02c026eb7 zink: print result code string on vulkan failure
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17726>
2022-07-28 16:06:50 +00:00
Mike Blumenkrantz
1bc9db6879 zink: split out rp_changed to be more granular for dynamic render
sometimes a state change MAY require a renderpass change, but this change
will not require splitting the current renderpass

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17640>
2022-07-20 17:30:19 +00:00
Eric Engestrom
0ab33ec6d4 zink: use updated tokens from vk.xml
Signed-off-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17342>
2022-07-12 15:53:11 +00:00
Mike Blumenkrantz
4cb3043b53 zink: set PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY for device-local resources
these can't be mapped, so ensure tc doesn't try to pass UNSYNCHRONIZED
maps and break the resources

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17187>
2022-06-29 04:40:07 +00:00
Mike Blumenkrantz
6786e508a2 zink: acquire swapchain images on image map
this is a weird one

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17149>
2022-06-28 02:42:02 +00:00
Mike Blumenkrantz
32c34e93aa zink: add flag to indicate if a resource is a dmabuf
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15810>
2022-06-22 20:42:02 +00:00
Mike Blumenkrantz
be4f120476 zink: be a little selective about BAR fallback memory type
some resources MUST be host-visible, so use the appropriate heap for them

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17093>
2022-06-17 01:14:45 +00:00
Mike Blumenkrantz
5750050432 zink: move BAR allocation demotion up the stack
having this so far down in the BO allocation path meant that slabs were
getting demoted to device-local and then stored as BAR in the pb cache,
which broke the cache pretty badly

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17093>
2022-06-17 01:14:45 +00:00
Mike Blumenkrantz
ce5aa07db1 zink: fix buffer transfer flushes with offsets
the src and dst ofsets need to be adjusted by the base map offset
in order to flush the correct region

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17095>
2022-06-17 00:56:33 +00:00
Mike Blumenkrantz
28d23c9e26 zink: use only the extents for buffer unmap flushes
flush_region is relative to the map, so passing in the offsets again
breaks the flush (if the flush hook is implemented correctly)

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17095>
2022-06-17 00:56:33 +00:00