From ec14381e0bd681c354de1a002894a628f8bf69e5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 12 Oct 2013 23:36:51 +0200 Subject: Bug 579: Use result value in checkForError(..) for CLGLTexture2d.createFromGL*, CLGLTexture3d.createFromGL*, CLGLImage2d.createFromGL* and CLGLBuffer.createFromGL* - instead of returned 'id' Thank you Johan & Daniel ! Using your original patch, I went through the other CLGL[Texture*|Image2d|Buffer] classes and ensured all are handled the same. Reported and 1st patch provided by: Johan Confirmed by: Daniel Balog --- src/com/jogamp/opencl/gl/CLGLBuffer.java | 10 +++++----- src/com/jogamp/opencl/gl/CLGLImage2d.java | 20 +++++++++++--------- src/com/jogamp/opencl/gl/CLGLTexture2d.java | 15 +++++++-------- src/com/jogamp/opencl/gl/CLGLTexture3d.java | 16 +++++++++------- 4 files changed, 32 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/com/jogamp/opencl/gl/CLGLBuffer.java b/src/com/jogamp/opencl/gl/CLGLBuffer.java index 7d41b0eb..a9fc49cd 100644 --- a/src/com/jogamp/opencl/gl/CLGLBuffer.java +++ b/src/com/jogamp/opencl/gl/CLGLBuffer.java @@ -40,7 +40,7 @@ import javax.media.opengl.GLContext; /** * Shared buffer between OpenGL and OpenCL contexts. - * @author Michael Bien + * @author Michael Bien, et.al. */ public final class CLGLBuffer extends CLBuffer implements CLGLObject { @@ -56,16 +56,16 @@ public final class CLGLBuffer extends CLBuffer implements C } - static CLGLBuffer create(CLContext context, B directBuffer, long size, int flags, int glObject) { + static CLGLBuffer create(CLContext context, B directBuffer, long size, int flags, int glBuffer) { checkBuffer(directBuffer, flags); CLGL clgli = (CLGL)getCL(context); int[] result = new int[1]; - long id = clgli.clCreateFromGLBuffer(context.ID, flags, glObject, result, 0); - CLException.checkForError(result[0], "can not create CLGLObject from #"+glObject); + long id = clgli.clCreateFromGLBuffer(context.ID, flags, glBuffer, result, 0); + CLException.checkForError(result[0], "can not create CLGLObject from glBuffer #"+glBuffer); - return new CLGLBuffer(context, directBuffer, id, glObject, size, flags); + return new CLGLBuffer(context, directBuffer, id, glBuffer, size, flags); } static void checkBuffer(B directBuffer, int flags) throws IllegalArgumentException { diff --git a/src/com/jogamp/opencl/gl/CLGLImage2d.java b/src/com/jogamp/opencl/gl/CLGLImage2d.java index dd6b9d5a..954a2334 100644 --- a/src/com/jogamp/opencl/gl/CLGLImage2d.java +++ b/src/com/jogamp/opencl/gl/CLGLImage2d.java @@ -31,17 +31,18 @@ package com.jogamp.opencl.gl; import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.opencl.CLContext; +import com.jogamp.opencl.CLException; import com.jogamp.opencl.CLImage2d; import com.jogamp.opencl.CLImageFormat; import com.jogamp.opencl.llb.impl.CLImageFormatImpl; + import java.nio.Buffer; -import javax.media.opengl.GLContext; -import static com.jogamp.opencl.llb.CL.*; +import javax.media.opengl.GLContext; /** * 2D OpenCL image representing an OpenGL renderbuffer. - * @author Michael Bien + * @author Michael Bien, et.al. */ public class CLGLImage2d extends CLImage2d implements CLGLObject { @@ -55,7 +56,7 @@ public class CLGLImage2d extends CLImage2d implements CLGLO this.GLID = glid; } - static CLGLImage2d createFromGLRenderbuffer(CLContext context, B directBuffer, int flags, int glObject) { + static CLGLImage2d createFromGLRenderbuffer(CLContext context, B directBuffer, int flags, int renderbuffer) { CLGLBuffer.checkBuffer(directBuffer, flags); @@ -63,19 +64,20 @@ public class CLGLImage2d extends CLImage2d implements CLGLO int[] result = new int[1]; CLGL clgli = (CLGL)cl; - long id = clgli.clCreateFromGLRenderbuffer(context.ID, flags, glObject, result, 0); + long id = clgli.clCreateFromGLRenderbuffer(context.ID, flags, renderbuffer, result, 0); + CLException.checkForError(result[0], "can not create CLGLImage2d from renderbuffer #"+renderbuffer+"."); - return createImage(context, id, directBuffer, glObject, flags); + return createImage(context, id, directBuffer, renderbuffer, flags); } static CLGLImage2d createImage(CLContext context, long id, B directBuffer, int glObject, int flags) { CLImageInfoAccessor accessor = new CLImageInfoAccessor(getCL(context), id); CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - int width = (int)accessor.getLong(CL_IMAGE_WIDTH); - int height = (int)accessor.getLong(CL_IMAGE_HEIGHT); + int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); + int height = (int)accessor.getLong(CL.CL_IMAGE_HEIGHT); return new CLGLImage2d(context, directBuffer, format, accessor, width, height, id, glObject, flags); } diff --git a/src/com/jogamp/opencl/gl/CLGLTexture2d.java b/src/com/jogamp/opencl/gl/CLGLTexture2d.java index 7cbd95d5..64ac4e0b 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture2d.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture2d.java @@ -30,17 +30,16 @@ package com.jogamp.opencl.gl; import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.CLContext; +import com.jogamp.opencl.CLException; import com.jogamp.opencl.CLImageFormat; import com.jogamp.opencl.llb.impl.CLImageFormatImpl; import com.jogamp.opencl.llb.gl.CLGL; -import java.nio.Buffer; -import static com.jogamp.opencl.CLException.*; -import static com.jogamp.opencl.llb.CL.*; +import java.nio.Buffer; /** * 2D OpenCL image representing an 2D OpenGL texture. - * @author Michael Bien + * @author Michael Bien, et.al. */ public class CLGLTexture2d extends CLGLImage2d implements CLGLTexture { @@ -63,15 +62,15 @@ public class CLGLTexture2d extends CLGLImage2d implements C CLGL clgli = (CLGL)cl; long id = clgli.clCreateFromGLTexture2D(context.ID, flags, target, mipLevel, texture, result, 0); - checkForError((int)id, "can not share memory with texture #"+texture+"."); + CLException.checkForError(result[0], "can not create CLGLTexture2d from texture #"+texture+"."); CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - int width = (int)accessor.getLong(CL_IMAGE_WIDTH); - int height = (int)accessor.getLong(CL_IMAGE_HEIGHT); + int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); + int height = (int)accessor.getLong(CL.CL_IMAGE_HEIGHT); return new CLGLTexture2d(context, directBuffer, format, accessor, target, mipLevel, width, height, id, texture, flags); diff --git a/src/com/jogamp/opencl/gl/CLGLTexture3d.java b/src/com/jogamp/opencl/gl/CLGLTexture3d.java index 8dd2682c..fdc2ba79 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture3d.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture3d.java @@ -31,17 +31,18 @@ package com.jogamp.opencl.gl; import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.CLContext; +import com.jogamp.opencl.CLException; import com.jogamp.opencl.CLImage3d; import com.jogamp.opencl.CLImageFormat; import com.jogamp.opencl.llb.impl.CLImageFormatImpl; + import java.nio.Buffer; -import javax.media.opengl.GLContext; -import static com.jogamp.opencl.llb.CL.*; +import javax.media.opengl.GLContext; /** * 3D OpenCL image representing an 3D OpenGL texture. - * @author Michael Bien + * @author Michael Bien, et.al. */ public class CLGLTexture3d extends CLImage3d implements CLGLObject, CLGLTexture { @@ -70,15 +71,16 @@ public class CLGLTexture3d extends CLImage3d implements CLG CLGL clgli = (CLGL)cl; long id = clgli.clCreateFromGLTexture3D(context.ID, flags, target, mipLevel, texture, result, 0); + CLException.checkForError(result[0], "can not create CLGLTexture3d from texture #"+texture+"."); CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - int width = (int)accessor.getLong(CL_IMAGE_WIDTH); - int height = (int)accessor.getLong(CL_IMAGE_HEIGHT); - int depth = (int)accessor.getLong(CL_IMAGE_DEPTH); + int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); + int height = (int)accessor.getLong(CL.CL_IMAGE_HEIGHT); + int depth = (int)accessor.getLong(CL.CL_IMAGE_DEPTH); return new CLGLTexture3d(context, directBuffer, format, accessor, target, mipLevel, width, height, depth, id, texture, flags); } -- cgit v1.2.3