diff options
author | Philip Langdale <philipl@overt.org> | 2019-10-02 11:13:21 -0700 |
---|---|---|
committer | Niklas Haas <github-c6e1c8@haasn.xyz> | 2020-07-14 07:32:04 +0200 |
commit | fba1c681b89502586a5ad467b729ed3878cacd3a (patch) | |
tree | c0d839a85e151c956a6f386b4e1055c84523efcc /video/out/hwdec | |
parent | 22e7c700dd86654d132cf3a4bc4b57dbd7da27a7 (diff) | |
download | mpv-fba1c681b89502586a5ad467b729ed3878cacd3a.tar.bz2 mpv-fba1c681b89502586a5ad467b729ed3878cacd3a.tar.xz |
vo_gpu: hwdec_vaapi: handle lack of object size with AMD drivers
It turns out that the AMD driver doesn't bother to set the size
field in the descriptor for an exported VA surface. I guess they
assume the caller can always use lseek() and don't bother. So, we
need to use lseek() in these situations.
Modified-by: Niklas Haas <git@haasn.xyz>
Guarded this behind PL_API_VER >= 88 to prevent it from exploding on
older libplacebo versions, where vaapi support does not yet work
properly on AMD due to lack of DRM modifiers.
Diffstat (limited to 'video/out/hwdec')
-rw-r--r-- | video/out/hwdec/hwdec_vaapi_vk.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/video/out/hwdec/hwdec_vaapi_vk.c b/video/out/hwdec/hwdec_vaapi_vk.c index 7f09a7e895..1cee9e86b9 100644 --- a/video/out/hwdec/hwdec_vaapi_vk.c +++ b/video/out/hwdec/hwdec_vaapi_vk.c @@ -15,6 +15,9 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +#include <errno.h> +#include <unistd.h> + #include "config.h" #include "hwdec_vaapi.h" #include "video/out/placebo/ra_pl.h" @@ -41,6 +44,29 @@ static bool vaapi_vk_map(struct ra_hwdec_mapper *mapper) uint32_t size = p->desc.objects[id].size; uint32_t offset = p->desc.layers[n].offset[0]; +#if PL_API_VER >= 88 + // AMD drivers do not return the size in the surface description, so we + // need to query it manually. The reason we guard this logic behind + // PL_API_VER >= 88 is that the same drivers also require DRM format + // modifier support in order to not produce corrupted textures, so + // having this #ifdef merely exists to protect users from combining + // too-new mpv with too-old libplacebo. + if (size == 0) { + size = lseek(fd, 0, SEEK_END); + if (size == -1) { + MP_ERR(mapper, "Cannot obtain size of object with fd %d: %s\n", + fd, mp_strerror(errno)); + return false; + } + off_t err = lseek(fd, 0, SEEK_SET); + if (err == -1) { + MP_ERR(mapper, "Failed to reset offset for fd %d: %s\n", + fd, mp_strerror(errno)); + return false; + } + } +#endif + struct pl_tex_params tex_params = { .w = mp_image_plane_w(&p->layout, n), .h = mp_image_plane_h(&p->layout, n), |