gralloc: Allow UBWC for explicitly defined UBWC HAL pixel format
1. Allow UBWC allocation, if client is using an explicitly defined
UBWC HAL pixel format OR if client sets UBWC gralloc usage flag and
GPU supports the format.
2. EGL wants gralloc to set PRIV_FLAGS_UBWC_ALIGNED bit in private
handle flags, only if GPU supports UBWC for that format.
Change-Id: I4194a046217cbc4c0a8ac2b2fb4b73ebd5076fc2
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index a7c4a9a..72f5c44 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -764,12 +764,15 @@
bool isUBwcEnabled(int format, int usage)
{
- if (isUBwcFormat(format) ||
- ((usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC) && isUBwcSupported(format)))
- {
- // Allow UBWC, only if GPU supports it and CPU usage flags are not set
- if (AdrenoMemInfo::getInstance().isUBWCSupportedByGPU(format) &&
- !(usage & (GRALLOC_USAGE_SW_READ_MASK |
+ // Allow UBWC, if client is using an explicitly defined UBWC pixel format.
+ if (isUBwcFormat(format))
+ return true;
+
+ // Allow UBWC, if client sets UBWC gralloc usage flag & GPU supports format.
+ if ((usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC) && isUBwcSupported(format) &&
+ AdrenoMemInfo::getInstance().isUBWCSupportedByGPU(format)) {
+ // Allow UBWC, only if CPU usage flags are not set
+ if (!(usage & (GRALLOC_USAGE_SW_READ_MASK |
GRALLOC_USAGE_SW_WRITE_MASK))) {
return true;
}
diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp
index 9ab9d09..48da09e 100644
--- a/libgralloc/gpu.cpp
+++ b/libgralloc/gpu.cpp
@@ -149,7 +149,8 @@
flags |= private_handle_t::PRIV_FLAGS_TILE_RENDERED;
}
- if (isUBwcEnabled(format, usage)) {
+ if (AdrenoMemInfo::getInstance().isUBWCSupportedByGPU(format) &&
+ isUBwcEnabled(format, usage)) {
flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED;
}