dzn: Re-design custom buffer descriptors
authorJesse Natalie <jenatali@microsoft.com>
Fri, 21 Apr 2023 18:48:16 +0000 (11:48 -0700)
committerMarge Bot <emma+marge@anholt.net>
Tue, 25 Apr 2023 15:36:01 +0000 (15:36 +0000)
commitd34ac0a70b705963b7d4f09aedebdfc66e8a2956
treedf0714a024c198dd18d46d81bb676e5146835477
parenta12a15a9ea3835812420b64e4599be6d155fa3e4
dzn: Re-design custom buffer descriptors

Previously, custom buffer descriptors were owned by a descriptor set. Now,
custom buffer descriptors are owned by the buffer. Additionally, we respect
the app-provided sizes when they're smaller than the buffer size, even if
robustness is not enabled, so that size queries work correctly.

This new design fixes several issues:
* Descriptor set copies were broken when they involved custom descriptors,
  because the original descriptor set owned the lifetime of the custom
  descriptor, the new one was just borrowing it. If those lifetimes didn't
  line up, problems would arise.
* A single buffer with the same sub-view placed in multiplel descriptor sets
  would allocate multiple slots, when it only really needed one.
* Custom buffer descriptors now lower the base offset to 0 to allow merging
  multiple overlapping (ending at the same upper bound) descriptors. Since
  the shader is already doing an offset add, making it nonzero is free.
* Dynamic buffer descriptors were incorrect before. The size passed into the
  descriptor set is supposed to be the size from the *dynamic* offset, not the
  size from the static offset. By allocating/populating the descriptor when
  placed into the set, it prevented larger offsets from working correctly. This
  buffer-owned design prevents cmdbufs from having to own lifetime of custom
  descriptors.

Fixes dEQP-VK.ssbo.unsized_array_length.float_offset_explicit_size

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22639>
src/microsoft/vulkan/dzn_cmd_buffer.c
src/microsoft/vulkan/dzn_descriptor_set.c
src/microsoft/vulkan/dzn_device.c
src/microsoft/vulkan/dzn_private.h