aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fosphor/cl.c
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2014-07-24 19:53:19 +0200
committerSylvain Munaut <tnt@246tNt.com>2014-07-24 22:34:06 +0200
commit35ec2209e4b28f22a1bba5afe589ce8d33b5c681 (patch)
treeaa7d620b7ae94e7674c30eb7706f40d27f4e3349 /lib/fosphor/cl.c
parentb94ca239815caa182213cec6873c28606791d734 (diff)
fosphor/cl: Separate the buffer creation into separate helper
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'lib/fosphor/cl.c')
-rw-r--r--lib/fosphor/cl.c65
1 files changed, 42 insertions, 23 deletions
diff --git a/lib/fosphor/cl.c b/lib/fosphor/cl.c
index edf82c3..1dba2de 100644
--- a/lib/fosphor/cl.c
+++ b/lib/fosphor/cl.c
@@ -374,6 +374,44 @@ error:
}
static int
+cl_init_buffers_gl(struct fosphor *self)
+{
+ struct fosphor_cl_state *cl = self->cl;
+ cl_int err;
+
+ /* GL shared objects */
+ /* Waterfall texture */
+ cl->mem_waterfall = clCreateFromGLTexture(cl->ctx,
+ CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0,
+ fosphor_gl_get_shared_id(self, GL_ID_TEX_WATERFALL),
+ &err
+ );
+ CL_ERR_CHECK(err, "Unable to share waterfall texture into OpenCL context");
+
+ /* Histogram texture */
+ 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
+ );
+ CL_ERR_CHECK(err, "Unable to share histogram texture into OpenCL context");
+
+ /* Spectrum VBO */
+ cl->mem_spectrum = clCreateFromGLBuffer(cl->ctx,
+ CL_MEM_WRITE_ONLY,
+ fosphor_gl_get_shared_id(self, GL_ID_VBO_SPECTRUM),
+ &err
+ );
+ CL_ERR_CHECK(err, "Unable to share spectrum VBO into OpenCL context");
+
+ /* All done */
+ err = 0;
+
+error:
+ return err;
+}
+
+static int
cl_do_init(struct fosphor *self)
{
struct fosphor_cl_state *cl = self->cl;
@@ -460,30 +498,11 @@ cl_do_init(struct fosphor *self)
CL_ERR_CHECK(err, "Unable to configure FFT kernel");
- /* GL shared objects */
- /* Waterfall texture */
- 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
- );
- CL_ERR_CHECK(err, "Unable to share waterfall texture into OpenCL context");
-
- /* Histogram texture */
- 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
- );
- CL_ERR_CHECK(err, "Unable to share histogram texture into OpenCL context");
+ /* Display kernel result memory objects */
+ err = cl_init_buffers_gl(self);
- /* Spectrum VBO */
- cl->mem_spectrum = clCreateFromGLBuffer(cl->ctx,
- CL_MEM_WRITE_ONLY,
- fosphor_gl_get_shared_id(self, GL_ID_VBO_SPECTRUM),
- &err
- );
- CL_ERR_CHECK(err, "Unable to share spectrum VBO into OpenCL context");
+ if (err != CL_SUCCESS)
+ goto error;
/* Display program/kernel */
if (cl->feat.flags & FLG_CL_NVIDIA_SM11)