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
xurui
f66e6b671c
zink: Some return values of malloc should be checked
...
Signed-off-by: xurui <xurui@kylinos.cn>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22328 >
2023-04-13 13:40:22 +00:00
Mike Blumenkrantz
7704773619
zink: handle swapchain handoffs around makecurrent
...
when a new resource is created for an extant swapchain, the existing
acquire (if any) should be transferred to the resource to ensure
expected behavior
this should be enough to fix piglit's glx-make-current
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22431 >
2023-04-12 21:43:35 +00:00
Mike Blumenkrantz
ca43ecefa4
zink: handle swapchain creation failure less lazily
...
this is a real scenario
cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22027 >
2023-03-21 01:39:39 +00:00
Mike Blumenkrantz
d862d708e2
zink: use res->queue to auto-handle queue transitions back to gfx queue
...
much simpler
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21733 >
2023-03-17 07:25:04 +00:00
Mike Blumenkrantz
d7b04c110b
zink: remove redundant dmabuf_acquire setting
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21733 >
2023-03-17 07:25:04 +00:00
Mike Blumenkrantz
2fd2133c9d
zink: track current queue for resources
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21733 >
2023-03-17 07:25:04 +00:00
Mike Blumenkrantz
81a4163375
zink: fix copy box merging adjacency
...
these cases need to increase the box size, not just adjust the offset
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21921 >
2023-03-15 16:42:19 +00:00
Mike Blumenkrantz
32f74c4db5
zink: fix copy box iteration when adding
...
need to use the iterator, not the base pointer
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21921 >
2023-03-15 16:42:19 +00:00
Mike Blumenkrantz
2409ddb5db
zink: fix copy box iteration
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21907 >
2023-03-14 21:25:55 +00:00
Mike Blumenkrantz
fe6f0692ed
zink: rework zink_resource::valid_buffer_range
...
this is now the valid buffer region for the "main" command buffer,
and all transfer ops store their regions in the copy boxes
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21802 >
2023-03-14 16:23:06 +00:00
Mike Blumenkrantz
46f98da188
zink: add a mechanism to trigger copy box resets from batch state reset
...
the resource isn't available during batch state reset, so a new flag
is needed to force a reset the next time the copy boxes would be used
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21779 >
2023-03-08 03:50:33 +00:00
Mike Blumenkrantz
aaca91eb79
zink: add a mechanism for managing TRANSFER_DST buffer barriers
...
this enables successive or unrelated transfer writes to avoid triggering
barriers, and ensuing reads of those writes should trigger their own
barriers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21779 >
2023-03-08 03:50:33 +00:00
Mike Blumenkrantz
54f3c589d5
zink: track the last write access for resources
...
this enables some optimization
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21779 >
2023-03-08 03:50:33 +00:00
Mike Blumenkrantz
1aa62912b7
zink: don't unset existing access when adding resource binds
...
this breaks barrier calcs, but it was fine since there was a pre-barrier
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21739 >
2023-03-07 01:57:41 +00:00
Mike Blumenkrantz
a0f3d171f6
zink: eliminate pre barrier for adding resource binds
...
this will automatically be handled by the copies below
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21739 >
2023-03-07 01:57:41 +00:00
Mike Blumenkrantz
0d8a54f913
zink: avoid ballooning of copy box tracking
...
* if the proposed box is smaller than an existing box then don't add it,
* if the proposed box is adjacent to an existing box, expand
* if the proposed box is larger than an existing box, replace
this reduces the chances of having a ton of copy boxes to iterate over
also add a perf warning in case a ton of copy boxes exist
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21665 >
2023-03-06 03:47:06 +00:00
Mike Blumenkrantz
52f27cda05
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
unlike the previous attempt at this optimization, this utilizes the screen-based
context for thread-safe transfers, which should avoid races/crashes
fix #8171
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21452 >
2023-02-27 03:50:14 +00:00
Mike Blumenkrantz
d78de2a962
zink: add locking for zink_screen::copy_context and defer creation
...
the copy context isn't always used, so this allows its creation to
be deferred and potentially save a bunch of memory
also add locking for multi-context thread safety
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21452 >
2023-02-27 03:50:14 +00:00
Mike Blumenkrantz
fa6e6545b1
zink: add some tracking for copy box regions
...
this enables tracking per-miplevel pipe_boxes for copy operations that
can then be used to avoid emitting barriers for successive copy operations
without overlapping regions
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21397 >
2023-02-24 05:27:31 +00:00
Erik Faye-Lund
176add76ad
zink: get rid of needless dependency
...
We haven't needed this header since 7f56fd9655 ("zink: it's kopperin'
time"), so let's get rid of it and the dependency that comes with it.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21441 >
2023-02-22 12:23:39 +00:00
SoroushIMG
96849363eb
zink: free resource objects' views array during destruction
...
since the array is not ralloc managed, it has be explicitly freed.
cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21285 >
2023-02-13 19:00:06 +00:00
Mike Blumenkrantz
4cda98c827
zink: implement a scaling descriptor buffer size
...
previously descriptor buffers were sized to allow for 25,000 descriptors
this is a great number.
but in some scenarios it's overkill, and it's theoretically possible that
it might be underkill in others (citation needed), so add some handling
for both cases to save small amounts of vram on average and not crash
in the distant future when hypercomputers try running drawoverhead
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21246 >
2023-02-13 10:27:16 +00:00
Mike Blumenkrantz
cd446b87e1
zink: add newlines to some debug printfs
...
cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21239 >
2023-02-10 19:42:53 +00:00