summaryrefslogtreecommitdiff
path: root/utests/utest_helper.cpp
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@gmail.com>2013-08-26 22:45:48 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-09-06 16:24:57 +0800
commit4a6106b0b6bc13b76855cfa9b1f4d33248ed97c7 (patch)
tree806d6c058b4776af8c6cc099d97dae73dd2e8fe8 /utests/utest_helper.cpp
parent9a2fd56bc0982499449f2ea84d7e0d5a3d49ad82 (diff)
CL: Enalbe gl sharing with new egl extension.
The previous implementation is only for 2d/3d texture sharing and is implemented in a hacky fashinon. We need to replace it with a clean and complete one. We introduce a new egl extension to export low level layout information of a buffer object/texture/render buffer from the mesa dri driver to the cl driver layer. As the extension is not accpepted by mesa, we have to implement this new extension in beignet internally. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com> Tested-by: He Junyan <junyan.he@inbox.com>
Diffstat (limited to 'utests/utest_helper.cpp')
-rw-r--r--utests/utest_helper.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index 297c6a33..b4f61df4 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -294,10 +294,10 @@ error:
#include <cstring>
#define GET_DEVICE_STR_INFO(LOWER_NAME, NAME) \
std::string LOWER_NAME ##Str; \
- OCL_CALL (clGetDeviceInfo, device, NAME, 0, 0, &param_value_size); \
+ OCL_CALL (clGetDeviceInfo, device, CL_DEVICE_##NAME, 0, 0, &param_value_size); \
{ \
std::vector<char> param_value(param_value_size); \
- OCL_CALL (clGetDeviceInfo, device, NAME, \
+ OCL_CALL (clGetDeviceInfo, device, CL_DEVICE_##NAME, \
param_value_size, param_value.empty() ? NULL : &param_value.front(), \
&param_value_size); \
if (!param_value.empty()) \
@@ -311,7 +311,9 @@ cl_ocl_init(void)
cl_int status = CL_SUCCESS;
cl_uint platform_n;
size_t i;
+#ifdef HAS_EGL
bool hasGLExt = false;
+#endif
cl_context_properties *props = NULL;
/* Get the platform number */
@@ -331,20 +333,21 @@ cl_ocl_init(void)
OCL_CALL (clGetDeviceIDs, platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);
{
size_t param_value_size;
- GET_DEVICE_STR_INFO(profile, CL_DEVICE_PROFILE);
- GET_DEVICE_STR_INFO(name, CL_DEVICE_NAME);
- GET_DEVICE_STR_INFO(vendor, CL_DEVICE_VENDOR);
- GET_DEVICE_STR_INFO(version, CL_DEVICE_VERSION);
- GET_DEVICE_STR_INFO(opencl_c_version, CL_DEVICE_OPENCL_C_VERSION);
- GET_DEVICE_STR_INFO(driver_version, CL_DRIVER_VERSION);
- GET_DEVICE_STR_INFO(extensions, CL_DEVICE_EXTENSIONS);
+ GET_DEVICE_STR_INFO(profile, PROFILE);
+ GET_DEVICE_STR_INFO(name, NAME);
+ GET_DEVICE_STR_INFO(vendor, VENDOR);
+ GET_DEVICE_STR_INFO(version, VERSION);
+ GET_DEVICE_STR_INFO(extensions, EXTENSIONS);
+ GET_DEVICE_STR_INFO(opencl_c_version, OPENCL_C_VERSION);
+#ifdef HAS_EGL
if (std::strstr(extensionsStr.c_str(), "cl_khr_gl_sharing")) {
hasGLExt = true;
}
+#endif
}
- if (hasGLExt) {
#ifdef HAS_EGL
+ if (hasGLExt) {
int i = 0;
props = new cl_context_properties[7];
props[i++] = CL_CONTEXT_PLATFORM;
@@ -356,8 +359,8 @@ cl_ocl_init(void)
props[i++] = (cl_context_properties)eglGetCurrentContext();
}
props[i++] = 0;
-#endif
}
+#endif
/* Now create a context */
ctx = clCreateContext(props, 1, &device, NULL, NULL, &status);
if (status != CL_SUCCESS) {