public class LwjglContext extends Context
OpenCLObject.ObjectReleaser
releaser
Constructor and Description |
---|
LwjglContext(org.lwjgl.opencl.CLContext context,
java.util.List<LwjglDevice> devices) |
Modifier and Type | Method and Description |
---|---|
Image |
bindImage(Image image,
Texture.Type textureType,
int miplevel,
MemoryAccess access)
Creates a shared image object from a jME3-image.
|
protected Image |
bindPureRenderBuffer(FrameBuffer.RenderBuffer buffer,
MemoryAccess access) |
Buffer |
bindVertexBuffer(VertexBuffer vb,
MemoryAccess access)
Creates a shared buffer from a VertexBuffer.
|
Buffer |
createBuffer(long size,
MemoryAccess access)
Allocates a new buffer of the specific size and access type on the device.
|
Buffer |
createBufferFromHost(java.nio.ByteBuffer data,
MemoryAccess access)
Creates a new buffer wrapping the specific host memory.
|
Image |
createImage(MemoryAccess access,
Image.ImageFormat format,
Image.ImageDescriptor descr)
Creates a new 1D, 2D, 3D image.
ImageFormat specifies the element type and order, like RGBA of floats.ImageDescriptor specifies the dimension of the image.Furthermore, a ByteBuffer can be specified in the ImageDescriptor together with row and slice pitches. |
Program |
createProgramFromBinary(java.nio.ByteBuffer binaries,
Device device)
Creates a program from the specified binaries.
|
Program |
createProgramFromSourceCode(java.lang.String sourceCode)
Creates a program object from the provided source code.
|
CommandQueue |
createQueue(Device device)
Creates a command queue sending commands to the specified device.
|
org.lwjgl.opencl.CLContext |
getContext() |
java.util.List<LwjglDevice> |
getDevices()
Returns all available devices for this context.
|
Image.ImageFormat[] |
querySupportedFormats(MemoryAccess access,
Image.ImageType type)
Queries all supported image formats for a specified memory access and
image type.
|
bindImage, bindImage, bindRenderBuffer, createBuffer, createBufferFromHost, createProgramFromSourceCodeWithDependencies, createProgramFromSourceFiles, createProgramFromSourceFiles, createProgramFromSourceFilesWithInclude, createProgramFromSourceFilesWithInclude, createQueue, register, toString
finalize, getReleaser, release
public LwjglContext(org.lwjgl.opencl.CLContext context, java.util.List<LwjglDevice> devices)
public org.lwjgl.opencl.CLContext getContext()
public java.util.List<LwjglDevice> getDevices()
Context
Platform
.
They are used to create a command queue sending commands to a particular
device, see Context.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.
PlatformChooser
.getDevices
in class Context
public CommandQueue createQueue(Device device)
Context
Context.getDevices()
.createQueue
in class Context
device
- the target devicepublic Buffer createBuffer(long size, MemoryAccess access)
Context
createBuffer
in class Context
size
- the size of the buffer in bytesaccess
- the allowed access of this buffer from kernel codepublic Buffer createBufferFromHost(java.nio.ByteBuffer data, MemoryAccess access)
Context
Context.createBuffer(long, com.jme3.opencl.MemoryAccess)
.createBufferFromHost
in class Context
data
- the host buffer to useaccess
- the allowed access of this buffer from kernel codepublic Image createImage(MemoryAccess access, Image.ImageFormat format, Image.ImageDescriptor descr)
Context
ImageFormat
specifies the element type and order, like RGBA of floats.ImageDescriptor
specifies the dimension of the image.createImage
in class Context
access
- the allowed access of this image from kernel codeformat
- the image formatdescr
- the image descriptorpublic Image.ImageFormat[] querySupportedFormats(MemoryAccess access, Image.ImageType type)
Context
ImageFormat
objects
where ImageChannelType
or ImageChannelOrder
are null
(or both). This is the case when the device supports new formats that
are not included in this wrapper yet.querySupportedFormats
in class Context
access
- the memory access typetype
- the image type (1D, 2D, 3D, ...)public Buffer bindVertexBuffer(VertexBuffer vb, MemoryAccess access)
Context
Before the returned buffer can be used, it must be acquired explicitly
by Buffer.acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue)
and after modifying it, released by Buffer.releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue)
.
This is needed so that OpenGL and OpenCL operations do not interfere with each other.
bindVertexBuffer
in class Context
vb
- the vertex buffer to shareaccess
- the memory access for the kernelpublic Image bindImage(Image image, Texture.Type textureType, int miplevel, MemoryAccess access)
Context
Before the returned image can be used, it must be acquired explicitly
by Image.acquireImageForSharingAsync(com.jme3.opencl.CommandQueue)
and after modifying it, released by Image.releaseImageForSharingAsync(com.jme3.opencl.CommandQueue)
This is needed so that OpenGL and OpenCL operations do not interfere with each other.
protected Image bindPureRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access)
bindPureRenderBuffer
in class Context
public Program createProgramFromSourceCode(java.lang.String sourceCode)
Context
Program.build()
.createProgramFromSourceCode
in class Context
sourceCode
- the source codepublic Program createProgramFromBinary(java.nio.ByteBuffer binaries, Device device)
Context
Program.getBinary(com.jme3.opencl.Device)
.
The returned program still needs to be build using
Program.build(java.lang.String, com.jme3.opencl.Device...)
.
Important:The device passed to Program.getBinary(..)
,
this method and Program#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.createProgramFromBinary
in class Context
binaries
- the binariesdevice
- the device to use