Package icyllis.arc3d.opengl

# Class GLCommandBuffer

java.lang.Object
icyllis.arc3d.engine.CommandBuffer
icyllis.arc3d.opengl.GLCommandBuffer

public final class GLCommandBuffer extends CommandBuffer
The OpenGL command buffer. The commands executed on `GLCommandBuffer` are mostly the same as that on `GLDevice`, but `GLCommandBuffer` assumes some values and will not handle dirty context.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `begin()`
  `boolean`
  `beginRenderPass(RenderPassDesc renderPassDesc, FramebufferDesc framebufferDesc, Rect2ic renderPassBounds, float[] clearColors, float clearDepth, int clearStencil)`
  Begin render pass.
  `boolean`
  `bindGraphicsPipeline(@RawPtr GraphicsPipeline graphicsPipeline)`
  Bind graphics pipeline.
  `void`
  `bindIndexBuffer(int indexType, @RawPtr Buffer buffer, long offset)`
  Render pass scope, caller must track the buffer.
  `void`
  `bindTextureSampler(int binding, @RawPtr Image texture, @RawPtr Sampler sampler, short swizzle)`
  Bind texture view and sampler to the same binding point (combined image sampler).
  `void`
  `bindUniformBuffer(int binding, @RawPtr Buffer buffer, long offset, long size)`
  Render pass scope, caller must track the buffer.
  `void`
  `bindVertexBuffer(int binding, @RawPtr Buffer buffer, long offset)`
  Render pass scope, caller must track the buffer.
  `protected boolean`
  `checkFinishedAndReset()`
  `void`
  `draw(int vertexCount, int baseVertex)`
  Records a non-indexed draw to current command buffer.
  `void`
  `drawIndexed(int indexCount, int baseIndex, int baseVertex)`
  Records an indexed draw to current command buffer.
  `void`
  `drawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex)`
  Records an indexed draw to current command buffer.
  `void`
  `drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex)`
  Records a non-indexed draw to current command buffer.
  `void`
  `endRenderPass()`
  End the current render pass.
  `void`
  `flushColorWrite(boolean enable)`
  Flush color mask for draw buffer 0.
  `void`
  `flushDepthWrite(boolean enable)`
  `void`
  `flushScissorTest(boolean enable)`
  Flush scissor test.
  `protected boolean`
  `onCopyBuffer(@RawPtr Buffer srcBuffer, @RawPtr Buffer dstBuffer, long srcOffset, long dstOffset, long size)`
  `protected boolean`
  `onCopyBufferToImage(@RawPtr Buffer srcBuffer, @RawPtr Image dstImage, int srcColorType, int dstColorType, BufferImageCopyData[] copyData)`
  `protected boolean`
  `onCopyImage(@RawPtr Image srcImage, int srcL, int srcT, int srcR, int srcB, @RawPtr Image dstImage, int dstX, int dstY, int mipLevel)`
  `void`
  `resetStates()`
  `void`
  `setScissor(int x, int y, int width, int height)`
  Set scissor, must be called after `CommandBuffer.beginRenderPass(icyllis.arc3d.engine.RenderPassDesc, icyllis.arc3d.engine.FramebufferDesc, icyllis.arc3d.core.Rect2ic, float[], float, int)`.
  `void`
  `setViewport(int x, int y, int width, int height)`
  Set viewport, must be called after `CommandBuffer.beginRenderPass(icyllis.arc3d.engine.RenderPassDesc, icyllis.arc3d.engine.FramebufferDesc, icyllis.arc3d.core.Rect2ic, float[], float, int)`.
  `protected boolean`
  `submit(QueueManager queueManager)`
  `protected void`
  `waitUntilFinished()`
  Blocks the current thread and waits for GPU to finish outstanding works.

  ### Methods inherited from class icyllis.arc3d.engine.CommandBuffer

  `callFinishedCallbacks, copyBuffer, copyBufferToImage, copyImage, releaseResources, trackCommandBufferResource, trackResource, trackResource`

  ### Methods inherited from class java.lang.Object

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

- ## Method Details

  - ### resetStates

    public void resetStates()

  - ### beginRenderPass

    public boolean beginRenderPass(RenderPassDesc renderPassDesc, FramebufferDesc framebufferDesc, Rect2ic renderPassBounds, float[] clearColors, float clearDepth, int clearStencil)
    Description copied from class: `CommandBuffer`
    Begin render pass. If successful, `CommandBuffer.endRenderPass()` must be called.
    Specified by:
      `beginRenderPass` in class `CommandBuffer`
    Parameters:
      `renderPassDesc` - descriptor to create a render pass
      `framebufferDesc` - descriptor to create a framebuffer
      `renderPassBounds` - content bounds of this render pass
      `clearColors` - clear color for each color attachment
      `clearDepth` - clear depth
      `clearStencil` - clear stencil (unsigned)
    Returns:
      success or not

  - ### endRenderPass

    public void endRenderPass()
    Description copied from class: `CommandBuffer`
    End the current render pass.
    Specified by:
      `endRenderPass` in class `CommandBuffer`

  - ### onCopyBuffer

    protected boolean onCopyBuffer(@RawPtr @RawPtr Buffer srcBuffer, @RawPtr @RawPtr Buffer dstBuffer, long srcOffset, long dstOffset, long size)
    Specified by:
      `onCopyBuffer` in class `CommandBuffer`

  - ### onCopyBufferToImage

    protected boolean onCopyBufferToImage(@RawPtr @RawPtr Buffer srcBuffer, @RawPtr @RawPtr Image dstImage, int srcColorType, int dstColorType, BufferImageCopyData[] copyData)
    Specified by:
      `onCopyBufferToImage` in class `CommandBuffer`

  - ### onCopyImage

    protected boolean onCopyImage(@RawPtr @RawPtr Image srcImage, int srcL, int srcT, int srcR, int srcB, @RawPtr @RawPtr Image dstImage, int dstX, int dstY, int mipLevel)
    Specified by:
      `onCopyImage` in class `CommandBuffer`

  - ### flushScissorTest

    public void flushScissorTest(boolean enable)
    Flush scissor test.
    Parameters:
      `enable` - whether to enable scissor test

  - ### flushColorWrite

    public void flushColorWrite(boolean enable)
    Flush color mask for draw buffer 0.
    Parameters:
      `enable` - whether to write color

  - ### flushDepthWrite

    public void flushDepthWrite(boolean enable)

  - ### bindGraphicsPipeline

    public boolean bindGraphicsPipeline(@RawPtr @RawPtr GraphicsPipeline graphicsPipeline)
    Description copied from class: `CommandBuffer`
    Bind graphics pipeline. Due to async compiling, it may fail. Render pass scope, caller must track the pipeline.
    Specified by:
      `bindGraphicsPipeline` in class `CommandBuffer`
    Parameters:
      `graphicsPipeline` - the pipeline object
    Returns:
      success or not

  - ### setViewport

    public void setViewport(int x, int y, int width, int height)
    Description copied from class: `CommandBuffer`
    Set viewport, must be called after `CommandBuffer.beginRenderPass(icyllis.arc3d.engine.RenderPassDesc, icyllis.arc3d.engine.FramebufferDesc, icyllis.arc3d.core.Rect2ic, float[], float, int)`.
    Specified by:
      `setViewport` in class `CommandBuffer`

  - ### setScissor

    public void setScissor(int x, int y, int width, int height)
    Description copied from class: `CommandBuffer`
    Set scissor, must be called after `CommandBuffer.beginRenderPass(icyllis.arc3d.engine.RenderPassDesc, icyllis.arc3d.engine.FramebufferDesc, icyllis.arc3d.core.Rect2ic, float[], float, int)`.
    Specified by:
      `setScissor` in class `CommandBuffer`

  - ### bindIndexBuffer

    public void bindIndexBuffer(int indexType, @RawPtr @RawPtr Buffer buffer, long offset)
    Description copied from class: `CommandBuffer`
    Render pass scope, caller must track the buffer.
    Specified by:
      `bindIndexBuffer` in class `CommandBuffer`
    Parameters:
      `indexType` - see `Engine.IndexType`

  - ### bindVertexBuffer

    public void bindVertexBuffer(int binding, @RawPtr @RawPtr Buffer buffer, long offset)
    Description copied from class: `CommandBuffer`
    Render pass scope, caller must track the buffer.
    Specified by:
      `bindVertexBuffer` in class `CommandBuffer`

  - ### bindUniformBuffer

    public void bindUniformBuffer(int binding, @RawPtr @RawPtr Buffer buffer, long offset, long size)
    Description copied from class: `CommandBuffer`
    Render pass scope, caller must track the buffer.
    Specified by:
      `bindUniformBuffer` in class `CommandBuffer`

  - ### bindTextureSampler

    public void bindTextureSampler(int binding, @RawPtr @RawPtr Image texture, @RawPtr @RawPtr Sampler sampler, short swizzle)
    Description copied from class: `CommandBuffer`
    Bind texture view and sampler to the same binding point (combined image sampler). Render pass scope, caller must track the image and sampler.
    Specified by:
      `bindTextureSampler` in class `CommandBuffer`
    Parameters:
      `binding` - the binding index
      `texture` - the texture image
      `sampler` - the sampler state
      `swizzle` - the swizzle of the texture view for shader read, see `Swizzle`

  - ### draw

    public void draw(int vertexCount, int baseVertex)
    Description copied from class: `CommandBuffer`
    Records a non-indexed draw to current command buffer. Render pass scope.
    Specified by:
      `draw` in class `CommandBuffer`
    Parameters:
      `vertexCount` - the number of vertices to draw
      `baseVertex` - the index of the first vertex to draw

  - ### drawIndexed

    public void drawIndexed(int indexCount, int baseIndex, int baseVertex)
    Description copied from class: `CommandBuffer`
    Records an indexed draw to current command buffer. For OpenGL ES, if base vertex is unavailable, gl_VertexID always begins at 0. Render pass scope.
    Specified by:
      `drawIndexed` in class `CommandBuffer`
    Parameters:
      `indexCount` - the number of vertices to draw
      `baseIndex` - the base index within the index buffer
      `baseVertex` - the value added to the vertex index before indexing into the vertex buffer

  - ### drawInstanced

    public void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex)
    Description copied from class: `CommandBuffer`
    Records a non-indexed draw to current command buffer. For OpenGL, regardless of the baseInstance value, gl_InstanceID always begins at 0. Render pass scope.
    Specified by:
      `drawInstanced` in class `CommandBuffer`
    Parameters:
      `instanceCount` - the number of instances to draw
      `baseInstance` - the instance ID of the first instance to draw
      `vertexCount` - the number of vertices to draw
      `baseVertex` - the index of the first vertex to draw

  - ### drawIndexedInstanced

    public void drawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex)
    Description copied from class: `CommandBuffer`
    Records an indexed draw to current command buffer. For OpenGL ES, if base vertex is unavailable, gl_VertexID always begins at 0. For OpenGL, regardless of the baseInstance value, gl_InstanceID always begins at 0. Render pass scope.
    Specified by:
      `drawIndexedInstanced` in class `CommandBuffer`
    Parameters:
      `indexCount` - the number of vertices to draw
      `baseIndex` - the base index within the index buffer
      `instanceCount` - the number of instances to draw
      `baseInstance` - the instance ID of the first instance to draw
      `baseVertex` - the value added to the vertex index before indexing into the vertex buffer

  - ### begin

    protected void begin()
    Specified by:
      `begin` in class `CommandBuffer`

  - ### submit

    protected boolean submit(QueueManager queueManager)
    Specified by:
      `submit` in class `CommandBuffer`

  - ### checkFinishedAndReset

    protected boolean checkFinishedAndReset()
    Specified by:
      `checkFinishedAndReset` in class `CommandBuffer`

  - ### waitUntilFinished

    protected void waitUntilFinished()
    Description copied from class: `CommandBuffer`
    Blocks the current thread and waits for GPU to finish outstanding works.
    Specified by:
      `waitUntilFinished` in class `CommandBuffer`