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
Mike Blumenkrantz
dc91f2c71b
zink: set PIPE_CAP_SURFACE_REINTERPRET_BLOCKS
...
this fixes perf for CompressedTexSubImage and makes DOOM2016 run at full speed
ref #8223
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21218 >
2023-02-09 09:54:27 -05:00
Mike Blumenkrantz
36595e94c7
zink: avoid the descriptor set multiplier for bindless buffers
...
the bindless descriptor buffer is already correctly sized, so it needs
to avoid the huge set multiplier or it'll explode all available vram
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21216 >
2023-02-09 08:08:22 -05:00
Mike Blumenkrantz
03c2bdda60
zink: use VK_EXT_multisampled_render_to_single_sampled for EXT_multisample_render_to_texture
...
this extension was added for the purpose of emulating the GL ext,
and using it is reasonably straightforward
the only (somewhat) invasive part is modifying the renderpass/dynamic hashes
to have samplecounts in the key, but this is also not too much work
now only fbfetch requires real renderpasses, and everything else is dynamic
fixes #7559
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20883 >
2023-02-01 10:08:57 +00:00
Mike Blumenkrantz
d745e3b0ab
zink: always unref old images when adding new binds
...
at some point this was correct, but refactoring has since occurred,
and this ends up leaking storage image objects
cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20867 >
2023-01-31 16:31:46 +00:00
Mike Blumenkrantz
01d2e7afce
zink: don't add dmabuf export type if dmabuf isn't supported
...
avoid trying to create dmabuf-exportable resources too
cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20791 >
2023-01-31 15:57:13 +00:00
Mike Blumenkrantz
3c562cfc06
zink: set vkusage/vkflags for buffer resource objects
...
this needs to be populated for other places in the driver that need it
cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20912 >
2023-01-27 19:23:29 +00:00
Mike Blumenkrantz
c545300f30
zink: add VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT for buffers if ext is enabled
...
cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20912 >
2023-01-27 19:23:29 +00:00
Mike Blumenkrantz
07809c4527
Revert "zink: allow direct memory mapping for any COHERENT+CACHED buffer"
...
This reverts commit a3552048c7 .
on some drivers this catches qbos, which then hits the below assert.
needs more investigation
Fixes: a3552048c7 ("zink: allow direct memory mapping for any COHERENT+CACHED buffer")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20912 >
2023-01-27 19:23:28 +00:00
Mike Blumenkrantz
87a9018ff9
zink: reorder commands more aggressively
...
by starting resources in the unordered state in a given batch, they
gain more opportunities to be promoted to the barrier cmdbuf and avoid
breaking renderpasses
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20890 >
2023-01-27 02:42:56 +00:00