Fix vaExportSurfaceHandle() detection with i965 VAAPI driver

This commit is contained in:
Cameron Gutman 2020-05-14 20:56:24 -07:00
parent 01f6188824
commit a1b74e1220

View File

@ -446,6 +446,26 @@ VAAPIRenderer::canExportEGL() {
VASurfaceID surfaceId; VASurfaceID surfaceId;
VAStatus st; VAStatus st;
VADRMPRIMESurfaceDescriptor descriptor; VADRMPRIMESurfaceDescriptor descriptor;
VASurfaceAttrib attrs[2];
int attributeCount = 0;
// FFmpeg handles setting these quirk flags for us
if (!(vaDeviceContext->driver_quirks & AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE)) {
attrs[attributeCount].type = VASurfaceAttribMemoryType;
attrs[attributeCount].flags = VA_SURFACE_ATTRIB_SETTABLE;
attrs[attributeCount].value.type = VAGenericValueTypeInteger;
attrs[attributeCount].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA;
attributeCount++;
}
// These attributes are required for i965 to create a surface that can
// be successfully exported via vaExportSurfaceHandle(). iHD doesn't
// need these, but it doesn't seem to hurt either.
attrs[attributeCount].type = VASurfaceAttribPixelFormat;
attrs[attributeCount].flags = VA_SURFACE_ATTRIB_SETTABLE;
attrs[attributeCount].value.type = VAGenericValueTypeInteger;
attrs[attributeCount].value.value.i = VA_FOURCC_NV12;
attributeCount++;
st = vaCreateSurfaces(vaDeviceContext->display, st = vaCreateSurfaces(vaDeviceContext->display,
VA_RT_FORMAT_YUV420, VA_RT_FORMAT_YUV420,
@ -453,8 +473,8 @@ VAAPIRenderer::canExportEGL() {
720, 720,
&surfaceId, &surfaceId,
1, 1,
nullptr, attrs,
0); attributeCount);
if (st != VA_STATUS_SUCCESS) { if (st != VA_STATUS_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"vaCreateSurfaces() failed: %d", st); "vaCreateSurfaces() failed: %d", st);