diff options
Diffstat (limited to 'gralloc/gr_utils.cpp')
-rw-r--r-- | gralloc/gr_utils.cpp | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/gralloc/gr_utils.cpp b/gralloc/gr_utils.cpp index bc15166b..6a7e54b3 100644 --- a/gralloc/gr_utils.cpp +++ b/gralloc/gr_utils.cpp @@ -218,6 +218,21 @@ uint32_t GetDataAlignment(int format, uint64_t usage) { return align; } +bool IsGPUFlagSupported(uint64_t usage) { + bool ret = true; + if ((usage & BufferUsage::GPU_MIPMAP_COMPLETE)) { + ALOGE("GPU_MIPMAP_COMPLETE not supported"); + ret = false; + } + + if ((usage & BufferUsage::GPU_CUBE_MAP)) { + ALOGE("GPU_CUBE_MAP not supported"); + ret = false; + } + + return ret; +} + // Returns the final buffer size meant to be allocated with ion unsigned int GetSize(const BufferInfo &info, unsigned int alignedw, unsigned int alignedh) { unsigned int size = 0; @@ -226,8 +241,8 @@ unsigned int GetSize(const BufferInfo &info, unsigned int alignedw, unsigned int int height = info.height; uint64_t usage = info.usage; - if ((usage & BufferUsage::GPU_MIPMAP_COMPLETE) || (usage & BufferUsage::GPU_CUBE_MAP)) { - ALOGE("Invalid GPU usage flags present 0x%" PRIx64, usage); + if (!IsGPUFlagSupported(usage)) { + ALOGE("Unsupported GPU usage flags present 0x%" PRIx64, usage); return 0; } @@ -325,8 +340,19 @@ unsigned int GetSize(const BufferInfo &info, unsigned int alignedw, unsigned int void GetBufferSizeAndDimensions(const BufferInfo &info, unsigned int *size, unsigned int *alignedw, unsigned int *alignedh) { - GetAlignedWidthAndHeight(info, alignedw, alignedh); - *size = GetSize(info, *alignedw, *alignedh); + GraphicsMetadata graphics_metadata = {}; + GetBufferSizeAndDimensions(info, size, alignedw, alignedh, &graphics_metadata); +} + +void GetBufferSizeAndDimensions(const BufferInfo &info, unsigned int *size, unsigned int *alignedw, + unsigned int *alignedh, GraphicsMetadata *graphics_metadata) { + int buffer_type = GetBufferType(info.format); + if (CanUseAdrenoForSize(buffer_type, info.usage)) { + GetGpuResourceSizeAndDimensions(info, size, alignedw, alignedh, graphics_metadata); + } else { + GetAlignedWidthAndHeight(info, alignedw, alignedh); + *size = GetSize(info, *alignedw, *alignedh); + } } void GetYuvUbwcSPPlaneInfo(uint64_t base, uint32_t width, uint32_t height, int color_format, @@ -541,6 +567,11 @@ bool IsUBwcSupported(int format) { case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS: case HAL_PIXEL_FORMAT_RGBA_1010102: case HAL_PIXEL_FORMAT_RGBX_1010102: + case HAL_PIXEL_FORMAT_DEPTH_16: + case HAL_PIXEL_FORMAT_DEPTH_24: + case HAL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: + case HAL_PIXEL_FORMAT_DEPTH_32F: + case HAL_PIXEL_FORMAT_STENCIL_8: return true; default: break; @@ -558,10 +589,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 +1002,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 @@ -1008,4 +1043,8 @@ bool GetAdrenoSizeAPIStatus() { return false; } +int GetBufferType(int inputFormat) { + return IsYuvFormat(inputFormat) ? BUFFER_TYPE_VIDEO : BUFFER_TYPE_UI; +} + } // namespace gralloc |