hwc2: do not create EGL sync object at all for virtio-gpu
Bug: 200733475
Change-Id: Iccc23e8b18f0cd20269a3dfc332136501e1dbaac
Merged-In: Iccc23e8b18f0cd20269a3dfc332136501e1dbaac
diff --git a/system/hwc2/HostComposer.cpp b/system/hwc2/HostComposer.cpp
index c55eccd..05e6ac0 100644
--- a/system/hwc2/HostComposer.cpp
+++ b/system/hwc2/HostComposer.cpp
@@ -66,6 +66,21 @@
}
}
+static bool useAngleFromProperty() {
+ static constexpr const auto kEglProp = "ro.hardware.egl";
+
+ const auto eglProp = android::base::GetProperty(kEglProp, "");
+ DEBUG_LOG("%s: prop value is: %s", __FUNCTION__, eglProp.c_str());
+
+ if (eglProp == "angle") {
+ ALOGD("%s: Using ANGLE.\n", __FUNCTION__);
+ return true;
+ } else {
+ ALOGD("%s: Not using ANGLE.\n", __FUNCTION__);
+ return false;
+ }
+}
+
#define DEFINE_AND_VALIDATE_HOST_CONNECTION \
HostConnection* hostCon = createOrGetHostConnection(); \
if (!hostCon) { \
@@ -173,6 +188,8 @@
HWC2::Error HostComposer::init(const HotplugCallback& cb) {
mIsMinigbm = isMinigbmFromProperty();
+ mUseAngle = useAngleFromProperty();
+
if (mIsMinigbm) {
if (!mDrmPresenter.init(cb)) {
ALOGE("%s: failed to initialize DrmPresenter", __FUNCTION__);
@@ -797,11 +814,17 @@
uint64_t sync_handle, thread_handle;
int retire_fd;
- hostCon->lock();
- rcEnc->rcCreateSyncKHR(rcEnc, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs,
- 2 * sizeof(EGLint), true /* destroy when signaled */,
- &sync_handle, &thread_handle);
- hostCon->unlock();
+ // We don't use rc command to sync if we are using ANGLE on the guest with
+ // virtio-gpu.
+ bool useRcCommandToSync = !(mUseAngle && mIsMinigbm);
+
+ if (useRcCommandToSync) {
+ hostCon->lock();
+ rcEnc->rcCreateSyncKHR(rcEnc, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs,
+ 2 * sizeof(EGLint), true /* destroy when signaled */,
+ &sync_handle, &thread_handle);
+ hostCon->unlock();
+ }
if (mIsMinigbm) {
displayInfo.compositionResultDrmBuffer->flushToDisplay(display->getId(),
@@ -817,13 +840,15 @@
*outRetireFence = dup(retire_fd);
close(retire_fd);
- hostCon->lock();
- if (rcEnc->hasAsyncFrameCommands()) {
- rcEnc->rcDestroySyncKHRAsync(rcEnc, sync_handle);
- } else {
- rcEnc->rcDestroySyncKHR(rcEnc, sync_handle);
+ if (useRcCommandToSync) {
+ hostCon->lock();
+ if (rcEnc->hasAsyncFrameCommands()) {
+ rcEnc->rcDestroySyncKHRAsync(rcEnc, sync_handle);
+ } else {
+ rcEnc->rcDestroySyncKHR(rcEnc, sync_handle);
+ }
+ hostCon->unlock();
}
- hostCon->unlock();
} else {
// we set all layers Composition::Client, so do nothing.
diff --git a/system/hwc2/HostComposer.h b/system/hwc2/HostComposer.h
index fe4a49f..603807a 100644
--- a/system/hwc2/HostComposer.h
+++ b/system/hwc2/HostComposer.h
@@ -75,6 +75,8 @@
bool mIsMinigbm = false;
+ bool mUseAngle = false;
+
int mSyncDeviceFd = -1;
struct HostComposerDisplayInfo {