Support HAL_PIXEL_FORMAT_RGBA_FP16 in gralloc
BUG: 75778024
BUG: 78194651
Test: Ran CtsGraphics tests
Change-Id: I19c07970d657dfb6612db1b704e4f6d4e506b7b3
diff --git a/common/vsoc/shm/graphics.h b/common/vsoc/shm/graphics.h
index feaf7f8..22fe047 100644
--- a/common/vsoc/shm/graphics.h
+++ b/common/vsoc/shm/graphics.h
@@ -83,6 +83,8 @@
VSOC_PIXEL_FORMAT_RGBX_8888 = PixelFormatBuilder<4,1>::value,
VSOC_PIXEL_FORMAT_BGRA_8888 = PixelFormatBuilder<4,2>::value,
+ VSOC_PIXEL_FORMAT_RGBA_FP16 = PixelFormatBuilder<8,0>::value,
+
// VSOC_PIXEL_FORMAT_IMPLEMENTATION_DEFINED intentionally left out. The HALs
// should choose one of the defined contrete types.
//
@@ -137,6 +139,7 @@
ASSERT_SHM_CONSTANT_VALUE(VSOC_PIXEL_FORMAT_RGBA_8888, multi_region);
ASSERT_SHM_CONSTANT_VALUE(VSOC_PIXEL_FORMAT_RGBX_8888, multi_region);
ASSERT_SHM_CONSTANT_VALUE(VSOC_PIXEL_FORMAT_BGRA_8888, multi_region);
+ASSERT_SHM_CONSTANT_VALUE(VSOC_PIXEL_FORMAT_RGBA_FP16, multi_region);
namespace layout {
diff --git a/common/vsoc/shm/version.h b/common/vsoc/shm/version.h
index 0efae81..895b87b 100644
--- a/common/vsoc/shm/version.h
+++ b/common/vsoc/shm/version.h
@@ -89,6 +89,7 @@
static const uint32_t VSOC_PIXEL_FORMAT_RGBA_8888 = 24;
static const uint32_t VSOC_PIXEL_FORMAT_RGBX_8888 = 25;
static const uint32_t VSOC_PIXEL_FORMAT_BGRA_8888 = 26;
+static const uint32_t VSOC_PIXEL_FORMAT_RGBA_FP16 = 56;
} // namespace constant_values
} // namespace multi_region
diff --git a/guest/hals/gralloc/gralloc.cpp b/guest/hals/gralloc/gralloc.cpp
index 5d395db..fda705e 100644
--- a/guest/hals/gralloc/gralloc.cpp
+++ b/guest/hals/gralloc/gralloc.cpp
@@ -52,6 +52,10 @@
inline int formatToBytesPerPixel(int format) {
switch (format) {
+#if VSOC_PLATFORM_SDK_AFTER(N_MR1)
+ case HAL_PIXEL_FORMAT_RGBA_FP16:
+ return 8;
+#endif
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
case HAL_PIXEL_FORMAT_BGRA_8888:
@@ -69,7 +73,7 @@
return 1;
default:
ALOGE("%s: unknown format=%d", __FUNCTION__, format);
- return 4;
+ return 8;
}
}
diff --git a/guest/hals/gralloc/legacy/gralloc_vsoc_priv.h b/guest/hals/gralloc/legacy/gralloc_vsoc_priv.h
index f810650..a324f3a 100644
--- a/guest/hals/gralloc/legacy/gralloc_vsoc_priv.h
+++ b/guest/hals/gralloc/legacy/gralloc_vsoc_priv.h
@@ -152,6 +152,10 @@
static inline int formatToBytesPerPixel(int format) {
switch (format) {
+#if VSOC_PLATFORM_SDK_AFTER(N_MR1)
+ case HAL_PIXEL_FORMAT_RGBA_FP16:
+ return 8;
+#endif
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
case HAL_PIXEL_FORMAT_BGRA_8888:
@@ -175,7 +179,7 @@
#endif
default:
ALOGE("%s: unknown format=%d", __FUNCTION__, format);
- return 4;
+ return 8;
}
}
@@ -239,6 +243,10 @@
case HAL_PIXEL_FORMAT_FLEX_RGB_888:
return "FLEX_RGB_888";
#endif
+#if VSOC_PLATFORM_SDK_AFTER(N_MR1)
+ case HAL_PIXEL_FORMAT_RGBA_FP16:
+ return "RGBA_FP16";
+#endif
// Formats that have been removed
#if VSOC_PLATFORM_SDK_BEFORE(K)