diff options
author | Saurabh Dubey <sdubey@codeaurora.org> | 2018-05-29 09:46:41 +0530 |
---|---|---|
committer | Saurabh Dubey <sdubey@codeaurora.org> | 2018-05-29 09:46:41 +0530 |
commit | b28b82b4259ce758dbbefb414e7433f939cde615 (patch) | |
tree | e5f4490ab9d44492ff47f5f09f8806ab45351e2f /gralloc/gr_utils.cpp | |
parent | cfe94acc8dcea9fa19d582e7c6d0f65e07d96f4f (diff) |
Gralloc: Use adreno APIs for buffer size calculations
1) Add support to use adreno APIs for non video layers'
buffer size calculations.
2) Add graphics metadata field to MetaData_t structure.
3) Add bindings for newly introduced formats in
GetGpuPixelFormat.
4) Add support to retrieve the graphics metadata in
Perform API.
5) Modify BUFFER_TYPE determination logic
Change-Id: I7674209b42d7cd39bc8de39e3a10582bb216e6cf
CRs-Fixed: 2226672
Diffstat (limited to 'gralloc/gr_utils.cpp')
-rw-r--r-- | gralloc/gr_utils.cpp | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/gralloc/gr_utils.cpp b/gralloc/gr_utils.cpp index f7ddac60..0436c2ae 100644 --- a/gralloc/gr_utils.cpp +++ b/gralloc/gr_utils.cpp @@ -32,7 +32,6 @@ #include "gr_adreno_info.h" #include "gr_utils.h" -#include "qdMetaData.h" #define ASTC_BLOCK_SIZE 16 @@ -42,8 +41,8 @@ namespace gralloc { -bool IsYuvFormat(const private_handle_t *hnd) { - switch (hnd->format) { +bool IsYuvFormat(int format) { + switch (format) { case HAL_PIXEL_FORMAT_YCbCr_420_SP: case HAL_PIXEL_FORMAT_YCbCr_422_SP: case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS: @@ -64,6 +63,9 @@ bool IsYuvFormat(const private_handle_t *hnd) { case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC: case HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC: case HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS: + // Below formats used by camera and VR + case HAL_PIXEL_FORMAT_BLOB: + case HAL_PIXEL_FORMAT_RAW_OPAQUE: return true; default: return false; @@ -943,4 +945,39 @@ int GetBufferLayout(private_handle_t *hnd, uint32_t stride[4], uint32_t offset[4 return 0; } +void GetGpuResourceSizeAndDimensions(const BufferInfo &info, unsigned int *size, + unsigned int *alignedw, unsigned int *alignedh, + GraphicsMetadata *graphics_metadata) { + GetAlignedWidthAndHeight(info, alignedw, alignedh); + AdrenoMemInfo* adreno_mem_info = AdrenoMemInfo::GetInstance(); + graphics_metadata->size = adreno_mem_info->AdrenoGetMetadataBlobSize(); + uint64_t adreno_usage = info.usage; + // If gralloc disables UBWC based on any of the checks, + // we pass modified usage flag to adreno to convey this. + int is_ubwc_enabled = IsUBwcEnabled(info.format, info.usage); + if (!is_ubwc_enabled) { + adreno_usage &= ~(GRALLOC_USAGE_PRIVATE_ALLOC_UBWC); + } + + // Call adreno api for populating metadata blob + int ret = adreno_mem_info->AdrenoInitMemoryLayout(graphics_metadata->data, info.width, + info.height, 1, info.format, 1, + is_ubwc_enabled, adreno_usage, 1); + if (ret != 0) { + ALOGE("%s Graphics metadata init failed", __FUNCTION__); + *size = 0; + return; + } + // Call adreno api with the metadata blob to get buffer size + *size = adreno_mem_info->AdrenoGetAlignedGpuBufferSize(graphics_metadata->data); +} + +bool GetAdrenoSizeAPIStatus() { + AdrenoMemInfo* adreno_mem_info = AdrenoMemInfo::GetInstance(); + if (adreno_mem_info) { + return adreno_mem_info->AdrenoSizeAPIAvaliable(); + } + return false; +} + } // namespace gralloc |