mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2025-02-26 11:47:11 +00:00
Test if vaExportSurfaceHandle() works before claiming EGL export is supported
This commit is contained in:
parent
b800ce9ebe
commit
283f31a734
1 changed files with 41 additions and 0 deletions
|
@ -427,8 +427,49 @@ VAAPIRenderer::renderFrame(AVFrame* frame)
|
|||
|
||||
#ifdef HAVE_EGL
|
||||
|
||||
// Ensure that vaExportSurfaceHandle() is supported by the VA-API driver
|
||||
bool
|
||||
VAAPIRenderer::canExportEGL() {
|
||||
AVHWDeviceContext* deviceContext = (AVHWDeviceContext*)m_HwContext->data;
|
||||
AVVAAPIDeviceContext* vaDeviceContext = (AVVAAPIDeviceContext*)deviceContext->hwctx;
|
||||
VASurfaceID surfaceId;
|
||||
VAStatus st;
|
||||
VADRMPRIMESurfaceDescriptor descriptor;
|
||||
|
||||
st = vaCreateSurfaces(vaDeviceContext->display,
|
||||
VA_RT_FORMAT_YUV420,
|
||||
1280,
|
||||
720,
|
||||
&surfaceId,
|
||||
1,
|
||||
nullptr,
|
||||
0);
|
||||
if (st != VA_STATUS_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"vaCreateSurfaces() failed: %d", st);
|
||||
return false;
|
||||
}
|
||||
|
||||
st = vaExportSurfaceHandle(vaDeviceContext->display,
|
||||
surfaceId,
|
||||
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
|
||||
VA_EXPORT_SURFACE_READ_ONLY | VA_EXPORT_SURFACE_SEPARATE_LAYERS,
|
||||
&descriptor);
|
||||
|
||||
vaDestroySurfaces(vaDeviceContext->display, &surfaceId, 1);
|
||||
|
||||
if (st != VA_STATUS_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"vaExportSurfaceHandle() failed: %d", st);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < descriptor.num_objects; ++i) {
|
||||
close(descriptor.objects[i].fd);
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"VAAPI driver supports exporting DRM PRIME surface handles");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue