com.jogamp.opencl
Class CLMemory<B extends Buffer>

java.lang.Object
  extended by com.jogamp.opencl.CLMemory<B>
All Implemented Interfaces:
AutoCloseable, CLResource
Direct Known Subclasses:
CLBuffer, CLImage

public abstract class CLMemory<B extends Buffer>
extends Object
implements CLResource

Common superclass for all OpenCL memory types. Represents an OpenCL memory object and wraps an optional NIO buffer.

Author:
Michael Bien

Nested Class Summary
static class CLMemory.GLObjectType
           
static class CLMemory.Map
          Configures the mapping process.
static class CLMemory.Mem
          Memory settings for configuring CLMemory.
 
Field Summary
protected  CL cl
           
protected  CLContext context
           
protected  int FLAGS
           
 long ID
          The OpenCL object handle.
protected  long size
           
 
Constructor Summary
protected CLMemory(CLContext context, B directBuffer, long size, long id, int flags)
           
protected CLMemory(CLContext context, long size, long id, int flags)
           
 
Method Summary
abstract
<T extends Buffer>
CLMemory<T>
cloneWith(T directBuffer)
          Returns a new instance of CLMemory pointing to the same CLResource but using a different Buffer.
 void close()
          Deprecated. This method is not intended to be called from client code.
 boolean equals(Object obj)
           
 B getBuffer()
          Returns the optional NIO buffer for this memory object.
protected static CL getCL(CLContext context)
           
 int getCLCapacity()
          Returns the size in buffer elements of this memory object.
 long getCLSize()
          Returns the size of the allocated OpenCL memory.
 EnumSet<CLMemory.Mem> getConfig()
          Returns the configuration of this memory object.
 CLContext getContext()
          Returns the context for this OpenCL object.
 long getID()
          Returns the OpenCL object handle
 int getMapCount()
          Returns the number of buffer mappings.
 int getNIOCapacity()
          Returns the capacity of the wrapped direct buffer or 0 if no buffer available.
 int getNIOSize()
          Returns the size of the wrapped direct buffer in byte or 0 if no buffer available.
 CLPlatform getPlatform()
          Returns the platform for this OpenCL object.
protected static long getSizeImpl(CL cl, long id)
           
 int hashCode()
           
protected static boolean isHostPointerFlag(int flags)
          Returns true if a host pointer must be specified on mem object creation.
 boolean isReadOnly()
          Returns true if this memory object was created with the CLMemory.Mem.READ_ONLY flag.
 boolean isReadWrite()
          Returns true if this memory object was created with the CLMemory.Mem.READ_WRITE flag.
 boolean isWriteOnly()
          Returns true if this memory object was created with the CLMemory.Mem.WRITE_ONLY flag.
 void registerDestructorCallback(CLMemObjectListener listener)
          Registers a callback which will be called by the OpenCL implementation when the memory object is released.
 void release()
          Releases the OpenCL resource.
protected static int sizeOfBufferElem(Buffer buffer)
           
 String toString()
           
 CLMemory<B> use(B buffer)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FLAGS

protected final int FLAGS

size

protected final long size

ID

public final long ID
The OpenCL object handle.


context

protected CLContext context

cl

protected final CL cl
Constructor Detail

CLMemory

protected CLMemory(CLContext context,
                   long size,
                   long id,
                   int flags)

CLMemory

protected CLMemory(CLContext context,
                   B directBuffer,
                   long size,
                   long id,
                   int flags)
Method Detail

isHostPointerFlag

protected static boolean isHostPointerFlag(int flags)
Returns true if a host pointer must be specified on mem object creation.


sizeOfBufferElem

protected static int sizeOfBufferElem(Buffer buffer)

getSizeImpl

protected static long getSizeImpl(CL cl,
                                  long id)

getCL

protected static CL getCL(CLContext context)

registerDestructorCallback

public void registerDestructorCallback(CLMemObjectListener listener)
Registers a callback which will be called by the OpenCL implementation when the memory object is released.


cloneWith

public abstract <T extends Buffer> CLMemory<T> cloneWith(T directBuffer)
Returns a new instance of CLMemory pointing to the same CLResource but using a different Buffer.


use

public CLMemory<B> use(B buffer)

getBuffer

public B getBuffer()
Returns the optional NIO buffer for this memory object.


getNIOCapacity

public int getNIOCapacity()
Returns the capacity of the wrapped direct buffer or 0 if no buffer available.


getNIOSize

public int getNIOSize()
Returns the size of the wrapped direct buffer in byte or 0 if no buffer available.


getCLSize

public long getCLSize()
Returns the size of the allocated OpenCL memory.


getCLCapacity

public int getCLCapacity()
Returns the size in buffer elements of this memory object.


getConfig

public EnumSet<CLMemory.Mem> getConfig()
Returns the configuration of this memory object.


getMapCount

public int getMapCount()
Returns the number of buffer mappings. The map count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for debugging.


isReadOnly

public boolean isReadOnly()
Returns true if this memory object was created with the CLMemory.Mem.READ_ONLY flag.


isWriteOnly

public boolean isWriteOnly()
Returns true if this memory object was created with the CLMemory.Mem.WRITE_ONLY flag.


isReadWrite

public boolean isReadWrite()
Returns true if this memory object was created with the CLMemory.Mem.READ_WRITE flag.


release

public void release()
Description copied from interface: CLResource
Releases the OpenCL resource.

Specified by:
release in interface CLResource

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()

close

@Deprecated
public final void close()
Deprecated. This method is not intended to be called from client code.

Implementation detail. TODO remove as soon we have extension methods.

Specified by:
close in interface AutoCloseable
See Also:
AutoCloseable

getContext

public CLContext getContext()
Returns the context for this OpenCL object.


getPlatform

public CLPlatform getPlatform()
Returns the platform for this OpenCL object.


getID

public long getID()
Returns the OpenCL object handle