Add fp16 pixel and window formats
Bug: 32984164
Test: compile
Change-Id: I8303afbf857796295a280c0d9438a3c403a11437
diff --git a/include/android/native_window.h b/include/android/native_window.h
index b60b9f1..b017a25 100644
--- a/include/android/native_window.h
+++ b/include/android/native_window.h
@@ -38,12 +38,18 @@
* Pixel formats that a window can use.
*/
enum {
+ // NOTE: these values must match the values from graphics/common/x.x/types.hal
+
/** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/
WINDOW_FORMAT_RGBA_8888 = 1,
/** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits. **/
WINDOW_FORMAT_RGBX_8888 = 2,
/** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/
WINDOW_FORMAT_RGB_565 = 4,
+ /** Red: 16 bits, Green: 16 bits, Blue: 16 bits, Alpha: 16 bits. **/
+ WINDOW_FORMAT_RGBA_FP16 = 0x16,
+ /** Red: 16 bits, Green: 16 bits, Blue: 16 bits, Unused: 16 bits. **/
+ WINDOW_FORMAT_RGBX_FP16 = 0x17,
};
struct ANativeWindow;
diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h
index f26fecb..99c6663 100644
--- a/include/ui/PixelFormat.h
+++ b/include/ui/PixelFormat.h
@@ -60,6 +60,8 @@
PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit ARGB
PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit ARGB
+ PIXEL_FORMAT_RGBA_FP16 = HAL_PIXEL_FORMAT_RGBA_FP16, // 64-bit RGBA
+ PIXEL_FORMAT_RGBX_FP16 = HAL_PIXEL_FORMAT_RGBX_FP16, // 64-bit RGB0
};
typedef int32_t PixelFormat;
diff --git a/libs/gui/CpuConsumer.cpp b/libs/gui/CpuConsumer.cpp
index 8393160..4acf618 100644
--- a/libs/gui/CpuConsumer.cpp
+++ b/libs/gui/CpuConsumer.cpp
@@ -64,6 +64,8 @@
switch (static_cast<int>(format)) {
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_RGBA_FP16:
+ case HAL_PIXEL_FORMAT_RGBX_FP16:
case HAL_PIXEL_FORMAT_RGB_888:
case HAL_PIXEL_FORMAT_RGB_565:
case HAL_PIXEL_FORMAT_BGRA_8888:
diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp
index 10e999c..9f0398d 100644
--- a/libs/gui/GLConsumer.cpp
+++ b/libs/gui/GLConsumer.cpp
@@ -856,6 +856,8 @@
switch (buf->getPixelFormat()) {
case PIXEL_FORMAT_RGBA_8888:
case PIXEL_FORMAT_RGBX_8888:
+ case PIXEL_FORMAT_RGBA_FP16:
+ case PIXEL_FORMAT_RGBX_FP16:
case PIXEL_FORMAT_RGB_888:
case PIXEL_FORMAT_RGB_565:
case PIXEL_FORMAT_BGRA_8888:
diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp
index cab1dde..3ceb638 100644
--- a/libs/ui/PixelFormat.cpp
+++ b/libs/ui/PixelFormat.cpp
@@ -22,6 +22,9 @@
uint32_t bytesPerPixel(PixelFormat format) {
switch (format) {
+ case PIXEL_FORMAT_RGBA_FP16:
+ case PIXEL_FORMAT_RGBX_FP16:
+ return 8;
case PIXEL_FORMAT_RGBA_8888:
case PIXEL_FORMAT_RGBX_8888:
case PIXEL_FORMAT_BGRA_8888:
@@ -38,6 +41,9 @@
uint32_t bitsPerPixel(PixelFormat format) {
switch (format) {
+ case PIXEL_FORMAT_RGBA_FP16:
+ case PIXEL_FORMAT_RGBX_FP16:
+ return 64;
case PIXEL_FORMAT_RGBA_8888:
case PIXEL_FORMAT_RGBX_8888:
case PIXEL_FORMAT_BGRA_8888:
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index d5a02e3..55a6093 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -475,6 +475,7 @@
// modify the EGLconfig's format before setting the native window's
// format.
+ // TODO: Add support for HAL_PIXEL_FORMAT_RGBA_FP16
// by default, just pick RGBA_8888
EGLint format = HAL_PIXEL_FORMAT_RGBA_8888;
android_dataspace dataSpace = HAL_DATASPACE_UNKNOWN;
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
index 2102457..c40a58c 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
@@ -1159,6 +1159,8 @@
switch (format) {
case PIXEL_FORMAT_RGBA_8888: return String8("RGBA_8888");
case PIXEL_FORMAT_RGBX_8888: return String8("RGBx_8888");
+ case PIXEL_FORMAT_RGBA_FP16: return String8("RGBA_FP16");
+ case PIXEL_FORMAT_RGBX_FP16: return String8("RGBx_FP16");
case PIXEL_FORMAT_RGB_888: return String8("RGB_888");
case PIXEL_FORMAT_RGB_565: return String8("RGB_565");
case PIXEL_FORMAT_BGRA_8888: return String8("BGRA_8888");
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 20c0261..89f968f 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1187,6 +1187,7 @@
switch (format) {
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_BGRA_8888:
+ case HAL_PIXEL_FORMAT_RGBA_FP16:
return false;
}
// in all other case, we have no blending (also for unknown formats)