2 * Copyright 2014 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Authors: Tom Stellard <thomas.stellard@amd.com>
27 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
29 #include "piglit-framework-cl-api.h"
31 PIGLIT_CL_API_TEST_CONFIG_BEGIN
33 config
.name
= "clCreateImage";
34 config
.version_min
= 10;
36 config
.run_per_platform
= true;
37 config
.create_context
= true;
39 PIGLIT_CL_API_TEST_CONFIG_END
42 no_image_check_invalid(
44 enum piglit_result
*result
,
47 if (!piglit_cl_check_error(errcode_ret
, CL_INVALID_OPERATION
)) {
48 fprintf(stderr
, "%s: CL_INVALID_OPERATION expected when no "
49 "devices support images.\n", name
);
50 piglit_merge_result(result
, PIGLIT_FAIL
);
54 static enum piglit_result
55 no_image_tests(const struct piglit_cl_api_test_env
* env
)
57 enum piglit_result result
= PIGLIT_PASS
;
58 cl_context cl_ctx
= env
->context
->cl_ctx
;
59 cl_mem_flags flags
= CL_MEM_READ_ONLY
;
60 cl_image_format image_format
;
61 size_t image_width
= 1;
62 size_t image_height
= 1;
63 size_t image_depth
= 2;
64 size_t image_row_pitch
= 0;
65 size_t image_slice_pitch
= 0;
66 void *host_ptr
= NULL
;
69 image_format
.image_channel_order
= CL_RGBA
;
70 image_format
.image_channel_data_type
= CL_FLOAT
;
72 clCreateImage2D(cl_ctx
, flags
, &image_format
, image_width
,
73 image_height
, image_row_pitch
, host_ptr
,
76 no_image_check_invalid(errcode_ret
, &result
, "clCreateImage2D");
78 clCreateImage3D(cl_ctx
, flags
, &image_format
, image_width
,
79 image_height
, image_depth
, image_row_pitch
,
80 image_slice_pitch
, host_ptr
, &errcode_ret
);
82 no_image_check_invalid(errcode_ret
, &result
, "clCreateImage3D");
88 piglit_cl_test(const int argc
,
90 const struct piglit_cl_api_test_config
* config
,
91 const struct piglit_cl_api_test_env
* env
)
93 if (!piglit_cl_get_context_image_support(env
->context
)) {
94 return no_image_tests(env
);