[Piglit] [PATCH 2/2] cl: check for image support using util/ functions
Serge Martin
edb+piglit at sigluy.net
Fri May 6 11:11:52 UTC 2016
---
tests/cl/api/create-image.c | 19 +------------------
tests/cl/api/create-sampler.c | 18 +-----------------
tests/cl/api/enqueue-fill-image.c | 10 +---------
tests/cl/api/get-image-info.c | 19 +------------------
tests/cl/api/set-kernel-arg.c | 18 +-----------------
5 files changed, 5 insertions(+), 79 deletions(-)
diff --git a/tests/cl/api/create-image.c b/tests/cl/api/create-image.c
index 1ee5f71..29e552c 100644
--- a/tests/cl/api/create-image.c
+++ b/tests/cl/api/create-image.c
@@ -38,23 +38,6 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
PIGLIT_CL_API_TEST_CONFIG_END
-static bool context_has_image_support(const piglit_cl_context ctx)
-{
- unsigned i;
- for(i = 0; i < ctx->num_devices; i++) {
- int *image_support =
- piglit_cl_get_device_info(ctx->device_ids[i],
- CL_DEVICE_IMAGE_SUPPORT);
- if (*image_support) {
- free(image_support);
- return true;
- }
-
- free(image_support);
- }
- return false;
-}
-
static void
no_image_check_invalid(
cl_int errcode_ret,
@@ -107,7 +90,7 @@ piglit_cl_test(const int argc,
const struct piglit_cl_api_test_config* config,
const struct piglit_cl_api_test_env* env)
{
- if (!context_has_image_support(env->context)) {
+ if (!piglit_cl_get_context_image_support(env->context)) {
return no_image_tests(env);
} else {
return PIGLIT_PASS;
diff --git a/tests/cl/api/create-sampler.c b/tests/cl/api/create-sampler.c
index dcdef05..d51fe47 100644
--- a/tests/cl/api/create-sampler.c
+++ b/tests/cl/api/create-sampler.c
@@ -36,22 +36,6 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
PIGLIT_CL_API_TEST_CONFIG_END
-static bool context_has_image_support(const piglit_cl_context ctx)
-{
- unsigned i;
- for(i = 0; i < ctx->num_devices; i++) {
- int *image_support =
- piglit_cl_get_device_info(ctx->device_ids[i],
- CL_DEVICE_IMAGE_SUPPORT);
- if (*image_support) {
- free(image_support);
- return true;
- }
- free(image_support);
- }
- return false;
-}
-
static enum piglit_result
no_image_tests(const struct piglit_cl_api_test_env* env)
{
@@ -80,7 +64,7 @@ piglit_cl_test(const int argc,
const struct piglit_cl_api_test_config* config,
const struct piglit_cl_api_test_env* env)
{
- if (!context_has_image_support(env->context)) {
+ if (!piglit_cl_get_context_image_support(env->context)) {
return no_image_tests(env);
} else {
return PIGLIT_PASS;
diff --git a/tests/cl/api/enqueue-fill-image.c b/tests/cl/api/enqueue-fill-image.c
index 2839b67..4de5dca 100644
--- a/tests/cl/api/enqueue-fill-image.c
+++ b/tests/cl/api/enqueue-fill-image.c
@@ -104,19 +104,11 @@ piglit_cl_test(const int argc,
cl_command_queue queue = env->context->command_queues[0];
int i;
- cl_bool *image_support =
- piglit_cl_get_device_info(env->context->device_ids[0],
- CL_DEVICE_IMAGE_SUPPORT);
-
- if (!*image_support) {
+ if (!piglit_cl_get_device_image_support(env->context->device_ids[0])) {
fprintf(stderr, "No image support\n");
- free(image_support);
return PIGLIT_SKIP;
}
- free(image_support);
- image_support = NULL;
-
img_format.image_channel_order = CL_RGBA;
img_format.image_channel_data_type = CL_UNSIGNED_INT8;
img_desc.image_type = CL_MEM_OBJECT_IMAGE2D;
diff --git a/tests/cl/api/get-image-info.c b/tests/cl/api/get-image-info.c
index a8b5bec..d4dc842 100644
--- a/tests/cl/api/get-image-info.c
+++ b/tests/cl/api/get-image-info.c
@@ -46,23 +46,6 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
PIGLIT_CL_API_TEST_CONFIG_END
-static bool context_has_image_support(const piglit_cl_context ctx)
-{
- int ret = 0;
- unsigned i;
- for(i = 0; i < ctx->num_devices; i++) {
- int *image_support =
- piglit_cl_get_device_info(ctx->device_ids[i],
- CL_DEVICE_IMAGE_SUPPORT);
- if (image_support)
- ret |= *image_support;
-
- free(image_support);
- }
- return ret;
-}
-
-
enum piglit_result
piglit_cl_test(const int argc,
const char** argv,
@@ -79,7 +62,7 @@ piglit_cl_test(const int argc,
.image_channel_data_type = CL_FLOAT,
};
- if (!context_has_image_support(env->context)) {
+ if (!piglit_cl_get_context_image_support(env->context)) {
fprintf(stderr, "No device with image support found!\n");
return PIGLIT_SKIP;
}
diff --git a/tests/cl/api/set-kernel-arg.c b/tests/cl/api/set-kernel-arg.c
index 0d476e3..9b5a567 100644
--- a/tests/cl/api/set-kernel-arg.c
+++ b/tests/cl/api/set-kernel-arg.c
@@ -59,22 +59,6 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
PIGLIT_CL_API_TEST_CONFIG_END
-static bool
-get_device_image_support(cl_device_id device)
-{
- cl_bool *has_image =
- piglit_cl_get_device_info(device, CL_DEVICE_IMAGE_SUPPORT);
-
- if (!*has_image) {
- fprintf(stdout, "No image support. Sampler arg won't be tested\n");
- free(has_image);
- return false;
- }
-
- free(has_image);
- return true;
-}
-
static void
test (cl_kernel kernel,
cl_uint arg_index,
@@ -126,7 +110,7 @@ piglit_cl_test(const int argc,
cl_mem invalid_buffer;
cl_bool image_support =
- get_device_image_support(env->context->device_ids[0]);
+ piglit_cl_get_device_image_support(env->context->device_ids[0]);
/*** Normal usage ***/
kernel = clCreateKernel(env->program, "kernel_fun", &errNo);
--
2.5.5
More information about the Piglit
mailing list