Commit graph

472 commits

Author SHA1 Message Date
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
Mike Blumenkrantz
7a169254c5 zink: add COHERENT requirement for CACHED memory
zink doesn't handle non-coherent cached memory correctly, so ensure
that scenario is never hit

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23728>
2023-06-20 16:53:31 +00:00
Mike Blumenkrantz
ff1e667e45 zink: strip format list when disabling mutable during image creation
drivers shouldn't be getting a format list if it won't be used

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23514>
2023-06-15 05:02:37 +00:00
Mike Blumenkrantz
9e83723a21 zink: add srgb mutable for all resources by default
this should enable compression on more intermediate fb attachments

it also means that VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT can now be set
on images where ZINK_BIND_MUTABLE is not set, so non-resource APIs need
to check ZINK_BIND_MUTABLE

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23514>
2023-06-15 05:02:37 +00:00
Mike Blumenkrantz
4edbe8f5a0 zink: add mem debugging
modeled off turnip's debug infra, this adds debug printing for oom
scenarios

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23653>
2023-06-15 01:31:24 +00:00
Mike Blumenkrantz
4e87d81d20 zink: add a dgc debug mode for testing
this is useful for drivers trying to implement DGC since there is no cts

do not use.

it will not make anything faster.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23550>
2023-06-14 12:37:24 +00:00
Mike Blumenkrantz
8f56228ace zink: only try to create srgb mutable images if the vk format is supported
otherwise this is just a regular single-format image

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23626>
2023-06-13 17:45:38 +00:00
Mike Blumenkrantz
81834a211d zink: check for cached mem correctly when mapping buffer
bo placement is the mem index, not the mem flags

Fixes: 52f27cda05 ("zink: allow direct memory mapping for any COHERENT+CACHED buffer")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23511>
2023-06-08 14:30:39 +00:00
Julia Tatz
81b0840caa zink: Implement PIPE_CAP_RESOURCE_FROM_USER_MEMORY
Needed for GL_AMD_pinned_memory & zero-copy support in opencl

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23199>
2023-05-25 02:41:23 +00:00
Mike Blumenkrantz
8d58fa5787 zink: only add feedback loop usage bit if extension is supported
cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22960>
2023-05-15 22:52:57 +00:00
Mike Blumenkrantz
443e098f7a zink: make mesa_logw separate from perf_debug
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22899>
2023-05-09 22:16:22 +00:00
Mike Blumenkrantz
24350064ca zink: fix uncached memory readback
the inner conditional here didn't include uncached readback, meaning
that many (most?) buffers allocated with uncached memory (i.e., BAR) were
being read back directly instead of using staging resources to be faster

at some point this inner conditional should be reevaluated to determine
whether it still does anything, but this is not that time

fixes, among other things, loading in DOOM2016 on some GPUs

Fixes: 52f27cda05 ("zink: allow direct memory mapping for any COHERENT+CACHED buffer")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22907>
2023-05-09 00:56:19 +00:00
Mike Blumenkrantz
8e75378a2d zink: delete persistent map tracking
this was never needed and never did anything: zink only uses COHERENT
memory, which is always available on queue submission, so it was all
just pointless code

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22907>
2023-05-09 00:56:19 +00:00
Mike Blumenkrantz
3909471288 zink: use a perf_debug() macro for debug message logging of copy box warning
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22196>
2023-04-20 02:52:16 +00:00
Mike Blumenkrantz
366b79fa10 zink: only print copy box warning once per resource
this otherwise gets spammy

cc: mesa-stable

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22196>
2023-04-20 02:52:16 +00:00
Mike Blumenkrantz
31a0de9921 zink: make general bo allocation more robust by iterating
previously there was a fallback path here (broken by f6d3a5755f)
which would attempt to demote BAR allocations to other heaps on failure
to avoid oom

this was great, but it's not the most robust solution, which is to iterate
all the memory types matching the given heap and try them in addition to having
a demotion fallback

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22479>
2023-04-16 23:55:30 +00:00
Mike Blumenkrantz
9d923b14f9 zink: restore BAR allocation failure demotion
this restores the fallback used when BAR allocation fails due to oom
by re-selecting memoryTypeIndex after the heap demotion

Fixes: f6d3a5755f ("zink: zink_heap isn't 1-to-1 with memoryTypeIndex")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22479>
2023-04-16 23:55:30 +00:00
Mike Blumenkrantz
561b64cf55 zink: slightly rework memoryTypeIndex selection to pre-determine heap
should be no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22479>
2023-04-16 23:55:30 +00:00
Mike Blumenkrantz
085c9efbf3 zink: move memoryTypeIndex selection down in general bo allocation
no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22479>
2023-04-16 23:55:30 +00:00