Class GPUPoolBehavior<T extends GPUMemoryPool.InternalMemory<D>,D>

java.lang.Object
org.boxutil.define.struct.memorypool.GPUPoolBehavior<T,D>

public class GPUPoolBehavior<T extends GPUMemoryPool.InternalMemory<D>,D> extends Object
  • Field Details

  • Constructor Details

    • GPUPoolBehavior

      public GPUPoolBehavior(int glTarget, @NotNull GPUMemoryPool.MemoryBuilder<T,D> newEmptyMemory, @NotNull GPUMemoryPool.MemoryBuilder<T,D> newNotEmptyMemory)
      Parameters:
      glTarget - the type of buffer, for example: GL15.GL_ARRAY_BUFFER, GL31.GL_TEXTURE_BUFFER, GL31.GL_UNIFORM_BUFFER etc.
      newEmptyMemory - for example:
      (meta, address, size, index, pool) -> new InternalMemory<>(meta, address, size, index, true)
      newNotEmptyMemory - for example:
      (meta, address, size, index, pool) -> new InternalMemory<>(meta, address, size, index, false)
    • GPUPoolBehavior

      public GPUPoolBehavior(GPUPoolBehavior<T,D> src)
      Shallow copy constructor.

      Do not forget to check if any functional interface have reference of src field.

  • Method Details

    • setImmutableBufferAllow

      public GPUPoolBehavior<T,D> setImmutableBufferAllow(boolean immutableBufferAllow)
      false when not create an immutable buffer even if supported. For default value was true.

    • setUseDynamicStorageBuffer

      public GPUPoolBehavior<T,D> setUseDynamicStorageBuffer(boolean useDynamicStorageBuffer)
      Only effective when immutableBufferAllow was true.

      The memory pool may be updated after creation through calls to GL15.glBufferSubData(int, long, java.nio.ByteBuffer) when set to true.

      For default value was true.

    • setBufferAccessBits

      public GPUPoolBehavior<T,D> setBufferAccessBits(int access)
      Only effective when immutableBufferAllow was true, and related OpenGL features was supported.

      It must be a bitwise combination of a subset of the following flags:

      GL30.GL_MAP_READ_BIT, GL30.GL_MAP_WRITE_BIT, GL44.GL_MAP_PERSISTENT_BIT, GL44.GL_MAP_COHERENT_BIT, GL44.GL_CLIENT_STORAGE_BIT, otherwise set to 0.

      If access contains GL44.GL_MAP_PERSISTENT_BIT, must contain at least one of GL30.GL_MAP_READ_BIT or GL30.GL_MAP_WRITE_BIT.

      If access contains GL44.GL_MAP_COHERENT_BIT, it must also contain GL44.GL_MAP_PERSISTENT_BIT, and you should be use barrier and/or sync to ensure client/server can see the read/write commands at after.

      For default value was GL_MAP_WRITE_BIT.

    • setReservedSize

      public GPUPoolBehavior<T,D> setReservedSize(int reservedSize)
      A nonnegative integer.

      The reserved size from the start of buffer in byte, this memory is not part of the pool's accessible memory.

    • setDefaultBufferSize

      public GPUPoolBehavior<T,D> setDefaultBufferSize(long defaultBufferSize)
      A nonnegative integer.

      The initialized size of buffer in byte.

    • setMaxBufferSize

      public GPUPoolBehavior<T,D> setMaxBufferSize(long maxBufferSize)
      A nonnegative integer.

      Limit value that the buffer object has an explicit size limit defined by the OpenGL specification in byte, otherwise set to 0.

      When a new buffer object will create with unsupported size, an OutOfMemoryError will be thrown.

    • setContextRequirements

      public GPUPoolBehavior<T,D> setContextRequirements(Function<? super GPUMemoryPool<T,D>,Boolean> glContextRequirements)
      The creation conditions of the memory pool, will check it when pool initializations.

      Returns false when not supported on current device, otherwise true.

      null when OpenGL 1.5 required only.

    • setRebindBuffer

      public GPUPoolBehavior<T,D> setRebindBuffer(Consumer<? super GPUMemoryPool<T,D>> glRebindBuffer)
      After a new buffer has created, maybe you want to bind it to any location in shader; without GL15.glBindBuffer(int, int) before or after this calls, so you should be bind and unbind your buffer in method.

      NOTE: For objects that are private to the OpenGL context – such as a VBO thread pool with an associated VAO – the reBind operation should dispatch a signal (or closure) to the actual thread that requires it, thereby deferring VAO configuration to be performed on that thread.

      null when without rebind behavior.

    • setPoolInit

      public GPUPoolBehavior<T,D> setPoolInit(Consumer<? super GPUMemoryPool<T,D>> glPoolInit)
      At end of the buffer object GPUMemoryPool.init().

      null when without after-init behavior.

    • setPoolDestroy

      public GPUPoolBehavior<T,D> setPoolDestroy(Consumer<? super GPUMemoryPool<T,D>> glPoolDestroy)
      At end of the buffer object GPUMemoryPool.destroy(), for delete some vao/texture object.

      null when without after-destroy behavior.

    • setBufferInitRule

      public GPUPoolBehavior<T,D> setBufferInitRule(@NotNull BiFunction<Long,? super GPUMemoryPool<T,D>,Long> bufferInitRule)
      The memory allocation behavior when malloc is first called after initialization.

      The first Long parameter is the requested size for that malloc call, and this function should return a value no less than that parameter.

    • setBufferExpendRule

      public GPUPoolBehavior<T,D> setBufferExpendRule(@NotNull BiFunction<Long,? super GPUMemoryPool<T,D>,Long> bufferExpendRule)
      The behavior of re‑creating a larger‑capacity Buffer object when the current memory space is insufficient.

      The first Long parameter is the size of the existing buffer object before expansion, and this function should return a value no less than that parameter.

    • setNewMemoryFormat

      public GPUPoolBehavior<T,D> setNewMemoryFormat(GPUMemoryPool.MemoryFormat<T,D> format)
      The behavior of make a new memory region by GPUMemoryPool.malloc(Object, long) and then check or write data into memory; without GL15.glBindBuffer(int, int) before or after this calls, so you should be bind and unbind your buffer in method.

      null when without format behavior.