Commit graph

490 commits

Author SHA1 Message Date
Mike Blumenkrantz
052f85ea1b zink: flag color attachment images as input attachments at creation
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12603>
2021-08-31 19:45:29 +00:00
Mike Blumenkrantz
849033e6d8 zink: implement PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY when resizable bar not present
this helps in some cases to avoid allocating and mapping large staging resources

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12579>
2021-08-30 13:46:04 +00:00
Erik Faye-Lund
e3239dff05 zink: avoid overflow when calculating size
If we multiply before we (implicitly) cast the result to the target
type, we needlessly risk overflowing the result.

CID: 1490790, 1475922

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12559>
2021-08-27 18:32:03 +00:00
Erik Faye-Lund
c96afa9fc8 zink: initialize pQueueFamilyIndices
This silences a Coverity warning about an uninitialized variable.

CID: 1490800

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12559>
2021-08-27 18:32:03 +00:00
Mike Blumenkrantz
bdbcf256a1 zink: return early when getting resource modifer if no modifier is used
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12534>
2021-08-25 21:14:11 +00:00
Mike Blumenkrantz
403acd299f zink: handle map failures more effectively
the transfer object needs to be destroyed

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12422>
2021-08-17 17:00:32 -04:00
Mike Blumenkrantz
afa867b973 zink: break out transfer map destroy
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12422>
2021-08-17 17:00:32 -04:00
Mike Blumenkrantz
97545a0a1f zink: remove unused variable from image map
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12422>
2021-08-17 17:00:32 -04:00
Mike Blumenkrantz
c5a6ebc605 zink: split buffer and image map functions
this is a bit nicer to read

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12422>
2021-08-17 17:00:32 -04:00
Mike Blumenkrantz
b19bff17f4 zink: split out zink_transfer allocation
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12422>
2021-08-17 17:00:32 -04:00
Mike Blumenkrantz
9e6916fb00 zink: remove duplicated zink_resource_object::mem member
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12421>
2021-08-17 20:43:18 +00:00
Mike Blumenkrantz
67239cf754 zink: collapse 'dedicated' allocation into zink_bo
this simplifies all the map and memory management code

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12421>
2021-08-17 20:43:18 +00:00
Mike Blumenkrantz
97d04c2bc5 zink: rejigger PIPE_MAP_ONCE for internal qbo reads
DONTBLOCK is only used internally for this case, and promoting it over
the staging buffer case ensures that it's always reached when it should be

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12410>
2021-08-17 19:40:27 +00:00
Mike Blumenkrantz
7d39ef49bd zink: remove PIPE_MAP_ONCE from subdata
subdata calls that happen once for a buffer are likely to happen again,
so just leave them mapped

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12410>
2021-08-17 19:40:27 +00:00
Mike Blumenkrantz
daff597940 zink: make map_count useful for dedicated image allocations
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12410>
2021-08-17 19:40:27 +00:00
Mike Blumenkrantz
89e2591e8d zink: split mem unmap logic for images and buffers
buffers should only be unmapped if they're explicitly marked for unmap,
but images should only be unmapped when running in 32bit, in which case
they need to always be unmapped

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12410>
2021-08-17 19:40:27 +00:00
Mike Blumenkrantz
6001ebc1b6 zink: split transfer_unmap for images and buffers
these should be separate

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12410>
2021-08-17 19:40:27 +00:00
Mike Blumenkrantz
5fedce7bfb zink: stop zeroing structs during resource allocation
some of these show up in profiling

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12410>
2021-08-17 19:40:27 +00:00
Mike Blumenkrantz
40fdb3212c zink: add a suballocator
this is an aux/pipebuffer implementation borrowing heavily from the
one in radeonsi. it currently has the following limitations, which
will be resolved in a followup series:
* 32bit address space still explodes
* swapchain images still have separate memory handling

performance in games like Tomb Raider has been observed to increase by
over 1000%

SQUASHED: simplify get_memory_type_index()

now that the heaps are enumerated, this can be reduced to a simple
array index with a fallback

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12146>
2021-08-17 13:21:28 +00:00
Mike Blumenkrantz
461662bf3c zink: simplify some dumb code in invalidate_buffer (v2)
the ref has to be preserved so that rebind doesn't destroy it prematurely

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12118>
2021-07-28 23:56:06 +00:00
Mike Blumenkrantz
2668489cf9 Revert "zink: simplify some dumb code in invalidate_buffer"
This reverts commit 6bda555cc0.

this needs to stay dumb in order to preserve the ref on the resource
without destroying it during rebind

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12118>
2021-07-28 23:56:06 +00:00
Mike Blumenkrantz
5ff0f4a901 zink: never use staging buffer for unsynchronized buffer maps
this is ultra broken, do not attempt

Fixes: 6bfbce0447 ("zink: rework buffer mapping")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12111>
2021-07-28 21:15:26 +00:00
Mike Blumenkrantz
6bfbce0447 zink: rework buffer mapping
this collects a bunch of changes which need to be made but which can't
be split up incrementally without breaking things:
* move map offset to zink_transfer::offset for consistent handling
* fix stream uploader map rules to only apply for discard cases so
  the stream uploader doesn't explode
* fix the staging buffer map rules to apply to any non-staging readback
* stop making huge staging buffers for readback
* break out the DONTBLOCK case since this is only coming from qbo readback
* add explicit read-only sync for maps to stall on writes

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12090>
2021-07-28 00:42:56 +00:00
Mike Blumenkrantz
7665e656c1 zink: remove no longer used internal resource function
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12008>
2021-07-26 19:52:49 -04:00
Mike Blumenkrantz
3137795e38 zink: replace some direct batch_usage calls with resource abstractions
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12008>
2021-07-26 19:52:47 -04:00
Mike Blumenkrantz
6bda555cc0 zink: simplify some dumb code in invalidate_buffer
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12008>
2021-07-26 19:51:53 -04:00
Mike Blumenkrantz
79ccc17da5 zink: use resource batch usage helpers in invalidate_buffer()
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12008>
2021-07-26 19:48:07 -04:00
Mike Blumenkrantz
13d732ec5b zink: add some resource util functions for batch usage
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12008>
2021-07-26 19:48:07 -04:00
Mike Blumenkrantz
2736bf4e17 zink: split mem cache per type
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11966>
2021-07-22 00:32:50 +00:00
Mike Blumenkrantz
7aca74e219 zink: inline mem cache hash table
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11966>
2021-07-22 00:32:50 +00:00
Mike Blumenkrantz
fdfa155f2b zink: move mem cache to sub-struct
no functional changes

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11966>
2021-07-22 00:32:50 +00:00
Mike Blumenkrantz
ba3c4ce385 zink: add mechanism for generating VkBuffers for rebinding
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11836>
2021-07-22 00:04:58 +00:00
Michel Zou
4c36224f95 zink: Fix unused-variable warning
Fixes: 9b40fc48
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11920>
2021-07-20 18:44:39 +00:00
Bas Nieuwenhuizen
785b4728cf zink: set dedicated allocation when needed
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11958>
2021-07-19 23:34:21 +00:00
Mike Blumenkrantz
e9516a4edd zink: check for dedicated allocation requirements during image alloc
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11958>
2021-07-19 23:34:21 +00:00
Mike Blumenkrantz
d29c086fb9 zink: simplify modifier ifdefs
these are the only two defines referenced, so they can be defined to 0
for platforms that don't support modifiers in order to remove a ton of
ifdefs and make the code more readable

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11847>
2021-07-13 14:59:18 +00:00
Mike Blumenkrantz
b88055f379 zink: add a pipe_screen::resource_create_with_modifiers hook
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:52 +00:00
Mike Blumenkrantz
452ffddbff zink: add fallback for linear modifier use
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:52 +00:00
Mike Blumenkrantz
02593a05e2 zink: don't pass modifier count to first image create
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:52 +00:00
Mike Blumenkrantz
943ab741e2 zink: explicitly disallow using the modifier image create for non-linear images
the first call is just for the base image, the second call is the one that needs
modifiers

Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:52 +00:00
Mike Blumenkrantz
b6990f7359 zink: use VkImageDrmFormatModifierListCreateInfoEXT for creating from modifier array
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:52 +00:00
Mike Blumenkrantz
9b40fc4892 zink: add a pipe_screen::resource_get_param hook
this is used for querying image properties

Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:52 +00:00
Mike Blumenkrantz
6e927d1152 zink: store modifier aspect to resource
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:52 +00:00
Mike Blumenkrantz
f1f13a110a zink: start storing modifiers to the base resource struct
need these for rebinds

Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:51 +00:00
Erik Faye-Lund
8eb91e372b zink: implement support for non-planar DRM modifiers
Planar DRM modifiers are a bit more tricky, so let's kick that ball down
the road. For now, this should help a bit.

Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:51 +00:00
Mike Blumenkrantz
c6d677ce3d zink: ensure sparse allocations aren't marked host-visible
Fixes: 5fee58bf59 ("zink: collapse host_visible and non-coherent alignment alloc cases")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11768>
2021-07-08 13:26:41 +00:00
Mike Blumenkrantz
c4c279bd7a zink: remove unnecessary stall during device-local map case
this stalls after the copy already, no need to also stall before it

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11749>
2021-07-07 01:55:45 +00:00
Mike Blumenkrantz
b9ada09ca3 zink: move resource object ref to batch in init_storage_object
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11692>
2021-07-07 00:22:09 +00:00
Mike Blumenkrantz
08b3847215 zink: move resource object ref to batch in invalidate hook
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11692>
2021-07-07 00:22:09 +00:00
Mike Blumenkrantz
347163aec2 zink: stop screwing up buffer offsets during for maps
stop using the memory bind offset

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11687>
2021-07-02 03:29:04 +00:00