From: Gurchetan Singh Date: Thu, 26 Apr 2018 00:36:59 +0000 (-0700) Subject: minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fexternal-minigbm.git;a=commitdiff_plain;h=292da5365a373a8e1eed603fc3aa16e3595d8252 minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16 This is needed to support the following CTS test: android.graphics.cts.BitmapColorSpaceTest#test16bitHardware There have been some rumblings about adding 64-bit formats to : https://lists.freedesktop.org/archives/intel-gvt-dev/2017-July/001469.html However, nothing has landed, so let's just define our own format for the time being. BUG=b:77973662 TEST=Compile for kevin and kevin-arcnext Unfortunately, my P setup refuses to work, so let the lab test. Change-Id: I1fea16400ba6632a8ef17105e27bc7799d2af515 Reviewed-on: https://chromium-review.googlesource.com/1029355 Commit-Ready: Gurchetan Singh Tested-by: Gurchetan Singh Reviewed-by: Gurchetan Singh --- diff --git a/amdgpu.c b/amdgpu.c index 3bf5eb2..b01967a 100644 --- a/amdgpu.c +++ b/amdgpu.c @@ -33,9 +33,9 @@ struct amdgpu_priv { int drm_version; }; -const static uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, - DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, - DRM_FORMAT_XRGB8888 }; +const static uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, + DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, + DRM_FORMAT_XBGR16161616, DRM_FORMAT_XRGB8888 }; const static uint32_t texture_source_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8, DRM_FORMAT_NV21, DRM_FORMAT_NV12, DRM_FORMAT_YVU420_ANDROID }; diff --git a/cros_gralloc/cros_gralloc_helpers.cc b/cros_gralloc/cros_gralloc_helpers.cc index c09c2b5..4c9c68f 100644 --- a/cros_gralloc/cros_gralloc_helpers.cc +++ b/cros_gralloc/cros_gralloc_helpers.cc @@ -26,6 +26,8 @@ uint32_t cros_gralloc_convert_format(int format) return DRM_FORMAT_RGB888; case HAL_PIXEL_FORMAT_RGBA_8888: return DRM_FORMAT_ABGR8888; + case HAL_PIXEL_FORMAT_RGBA_FP16: + return DRM_FORMAT_XBGR16161616; case HAL_PIXEL_FORMAT_RGBX_8888: return DRM_FORMAT_XBGR8888; case HAL_PIXEL_FORMAT_YCbCr_420_888: diff --git a/cros_gralloc/cros_gralloc_helpers.h b/cros_gralloc/cros_gralloc_helpers.h index a55eebc..3e160ad 100644 --- a/cros_gralloc/cros_gralloc_helpers.h +++ b/cros_gralloc/cros_gralloc_helpers.h @@ -14,6 +14,10 @@ #include #include +#if ANDROID_VERSION < 0x0900 +#define HAL_PIXEL_FORMAT_RGBA_FP16 0x16 +#endif + constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA; constexpr uint32_t handle_data_size = ((sizeof(struct cros_gralloc_handle) - offsetof(cros_gralloc_handle, fds[0])) / sizeof(int)); diff --git a/drv.h b/drv.h index 09aa33f..c91382e 100644 --- a/drv.h +++ b/drv.h @@ -50,6 +50,7 @@ extern "C" { */ #define DRM_FORMAT_NONE fourcc_code('0', '0', '0', '0') +#define DRM_FORMAT_XBGR16161616 fourcc_code('9', '9', '9', '6') #define DRM_FORMAT_YVU420_ANDROID fourcc_code('9', '9', '9', '7') #define DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED fourcc_code('9', '9', '9', '8') #define DRM_FORMAT_FLEX_YCbCr_420_888 fourcc_code('9', '9', '9', '9') diff --git a/helpers.c b/helpers.c index 6ffb4f4..b0db2c7 100644 --- a/helpers.c +++ b/helpers.c @@ -55,6 +55,13 @@ static const struct planar_layout packed_4bpp_layout = { .bytes_per_pixel = { 4 } }; +static const struct planar_layout packed_8bpp_layout = { + .num_planes = 1, + .horizontal_subsampling = { 1 }, + .vertical_subsampling = { 1 }, + .bytes_per_pixel = { 8 } +}; + static const struct planar_layout biplanar_yuv_420_layout = { .num_planes = 2, .horizontal_subsampling = { 1, 2 }, @@ -137,6 +144,9 @@ static const struct planar_layout *layout_from_format(uint32_t format) case DRM_FORMAT_XRGB8888: return &packed_4bpp_layout; + case DRM_FORMAT_XBGR16161616: + return &packed_8bpp_layout; + default: drv_log("UNKNOWN FORMAT %d\n", format); return NULL; @@ -189,8 +199,7 @@ uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane) const struct planar_layout *layout = layout_from_format(format); assert(plane < layout->num_planes); - uint32_t plane_width = - DIV_ROUND_UP(width, layout->horizontal_subsampling[plane]); + uint32_t plane_width = DIV_ROUND_UP(width, layout->horizontal_subsampling[plane]); uint32_t stride = plane_width * layout->bytes_per_pixel[plane]; /* diff --git a/i915.c b/i915.c index fc877cb..af9d0ba 100644 --- a/i915.c +++ b/i915.c @@ -21,11 +21,11 @@ #define I915_CACHELINE_SIZE 64 #define I915_CACHELINE_MASK (I915_CACHELINE_SIZE - 1) -static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB1555, - DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565, - DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888, - DRM_FORMAT_XRGB1555, DRM_FORMAT_XRGB2101010, - DRM_FORMAT_XRGB8888 }; +static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB1555, + DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565, + DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888, + DRM_FORMAT_XBGR16161616, DRM_FORMAT_XRGB1555, + DRM_FORMAT_XRGB2101010, DRM_FORMAT_XRGB8888 }; static const uint32_t tileable_texture_source_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8, DRM_FORMAT_UYVY, DRM_FORMAT_YUYV }; diff --git a/mediatek.c b/mediatek.c index cfb60b3..379a119 100644 --- a/mediatek.c +++ b/mediatek.c @@ -23,9 +23,9 @@ struct mediatek_private_map_data { void *gem_addr; }; -static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, - DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, - DRM_FORMAT_XRGB8888 }; +static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, + DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, + DRM_FORMAT_XBGR16161616, DRM_FORMAT_XRGB8888 }; static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID }; diff --git a/rockchip.c b/rockchip.c index a0d9141..dfa1324 100644 --- a/rockchip.c +++ b/rockchip.c @@ -23,9 +23,9 @@ struct rockchip_private_map_data { void *gem_addr; }; -static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, - DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, - DRM_FORMAT_XRGB8888 }; +static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, + DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, + DRM_FORMAT_XBGR16161616, DRM_FORMAT_XRGB8888 }; static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_NV12, DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID };