vdpau: Refactor query for video surface formats.

Cc: mesa-stable

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10614
Signed-off-by: Chris Rankin <rankincj@gmail.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27730>
This commit is contained in:
Chris Rankin 2024-02-21 16:37:58 +00:00 committed by Marge Bot
parent 174b715391
commit c3ceec6cd8
2 changed files with 29 additions and 24 deletions

View file

@ -118,21 +118,21 @@ vl_video_buffer_is_format_supported(struct pipe_screen *screen,
vl_get_video_buffer_formats(screen, format, resource_formats); vl_get_video_buffer_formats(screen, format, resource_formats);
for (i = 0; i < VL_NUM_COMPONENTS; ++i) { for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
enum pipe_format format = resource_formats[i]; enum pipe_format fmt = resource_formats[i];
if (format == PIPE_FORMAT_NONE) if (fmt == PIPE_FORMAT_NONE)
continue; continue;
/* we at least need to sample from it */ /* we at least need to sample from it */
if (!screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW)) if (!screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW))
return false; continue;
format = vl_video_buffer_surface_format(format); fmt = vl_video_buffer_surface_format(fmt);
if (!screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_RENDER_TARGET)) if (screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_RENDER_TARGET))
return false; return true;
} }
return true; return false;
} }
unsigned unsigned

View file

@ -108,6 +108,8 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp
{ {
vlVdpDevice *dev; vlVdpDevice *dev;
struct pipe_screen *pscreen; struct pipe_screen *pscreen;
VdpYCbCrFormat ycbcrFormat;
bool supported;
if (!is_supported) if (!is_supported)
return VDP_STATUS_INVALID_POINTER; return VDP_STATUS_INVALID_POINTER;
@ -122,47 +124,50 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp
mtx_lock(&dev->mutex); mtx_lock(&dev->mutex);
ycbcrFormat = bits_ycbcr_format;
switch(bits_ycbcr_format) { switch(bits_ycbcr_format) {
case VDP_YCBCR_FORMAT_NV12: case VDP_YCBCR_FORMAT_NV12:
*is_supported = surface_chroma_type == VDP_CHROMA_TYPE_420; supported = surface_chroma_type == VDP_CHROMA_TYPE_420;
break; break;
case VDP_YCBCR_FORMAT_YV12: case VDP_YCBCR_FORMAT_YV12:
*is_supported = surface_chroma_type == VDP_CHROMA_TYPE_420; supported = surface_chroma_type == VDP_CHROMA_TYPE_420;
/* We can convert YV12 to NV12 on the fly! */ /* We can convert YV12 to NV12 on the fly! */
if (*is_supported && ycbcrFormat = VDP_YCBCR_FORMAT_NV12;
pscreen->is_video_format_supported(pscreen,
PIPE_FORMAT_NV12,
PIPE_VIDEO_PROFILE_UNKNOWN,
PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) {
mtx_unlock(&dev->mutex);
return VDP_STATUS_OK;
}
break; break;
case VDP_YCBCR_FORMAT_UYVY: case VDP_YCBCR_FORMAT_UYVY:
case VDP_YCBCR_FORMAT_YUYV: case VDP_YCBCR_FORMAT_YUYV:
*is_supported = surface_chroma_type == VDP_CHROMA_TYPE_422; supported = surface_chroma_type == VDP_CHROMA_TYPE_422;
break; break;
case VDP_YCBCR_FORMAT_Y8U8V8A8: case VDP_YCBCR_FORMAT_Y8U8V8A8:
case VDP_YCBCR_FORMAT_V8U8Y8A8: case VDP_YCBCR_FORMAT_V8U8Y8A8:
*is_supported = surface_chroma_type == VDP_CHROMA_TYPE_444; supported = surface_chroma_type == VDP_CHROMA_TYPE_444;
break;
case VDP_YCBCR_FORMAT_P010:
case VDP_YCBCR_FORMAT_P016:
/* Do any other profiles imply support for this chroma type? */
supported = (surface_chroma_type == VDP_CHROMA_TYPE_420_16)
&& vl_codec_supported(pscreen, PIPE_VIDEO_PROFILE_HEVC_MAIN_10, false);
break; break;
default: default:
*is_supported = false; supported = false;
break; break;
} }
if (*is_supported && if (supported &&
!pscreen->is_video_format_supported(pscreen, !pscreen->is_video_format_supported(pscreen,
FormatYCBCRToPipe(bits_ycbcr_format), FormatYCBCRToPipe(ycbcrFormat),
PIPE_VIDEO_PROFILE_UNKNOWN, PIPE_VIDEO_PROFILE_UNKNOWN,
PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) { PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) {
*is_supported = false; supported = false;
} }
*is_supported = supported;
mtx_unlock(&dev->mutex); mtx_unlock(&dev->mutex);
return VDP_STATUS_OK; return VDP_STATUS_OK;