mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 05:10:11 +01:00
Remove VDPAU
VDPAU only supports X11 and GL interop. There is no Wayland or Vulkan interop support. The API has limitations that makes it impossible to correctly decode certain streams. Application support is also very limited, and VAAPI is always a better choice over VDPAU. Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36632>
This commit is contained in:
parent
e7ea1233b1
commit
4b54277d2e
31 changed files with 13 additions and 6412 deletions
|
|
@ -557,7 +557,7 @@ Capability about the features and limits of the driver/GPU.
|
||||||
|
|
||||||
* ``pipe_caps.cl_gl_sharing``: True if driver supports everything required by a frontend implementing the CL extension, and
|
* ``pipe_caps.cl_gl_sharing``: True if driver supports everything required by a frontend implementing the CL extension, and
|
||||||
also supports importing/exporting all of pipe_texture_target via dma buffers.
|
also supports importing/exporting all of pipe_texture_target via dma buffers.
|
||||||
* ``pipe_caps.prefer_compute_for_multimedia``: Whether VDPAU and VAAPI
|
* ``pipe_caps.prefer_compute_for_multimedia``: Whether VAAPI
|
||||||
should use a compute-based blit instead of pipe_context::blit and compute pipeline for compositing images.
|
should use a compute-based blit instead of pipe_context::blit and compute pipeline for compositing images.
|
||||||
* ``pipe_caps.fragment_shader_interlock``: True if fragment shader interlock
|
* ``pipe_caps.fragment_shader_interlock``: True if fragment shader interlock
|
||||||
functionality is supported.
|
functionality is supported.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ The Mesa project began as an open-source implementation of the
|
||||||
`OpenGL`_ specification - a system for rendering interactive 3D graphics.
|
`OpenGL`_ specification - a system for rendering interactive 3D graphics.
|
||||||
|
|
||||||
Over the years the project has grown to implement more graphics APIs,
|
Over the years the project has grown to implement more graphics APIs,
|
||||||
including `OpenGL ES`_, `OpenCL`_, `VDPAU`_, `VA-API`_,
|
including `OpenGL ES`_, `OpenCL`_, `VA-API`_,
|
||||||
`Vulkan`_ and `EGL`_.
|
`Vulkan`_ and `EGL`_.
|
||||||
|
|
||||||
A variety of device drivers allows the Mesa libraries to be used in many
|
A variety of device drivers allows the Mesa libraries to be used in many
|
||||||
|
|
@ -19,7 +19,6 @@ Linux, FreeBSD, and other operating systems.
|
||||||
.. _OpenGL: https://www.opengl.org/
|
.. _OpenGL: https://www.opengl.org/
|
||||||
.. _OpenGL ES: https://www.khronos.org/opengles/
|
.. _OpenGL ES: https://www.khronos.org/opengles/
|
||||||
.. _OpenCL: https://www.khronos.org/opencl/
|
.. _OpenCL: https://www.khronos.org/opencl/
|
||||||
.. _VDPAU: https://en.wikipedia.org/wiki/VDPAU
|
|
||||||
.. _VA-API: https://en.wikipedia.org/wiki/Video_Acceleration_API
|
.. _VA-API: https://en.wikipedia.org/wiki/Video_Acceleration_API
|
||||||
.. _Vulkan: https://www.vulkan.org/
|
.. _Vulkan: https://www.vulkan.org/
|
||||||
.. _EGL: https://www.khronos.org/egl/
|
.. _EGL: https://www.khronos.org/egl/
|
||||||
|
|
|
||||||
|
|
@ -20,3 +20,4 @@ VK_KHR_maintenance8 on panvk/v10+
|
||||||
VK_KHR_maintenance9 on panvk
|
VK_KHR_maintenance9 on panvk
|
||||||
VK_AMD_buffer_marker on NVK
|
VK_AMD_buffer_marker on NVK
|
||||||
VK_EXT_ycbcr_2plane_444_formats on radv
|
VK_EXT_ycbcr_2plane_444_formats on radv
|
||||||
|
Removed VDPAU frontend
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,6 @@ each directory.
|
||||||
- **hgl** - Haiku OpenGL
|
- **hgl** - Haiku OpenGL
|
||||||
- **lavapipe** - Vulkan frontend, software Vulkan rasterizer using LLVMpipe.
|
- **lavapipe** - Vulkan frontend, software Vulkan rasterizer using LLVMpipe.
|
||||||
- **va** - VA-API frontend
|
- **va** - VA-API frontend
|
||||||
- **vdpau** - VDPAU frontend
|
|
||||||
- **wgl** - Windows WGL frontend
|
- **wgl** - Windows WGL frontend
|
||||||
|
|
||||||
- **winsys** - The device drivers are platform-independent, the
|
- **winsys** - The device drivers are platform-independent, the
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ Haiku. We're actively developing and maintaining several hardware and
|
||||||
software drivers.
|
software drivers.
|
||||||
|
|
||||||
The primary API is OpenGL but there's also support for OpenGL ES, Vulkan,
|
The primary API is OpenGL but there's also support for OpenGL ES, Vulkan,
|
||||||
EGL, OpenCL, VDPAU and VA-API.
|
EGL, OpenCL and VA-API.
|
||||||
|
|
||||||
Hardware drivers include:
|
Hardware drivers include:
|
||||||
|
|
||||||
|
|
@ -75,3 +75,4 @@ the Git repo. The list includes:
|
||||||
- Silicon Integrated Systems
|
- Silicon Integrated Systems
|
||||||
- swrast
|
- swrast
|
||||||
- VIA Unichrome
|
- VIA Unichrome
|
||||||
|
- VDPAU
|
||||||
|
|
|
||||||
36
meson.build
36
meson.build
|
|
@ -628,30 +628,6 @@ if with_gallium_d3d12 and not _with_gallium_d3d12_video.disabled()
|
||||||
pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO'
|
pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
_vdpau_drivers = [
|
|
||||||
with_gallium_d3d12_video,
|
|
||||||
with_gallium_nouveau,
|
|
||||||
with_gallium_r600,
|
|
||||||
with_gallium_radeonsi,
|
|
||||||
with_gallium_virgl,
|
|
||||||
]
|
|
||||||
|
|
||||||
vdpau = get_option('gallium-vdpau') \
|
|
||||||
.require(system_has_kms_drm, error_message : 'VDPAU state tracker can only be build on unix-like OSes.') \
|
|
||||||
.require(with_platform_x11, error_message : 'VDPAU state tracker requires X11 support.') \
|
|
||||||
.require(_vdpau_drivers.contains(true), error_message : 'VDPAU state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).')
|
|
||||||
|
|
||||||
dep_vdpau = dependency('vdpau', version : '>= 1.5', required : vdpau)
|
|
||||||
if dep_vdpau.found()
|
|
||||||
dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
|
|
||||||
endif
|
|
||||||
with_gallium_vdpau = dep_vdpau.found()
|
|
||||||
|
|
||||||
vdpau_drivers_path = get_option('vdpau-libs-path')
|
|
||||||
if vdpau_drivers_path == ''
|
|
||||||
vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
|
|
||||||
endif
|
|
||||||
|
|
||||||
# GLSL has interesting version output and Meson doesn't parse it correctly as of
|
# GLSL has interesting version output and Meson doesn't parse it correctly as of
|
||||||
# Meson 1.4.0
|
# Meson 1.4.0
|
||||||
prog_glslang = find_program(
|
prog_glslang = find_program(
|
||||||
|
|
@ -2091,8 +2067,7 @@ if with_platform_x11
|
||||||
# needed for GL sharing extension
|
# needed for GL sharing extension
|
||||||
dep_x11 = dependency('x11', version : dep_xlib_version)
|
dep_x11 = dependency('x11', version : dep_xlib_version)
|
||||||
endif
|
endif
|
||||||
if (with_any_vk or with_glx == 'dri' or with_egl or
|
if (with_any_vk or with_glx == 'dri' or with_egl or with_gallium_va)
|
||||||
(with_gallium_vdpau or with_gallium_va))
|
|
||||||
dep_xcb = dependency('xcb')
|
dep_xcb = dependency('xcb')
|
||||||
dep_xcb_keysyms = dependency('xcb-keysyms', required : false)
|
dep_xcb_keysyms = dependency('xcb-keysyms', required : false)
|
||||||
with_xcb_keysyms = dep_xcb_keysyms.found()
|
with_xcb_keysyms = dep_xcb_keysyms.found()
|
||||||
|
|
@ -2128,8 +2103,7 @@ if with_platform_x11
|
||||||
endif
|
endif
|
||||||
if (with_egl or
|
if (with_egl or
|
||||||
with_dri or
|
with_dri or
|
||||||
with_any_vk or
|
with_any_vk)
|
||||||
with_gallium_vdpau)
|
|
||||||
dep_xcb_xfixes = dependency('xcb-xfixes')
|
dep_xcb_xfixes = dependency('xcb-xfixes')
|
||||||
endif
|
endif
|
||||||
if with_any_vk
|
if with_any_vk
|
||||||
|
|
@ -2363,9 +2337,6 @@ summary(vulkan_summary, section: 'Vulkan', bool_yn: true, list_sep: ' ')
|
||||||
|
|
||||||
video_summary = {'Codecs': _codecs.length() != 0 ? _codecs : false}
|
video_summary = {'Codecs': _codecs.length() != 0 ? _codecs : false}
|
||||||
video_apis = []
|
video_apis = []
|
||||||
if with_gallium_vdpau
|
|
||||||
video_apis += 'vdpau'
|
|
||||||
endif
|
|
||||||
if with_gallium_va
|
if with_gallium_va
|
||||||
video_apis += 'va'
|
video_apis += 'va'
|
||||||
endif
|
endif
|
||||||
|
|
@ -2390,9 +2361,6 @@ if with_gallium
|
||||||
gallium_summary += {'Platforms': _platforms}
|
gallium_summary += {'Platforms': _platforms}
|
||||||
|
|
||||||
gallium_frontends = ['mesa']
|
gallium_frontends = ['mesa']
|
||||||
if with_gallium_vdpau
|
|
||||||
gallium_frontends += 'vdpau'
|
|
||||||
endif
|
|
||||||
if with_gallium_va
|
if with_gallium_va
|
||||||
gallium_frontends += 'va'
|
gallium_frontends += 'va'
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -102,20 +102,6 @@ option(
|
||||||
description : 'Enable HUD block/NIC I/O HUD status support',
|
description : 'Enable HUD block/NIC I/O HUD status support',
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
|
||||||
'gallium-vdpau',
|
|
||||||
type : 'feature',
|
|
||||||
deprecated: {'true': 'enabled', 'false': 'disabled'},
|
|
||||||
description : 'enable gallium vdpau frontend.',
|
|
||||||
)
|
|
||||||
|
|
||||||
option(
|
|
||||||
'vdpau-libs-path',
|
|
||||||
type : 'string',
|
|
||||||
value : '',
|
|
||||||
description : 'path to put vdpau libraries. defaults to $libdir/vdpau.'
|
|
||||||
)
|
|
||||||
|
|
||||||
option(
|
option(
|
||||||
'gallium-va',
|
'gallium-va',
|
||||||
type : 'feature',
|
type : 'feature',
|
||||||
|
|
@ -717,7 +703,7 @@ option(
|
||||||
description : 'List of codecs to build support for. ' +
|
description : 'List of codecs to build support for. ' +
|
||||||
'Distros might want to consult their legal department before ' +
|
'Distros might want to consult their legal department before ' +
|
||||||
'enabling these. This is used for all video APIs (vaapi, ' +
|
'enabling these. This is used for all video APIs (vaapi, ' +
|
||||||
'vdpau, vulkan). Non-patent encumbered codecs will be ' +
|
'vulkan). Non-patent encumbered codecs will be ' +
|
||||||
'enabled by default with the all_free default value.'
|
'enabled by default with the all_free default value.'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@ with_nir_headers_only = (
|
||||||
gallium_drivers == ['d3d12'] and
|
gallium_drivers == ['d3d12'] and
|
||||||
get_option('gallium-d3d12-graphics').disabled() and
|
get_option('gallium-d3d12-graphics').disabled() and
|
||||||
not [
|
not [
|
||||||
with_gallium_vdpau,
|
|
||||||
with_gallium_va,
|
with_gallium_va,
|
||||||
with_any_vk,
|
with_any_vk,
|
||||||
with_gallium_st_d3d10umd,
|
with_gallium_st_d3d10umd,
|
||||||
|
|
|
||||||
|
|
@ -562,7 +562,7 @@ libgalliumvl = static_library(
|
||||||
|
|
||||||
# some drivers export their screen creation function globally, so all frontends have to contain the
|
# some drivers export their screen creation function globally, so all frontends have to contain the
|
||||||
# full libgalliumvl. So we'll handle this here globally for everybody.
|
# full libgalliumvl. So we'll handle this here globally for everybody.
|
||||||
if (with_gallium_mediafoundation or with_gallium_va or with_gallium_vdpau or with_dri or with_gallium_radeonsi)
|
if (with_gallium_mediafoundation or with_gallium_va or with_dri or with_gallium_radeonsi)
|
||||||
libgalliumvl_stub = libgalliumvl
|
libgalliumvl_stub = libgalliumvl
|
||||||
else
|
else
|
||||||
libgalliumvl_stub = _libgalliumvl_stub
|
libgalliumvl_stub = _libgalliumvl_stub
|
||||||
|
|
|
||||||
|
|
@ -1,210 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Thomas Balling Sørensen.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include <vdpau/vdpau.h>
|
|
||||||
|
|
||||||
#include "util/u_memory.h"
|
|
||||||
#include "util/u_sampler.h"
|
|
||||||
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a VdpBitmapSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpBitmapSurfaceCreate(VdpDevice device,
|
|
||||||
VdpRGBAFormat rgba_format,
|
|
||||||
uint32_t width, uint32_t height,
|
|
||||||
VdpBool frequently_accessed,
|
|
||||||
VdpBitmapSurface *surface)
|
|
||||||
{
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
struct pipe_resource res_tmpl, *res;
|
|
||||||
struct pipe_sampler_view sv_templ;
|
|
||||||
VdpStatus ret;
|
|
||||||
|
|
||||||
vlVdpBitmapSurface *vlsurface = NULL;
|
|
||||||
|
|
||||||
if (!(width && height))
|
|
||||||
return VDP_STATUS_INVALID_SIZE;
|
|
||||||
|
|
||||||
vlVdpDevice *dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pipe = dev->context;
|
|
||||||
if (!pipe)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (!surface)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
vlsurface = CALLOC(1, sizeof(vlVdpBitmapSurface));
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
DeviceReference(&vlsurface->device, dev);
|
|
||||||
|
|
||||||
memset(&res_tmpl, 0, sizeof(res_tmpl));
|
|
||||||
res_tmpl.target = PIPE_TEXTURE_2D;
|
|
||||||
res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
|
|
||||||
res_tmpl.width0 = width;
|
|
||||||
res_tmpl.height0 = height;
|
|
||||||
res_tmpl.depth0 = 1;
|
|
||||||
res_tmpl.array_size = 1;
|
|
||||||
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
|
|
||||||
res_tmpl.usage = frequently_accessed ? PIPE_USAGE_DYNAMIC : PIPE_USAGE_DEFAULT;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
|
|
||||||
if (!CheckSurfaceParams(pipe->screen, &res_tmpl)) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto err_unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
|
|
||||||
if (!res) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto err_unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
|
|
||||||
vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
|
|
||||||
|
|
||||||
pipe_resource_reference(&res, NULL);
|
|
||||||
|
|
||||||
if (!vlsurface->sampler_view) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto err_unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
*surface = vlAddDataHTAB(vlsurface);
|
|
||||||
if (*surface == 0) {
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
ret = VDP_STATUS_ERROR;
|
|
||||||
goto err_sampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
|
|
||||||
err_sampler:
|
|
||||||
pipe->sampler_view_release(pipe, vlsurface->sampler_view);
|
|
||||||
err_unlock:
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
DeviceReference(&vlsurface->device, NULL);
|
|
||||||
FREE(vlsurface);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a VdpBitmapSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpBitmapSurfaceDestroy(VdpBitmapSurface surface)
|
|
||||||
{
|
|
||||||
vlVdpBitmapSurface *vlsurface;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
struct pipe_context *pipe = vlsurface->sampler_view->context;
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
pipe->sampler_view_release(pipe, vlsurface->sampler_view);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
vlRemoveDataHTAB(surface);
|
|
||||||
DeviceReference(&vlsurface->device, NULL);
|
|
||||||
FREE(vlsurface);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the parameters used to create a VdpBitmapSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpBitmapSurfaceGetParameters(VdpBitmapSurface surface,
|
|
||||||
VdpRGBAFormat *rgba_format,
|
|
||||||
uint32_t *width, uint32_t *height,
|
|
||||||
VdpBool *frequently_accessed)
|
|
||||||
{
|
|
||||||
vlVdpBitmapSurface *vlsurface;
|
|
||||||
struct pipe_resource *res;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (!(rgba_format && width && height && frequently_accessed))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
res = vlsurface->sampler_view->texture;
|
|
||||||
*rgba_format = PipeToFormatRGBA(res->format);
|
|
||||||
*width = res->width0;
|
|
||||||
*height = res->height0;
|
|
||||||
*frequently_accessed = res->usage == PIPE_USAGE_DYNAMIC;
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy image data from application memory in the surface's native format to
|
|
||||||
* a VdpBitmapSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface,
|
|
||||||
void const *const *source_data,
|
|
||||||
uint32_t const *source_pitches,
|
|
||||||
VdpRect const *destination_rect)
|
|
||||||
{
|
|
||||||
vlVdpBitmapSurface *vlsurface;
|
|
||||||
struct pipe_box dst_box;
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (!(source_data && source_pitches))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
pipe = vlsurface->device->context;
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
|
|
||||||
pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
|
|
||||||
PIPE_MAP_WRITE, &dst_box, *source_data,
|
|
||||||
*source_pitches, 0);
|
|
||||||
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,333 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Younes Manton og Thomas Balling Sørensen.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include "util/compiler.h"
|
|
||||||
|
|
||||||
#include "util/u_memory.h"
|
|
||||||
#include "util/u_debug.h"
|
|
||||||
#include "util/format/u_format.h"
|
|
||||||
#include "util/u_sampler.h"
|
|
||||||
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a VdpDevice object for use with X11.
|
|
||||||
*/
|
|
||||||
PUBLIC VdpStatus
|
|
||||||
vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
|
|
||||||
VdpGetProcAddress **get_proc_address)
|
|
||||||
{
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
struct pipe_resource *res, res_tmpl;
|
|
||||||
struct pipe_sampler_view sv_tmpl;
|
|
||||||
vlVdpDevice *dev = NULL;
|
|
||||||
VdpStatus ret;
|
|
||||||
|
|
||||||
if (!(display && device && get_proc_address))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
if (!vlCreateHTAB()) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto no_htab;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev = CALLOC(1, sizeof(vlVdpDevice));
|
|
||||||
if (!dev) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto no_dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_reference_init(&dev->reference, 1);
|
|
||||||
|
|
||||||
dev->vscreen = vl_dri3_screen_create(display, screen);
|
|
||||||
if (!dev->vscreen)
|
|
||||||
dev->vscreen = vl_xlib_swrast_screen_create(display, screen);
|
|
||||||
if (!dev->vscreen) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto no_vscreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
/* video cannot work if these are not supported */
|
|
||||||
if (!pscreen->get_video_param || !pscreen->is_video_format_supported) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto no_vscreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->context = pipe_create_multimedia_context(pscreen, false);
|
|
||||||
if (!dev->context) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto no_context;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pscreen->caps.npot_textures) {
|
|
||||||
ret = VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
goto no_context;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&res_tmpl, 0, sizeof(res_tmpl));
|
|
||||||
|
|
||||||
res_tmpl.target = PIPE_TEXTURE_2D;
|
|
||||||
res_tmpl.format = PIPE_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
res_tmpl.width0 = 1;
|
|
||||||
res_tmpl.height0 = 1;
|
|
||||||
res_tmpl.depth0 = 1;
|
|
||||||
res_tmpl.array_size = 1;
|
|
||||||
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
|
|
||||||
res_tmpl.usage = PIPE_USAGE_DEFAULT;
|
|
||||||
|
|
||||||
if (!CheckSurfaceParams(pscreen, &res_tmpl)) {
|
|
||||||
ret = VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
goto no_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = pscreen->resource_create(pscreen, &res_tmpl);
|
|
||||||
if (!res) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto no_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&sv_tmpl, 0, sizeof(sv_tmpl));
|
|
||||||
u_sampler_view_default_template(&sv_tmpl, res, res->format);
|
|
||||||
|
|
||||||
sv_tmpl.swizzle_r = PIPE_SWIZZLE_1;
|
|
||||||
sv_tmpl.swizzle_g = PIPE_SWIZZLE_1;
|
|
||||||
sv_tmpl.swizzle_b = PIPE_SWIZZLE_1;
|
|
||||||
sv_tmpl.swizzle_a = PIPE_SWIZZLE_1;
|
|
||||||
|
|
||||||
dev->dummy_sv = dev->context->create_sampler_view(dev->context, res, &sv_tmpl);
|
|
||||||
pipe_resource_reference(&res, NULL);
|
|
||||||
if (!dev->dummy_sv) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto no_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
*device = vlAddDataHTAB(dev);
|
|
||||||
if (*device == 0) {
|
|
||||||
ret = VDP_STATUS_ERROR;
|
|
||||||
goto no_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vl_compositor_init(&dev->compositor, dev->context, false)) {
|
|
||||||
ret = VDP_STATUS_ERROR;
|
|
||||||
goto no_compositor;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) mtx_init(&dev->mutex, mtx_plain);
|
|
||||||
|
|
||||||
*get_proc_address = &vlVdpGetProcAddress;
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
|
|
||||||
no_compositor:
|
|
||||||
vlRemoveDataHTAB(*device);
|
|
||||||
no_handle:
|
|
||||||
dev->context->sampler_view_release(dev->context, dev->dummy_sv);
|
|
||||||
no_resource:
|
|
||||||
dev->context->destroy(dev->context);
|
|
||||||
no_context:
|
|
||||||
dev->vscreen->destroy(dev->vscreen);
|
|
||||||
no_vscreen:
|
|
||||||
FREE(dev);
|
|
||||||
no_dev:
|
|
||||||
vlDestroyHTAB();
|
|
||||||
no_htab:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a VdpPresentationQueueTarget for use with X11.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable,
|
|
||||||
VdpPresentationQueueTarget *target)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueueTarget *pqt;
|
|
||||||
VdpStatus ret;
|
|
||||||
|
|
||||||
if (!drawable)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
vlVdpDevice *dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pqt = CALLOC(1, sizeof(vlVdpPresentationQueueTarget));
|
|
||||||
if (!pqt)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
DeviceReference(&pqt->device, dev);
|
|
||||||
pqt->drawable = drawable;
|
|
||||||
|
|
||||||
*target = vlAddDataHTAB(pqt);
|
|
||||||
if (*target == 0) {
|
|
||||||
ret = VDP_STATUS_ERROR;
|
|
||||||
goto no_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
|
|
||||||
no_handle:
|
|
||||||
FREE(pqt);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a VdpPresentationQueueTarget.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueTargetDestroy(VdpPresentationQueueTarget presentation_queue_target)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueueTarget *pqt;
|
|
||||||
|
|
||||||
pqt = vlGetDataHTAB(presentation_queue_target);
|
|
||||||
if (!pqt)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
vlRemoveDataHTAB(presentation_queue_target);
|
|
||||||
DeviceReference(&pqt->device, NULL);
|
|
||||||
FREE(pqt);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a VdpDevice.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpDeviceDestroy(VdpDevice device)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
vlRemoveDataHTAB(device);
|
|
||||||
DeviceReference(&dev, NULL);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free a VdpDevice.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
vlVdpDeviceFree(vlVdpDevice *dev)
|
|
||||||
{
|
|
||||||
mtx_destroy(&dev->mutex);
|
|
||||||
vl_compositor_cleanup(&dev->compositor);
|
|
||||||
dev->context->sampler_view_release(dev->context, dev->dummy_sv);
|
|
||||||
dev->context->destroy(dev->context);
|
|
||||||
dev->vscreen->destroy(dev->vscreen);
|
|
||||||
FREE(dev);
|
|
||||||
vlDestroyHTAB();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a VDPAU function pointer.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (!function_pointer)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
if (!vlGetFuncFTAB(function_id, function_pointer))
|
|
||||||
return VDP_STATUS_INVALID_FUNC_ID;
|
|
||||||
|
|
||||||
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Got proc address %p for id %d\n", *function_pointer, function_id);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _ERROR_TYPE(TYPE,STRING) case TYPE: return STRING;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a string describing an error code.
|
|
||||||
*/
|
|
||||||
char const *
|
|
||||||
vlVdpGetErrorString (VdpStatus status)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
_ERROR_TYPE(VDP_STATUS_OK,"The operation completed successfully; no error.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_NO_IMPLEMENTATION,"No backend implementation could be loaded.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_DISPLAY_PREEMPTED,"The display was preempted, or a fatal error occurred. The application must re-initialize VDPAU.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_HANDLE,"An invalid handle value was provided. Either the handle does not exist at all, or refers to an object of an incorrect type.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_POINTER,"An invalid pointer was provided. Typically, this means that a NULL pointer was provided for an 'output' parameter.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_CHROMA_TYPE,"An invalid/unsupported VdpChromaType value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_Y_CB_CR_FORMAT,"An invalid/unsupported VdpYCbCrFormat value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_RGBA_FORMAT,"An invalid/unsupported VdpRGBAFormat value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_INDEXED_FORMAT,"An invalid/unsupported VdpIndexedFormat value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_COLOR_STANDARD,"An invalid/unsupported VdpColorStandard value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_COLOR_TABLE_FORMAT,"An invalid/unsupported VdpColorTableFormat value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_BLEND_FACTOR,"An invalid/unsupported VdpOutputSurfaceRenderBlendFactor value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_BLEND_EQUATION,"An invalid/unsupported VdpOutputSurfaceRenderBlendEquation value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_FLAG,"An invalid/unsupported flag value/combination was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_DECODER_PROFILE,"An invalid/unsupported VdpDecoderProfile value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE,"An invalid/unsupported VdpVideoMixerFeature value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER,"An invalid/unsupported VdpVideoMixerParameter value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE,"An invalid/unsupported VdpVideoMixerAttribute value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE,"An invalid/unsupported VdpVideoMixerPictureStructure value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_FUNC_ID,"An invalid/unsupported VdpFuncId value was supplied.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_SIZE,"The size of a supplied object does not match the object it is being used with.\
|
|
||||||
For example, a VdpVideoMixer is configured to process VdpVideoSurface objects of a specific size.\
|
|
||||||
If presented with a VdpVideoSurface of a different size, this error will be raised.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_VALUE,"An invalid/unsupported value was supplied.\
|
|
||||||
This is a catch-all error code for values of type other than those with a specific error code.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_INVALID_STRUCT_VERSION,"An invalid/unsupported structure version was specified in a versioned structure. \
|
|
||||||
This implies that the implementation is older than the header file the application was built against.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_RESOURCES,"The system does not have enough resources to complete the requested operation at this time.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_HANDLE_DEVICE_MISMATCH,"The set of handles supplied are not all related to the same VdpDevice.When performing operations \
|
|
||||||
that operate on multiple surfaces, such as VdpOutputSurfaceRenderOutputSurface or VdpVideoMixerRender, \
|
|
||||||
all supplied surfaces must have been created within the context of the same VdpDevice object. \
|
|
||||||
This error is raised if they were not.");
|
|
||||||
_ERROR_TYPE(VDP_STATUS_ERROR,"A catch-all error, used when no other error code applies.");
|
|
||||||
default: return "Unknown Error";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res)
|
|
||||||
{
|
|
||||||
const struct util_format_description *desc;
|
|
||||||
|
|
||||||
memset(templ, 0, sizeof(*templ));
|
|
||||||
u_sampler_view_default_template(templ, res, res->format);
|
|
||||||
|
|
||||||
desc = util_format_description(res->format);
|
|
||||||
if (desc->swizzle[0] == PIPE_SWIZZLE_0)
|
|
||||||
templ->swizzle_r = PIPE_SWIZZLE_1;
|
|
||||||
if (desc->swizzle[1] == PIPE_SWIZZLE_0)
|
|
||||||
templ->swizzle_g = PIPE_SWIZZLE_1;
|
|
||||||
if (desc->swizzle[2] == PIPE_SWIZZLE_0)
|
|
||||||
templ->swizzle_b = PIPE_SWIZZLE_1;
|
|
||||||
if (desc->swizzle[3] == PIPE_SWIZZLE_0)
|
|
||||||
templ->swizzle_a = PIPE_SWIZZLE_1;
|
|
||||||
}
|
|
||||||
|
|
@ -1,139 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Younes Manton & Thomas Balling Sørensen.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "util/u_memory.h"
|
|
||||||
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
|
|
||||||
static void* ftab[67] =
|
|
||||||
{
|
|
||||||
&vlVdpGetErrorString, /* VDP_FUNC_ID_GET_ERROR_STRING */
|
|
||||||
&vlVdpGetProcAddress, /* VDP_FUNC_ID_GET_PROC_ADDRESS */
|
|
||||||
&vlVdpGetApiVersion, /* VDP_FUNC_ID_GET_API_VERSION */
|
|
||||||
NULL, /* DUMMY */
|
|
||||||
&vlVdpGetInformationString, /* VDP_FUNC_ID_GET_INFORMATION_STRING */
|
|
||||||
&vlVdpDeviceDestroy, /* VDP_FUNC_ID_DEVICE_DESTROY */
|
|
||||||
&vlVdpGenerateCSCMatrix, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */
|
|
||||||
&vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */
|
|
||||||
&vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */
|
|
||||||
&vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */
|
|
||||||
&vlVdpVideoSurfaceDestroy, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */
|
|
||||||
&vlVdpVideoSurfaceGetParameters, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */
|
|
||||||
&vlVdpVideoSurfaceGetBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */
|
|
||||||
&vlVdpVideoSurfacePutBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */
|
|
||||||
&vlVdpOutputSurfaceQueryCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES */
|
|
||||||
&vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES */
|
|
||||||
&vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */
|
|
||||||
&vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES */
|
|
||||||
&vlVdpOutputSurfaceCreate, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */
|
|
||||||
&vlVdpOutputSurfaceDestroy, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */
|
|
||||||
&vlVdpOutputSurfaceGetParameters, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */
|
|
||||||
&vlVdpOutputSurfaceGetBitsNative, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */
|
|
||||||
&vlVdpOutputSurfacePutBitsNative, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE */
|
|
||||||
&vlVdpOutputSurfacePutBitsIndexed, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */
|
|
||||||
&vlVdpOutputSurfacePutBitsYCbCr, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */
|
|
||||||
&vlVdpBitmapSurfaceQueryCapabilities, /* VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES */
|
|
||||||
&vlVdpBitmapSurfaceCreate, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */
|
|
||||||
&vlVdpBitmapSurfaceDestroy, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */
|
|
||||||
&vlVdpBitmapSurfaceGetParameters, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */
|
|
||||||
&vlVdpBitmapSurfacePutBitsNative, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */
|
|
||||||
NULL, /* DUMMY */
|
|
||||||
NULL, /* DUMMY */
|
|
||||||
NULL, /* DUMMY */
|
|
||||||
&vlVdpOutputSurfaceRenderOutputSurface, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE */
|
|
||||||
&vlVdpOutputSurfaceRenderBitmapSurface, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */
|
|
||||||
NULL, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */
|
|
||||||
&vlVdpDecoderQueryCapabilities, /* VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES */
|
|
||||||
&vlVdpDecoderCreate, /* VDP_FUNC_ID_DECODER_CREATE */
|
|
||||||
&vlVdpDecoderDestroy, /* VDP_FUNC_ID_DECODER_DESTROY */
|
|
||||||
&vlVdpDecoderGetParameters, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */
|
|
||||||
&vlVdpDecoderRender, /* VDP_FUNC_ID_DECODER_RENDER */
|
|
||||||
&vlVdpVideoMixerQueryFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT */
|
|
||||||
&vlVdpVideoMixerQueryParameterSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT */
|
|
||||||
&vlVdpVideoMixerQueryAttributeSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT */
|
|
||||||
&vlVdpVideoMixerQueryParameterValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE */
|
|
||||||
&vlVdpVideoMixerQueryAttributeValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE */
|
|
||||||
&vlVdpVideoMixerCreate, /* VDP_FUNC_ID_VIDEO_MIXER_CREATE */
|
|
||||||
&vlVdpVideoMixerSetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES */
|
|
||||||
&vlVdpVideoMixerSetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES */
|
|
||||||
&vlVdpVideoMixerGetFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT */
|
|
||||||
&vlVdpVideoMixerGetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES */
|
|
||||||
&vlVdpVideoMixerGetParameterValues, /* VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES */
|
|
||||||
&vlVdpVideoMixerGetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */
|
|
||||||
&vlVdpVideoMixerDestroy, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */
|
|
||||||
&vlVdpVideoMixerRender, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */
|
|
||||||
&vlVdpPresentationQueueTargetDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */
|
|
||||||
&vlVdpPresentationQueueCreate, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */
|
|
||||||
&vlVdpPresentationQueueDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */
|
|
||||||
&vlVdpPresentationQueueSetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */
|
|
||||||
&vlVdpPresentationQueueGetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */
|
|
||||||
NULL, /* DUMMY */
|
|
||||||
NULL, /* DUMMY */
|
|
||||||
&vlVdpPresentationQueueGetTime, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */
|
|
||||||
&vlVdpPresentationQueueDisplay, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */
|
|
||||||
&vlVdpPresentationQueueBlockUntilSurfaceIdle, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */
|
|
||||||
&vlVdpPresentationQueueQuerySurfaceStatus, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */
|
|
||||||
&vlVdpPreemptionCallbackRegister /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */
|
|
||||||
};
|
|
||||||
|
|
||||||
static void* ftab_winsys[1] =
|
|
||||||
{
|
|
||||||
&vlVdpPresentationQueueTargetCreateX11 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
|
|
||||||
};
|
|
||||||
|
|
||||||
static void* ftab_driver[4] =
|
|
||||||
{
|
|
||||||
&vlVdpVideoSurfaceGallium, /* VDP_FUNC_ID_SURFACE_GALLIUM */
|
|
||||||
&vlVdpOutputSurfaceGallium, /* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
|
|
||||||
&vlVdpVideoSurfaceDMABuf, /* VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF */
|
|
||||||
&vlVdpOutputSurfaceDMABuf /* VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF */
|
|
||||||
};
|
|
||||||
|
|
||||||
bool vlGetFuncFTAB(VdpFuncId function_id, void **func)
|
|
||||||
{
|
|
||||||
assert(func);
|
|
||||||
*func = NULL;
|
|
||||||
|
|
||||||
if (function_id < VDP_FUNC_ID_BASE_WINSYS) {
|
|
||||||
if (function_id < ARRAY_SIZE(ftab))
|
|
||||||
*func = ftab[function_id];
|
|
||||||
|
|
||||||
} else if (function_id < VDP_FUNC_ID_BASE_DRIVER) {
|
|
||||||
function_id -= VDP_FUNC_ID_BASE_WINSYS;
|
|
||||||
if (function_id < ARRAY_SIZE(ftab_winsys))
|
|
||||||
*func = ftab_winsys[function_id];
|
|
||||||
|
|
||||||
} else {
|
|
||||||
function_id -= VDP_FUNC_ID_BASE_DRIVER;
|
|
||||||
if (function_id < ARRAY_SIZE(ftab_driver))
|
|
||||||
*func = ftab_driver[function_id];
|
|
||||||
}
|
|
||||||
|
|
||||||
return *func != NULL;
|
|
||||||
}
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Younes Manton.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include "util/simple_mtx.h"
|
|
||||||
#include "util/u_handle_table.h"
|
|
||||||
#include "util/u_thread.h"
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
|
|
||||||
static struct handle_table *htab = NULL;
|
|
||||||
static simple_mtx_t htab_lock = SIMPLE_MTX_INITIALIZER;
|
|
||||||
|
|
||||||
bool vlCreateHTAB(void)
|
|
||||||
{
|
|
||||||
bool ret;
|
|
||||||
|
|
||||||
/* Make sure handle table handles match VDPAU handles. */
|
|
||||||
assert(sizeof(unsigned) <= sizeof(vlHandle));
|
|
||||||
simple_mtx_lock(&htab_lock);
|
|
||||||
if (!htab)
|
|
||||||
htab = handle_table_create();
|
|
||||||
ret = htab != NULL;
|
|
||||||
simple_mtx_unlock(&htab_lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vlDestroyHTAB(void)
|
|
||||||
{
|
|
||||||
simple_mtx_lock(&htab_lock);
|
|
||||||
if (htab && !handle_table_get_first_handle(htab)) {
|
|
||||||
handle_table_destroy(htab);
|
|
||||||
htab = NULL;
|
|
||||||
}
|
|
||||||
simple_mtx_unlock(&htab_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
vlHandle vlAddDataHTAB(void *data)
|
|
||||||
{
|
|
||||||
vlHandle handle = 0;
|
|
||||||
|
|
||||||
assert(data);
|
|
||||||
simple_mtx_lock(&htab_lock);
|
|
||||||
if (htab)
|
|
||||||
handle = handle_table_add(htab, data);
|
|
||||||
simple_mtx_unlock(&htab_lock);
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* vlGetDataHTAB(vlHandle handle)
|
|
||||||
{
|
|
||||||
void *data = NULL;
|
|
||||||
|
|
||||||
assert(handle);
|
|
||||||
simple_mtx_lock(&htab_lock);
|
|
||||||
if (htab)
|
|
||||||
data = handle_table_get(htab, handle);
|
|
||||||
simple_mtx_unlock(&htab_lock);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vlRemoveDataHTAB(vlHandle handle)
|
|
||||||
{
|
|
||||||
simple_mtx_lock(&htab_lock);
|
|
||||||
if (htab)
|
|
||||||
handle_table_remove(htab, handle);
|
|
||||||
simple_mtx_unlock(&htab_lock);
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
# Copyright © 2017, 2019 Intel Corproration
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
VDPAU_MAJOR = 1
|
|
||||||
VDPAU_MINOR = 0
|
|
||||||
|
|
||||||
libvdpau_st = static_library(
|
|
||||||
'vdpau_st',
|
|
||||||
files(
|
|
||||||
'bitmap.c', 'decode.c', 'device.c', 'ftab.c', 'htab.c', 'mixer.c',
|
|
||||||
'output.c', 'preemption.c', 'presentation.c', 'query.c', 'surface.c',
|
|
||||||
),
|
|
||||||
c_args : [
|
|
||||||
'-DVER_MAJOR=@0@'.format(VDPAU_MAJOR),
|
|
||||||
'-DVER_MINOR=@0@'.format(VDPAU_MINOR),
|
|
||||||
],
|
|
||||||
gnu_symbol_visibility : 'hidden',
|
|
||||||
include_directories : [
|
|
||||||
inc_include, inc_src, inc_util, inc_gallium, inc_gallium_aux,
|
|
||||||
],
|
|
||||||
dependencies : [dep_vdpau, dep_xcb, dep_x11_xcb, dep_libdrm, idep_mesautil],
|
|
||||||
)
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,829 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Thomas Balling Sørensen.
|
|
||||||
* Copyright 2011 Christian König.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include <vdpau/vdpau.h>
|
|
||||||
|
|
||||||
#include "util/u_debug.h"
|
|
||||||
#include "util/u_memory.h"
|
|
||||||
#include "util/u_sampler.h"
|
|
||||||
#include "util/format/u_format.h"
|
|
||||||
#include "util/u_surface.h"
|
|
||||||
|
|
||||||
#include "vl/vl_csc.h"
|
|
||||||
|
|
||||||
#include "frontend/drm_driver.h"
|
|
||||||
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a VdpOutputSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceCreate(VdpDevice device,
|
|
||||||
VdpRGBAFormat rgba_format,
|
|
||||||
uint32_t width, uint32_t height,
|
|
||||||
VdpOutputSurface *surface)
|
|
||||||
{
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
struct pipe_resource res_tmpl, *res;
|
|
||||||
struct pipe_sampler_view sv_templ;
|
|
||||||
struct pipe_surface surf_templ;
|
|
||||||
|
|
||||||
vlVdpOutputSurface *vlsurface = NULL;
|
|
||||||
|
|
||||||
if (!(width && height))
|
|
||||||
return VDP_STATUS_INVALID_SIZE;
|
|
||||||
|
|
||||||
vlVdpDevice *dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pipe = dev->context;
|
|
||||||
if (!pipe)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
vlsurface = CALLOC(1, sizeof(vlVdpOutputSurface));
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
DeviceReference(&vlsurface->device, dev);
|
|
||||||
|
|
||||||
memset(&res_tmpl, 0, sizeof(res_tmpl));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The output won't look correctly when this buffer is send to X,
|
|
||||||
* if the VDPAU RGB component order doesn't match the X11 one so
|
|
||||||
* we only allow the X11 format
|
|
||||||
*/
|
|
||||||
vlsurface->send_to_X = dev->vscreen->color_depth == 24 &&
|
|
||||||
rgba_format == VDP_RGBA_FORMAT_B8G8R8A8;
|
|
||||||
|
|
||||||
res_tmpl.target = PIPE_TEXTURE_2D;
|
|
||||||
res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
|
|
||||||
res_tmpl.width0 = width;
|
|
||||||
res_tmpl.height0 = height;
|
|
||||||
res_tmpl.depth0 = 1;
|
|
||||||
res_tmpl.array_size = 1;
|
|
||||||
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
|
|
||||||
PIPE_BIND_SHARED | PIPE_BIND_SCANOUT;
|
|
||||||
res_tmpl.usage = PIPE_USAGE_DEFAULT;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
|
|
||||||
if (!CheckSurfaceParams(pipe->screen, &res_tmpl))
|
|
||||||
goto err_unlock;
|
|
||||||
|
|
||||||
res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
|
|
||||||
if (!res)
|
|
||||||
goto err_unlock;
|
|
||||||
|
|
||||||
vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
|
|
||||||
vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
|
|
||||||
if (!vlsurface->sampler_view)
|
|
||||||
goto err_resource;
|
|
||||||
|
|
||||||
memset(&surf_templ, 0, sizeof(surf_templ));
|
|
||||||
u_surface_default_template(&surf_templ, res);
|
|
||||||
vlsurface->surface = surf_templ;
|
|
||||||
|
|
||||||
*surface = vlAddDataHTAB(vlsurface);
|
|
||||||
if (*surface == 0)
|
|
||||||
goto err_resource;
|
|
||||||
|
|
||||||
pipe_resource_reference(&res, NULL);
|
|
||||||
|
|
||||||
if (!vl_compositor_init_state(&vlsurface->cstate, pipe))
|
|
||||||
goto err_resource;
|
|
||||||
|
|
||||||
vl_compositor_reset_dirty_area(&vlsurface->dirty_area);
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
|
|
||||||
err_resource:
|
|
||||||
pipe->sampler_view_release(pipe, vlsurface->sampler_view);
|
|
||||||
pipe_resource_reference(&res, NULL);
|
|
||||||
err_unlock:
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
DeviceReference(&vlsurface->device, NULL);
|
|
||||||
FREE(vlsurface);
|
|
||||||
return VDP_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a VdpOutputSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceDestroy(VdpOutputSurface surface)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *vlsurface;
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pipe = vlsurface->device->context;
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
pipe->sampler_view_release(pipe, vlsurface->sampler_view);
|
|
||||||
pipe->screen->fence_reference(pipe->screen, &vlsurface->fence, NULL);
|
|
||||||
vl_compositor_cleanup_state(&vlsurface->cstate);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
vlRemoveDataHTAB(surface);
|
|
||||||
DeviceReference(&vlsurface->device, NULL);
|
|
||||||
FREE(vlsurface);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the parameters used to create a VdpOutputSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceGetParameters(VdpOutputSurface surface,
|
|
||||||
VdpRGBAFormat *rgba_format,
|
|
||||||
uint32_t *width, uint32_t *height)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *vlsurface;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
*rgba_format = PipeToFormatRGBA(vlsurface->sampler_view->texture->format);
|
|
||||||
*width = vlsurface->sampler_view->texture->width0;
|
|
||||||
*height = vlsurface->sampler_view->texture->height0;
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy image data from a VdpOutputSurface to application memory in the
|
|
||||||
* surface's native format.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
|
|
||||||
VdpRect const *source_rect,
|
|
||||||
void *const *destination_data,
|
|
||||||
uint32_t const *destination_pitches)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *vlsurface;
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
struct pipe_resource *res;
|
|
||||||
struct pipe_box box;
|
|
||||||
struct pipe_transfer *transfer;
|
|
||||||
uint8_t *map;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pipe = vlsurface->device->context;
|
|
||||||
if (!pipe)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (!destination_data || !destination_pitches)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
res = vlsurface->sampler_view->texture;
|
|
||||||
box = RectToPipeBox(source_rect, res);
|
|
||||||
map = pipe->texture_map(pipe, res, 0, PIPE_MAP_READ, &box, &transfer);
|
|
||||||
if (!map) {
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
util_copy_rect(*destination_data, res->format, *destination_pitches, 0, 0,
|
|
||||||
box.width, box.height, map, transfer->stride, 0, 0);
|
|
||||||
|
|
||||||
pipe_texture_unmap(pipe, transfer);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy image data from application memory in the surface's native format to
|
|
||||||
* a VdpOutputSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface,
|
|
||||||
void const *const *source_data,
|
|
||||||
uint32_t const *source_pitches,
|
|
||||||
VdpRect const *destination_rect)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *vlsurface;
|
|
||||||
struct pipe_box dst_box;
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pipe = vlsurface->device->context;
|
|
||||||
if (!pipe)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (!source_data || !source_pitches)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
|
|
||||||
|
|
||||||
/* Check for a no-op. (application bug?) */
|
|
||||||
if (!dst_box.width || !dst_box.height) {
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
|
|
||||||
PIPE_MAP_WRITE, &dst_box, *source_data,
|
|
||||||
*source_pitches, 0);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy image data from application memory in a specific indexed format to
|
|
||||||
* a VdpOutputSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
|
|
||||||
VdpIndexedFormat source_indexed_format,
|
|
||||||
void const *const *source_data,
|
|
||||||
uint32_t const *source_pitch,
|
|
||||||
VdpRect const *destination_rect,
|
|
||||||
VdpColorTableFormat color_table_format,
|
|
||||||
void const *color_table)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *vlsurface;
|
|
||||||
struct pipe_context *context;
|
|
||||||
struct vl_compositor *compositor;
|
|
||||||
struct vl_compositor_state *cstate;
|
|
||||||
|
|
||||||
enum pipe_format index_format;
|
|
||||||
enum pipe_format colortbl_format;
|
|
||||||
|
|
||||||
struct pipe_resource *res, res_tmpl;
|
|
||||||
struct pipe_sampler_view sv_tmpl;
|
|
||||||
struct pipe_sampler_view *sv_idx = NULL, *sv_tbl = NULL;
|
|
||||||
|
|
||||||
struct pipe_box box;
|
|
||||||
struct u_rect dst_rect;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
context = vlsurface->device->context;
|
|
||||||
compositor = &vlsurface->device->compositor;
|
|
||||||
cstate = &vlsurface->cstate;
|
|
||||||
|
|
||||||
index_format = FormatIndexedToPipe(source_indexed_format);
|
|
||||||
if (index_format == PIPE_FORMAT_NONE)
|
|
||||||
return VDP_STATUS_INVALID_INDEXED_FORMAT;
|
|
||||||
|
|
||||||
if (!source_data || !source_pitch)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
colortbl_format = FormatColorTableToPipe(color_table_format);
|
|
||||||
if (colortbl_format == PIPE_FORMAT_NONE)
|
|
||||||
return VDP_STATUS_INVALID_COLOR_TABLE_FORMAT;
|
|
||||||
|
|
||||||
if (!color_table)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
memset(&res_tmpl, 0, sizeof(res_tmpl));
|
|
||||||
res_tmpl.target = PIPE_TEXTURE_2D;
|
|
||||||
res_tmpl.format = index_format;
|
|
||||||
|
|
||||||
if (destination_rect) {
|
|
||||||
if (destination_rect->x1 > destination_rect->x0 &&
|
|
||||||
destination_rect->y1 > destination_rect->y0) {
|
|
||||||
res_tmpl.width0 = destination_rect->x1 - destination_rect->x0;
|
|
||||||
res_tmpl.height0 = destination_rect->y1 - destination_rect->y0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
res_tmpl.width0 = vlsurface->surface.texture->width0;
|
|
||||||
res_tmpl.height0 = vlsurface->surface.texture->height0;
|
|
||||||
}
|
|
||||||
res_tmpl.depth0 = 1;
|
|
||||||
res_tmpl.array_size = 1;
|
|
||||||
res_tmpl.usage = PIPE_USAGE_STAGING;
|
|
||||||
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
if (!CheckSurfaceParams(context->screen, &res_tmpl))
|
|
||||||
goto error_resource;
|
|
||||||
|
|
||||||
res = context->screen->resource_create(context->screen, &res_tmpl);
|
|
||||||
if (!res)
|
|
||||||
goto error_resource;
|
|
||||||
|
|
||||||
box.x = box.y = box.z = 0;
|
|
||||||
box.width = res->width0;
|
|
||||||
box.height = res->height0;
|
|
||||||
box.depth = res->depth0;
|
|
||||||
|
|
||||||
context->texture_subdata(context, res, 0, PIPE_MAP_WRITE, &box,
|
|
||||||
source_data[0], source_pitch[0],
|
|
||||||
source_pitch[0] * res->height0);
|
|
||||||
|
|
||||||
memset(&sv_tmpl, 0, sizeof(sv_tmpl));
|
|
||||||
u_sampler_view_default_template(&sv_tmpl, res, res->format);
|
|
||||||
|
|
||||||
sv_idx = context->create_sampler_view(context, res, &sv_tmpl);
|
|
||||||
pipe_resource_reference(&res, NULL);
|
|
||||||
|
|
||||||
if (!sv_idx)
|
|
||||||
goto error_resource;
|
|
||||||
|
|
||||||
memset(&res_tmpl, 0, sizeof(res_tmpl));
|
|
||||||
res_tmpl.target = PIPE_TEXTURE_1D;
|
|
||||||
res_tmpl.format = colortbl_format;
|
|
||||||
res_tmpl.width0 = 1 << util_format_get_component_bits(
|
|
||||||
index_format, UTIL_FORMAT_COLORSPACE_RGB, 0);
|
|
||||||
res_tmpl.height0 = 1;
|
|
||||||
res_tmpl.depth0 = 1;
|
|
||||||
res_tmpl.array_size = 1;
|
|
||||||
res_tmpl.usage = PIPE_USAGE_STAGING;
|
|
||||||
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
|
|
||||||
|
|
||||||
res = context->screen->resource_create(context->screen, &res_tmpl);
|
|
||||||
if (!res)
|
|
||||||
goto error_resource;
|
|
||||||
|
|
||||||
box.x = box.y = box.z = 0;
|
|
||||||
box.width = res->width0;
|
|
||||||
box.height = res->height0;
|
|
||||||
box.depth = res->depth0;
|
|
||||||
|
|
||||||
context->texture_subdata(context, res, 0, PIPE_MAP_WRITE, &box, color_table,
|
|
||||||
util_format_get_stride(colortbl_format, res->width0), 0);
|
|
||||||
|
|
||||||
memset(&sv_tmpl, 0, sizeof(sv_tmpl));
|
|
||||||
u_sampler_view_default_template(&sv_tmpl, res, res->format);
|
|
||||||
|
|
||||||
sv_tbl = context->create_sampler_view(context, res, &sv_tmpl);
|
|
||||||
pipe_resource_reference(&res, NULL);
|
|
||||||
|
|
||||||
if (!sv_tbl)
|
|
||||||
goto error_resource;
|
|
||||||
|
|
||||||
vl_compositor_clear_layers(cstate);
|
|
||||||
vl_compositor_set_palette_layer(cstate, compositor, 0, sv_idx, sv_tbl, NULL, NULL, false);
|
|
||||||
vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
|
|
||||||
vl_compositor_render(cstate, compositor, &vlsurface->surface, &vlsurface->dirty_area, false);
|
|
||||||
|
|
||||||
context->sampler_view_release(context, sv_idx);
|
|
||||||
context->sampler_view_release(context, sv_tbl);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
|
|
||||||
error_resource:
|
|
||||||
context->sampler_view_release(context, sv_idx);
|
|
||||||
context->sampler_view_release(context, sv_tbl);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy image data from application memory in a specific YCbCr format to
|
|
||||||
* a VdpOutputSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
|
|
||||||
VdpYCbCrFormat source_ycbcr_format,
|
|
||||||
void const *const *source_data,
|
|
||||||
uint32_t const *source_pitches,
|
|
||||||
VdpRect const *destination_rect,
|
|
||||||
VdpCSCMatrix const *csc_matrix)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *vlsurface;
|
|
||||||
struct vl_compositor *compositor;
|
|
||||||
struct vl_compositor_state *cstate;
|
|
||||||
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
enum pipe_format format;
|
|
||||||
struct pipe_video_buffer vtmpl, *vbuffer;
|
|
||||||
struct u_rect dst_rect;
|
|
||||||
struct pipe_sampler_view **sampler_views;
|
|
||||||
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
|
|
||||||
pipe = vlsurface->device->context;
|
|
||||||
compositor = &vlsurface->device->compositor;
|
|
||||||
cstate = &vlsurface->cstate;
|
|
||||||
|
|
||||||
format = FormatYCBCRToPipe(source_ycbcr_format);
|
|
||||||
if (format == PIPE_FORMAT_NONE)
|
|
||||||
return VDP_STATUS_INVALID_Y_CB_CR_FORMAT;
|
|
||||||
|
|
||||||
if (!source_data || !source_pitches)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
memset(&vtmpl, 0, sizeof(vtmpl));
|
|
||||||
vtmpl.buffer_format = format;
|
|
||||||
|
|
||||||
if (destination_rect) {
|
|
||||||
if (destination_rect->x1 > destination_rect->x0 &&
|
|
||||||
destination_rect->y1 > destination_rect->y0) {
|
|
||||||
vtmpl.width = destination_rect->x1 - destination_rect->x0;
|
|
||||||
vtmpl.height = destination_rect->y1 - destination_rect->y0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vtmpl.width = vlsurface->surface.texture->width0;
|
|
||||||
vtmpl.height = vlsurface->surface.texture->height0;
|
|
||||||
}
|
|
||||||
|
|
||||||
vbuffer = pipe->create_video_buffer(pipe, &vtmpl);
|
|
||||||
if (!vbuffer) {
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
sampler_views = vbuffer->get_sampler_view_planes(vbuffer);
|
|
||||||
if (!sampler_views) {
|
|
||||||
vbuffer->destroy(vbuffer);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
|
||||||
struct pipe_sampler_view *sv = sampler_views[i];
|
|
||||||
if (!sv) continue;
|
|
||||||
|
|
||||||
struct pipe_box dst_box;
|
|
||||||
u_box_3d(0, 0, 0,
|
|
||||||
sv->texture->width0, sv->texture->height0, 1, &dst_box);
|
|
||||||
|
|
||||||
pipe->texture_subdata(pipe, sv->texture, 0, PIPE_MAP_WRITE, &dst_box,
|
|
||||||
source_data[i], source_pitches[i], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!csc_matrix) {
|
|
||||||
vl_csc_matrix csc;
|
|
||||||
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, 1, &csc);
|
|
||||||
if (!vl_compositor_set_csc_matrix(cstate, (const vl_csc_matrix*)&csc, 1.0f, 0.0f))
|
|
||||||
goto err_csc_matrix;
|
|
||||||
} else {
|
|
||||||
if (!vl_compositor_set_csc_matrix(cstate, csc_matrix, 1.0f, 0.0f))
|
|
||||||
goto err_csc_matrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
vl_compositor_clear_layers(cstate);
|
|
||||||
vl_compositor_set_buffer_layer(cstate, compositor, 0, vbuffer, NULL, NULL, VL_COMPOSITOR_WEAVE);
|
|
||||||
vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
|
|
||||||
vl_compositor_render(cstate, compositor, &vlsurface->surface, &vlsurface->dirty_area, false);
|
|
||||||
|
|
||||||
vbuffer->destroy(vbuffer);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
err_csc_matrix:
|
|
||||||
vbuffer->destroy(vbuffer);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned
|
|
||||||
BlendFactorToPipe(VdpOutputSurfaceRenderBlendFactor factor)
|
|
||||||
{
|
|
||||||
switch (factor) {
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO:
|
|
||||||
return PIPE_BLENDFACTOR_ZERO;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE:
|
|
||||||
return PIPE_BLENDFACTOR_ONE;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_COLOR:
|
|
||||||
return PIPE_BLENDFACTOR_SRC_COLOR;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_COLOR:
|
|
||||||
return PIPE_BLENDFACTOR_INV_SRC_COLOR;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA:
|
|
||||||
return PIPE_BLENDFACTOR_SRC_ALPHA;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA:
|
|
||||||
return PIPE_BLENDFACTOR_INV_SRC_ALPHA;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_DST_ALPHA:
|
|
||||||
return PIPE_BLENDFACTOR_DST_ALPHA;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_DST_ALPHA:
|
|
||||||
return PIPE_BLENDFACTOR_INV_DST_ALPHA;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_DST_COLOR:
|
|
||||||
return PIPE_BLENDFACTOR_DST_COLOR;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_DST_COLOR:
|
|
||||||
return PIPE_BLENDFACTOR_INV_DST_COLOR;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA_SATURATE:
|
|
||||||
return PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_CONSTANT_COLOR:
|
|
||||||
return PIPE_BLENDFACTOR_CONST_COLOR;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR:
|
|
||||||
return PIPE_BLENDFACTOR_INV_CONST_COLOR;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_CONSTANT_ALPHA:
|
|
||||||
return PIPE_BLENDFACTOR_CONST_ALPHA;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA:
|
|
||||||
return PIPE_BLENDFACTOR_INV_CONST_ALPHA;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return PIPE_BLENDFACTOR_ONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned
|
|
||||||
BlendEquationToPipe(VdpOutputSurfaceRenderBlendEquation equation)
|
|
||||||
{
|
|
||||||
switch (equation) {
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_SUBTRACT:
|
|
||||||
return PIPE_BLEND_SUBTRACT;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_REVERSE_SUBTRACT:
|
|
||||||
return PIPE_BLEND_REVERSE_SUBTRACT;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD:
|
|
||||||
return PIPE_BLEND_ADD;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_MIN:
|
|
||||||
return PIPE_BLEND_MIN;
|
|
||||||
case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_MAX:
|
|
||||||
return PIPE_BLEND_MAX;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return PIPE_BLEND_ADD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *
|
|
||||||
BlenderToPipe(struct pipe_context *context,
|
|
||||||
VdpOutputSurfaceRenderBlendState const *blend_state)
|
|
||||||
{
|
|
||||||
struct pipe_blend_state blend;
|
|
||||||
|
|
||||||
memset(&blend, 0, sizeof blend);
|
|
||||||
blend.independent_blend_enable = 0;
|
|
||||||
|
|
||||||
if (blend_state) {
|
|
||||||
blend.rt[0].blend_enable = 1;
|
|
||||||
blend.rt[0].rgb_src_factor = BlendFactorToPipe(blend_state->blend_factor_source_color);
|
|
||||||
blend.rt[0].rgb_dst_factor = BlendFactorToPipe(blend_state->blend_factor_destination_color);
|
|
||||||
blend.rt[0].alpha_src_factor = BlendFactorToPipe(blend_state->blend_factor_source_alpha);
|
|
||||||
blend.rt[0].alpha_dst_factor = BlendFactorToPipe(blend_state->blend_factor_destination_alpha);
|
|
||||||
blend.rt[0].rgb_func = BlendEquationToPipe(blend_state->blend_equation_color);
|
|
||||||
blend.rt[0].alpha_func = BlendEquationToPipe(blend_state->blend_equation_alpha);
|
|
||||||
} else {
|
|
||||||
blend.rt[0].blend_enable = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
blend.logicop_enable = 0;
|
|
||||||
blend.logicop_func = PIPE_LOGICOP_CLEAR;
|
|
||||||
blend.rt[0].colormask = PIPE_MASK_RGBA;
|
|
||||||
blend.dither = 0;
|
|
||||||
|
|
||||||
return context->create_blend_state(context, &blend);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct vertex4f *
|
|
||||||
ColorsToPipe(VdpColor const *colors, uint32_t flags, struct vertex4f result[4])
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
struct vertex4f *dst = result;
|
|
||||||
|
|
||||||
if (!colors)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < 4; ++i) {
|
|
||||||
dst->x = colors->red;
|
|
||||||
dst->y = colors->green;
|
|
||||||
dst->z = colors->blue;
|
|
||||||
dst->w = colors->alpha;
|
|
||||||
|
|
||||||
++dst;
|
|
||||||
if (flags & VDP_OUTPUT_SURFACE_RENDER_COLOR_PER_VERTEX)
|
|
||||||
++colors;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Composite a sub-rectangle of a VdpOutputSurface into a sub-rectangle of
|
|
||||||
* another VdpOutputSurface; Output Surface object VdpOutputSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
|
|
||||||
VdpRect const *destination_rect,
|
|
||||||
VdpOutputSurface source_surface,
|
|
||||||
VdpRect const *source_rect,
|
|
||||||
VdpColor const *colors,
|
|
||||||
VdpOutputSurfaceRenderBlendState const *blend_state,
|
|
||||||
uint32_t flags)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *dst_vlsurface;
|
|
||||||
|
|
||||||
struct pipe_context *context;
|
|
||||||
struct pipe_sampler_view *src_sv;
|
|
||||||
struct vl_compositor *compositor;
|
|
||||||
struct vl_compositor_state *cstate;
|
|
||||||
|
|
||||||
struct u_rect src_rect, dst_rect;
|
|
||||||
|
|
||||||
struct vertex4f vlcolors[4];
|
|
||||||
void *blend;
|
|
||||||
|
|
||||||
dst_vlsurface = vlGetDataHTAB(destination_surface);
|
|
||||||
if (!dst_vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (source_surface == VDP_INVALID_HANDLE) {
|
|
||||||
src_sv = dst_vlsurface->device->dummy_sv;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
vlVdpOutputSurface *src_vlsurface = vlGetDataHTAB(source_surface);
|
|
||||||
if (!src_vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (dst_vlsurface->device != src_vlsurface->device)
|
|
||||||
return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
|
|
||||||
|
|
||||||
src_sv = src_vlsurface->sampler_view;
|
|
||||||
}
|
|
||||||
|
|
||||||
mtx_lock(&dst_vlsurface->device->mutex);
|
|
||||||
|
|
||||||
context = dst_vlsurface->device->context;
|
|
||||||
compositor = &dst_vlsurface->device->compositor;
|
|
||||||
cstate = &dst_vlsurface->cstate;
|
|
||||||
|
|
||||||
blend = BlenderToPipe(context, blend_state);
|
|
||||||
|
|
||||||
vl_compositor_clear_layers(cstate);
|
|
||||||
vl_compositor_set_layer_blend(cstate, 0, blend, false);
|
|
||||||
vl_compositor_set_rgba_layer(cstate, compositor, 0, src_sv,
|
|
||||||
RectToPipe(source_rect, &src_rect), NULL,
|
|
||||||
ColorsToPipe(colors, flags, vlcolors));
|
|
||||||
STATIC_ASSERT(VL_COMPOSITOR_ROTATE_0 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_0);
|
|
||||||
STATIC_ASSERT(VL_COMPOSITOR_ROTATE_90 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_90);
|
|
||||||
STATIC_ASSERT(VL_COMPOSITOR_ROTATE_180 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_180);
|
|
||||||
STATIC_ASSERT(VL_COMPOSITOR_ROTATE_270 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_270);
|
|
||||||
vl_compositor_set_layer_rotation(cstate, 0, flags & 3);
|
|
||||||
vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
|
|
||||||
vl_compositor_render(cstate, compositor, &dst_vlsurface->surface, &dst_vlsurface->dirty_area, false);
|
|
||||||
|
|
||||||
context->delete_blend_state(context, blend);
|
|
||||||
mtx_unlock(&dst_vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Composite a sub-rectangle of a VdpBitmapSurface into a sub-rectangle of
|
|
||||||
* a VdpOutputSurface; Output Surface object VdpOutputSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
|
|
||||||
VdpRect const *destination_rect,
|
|
||||||
VdpBitmapSurface source_surface,
|
|
||||||
VdpRect const *source_rect,
|
|
||||||
VdpColor const *colors,
|
|
||||||
VdpOutputSurfaceRenderBlendState const *blend_state,
|
|
||||||
uint32_t flags)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *dst_vlsurface;
|
|
||||||
|
|
||||||
struct pipe_context *context;
|
|
||||||
struct pipe_sampler_view *src_sv;
|
|
||||||
struct vl_compositor *compositor;
|
|
||||||
struct vl_compositor_state *cstate;
|
|
||||||
|
|
||||||
struct u_rect src_rect, dst_rect;
|
|
||||||
|
|
||||||
struct vertex4f vlcolors[4];
|
|
||||||
void *blend;
|
|
||||||
|
|
||||||
dst_vlsurface = vlGetDataHTAB(destination_surface);
|
|
||||||
if (!dst_vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (source_surface == VDP_INVALID_HANDLE) {
|
|
||||||
src_sv = dst_vlsurface->device->dummy_sv;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
vlVdpBitmapSurface *src_vlsurface = vlGetDataHTAB(source_surface);
|
|
||||||
if (!src_vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (dst_vlsurface->device != src_vlsurface->device)
|
|
||||||
return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
|
|
||||||
|
|
||||||
src_sv = src_vlsurface->sampler_view;
|
|
||||||
}
|
|
||||||
|
|
||||||
context = dst_vlsurface->device->context;
|
|
||||||
compositor = &dst_vlsurface->device->compositor;
|
|
||||||
cstate = &dst_vlsurface->cstate;
|
|
||||||
|
|
||||||
mtx_lock(&dst_vlsurface->device->mutex);
|
|
||||||
|
|
||||||
blend = BlenderToPipe(context, blend_state);
|
|
||||||
|
|
||||||
vl_compositor_clear_layers(cstate);
|
|
||||||
vl_compositor_set_layer_blend(cstate, 0, blend, false);
|
|
||||||
vl_compositor_set_rgba_layer(cstate, compositor, 0, src_sv,
|
|
||||||
RectToPipe(source_rect, &src_rect), NULL,
|
|
||||||
ColorsToPipe(colors, flags, vlcolors));
|
|
||||||
vl_compositor_set_layer_rotation(cstate, 0, flags & 3);
|
|
||||||
vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
|
|
||||||
vl_compositor_render(cstate, compositor, &dst_vlsurface->surface, &dst_vlsurface->dirty_area, false);
|
|
||||||
|
|
||||||
context->delete_blend_state(context, blend);
|
|
||||||
mtx_unlock(&dst_vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct pipe_resource *vlVdpOutputSurfaceGallium(VdpOutputSurface surface)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *vlsurface;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface || !vlsurface->surface.texture)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return vlsurface->surface.texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface,
|
|
||||||
struct VdpSurfaceDMABufDesc *result)
|
|
||||||
{
|
|
||||||
vlVdpOutputSurface *vlsurface;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
struct winsys_handle whandle;
|
|
||||||
|
|
||||||
memset(result, 0, sizeof(*result));
|
|
||||||
result->handle = -1;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface || !vlsurface->surface.texture)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
|
|
||||||
|
|
||||||
memset(&whandle, 0, sizeof(struct winsys_handle));
|
|
||||||
whandle.type = WINSYS_HANDLE_TYPE_FD;
|
|
||||||
|
|
||||||
pscreen = vlsurface->surface.texture->screen;
|
|
||||||
if (!pscreen->resource_get_handle(pscreen, vlsurface->device->context,
|
|
||||||
vlsurface->surface.texture, &whandle,
|
|
||||||
PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) {
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
result->handle = whandle.handle;
|
|
||||||
result->width = pipe_surface_width(&vlsurface->surface);
|
|
||||||
result->height = pipe_surface_height(&vlsurface->surface);
|
|
||||||
result->offset = whandle.offset;
|
|
||||||
result->stride = whandle.stride;
|
|
||||||
result->format = PipeToFormatRGBA(vlsurface->surface.format);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Thomas Balling Sørensen.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include <vdpau/vdpau.h>
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A callback to notify the client application that a device's display has
|
|
||||||
* been preempted.
|
|
||||||
*/
|
|
||||||
void vlVdpPreemptionCallback(VdpDevice device, void *context)
|
|
||||||
{
|
|
||||||
/* TODO: Implement preemption */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the display preemption callback.
|
|
||||||
*/
|
|
||||||
VdpStatus vlVdpPreemptionCallbackRegister(VdpDevice device,
|
|
||||||
VdpPreemptionCallback callback,
|
|
||||||
void *context)
|
|
||||||
{
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
@ -1,382 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Thomas Balling Sørensen.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <vdpau/vdpau.h>
|
|
||||||
|
|
||||||
#include "util/u_debug.h"
|
|
||||||
#include "util/u_memory.h"
|
|
||||||
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a VdpPresentationQueue.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueCreate(VdpDevice device,
|
|
||||||
VdpPresentationQueueTarget presentation_queue_target,
|
|
||||||
VdpPresentationQueue *presentation_queue)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueue *pq = NULL;
|
|
||||||
VdpStatus ret;
|
|
||||||
|
|
||||||
if (!presentation_queue)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
vlVdpDevice *dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
vlVdpPresentationQueueTarget *pqt = vlGetDataHTAB(presentation_queue_target);
|
|
||||||
if (!pqt)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (dev != pqt->device)
|
|
||||||
return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
|
|
||||||
|
|
||||||
pq = CALLOC(1, sizeof(vlVdpPresentationQueue));
|
|
||||||
if (!pq)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
DeviceReference(&pq->device, dev);
|
|
||||||
pq->drawable = pqt->drawable;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
if (!vl_compositor_init_state(&pq->cstate, dev->context)) {
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
ret = VDP_STATUS_ERROR;
|
|
||||||
goto no_compositor;
|
|
||||||
}
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
*presentation_queue = vlAddDataHTAB(pq);
|
|
||||||
if (*presentation_queue == 0) {
|
|
||||||
ret = VDP_STATUS_ERROR;
|
|
||||||
goto no_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
|
|
||||||
no_handle:
|
|
||||||
no_compositor:
|
|
||||||
DeviceReference(&pq->device, NULL);
|
|
||||||
FREE(pq);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a VdpPresentationQueue.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueDestroy(VdpPresentationQueue presentation_queue)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueue *pq;
|
|
||||||
|
|
||||||
pq = vlGetDataHTAB(presentation_queue);
|
|
||||||
if (!pq)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
mtx_lock(&pq->device->mutex);
|
|
||||||
vl_compositor_cleanup_state(&pq->cstate);
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
|
|
||||||
vlRemoveDataHTAB(presentation_queue);
|
|
||||||
DeviceReference(&pq->device, NULL);
|
|
||||||
FREE(pq);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the background color setting.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue,
|
|
||||||
VdpColor *const background_color)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueue *pq;
|
|
||||||
union pipe_color_union color;
|
|
||||||
|
|
||||||
if (!background_color)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
pq = vlGetDataHTAB(presentation_queue);
|
|
||||||
if (!pq)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
color.f[0] = background_color->red;
|
|
||||||
color.f[1] = background_color->green;
|
|
||||||
color.f[2] = background_color->blue;
|
|
||||||
color.f[3] = background_color->alpha;
|
|
||||||
|
|
||||||
mtx_lock(&pq->device->mutex);
|
|
||||||
vl_compositor_set_clear_color(&pq->cstate, &color);
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the current background color setting.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue,
|
|
||||||
VdpColor *const background_color)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueue *pq;
|
|
||||||
union pipe_color_union color;
|
|
||||||
|
|
||||||
if (!background_color)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
pq = vlGetDataHTAB(presentation_queue);
|
|
||||||
if (!pq)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
mtx_lock(&pq->device->mutex);
|
|
||||||
vl_compositor_get_clear_color(&pq->cstate, &color);
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
|
|
||||||
background_color->red = color.f[0];
|
|
||||||
background_color->green = color.f[1];
|
|
||||||
background_color->blue = color.f[2];
|
|
||||||
background_color->alpha = color.f[3];
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the presentation queue's "current" time.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueGetTime(VdpPresentationQueue presentation_queue,
|
|
||||||
VdpTime *current_time)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueue *pq;
|
|
||||||
|
|
||||||
if (!current_time)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
pq = vlGetDataHTAB(presentation_queue);
|
|
||||||
if (!pq)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
mtx_lock(&pq->device->mutex);
|
|
||||||
*current_time = pq->device->vscreen->get_timestamp(pq->device->vscreen,
|
|
||||||
(void *)pq->drawable);
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enter a surface into the presentation queue.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
|
|
||||||
VdpOutputSurface surface,
|
|
||||||
uint32_t clip_width,
|
|
||||||
uint32_t clip_height,
|
|
||||||
VdpTime earliest_presentation_time)
|
|
||||||
{
|
|
||||||
static int dump_window = -1;
|
|
||||||
|
|
||||||
vlVdpPresentationQueue *pq;
|
|
||||||
vlVdpOutputSurface *surf;
|
|
||||||
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
struct pipe_resource *tex;
|
|
||||||
struct pipe_surface surf_templ;
|
|
||||||
struct u_rect src_rect, dst_clip, *dirty_area;
|
|
||||||
|
|
||||||
struct vl_compositor *compositor;
|
|
||||||
struct vl_compositor_state *cstate;
|
|
||||||
struct vl_screen *vscreen;
|
|
||||||
|
|
||||||
pq = vlGetDataHTAB(presentation_queue);
|
|
||||||
if (!pq)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
surf = vlGetDataHTAB(surface);
|
|
||||||
if (!surf)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pipe = pq->device->context;
|
|
||||||
compositor = &pq->device->compositor;
|
|
||||||
cstate = &pq->cstate;
|
|
||||||
vscreen = pq->device->vscreen;
|
|
||||||
|
|
||||||
mtx_lock(&pq->device->mutex);
|
|
||||||
if (vscreen->set_back_texture_from_output && surf->send_to_X)
|
|
||||||
vscreen->set_back_texture_from_output(vscreen, surf->surface.texture, clip_width, clip_height);
|
|
||||||
tex = vscreen->texture_from_drawable(vscreen, (void *)pq->drawable);
|
|
||||||
if (!tex) {
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vscreen->set_back_texture_from_output || !surf->send_to_X) {
|
|
||||||
dirty_area = vscreen->get_dirty_area(vscreen);
|
|
||||||
|
|
||||||
memset(&surf_templ, 0, sizeof(surf_templ));
|
|
||||||
u_surface_default_template(&surf_templ, tex);
|
|
||||||
|
|
||||||
dst_clip.x0 = 0;
|
|
||||||
dst_clip.y0 = 0;
|
|
||||||
dst_clip.x1 = clip_width ? clip_width : pipe_surface_width(&surf_templ);
|
|
||||||
dst_clip.y1 = clip_height ? clip_height : pipe_surface_height(&surf_templ);
|
|
||||||
|
|
||||||
src_rect.x0 = 0;
|
|
||||||
src_rect.y0 = 0;
|
|
||||||
src_rect.x1 = pipe_surface_width(&surf_templ);
|
|
||||||
src_rect.y1 = pipe_surface_height(&surf_templ);
|
|
||||||
|
|
||||||
vl_compositor_clear_layers(cstate);
|
|
||||||
vl_compositor_set_rgba_layer(cstate, compositor, 0, surf->sampler_view, &src_rect, NULL, NULL);
|
|
||||||
vl_compositor_set_dst_clip(cstate, &dst_clip);
|
|
||||||
vl_compositor_render(cstate, compositor, &surf_templ, dirty_area, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
vscreen->set_next_timestamp(vscreen, earliest_presentation_time);
|
|
||||||
|
|
||||||
// flush before calling flush_frontbuffer so that rendering is flushed
|
|
||||||
// to back buffer so the texture can be copied in flush_frontbuffer
|
|
||||||
pipe->screen->fence_reference(pipe->screen, &surf->fence, NULL);
|
|
||||||
pipe->flush(pipe, &surf->fence, 0);
|
|
||||||
pipe->screen->flush_frontbuffer(pipe->screen, pipe, tex, 0, 0,
|
|
||||||
vscreen->get_private(vscreen), 0, NULL);
|
|
||||||
|
|
||||||
pq->last_surf = surf;
|
|
||||||
|
|
||||||
if (dump_window == -1) {
|
|
||||||
dump_window = debug_get_num_option("VDPAU_DUMP", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dump_window) {
|
|
||||||
static unsigned int framenum = 0;
|
|
||||||
char cmd[256];
|
|
||||||
|
|
||||||
if (framenum) {
|
|
||||||
sprintf(cmd, "xwd -id %d -silent -out vdpau_frame_%08d.xwd", (int)pq->drawable, framenum);
|
|
||||||
if (system(cmd) != 0)
|
|
||||||
VDPAU_MSG(VDPAU_ERR, "[VDPAU] Dumping surface %d failed.\n", surface);
|
|
||||||
}
|
|
||||||
framenum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vscreen->set_back_texture_from_output || !surf->send_to_X) {
|
|
||||||
pipe_resource_reference(&tex, NULL);
|
|
||||||
}
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wait for a surface to finish being displayed.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueBlockUntilSurfaceIdle(VdpPresentationQueue presentation_queue,
|
|
||||||
VdpOutputSurface surface,
|
|
||||||
VdpTime *first_presentation_time)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueue *pq;
|
|
||||||
vlVdpOutputSurface *surf;
|
|
||||||
struct pipe_screen *screen;
|
|
||||||
|
|
||||||
if (!first_presentation_time)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
pq = vlGetDataHTAB(presentation_queue);
|
|
||||||
if (!pq)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
surf = vlGetDataHTAB(surface);
|
|
||||||
if (!surf)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
mtx_lock(&pq->device->mutex);
|
|
||||||
if (surf->fence) {
|
|
||||||
screen = pq->device->vscreen->pscreen;
|
|
||||||
screen->fence_finish(screen, NULL, surf->fence, OS_TIMEOUT_INFINITE);
|
|
||||||
screen->fence_reference(screen, &surf->fence, NULL);
|
|
||||||
}
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
|
|
||||||
return vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Poll the current queue status of a surface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpPresentationQueueQuerySurfaceStatus(VdpPresentationQueue presentation_queue,
|
|
||||||
VdpOutputSurface surface,
|
|
||||||
VdpPresentationQueueStatus *status,
|
|
||||||
VdpTime *first_presentation_time)
|
|
||||||
{
|
|
||||||
vlVdpPresentationQueue *pq;
|
|
||||||
vlVdpOutputSurface *surf;
|
|
||||||
struct pipe_screen *screen;
|
|
||||||
|
|
||||||
if (!(status && first_presentation_time))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
pq = vlGetDataHTAB(presentation_queue);
|
|
||||||
if (!pq)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
surf = vlGetDataHTAB(surface);
|
|
||||||
if (!surf)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
*first_presentation_time = 0;
|
|
||||||
|
|
||||||
if (!surf->fence) {
|
|
||||||
if (pq->last_surf == surf)
|
|
||||||
*status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE;
|
|
||||||
else
|
|
||||||
*status = VDP_PRESENTATION_QUEUE_STATUS_IDLE;
|
|
||||||
} else {
|
|
||||||
mtx_lock(&pq->device->mutex);
|
|
||||||
screen = pq->device->vscreen->pscreen;
|
|
||||||
if (screen->fence_finish(screen, NULL, surf->fence, 0)) {
|
|
||||||
screen->fence_reference(screen, &surf->fence, NULL);
|
|
||||||
*status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE;
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
|
|
||||||
// We actually need to query the timestamp of the last VSYNC event from the hardware
|
|
||||||
vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time);
|
|
||||||
*first_presentation_time += 1;
|
|
||||||
} else {
|
|
||||||
*status = VDP_PRESENTATION_QUEUE_STATUS_QUEUED;
|
|
||||||
mtx_unlock(&pq->device->mutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
@ -1,630 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Younes Manton.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
#include "pipe/p_screen.h"
|
|
||||||
#include "pipe/p_defines.h"
|
|
||||||
#include "util/u_debug.h"
|
|
||||||
|
|
||||||
#include "vl/vl_codec.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the VDPAU version implemented by the backend.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpGetApiVersion(uint32_t *api_version)
|
|
||||||
{
|
|
||||||
if (!api_version)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
*api_version = 1;
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve an implementation-specific string description of the implementation.
|
|
||||||
* This typically includes detailed version information.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpGetInformationString(char const **information_string)
|
|
||||||
{
|
|
||||||
if (!information_string)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
*information_string = INFORMATION_STRING;
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's VdpVideoSurface capabilities.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
|
|
||||||
VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
uint32_t max_2d_texture_size;
|
|
||||||
|
|
||||||
if (!(is_supported && max_width && max_height))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
if (!pscreen)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
|
|
||||||
/* XXX: Current limits */
|
|
||||||
*is_supported = true;
|
|
||||||
max_2d_texture_size = pscreen->caps.max_texture_2d_size;
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
if (!max_2d_texture_size)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
*max_width = *max_height = max_2d_texture_size;
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's VdpVideoSurface GetBits/PutBits capabilities.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
|
|
||||||
VdpYCbCrFormat bits_ycbcr_format,
|
|
||||||
VdpBool *is_supported)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
VdpYCbCrFormat ycbcrFormat;
|
|
||||||
bool supported;
|
|
||||||
|
|
||||||
if (!is_supported)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
if (!pscreen)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
|
|
||||||
ycbcrFormat = bits_ycbcr_format;
|
|
||||||
switch(bits_ycbcr_format) {
|
|
||||||
case VDP_YCBCR_FORMAT_NV12:
|
|
||||||
supported = surface_chroma_type == VDP_CHROMA_TYPE_420;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VDP_YCBCR_FORMAT_YV12:
|
|
||||||
supported = surface_chroma_type == VDP_CHROMA_TYPE_420;
|
|
||||||
|
|
||||||
/* We can convert YV12 to NV12 on the fly! */
|
|
||||||
ycbcrFormat = VDP_YCBCR_FORMAT_NV12;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VDP_YCBCR_FORMAT_UYVY:
|
|
||||||
case VDP_YCBCR_FORMAT_YUYV:
|
|
||||||
supported = surface_chroma_type == VDP_CHROMA_TYPE_422;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VDP_YCBCR_FORMAT_Y8U8V8A8:
|
|
||||||
case VDP_YCBCR_FORMAT_V8U8Y8A8:
|
|
||||||
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;
|
|
||||||
|
|
||||||
default:
|
|
||||||
supported = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (supported &&
|
|
||||||
!pscreen->is_video_format_supported(pscreen,
|
|
||||||
FormatYCBCRToPipe(ycbcrFormat),
|
|
||||||
PIPE_VIDEO_PROFILE_UNKNOWN,
|
|
||||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) {
|
|
||||||
supported = false;
|
|
||||||
}
|
|
||||||
*is_supported = supported;
|
|
||||||
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's VdpDecoder capabilities.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
|
|
||||||
VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks,
|
|
||||||
uint32_t *max_width, uint32_t *max_height)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
enum pipe_video_profile p_profile;
|
|
||||||
|
|
||||||
if (!(is_supported && max_level && max_macroblocks && max_width && max_height))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
if (!pscreen)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
p_profile = ProfileToPipe(profile);
|
|
||||||
if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
|
|
||||||
*is_supported = false;
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
*is_supported = vl_codec_supported(pscreen, p_profile, false);
|
|
||||||
if (*is_supported) {
|
|
||||||
*max_width = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
|
||||||
PIPE_VIDEO_CAP_MAX_WIDTH);
|
|
||||||
*max_height = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
|
||||||
PIPE_VIDEO_CAP_MAX_HEIGHT);
|
|
||||||
*max_level = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
|
||||||
PIPE_VIDEO_CAP_MAX_LEVEL);
|
|
||||||
*max_macroblocks = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
|
||||||
PIPE_VIDEO_CAP_MAX_MACROBLOCKS);
|
|
||||||
if (*max_macroblocks == 0) {
|
|
||||||
*max_macroblocks = (*max_width/16)*(*max_height/16);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*max_width = 0;
|
|
||||||
*max_height = 0;
|
|
||||||
*max_level = 0;
|
|
||||||
*max_macroblocks = 0;
|
|
||||||
}
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's VdpOutputSurface capabilities.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
|
|
||||||
VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
enum pipe_format format;
|
|
||||||
|
|
||||||
dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
if (!pscreen)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
format = VdpFormatRGBAToPipe(surface_rgba_format);
|
|
||||||
if (format == PIPE_FORMAT_NONE || format == PIPE_FORMAT_A8_UNORM)
|
|
||||||
return VDP_STATUS_INVALID_RGBA_FORMAT;
|
|
||||||
|
|
||||||
if (!(is_supported && max_width && max_height))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
*is_supported = pscreen->is_format_supported
|
|
||||||
(
|
|
||||||
pscreen, format, PIPE_TEXTURE_2D, 1, 1,
|
|
||||||
PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
|
|
||||||
);
|
|
||||||
if (*is_supported) {
|
|
||||||
uint32_t max_2d_texture_size = pscreen->caps.max_texture_2d_size;
|
|
||||||
|
|
||||||
if (!max_2d_texture_size) {
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
return VDP_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
*max_width = *max_height = max_2d_texture_size;
|
|
||||||
} else {
|
|
||||||
*max_width = 0;
|
|
||||||
*max_height = 0;
|
|
||||||
}
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's capability to perform a PutBits operation using
|
|
||||||
* application data matching the surface's format.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
|
|
||||||
VdpBool *is_supported)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
enum pipe_format format;
|
|
||||||
|
|
||||||
dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
if (!pscreen)
|
|
||||||
return VDP_STATUS_ERROR;
|
|
||||||
|
|
||||||
format = VdpFormatRGBAToPipe(surface_rgba_format);
|
|
||||||
if (format == PIPE_FORMAT_NONE || format == PIPE_FORMAT_A8_UNORM)
|
|
||||||
return VDP_STATUS_INVALID_RGBA_FORMAT;
|
|
||||||
|
|
||||||
if (!is_supported)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
*is_supported = pscreen->is_format_supported
|
|
||||||
(
|
|
||||||
pscreen, format, PIPE_TEXTURE_2D, 1, 1,
|
|
||||||
PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
|
|
||||||
);
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's capability to perform a PutBits operation using
|
|
||||||
* application data in a specific indexed format.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device,
|
|
||||||
VdpRGBAFormat surface_rgba_format,
|
|
||||||
VdpIndexedFormat bits_indexed_format,
|
|
||||||
VdpColorTableFormat color_table_format,
|
|
||||||
VdpBool *is_supported)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
enum pipe_format rgba_format, index_format, colortbl_format;
|
|
||||||
|
|
||||||
dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
if (!pscreen)
|
|
||||||
return VDP_STATUS_ERROR;
|
|
||||||
|
|
||||||
rgba_format = VdpFormatRGBAToPipe(surface_rgba_format);
|
|
||||||
if (rgba_format == PIPE_FORMAT_NONE || rgba_format == PIPE_FORMAT_A8_UNORM)
|
|
||||||
return VDP_STATUS_INVALID_RGBA_FORMAT;
|
|
||||||
|
|
||||||
index_format = FormatIndexedToPipe(bits_indexed_format);
|
|
||||||
if (index_format == PIPE_FORMAT_NONE)
|
|
||||||
return VDP_STATUS_INVALID_INDEXED_FORMAT;
|
|
||||||
|
|
||||||
colortbl_format = FormatColorTableToPipe(color_table_format);
|
|
||||||
if (colortbl_format == PIPE_FORMAT_NONE)
|
|
||||||
return VDP_STATUS_INVALID_COLOR_TABLE_FORMAT;
|
|
||||||
|
|
||||||
if (!is_supported)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
*is_supported = pscreen->is_format_supported
|
|
||||||
(
|
|
||||||
pscreen, rgba_format, PIPE_TEXTURE_2D, 1, 1,
|
|
||||||
PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
|
|
||||||
);
|
|
||||||
|
|
||||||
*is_supported &= pscreen->is_format_supported
|
|
||||||
(
|
|
||||||
pscreen, index_format, PIPE_TEXTURE_2D, 1, 1,
|
|
||||||
PIPE_BIND_SAMPLER_VIEW
|
|
||||||
);
|
|
||||||
|
|
||||||
*is_supported &= pscreen->is_format_supported
|
|
||||||
(
|
|
||||||
pscreen, colortbl_format, PIPE_TEXTURE_1D, 1, 1,
|
|
||||||
PIPE_BIND_SAMPLER_VIEW
|
|
||||||
);
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's capability to perform a PutBits operation using
|
|
||||||
* application data in a specific YCbCr/YUB format.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
|
|
||||||
VdpYCbCrFormat bits_ycbcr_format,
|
|
||||||
VdpBool *is_supported)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
enum pipe_format rgba_format, ycbcr_format;
|
|
||||||
|
|
||||||
dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
if (!pscreen)
|
|
||||||
return VDP_STATUS_ERROR;
|
|
||||||
|
|
||||||
rgba_format = VdpFormatRGBAToPipe(surface_rgba_format);
|
|
||||||
if (rgba_format == PIPE_FORMAT_NONE || rgba_format == PIPE_FORMAT_A8_UNORM)
|
|
||||||
return VDP_STATUS_INVALID_RGBA_FORMAT;
|
|
||||||
|
|
||||||
ycbcr_format = FormatYCBCRToPipe(bits_ycbcr_format);
|
|
||||||
if (ycbcr_format == PIPE_FORMAT_NONE)
|
|
||||||
return VDP_STATUS_INVALID_INDEXED_FORMAT;
|
|
||||||
|
|
||||||
if (!is_supported)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
*is_supported = pscreen->is_format_supported
|
|
||||||
(
|
|
||||||
pscreen, rgba_format, PIPE_TEXTURE_2D, 1, 1,
|
|
||||||
PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
|
|
||||||
);
|
|
||||||
|
|
||||||
*is_supported &= pscreen->is_video_format_supported
|
|
||||||
(
|
|
||||||
pscreen, ycbcr_format,
|
|
||||||
PIPE_VIDEO_PROFILE_UNKNOWN,
|
|
||||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM
|
|
||||||
);
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's VdpBitmapSurface capabilities.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
|
|
||||||
VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev;
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
enum pipe_format format;
|
|
||||||
|
|
||||||
dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pscreen = dev->vscreen->pscreen;
|
|
||||||
if (!pscreen)
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
|
|
||||||
format = VdpFormatRGBAToPipe(surface_rgba_format);
|
|
||||||
if (format == PIPE_FORMAT_NONE)
|
|
||||||
return VDP_STATUS_INVALID_RGBA_FORMAT;
|
|
||||||
|
|
||||||
if (!(is_supported && max_width && max_height))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
*is_supported = pscreen->is_format_supported
|
|
||||||
(
|
|
||||||
pscreen, format, PIPE_TEXTURE_2D, 1, 1,
|
|
||||||
PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
|
|
||||||
);
|
|
||||||
if (*is_supported) {
|
|
||||||
uint32_t max_2d_texture_size = pscreen->caps.max_texture_2d_size;
|
|
||||||
|
|
||||||
if (!max_2d_texture_size) {
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
return VDP_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
*max_width = *max_height = max_2d_texture_size;
|
|
||||||
} else {
|
|
||||||
*max_width = 0;
|
|
||||||
*max_height = 0;
|
|
||||||
}
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's support for a specific feature.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature,
|
|
||||||
VdpBool *is_supported)
|
|
||||||
{
|
|
||||||
if (!is_supported)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
switch (feature) {
|
|
||||||
case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
|
|
||||||
case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
|
|
||||||
case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
|
|
||||||
case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
|
|
||||||
case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
|
|
||||||
*is_supported = VDP_TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
*is_supported = VDP_FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's support for a specific parameter.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter,
|
|
||||||
VdpBool *is_supported)
|
|
||||||
{
|
|
||||||
if (!is_supported)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
switch (parameter) {
|
|
||||||
case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH:
|
|
||||||
case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT:
|
|
||||||
case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE:
|
|
||||||
case VDP_VIDEO_MIXER_PARAMETER_LAYERS:
|
|
||||||
*is_supported = VDP_TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
*is_supported = VDP_FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's supported for a specific parameter.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter,
|
|
||||||
void *min_value, void *max_value)
|
|
||||||
{
|
|
||||||
vlVdpDevice *dev = vlGetDataHTAB(device);
|
|
||||||
struct pipe_screen *screen;
|
|
||||||
|
|
||||||
if (!dev)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
if (!(min_value && max_value))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
screen = dev->vscreen->pscreen;
|
|
||||||
switch (parameter) {
|
|
||||||
case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH:
|
|
||||||
*(uint32_t*)min_value = 48;
|
|
||||||
*(uint32_t*)max_value = screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN,
|
|
||||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
|
||||||
PIPE_VIDEO_CAP_MAX_WIDTH);
|
|
||||||
break;
|
|
||||||
case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT:
|
|
||||||
*(uint32_t*)min_value = 48;
|
|
||||||
*(uint32_t*)max_value = screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN,
|
|
||||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
|
||||||
PIPE_VIDEO_CAP_MAX_HEIGHT);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VDP_VIDEO_MIXER_PARAMETER_LAYERS:
|
|
||||||
*(uint32_t*)min_value = 0;
|
|
||||||
*(uint32_t*)max_value = 4;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE:
|
|
||||||
default:
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
return VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER;
|
|
||||||
}
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's support for a specific attribute.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute,
|
|
||||||
VdpBool *is_supported)
|
|
||||||
{
|
|
||||||
if (!is_supported)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
switch (attribute) {
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
|
|
||||||
*is_supported = VDP_TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
*is_supported = VDP_FALSE;
|
|
||||||
}
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the implementation's supported for a specific attribute.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute,
|
|
||||||
void *min_value, void *max_value)
|
|
||||||
{
|
|
||||||
if (!(min_value && max_value))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
switch (attribute) {
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
|
|
||||||
*(float*)min_value = 0.0f;
|
|
||||||
*(float*)max_value = 1.0f;
|
|
||||||
break;
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
|
|
||||||
*(float*)min_value = -1.0f;
|
|
||||||
*(float*)max_value = 1.0f;
|
|
||||||
break;
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
|
|
||||||
*(uint8_t*)min_value = 0;
|
|
||||||
*(uint8_t*)max_value = 1;
|
|
||||||
break;
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
|
|
||||||
case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
|
|
||||||
default:
|
|
||||||
return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
|
|
||||||
}
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
@ -1,551 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Thomas Balling Sørensen.
|
|
||||||
* Copyright 2011 Christian König.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "pipe/p_state.h"
|
|
||||||
|
|
||||||
#include "util/u_memory.h"
|
|
||||||
#include "util/u_debug.h"
|
|
||||||
#include "util/u_rect.h"
|
|
||||||
#include "util/u_surface.h"
|
|
||||||
#include "util/u_video.h"
|
|
||||||
#include "vl/vl_defines.h"
|
|
||||||
|
|
||||||
#include "frontend/drm_driver.h"
|
|
||||||
|
|
||||||
#include "vdpau_private.h"
|
|
||||||
|
|
||||||
enum getbits_conversion {
|
|
||||||
CONVERSION_NONE,
|
|
||||||
CONVERSION_NV12_TO_YV12,
|
|
||||||
CONVERSION_YV12_TO_NV12,
|
|
||||||
CONVERSION_SWAP_YUYV_UYVY,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a VdpVideoSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type,
|
|
||||||
uint32_t width, uint32_t height,
|
|
||||||
VdpVideoSurface *surface)
|
|
||||||
{
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
vlVdpSurface *p_surf;
|
|
||||||
VdpStatus ret;
|
|
||||||
|
|
||||||
if (!(width && height)) {
|
|
||||||
ret = VDP_STATUS_INVALID_SIZE;
|
|
||||||
goto inv_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
p_surf = CALLOC(1, sizeof(vlVdpSurface));
|
|
||||||
if (!p_surf) {
|
|
||||||
ret = VDP_STATUS_RESOURCES;
|
|
||||||
goto no_res;
|
|
||||||
}
|
|
||||||
|
|
||||||
vlVdpDevice *dev = vlGetDataHTAB(device);
|
|
||||||
if (!dev) {
|
|
||||||
ret = VDP_STATUS_INVALID_HANDLE;
|
|
||||||
goto inv_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceReference(&p_surf->device, dev);
|
|
||||||
pipe = dev->context;
|
|
||||||
|
|
||||||
mtx_lock(&dev->mutex);
|
|
||||||
memset(&p_surf->templat, 0, sizeof(p_surf->templat));
|
|
||||||
p_surf->templat.buffer_format = ChromaToPipeFormat(chroma_type);
|
|
||||||
p_surf->templat.width = width;
|
|
||||||
p_surf->templat.height = height;
|
|
||||||
p_surf->templat.interlaced = pipe->screen->get_video_param
|
|
||||||
(
|
|
||||||
pipe->screen,
|
|
||||||
PIPE_VIDEO_PROFILE_UNKNOWN,
|
|
||||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
|
||||||
PIPE_VIDEO_CAP_PREFERS_INTERLACED
|
|
||||||
);
|
|
||||||
if (p_surf->templat.buffer_format != PIPE_FORMAT_NONE)
|
|
||||||
p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
|
|
||||||
/* do not mandate early allocation of a video buffer */
|
|
||||||
|
|
||||||
if (!pipe->screen->get_video_param(pipe->screen,
|
|
||||||
PIPE_VIDEO_PROFILE_UNKNOWN,
|
|
||||||
PIPE_VIDEO_ENTRYPOINT_UNKNOWN,
|
|
||||||
PIPE_VIDEO_CAP_SKIP_CLEAR_SURFACE))
|
|
||||||
vlVdpVideoSurfaceClear(p_surf);
|
|
||||||
|
|
||||||
mtx_unlock(&dev->mutex);
|
|
||||||
|
|
||||||
*surface = vlAddDataHTAB(p_surf);
|
|
||||||
if (*surface == 0) {
|
|
||||||
ret = VDP_STATUS_ERROR;
|
|
||||||
goto no_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
|
|
||||||
no_handle:
|
|
||||||
p_surf->video_buffer->destroy(p_surf->video_buffer);
|
|
||||||
|
|
||||||
inv_device:
|
|
||||||
DeviceReference(&p_surf->device, NULL);
|
|
||||||
FREE(p_surf);
|
|
||||||
|
|
||||||
no_res:
|
|
||||||
inv_size:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a VdpVideoSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoSurfaceDestroy(VdpVideoSurface surface)
|
|
||||||
{
|
|
||||||
vlVdpSurface *p_surf;
|
|
||||||
|
|
||||||
p_surf = (vlVdpSurface *)vlGetDataHTAB((vlHandle)surface);
|
|
||||||
if (!p_surf)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
mtx_lock(&p_surf->device->mutex);
|
|
||||||
if (p_surf->video_buffer)
|
|
||||||
p_surf->video_buffer->destroy(p_surf->video_buffer);
|
|
||||||
if (p_surf->ref_buffer)
|
|
||||||
p_surf->ref_buffer->destroy(p_surf->ref_buffer);
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
|
|
||||||
vlRemoveDataHTAB(surface);
|
|
||||||
DeviceReference(&p_surf->device, NULL);
|
|
||||||
FREE(p_surf);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the parameters used to create a VdpVideoSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoSurfaceGetParameters(VdpVideoSurface surface,
|
|
||||||
VdpChromaType *chroma_type,
|
|
||||||
uint32_t *width, uint32_t *height)
|
|
||||||
{
|
|
||||||
if (!(width && height && chroma_type))
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
vlVdpSurface *p_surf = vlGetDataHTAB(surface);
|
|
||||||
if (!p_surf)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (p_surf->video_buffer) {
|
|
||||||
*width = p_surf->video_buffer->width;
|
|
||||||
*height = p_surf->video_buffer->height;
|
|
||||||
*chroma_type = PipeToChroma(pipe_format_to_chroma_format(p_surf->video_buffer->buffer_format));
|
|
||||||
} else {
|
|
||||||
*width = p_surf->templat.width;
|
|
||||||
*height = p_surf->templat.height;
|
|
||||||
*chroma_type = PipeToChroma(pipe_format_to_chroma_format(p_surf->templat.buffer_format));
|
|
||||||
}
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
vlVdpVideoSurfaceSize(vlVdpSurface *p_surf, int component,
|
|
||||||
unsigned *width, unsigned *height)
|
|
||||||
{
|
|
||||||
*width = p_surf->templat.width;
|
|
||||||
*height = p_surf->templat.height;
|
|
||||||
|
|
||||||
vl_video_buffer_adjust_size(width, height, component,
|
|
||||||
pipe_format_to_chroma_format(p_surf->templat.buffer_format),
|
|
||||||
p_surf->templat.interlaced);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy image data from a VdpVideoSurface to application memory in a specified
|
|
||||||
* YCbCr format.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
|
|
||||||
VdpYCbCrFormat destination_ycbcr_format,
|
|
||||||
void *const *destination_data,
|
|
||||||
uint32_t const *destination_pitches)
|
|
||||||
{
|
|
||||||
vlVdpSurface *vlsurface;
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
enum pipe_format format, buffer_format;
|
|
||||||
struct pipe_sampler_view **sampler_views;
|
|
||||||
enum getbits_conversion conversion = CONVERSION_NONE;
|
|
||||||
unsigned i, j;
|
|
||||||
|
|
||||||
vlsurface = vlGetDataHTAB(surface);
|
|
||||||
if (!vlsurface)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pipe = vlsurface->device->context;
|
|
||||||
if (!pipe)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (!destination_data || !destination_pitches)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
format = FormatYCBCRToPipe(destination_ycbcr_format);
|
|
||||||
if (format == PIPE_FORMAT_NONE)
|
|
||||||
return VDP_STATUS_INVALID_Y_CB_CR_FORMAT;
|
|
||||||
|
|
||||||
if (vlsurface->video_buffer == NULL)
|
|
||||||
return VDP_STATUS_INVALID_VALUE;
|
|
||||||
|
|
||||||
buffer_format = vlsurface->video_buffer->buffer_format;
|
|
||||||
if (format != buffer_format) {
|
|
||||||
if (format == PIPE_FORMAT_YV12 && buffer_format == PIPE_FORMAT_NV12)
|
|
||||||
conversion = CONVERSION_NV12_TO_YV12;
|
|
||||||
else if (format == PIPE_FORMAT_NV12 && buffer_format == PIPE_FORMAT_YV12)
|
|
||||||
conversion = CONVERSION_YV12_TO_NV12;
|
|
||||||
else if ((format == PIPE_FORMAT_YUYV && buffer_format == PIPE_FORMAT_UYVY) ||
|
|
||||||
(format == PIPE_FORMAT_UYVY && buffer_format == PIPE_FORMAT_YUYV))
|
|
||||||
conversion = CONVERSION_SWAP_YUYV_UYVY;
|
|
||||||
else
|
|
||||||
return VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
mtx_lock(&vlsurface->device->mutex);
|
|
||||||
sampler_views = vlsurface->video_buffer->get_sampler_view_planes(vlsurface->video_buffer);
|
|
||||||
if (!sampler_views) {
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
|
||||||
unsigned width, height;
|
|
||||||
struct pipe_sampler_view *sv = sampler_views[i];
|
|
||||||
if (!sv) continue;
|
|
||||||
|
|
||||||
vlVdpVideoSurfaceSize(vlsurface, i, &width, &height);
|
|
||||||
|
|
||||||
for (j = 0; j < sv->texture->array_size; ++j) {
|
|
||||||
struct pipe_box box;
|
|
||||||
u_box_3d(0, 0, j, width, height, 1, &box);
|
|
||||||
struct pipe_transfer *transfer;
|
|
||||||
uint8_t *map;
|
|
||||||
|
|
||||||
map = pipe->texture_map(pipe, sv->texture, 0,
|
|
||||||
PIPE_MAP_READ, &box, &transfer);
|
|
||||||
if (!map) {
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conversion == CONVERSION_NV12_TO_YV12 && i == 1) {
|
|
||||||
u_copy_nv12_to_yv12(destination_data, destination_pitches,
|
|
||||||
i, j, transfer->stride, sv->texture->array_size,
|
|
||||||
map, box.width, box.height);
|
|
||||||
} else if (conversion == CONVERSION_YV12_TO_NV12 && i > 0) {
|
|
||||||
u_copy_yv12_to_nv12(destination_data, destination_pitches,
|
|
||||||
i, j, transfer->stride, sv->texture->array_size,
|
|
||||||
map, box.width, box.height);
|
|
||||||
} else if (conversion == CONVERSION_SWAP_YUYV_UYVY) {
|
|
||||||
u_copy_swap422_packed(destination_data, destination_pitches,
|
|
||||||
i, j, transfer->stride, sv->texture->array_size,
|
|
||||||
map, box.width, box.height);
|
|
||||||
} else {
|
|
||||||
util_copy_rect(destination_data[i] + destination_pitches[i] * j, sv->texture->format,
|
|
||||||
destination_pitches[i] * sv->texture->array_size, 0, 0,
|
|
||||||
box.width, box.height, map, transfer->stride, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_texture_unmap(pipe, transfer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mtx_unlock(&vlsurface->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy image data from application memory in a specific YCbCr format to
|
|
||||||
* a VdpVideoSurface.
|
|
||||||
*/
|
|
||||||
VdpStatus
|
|
||||||
vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
|
|
||||||
VdpYCbCrFormat source_ycbcr_format,
|
|
||||||
void const *const *source_data,
|
|
||||||
uint32_t const *source_pitches)
|
|
||||||
{
|
|
||||||
enum pipe_format pformat = FormatYCBCRToPipe(source_ycbcr_format);
|
|
||||||
enum getbits_conversion conversion = CONVERSION_NONE;
|
|
||||||
struct pipe_context *pipe;
|
|
||||||
struct pipe_sampler_view **sampler_views;
|
|
||||||
unsigned i, j;
|
|
||||||
unsigned usage = PIPE_MAP_WRITE;
|
|
||||||
|
|
||||||
vlVdpSurface *p_surf = vlGetDataHTAB(surface);
|
|
||||||
if (!p_surf)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
pipe = p_surf->device->context;
|
|
||||||
if (!pipe)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (!source_data || !source_pitches)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
mtx_lock(&p_surf->device->mutex);
|
|
||||||
|
|
||||||
if (p_surf->video_buffer == NULL ||
|
|
||||||
((pformat != p_surf->video_buffer->buffer_format))) {
|
|
||||||
enum pipe_format nformat = pformat;
|
|
||||||
struct pipe_screen *screen = pipe->screen;
|
|
||||||
|
|
||||||
/* Determine the most suitable format for the new surface */
|
|
||||||
if (!screen->is_video_format_supported(screen, nformat,
|
|
||||||
PIPE_VIDEO_PROFILE_UNKNOWN,
|
|
||||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) {
|
|
||||||
nformat = screen->get_video_param(screen,
|
|
||||||
PIPE_VIDEO_PROFILE_UNKNOWN,
|
|
||||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
|
||||||
PIPE_VIDEO_CAP_PREFERRED_FORMAT);
|
|
||||||
if (nformat == PIPE_FORMAT_NONE) {
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
return VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_surf->video_buffer == NULL ||
|
|
||||||
nformat != p_surf->video_buffer->buffer_format) {
|
|
||||||
/* destroy the old one */
|
|
||||||
if (p_surf->video_buffer)
|
|
||||||
p_surf->video_buffer->destroy(p_surf->video_buffer);
|
|
||||||
|
|
||||||
/* adjust the template parameters */
|
|
||||||
p_surf->templat.buffer_format = nformat;
|
|
||||||
if (nformat == PIPE_FORMAT_YUYV || nformat == PIPE_FORMAT_UYVY)
|
|
||||||
p_surf->templat.interlaced = false;
|
|
||||||
|
|
||||||
/* and try to create the video buffer with the new format */
|
|
||||||
p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
|
|
||||||
|
|
||||||
/* stil no luck? ok forget it we don't support it */
|
|
||||||
if (!p_surf->video_buffer) {
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
return VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
}
|
|
||||||
vlVdpVideoSurfaceClear(p_surf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pformat != p_surf->video_buffer->buffer_format) {
|
|
||||||
if (pformat == PIPE_FORMAT_YV12 &&
|
|
||||||
p_surf->video_buffer->buffer_format == PIPE_FORMAT_NV12)
|
|
||||||
conversion = CONVERSION_YV12_TO_NV12;
|
|
||||||
else {
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
return VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sampler_views = p_surf->video_buffer->get_sampler_view_planes(p_surf->video_buffer);
|
|
||||||
if (!sampler_views) {
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
|
||||||
unsigned width, height;
|
|
||||||
struct pipe_sampler_view *sv = sampler_views[i];
|
|
||||||
struct pipe_resource *tex;
|
|
||||||
if (!sv || !source_pitches[i]) continue;
|
|
||||||
|
|
||||||
tex = sv->texture;
|
|
||||||
vlVdpVideoSurfaceSize(p_surf, i, &width, &height);
|
|
||||||
|
|
||||||
for (j = 0; j < tex->array_size; ++j) {
|
|
||||||
struct pipe_box dst_box;
|
|
||||||
u_box_3d(0, 0, j, width, height, 1, &dst_box);
|
|
||||||
|
|
||||||
if (conversion == CONVERSION_YV12_TO_NV12 && i == 1) {
|
|
||||||
struct pipe_transfer *transfer;
|
|
||||||
uint8_t *map;
|
|
||||||
|
|
||||||
map = pipe->texture_map(pipe, tex, 0, usage,
|
|
||||||
&dst_box, &transfer);
|
|
||||||
if (!map) {
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
u_copy_nv12_from_yv12(source_data, source_pitches,
|
|
||||||
i, j, transfer->stride, tex->array_size,
|
|
||||||
map, dst_box.width, dst_box.height);
|
|
||||||
|
|
||||||
pipe_texture_unmap(pipe, transfer);
|
|
||||||
} else {
|
|
||||||
pipe->texture_subdata(pipe, tex, 0,
|
|
||||||
PIPE_MAP_WRITE, &dst_box,
|
|
||||||
source_data[i] + source_pitches[i] * j,
|
|
||||||
source_pitches[i] * tex->array_size,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* This surface has already been synced
|
|
||||||
* by the first map.
|
|
||||||
*/
|
|
||||||
usage |= PIPE_MAP_UNSYNCHRONIZED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to initially clear the VideoSurface after (re-)creation
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf)
|
|
||||||
{
|
|
||||||
struct pipe_context *pipe = vlsurf->device->context;
|
|
||||||
struct pipe_surface *surfaces;
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
if (!vlsurf->video_buffer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
surfaces = vlsurf->video_buffer->get_surfaces(vlsurf->video_buffer);
|
|
||||||
for (i = 0; i < VL_MAX_SURFACES; ++i) {
|
|
||||||
union pipe_color_union c = {};
|
|
||||||
|
|
||||||
if (!surfaces[i].texture)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (i > !!vlsurf->templat.interlaced)
|
|
||||||
c.f[0] = c.f[1] = c.f[2] = c.f[3] = 0.5f;
|
|
||||||
|
|
||||||
uint16_t width, height;
|
|
||||||
pipe_surface_size(&surfaces[i], &width, &height);
|
|
||||||
pipe->clear_render_target(pipe, &surfaces[i], &c, 0, 0,
|
|
||||||
width, height, false);
|
|
||||||
}
|
|
||||||
pipe->flush(pipe, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interop for the GL gallium frontend
|
|
||||||
*/
|
|
||||||
struct pipe_video_buffer *vlVdpVideoSurfaceGallium(VdpVideoSurface surface)
|
|
||||||
{
|
|
||||||
vlVdpSurface *p_surf = vlGetDataHTAB(surface);
|
|
||||||
if (!p_surf)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
mtx_lock(&p_surf->device->mutex);
|
|
||||||
if (p_surf->video_buffer == NULL) {
|
|
||||||
struct pipe_context *pipe = p_surf->device->context;
|
|
||||||
|
|
||||||
/* try to create a video buffer if we don't already have one */
|
|
||||||
p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
|
|
||||||
}
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
|
|
||||||
return p_surf->video_buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
|
|
||||||
VdpVideoSurfacePlane plane,
|
|
||||||
struct VdpSurfaceDMABufDesc *result)
|
|
||||||
{
|
|
||||||
vlVdpSurface *p_surf = vlGetDataHTAB(surface);
|
|
||||||
|
|
||||||
struct pipe_screen *pscreen;
|
|
||||||
struct winsys_handle whandle;
|
|
||||||
|
|
||||||
struct pipe_surface *surf;
|
|
||||||
|
|
||||||
if (!p_surf)
|
|
||||||
return VDP_STATUS_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (plane > 3)
|
|
||||||
return VDP_STATUS_INVALID_VALUE;
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
return VDP_STATUS_INVALID_POINTER;
|
|
||||||
|
|
||||||
memset(result, 0, sizeof(*result));
|
|
||||||
result->handle = -1;
|
|
||||||
|
|
||||||
mtx_lock(&p_surf->device->mutex);
|
|
||||||
if (p_surf->video_buffer == NULL) {
|
|
||||||
struct pipe_context *pipe = p_surf->device->context;
|
|
||||||
|
|
||||||
/* try to create a video buffer if we don't already have one */
|
|
||||||
p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if surface match interop requirements */
|
|
||||||
if (p_surf->video_buffer == NULL || !p_surf->video_buffer->interlaced ||
|
|
||||||
p_surf->video_buffer->buffer_format != PIPE_FORMAT_NV12) {
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
return VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
surf = &p_surf->video_buffer->get_surfaces(p_surf->video_buffer)[plane];
|
|
||||||
if (!surf) {
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
return VDP_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&whandle, 0, sizeof(struct winsys_handle));
|
|
||||||
whandle.type = WINSYS_HANDLE_TYPE_FD;
|
|
||||||
whandle.layer = surf->first_layer;
|
|
||||||
|
|
||||||
pscreen = surf->texture->screen;
|
|
||||||
if (!pscreen->resource_get_handle(pscreen, p_surf->device->context,
|
|
||||||
surf->texture, &whandle,
|
|
||||||
PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) {
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
return VDP_STATUS_NO_IMPLEMENTATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
mtx_unlock(&p_surf->device->mutex);
|
|
||||||
result->handle = whandle.handle;
|
|
||||||
result->width = pipe_surface_width(surf);
|
|
||||||
result->height = pipe_surface_height(surf);
|
|
||||||
result->offset = whandle.offset;
|
|
||||||
result->stride = whandle.stride;
|
|
||||||
|
|
||||||
if (surf->format == PIPE_FORMAT_R8_UNORM)
|
|
||||||
result->format = VDP_RGBA_FORMAT_R8;
|
|
||||||
else
|
|
||||||
result->format = VDP_RGBA_FORMAT_R8G8;
|
|
||||||
|
|
||||||
return VDP_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
@ -1,618 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2010 Younes Manton & Thomas Balling Sørensen.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef VDPAU_PRIVATE_H
|
|
||||||
#define VDPAU_PRIVATE_H
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <vdpau/vdpau.h>
|
|
||||||
#include <vdpau/vdpau_x11.h>
|
|
||||||
|
|
||||||
#include "util/compiler.h"
|
|
||||||
#include "pipe/p_video_codec.h"
|
|
||||||
|
|
||||||
#include "frontend/vdpau_interop.h"
|
|
||||||
#include "frontend/vdpau_dmabuf.h"
|
|
||||||
#include "frontend/vdpau_funcs.h"
|
|
||||||
|
|
||||||
#include "util/u_debug.h"
|
|
||||||
#include "util/u_rect.h"
|
|
||||||
#include "util/u_surface.h"
|
|
||||||
#include "util/u_thread.h"
|
|
||||||
|
|
||||||
#include "vl/vl_video_buffer.h"
|
|
||||||
#include "vl/vl_bicubic_filter.h"
|
|
||||||
#include "vl/vl_compositor.h"
|
|
||||||
#include "vl/vl_csc.h"
|
|
||||||
#include "vl/vl_deint_filter.h"
|
|
||||||
#include "vl/vl_matrix_filter.h"
|
|
||||||
#include "vl/vl_median_filter.h"
|
|
||||||
#include "vl/vl_winsys.h"
|
|
||||||
|
|
||||||
/* Full VDPAU API documentation available at :
|
|
||||||
* ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */
|
|
||||||
|
|
||||||
#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
|
|
||||||
#define QUOTEME(x) #x
|
|
||||||
#define TOSTRING(x) QUOTEME(x)
|
|
||||||
#define INFORMATION_STRING TOSTRING(INFORMATION)
|
|
||||||
|
|
||||||
static inline enum pipe_video_chroma_format
|
|
||||||
ChromaToPipe(VdpChromaType vdpau_type)
|
|
||||||
{
|
|
||||||
switch (vdpau_type) {
|
|
||||||
case VDP_CHROMA_TYPE_420:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_420;
|
|
||||||
case VDP_CHROMA_TYPE_422:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_422;
|
|
||||||
case VDP_CHROMA_TYPE_444:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_444;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline VdpChromaType
|
|
||||||
PipeToChroma(enum pipe_video_chroma_format pipe_type)
|
|
||||||
{
|
|
||||||
switch (pipe_type) {
|
|
||||||
case PIPE_VIDEO_CHROMA_FORMAT_420:
|
|
||||||
return VDP_CHROMA_TYPE_420;
|
|
||||||
case PIPE_VIDEO_CHROMA_FORMAT_422:
|
|
||||||
return VDP_CHROMA_TYPE_422;
|
|
||||||
case PIPE_VIDEO_CHROMA_FORMAT_444:
|
|
||||||
return VDP_CHROMA_TYPE_444;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum pipe_video_chroma_format
|
|
||||||
FormatYCBCRToPipeChroma(VdpYCbCrFormat vdpau_format)
|
|
||||||
{
|
|
||||||
switch (vdpau_format) {
|
|
||||||
case VDP_YCBCR_FORMAT_NV12:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_420;
|
|
||||||
case VDP_YCBCR_FORMAT_YV12:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_420;
|
|
||||||
case VDP_YCBCR_FORMAT_UYVY:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_422;
|
|
||||||
case VDP_YCBCR_FORMAT_YUYV:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_422;
|
|
||||||
case VDP_YCBCR_FORMAT_Y8U8V8A8:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_444;
|
|
||||||
case VDP_YCBCR_FORMAT_V8U8Y8A8:
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_444;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PIPE_VIDEO_CHROMA_FORMAT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum pipe_format
|
|
||||||
FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format)
|
|
||||||
{
|
|
||||||
switch (vdpau_format) {
|
|
||||||
case VDP_YCBCR_FORMAT_NV12:
|
|
||||||
return PIPE_FORMAT_NV12;
|
|
||||||
case VDP_YCBCR_FORMAT_YV12:
|
|
||||||
return PIPE_FORMAT_YV12;
|
|
||||||
case VDP_YCBCR_FORMAT_UYVY:
|
|
||||||
return PIPE_FORMAT_UYVY;
|
|
||||||
case VDP_YCBCR_FORMAT_YUYV:
|
|
||||||
return PIPE_FORMAT_YUYV;
|
|
||||||
case VDP_YCBCR_FORMAT_Y8U8V8A8:
|
|
||||||
return PIPE_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
case VDP_YCBCR_FORMAT_V8U8Y8A8:
|
|
||||||
return PIPE_FORMAT_B8G8R8A8_UNORM;
|
|
||||||
#ifdef VDP_YCBCR_FORMAT_P010
|
|
||||||
case VDP_YCBCR_FORMAT_P010:
|
|
||||||
return PIPE_FORMAT_P010;
|
|
||||||
#endif
|
|
||||||
#ifdef VDP_YCBCR_FORMAT_P016
|
|
||||||
case VDP_YCBCR_FORMAT_P016:
|
|
||||||
return PIPE_FORMAT_P016;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
/* NOTE: Can't be "unreachable", as it's quite reachable. */
|
|
||||||
assert(!"unexpected VdpYCbCrFormat");
|
|
||||||
return PIPE_FORMAT_NONE;
|
|
||||||
#ifdef VDP_YCBCR_FORMAT_Y_UV_444
|
|
||||||
case VDP_YCBCR_FORMAT_Y_UV_444:
|
|
||||||
return PIPE_FORMAT_NONE;
|
|
||||||
#endif
|
|
||||||
#ifdef VDP_YCBCR_FORMAT_Y_U_V_444
|
|
||||||
case VDP_YCBCR_FORMAT_Y_U_V_444:
|
|
||||||
return PIPE_FORMAT_NONE;
|
|
||||||
#endif
|
|
||||||
#ifdef VDP_YCBCR_FORMAT_Y_U_V_444_16
|
|
||||||
case VDP_YCBCR_FORMAT_Y_U_V_444_16:
|
|
||||||
return PIPE_FORMAT_NONE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum pipe_format
|
|
||||||
ChromaToPipeFormat(VdpChromaType vdpau_type)
|
|
||||||
{
|
|
||||||
switch (vdpau_type) {
|
|
||||||
case VDP_CHROMA_TYPE_420:
|
|
||||||
return PIPE_FORMAT_NV12;
|
|
||||||
#ifdef VDP_CHROMA_TYPE_420_16
|
|
||||||
case VDP_CHROMA_TYPE_420_16:
|
|
||||||
return PIPE_FORMAT_P016;
|
|
||||||
#endif
|
|
||||||
case VDP_CHROMA_TYPE_422:
|
|
||||||
return PIPE_FORMAT_UYVY;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PIPE_FORMAT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline VdpYCbCrFormat
|
|
||||||
PipeToFormatYCBCR(enum pipe_format p_format)
|
|
||||||
{
|
|
||||||
switch (p_format) {
|
|
||||||
case PIPE_FORMAT_NV12:
|
|
||||||
return VDP_YCBCR_FORMAT_NV12;
|
|
||||||
case PIPE_FORMAT_YV12:
|
|
||||||
return VDP_YCBCR_FORMAT_YV12;
|
|
||||||
case PIPE_FORMAT_UYVY:
|
|
||||||
return VDP_YCBCR_FORMAT_UYVY;
|
|
||||||
case PIPE_FORMAT_YUYV:
|
|
||||||
return VDP_YCBCR_FORMAT_YUYV;
|
|
||||||
case PIPE_FORMAT_R8G8B8A8_UNORM:
|
|
||||||
return VDP_YCBCR_FORMAT_Y8U8V8A8;
|
|
||||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
|
||||||
return VDP_YCBCR_FORMAT_V8U8Y8A8;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline VdpRGBAFormat
|
|
||||||
PipeToFormatRGBA(enum pipe_format p_format)
|
|
||||||
{
|
|
||||||
switch (p_format) {
|
|
||||||
case PIPE_FORMAT_A8_UNORM:
|
|
||||||
return VDP_RGBA_FORMAT_A8;
|
|
||||||
case PIPE_FORMAT_B10G10R10A2_UNORM:
|
|
||||||
return VDP_RGBA_FORMAT_B10G10R10A2;
|
|
||||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
|
||||||
return VDP_RGBA_FORMAT_B8G8R8A8;
|
|
||||||
case PIPE_FORMAT_R10G10B10A2_UNORM:
|
|
||||||
return VDP_RGBA_FORMAT_R10G10B10A2;
|
|
||||||
case PIPE_FORMAT_R8G8B8A8_UNORM:
|
|
||||||
return VDP_RGBA_FORMAT_R8G8B8A8;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum pipe_format
|
|
||||||
FormatIndexedToPipe(VdpRGBAFormat vdpau_format)
|
|
||||||
{
|
|
||||||
switch (vdpau_format) {
|
|
||||||
case VDP_INDEXED_FORMAT_A4I4:
|
|
||||||
return PIPE_FORMAT_R4A4_UNORM;
|
|
||||||
case VDP_INDEXED_FORMAT_I4A4:
|
|
||||||
return PIPE_FORMAT_A4R4_UNORM;
|
|
||||||
case VDP_INDEXED_FORMAT_A8I8:
|
|
||||||
return PIPE_FORMAT_A8R8_UNORM;
|
|
||||||
case VDP_INDEXED_FORMAT_I8A8:
|
|
||||||
return PIPE_FORMAT_R8A8_UNORM;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PIPE_FORMAT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum pipe_format
|
|
||||||
FormatColorTableToPipe(VdpColorTableFormat vdpau_format)
|
|
||||||
{
|
|
||||||
switch(vdpau_format) {
|
|
||||||
case VDP_COLOR_TABLE_FORMAT_B8G8R8X8:
|
|
||||||
return PIPE_FORMAT_B8G8R8X8_UNORM;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PIPE_FORMAT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum pipe_video_profile
|
|
||||||
ProfileToPipe(VdpDecoderProfile vdpau_profile)
|
|
||||||
{
|
|
||||||
switch (vdpau_profile) {
|
|
||||||
case VDP_DECODER_PROFILE_MPEG1:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG1;
|
|
||||||
case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
|
|
||||||
case VDP_DECODER_PROFILE_MPEG2_MAIN:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
|
|
||||||
case VDP_DECODER_PROFILE_H264_BASELINE:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
|
|
||||||
case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE;
|
|
||||||
case VDP_DECODER_PROFILE_H264_MAIN:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
|
|
||||||
case VDP_DECODER_PROFILE_H264_HIGH:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
|
|
||||||
case VDP_DECODER_PROFILE_MPEG4_PART2_SP:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE;
|
|
||||||
case VDP_DECODER_PROFILE_MPEG4_PART2_ASP:
|
|
||||||
return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE;
|
|
||||||
case VDP_DECODER_PROFILE_VC1_SIMPLE:
|
|
||||||
return PIPE_VIDEO_PROFILE_VC1_SIMPLE;
|
|
||||||
case VDP_DECODER_PROFILE_VC1_MAIN:
|
|
||||||
return PIPE_VIDEO_PROFILE_VC1_MAIN;
|
|
||||||
case VDP_DECODER_PROFILE_VC1_ADVANCED:
|
|
||||||
return PIPE_VIDEO_PROFILE_VC1_ADVANCED;
|
|
||||||
case VDP_DECODER_PROFILE_HEVC_MAIN:
|
|
||||||
return PIPE_VIDEO_PROFILE_HEVC_MAIN;
|
|
||||||
case VDP_DECODER_PROFILE_HEVC_MAIN_10:
|
|
||||||
return PIPE_VIDEO_PROFILE_HEVC_MAIN_10;
|
|
||||||
case VDP_DECODER_PROFILE_HEVC_MAIN_STILL:
|
|
||||||
return PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL;
|
|
||||||
case VDP_DECODER_PROFILE_HEVC_MAIN_12:
|
|
||||||
return PIPE_VIDEO_PROFILE_HEVC_MAIN_12;
|
|
||||||
case VDP_DECODER_PROFILE_HEVC_MAIN_444:
|
|
||||||
return PIPE_VIDEO_PROFILE_HEVC_MAIN_444;
|
|
||||||
case VDP_DECODER_PROFILE_AV1_MAIN:
|
|
||||||
return PIPE_VIDEO_PROFILE_AV1_MAIN;
|
|
||||||
default:
|
|
||||||
return PIPE_VIDEO_PROFILE_UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline VdpDecoderProfile
|
|
||||||
PipeToProfile(enum pipe_video_profile p_profile)
|
|
||||||
{
|
|
||||||
switch (p_profile) {
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG1:
|
|
||||||
return VDP_DECODER_PROFILE_MPEG1;
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
|
|
||||||
return VDP_DECODER_PROFILE_MPEG2_SIMPLE;
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
|
|
||||||
return VDP_DECODER_PROFILE_MPEG2_MAIN;
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
|
|
||||||
return VDP_DECODER_PROFILE_H264_BASELINE;
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE:
|
|
||||||
return VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE;
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
|
|
||||||
return VDP_DECODER_PROFILE_H264_MAIN;
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
|
|
||||||
return VDP_DECODER_PROFILE_H264_HIGH;
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
|
|
||||||
return VDP_DECODER_PROFILE_MPEG4_PART2_SP;
|
|
||||||
case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
|
|
||||||
return VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
|
|
||||||
case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
|
|
||||||
return VDP_DECODER_PROFILE_VC1_SIMPLE;
|
|
||||||
case PIPE_VIDEO_PROFILE_VC1_MAIN:
|
|
||||||
return VDP_DECODER_PROFILE_VC1_MAIN;
|
|
||||||
case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
|
|
||||||
return VDP_DECODER_PROFILE_VC1_ADVANCED;
|
|
||||||
case PIPE_VIDEO_PROFILE_HEVC_MAIN:
|
|
||||||
return VDP_DECODER_PROFILE_HEVC_MAIN;
|
|
||||||
case PIPE_VIDEO_PROFILE_HEVC_MAIN_10:
|
|
||||||
return VDP_DECODER_PROFILE_HEVC_MAIN_10;
|
|
||||||
case PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL:
|
|
||||||
return VDP_DECODER_PROFILE_HEVC_MAIN_STILL;
|
|
||||||
case PIPE_VIDEO_PROFILE_HEVC_MAIN_12:
|
|
||||||
return VDP_DECODER_PROFILE_HEVC_MAIN_12;
|
|
||||||
case PIPE_VIDEO_PROFILE_HEVC_MAIN_444:
|
|
||||||
return VDP_DECODER_PROFILE_HEVC_MAIN_444;
|
|
||||||
case PIPE_VIDEO_PROFILE_AV1_MAIN:
|
|
||||||
return VDP_DECODER_PROFILE_AV1_MAIN;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct u_rect *
|
|
||||||
RectToPipe(const VdpRect *src, struct u_rect *dst)
|
|
||||||
{
|
|
||||||
if (src) {
|
|
||||||
dst->x0 = src->x0;
|
|
||||||
dst->y0 = src->y0;
|
|
||||||
dst->x1 = src->x1;
|
|
||||||
dst->y1 = src->y1;
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct pipe_box
|
|
||||||
RectToPipeBox(const VdpRect *rect, struct pipe_resource *res)
|
|
||||||
{
|
|
||||||
struct pipe_box box;
|
|
||||||
|
|
||||||
box.x = 0;
|
|
||||||
box.y = 0;
|
|
||||||
box.z = 0;
|
|
||||||
box.width = res->width0;
|
|
||||||
box.height = res->height0;
|
|
||||||
box.depth = 1;
|
|
||||||
|
|
||||||
if (rect) {
|
|
||||||
if (rect->x1 > rect->x0 &&
|
|
||||||
rect->y1 > rect->y0) {
|
|
||||||
box.x = rect->x0;
|
|
||||||
box.y = rect->y0;
|
|
||||||
box.width = rect->x1 - box.x;
|
|
||||||
box.height = rect->y1 - box.y;
|
|
||||||
} else {
|
|
||||||
box.width = 0;
|
|
||||||
box.height = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
CheckSurfaceParams(struct pipe_screen *screen,
|
|
||||||
const struct pipe_resource *templ)
|
|
||||||
{
|
|
||||||
return screen->is_format_supported(screen, templ->format, templ->target,
|
|
||||||
templ->nr_samples,
|
|
||||||
templ->nr_storage_samples, templ->bind);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
struct pipe_reference reference;
|
|
||||||
struct vl_screen *vscreen;
|
|
||||||
struct pipe_context *context;
|
|
||||||
struct vl_compositor compositor;
|
|
||||||
struct pipe_sampler_view *dummy_sv;
|
|
||||||
mtx_t mutex;
|
|
||||||
} vlVdpDevice;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vlVdpDevice *device;
|
|
||||||
struct vl_compositor_state cstate;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
bool supported, enabled;
|
|
||||||
float luma_min, luma_max;
|
|
||||||
} luma_key;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
bool supported, enabled, spatial;
|
|
||||||
struct vl_deint_filter *filter;
|
|
||||||
} deint;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
bool supported, enabled;
|
|
||||||
struct vl_bicubic_filter *filter;
|
|
||||||
} bicubic;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
bool supported, enabled;
|
|
||||||
unsigned level;
|
|
||||||
struct vl_median_filter *filter;
|
|
||||||
} noise_reduction;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
bool supported, enabled;
|
|
||||||
float value;
|
|
||||||
struct vl_matrix_filter *filter;
|
|
||||||
} sharpness;
|
|
||||||
|
|
||||||
unsigned video_width, video_height;
|
|
||||||
enum pipe_video_chroma_format chroma_format;
|
|
||||||
unsigned max_layers, skip_chroma_deint;
|
|
||||||
|
|
||||||
bool custom_csc;
|
|
||||||
vl_csc_matrix csc;
|
|
||||||
} vlVdpVideoMixer;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vlVdpDevice *device;
|
|
||||||
struct pipe_video_buffer templat, *video_buffer, *ref_buffer;
|
|
||||||
} vlVdpSurface;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vlVdpDevice *device;
|
|
||||||
struct pipe_sampler_view *sampler_view;
|
|
||||||
} vlVdpBitmapSurface;
|
|
||||||
|
|
||||||
typedef uint64_t vlVdpTime;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vlVdpDevice *device;
|
|
||||||
struct pipe_surface surface;
|
|
||||||
struct pipe_sampler_view *sampler_view;
|
|
||||||
struct pipe_fence_handle *fence;
|
|
||||||
struct vl_compositor_state cstate;
|
|
||||||
struct u_rect dirty_area;
|
|
||||||
bool send_to_X;
|
|
||||||
} vlVdpOutputSurface;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vlVdpDevice *device;
|
|
||||||
Drawable drawable;
|
|
||||||
} vlVdpPresentationQueueTarget;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vlVdpDevice *device;
|
|
||||||
Drawable drawable;
|
|
||||||
struct vl_compositor_state cstate;
|
|
||||||
vlVdpOutputSurface *last_surf;
|
|
||||||
} vlVdpPresentationQueue;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vlVdpDevice *device;
|
|
||||||
mtx_t mutex;
|
|
||||||
struct pipe_video_codec *decoder;
|
|
||||||
} vlVdpDecoder;
|
|
||||||
|
|
||||||
typedef uint32_t vlHandle;
|
|
||||||
|
|
||||||
bool vlCreateHTAB(void);
|
|
||||||
void vlDestroyHTAB(void);
|
|
||||||
vlHandle vlAddDataHTAB(void *data);
|
|
||||||
void* vlGetDataHTAB(vlHandle handle);
|
|
||||||
void vlRemoveDataHTAB(vlHandle handle);
|
|
||||||
|
|
||||||
bool vlGetFuncFTAB(VdpFuncId function_id, void **func);
|
|
||||||
|
|
||||||
/* Public functions */
|
|
||||||
VdpDeviceCreateX11 vdp_imp_device_create_x11;
|
|
||||||
|
|
||||||
void vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res);
|
|
||||||
|
|
||||||
/* Internal function pointers */
|
|
||||||
VdpGetErrorString vlVdpGetErrorString;
|
|
||||||
VdpDeviceDestroy vlVdpDeviceDestroy;
|
|
||||||
void vlVdpDeviceFree(vlVdpDevice *dev);
|
|
||||||
VdpGetProcAddress vlVdpGetProcAddress;
|
|
||||||
VdpGetApiVersion vlVdpGetApiVersion;
|
|
||||||
VdpGetInformationString vlVdpGetInformationString;
|
|
||||||
VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities;
|
|
||||||
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities;
|
|
||||||
VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities;
|
|
||||||
VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities;
|
|
||||||
VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities;
|
|
||||||
VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities;
|
|
||||||
VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;
|
|
||||||
VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities;
|
|
||||||
VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport;
|
|
||||||
VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
|
|
||||||
VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
|
|
||||||
VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
|
|
||||||
VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
|
|
||||||
VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
|
|
||||||
VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
|
|
||||||
VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
|
|
||||||
VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
|
|
||||||
VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
|
|
||||||
void vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf);
|
|
||||||
VdpDecoderCreate vlVdpDecoderCreate;
|
|
||||||
VdpDecoderDestroy vlVdpDecoderDestroy;
|
|
||||||
VdpDecoderGetParameters vlVdpDecoderGetParameters;
|
|
||||||
VdpDecoderRender vlVdpDecoderRender;
|
|
||||||
VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;
|
|
||||||
VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy;
|
|
||||||
VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters;
|
|
||||||
VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative;
|
|
||||||
VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative;
|
|
||||||
VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed;
|
|
||||||
VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr;
|
|
||||||
VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface;
|
|
||||||
VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface;
|
|
||||||
VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;
|
|
||||||
VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;
|
|
||||||
VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;
|
|
||||||
VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;
|
|
||||||
VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;
|
|
||||||
VdpPresentationQueueCreate vlVdpPresentationQueueCreate;
|
|
||||||
VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;
|
|
||||||
VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;
|
|
||||||
VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;
|
|
||||||
VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;
|
|
||||||
VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;
|
|
||||||
VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;
|
|
||||||
VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;
|
|
||||||
VdpPreemptionCallback vlVdpPreemptionCallback;
|
|
||||||
VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;
|
|
||||||
VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;
|
|
||||||
VdpVideoMixerCreate vlVdpVideoMixerCreate;
|
|
||||||
VdpVideoMixerRender vlVdpVideoMixerRender;
|
|
||||||
VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;
|
|
||||||
VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport;
|
|
||||||
VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables;
|
|
||||||
VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues;
|
|
||||||
VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues;
|
|
||||||
VdpVideoMixerDestroy vlVdpVideoMixerDestroy;
|
|
||||||
VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
|
|
||||||
/* Winsys specific internal function pointers */
|
|
||||||
VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
|
|
||||||
|
|
||||||
|
|
||||||
/* interop for GL gallium frontend */
|
|
||||||
VdpVideoSurfaceGallium vlVdpVideoSurfaceGallium;
|
|
||||||
VdpOutputSurfaceGallium vlVdpOutputSurfaceGallium;
|
|
||||||
VdpVideoSurfaceDMABuf vlVdpVideoSurfaceDMABuf;
|
|
||||||
VdpOutputSurfaceDMABuf vlVdpOutputSurfaceDMABuf;
|
|
||||||
|
|
||||||
#define VDPAU_OUT 0
|
|
||||||
#define VDPAU_ERR 1
|
|
||||||
#define VDPAU_WARN 2
|
|
||||||
#define VDPAU_TRACE 3
|
|
||||||
|
|
||||||
static inline void VDPAU_MSG(unsigned int level, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
static int debug_level = -1;
|
|
||||||
|
|
||||||
if (debug_level == -1) {
|
|
||||||
debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (level <= debug_level) {
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
_debug_vprintf(fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
DeviceReference(vlVdpDevice **ptr, vlVdpDevice *dev)
|
|
||||||
{
|
|
||||||
vlVdpDevice *old_dev = *ptr;
|
|
||||||
|
|
||||||
if (pipe_reference(&(*ptr)->reference, &dev->reference))
|
|
||||||
vlVdpDeviceFree(old_dev);
|
|
||||||
*ptr = dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* VDPAU_PRIVATE_H */
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Authors:
|
|
||||||
* Christian König <christian.koenig@amd.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VDPAU_DMABUF_H_
|
|
||||||
#define _VDPAU_DMABUF_H_
|
|
||||||
|
|
||||||
#include <vdpau/vdpau.h>
|
|
||||||
|
|
||||||
/* driver specific functions for NV_vdpau_interop */
|
|
||||||
#ifndef VDP_FUNC_ID_BASE_DRIVER
|
|
||||||
#define VDP_FUNC_ID_BASE_DRIVER 0x2000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* New DMA-buf based implementation */
|
|
||||||
#define VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 2)
|
|
||||||
#define VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 3)
|
|
||||||
|
|
||||||
/* Define some more internal RGBA formats for more
|
|
||||||
* robust handling of Video Surfaces
|
|
||||||
*/
|
|
||||||
#define VDP_RGBA_FORMAT_R8 (-1)
|
|
||||||
#define VDP_RGBA_FORMAT_R8G8 (-2)
|
|
||||||
|
|
||||||
struct VdpSurfaceDMABufDesc {
|
|
||||||
/* DMA-buf file descriptor */
|
|
||||||
uint32_t handle;
|
|
||||||
/* Width in pixel */
|
|
||||||
uint32_t width;
|
|
||||||
/* Height in pixel */
|
|
||||||
uint32_t height;
|
|
||||||
/* Offset in bytes */
|
|
||||||
uint32_t offset;
|
|
||||||
/* Stride in bytes */
|
|
||||||
uint32_t stride;
|
|
||||||
/* VDP_RGBA_FORMAT_* as defined in the VDPAU spec and above. */
|
|
||||||
uint32_t format;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Video surface planes
|
|
||||||
*/
|
|
||||||
typedef uint32_t VdpVideoSurfacePlane;
|
|
||||||
|
|
||||||
/** \hideinitializer \brief Luma top field */
|
|
||||||
#define VDP_VIDEO_SURFACE_PLANE_LUMA_TOP ((VdpVideoSurfacePlane)0)
|
|
||||||
/** \hideinitializer \brief Luma bottom field */
|
|
||||||
#define VDP_VIDEO_SURFACE_PLANE_LUMA_BOTTOM ((VdpVideoSurfacePlane)1)
|
|
||||||
/** \hideinitializer \brief Chroma top field */
|
|
||||||
#define VDP_VIDEO_SURFACE_PLANE_CHROMA_TOP ((VdpVideoSurfacePlane)2)
|
|
||||||
/** \hideinitializer \brief Chroma bottom field */
|
|
||||||
#define VDP_VIDEO_SURFACE_PLANE_CHROMA_BOTTOM ((VdpVideoSurfacePlane)3)
|
|
||||||
|
|
||||||
typedef VdpStatus VdpVideoSurfaceDMABuf(
|
|
||||||
VdpVideoSurface surface,
|
|
||||||
VdpVideoSurfacePlane plane,
|
|
||||||
struct VdpSurfaceDMABufDesc * result
|
|
||||||
);
|
|
||||||
|
|
||||||
typedef VdpStatus VdpOutputSurfaceDMABuf(
|
|
||||||
VdpOutputSurface surface,
|
|
||||||
struct VdpSurfaceDMABufDesc * result
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif /* _VDPAU_DMABUF_H_ */
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Authors:
|
|
||||||
* Christian König <christian.koenig@amd.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VDPAU_FUNCS_H_
|
|
||||||
#define _VDPAU_FUNCS_H_
|
|
||||||
|
|
||||||
#include "vdpau_dmabuf.h"
|
|
||||||
|
|
||||||
/* Used for implementing NV_vdpau_interop */
|
|
||||||
static inline enum pipe_format
|
|
||||||
VdpFormatRGBAToPipe(uint32_t vdpau_format)
|
|
||||||
{
|
|
||||||
switch (vdpau_format) {
|
|
||||||
case VDP_RGBA_FORMAT_R8:
|
|
||||||
return PIPE_FORMAT_R8_UNORM;
|
|
||||||
case VDP_RGBA_FORMAT_R8G8:
|
|
||||||
return PIPE_FORMAT_R8G8_UNORM;
|
|
||||||
case VDP_RGBA_FORMAT_A8:
|
|
||||||
return PIPE_FORMAT_A8_UNORM;
|
|
||||||
case VDP_RGBA_FORMAT_B10G10R10A2:
|
|
||||||
return PIPE_FORMAT_B10G10R10A2_UNORM;
|
|
||||||
case VDP_RGBA_FORMAT_B8G8R8A8:
|
|
||||||
return PIPE_FORMAT_B8G8R8A8_UNORM;
|
|
||||||
case VDP_RGBA_FORMAT_R10G10B10A2:
|
|
||||||
return PIPE_FORMAT_R10G10B10A2_UNORM;
|
|
||||||
case VDP_RGBA_FORMAT_R8G8B8A8:
|
|
||||||
return PIPE_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PIPE_FORMAT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _VDPAU_FUNCS_H_ */
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Authors:
|
|
||||||
* Christian König <christian.koenig@amd.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VDPAU_INTEROP_H_
|
|
||||||
#define _VDPAU_INTEROP_H_
|
|
||||||
|
|
||||||
/* driver specific functions for NV_vdpau_interop */
|
|
||||||
#ifndef VDP_FUNC_ID_BASE_DRIVER
|
|
||||||
#define VDP_FUNC_ID_BASE_DRIVER 0x2000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Older implementation relying on passing pipe_video_buffer and
|
|
||||||
* pipe_resources around. Deprecated and shouldn't be used for new things.
|
|
||||||
*/
|
|
||||||
#define VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 0)
|
|
||||||
#define VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 1)
|
|
||||||
|
|
||||||
struct pipe_resource;
|
|
||||||
struct pipe_video_buffer;
|
|
||||||
|
|
||||||
typedef struct pipe_video_buffer *VdpVideoSurfaceGallium(uint32_t surface);
|
|
||||||
typedef struct pipe_resource *VdpOutputSurfaceGallium(uint32_t surface);
|
|
||||||
|
|
||||||
#endif /* _VDPAU_INTEROP_H_ */
|
|
||||||
|
|
@ -8,8 +8,7 @@ foreach d : [[with_gallium_r300 or with_gallium_radeonsi or with_gallium_r600, '
|
||||||
[with_gallium_radeonsi, 'amdgpu_winsys_create'],
|
[with_gallium_radeonsi, 'amdgpu_winsys_create'],
|
||||||
[with_gallium_nouveau, 'nouveau_drm_screen_create'],
|
[with_gallium_nouveau, 'nouveau_drm_screen_create'],
|
||||||
[with_gallium_freedreno, 'fd_drm_screen_create_renderonly'],
|
[with_gallium_freedreno, 'fd_drm_screen_create_renderonly'],
|
||||||
[amd_with_llvm and with_gallium_radeonsi, 'ac_init_shared_llvm_once'],
|
[amd_with_llvm and with_gallium_radeonsi, 'ac_init_shared_llvm_once']]
|
||||||
[with_gallium_vdpau, 'vdp_imp_device_create_x11']]
|
|
||||||
if d[0]
|
if d[0]
|
||||||
sym_config.set(d[1], d[1] + ';')
|
sym_config.set(d[1], d[1] + ';')
|
||||||
else
|
else
|
||||||
|
|
@ -216,12 +215,6 @@ if with_gallium_va
|
||||||
subdir('targets/va')
|
subdir('targets/va')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if with_gallium_vdpau
|
|
||||||
subdir('frontends/vdpau')
|
|
||||||
if not with_dri
|
|
||||||
subdir('targets/vdpau')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if with_gallium_mediafoundation
|
if with_gallium_mediafoundation
|
||||||
subdir('frontends/mediafoundation')
|
subdir('frontends/mediafoundation')
|
||||||
subdir('targets/mediafoundation')
|
subdir('targets/mediafoundation')
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@
|
||||||
@fd_drm_screen_create_renderonly@
|
@fd_drm_screen_create_renderonly@
|
||||||
@ac_init_shared_llvm_once@
|
@ac_init_shared_llvm_once@
|
||||||
@va_driver_init@
|
@va_driver_init@
|
||||||
@vdp_imp_device_create_x11@
|
|
||||||
local:
|
local:
|
||||||
*;
|
*;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,11 @@ gallium_dri_drivers = []
|
||||||
gallium_dri_link_with = []
|
gallium_dri_link_with = []
|
||||||
gallium_dri_link_whole = []
|
gallium_dri_link_whole = []
|
||||||
|
|
||||||
if with_gallium_va or with_gallium_vdpau
|
if with_gallium_va
|
||||||
gallium_dri_link_with += [libgalliumvlwinsys]
|
gallium_dri_link_with += [libgalliumvlwinsys]
|
||||||
if with_gallium_va
|
if with_gallium_va
|
||||||
gallium_dri_link_whole += [libva_st]
|
gallium_dri_link_whole += [libva_st]
|
||||||
endif
|
endif
|
||||||
if with_gallium_vdpau
|
|
||||||
gallium_dri_link_whole += [libvdpau_st]
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
dri_sym = configure_file(input : 'dri.sym.in', output : 'dri.sym', configuration : sym_config)
|
dri_sym = configure_file(input : 'dri.sym.in', output : 'dri.sym', configuration : sym_config)
|
||||||
|
|
@ -70,22 +67,16 @@ libgallium_dri = shared_library(
|
||||||
|
|
||||||
shared_glapi_lib = libgallium_dri
|
shared_glapi_lib = libgallium_dri
|
||||||
|
|
||||||
if with_gallium_va or with_gallium_vdpau
|
if with_gallium_va
|
||||||
va_drivers = []
|
va_drivers = []
|
||||||
vdpau_drivers = []
|
|
||||||
foreach d : [[with_gallium_r600, 'r600'],
|
foreach d : [[with_gallium_r600, 'r600'],
|
||||||
[with_gallium_radeonsi, 'radeonsi'],
|
[with_gallium_radeonsi, 'radeonsi'],
|
||||||
[with_gallium_nouveau, 'nouveau'],
|
[with_gallium_nouveau, 'nouveau'],
|
||||||
[with_gallium_virgl, 'virtio_gpu'],
|
[with_gallium_virgl, 'virtio_gpu'],
|
||||||
[with_gallium_d3d12_video, 'd3d12']]
|
[with_gallium_d3d12_video, 'd3d12']]
|
||||||
if d[0]
|
if d[0]
|
||||||
if with_gallium_va
|
|
||||||
va_drivers += '@0@_drv_video.so'.format(d[1])
|
va_drivers += '@0@_drv_video.so'.format(d[1])
|
||||||
endif
|
endif
|
||||||
if with_gallium_vdpau
|
|
||||||
vdpau_drivers += 'libvdpau_@0@.so.@1@.@2@.0'.format(d[1], VDPAU_MAJOR, VDPAU_MINOR)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
if va_drivers.length() > 0
|
if va_drivers.length() > 0
|
||||||
|
|
@ -98,15 +89,4 @@ if with_gallium_va or with_gallium_vdpau
|
||||||
install_tag : 'runtime',
|
install_tag : 'runtime',
|
||||||
)
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if vdpau_drivers.length() > 0
|
|
||||||
meson.add_install_script(
|
|
||||||
install_megadrivers,
|
|
||||||
libgallium_dri.full_path(),
|
|
||||||
vdpau_drivers_path,
|
|
||||||
vdpau_drivers,
|
|
||||||
'--megadriver-libdir', get_option('libdir'),
|
|
||||||
install_tag : 'runtime',
|
|
||||||
)
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
# Copyright © 2017-2018 Intel Corporation
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
# TODO: support non-static targets
|
|
||||||
# Static targets are always enabled in autotools (unless you modify
|
|
||||||
# configure.ac)
|
|
||||||
|
|
||||||
vdpau_link_args = []
|
|
||||||
vdpau_link_depends = []
|
|
||||||
vdpau_drivers = []
|
|
||||||
|
|
||||||
vdpau_sym = configure_file(input : 'vdpau.sym.in', output : 'vdpau.sym', configuration : sym_config)
|
|
||||||
|
|
||||||
if with_ld_version_script
|
|
||||||
vdpau_link_args += ['-Wl,--version-script', join_paths(meson.current_build_dir(), 'vdpau.sym')]
|
|
||||||
vdpau_link_depends += vdpau_sym
|
|
||||||
endif
|
|
||||||
if with_ld_dynamic_list
|
|
||||||
vdpau_link_args += ['-Wl,--dynamic-list', join_paths(meson.current_source_dir(), '../dri.dyn')]
|
|
||||||
vdpau_link_depends += files('../dri.dyn')
|
|
||||||
endif
|
|
||||||
|
|
||||||
link_with_libvdpau_gallium = [
|
|
||||||
libgalliumvlwinsys, libgalliumvl, libgallium,
|
|
||||||
libpipe_loader_static, libws_null, libwsw, libswdri, libswkmsdri,
|
|
||||||
]
|
|
||||||
|
|
||||||
if with_glx == 'xlib'
|
|
||||||
link_with_libvdpau_gallium += [libws_xlib]
|
|
||||||
endif
|
|
||||||
|
|
||||||
libvdpau_gallium = shared_library(
|
|
||||||
'vdpau_gallium',
|
|
||||||
'vdpau_target.c',
|
|
||||||
gnu_symbol_visibility : 'hidden',
|
|
||||||
link_args : [vdpau_link_args, ld_args_gc_sections],
|
|
||||||
include_directories : [
|
|
||||||
inc_include, inc_src, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_winsys, inc_gallium_drivers,
|
|
||||||
],
|
|
||||||
link_whole : [libvdpau_st],
|
|
||||||
link_with : link_with_libvdpau_gallium,
|
|
||||||
dependencies : [
|
|
||||||
idep_mesautil,
|
|
||||||
driver_r600, driver_radeonsi, driver_nouveau, driver_d3d12, driver_virgl,
|
|
||||||
],
|
|
||||||
link_depends : vdpau_link_depends,
|
|
||||||
soversion : '@0@.@1@.0'.format(VDPAU_MAJOR, VDPAU_MINOR),
|
|
||||||
install : true,
|
|
||||||
install_dir : vdpau_drivers_path,
|
|
||||||
name_suffix : libname_suffix,
|
|
||||||
)
|
|
||||||
foreach d : [[with_gallium_r600, 'r600'],
|
|
||||||
[with_gallium_radeonsi, 'radeonsi'],
|
|
||||||
[with_gallium_nouveau, 'nouveau'],
|
|
||||||
[with_gallium_virgl, 'virtio_gpu'],
|
|
||||||
[with_gallium_d3d12_video, 'd3d12']]
|
|
||||||
if d[0]
|
|
||||||
vdpau_drivers += 'libvdpau_@0@.so.@1@.@2@.0'.format(d[1], VDPAU_MAJOR, VDPAU_MINOR)
|
|
||||||
endif
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
if vdpau_drivers.length() > 0
|
|
||||||
meson.add_install_script(
|
|
||||||
install_megadrivers,
|
|
||||||
libvdpau_gallium.full_path(),
|
|
||||||
vdpau_drivers_path,
|
|
||||||
vdpau_drivers,
|
|
||||||
install_tag : 'runtime',
|
|
||||||
)
|
|
||||||
endif
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
global:
|
|
||||||
vdp_imp_device_create_x11;
|
|
||||||
@nouveau_drm_screen_create@
|
|
||||||
@radeon_drm_winsys_create@
|
|
||||||
@amdgpu_winsys_create@
|
|
||||||
@ac_init_shared_llvm_once@
|
|
||||||
local:
|
|
||||||
*;
|
|
||||||
};
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
#include "target-helpers/drm_helper.h"
|
|
||||||
#include "target-helpers/sw_helper.h"
|
|
||||||
Loading…
Add table
Reference in a new issue