From f04c4c02559224c7d6e2e15b10e8b1de3d1e77f8 Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Thu, 8 Nov 2018 12:34:17 -0800 Subject: Allow GRALLOC_USAGE_HW_FB as usage hint for UBWC. Rollforward of I7cec70f463f6045116b78d6ccb1caf2a4c7023a3, but without accidentally enabling UBWC if render target flags are set. Bug: 118690958 Test: boots, manual tests, camera preview works. Change-Id: I84a1af4ff4a6c2177102f07d04f1e9ab85187fc0 --- gralloc/gr_utils.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gralloc') diff --git a/gralloc/gr_utils.cpp b/gralloc/gr_utils.cpp index 48d8bb53..c2371575 100644 --- a/gralloc/gr_utils.cpp +++ b/gralloc/gr_utils.cpp @@ -558,10 +558,12 @@ bool IsUBwcEnabled(int format, uint64_t usage) { // Allow UBWC, if an OpenGL client sets UBWC usage flag and GPU plus MDP // support the format. OR if a non-OpenGL client like Rotator, sets UBWC // usage flag and MDP supports the format. - if ((usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC) && IsUBwcSupported(format)) { - bool enable = true; + if (IsUBwcSupported(format)) { + bool enable = + (usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC) | (usage & BufferUsage::COMPOSER_CLIENT_TARGET); // Query GPU for UBWC only if buffer is intended to be used by GPU. - if ((usage & BufferUsage::GPU_TEXTURE) || (usage & BufferUsage::GPU_RENDER_TARGET)) { + if (enable && + ((usage & BufferUsage::GPU_TEXTURE) || (usage & BufferUsage::GPU_RENDER_TARGET))) { if (AdrenoMemInfo::GetInstance()) { enable = AdrenoMemInfo::GetInstance()->IsUBWCSupportedByGPU(format); } @@ -969,6 +971,8 @@ void GetGpuResourceSizeAndDimensions(const BufferInfo &info, unsigned int *size, int is_ubwc_enabled = IsUBwcEnabled(info.format, info.usage); if (!is_ubwc_enabled) { adreno_usage &= ~(GRALLOC_USAGE_PRIVATE_ALLOC_UBWC); + } else { + adreno_usage |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC; } // Call adreno api for populating metadata blob -- cgit v1.2.3