-
Notifications
You must be signed in to change notification settings - Fork 223
Added test to verify negative result of clSetKernelArg with CL_INVALID_MEM_OBJECT and MSAA image object argument #2472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
cb7308b
2e9ae20
82e829f
18ca59b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |
| #include "testBase.h" | ||
| #include "harness/typeWrappers.h" | ||
| #include "harness/conversions.h" | ||
| #include "harness/featureHelpers.h" | ||
| #include "harness/stringHelpers.h" | ||
| #include <vector> | ||
|
|
||
| const char *sample_single_test_kernel[] = { | ||
|
|
@@ -87,6 +89,15 @@ const char *sample_two_kernel_program[] = { | |
| "\n" | ||
| "}\n" }; | ||
|
|
||
| const char *sample_arg_image_msaa_test_kernel = R"( | ||
| #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable | ||
| __kernel void arg_image_test(%s src, __global float4 *dst) | ||
| { | ||
| int%s coord = (int%s)(get_global_id(0)); | ||
| dst[0]=read_imagef(src, coord, 0); | ||
| } | ||
| )"; | ||
|
|
||
| const char *sample_read_only_image_test_kernel = R"( | ||
| __kernel void read_only_image_test(__write_only image2d_t img, __global uint4 *src) | ||
| { | ||
|
|
@@ -718,6 +729,62 @@ REGISTER_TEST(negative_set_immutable_memory_to_writeable_kernel_arg) | |
| return TEST_PASS; | ||
| } | ||
|
|
||
| REGISTER_TEST(negative_set_kernel_arg_invalid_image_msaa) | ||
| { | ||
| PASSIVE_REQUIRE_IMAGE_SUPPORT(device) | ||
|
|
||
| if (!is_extension_available(device, "cl_khr_gl_msaa_sharing")) | ||
| { | ||
| log_info("Test not run because 'cl_khr_gl_msaa_sharing' extension is " | ||
| "not supported by the tested device\n"); | ||
| return TEST_SKIPPED_ITSELF; | ||
| } | ||
|
|
||
| cl_int error = CL_SUCCESS; | ||
| clProgramWrapper program; | ||
| clKernelWrapper kernel; | ||
|
|
||
| std::vector<std::pair<std::string, std::string>> image_types = { | ||
| { "image2d_msaa_t", "2" }, | ||
| { "image2d_array_msaa_t", "4" }, | ||
| { "image2d_msaa_depth_t", "4" }, | ||
| { "image2d_array_msaa_depth_t", "4" } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not convinced that all of these cases should return an error. I think It's probably reasonable to expect that I think that Note that the error description in
This is somewhat ambiguous though - what is considered to be "a multisample depth image object"? Also, note that the spec does not require the image to be a 2D image, which seems like an oversight. The updated text in the GitHub spec sources but not yet in a published specification is:
This is more precise, but maybe we got the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
While mathematically a single-sample image is a subset of MSAA, I believe
My interpretation relies on the "must" keyword here. It implies that if the kernel expects |
||
| }; | ||
|
|
||
| constexpr cl_image_format format = { CL_RGBA, CL_UNSIGNED_INT8 }; | ||
| constexpr size_t size_dim = 32; | ||
| clMemWrapper image = | ||
| create_image_2d(context, CL_MEM_READ_ONLY, &format, size_dim, size_dim, | ||
| 0, nullptr, &error); | ||
| test_error(error, "clCreateBuffer failed"); | ||
|
|
||
| for (auto &el : image_types) | ||
| { | ||
| std::string program_source = | ||
| str_sprintf(std::string(sample_arg_image_msaa_test_kernel), | ||
| el.first.c_str(), el.second.c_str(), el.second.c_str()); | ||
|
|
||
| const char *ptr = program_source.c_str(); | ||
| cl_int error = create_single_kernel_helper(context, &program, &kernel, | ||
| 1, &ptr, "arg_image_test"); | ||
| test_error(error, "Unable to build test program"); | ||
|
|
||
| kernel = clCreateKernel(program, "arg_image_test", &error); | ||
| test_error(error, | ||
| "Unable to get arg_image_test kernel for built program"); | ||
|
|
||
| error = clSetKernelArg(kernel, 0, sizeof(cl_mem), &image); | ||
| test_failure_error_ret( | ||
| error, CL_INVALID_MEM_OBJECT, | ||
| "clSetKernelArg is supposed to fail with CL_INVALID_MEM_OBJECT " | ||
| "when arg_value does not follow the rules described in spec for " | ||
| "msaa images", | ||
| TEST_FAIL); | ||
| } | ||
|
|
||
| return TEST_PASS; | ||
| } | ||
|
|
||
| REGISTER_TEST(negative_set_read_write_image_arg) | ||
| { | ||
| cl_int error = CL_SUCCESS; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done