aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fosphor/cl.c
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2014-07-24 01:32:52 +0200
committerSylvain Munaut <tnt@246tNt.com>2014-07-24 22:34:06 +0200
commit9433e6047828583a507ddf118e26c4c150721edf (patch)
tree7b59f658ba534d68279111187215ba07d8f3bc78 /lib/fosphor/cl.c
parentcc9f988a204971b072ddb4796d7bbe97a394f00e (diff)
fosphor/cl: Handle CL 1.1 vs 1.2 differently
The OpenCL 1.2 is nicer but we can't always use it and on linux, even if the CL_VERSION_1_2 exists, we can't trust it because distrib sometimes have CL 1.2 headers with a CL 1.1 dispatcher. So instead, we only assume we have 1.1 header and lib at compile time. Then at run-time we do a dynamic lookup of the 1.2 symbols from the lib. We also check if the actual selected platform does support 1.2 (you could have a 1.2 dispatcher with a 1.1 platform implementation). If both conditions are satisfied, then we dispatch the call to the 1.2 implementation and if not, then we dispatch them to a local fallback implementation of the functions (but limited to the functions we need) It's not pretty but it should work and it isolates all the hack magic inside cl_compat.{c,h} and you just use the CL1.2 API normally outside of it. Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'lib/fosphor/cl.c')
-rw-r--r--lib/fosphor/cl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/fosphor/cl.c b/lib/fosphor/cl.c
index 7cbb795..edf82c3 100644
--- a/lib/fosphor/cl.c
+++ b/lib/fosphor/cl.c
@@ -34,6 +34,7 @@
#include <string.h>
#include "cl_platform.h"
+#include "cl_compat.h"
#if defined(__APPLE__) || defined(MAXOSX)
# include <OpenGL/OpenGL.h>
@@ -461,7 +462,7 @@ cl_do_init(struct fosphor *self)
/* GL shared objects */
/* Waterfall texture */
- cl->mem_waterfall = clCreateFromGLTexture2D(cl->ctx,
+ cl->mem_waterfall = clCreateFromGLTexture(cl->ctx,
CL_MEM_READ_WRITE, GL_TEXTURE_2D, 0,
fosphor_gl_get_shared_id(self, GL_ID_TEX_WATERFALL),
&err
@@ -469,7 +470,7 @@ cl_do_init(struct fosphor *self)
CL_ERR_CHECK(err, "Unable to share waterfall texture into OpenCL context");
/* Histogram texture */
- cl->mem_histogram = clCreateFromGLTexture2D(cl->ctx,
+ cl->mem_histogram = clCreateFromGLTexture(cl->ctx,
CL_MEM_READ_WRITE, GL_TEXTURE_2D, 0,
fosphor_gl_get_shared_id(self, GL_ID_TEX_HISTOGRAM),
&err
@@ -600,6 +601,10 @@ fosphor_cl_init(struct fosphor *self)
fprintf(stderr, "[+] Selected device: %s\n", dev_name);
+ /* Setup compatibility layer for this platform */
+ cl_compat_init();
+ cl_compat_check_platform(cl->pl_id);
+
/* Initialize selected platform / device */
err = cl_do_init(self);
if (err)