Giter VIP home page Giter VIP logo

Comments (5)

gpu avatar gpu commented on August 28, 2024

I wasn't ware of Apple doing their own thing there, or what the reasoning and processes are that led to this function existing in the first place (I mean, clGetGLContextInfoKHR should have been enough to "emulate" the functionality that they needed).

I can have a look to see how this could sensibly be added.

But a (possibly important) a note: I had a short look at the linked issue, and it appears to be about "the other JOCL" - are you sure that wasn't supposed to be asked in https://github.com/JogAmp/jocl ?

from jocl.

LlemonDuck avatar LlemonDuck commented on August 28, 2024

Thanks for the response. That other thread has been a bit of a shitshow.

I know for sure I'm working with your JOCL lib, I find it much nicer than JogAmp's.

As of now, I'd prefer not to switch over to jogamp, but I think they do already have the binding, so it may be necessary if we can't get it added here.

I forked this project to try and add the binding myself, but I have to admit I'm not great with JNI and progress has been slow.

from jocl.

gpu avatar gpu commented on August 28, 2024

Adding the function itself should probably be relatively simple, following the pattern of the existing functions. (But admittedly: The last update for JOCL that I did on this level has been a while, so I'll also have to re-orient myself a bit). A question on top of that it whether I would add it directly in the CL class, because it is a vendor-specific function. I'd consider adding it in some CLApple class or so, throwing an exception if it is called on non-apple platforms, but I'll have to think about the best solution first. I'll try to allocate some time for that durint the weekend.

from jocl.

LlemonDuck avatar LlemonDuck commented on August 28, 2024

Thank you, that would be immensely helpful. In case you don't have offhand access to a mac, here's the relevant section of the header file (cl_gl_ext.h in /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers).

It seems that these three constants + the one method are the only portions of the file unique to cl_APPLE_gl_sharing and the rest is standard cl_khr_gl_sharing.

/* Context GL sharing
 *
 * Please check for the "cl_APPLE_gl_sharing" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
 * before using these extensions.

 * Apple extension for creating a CL context from a CGL share group
 *
 * This enumerated value can be specified as part of the <properties> argument passed to clCreateContext 
 * to allow OpenCL compliant devices in an existing CGL share group to be used as the devices in 
 * the newly created CL context. GL objects that were allocated in the given CGL share group can 
 * now be shared between CL and GL.
 *
 * If the <num_devices> and <devices> argument values to clCreateContext are 0 and NULL respectively,
 * all CL compliant devices in the CGL share group will be used to create the context.
 * Additional CL devices can also be specified using the <num_devices> and <devices> arguments.
 * These, however, cannot be GPU devices. On Mac OS X, you can add the CPU to the list of CL devices
 * (in addition to the CL compliant devices in the CGL share group) used to create the CL context. 
 * Note that if a CPU device is specified, the CGL share group must also include the GL float renderer; 
 * Otherwise CL_INVALID_DEVICE will be returned.
 *
 * NOTE:  Make sure that appropriate cl_gl.h header file is included separately
 */
#define CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE        0x10000000 /* Introduced in Mac OS X 10.6 */
  
/* Apple extension for retrieving OpenGL context information for a CL context 
 * created via the above method.
 *
 * Provides a query mechanism to retrieve OpenGL context specific information 
 * from an OpenCL context to help identify device specific mappings and usage.
 * 
 * For example, one possible usage would be to allow the client to map a CGL 
 * virtual screen index to an appropriate CL device id to insure that the 
 * rendering device and the compute device are the same, thus guaranteeing 
 * any shared OpenGL memory that is attached o a CL memory object remains 
 * resident on the active device.
 */

cl_int	clGetGLContextInfoAPPLE ( cl_context __nonnull /* context */,
								  void * __nonnull /* platform_gl_ctx */,
								  cl_gl_platform_info /* param_name */,
								  size_t /* param_value_size */,
								  void *  __nullable /* param_value */,
								  size_t * __nullable /* param_value_size_ret */)  CL_EXT_SUFFIX__VERSION_1_0 CL_DEPRECATED(10.6, 10.14);  

/* The list of supported param_name values and the information returned in param_value by 
 * clGetContextInfo are listed below:

 * Returns a cl_device_id for the CL device associated with the virtual screen for 
 * the given CGL context.  Return type: cl_device_id
 */
#define CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE 		0x10000002 /* Introduced in Mac OS X 10.6 */

/* Returns an array of cl_device_ids for the CL device(s) corresponding to 
 * the virtual screen(s) for the given CGL context.   Return type: cl_device_id[]
 */
#define CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE	0x10000003 /* Introduced in Mac OS X 10.6 */

/* Error code returned by clGetGLContextInfoAPPLE if an invalid platform_gl_ctx is provided           */
#define CL_INVALID_GL_CONTEXT_APPLE                         -1000      /* Introduced in Mac OS X 10.6 */

from jocl.

gpu avatar gpu commented on August 28, 2024

Thanks again for your contribution!

The updated version is available under

<dependency>
    <groupId>org.jocl</groupId>
    <artifactId>jocl</artifactId>
    <version>2.0.3</version>
</dependency>

If you encounter any problems with that, just let me know.

from jocl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.