Package com.jme3.opencl.lwjgl
Class LwjglContext
java.lang.Object
com.jme3.opencl.AbstractOpenCLObject
com.jme3.opencl.Context
com.jme3.opencl.lwjgl.LwjglContext
- All Implemented Interfaces:
OpenCLObject
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.jme3.opencl.OpenCLObject
OpenCLObject.ObjectReleaser -
Field Summary
Fields inherited from class com.jme3.opencl.AbstractOpenCLObject
releaser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbindImage(Image image, Texture.Type textureType, int mipLevel, MemoryAccess access) Creates a shared image object from a jME3-image.protected ImagebindPureRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access) bindVertexBuffer(VertexBuffer vb, MemoryAccess access) Creates a shared buffer from a VertexBuffer.createBuffer(long size, MemoryAccess access) Allocates a new buffer of the specific size and access type on the device.createBufferFromHost(ByteBuffer data, MemoryAccess access) Creates a new buffer wrapping the specific host memory.createImage(MemoryAccess access, Image.ImageFormat format, Image.ImageDescriptor descr) Creates a new 1D, 2D, 3D image.
ImageFormatspecifies the element type and order, like RGBA of floats.
ImageDescriptorspecifies the dimension of the image.
Furthermore, a ByteBuffer can be specified in the ImageDescriptor together with row and slice pitches.createProgramFromBinary(ByteBuffer binaries, Device device) Creates a program from the specified binaries.createProgramFromSourceCode(String sourceCode) Creates a program object from the provided source code.createQueue(Device device) Creates a command queue sending commands to the specified device.org.lwjgl.opencl.CLContextReturns all available devices for this context.querySupportedFormats(MemoryAccess access, Image.ImageType type) Queries all supported image formats for a specified memory access and image type.Methods inherited from class com.jme3.opencl.Context
bindImage, bindImage, bindRenderBuffer, createBuffer, createBufferFromHost, createProgramFromSourceCodeWithDependencies, createProgramFromSourceFiles, createProgramFromSourceFiles, createProgramFromSourceFilesWithInclude, createProgramFromSourceFilesWithInclude, createQueue, register, toStringMethods inherited from class com.jme3.opencl.AbstractOpenCLObject
finalize, getReleaser, release
-
Constructor Details
-
LwjglContext
-
-
Method Details
-
getContext
public org.lwjgl.opencl.CLContext getContext() -
getDevices
Description copied from class:ContextReturns all available devices for this context. These devices all belong to the samePlatform. They are used to create a command queue sending commands to a particular device, seeContext.createQueue(com.jme3.opencl.Device). Also, device capabilities, like the supported OpenCL version, extensions, memory size and so on, are queried over the Device instances.
The available devices were specified by aPlatformChooser.- Specified by:
getDevicesin classContext- Returns:
- a list of devices
-
createQueue
Description copied from class:ContextCreates a command queue sending commands to the specified device. The device must be an entry ofContext.getDevices().- Specified by:
createQueuein classContext- Parameters:
device- the target device- Returns:
- the command queue
-
createBuffer
Description copied from class:ContextAllocates a new buffer of the specific size and access type on the device.- Specified by:
createBufferin classContext- Parameters:
size- the size of the buffer in bytesaccess- the allowed access of this buffer from kernel code- Returns:
- the new buffer
-
createBufferFromHost
Description copied from class:ContextCreates a new buffer wrapping the specific host memory. This host memory specified by a ByteBuffer can then be used directly by kernel code, although the access might be slower than with native buffers created byContext.createBuffer(long, com.jme3.opencl.MemoryAccess).- Specified by:
createBufferFromHostin classContext- Parameters:
data- the host buffer to useaccess- the allowed access of this buffer from kernel code- Returns:
- the new buffer
-
createImage
public Image createImage(MemoryAccess access, Image.ImageFormat format, Image.ImageDescriptor descr) Description copied from class:ContextCreates a new 1D, 2D, 3D image.
ImageFormatspecifies the element type and order, like RGBA of floats.
ImageDescriptorspecifies the dimension of the image.
Furthermore, a ByteBuffer can be specified in the ImageDescriptor together with row and slice pitches. This buffer is then used to store the image. If no ByteBuffer is specified, a new buffer is allocated (this is the normal behaviour).- Specified by:
createImagein classContext- Parameters:
access- the allowed access of this image from kernel codeformat- the image formatdescr- the image descriptor- Returns:
- the new image object
-
querySupportedFormats
Description copied from class:ContextQueries all supported image formats for a specified memory access and image type.
Note that the returned array may containImageFormatobjects whereImageChannelTypeorImageChannelOrderarenull(or both). This is the case when the device supports new formats that are not included in this wrapper yet.- Specified by:
querySupportedFormatsin classContext- Parameters:
access- the memory access typetype- the image type (1D, 2D, 3D, ...)- Returns:
- an array of all supported image formats
-
bindVertexBuffer
Description copied from class:ContextCreates a shared buffer from a VertexBuffer. The returned buffer and the vertex buffer operate on the same memory, changes in one view are visible in the other view. This can be used to modify meshes directly from OpenCL (e.g. for particle systems).
Note: The vertex buffer must already been uploaded to the GPU, i.e. it must be used at least once for drawing.Before the returned buffer can be used, it must be acquired explicitly by
Buffer.acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue)and after modifying it, released byBuffer.releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue). This is needed so that OpenGL and OpenCL operations do not interfere with each other.- Specified by:
bindVertexBufferin classContext- Parameters:
vb- the vertex buffer to shareaccess- the memory access for the kernel- Returns:
- the new buffer
-
bindImage
Description copied from class:ContextCreates a shared image object from a jME3-image. The returned image shares the same memory with the jME3-image, changes in one view are visible in the other view. This can be used to modify textures and images directly from OpenCL (e.g. for post-processing effects and other texture effects).
Note: The image must already been uploaded to the GPU, i.e. it must be used at least once for drawing.Before the returned image can be used, it must be acquired explicitly by
Image.acquireImageForSharingAsync(com.jme3.opencl.CommandQueue)and after modifying it, released byImage.releaseImageForSharingAsync(com.jme3.opencl.CommandQueue)This is needed so that OpenGL and OpenCL operations do not interfere with each other. -
bindPureRenderBuffer
- Specified by:
bindPureRenderBufferin classContext
-
createProgramFromSourceCode
Description copied from class:ContextCreates a program object from the provided source code. The program still needs to be compiled usingProgram.build().- Specified by:
createProgramFromSourceCodein classContext- Parameters:
sourceCode- the source code- Returns:
- the program object
-
createProgramFromBinary
Description copied from class:ContextCreates a program from the specified binaries. The binaries are created byProgram.getBinary(com.jme3.opencl.Device). The returned program still needs to be build usingProgram.build(java.lang.String, com.jme3.opencl.Device...). Important:The device passed toProgram.getBinary(..), this method andProgram#build(..)must be the same. The binaries are used to build a program cache across multiple launches of the application. The programs build much faster from binaries than from sources.- Specified by:
createProgramFromBinaryin classContext- Parameters:
binaries- the binariesdevice- the device to use- Returns:
- the new program
-