opencl images

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

opencl images

notzed
Morning,

I want to research the use of opencl image2d_t objects for some code I have, but it seems there is no way to create such an image without using the opengl interoperability stuff - that I have been able to find.  e.g. CLImage2d.createImage() is never called in jocl (at least according to netbeans in the latest git checkout).

Is using the opengl stuff (currently) the only way to create opencl images with jocl?

If so (and this is perhaps out of scope for this list), is there an 'opencl' difference between using a renderbuffer vs a texture.  Scenario is taking lots of frames of input (from disk), performing format conversion, doing some processing on them, and generating a single result.

Ta,
 !Z
Reply | Threaded
Open this post in threaded view
|

Re: opencl images

notzed
As a followup i've been working with the opengl stuff in the meantime, but have hit some snags.

First a small typo in CLGLTexture2d, for which i've submitted a patch to bugzilla.

Second, I've been unable to create single channel textures.  Should this be expected to work, or am I trying something invalid?

...
  gl.glBindTexture(GL_TEXTURE_2D, txts[0]);
  gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, width, height, 0, GL_INTENSITY, GL_UNSIGNED_BYTE, buffer);
  gl.glBindTexture(GL_TEXTURE_2D, 0);
...
  gl.glFlush();
... (same texture)
rTex = cl.createFromGLTexture2d(GL_TEXTURE_2D, txts[0], 0, Mem.READ_WRITE);

But this fails in CLGLTexture2d.createFromGLTexture2d() when it tries to get the image size:
        int width = (int)accessor.getLong(CL_IMAGE_WIDTH);

with:

Exception in thread "AWT-EventQueue-0" com.jogamp.opencl.CLException$CLInvalidMemObjectException: error while asking for info value
error: CL_INVALID_MEM_OBJECT (man page: http://www.khronos.org/opencl/sdk/1.0/docs/man/xhtml/errors.html)
gl.reshape
        at com.jogamp.opencl.CLException.checkForError(CLException.java:38)
        at com.jogamp.opencl.CLInfoAccessor.getLong(CLInfoAccessor.java:39)
        at com.jogamp.opencl.gl.CLGLTexture2d.createFromGLTexture2d(CLGLTexture2d.java:42)

I tried a bunch of different format types, but only GL_RGBA seems to work.
Reply | Threaded
Open this post in threaded view
|

Re: opencl images

Michael Bien
sorry for the delay,

On 06/24/2010 03:53 PM, notzed [via jogamp] wrote:
> As a followup i've been working with the opengl stuff in the meantime,
> but have hit some snags.
>
> First a small typo in CLGLTexture2d, for which i've submitted a patch
> to bugzilla.
thank you very much for the patch. its already in:
http://github.com/mbien/jocl/commit/9560f296e01e120279a01ad06189f71cd662ed42



>
> Second, I've been unable to create single channel textures.  Should
> this be expected to work, or am I trying something invalid?
>
> ...
>   gl.glBindTexture(GL_TEXTURE_2D, txts[0]);
>   gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, width, height, 0,
> GL_INTENSITY, GL_UNSIGNED_BYTE, buffer);
>   gl.glBindTexture(GL_TEXTURE_2D, 0);
> ...
>   gl.glFlush();
> ... (same texture)
> rTex = cl.createFromGLTexture2d(GL_TEXTURE_2D, txts[0], 0,
> Mem.READ_WRITE);
>
> But this fails in CLGLTexture2d.createFromGLTexture2d() when it tries
> to get the image size:
>         int width = (int)accessor.getLong(CL_IMAGE_WIDTH);
>
> with:
>
> Exception in thread "AWT-EventQueue-0"
> com.jogamp.opencl.CLException$CLInvalidMemObjectException: error while
> asking for info value
> error: CL_INVALID_MEM_OBJECT (man page:
> http://www.khronos.org/opencl/sdk/1.0/docs/man/xhtml/errors.html)
> gl.reshape
>         at
> com.jogamp.opencl.CLException.checkForError(CLException.java:38)
>         at
> com.jogamp.opencl.CLInfoAccessor.getLong(CLInfoAccessor.java:39)
>         at
> com.jogamp.opencl.gl.CLGLTexture2d.createFromGLTexture2d(CLGLTexture2d.java:42)
>
>
> I tried a bunch of different format types, but only GL_RGBA seems to
> work.

looks valid for me. I'll add a utility method to query all supported
image formats than we will hopefully have the cause of this issue.


best regards,

michael


Reply | Threaded
Open this post in threaded view
|

Re: opencl images

Michael Bien
In reply to this post by notzed
evening,

On 06/24/2010 07:09 AM, notzed [via jogamp] wrote:

> Morning,
>
> I want to research the use of opencl image2d_t objects for some code I
> have, but it seems there is no way to create such an image without
> using the opengl interoperability stuff - that I have been able to
> find.  e.g. CLImage2d.createImage() is never called in jocl (at least
> according to netbeans in the latest git checkout).
>
> Is using the opengl stuff (currently) the only way to create opencl
> images with jocl?

the image factory methods in the high level api aren't there yet.

But i see you figured out how to call the other factories :)

... will begin with that early next weak.


>
> If so (and this is perhaps out of scope for this list), is there an
> 'opencl' difference between using a renderbuffer vs a texture.

a renderbuffer should end up in a CLGLImage2d and a GL texture in a
CLGLTextureND. The difference between image and texture is that a
texture has samplers an image not. (texture extends image in the high
level binding)


regards,

michael


Reply | Threaded
Open this post in threaded view
|

Re: opencl images

Michael Bien
In reply to this post by Michael Bien
Michael Bien wrote
looks valid for me. I'll add a utility method to query all supported
image formats than we will hopefully have the cause of this issue.
done, see:
http://github.com/mbien/jocl/commit/b6d6f75129cac5f4719d1cbfb3c0b63159086137

here is a list of the formats required for an OpenCL 1.1 implementation:
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetSupportedImageFormats.html

-michael
Reply | Threaded
Open this post in threaded view
|

Re: opencl images

notzed
In reply to this post by Michael Bien
On 25 June 2010 02:32, Michael Bien [via jogamp]
<[hidden email]> wrote:
>> Is using the opengl stuff (currently) the only way to create opencl
>> images with jocl?
> the image factory methods in the high level api aren't there yet.
>
> But i see you figured out how to call the other factories :)

Well it's basically the opencl api, which *is* documented :)

> ... will begin with that early next weak.

Awesome.  I they're just simple stubs to CLImage* I could probably
write a patch if you're busy, if I can manage to get it to build
anyway - looks like head jogl/gluegen are out of sync wrt
'ReflectionUtil' class at this instant.

Ta for the other info and following up on the patch.

 !Z
Reply | Threaded
Open this post in threaded view
|

Re: opencl images

Michael Bien
notzed wrote
Awesome.  I they're just simple stubs to CLImage* I could probably
write a patch if you're busy, if I can manage to get it to build
anyway
Would be cool if you could fork the repo on github. Makes patching easier + keeps authorship information of patches.
The image factory methods should be IMO implemented in CLContext - analog to the CLBuffer stuff:
http://jogamp.org/chuck/job/jocl_onmaster/label=linux64-null-centos54-jogamp-x64-chuck-001/javadoc/com/jogamp/opencl/CLContext.html#createBuffer%28B,%20com.jogamp.opencl.CLMemory.Mem...%29

alternatively, a demo or junit test would be a great contribution too :)

notzed wrote
 looks like head jogl/gluegen are out of sync wrt
'ReflectionUtil' class at this instant.
pull gluegen from my repo. jogl should be in sync.
chucky is still happy: http://jogamp.org/chuck/ :)

regards,

michael
Reply | Threaded
Open this post in threaded view
|

Re: opencl images

notzed

Hi again,

Sorry for not replying - I didn't see this reply.  Seems like the image stuff is in there now too - thanks.  Can't think of anything to do for a demo (apart from my job, but i can't use that), but I would like to eventually.

After another false start I did eventually get some results from the image stuff but it's a bit puzzling, so i'm not sure if it's a jocl issue or AMD's stream sdk, so I thought i'd ask here first.  I'm using the auto build 2010-07-04.  It's not really critical as i'm still just investigating.

Basic code flow is this:
 byte buffer loaded with test data
 call a kernel which processes this into an RGBA/UNORM_INT8 image, using write_imagef
 call another kernel which converts this back to an int buffer, which uses read_imageui and then some shifts to pack to an int.

I believe the write_imagef should 'normalise' 1.0f -> 255, and the read_imageui should read un-normalised '255'.  But instead  I get '0x3f800000', which is just 1.0f as an int.  If I use read_imagef I get the correct result (and similar for other values which indicate it's actually storing 8 bit ints as expected).  If I change the write kernel to use write_imageui I always read back 0, no matter which of the few values I tried.

Looks like some issue with amd's image support, but I thought i'd ask here first since i'm using this extra api layer.

I'll have to check my `git' checkouts, i must be using the wrong repository.  i detest git.

 Z

Reply | Threaded
Open this post in threaded view
|

Re: opencl images

Michael Bien
I haven't used images much so far. But readying your description, it could be quite possible that you run into bugs of the OpenCL implementation in those kind of corner cases.

AMD has a few samples in the sdk (convolution filters, sobel filter). I am afraid non of them seems to use this kind of conversion trick :)
But maybe its something trivial, e.g. you read from the wrong buffer or so... hard to help you without code or a junit test ;)

regarding git:
cd gluegen
git pull git://github.com/mbien/gluegen.git master
cd jogl
git pull git://github.com/mbien/jogl.git master
cd jocl
git pull git://github.com/mbien/jocl.git master

and you have the latest version of jocl with its dependencies. (jogl is only a compiletime dependency, so if you don't use any OpenGL interoperability its not that important to be up2date with this repo)

regards,

michael


On 07/12/2010 02:27 PM, notzed [via jogamp] wrote:

Hi again,

Sorry for not replying - I didn't see this reply.  Seems like the image stuff is in there now too - thanks.  Can't think of anything to do for a demo (apart from my job, but i can't use that), but I would like to eventually.

After another false start I did eventually get some results from the image stuff but it's a bit puzzling, so i'm not sure if it's a jocl issue or AMD's stream sdk, so I thought i'd ask here first.  I'm using the auto build 2010-07-04.  It's not really critical as i'm still just investigating.

Basic code flow is this:
 byte buffer loaded with test data
 call a kernel which processes this into an RGBA/UNORM_INT8 image, using write_imagef
 call another kernel which converts this back to an int buffer, which uses read_imageui and then some shifts to pack to an int.

I believe the write_imagef should 'normalise' 1.0f -> 255, and the read_imageui should read un-normalised '255'.  But instead  I get '0x3f800000', which is just 1.0f as an int.  If I use read_imagef I get the correct result (and similar for other values which indicate it's actually storing 8 bit ints as expected).  If I change the write kernel to use write_imageui I always read back 0, no matter which of the few values I tried.

Looks like some issue with amd's image support, but I thought i'd ask here first since i'm using this extra api layer.

I'll have to check my `git' checkouts, i must be using the wrong repository.  i detest git.

 Z




View message @ http://jogamp.762907.n3.nabble.com/opencl-images-tp918750p960200.html
To start a new topic under jogamp, email [hidden email]
To unsubscribe from jogamp, click here.