Class BufferGPU<T extends Buffer>

java.lang.Object
cz.fidentis.analyst.opencl.memory.BufferGPU<T>
Type Parameters:
T - Any type to be stored in buffer
All Implemented Interfaces:
CLResources
Direct Known Subclasses:
IntegerBuffer, RayIntersectionBuffer, WriteBufferGPU

public abstract class BufferGPU<T extends Buffer> extends Object implements CLResources
Buffer in GPU memory. Read-Only on host side.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    BufferGPU(com.jogamp.opencl.CLContext clContext)
    Creates Buffer in specified OpenCl Context with default element size set to 1
    protected
    BufferGPU(com.jogamp.opencl.CLContext clContext, int elementSize)
    Creates Buffer in specified OpenCl Context with given element size
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    allocateBuffer(int desiredSize)
    Allocate the buffer to fit the elements
    abstract com.jogamp.opencl.CLBuffer<T>
    get()
    Get underlying CLBuffer
    com.jogamp.opencl.CLContext
    Get current OpenCL context
    int
     
    int
    Some elements take multiple values to be continuously stored in buffer.
    protected com.jogamp.opencl.CLCommandQueue
    Get current OpenCL queue
    int
     
    void
    resize(int elementCount)
    Creating new buffer and releasing the old one is costly.
    protected abstract void
    resizeSubBuffer(int desiredSize)
    Creating new SubBuffer of the main buffer to operate with smaller amount of memory
    abstract void
    Rewinds the buffer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface cz.fidentis.analyst.opencl.memory.CLResources

    release
  • Constructor Details

    • BufferGPU

      public BufferGPU(com.jogamp.opencl.CLContext clContext)
      Creates Buffer in specified OpenCl Context with default element size set to 1
      Parameters:
      clContext - OpenCl Context
    • BufferGPU

      protected BufferGPU(com.jogamp.opencl.CLContext clContext, int elementSize)
      Creates Buffer in specified OpenCl Context with given element size
      Parameters:
      clContext - OpenCl Context
      elementSize - element size
  • Method Details

    • getElementSize

      public int getElementSize()
      Some elements take multiple values to be continuously stored in buffer.
      Returns:
      Size of 1 element loaded in buffer.
    • getCount

      public int getCount()
      Returns:
      Count of the elements loaded inside. Do not confuse with the actual size of allocated memory
    • getSize

      public int getSize()
      Returns:
      Memory size of the buffer. Do not confuse with current element count
    • getClContext

      public com.jogamp.opencl.CLContext getClContext()
      Get current OpenCL context
      Returns:
      OpenCL context
    • resize

      public void resize(int elementCount)
      Creating new buffer and releasing the old one is costly. Reuse them if they are already big enough.
      Parameters:
      elementCount - element count to fit in
    • get

      public abstract com.jogamp.opencl.CLBuffer<T> get()
      Get underlying CLBuffer
      Returns:
      CLBuffer
    • rewind

      public abstract void rewind()
      Rewinds the buffer
    • allocateBuffer

      protected abstract void allocateBuffer(int desiredSize)
      Allocate the buffer to fit the elements
      Parameters:
      desiredSize - desired size of the buffer
    • resizeSubBuffer

      protected abstract void resizeSubBuffer(int desiredSize)
      Creating new SubBuffer of the main buffer to operate with smaller amount of memory
      Parameters:
      desiredSize - desired size of the buffer
    • getQueue

      protected com.jogamp.opencl.CLCommandQueue getQueue()
      Get current OpenCL queue
      Returns:
      OpenCL queue