Commit graph

97 commits

Author SHA1 Message Date
Matthew Waters
d20d94cc48 vkformat: also use the correct srgb vs unorm when using older
gst_video_info_from_video_info()

Fixes sRGB colorspace chosen by GstVulkanSwapper and therefore used for
display.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5316>
2023-10-27 09:13:18 +00:00
Víctor Manuel Jáquez Leal
a2f875251f vkimagebufferpool: use GstVulkanOperation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5079>
2023-10-26 07:26:23 +00:00
Víctor Manuel Jáquez Leal
265f1274dc vkoperation: synchronization helper object
An operation is an arbitrary amount of work to be executed on the host, a
device, or an external entity such as a presentation engine.

The purpose of this object is to help on the operation's synchronization
through declaring explicit execution dependencies, and memory dependencies
between two sets of operations defined by the command’s two synchronization
scopes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5079>
2023-10-26 07:26:22 +00:00
Víctor Manuel Jáquez Leal
c83c508c5e vulkan: add a timeline semaphore per image
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5079>
2023-10-26 07:26:22 +00:00
Víctor Manuel Jáquez Leal
964aec54b4 vkbarrier: Use guint64 for VkFlags and VkFlags2
While VkPipelineStageFlags is an enum (arguably backed as uint32 in 32bit
platforms), VkPipelineStageFlags2 is a redefinition of guint64; likewise for
VkAccessFlags and VkAccessFlags2.

This patch types both members in GstVulkanBarrierMemoryInfo as guint64 for
compatibility, so it could be used with or without synchronization2 vulkan
extension.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5079>
2023-10-26 07:26:22 +00:00
Víctor Manuel Jáquez Leal
8809ce5648 vkmemory: unref queue in barriers
Queue might be assigned for queue transfers, so we need to unref it if the
memory has been assigned to a specific queue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5079>
2023-10-26 07:26:22 +00:00
Víctor Manuel Jáquez Leal
5acd6c23b8 vkdevice: use macro VK_KHR_synchronization2 as guard
Instead of (defined(VK_VERSION_1_3) || (defined(VK_VERSION_1_2) && VK_HEADER_VERSION >= 170))

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5079>
2023-10-26 07:26:22 +00:00
Matthew Waters
48ab457d79 vulkan/physical-device: don't assume that queue_family_ops is filled
On old enough vulkan (< 1.2), we will never retrieve the family operations and
will perform a NULL pointer dereference when dumping the queue family op
properties.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5547>
2023-10-25 16:38:06 +11:00
Jordan Petridis
9f3b8c9366 vkwindow_xcb: Make the visible private field a guint
This field is used to store gbooleans (which are ints) but if it's
a :1 bit depth assigning ints to it changes it's value as the only
valid values are -1 and 0.

Make it a guint instead so the cast would be correct.

```
../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/xcb/gstvkwindow_xcb.c:151:25: error:
implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1
[-Werror,-Wsingle-bit-bitfield-constant-conversion]
    window_xcb->visible = TRUE;
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5432>
2023-10-23 10:43:52 +05:30
Víctor Manuel Jáquez Leal
b7ded81f7b vkbufferimagepool: short circuit usage for decoding
NVIDIA & RADV drivers don't report decoding features for color format. Setting
requested usage to zero to short circuit validation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5288>
2023-09-08 18:11:55 +02:00
Matthew Waters
9d79852890 vkformat: assume that unknown rgb transfer is sRGB
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5288>
2023-09-08 16:09:33 +00:00
Matthew Waters
b82a402bf1 vkformat: also check configured usage flags
This does also mean that if the primary format fails this check, we need
to try the secondary format before returning an error

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2957
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5288>
2023-09-08 16:09:33 +00:00
Matthew Waters
4d3b03e8e8 vkformat: invert srgb and multiplane && planes > 1 checks
The primary format for RGB includes sRGB transfer but was not actually
being used.

The !(no_multiplane && planes > 1) check for YUV resulted in those
formats never being used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5288>
2023-09-08 16:09:33 +00:00
Matthew Waters
8a9d630e3b vkformat: FORMAT_FEATURE_COLOR_ATTACHMENT also includes INPUT_ATTACHMENT
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5288>
2023-09-08 16:09:33 +00:00
Matthew Waters
6c534655d4 vkformat: reorder RGBA formats before RGBx formats
Fixes gst_vulkan_format_to_video_format to use the RGBA formats instead
of RGBx formats.

Fixes vulkansink exposing a RGBx/BGRx format instead of the more
relevant RGBA/BGRA formats

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5288>
2023-09-08 16:09:33 +00:00
Stéphane Cerveau
c98f5c2bf4 vkvideoutils: fix memory leak in structure's string
Retrieve a const char* from structure for "chromat-format" and
avoid extra mem copy.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4904>
2023-06-22 04:42:58 +00:00
Stéphane Cerveau
fc0ee45fb5 vkdevice: fix beta extensions symbol
Missing 's' to VK_ENABLE_BETA_EXTENSIONS

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4904>
2023-06-22 04:42:58 +00:00
Stéphane Cerveau
c1149d60c1 vkphysicaldevice: fix leak with queue_family_query_props
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4904>
2023-06-22 04:42:58 +00:00
Stéphane Cerveau
6920166af4 vulkan: fix C2099 error with VS2019
As VK_FORMAT_FEATURE_2_xxx are defined as static const variable, the
vscoce C compiler prevents the initialization of the  vk_usage_map
structure with error "C2099: initializer is not a constant".

Init the structure separately.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4904>
2023-06-22 04:42:58 +00:00
Víctor Manuel Jáquez Leal
06d793033d vulkan/format: use basic features (v1) as fallback
if vkGetPhysicalDeviceFormatProperties2 isn't available.

This approach assumes that, for basic features flags symbols,
VkFormatFeatureFlagBits and VkFormatFeatureFlagBits2 are binary equivalent.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4746>
2023-06-01 13:58:47 +00:00
Matthew Waters
0a74a967e3 vulkan/format: don't rely on vulkan header version for function availability
e.g. android will have update vulkan.h headers but old platforms will
not contain the function and will result in a link error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4746>
2023-06-01 13:58:47 +00:00
Víctor Manuel Jáquez Leal
8b75e5fb57 vkvideoutils: fix code-style
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4716>
2023-05-26 10:08:27 +02:00
Víctor Manuel Jáquez Leal
365454790a vkphysicaldevice: fetch queue family query result support
And merged in a single structure the queue family operations report.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4716>
2023-05-26 10:08:27 +02:00
Víctor Manuel Jáquez Leal
e2a40c58bf vkimagebufferpool: chain the correct structure
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4716>
2023-05-26 09:45:07 +02:00
Víctor Manuel Jáquez Leal
e9414b9582 vkvideoutils: fix bug for chroma string comparison
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4716>
2023-05-26 09:45:07 +02:00
Víctor Manuel Jáquez Leal
8670a023f1 vkimagebufferpool: prepare new allocated buffers
This means change initial memory undefined layout and access to the ones
required for their usage.

This is only used if VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME is available.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:30 +00:00
Víctor Manuel Jáquez Leal
e177080bec vulkan: number of memories in buffer rather than number of planes
New vulkan formats don't match the number of planes with the number of memories
attached to the buffer. This patch changes the pattern of using planes for
traverse the memories with the number of attached memories.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
565fe3291e vkutils: add gst_vulkan_get_or_create_image_view_with_info()
It's a generalization of the original gst_vulkan_get_or_create_image_view().

The reason for passing the whole VkImageViewCreateInfo structure rather than
just the missing fields, is because VkImageSubresourceRange and
VkComponentMapping can be different and those are most of VkImageViewCreateInfo.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
bb29b4dfec vkdevice: enable device optional extensions
Enable before-hand what the user might use.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
d7bbcffe14 vkformat: add VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
b1321f78d3 vkswapper: use gst_vulkan_format_to_video_format()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
d84926b60f vkformat: add gst_vulkan_format_to_video_format()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
ce7256e0d3 vulkan: use gst_vulkan_format_get_aspect()
In order to use it, without depending in a previous calling of
_create_info_from_args(), VkFormat as input parameter to
gst_vulkan_image_memory_init() was added.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
b8e908131d vkformat: add gst_vulkan_format_get_aspect()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
26d00ba0cc vkimagebufferpool: fail if image cannot be allocated
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
d91c17264c vkimagebufferpool: gst_vulkan_image_buffer_pool_config_set_decode_caps()
This is going to be used when the pool is used by a video decoder for
VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, since the frame allocation needs the
VkVideoProfileInfoKHR, and for that here GstCaps is used to wire it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
07271fc648 vkvideoutils: add gst_vulkan_video_profile_{to/from}_caps()
Add this new source file with utils for video profile mapping with GstCaps.
These method is used to pass this information along GStreamer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
c7c5dedd7f vkimagebufferpool: use gst_vulkan_image_memory_alloc_with_image_info()
As the pool will be only used for images with usage
VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR only one layer has to be allocated.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
83e73a2f59 vulkan: find memory type index with requirements
The specification says:

VUID-vkAllocateMemory-pAllocateInfo-01713

must pAllocateInfo->allocationSize be less than or equal to
VkPhysicalDeviceMemoryProperties::memoryHeaps[memindex].size where memindex =
VkPhysicalDeviceMemoryProperties::memoryTypes[pAllocateInfo->memoryTypeIndex].heapIndex
as returned by vkGetPhysicalDeviceMemoryProperties for the VkPhysicalDevice that
device was created from.

Though this can be catch by the validation layer, the requested frame size
depends on the use case so it's better to check this restriction by our code.

This patch also makes use of this new function to find memory type index,
 and removes the unused function to find memory type index, which, as GstVulkan is
considered unstable, we can do it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
4dd0fd6797 vkimagebufferpool: use gst_vulkan_format_from_video_info_2()
To get the number of images and its Vulkan formats for the GStreamer format.
Also it gets the basic image usage by default if it's not defined. It fails if the
video format is not supported.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
35dbd9f92c vkformat: add gst_vulkan_format_from_video_info_2()
The purpose of this function is to get more info about the mapped Vulkan format
from the GStreamer format, since they can be multiple Vulkan formats for one
GStreamer format.

Also a Vulkan format may have certain usage and aspects that must be verified.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
14dd6aac16 vkformat: move gst_vulkan_format_from_video_info()
Moved gst_vulkan_format_from_video_info() from gstvkimagememory to gstvkformat
in order to centralize the video format operations in a single source file.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
b1c166b53c vkimagebufferpool: pass usage and memory properties
Pass, in config structure, usage and memory properties, assigning proper
defaults if they aren't set. This parameters are used in image memory
allocation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
7b62c26139 vkdevice: add gst_vulkan_device_queue_family_indices()
This method will return a GArray with all the queue family indices created by
the device when it's opened. This array will be used by VkImageCreateInfo to
allocate a new Vulkan image.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
ea2bd1882f vkdevice: add programming parameters verification
To `gst_vulkan_device_foreach_queue()`.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
1e2ff519c6 vkbuffermemory: add gst_vulkan_buffer_memory_alloc_with_buffer_info()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
64ba7fb2eb vkimagememory: gst_vulkan_image_memory_alloc_with_image_info()
This new method instead of passing a bunch of variables which will fill
`VkImageCreateInfo`, the method accepts this whole structure, so the caller can
customize it as much as they want.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
5f5249cf73 vkimagememory: look up for Vulkan format using a static table
Replace the switch structure with explicit and extendable static table.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
1458c31031 vkdevice: enable multiple queues per device
Originally the opened device only created one queue of one family queue, to say
graphics one. This approach felt short when other queue family is required not
shared with the graphics queue family, for example video decoding.

This new approach proposes to create those queues with supported families. For
now, only video decoding and encoder are created, if they are available.

In order to hold multiple queues opened, an array of VkDeviceQueueCreateInfo is
held along the live the device object, because it's used to traverse or get the
opened queues.

The algorithm to choose which queues create (or open) is to look for the queue
with more family bits, which also supports the one we are requesting, thus
minimizing the number of global queues of a certain family to create.
Nonetheless, the number of queues to open per family is set to be all of them,
widening the possibility of parallelism.

Also, this commit do a cosmetic refactor the assigning the physical device
nearer where it's used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00
Víctor Manuel Jáquez Leal
25140499fc vkdevice: enable features from physical device
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
2023-05-19 04:26:29 +00:00