Class CUGL
- java.lang.Object
-
- org.lwjgl.cuda.CUGL
-
public class CUGL extends java.lang.ObjectContains bindings to CUDA Driver OpenGL Interoperability API.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCUGL.FunctionsContains the function pointers loaded fromCU.getLibrary().
-
Field Summary
Fields Modifier and Type Field Description static intCU_GL_DEVICE_LIST_ALL
CU_GL_DEVICE_LIST_CURRENT_FRAME
CU_GL_DEVICE_LIST_NEXT_FRAMECUDA devices corresponding to an OpenGL device.static intCU_GL_MAP_RESOURCE_FLAGS_NONE
CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY
CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARDFlags to map or unmap a resource.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcuGLCtxCreate(org.lwjgl.PointerBuffer pCtx, int Flags, int device)Create a CUDA context for interoperability with OpenGL.static intcuGLGetDevices(java.nio.IntBuffer pCudaDeviceCount, java.nio.IntBuffer pCudaDevices, int deviceList)Gets the CUDA devices associated with the current OpenGL context.static intcuGLInit()Initializes OpenGL interoperability.static intcuGLMapBufferObject(org.lwjgl.PointerBuffer dptr, org.lwjgl.PointerBuffer size, int buffer)Maps an OpenGL buffer object.static intcuGLMapBufferObjectAsync(org.lwjgl.PointerBuffer dptr, org.lwjgl.PointerBuffer size, int buffer, long hStream)Maps an OpenGL buffer object.static intcuGLRegisterBufferObject(int buffer)Registers an OpenGL buffer object.static intcuGLSetBufferObjectMapFlags(int buffer, int Flags)Set the map flags for an OpenGL buffer object.static intcuGLUnmapBufferObject(int buffer)Unmaps an OpenGL buffer object.static intcuGLUnmapBufferObjectAsync(int buffer, long hStream)Unmaps an OpenGL buffer object.static intcuGLUnregisterBufferObject(int buffer)Unregister an OpenGL buffer object.static intcuGraphicsGLRegisterBuffer(org.lwjgl.PointerBuffer pCudaResource, int buffer, int Flags)Registers an OpenGL buffer object.static intcuGraphicsGLRegisterImage(org.lwjgl.PointerBuffer pCudaResource, int image, int target, int Flags)Register an OpenGL texture or renderbuffer object.static intncuGLCtxCreate(long pCtx, int Flags, int device)Unsafe version of:GLCtxCreatestatic intncuGLGetDevices(long pCudaDeviceCount, long pCudaDevices, int cudaDeviceCount, int deviceList)Unsafe version of:GLGetDevicesstatic intncuGLMapBufferObject(long dptr, long size, int buffer)Unsafe version of:GLMapBufferObjectstatic intncuGLMapBufferObjectAsync(long dptr, long size, int buffer, long hStream)Unsafe version of:GLMapBufferObjectAsyncstatic intncuGraphicsGLRegisterBuffer(long pCudaResource, int buffer, int Flags)Unsafe version of:GraphicsGLRegisterBufferstatic intncuGraphicsGLRegisterImage(long pCudaResource, int image, int target, int Flags)Unsafe version of:GraphicsGLRegisterImage
-
-
-
Field Detail
-
CU_GL_DEVICE_LIST_ALL, CU_GL_DEVICE_LIST_CURRENT_FRAME, CU_GL_DEVICE_LIST_NEXT_FRAME
CUDA devices corresponding to an OpenGL device. (CUGLDeviceList)Enum values:
GL_DEVICE_LIST_ALL- The CUDA devices for all GPUs used by the current OpenGL context.GL_DEVICE_LIST_CURRENT_FRAME- The CUDA devices for the GPUs used by the current OpenGL context in its currently rendering frame.GL_DEVICE_LIST_NEXT_FRAME- The CUDA devices for the GPUs to be used by the current OpenGL context in the next frame.
-
CU_GL_MAP_RESOURCE_FLAGS_NONE, CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY, CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD
Flags to map or unmap a resource. (CUGLmap_flags)Enum values:
-
-
Method Detail
-
ncuGraphicsGLRegisterBuffer
public static int ncuGraphicsGLRegisterBuffer(long pCudaResource, int buffer, int Flags)Unsafe version of:GraphicsGLRegisterBuffer
-
cuGraphicsGLRegisterBuffer
public static int cuGraphicsGLRegisterBuffer(org.lwjgl.PointerBuffer pCudaResource, int buffer, int Flags)Registers an OpenGL buffer object.Registers the buffer object specified by
bufferfor access by CUDA. A handle to the registered object is returned aspCudaResource. The register flagsFlagsspecify the intended usage, as follows:GRAPHICS_REGISTER_FLAGS_NONE: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA. This is the default value.GRAPHICS_REGISTER_FLAGS_READ_ONLY: Specifies that CUDA will not write to this resource.GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD: Specifies that CUDA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved.
- Parameters:
pCudaResource- pointer to the returned object handlebuffer- name of buffer object to be registeredFlags- register flags
-
ncuGraphicsGLRegisterImage
public static int ncuGraphicsGLRegisterImage(long pCudaResource, int image, int target, int Flags)Unsafe version of:GraphicsGLRegisterImage
-
cuGraphicsGLRegisterImage
public static int cuGraphicsGLRegisterImage(org.lwjgl.PointerBuffer pCudaResource, int image, int target, int Flags)Register an OpenGL texture or renderbuffer object.Registers the texture or renderbuffer object specified by
imagefor access by CUDA. A handle to the registered object is returned aspCudaResource.targetmust match the type of the object, and must be one ofGL_TEXTURE_2D,GL_TEXTURE_RECTANGLE,GL_TEXTURE_CUBE_MAP,GL_TEXTURE_3D,GL_TEXTURE_2D_ARRAY, orGL_RENDERBUFFER.The register flags
Flagsspecify the intended usage, as follows:GRAPHICS_REGISTER_FLAGS_NONE: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA. This is the default value.GRAPHICS_REGISTER_FLAGS_READ_ONLY: Specifies that CUDA will not write to this resource.GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD: Specifies that CUDA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved.GRAPHICS_REGISTER_FLAGS_SURFACE_LDST: Specifies that CUDA will bind this resource to a surface reference.GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER: Specifies that CUDA will perform texture gather operations on this resource.
The following image formats are supported. For brevity's sake, the list is abbreviated. For ex.,
{GL_R, GL_RG} X {8, 16}would expand to the following 4 formats{GL_R8, GL_R16, GL_RG8, GL_RG16}:- GL_RED, GL_RG, GL_RGBA, GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY
- {GL_R, GL_RG, GL_RGBA} X {8, 16, 16F, 32F, 8UI, 16UI, 32UI, 8I, 16I, 32I}
- {GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY} X {8, 16, 16F_ARB, 32F_ARB, 8UI_EXT, 16UI_EXT, 32UI_EXT, 8I_EXT, 16I_EXT, 32I_EXT}
The following image classes are currently disallowed:
- Textures with borders
- Multisampled renderbuffers
- Parameters:
pCudaResource- pointer to the returned object handleimage- name of texture or renderbuffer object to be registeredtarget- identifies the type of object specified byimageFlags- register flags
-
ncuGLGetDevices
public static int ncuGLGetDevices(long pCudaDeviceCount, long pCudaDevices, int cudaDeviceCount, int deviceList)Unsafe version of:GLGetDevices- Parameters:
cudaDeviceCount- the size of the output device arraypCudaDevices
-
cuGLGetDevices
public static int cuGLGetDevices(java.nio.IntBuffer pCudaDeviceCount, java.nio.IntBuffer pCudaDevices, int deviceList)Gets the CUDA devices associated with the current OpenGL context.Returns in
*pCudaDeviceCountthe number of CUDA-compatible devices corresponding to the current OpenGL context. Also returns in*pCudaDevicesat mostcudaDeviceCountof the CUDA-compatible devices corresponding to the current OpenGL context. If any of the GPUs being used by the current OpenGL context are not CUDA capable then the call will returnCU.CUDA_ERROR_NO_DEVICE.The
deviceListargument may be any of the following:GL_DEVICE_LIST_ALL: Query all devices used by the current OpenGL context.GL_DEVICE_LIST_CURRENT_FRAME: Query the devices used by the current OpenGL context to render the current frame (in SLI).GL_DEVICE_LIST_NEXT_FRAME: Query the devices used by the current OpenGL context to render the next frame (in SLI). Note that this is a prediction, it can't be guaranteed that this is correct in all cases.
Note
This function is not supported on Mac OS X.
- Parameters:
pCudaDeviceCount- returned number of CUDA devicespCudaDevices- returned CUDA devicesdeviceList- the set of devices to return
-
ncuGLCtxCreate
public static int ncuGLCtxCreate(long pCtx, int Flags, int device)Unsafe version of:GLCtxCreate
-
cuGLCtxCreate
public static int cuGLCtxCreate(org.lwjgl.PointerBuffer pCtx, int Flags, int device)Create a CUDA context for interoperability with OpenGL.Deprecated: This function is deprecated as of Cuda 5.0.
This function is deprecated and should no longer be used. It is no longer necessary to associate a CUDA context with an OpenGL context in order to achieve maximum interoperability performance.
- Parameters:
pCtx- returned CUDA contextFlags- options for CUDA context creationdevice- device on which to create the context
-
cuGLInit
public static int cuGLInit()
Initializes OpenGL interoperability.Deprecated: This function is deprecated as of Cuda 3.0.
Initializes OpenGL interoperability. This function is deprecated and calling it is no longer required. It may fail if the needed OpenGL driver facilities are not available.
-
cuGLRegisterBufferObject
public static int cuGLRegisterBufferObject(int buffer)
Registers an OpenGL buffer object.Deprecated: This function is deprecated as of Cuda 3.0.
Registers the buffer object specified by
bufferfor access by CUDA. This function must be called before CUDA can map the buffer object. There must be a valid OpenGL context bound to the current thread when this function is called, and the buffer name is resolved by that context.- Parameters:
buffer- the name of the buffer object to register
-
ncuGLMapBufferObject
public static int ncuGLMapBufferObject(long dptr, long size, int buffer)Unsafe version of:GLMapBufferObject
-
cuGLMapBufferObject
public static int cuGLMapBufferObject(org.lwjgl.PointerBuffer dptr, org.lwjgl.PointerBuffer size, int buffer)Maps an OpenGL buffer object.Deprecated: This function is deprecated as of Cuda 3.0.
Maps the buffer object specified by
bufferinto the address space of the current CUDA context and returns in*dptrand*sizethe base pointer and size of the resulting mapping.There must be a valid OpenGL context bound to the current thread when this function is called. This must be the same context, or a member of the same shareGroup, as the context that was bound when the buffer was registered.
All streams in the current CUDA context are synchronized with the current GL context.
- Parameters:
dptr- returned mapped base pointersize- returned size of mappingbuffer- the name of the buffer object to map
-
cuGLUnmapBufferObject
public static int cuGLUnmapBufferObject(int buffer)
Unmaps an OpenGL buffer object.Deprecated: This function is deprecated as of Cuda 3.0.
Unmaps the buffer object specified by
bufferfor access by CUDA.There must be a valid OpenGL context bound to the current thread when this function is called. This must be the same context, or a member of the same
shareGroup, as the context that was bound when the buffer was registered.All streams in the current CUDA context are synchronized with the current GL context.
- Parameters:
buffer- buffer object to unmap
-
cuGLUnregisterBufferObject
public static int cuGLUnregisterBufferObject(int buffer)
Unregister an OpenGL buffer object.Deprecated: This function is deprecated as of Cuda 3.0.
Unregisters the buffer object specified by
buffer. This releases any resources associated with the registered buffer. After this call, the buffer may no longer be mapped for access by CUDA.There must be a valid OpenGL context bound to the current thread when this function is called. This must be the same context, or a member of the same shareGroup, as the context that was bound when the buffer was registered.
- Parameters:
buffer- name of the buffer object to unregister
-
cuGLSetBufferObjectMapFlags
public static int cuGLSetBufferObjectMapFlags(int buffer, int Flags)Set the map flags for an OpenGL buffer object.Deprecated: This function is deprecated as of Cuda 3.0.
Sets the map flags for the buffer object specified by
buffer.Changes to
Flagswill take effect the next timebufferis mapped. TheFlagsargument may be any of the following:GL_MAP_RESOURCE_FLAGS_NONE: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA kernels. This is the default value.GL_MAP_RESOURCE_FLAGS_READ_ONLY: Specifies that CUDA kernels which access this resource will not write to this resource.GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD: Specifies that CUDA kernels which access this resource will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved.
If
bufferhas not been registered for use with CUDA, thenCU.CUDA_ERROR_INVALID_HANDLEis returned. Ifbufferis presently mapped for access by CUDA, thenCU.CUDA_ERROR_ALREADY_MAPPEDis returned.There must be a valid OpenGL context bound to the current thread when this function is called. This must be the same context, or a member of the same shareGroup, as the context that was bound when the buffer was registered.
- Parameters:
buffer- buffer object to unmapFlags- map flags
-
ncuGLMapBufferObjectAsync
public static int ncuGLMapBufferObjectAsync(long dptr, long size, int buffer, long hStream)Unsafe version of:GLMapBufferObjectAsync
-
cuGLMapBufferObjectAsync
public static int cuGLMapBufferObjectAsync(org.lwjgl.PointerBuffer dptr, org.lwjgl.PointerBuffer size, int buffer, long hStream)Maps an OpenGL buffer object.Deprecated: This function is deprecated as of Cuda 3.0.
Maps the buffer object specified by
bufferinto the address space of the current CUDA context and returns in*dptrand*sizethe base pointer and size of the resulting mapping.There must be a valid OpenGL context bound to the current thread when this function is called. This must be the same context, or a member of the same shareGroup, as the context that was bound when the buffer was registered.
Stream
hStreamin the current CUDA context is synchronized with the current GL context.- Parameters:
dptr- returned mapped base pointersize- returned size of mappingbuffer- the name of the buffer object to maphStream- stream to synchronize
-
cuGLUnmapBufferObjectAsync
public static int cuGLUnmapBufferObjectAsync(int buffer, long hStream)Unmaps an OpenGL buffer object.Deprecated: This function is deprecated as of Cuda 3.0.
Unmaps the buffer object specified by
bufferfor access by CUDA.There must be a valid OpenGL context bound to the current thread when this function is called. This must be the same context, or a member of the same
shareGroup, as the context that was bound when the buffer was registered.Stream
hStreamin the current CUDA context is synchronized with the current GL context.- Parameters:
buffer- name of the buffer object to unmaphStream- stream to synchronize
-
-