mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
vulkan/image: use the full video info for returning vulkan formats
We may need some colorspace information for returning sRGB vs no sRGB.
This commit is contained in:
parent
60cec38591
commit
475a2b0acd
8 changed files with 28 additions and 56 deletions
|
@ -1333,7 +1333,7 @@ static VkAttachmentDescription
|
|||
for (i = 0; i < *n_descriptions; i++) {
|
||||
/* *INDENT-OFF* */
|
||||
color_attachments[i] = (VkAttachmentDescription) {
|
||||
.format = gst_vulkan_format_from_video_format (GST_VIDEO_INFO_FORMAT (&render->out_info), i),
|
||||
.format = gst_vulkan_format_from_video_info (&render->out_info, i),
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
|
@ -1764,12 +1764,11 @@ gst_vulkan_color_convert_transform (GstBaseTransform * bt, GstBuffer * inbuf,
|
|||
/* we need a scratch buffer because framebuffers can only output to
|
||||
* attachments of at least the same size which means no sub-sampled
|
||||
* rendering */
|
||||
GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&render->out_info);
|
||||
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
VkFormat vk_format;
|
||||
GstMemory *mem;
|
||||
|
||||
vk_format = gst_vulkan_format_from_video_format (v_format, i);
|
||||
vk_format = gst_vulkan_format_from_video_info (&render->out_info, i);
|
||||
|
||||
mem = gst_vulkan_image_memory_alloc (render->device,
|
||||
vk_format, GST_VIDEO_INFO_WIDTH (&render->out_info),
|
||||
|
|
|
@ -261,7 +261,7 @@ static VkAttachmentDescription
|
|||
color_attachments = g_new0 (VkAttachmentDescription, *n_descriptions);
|
||||
/* *INDENT-OFF* */
|
||||
color_attachments[0] = (VkAttachmentDescription) {
|
||||
.format = gst_vulkan_format_from_video_format (GST_VIDEO_INFO_FORMAT (&render->in_info), 0),
|
||||
.format = gst_vulkan_format_from_video_info (&render->in_info, 0),
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
|
|
|
@ -239,11 +239,10 @@ _raw_to_buffer_set_caps (gpointer impl, GstCaps * in_caps, GstCaps * out_caps)
|
|||
out_height = GST_VIDEO_INFO_HEIGHT (&raw->out_info);
|
||||
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&raw->out_info); i++) {
|
||||
GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&raw->out_info);
|
||||
GstVulkanImageMemory *img_mem;
|
||||
VkFormat vk_format;
|
||||
|
||||
vk_format = gst_vulkan_format_from_video_format (v_format, i);
|
||||
vk_format = gst_vulkan_format_from_video_info (&raw->out_info, i);
|
||||
|
||||
img_mem = (GstVulkanImageMemory *)
|
||||
gst_vulkan_image_memory_alloc (raw->upload->device, vk_format,
|
||||
|
|
|
@ -1944,7 +1944,7 @@ static VkAttachmentDescription
|
|||
for (i = 0; i < *n_descriptions; i++) {
|
||||
/* *INDENT-OFF* */
|
||||
color_attachments[i] = (VkAttachmentDescription) {
|
||||
.format = gst_vulkan_format_from_video_format (GST_VIDEO_INFO_FORMAT (&render->out_info), i),
|
||||
.format = gst_vulkan_format_from_video_info (&render->out_info, i),
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
|
|
|
@ -103,13 +103,12 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool,
|
|||
/* get the size of the buffer to allocate */
|
||||
priv->v_info.size = 0;
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&priv->v_info); i++) {
|
||||
GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&priv->v_info);
|
||||
GstVulkanImageMemory *img_mem;
|
||||
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
guint width, height;
|
||||
VkFormat vk_format;
|
||||
|
||||
vk_format = gst_vulkan_format_from_video_format (v_format, i);
|
||||
vk_format = gst_vulkan_format_from_video_info (&priv->v_info, i);
|
||||
width = GST_VIDEO_INFO_COMP_WIDTH (&priv->v_info, i);
|
||||
height = GST_VIDEO_INFO_COMP_HEIGHT (&priv->v_info, i);
|
||||
if (priv->raw_caps)
|
||||
|
@ -171,12 +170,11 @@ gst_vulkan_image_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|||
}
|
||||
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&priv->v_info); i++) {
|
||||
GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&priv->v_info);
|
||||
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
VkFormat vk_format;
|
||||
GstMemory *mem;
|
||||
|
||||
vk_format = gst_vulkan_format_from_video_format (v_format, i);
|
||||
vk_format = gst_vulkan_format_from_video_info (&priv->v_info, i);
|
||||
if (priv->raw_caps)
|
||||
tiling = VK_IMAGE_TILING_LINEAR;
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFUALT);
|
|||
static GstAllocator *_vulkan_image_memory_allocator;
|
||||
|
||||
/**
|
||||
* gst_vulkan_format_from_video_format: (skip)
|
||||
* @v_format: the #GstVideoFormat
|
||||
* gst_vulkan_format_from_video_info: (skip)
|
||||
* @v_info: the #GstVideoInfo
|
||||
* @plane: the plane
|
||||
*
|
||||
* Returns: the VkFormat to use for @v_format and @plane
|
||||
|
@ -49,21 +49,34 @@ static GstAllocator *_vulkan_image_memory_allocator;
|
|||
* Since: 1.18
|
||||
*/
|
||||
VkFormat
|
||||
gst_vulkan_format_from_video_format (GstVideoFormat v_format, guint plane)
|
||||
gst_vulkan_format_from_video_info (GstVideoInfo * v_info, guint plane)
|
||||
{
|
||||
guint n_plane_components;
|
||||
|
||||
switch (v_format) {
|
||||
switch (GST_VIDEO_INFO_FORMAT (v_info)) {
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_RGBA:
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
|
||||
GST_VIDEO_TRANSFER_SRGB)
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
else
|
||||
return VK_FORMAT_R8G8B8A8_SRGB;
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_BGRA:
|
||||
return VK_FORMAT_B8G8R8A8_UNORM;
|
||||
if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
|
||||
GST_VIDEO_TRANSFER_SRGB)
|
||||
return VK_FORMAT_B8G8R8A8_UNORM;
|
||||
else
|
||||
return VK_FORMAT_B8G8R8A8_SRGB;
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
case GST_VIDEO_FORMAT_ABGR:
|
||||
if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
|
||||
GST_VIDEO_TRANSFER_SRGB)
|
||||
n_plane_components = 4;
|
||||
else
|
||||
return VK_FORMAT_UNDEFINED;
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
n_plane_components = 4;
|
||||
break;
|
||||
|
|
|
@ -142,7 +142,7 @@ void gst_vulkan_image_memory_add_view (GstVulkanImageMemory *
|
|||
GstVulkanImageView * view);
|
||||
|
||||
GST_VULKAN_API
|
||||
VkFormat gst_vulkan_format_from_video_format (GstVideoFormat v_format,
|
||||
VkFormat gst_vulkan_format_from_video_info (GstVideoInfo * v_info,
|
||||
guint plane);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -158,55 +158,18 @@ _vk_format_to_video_format (VkFormat format)
|
|||
switch (format) {
|
||||
/* double check endianness */
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
case VK_FORMAT_R8G8B8A8_SRGB:
|
||||
return GST_VIDEO_FORMAT_RGBA;
|
||||
case VK_FORMAT_R8G8B8_UNORM:
|
||||
case VK_FORMAT_R8G8B8_SRGB:
|
||||
return GST_VIDEO_FORMAT_RGB;
|
||||
case VK_FORMAT_B8G8R8A8_UNORM:
|
||||
case VK_FORMAT_B8G8R8A8_SRGB:
|
||||
return GST_VIDEO_FORMAT_BGRA;
|
||||
case VK_FORMAT_B8G8R8_UNORM:
|
||||
case VK_FORMAT_B8G8R8_SRGB:
|
||||
return GST_VIDEO_FORMAT_BGR;
|
||||
default:
|
||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static VkFormat
|
||||
_vk_format_from_video_info (GstVideoInfo * v_info)
|
||||
{
|
||||
switch (GST_VIDEO_INFO_FORMAT (v_info)) {
|
||||
case GST_VIDEO_FORMAT_RGBA:
|
||||
if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
|
||||
GST_VIDEO_TRANSFER_SRGB)
|
||||
return VK_FORMAT_R8G8B8A8_SRGB;
|
||||
else
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
case GST_VIDEO_FORMAT_RGB:
|
||||
if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
|
||||
GST_VIDEO_TRANSFER_SRGB)
|
||||
return VK_FORMAT_R8G8B8_SRGB;
|
||||
else
|
||||
return VK_FORMAT_R8G8B8_UNORM;
|
||||
case GST_VIDEO_FORMAT_BGRA:
|
||||
if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
|
||||
GST_VIDEO_TRANSFER_SRGB)
|
||||
return VK_FORMAT_B8G8R8A8_SRGB;
|
||||
else
|
||||
return VK_FORMAT_B8G8R8A8_UNORM;
|
||||
case GST_VIDEO_FORMAT_BGR:
|
||||
if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
|
||||
GST_VIDEO_TRANSFER_SRGB)
|
||||
return VK_FORMAT_B8G8R8_SRGB;
|
||||
else
|
||||
return VK_FORMAT_B8G8R8_UNORM;
|
||||
default:
|
||||
return VK_FORMAT_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
static VkColorSpaceKHR
|
||||
_vk_color_space_from_video_info (GstVideoInfo * v_info)
|
||||
{
|
||||
|
@ -742,7 +705,7 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
preTransform = swapper->priv->surf_props.currentTransform;
|
||||
}
|
||||
|
||||
format = _vk_format_from_video_info (&swapper->priv->v_info);
|
||||
format = gst_vulkan_format_from_video_info (&swapper->priv->v_info, 0);
|
||||
color_space = _vk_color_space_from_video_info (&swapper->priv->v_info);
|
||||
|
||||
if ((swapper->priv->surf_props.supportedCompositeAlpha &
|
||||
|
|
Loading…
Reference in a new issue