Commit graph

346 commits

Author SHA1 Message Date
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
90b94828dd vulkan/meta: Make stencil reference dynamic for clears
We call CmdSetStencilReference() but don't set it to dynamic in the
pipeline.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
e1b12b49e6 vulkan: Allow scissors or viewports to be set without counts
This is unlikely but can happen if you have the following sequence:

 1. vkCmdSetScissors()
 2. No pipeline bind
 3. vkCmdClearImage() which causes a meta save
 4. Meta restore with vk_cmd_set_dynamic_graphics_state()

In that case, we don't have scissor counts but need to restore the
scissors set with `vkCmdSetScissors()` before the meta save.  We can
safely copy all of them, it's just more memory traffic than maybe we'd
like.  Fortunately, this can only happen at the start of a command
buffer and only with a fairly silly sequence of commands.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
8cc9c91f67 vulkan/meta_clear: Populate VkRenderingInfo::renderArea
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
b07e2a1049 vulkan/meta: Add implementations of Clear*Image
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
6a25cba792 vulkan/meta: Implement start-of-rendering clears
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
daa4485ecf vulkan/meta: Implement attachment clears
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
514c10344e vulkan/meta: Add a concept of rect pipelines
Most hardware supports some sort of rectangle primitive.  This adds a
new VK_PRIMITIVE_TOPOLOGY_RECT_LIST_MESA which will be used by the vast
majority of (if not all) meta commands.  Drivers can key off of of this
to build pipelines differently and implement their own cmd_draw_rects
and cmd_draw_volume hooks or they can map it to TRIANGLE_LIST and use
the provided helpers.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
8418d6c97a vulkan/meta: Add an object tracking list
This will let us create objects which get held onto by the command
buffer until it's reset or destroyed.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
54366ea922 vulkan/meta: Add the start of a meta framework
For now, this just adds some basic object caching.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
2023-08-04 21:31:57 +00:00
Faith Ekstrand
9359ff9c2d vulkan: Use VkBufferUsageFlags2 in vk_buffer
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24497>
2023-08-04 16:03:16 +00:00
Samuel Pitoiset
fb8ba9d3b9 vulkan/runtime: add common implementation for GetImageSubresourceLayout()
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24365>
2023-08-04 13:55:11 +00:00
Lionel Landwerlin
3651eb0be8 vulkan/runtime: add a layered implementation of vkCmdBindIndexBuffer
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24365>
2023-08-04 13:55:11 +00:00
Alyssa Rosenzweig
5fead24365 treewide: Drop is_ssa asserts
We only see SSA now.

Via Coccinelle patch:

    @@
    expression x;
    @@

    -assert(x.is_ssa);

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24432>
2023-08-03 22:40:28 +00:00
Faith Ekstrand
f2930ec5dd vulkan: Add init/finish helpers for vk_query_pool
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24409>
2023-08-01 19:17:05 +00:00
Danylo Piliaiev
555a1a3be1 vulkan/nir: Add common helper to check if output is XFB
It was not taken into account that without Offset decoration
the output is not written into XFB.

Aside from eliminating more outputs this change prevents gl_PerVertex
builtins generated by glslang from being kept alive in case when XFB
is enabled. Keeping such outputs alive may upset a driver.

VUID-StandaloneSpirv-Offset-04716:
    "Only variables or block members in the output interface decorated
    with Offset can be captured for transform feedback, and those
    variables or block members must also be decorated with XfbBuffer
    and XfbStride, or inherit XfbBuffer and XfbStride decorations from
    a block containing them"

Additional info about glslang behavior could be found at:
 https://github.com/KhronosGroup/glslang/issues/1526

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24318>
2023-08-01 10:30:59 +02:00
Faith Ekstrand
8de38aded5 vulkan: Add a core vk_sampler struct
Unlike some other core structs, I didn't bother to copy the entire
VkSamplerCreateInfo into the sampler.  There isn't typcially a lot of
pre-processing we can or need to do here and we may as well keep the
struct small for now.  It does, however, handle most things involving
chain-in structs.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24335>
2023-07-31 17:01:42 +00:00
Faith Ekstrand
829b3c0106 vulkan: Add common vkCmdBegin/EndQuery wrappers
These are identical to the IndexedEXT versions with index == 0.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24335>
2023-07-31 17:01:41 +00:00
Faith Ekstrand
f7e5e2cc4f vulkan: Add a vk_query_pool base object
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24335>
2023-07-31 17:01:41 +00:00
Faith Ekstrand
25b1e349c6 vulkan: Add a more direct way to use a NIR shader
This follows the pipeline libraries method of including SPIR-V and lets
you provide the NIR shader without wrapping it in a VkShaderModule.

Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24335>
2023-07-31 17:01:41 +00:00
Faith Ekstrand
b083f44303 vulkan: Add a core vk_buffer_view struct
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24335>
2023-07-31 17:01:41 +00:00
Rebecca Mckeever
87109c3e1b vulkan/runtime: Add helper functions for VK_EXT_host_image_copy
Add helper functions vk_memory_to_image_copy_layout() and
vk_image_to_memory_copy_layout(), which will be useful in
VK_EXT_host_image_copy implementations.

vk_memory_to_image_copy_layout() is similar to
vk_image_buffer_copy_layout(), except the second parameter is
VkMemoryToImageCopyEXT instead of VkBufferImageCopy2.

vk_image_to_memory_copy_layout() is similar to
vk_image_buffer_copy_layout(), except the second parameter is
VkImageToMemoryCopyEXT instead of VkBufferImageCopy2.

Signed-off-by: Rebecca Mckeever <rebecca.mckeever@collabora.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24290>
2023-07-25 23:34:02 +00:00
Alyssa Rosenzweig
31001c6184 vulkan: Add helpers for blend enum translation
Vulkan drivers that use nir_lower_blend need to translate Vulkan enums to the
common (non-Vulkan) versions used in nir_lower_blend. We don't need to duplicate
that boilerplate in every VK driver that uses nir_lower_blend, move panvk's
versions to common code so we can use them in agxv. I suspect powervr wants this
too.

It might be useful to also share the logic to translate vk_color_blend_state
to nir_lower_blend_options wholesale, but panvk wouldn't use it and agxv is
downstream so it wouldn't have any in-tree users. So I'll keep that part
vendored (for now). For now, let's share the easy win of the enum translation.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Italo Nicola <italonicola@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24076>
2023-07-13 21:03:32 +00:00
Daniel Schürmann
2efa5ad0f6 vulkan/pipeline_cache: add 'skip_disk_cache' option
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23909>
2023-07-11 07:36:53 +00:00
Erik Faye-Lund
b0bbd9c0d3 nir: do not needlessly rely on optimizations
We're going to do this rewrite once we get to nir_opt_algebraic anyway,
so let's save a little bit of needless work here.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24004>
2023-07-10 16:06:40 +02:00
Connor Abbott
df7be7323a vk/graphics_state: Don't track each vertex input field
It's unlikely that anyone will call vkCmdSetVertexInputEXT() twice with
the exact same arguments, so this wasn't really doing anything, and it
hurt performance in the common case as shown via "vkoverhead -test 21"
on turnip.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22301>
2023-07-03 19:51:05 +00:00
Connor Abbott
2a8e627e3a vulkan: Fix renderpass flags with driver-specific renderpass
We need to use the driver's renderpass to get the flags if the driver
provides it.

Fixes: f3876db1ee ("vulkan: Plumb rendering flags through vk_graphics_pipeline_state")
Reviewed-by: Faith Ekstrand <faith.ekstrand@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22301>
2023-07-03 19:51:05 +00:00
Connor Abbott
ea52d0d9e0 vk/graphics_state: Track attachment count as state
Even if this isn't dynamic state per-se because it always comes from the
pipeline, it's useful to be able to track it for the various dynamic
states that it affects, which may be either precompiled or not on
turnip.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22301>
2023-07-03 19:51:05 +00:00
Connor Abbott
f497cc9d56 vk/graphics_state: Add helpers for pre-baking state
Previously, drivers have either not supported some dynamic state (like
vertex input or sample locations) at all or it's been always dynamic. In
order to be able to set dynamic state sometimes and other times leave it
up to driver-specific state packets, we need a few helpers.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22301>
2023-07-03 19:51:05 +00:00
Connor Abbott
5405c9ed50 vk/graphics_state: Fix some assertions when copying state
On turnip we support dynamic vertex input, but static vertex input is
precompiled and so we will copy from a source without VI to a
destination with VI and it's valid in this case to do nothing. On the
other hand, it should never be valid if VI state is set but the pointer
isn't there, which the code previously silently skipped over. There's a
similar issue with sample locations.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22301>
2023-07-03 19:51:05 +00:00
Connor Abbott
7da44ef671 vk/graphics_state: Add VI_BINDINGS_VALID state
This is a mirror of vi::bindings_valid, but we can track it and set it
properly even when vertex input state is precompiled, because it is also
needed on turnip for knowing the size of the vertex buffer and vertex
stride state packets even when vertex input state is precompiled.
Previously drivers that could pre-bake vertex input state were expected
to handle this themselves, but this would've been complicated for turnip
because we can handle both pre-baked and dynamic vertex input state. Now
we have the one field which is correctly set in all circumstances and we
never have to setup space for vertex input state in the pipeline.

Reviewed-by: Faith Ekstrand <faith.ekstrand@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22301>
2023-07-03 19:51:05 +00:00
Connor Abbott
ea4257be32 vk/graphics_state: Add feedback_loop_input_only
On turnip, there are two cases for feedback loops:

- For feedback loops that involve input attachments, everything works as
  normal in GMEM mode but have to do a workaround in sysmem.
- For feedback loops that may involve any texture, GMEM mode is
  impossible and we have to disable it.

Currently we track this through a special flag on the pipeline, but this
won't be practical in the future. Add a flag to the common renderpass
state struct to patch this info through when using our own renderpass.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22301>
2023-07-03 19:51:05 +00:00
Connor Abbott
1d5eeefd9b vk/graphics_state: Remove vk_subpass_info
It only has a subset of the renderpass state, whereas with turnip we
need to use pretty much all of it at one point or another. Just allow
the driver to pass in the entire vk_render_pass_state if it's using its
own renderpass implementation.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22301>
2023-07-03 19:51:05 +00:00
Tatsuyuki Ishi
a9c6f7ffdf vulkan/pipeline_cache: Introduce weak reference mode.
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23877>
2023-07-03 13:53:05 +00:00
Tatsuyuki Ishi
47c9fba322 vulkan/pipeline_cache: Move cache_object_unref out of header.
For future use where private functions are called from unref code.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23877>
2023-07-03 13:53:05 +00:00
Tatsuyuki Ishi
44bfeb77d9 vulkan/pipeline_cache: Move locking outside of remove_object.
To match a future use case better.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23877>
2023-07-03 13:53:04 +00:00
Tatsuyuki Ishi
64c959e46c vulkan/pipeline_cache: Do not consume object passed into remove_object.
Future use case will require removing an object with zero ref count, so
leave it up to the caller to call unref.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23877>
2023-07-03 13:53:04 +00:00
Erik Faye-Lund
c69dc01796 vulkan: avoid needless constant-folding
While we're at it, also switch to the nir_f{add,mul}_imm helpers.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23855>
2023-06-29 07:08:18 +00:00
Konstantin Seurer
b0beca8c7a vulkan/rmv,radv: Use common trace trigger
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20573>
2023-06-27 06:25:56 +00:00
Konstantin Seurer
291fa05545 vulkan/wsi/x11: Capture traces using a hotkey
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20573>
2023-06-27 06:25:56 +00:00
Konstantin Seurer
70489edce4 vulkan: Common trace capturing infrastructure
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20573>
2023-06-27 06:25:56 +00:00
Hyunjun Ko
e2f95ad296 vulkan/video: keep delta weight and offsets of predicted weight tables in h265 slice parsing
Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23790>
2023-06-26 15:07:53 +09:00
Tatsuyuki Ishi
b69a1b4153 vulkan: Migrate shader module hash to BLAKE3.
Shaders are the largest thing we hash now, so they benefit from a faster
hash.

Change the field name from `sha1` to `hash` to avoid tying the definition
to a particular algorithm. This doubles down as a precaution against
callers still assuming a 20-byte hash (in which case the compilation will
error out).

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22571>
2023-06-23 09:28:04 +00:00
Michel Zou
badb85edb8 util: reinstate ENUM_PACKED
gets rid of warning: 'gcc_struct' attribute ignored [-Wattributes] introduced by !23338

Fixes: 86532fa21d ("util: Use the gcc_struct attribute for packed structures in mingw")
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23478>
2023-06-21 21:51:59 +00:00
Hyunjun Ko
240b419c03 vulkan/video: consider removed bits when calculating the size of comsumed data.
Closes: mesa/mesa#9170

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23688>
2023-06-21 19:24:49 +09:00
Hyunjun Ko
6f2e260d2b vulkan/video: move parsing longterm rps in h265 slice parsing.
It was just by mistake.

Fixes: efdcacb230 ("vulkan/video: add to parse h265 slice.")

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23688>
2023-06-21 19:24:08 +09:00
Hyunjun Ko
b10631865d vulkan/video: adds more conditions for setting loop_filter_across_slices_enable in h265 slice parsing.
Fixes: efdcacb230 ("vulkan/video: add to parse h265 slice.")

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23688>
2023-06-21 19:20:59 +09:00
Caio Oliveira
59a72570b6 compiler: Move spirv into a module of its own
For historical reasons, nir and vtn were compiled together,
and a bunch of vtn specific targets were defined in
src/compiler/meson.build.

Now that we can, make src/compiler/spirv produce an internal
library that depends on NIR, and is used by the drivers/tools.
Also move the vtn specific targets into that directory's
meson.build.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23668>
2023-06-20 16:18:08 +00:00
Samuel Pitoiset
0432a748ee vulkan/runtime: call CmdSetDepthBias2EXT() from CmdSetDepthBias()
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23696>
2023-06-20 12:46:28 +00:00
Lionel Landwerlin
f39fa39809 vulkan/runtime: add support for EXT_depth_bias_control
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23716>
2023-06-20 03:05:01 +00:00