Commit graph

490 commits

Author SHA1 Message Date
Gert Wollny
4824238dd9 zink: Fix return type and values of create_buffer and create_images
Fixes: f6383e03f9
    zink: use enums as return values in resource_object_create

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10532
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27387>
2024-01-31 14:56:55 +00:00
Mike Blumenkrantz
0a97d1ebfa zink: fix descriptor buffer unmaps on screen destroy
descriptor buffer uses mapped buffers. mapping/unmapping buffers
uses a ctx in the function params, but at this time there is no ctx.
since the ctx is not actually used for unmapping descriptor buffers,
this can instead use a special buffer unmap function to avoid invalid access

Fixes: b06f6e00fb ("zink: fix heap-use-after-free on batch_state with sub-allocated pipe_resources")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27344>
2024-01-31 04:08:20 +00:00
Gert Wollny
f6383e03f9 zink: use enums as return values in resource_object_create
(As suggested by Mike).

With that replace the goto statements for error cleanup by
a switch/case.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
3d203b5477 zink: remove duplicate arguments and use VkMemoryRequirements locally
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
9c3e733779 zink: simplify call to get_export_flags
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
472bca9469 zink: Move more code to create_image and create_buffer
With that resource_object_create only contains the common
initzialization, the error handling and then calls seperate
functions to create buffers or images.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
0b88f68067 zink: extract allocate_bo_and_update_obj from resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
df9cbe431e zink: drop duplicate assignment to obj->alignment
The value resource_object_create obj->alignment is set again in
allocate_bo and the assignment uses a few more tests there.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
063949063c zink: extract debug_resource_mem from resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
7180670e28 zink: extract update_obj_info from resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
081e5d1109 zink: extract function update_alloc_info from resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
1d0e9001cd zink: extract function create_image from resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
eb394f5316 zink: redesign the allocation try loop to test all heaps
Before the first time an allocation failed the heap was changed,
now we only change the heap type when checking all heaps results
in allocation failure.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
252e877a87 zink: extract function allocate_bo from resource_create_object
v2: move reworking the loop to a new commit (Mike)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
3806586c6e zink: extract get_export_flags from resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
e22c525aa0 zink: reduce number of #ifdefs in resource_create_object
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
a5fd408a74 zink: factor out get_image_memory_requirement in resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
55f3941076 zink: factor out get_format_feature_flags in resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
6664fdaf48 zink: Factor out create sampler conversion in resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
b2ce61b91d zink: shorten lifetime of success variable in resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:32 +00:00
Gert Wollny
7cf77c553c zink: Factor out create buffer from resource_object_create
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27155>
2024-01-30 20:17:31 +00:00
Marek Olšák
39c1311766 gallium/pb_buffer: define pb_buffer_lean without vtbl, inherit it by pb_buffer
amdgpu doesn't need vtbl.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26643>
2024-01-06 20:55:30 +00:00
Mary Guillemard
db0f177edd zink: Initialize pQueueFamilyIndices for image query / create
Fixes: d922850e36 ("zink: break out image/buffer create info structs into helper funcs")

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26303>
2024-01-05 13:59:49 +01:00
Karol Herbst
049af04341 zink: validate pointer alignment in resource_from_user_memory
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25937>
2023-10-28 14:38:55 +02:00
Mike Blumenkrantz
009d4a5fda zink: always set VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT for usermem
required by spec

backport-to: 23.3

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25914>
2023-10-27 00:44:49 +00:00
Mike Blumenkrantz
cd08b070a3 zink: add flag to restrict unsynchronized texture access
this is unset any time a texture is accessed and must be explicitly
re-set to preserve unsynchronized access

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25624>
2023-10-26 22:31:26 +00:00
Mike Blumenkrantz
8ee0d6dd71 zink: add a third cmdbuf for unsynchronized (not reordered) ops
this provides functionality for unsynchronized texture uploads without
HIC support by adding a cmdbuf which can only be accessed directly by
the frontend thread

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25624>
2023-10-26 22:31:26 +00:00
Mike Blumenkrantz
7d0dbdeca2 zink: assert that transfer_dst is available before doing buf2img
the blitter path here was just wishful thinking anyway

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25624>
2023-10-26 22:31:25 +00:00
Mike Blumenkrantz
00206e01a4 zink: handle unsynchronized image maps from tc
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25624>
2023-10-26 22:31:25 +00:00
Mike Blumenkrantz
782481c429 zink: add copy box locking
this can technically be accessed by multiple threads, so ensure
access is serialized

backport-to: 23.3

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25924>
2023-10-26 21:13:01 +00:00
Mike Blumenkrantz
99ff88cb5e zink: delete some dead modifier handling
this is no longer hit

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25299>
2023-10-25 18:23:16 +00:00
Mike Blumenkrantz
1c3db3e39a zink: blow up broken xservers more reliably
only certain drivers can successfully run an xserver with implicit modifier
handling, and the rest will have broken rendering

until such time that a vk extension emerges to handle this more widely,
break this interop for drivers where it's already broken

fixes #9819

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25299>
2023-10-25 18:23:16 +00:00
Mike Blumenkrantz
12fc8cf4df zink: only increment image_rebind_counter on image export if binds exist
rebinding all images on all contexts is only relevant for images which
have bindings, otherwise it's just pointless churn

fixes #10016

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25829>
2023-10-24 02:24:15 +00:00
Erik Faye-Lund
3485744087 zink: fix wording of warning
The string-argument for this function is the name of the feature, not
the entire message.

Fixes: ea0e22da44 ("zink: use warn_missing_feature for missing modifier support")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25644>
2023-10-10 16:11:05 +00:00
Samuel Pitoiset
ea0e22da44 zink: use warn_missing_feature for missing modifier support
To avoid spamming VKCTS output.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25636>
2023-10-10 11:44:12 +00:00
Mike Blumenkrantz
c8f4cfd641 zink: error at handle export on missing EXT_image_drm_format_modifier
this doesn't work anyway

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25526>
2023-10-09 18:43:09 +00:00
Mike Blumenkrantz
6d5174974a zink: use HIC for image subdata when possible
this has a lot of caveats:
* extension must be supported
* resource must have usage bit set
* resource must not have any pending batch usage
* resource must be in supported layout

if all of these conditionals pass, then HIC can be used for direct image subdata

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24775>
2023-09-09 13:02:44 +00:00
Mike Blumenkrantz
f24891269d zink: check/use suboptimal HIC during ici init
this allows implicit use of HIC where possible while rejecting it when
it would cause performance loss

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24775>
2023-09-09 13:02:44 +00:00
Mike Blumenkrantz
e006a3d8bc zink: use some return codes for check_ici errors
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24775>
2023-09-09 13:02:44 +00:00
Mike Blumenkrantz
4feb37d629 zink: fix some off-by-one indentation
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24775>
2023-09-09 13:02:44 +00:00
Mike Blumenkrantz
87fa46c10d zink: use VkFormatProperties3
but wrap it in a smaller type to save some space

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24775>
2023-09-09 13:02:44 +00:00
Mike Blumenkrantz
ca162bc82d zink: fix linear modifier dmabuf imports
these are disguised as INVALID modifiers, but really they're LINEAR

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25002>
2023-09-05 04:58:36 +00:00
Mike Blumenkrantz
252bff0f48 zink: use real A8_UNORM when possible
this is tricky because drivers are exposing their native support, but
that support may not fit the specific needs of the format

as such, (almost) every use of format where alpha emulation workarounds are
present now need to add a second layer of workarounds in order to handle
the case of possibly-genuine A8 (which might also be emulated A8 even if
the driver supports A8 for some things)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24685>
2023-08-15 16:42:27 +00:00
Mike Blumenkrantz
d19e8fc1fb zink: split create_ici to init and eval
no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24685>
2023-08-15 16:42:27 +00:00
Mike Blumenkrantz
4f8561369e zink: remove unused param from create_ici
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24685>
2023-08-15 16:42:27 +00:00
Mike Blumenkrantz
751407a59a zink: don't add VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT for transient images
this is illegal

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24309>
2023-08-08 20:20:09 +00:00
Dave Airlie
ae6be7a44a zink: turn off threaded cpu access if not visible.
This turns off the threaded cpu access it the resource isn't visible.

Fixes a bunch of crashes with current nvk.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24548>
2023-08-08 05:06:11 +00:00
Mike Blumenkrantz
d2a7ddf066 zink: get new bda when rebinding invalidated buffers
this otherwise yields a broken descriptor

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23803>
2023-06-30 00:48:07 +00:00
Yonggang Luo
7b45a0bd66 treewide: replace usage of boolean to bool
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23577>
2023-06-27 18:18:27 +08:00
Mike Blumenkrantz
c15b2491ec zink: ZINK_HEAP_HOST_VISIBLE_CACHED -> ZINK_HEAP_HOST_VISIBLE_COHERENT_CACHED
all host-visible memory in zink is expected to be coherent, and this makes
that expectation more explicit

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23728>
2023-06-20 16:53:32 +00:00