+/**
+ * Check for buggy apps that are known to not support modifiers, to avoid surprising them
+ * with a UBWC buffer.
+ */
+static bool should_avoid_ubwc(void)
+{
+#ifndef __ANDROID__
+ /* waffle is buggy and, requests a renderable buffer (which on qcom platforms, we
+ * want to use UBWC), and then passes it to the kernel discarding the modifier.
+ * So mesa ends up correctly rendering to as tiled+compressed, but kernel tries
+ * to display as linear. Other platforms do not see this issue, simply because
+ * they only use compressed (ex, AFBC) with the BO_USE_SCANOUT flag.
+ *
+ * See b/163137550
+ */
+ if (dlsym(RTLD_DEFAULT, "waffle_display_connect")) {
+ drv_log("WARNING: waffle detected, disabling UBWC\n");
+ return true;
+ }
+
+ /* The video_decode_accelerator_tests needs to read back the frames
+ * to verify they are correct. The frame verification relies on
+ * computing the MD5 of the video frame. UBWC results in a different
+ * MD5. This turns off UBWC for gtest until a proper frame
+ * comparison can be made
+ * Rely on the same mechanism that waffle is using, but this time check
+ * for a dynamic library function that is present in chrome, but missing
+ * in gtest. Cups is not loaded for video tests.
+ *
+ * See b/171260705
+ */
+ if (!dlsym(RTLD_DEFAULT, "cupsFilePrintf")) {
+ drv_log("WARNING: gtest detected, disabling UBWC\n");
+ return true;
+ }
+#endif
+ return false;
+}
+