From 146f745d0de292a04b88d1665edbdb4c75f9dbeb Mon Sep 17 00:00:00 2001 From: Roman Kiryanov <rkir@google.com> Date: Mon, 13 May 2019 14:11:47 -0700 Subject: [PATCH] Put HAL_PIXEL_FORMAT_RGB_888 back for CPU access BasicVulkanGpuTest expilictly requests GPU_SAMPLED_IMAGE usage, we can use it to decide if we support RGB_888 (Vulkan does not support it). HardwareBufferTest#testCreate requests only CPU access. Bug: 132447509 Bug: 131184223 Test: [OpenGL, Vulkan] x [CtsGraphicsTestCases, CtsHardwareTestCases] Change-Id: I2bbcddd2b3153208cbb00b76caca9564b743c61e Merged-In: Ib3f5d6cd9ed361205952d99b2f7173d5518dea79 Signed-off-by: Roman Kiryanov <rkir@google.com> --- system/gralloc/gralloc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp index d76ac0b..a83ca96 100644 --- a/system/gralloc/gralloc.cpp +++ b/system/gralloc/gralloc.cpp @@ -479,6 +479,7 @@ static int gralloc_alloc(alloc_device_t* dev, bool sw_write = (0 != (usage & GRALLOC_USAGE_SW_WRITE_MASK)); bool hw_write = (usage & GRALLOC_USAGE_HW_RENDER); bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK)); + const bool hw_texture = usage & GRALLOC_USAGE_HW_TEXTURE; #if PLATFORM_SDK_VERSION >= 17 bool hw_cam_write = (usage & GRALLOC_USAGE_HW_CAMERA_WRITE); bool hw_cam_read = (usage & GRALLOC_USAGE_HW_CAMERA_READ); @@ -541,6 +542,15 @@ static int gralloc_alloc(alloc_device_t* dev, glFormat = GL_RGBA; glType = GL_UNSIGNED_BYTE; break; + case HAL_PIXEL_FORMAT_RGB_888: + if (hw_texture) { + return -EINVAL; // we dont support RGB_888 for HW textures + } else { + bpp = 3; + glFormat = GL_RGB; + glType = GL_UNSIGNED_BYTE; + break; + } case HAL_PIXEL_FORMAT_RGB_565: bpp = 2; // Workaround: distinguish vs the RGB8/RGBA8 -- GitLab