From d47f27ae3ef94671a716d2d4d3c34b77e3b45559 Mon Sep 17 00:00:00 2001 From: Yang Rong Date: Mon, 26 Aug 2013 15:44:55 +0800 Subject: [PATCH] Add pfn_notify support in clCreateContext. Remove assert in cl_create_context when pfn_notify is not NULL, and save it, but don't used now. Per spec, driver should call it when devices becomes unavailable. Now driver doesn't check the device status. Signed-off-by: Yang Rong Reviewed-by: Zhigang Gong --- src/cl_context.c | 5 ++++- src/cl_context.h | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cl_context.c b/src/cl_context.c index a48436c..822fdf5 100644 --- a/src/cl_context.c +++ b/src/cl_context.c @@ -123,7 +123,6 @@ cl_create_context(const cl_context_properties * properties, cl_int err = CL_SUCCESS; cl_uint prop_len = 0; /* XXX */ - FATAL_IF (pfn_notify != NULL || user_data != NULL, "Unsupported call back"); FATAL_IF (num_devices != 1, "Only one device is supported"); /* Check that we are getting the right platform */ @@ -144,6 +143,10 @@ cl_create_context(const cl_context_properties * properties, /* Attach the device to the context */ ctx->device = *devices; + /* Save the user callback and user data*/ + ctx->pfn_notify = pfn_notify; + ctx->user_data = user_data; + exit: if (errcode_ret != NULL) *errcode_ret = err; diff --git a/src/cl_context.h b/src/cl_context.h index 718d589..b1ef479 100644 --- a/src/cl_context.h +++ b/src/cl_context.h @@ -1,4 +1,4 @@ -/* +/* * Copyright © 2012 Intel Corporation * * This library is free software; you can redistribute it and/or @@ -44,8 +44,8 @@ struct _cl_context_prop { enum _cl_gl_context_type gl_type; cl_context_properties gl_context; union { - cl_context_properties egl_display; - cl_context_properties glx_display; + cl_context_properties egl_display; + cl_context_properties glx_display; cl_context_properties wgl_hdc; cl_context_properties cgl_sharegroup; }; @@ -72,6 +72,10 @@ struct _cl_context { struct _cl_context_prop props; cl_context_properties * prop_user; /* a copy of user passed context properties when create context */ cl_uint prop_len; /* count of the properties */ + void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *); + /* User's callback when error occur in context */ + void *user_data; /* A pointer to user supplied data */ + }; /* Implement OpenCL function */ -- 2.7.4