Bug 579 - CLGLTexture2d.createFromGLTexture2d always fails due to passing id and not error to checkForError
Summary: CLGLTexture2d.createFromGLTexture2d always fails due to passing id and not er...
Status: RESOLVED FIXED
Alias: None
Product: Jocl
Classification: JogAmp
Component: opengl (show other bugs)
Version: 1
Hardware: All all
: P4 normal
Assignee: Michael Bien
URL:
Depends on:
Blocks:
 
Reported: 2012-05-06 10:20 CEST by Johan
Modified: 2013-10-12 23:39 CEST (History)
3 users (show)

See Also:
Type: ---
SCM Refs:
ec14381e0bd681c354de1a002894a628f8bf69e5
Workaround: ---


Attachments
fix for CLGLTexture2d patch (4.74 KB, patch)
2012-07-03 13:45 CEST, Daniel Balog
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johan 2012-05-06 10:20:15 CEST
High level OO wrapper bug:

In CLGLTexture2d.createFromGLTexture2d the checkForError call gets passed the texture id instead of the error flag from the clCreateFromGLTexture2D call:
checkForError((int)id, "can not share memory with texture #"+texture+".");

Instead it should be:
checkForError(result[0], "can not share memory with texture #"+texture+".");

This is a bug in the high level abstraction layer, but the low level JNI bindings work fine for sharing gl-cl textures, so you can use that instead in the meantime, but it would be great to get this high level stuff working also :).

It means CLGLTexture2d.createFromGLTexture2d will always fail when it actually succeeds ;).
Comment 1 Daniel Balog 2012-07-03 12:49:02 CEST
I would like to confirm this bug. It popped up as I was testing CLGLContext. The workaround (when you don't have the JOCL src) involves copy-pasting the method and initializing everything with reflection, which is tedious.

I'll post a patch.
Comment 2 Daniel Balog 2012-07-03 13:45:36 CEST
Created attachment 360 [details]
fix for CLGLTexture2d patch

This patch fixes the bug. It is an extremely easy fix. I see no reason to not apply the patch.

Note that the bug is probably due to a typo.

Check the clCreateFromGLTexture2D documentation if you don't believe me ;)

http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clCreateFromGLTexture2D.html
Comment 3 Julien Gouesse 2013-03-27 14:57:04 CET
We should really look at the suggested patch.
Comment 4 Sven Gothel 2013-10-12 23:39:05 CEST
Use result value in checkForError(..) for 
  CLGLTexture2d.createFromGL*
  CLGLTexture3d.createFromGL*
  CLGLImage2d.createFromGL*
  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.

@Daniel: This has nothing to do w/ trust, but I had little resources left
and I am only the 'interim' maintainer - we are looking for a new one.

Again: Thank you!
Comment 5 Sven Gothel 2013-10-12 23:39:51 CEST
To all: If the patch is erroneous .. pls reopen and send a git pull request / patch. 
No unit test!

Thank you!