Commit graph

175544 commits

Author SHA1 Message Date
Faith Ekstrand
7cdb86a843 nvk: Split nvk_queue into its own file
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Thomas H.P. Andersen
adb71cace7 nvk: fix mem leaks
device would leak in various situations.
Separate out lables were needed in the earlier
versions of this function but now we can just
use a single label

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Thomas H.P. Andersen
c9f0ec90fc nvk: delete commented code
nvk_CmdClearColorImage first lived in nvk_cmd_copy,
then moved to nvk_cmd_meta, and finally in nvk_cmd_clear

I seems that this was left behind in one of the moves

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Thomas H.P. Andersen
c086d60466 nvk: fix implicit-fallthrough warnings with clang
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Thomas H.P. Andersen
6bfecf8448 nvk: use common physical device enumeration
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Karol Herbst
3f16c30516 nvk: fix OOB read inside nvk_get_va_format
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
6ba98ca4a1 nvk: Update to the new command buffer infrastructure
We leave nvk_command_pool because we'll want to use it for recycling
individual pushbufs.  Drop reset_on_submit becuse there was never really
that much point in that micro-optimization and it isn't thread-safe
anyway if we recycle things in the pool.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Karol Herbst
fa8be32aec nouveau/ws: push chaining
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Karol Herbst
3d5b9d8b78 nouveau/ws: rework refing push buffer bos
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Karol Herbst
c791fae67b nouveau/ws: bound check nouveau_ws_push_append
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
6f702f9939 nvk: Add some asserts for nv50 compiler image restrictions
These just ensure that we assert instead of doing something that the
nv50 compiler is likely to screw up.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
c36ee41fdb nvk: Zero unused descriptors
When a descriptor gets freed because a buffer/image veiw or sampler is
deleted, zero out the descriptor memory.  This prevents the descriptor
from being used later and faulting on possibly non-existant memory.

While we're here, clean up the function a bit.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
67a45d1c5f nvk: Implement descriptor table growing
Now that command buffers are no longer referencing descriptor table BOs
directly and we're not handing out maps, we can support growing.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
cad1834ba4 nvk: Rework nvk_descriptor_table_add/remove
The new api returns a VkResult for more accurate error checking.  More
importantly, it also does copies the descriptor data into the table
instead of returning a map.  This means the users of the descriptor
table will never see a map and we can make sure that the copy happens
under the lock in case we have to grow.  Since each descriptor is only
32 bytes, this isn't going to be a perf problem.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
9e549ce08b nvk/sampler: Free descriptor table entries
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
b13faff71c nvk: Invalidate texture header and sampler caches each submit
It's possible descriptors have been added or removed.  We could track
it, but there's really no point.  Per-submit shouldn't be terrible.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
6935fe5c68 nvk: Rework TLS/SLM and image/sampler table handling
When Dave originally added SLM, he did so with a preamble pushbuf which
sets up the SLM area prior to executing any actual command buffers.
This has the advantage that the SLM BO is never directly referenced in
any command buffer and we can swap it out even after command buffers
have been built.  When I added image/sampler tables, I sort-of went
along with it but then did something different for 3D.

Thanks to buffer reference counting, we can employ a fairly simple
locking scheme.  Each of the globals: images, samplers, and TSL has a
lock which gets taken whenever the table is modified.  When we go to do
a submit, we take each lock and take a queue-local reference to the BO
and grab a copy of its size parameter under the lock.  If anything has
changed, we update the queue-local preamble pushbuf.  Because the queue
also holds a reference, we can safely proceed to submit command buffers
which reference those global BOs without the individual global locks
taken.  If SLM or one of the descriptor tables resizes while we're
mid-submit, our reference to the BO will remain valid until either the
destruction of the queue or the next submit.

The one small bit of threaded cleverness (one always has to be careful
with that) is that the SLM size can be checked without taking the lock
because the SLM size only ever increases.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
e8183da71f nvk: Drop most buffer tracking
If it's backed by an nvk_device_memory, we don't need to track it since
we always add all of those to every submit so that bindless works.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
a43e3fc80b nvk/dispatch: Rename push to p
I took to using this convention in nvk_cmd_draw.c because it's shorter.
Let's use it other places too.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
26fc226a7e nvk/blit: Rename push to p
I took to using this convention in nvk_cmd_draw.c because it's shorter.
Let's use it other places too.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
23260c3619 nvk/copy: Rename push to p
I took to using this convention in nvk_cmd_draw.c because it's shorter.
Let's use it other places too.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
39b64aed3f nvk: Inline nouveau_copy_linear
It has exactly one caller so the helper's not really doing us much.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Karol Herbst
71c830278f nvk: clean up bo mappings
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Karol Herbst
05bc4500ad nouveau/ws: add a bo unmap helper function
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Karol Herbst
886db84e94 nouveau/ws: add API to query if the context was killed
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
e1af0f983f nvk: Fix dynamic buffer descriptor copies
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
c88cf7828d nvk: Set up clip and cull distances
Closes: https://gitlab.freedesktop.org/nouveau/mesa/-/issues/12
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
7696f8c8d2 nil: Fix nonnormalized coordinates
Also, replace our TODO with a real comment explaining how nonnormalized
coordinate select works between image and texture header.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
d407e2b130 nil: Fix max mip level
The MAX_MIP_LEVEL field needs the actual number from the image because
it's used to compute the stride between layers.  The restrictions on mip
level come entirely from the RES_VIEW fields.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
89591214a3 nil/format: Depth/stencil formats appear as red
Previously, it was treated as luminance and the depth or stencil
component was broadcast to all channels except alpha.  In Vulkan, depth
and stencil textures are treated as red.  If we want it treated
differntly by some other API, that driver can do that with a swizzle.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
fe84f07fce nvk: Fix border color alpha
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
d3f4a23f7b nvk: VkSamplerCreateInfo::mipLodBias is signed
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
b5cdb13b55 nvk: Assert on CmdExecuteCommands
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
bd4988b9c0 nvk: Fix max anisotropy
Now that we're using the bitpack helpers, we don't need the extra shift

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
2a2076b0d2 nvk: Don't advertise tiling on non-power-of-two formats
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
60f41aca47 nvk: Use a UINT format to clear non-renderable images
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
177c968cd1 nvk: Implement vkCmdClear*Image directly
Instead of invoking the meta code, implement it ourselves so we get the
HW clear path.  We could probably put these implementations somewhere
common since they only set up a few things and invoke Begin/EndRendering
but there's not that much point for now.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
f1aa12d596 nvk: Add image_view_init/finish functions
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
7b7bfbcc61 nvk: Use hardware clears for attachment clears
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
10d16dce1c nouveau/parser: Add array and float tags for clear values
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Mauro Rossi
4d02d9d796 vulkan/meta: fix gnu-empty-initializer build error
Fixes the following building error:

../src/vulkan/runtime/vk_meta_clear.c:213:42: error: use of GNU empty initializer extension [-Werror,-Wgnu-empty-initializer]
   struct vk_meta_clear_push_data push = { };
                                         ^
1 error generated.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
b877922b07 nvk: Save/restore push constants around meta ops
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
a1652525e2 nvk: Wire up early z and post depth coverage
Was crawling through header bits and found that we weren't plumbing
these through.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Dave Airlie
b5beae5777 nvk: add basic primitive restart
fixes crucible
func.draw-index16-restart
func.draw-index32-restart

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Yusuf Khan
8e052c311f nvk: support GetImageSparseMemoryRequirements2
KHR_get_memory_requirements2 was enabled but GetImageMemoryRequirem
ents2 was not. This stubs out GetImageMemoryRequirements2 to fix it.

Signed-off-by: Yusuf Khan <yusisamerican@gmail.com>

v2: remove the v1 version of the command as its provided by the
common runtime

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Yusuf Khan
8271228289 nvk: implement GetDeviceMemoryCommitment
vulkan spec says:

If the memory object is allocated from a heap with the
VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT bit set, that object’s
backing memory may be provided by the implementation lazily. The
actual committed size of the memory may initially be as small as
zero (or as large as the requested size), and monotonically
increases as additional memory is needed.

As far as I can tell we ignore the bit meaning that we allocate the
requested size so return that as the size.

Signed-off-by: Yusuf Khan <yusisamerican@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
f3d43c2a86 nvk: Allocate descriptors for input attachments
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
d2b30362eb nvk: Assert samples == 1
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
e3afa1e3c2 nvk: Re-flow a couple function prototypes
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00
Faith Ekstrand
0252b000de nvk: Align descriptor buffers to NVK_MIN_UBO_ALIGNMENT
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:58 +00:00