Skip to content

Commit 5f6be59

Browse files
alexdean08Angle LUCI CQ
authored andcommitted
CL: Add check for 2d image creation from buffer
CL_INVALID_OPERATION must be returned when creating a 2d image from the buffer if cl_khr_image2d_from_buffer is not supported. Tests-Passing: OCLCTS.test_api consistency_2d_image_from_buffer Bug: angleproject:384765581 Change-Id: I431188b9c1d1881cf755058a8b8ca5741d17652d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6102106 Commit-Queue: Gowtham Tammana <[email protected]> Reviewed-by: Shahbaz Youssefi <[email protected]> Reviewed-by: Geoff Lang <[email protected]>
1 parent c289b30 commit 5f6be59

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/libANGLE/CLContext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class Context final : public _cl_context, public Object
113113
bool supportsImages() const;
114114
bool supportsIL() const;
115115
bool supportsBuiltInKernel(const std::string &name) const;
116+
bool supportsImage2DFromBuffer() const;
116117

117118
static void CL_CALLBACK ErrorCallback(const char *errinfo,
118119
const void *privateInfo,
@@ -180,6 +181,13 @@ inline bool Context::supportsImages() const
180181
}) != mDevices.cend());
181182
}
182183

184+
inline bool Context::supportsImage2DFromBuffer() const
185+
{
186+
return (std::find_if(mDevices.cbegin(), mDevices.cend(), [](const DevicePtr &ptr) {
187+
return ptr->getInfo().khrImage2D_FromBuffer == true;
188+
}) != mDevices.cend());
189+
}
190+
183191
inline bool Context::supportsIL() const
184192
{
185193
return (std::find_if(mDevices.cbegin(), mDevices.cend(), [](const DevicePtr &ptr) {

src/libANGLE/validationCL.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3086,6 +3086,15 @@ cl_int ValidateCreateImage(cl_context context,
30863086
return CL_INVALID_OPERATION;
30873087
}
30883088

3089+
// Returns CL_INVALID_OPERATION if no devices in context support creating a 2D image from a
3090+
// buffer.
3091+
const bool isImage2dFromBuffer =
3092+
image_desc->image_type == CL_MEM_OBJECT_IMAGE2D && image_desc->mem_object != NULL;
3093+
if (isImage2dFromBuffer && !ctx.supportsImage2DFromBuffer())
3094+
{
3095+
return CL_INVALID_OPERATION;
3096+
}
3097+
30893098
// CL_INVALID_IMAGE_SIZE if image dimensions specified in image_desc exceed the maximum
30903099
// image dimensions described in the Device Queries table for all devices in context.
30913100
const DevicePtrs &devices = ctx.getDevices();

0 commit comments

Comments
 (0)