graphics_Gralloc: add combination test, remove usage test
test_alloc_usage was ill-conceived, since you don't necessarily
need to allocate for every usage, and usages are usually a mask of
many different usages. Change this to test_alloc_combinations, which
tests combinations of formats and usages that we know Android
requests.
BUG=none
TEST=./gralloctest test_alloc_combinations passes
Change-Id: I695ba5b61ca10fb8b7c1d68b84d004268f083a9f
Reviewed-on: https://chromium-review.googlesource.com/500650
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Po-Hsien Wang <pwang@chromium.org>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
diff --git a/client/site_tests/graphics_Gralloc/graphics_Gralloc.py b/client/site_tests/graphics_Gralloc/graphics_Gralloc.py
index 8fcd8b8..36bdf1a 100644
--- a/client/site_tests/graphics_Gralloc/graphics_Gralloc.py
+++ b/client/site_tests/graphics_Gralloc/graphics_Gralloc.py
@@ -49,7 +49,7 @@
failures = []
# TODO(ihf): shard this test into multiple control files.
test_names = [
- 'alloc_varying_sizes', 'alloc_usage', 'api', 'gralloc_order',
+ 'alloc_varying_sizes', 'alloc_combinations', 'api', 'gralloc_order',
'uninitialized_handle', 'freed_handle', 'mapping', 'perform',
'ycbcr', 'async'
]
diff --git a/client/site_tests/graphics_Gralloc/src/gralloctest.c b/client/site_tests/graphics_Gralloc/src/gralloctest.c
index 42acac9..4d6d3b2 100644
--- a/client/site_tests/graphics_Gralloc/src/gralloctest.c
+++ b/client/site_tests/graphics_Gralloc/src/gralloctest.c
@@ -46,39 +46,39 @@
GRALLOC_DRM_GET_BACKING_STORE,
};
-/* See <system/graphics.h> for definitions. */
-static const uint32_t format_list[] = {
- HAL_PIXEL_FORMAT_BGRA_8888,
- HAL_PIXEL_FORMAT_BLOB,
- HAL_PIXEL_FORMAT_FLEX_RGB_888,
- HAL_PIXEL_FORMAT_FLEX_RGBA_8888,
- HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
- HAL_PIXEL_FORMAT_RAW10,
- HAL_PIXEL_FORMAT_RAW12,
- HAL_PIXEL_FORMAT_RAW16,
- HAL_PIXEL_FORMAT_RAW_OPAQUE,
- HAL_PIXEL_FORMAT_RGB_565,
- HAL_PIXEL_FORMAT_RGB_888,
- HAL_PIXEL_FORMAT_RGBA_8888,
- HAL_PIXEL_FORMAT_RGBX_8888,
- HAL_PIXEL_FORMAT_Y16,
- HAL_PIXEL_FORMAT_Y8,
- HAL_PIXEL_FORMAT_YCbCr_420_888,
- HAL_PIXEL_FORMAT_YCbCr_422_888,
- HAL_PIXEL_FORMAT_YCbCr_422_I,
- HAL_PIXEL_FORMAT_YCbCr_422_SP,
- HAL_PIXEL_FORMAT_YCbCr_444_888,
- HAL_PIXEL_FORMAT_YCrCb_420_SP,
- HAL_PIXEL_FORMAT_YV12,
+struct combinations {
+ int32_t format;
+ int32_t usage;
};
-/* See <hardware/gralloc.h> for descriptions. */
-static const uint32_t usage_list[] = {
- GRALLOC_USAGE_CURSOR, GRALLOC_USAGE_HW_RENDER,
- GRALLOC_USAGE_HW_TEXTURE, GRALLOC_USAGE_SW_READ_OFTEN,
- GRALLOC_USAGE_SW_WRITE_OFTEN, GRALLOC_USAGE_SW_READ_RARELY,
- GRALLOC_USAGE_SW_WRITE_RARELY,
+// clang-format off
+static struct combinations combos[] = {
+ { HAL_PIXEL_FORMAT_RGBA_8888,
+ GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN |
+ GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER |
+ GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_CURSOR },
+ { HAL_PIXEL_FORMAT_RGBA_8888,
+ GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_RENDER |
+ GRALLOC_USAGE_HW_COMPOSER },
+ { HAL_PIXEL_FORMAT_RGBX_8888,
+ GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN },
+ { HAL_PIXEL_FORMAT_YCbCr_420_888,
+ GRALLOC_USAGE_EXTERNAL_DISP | GRALLOC_USAGE_HW_COMPOSER |
+ GRALLOC_USAGE_HW_TEXTURE },
+ { HAL_PIXEL_FORMAT_YCbCr_420_888,
+ GRALLOC_USAGE_RENDERSCRIPT | GRALLOC_USAGE_SW_READ_OFTEN |
+ GRALLOC_USAGE_SW_WRITE_OFTEN },
+ { HAL_PIXEL_FORMAT_YV12,
+ GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_HW_COMPOSER |
+ GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP },
+ { HAL_PIXEL_FORMAT_RGB_565,
+ GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN },
+ { HAL_PIXEL_FORMAT_BGRA_8888,
+ GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN },
+ { HAL_PIXEL_FORMAT_BLOB,
+ GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN },
};
+// clang-format on
struct gralloctest {
buffer_handle_t handle; /* handle to the buffer */
@@ -300,26 +300,20 @@
/*
* This function tests that we find at least one working format for each
- * usage which we consider important.
+ * combos which we consider important.
*/
-static int test_alloc_usage(struct alloc_device_t *device)
+static int test_alloc_combinations(struct alloc_device_t *device)
{
- int i, j;
+ int i;
struct gralloctest test;
- gralloctest_init(&test, 512, 512, HAL_PIXEL_FORMAT_BGRA_8888,
- GRALLOC_USAGE_SW_READ_OFTEN);
+ gralloctest_init(&test, 512, 512, 0, 0);
- for (i = 0; i < ARRAY_SIZE(usage_list); i++) {
- test.usage = usage_list[i];
- int found = 0;
- for (j = 0; j < ARRAY_SIZE(format_list); j++) {
- test.format = format_list[j];
- if (allocate(device, &test))
- if (deallocate(device, &test))
- found = 1;
- }
- CHECK(found);
+ for (i = 0; i < ARRAY_SIZE(combos); i++) {
+ test.format = combos[i].format;
+ test.usage = combos[i].usage;
+ CHECK(allocate(device, &test));
+ CHECK(deallocate(device, &test));
}
return 1;
@@ -634,7 +628,7 @@
{
printf("usage: %s <test_name>\n\n", argv0);
printf("A valid test is one the following:\n");
- printf("alloc_varying_sizes\nalloc_usage\napi\ngralloc_order\n");
+ printf("alloc_varying_sizes\nalloc_combinations\napi\ngralloc_order\n");
printf("uninitialized_handle\nfreed_handle\nmapping\nperform\n");
printf("ycbcr\nasync\n");
}
@@ -669,8 +663,8 @@
if (strcmp(name, "alloc_varying_sizes") == 0) {
if (!test_alloc_varying_sizes(device))
goto fail;
- } else if (strcmp(name, "alloc_usage") == 0) {
- if (!test_alloc_usage(device))
+ } else if (strcmp(name, "alloc_combinations") == 0) {
+ if (!test_alloc_combinations(device))
goto fail;
} else if (strcmp(name, "api") == 0) {
if (!test_api(module))