Class CommandBuffer
- Direct Known Subclasses:
GLCommandBuffer,VulkanCommandBuffer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidbegin()abstract booleanbeginRenderPass(RenderPassDesc renderPassDesc, FramebufferDesc framebufferDesc, Rect2ic renderPassBounds, float[] clearColors, float clearDepth, int clearStencil) Begin render pass.abstract booleanbindGraphicsPipeline(@RawPtr GraphicsPipeline graphicsPipeline) Bind graphics pipeline.abstract voidbindIndexBuffer(int indexType, @RawPtr Buffer buffer, long offset) Render pass scope, caller must track the buffer.abstract voidbindTextureSampler(int binding, @RawPtr Image texture, @RawPtr Sampler sampler, short swizzle) Bind texture view and sampler to the same binding point (combined image sampler).abstract voidbindUniformBuffer(int binding, @RawPtr Buffer buffer, long offset, long size) Render pass scope, caller must track the buffer.abstract voidbindVertexBuffer(int binding, @RawPtr Buffer buffer, long offset) Render pass scope, caller must track the buffer.protected final voidcallFinishedCallbacks(boolean success) protected abstract booleanfinal booleancopyBuffer(@RawPtr Buffer srcBuffer, @RawPtr Buffer dstBuffer, long srcOffset, long dstOffset, long size) Performs a buffer-to-buffer copy.final booleancopyBufferToImage(@RawPtr Buffer srcBuffer, @RawPtr Image dstImage, int srcColorType, int dstColorType, BufferImageCopyData[] copyData) Performs a buffer-to-image copy.final booleancopyImage(@RawPtr Image srcImage, int srcL, int srcT, int srcR, int srcB, @RawPtr Image dstImage, int dstX, int dstY, int mipLevel) Perform an image-to-image copy, with the specified regions.abstract voiddraw(int vertexCount, int baseVertex) Records a non-indexed draw to current command buffer.abstract voiddrawIndexed(int indexCount, int baseIndex, int baseVertex) Records an indexed draw to current command buffer.abstract voiddrawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex) Records an indexed draw to current command buffer.abstract voiddrawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex) Records a non-indexed draw to current command buffer.abstract voidEnd the current render pass.protected abstract booleanonCopyBuffer(@RawPtr Buffer srcBuffer, @RawPtr Buffer dstBuffer, long srcOffset, long dstOffset, long size) protected abstract booleanonCopyBufferToImage(@RawPtr Buffer srcBuffer, @RawPtr Image dstImage, int srcColorType, int dstColorType, BufferImageCopyData[] copyData) protected abstract booleanonCopyImage(@RawPtr Image srcImage, int srcL, int srcT, int srcR, int srcB, @RawPtr Image dstImage, int dstX, int dstY, int mipLevel) protected final voidabstract voidsetScissor(int x, int y, int width, int height) Set scissor, must be called afterbeginRenderPass(icyllis.arc3d.engine.RenderPassDesc, icyllis.arc3d.engine.FramebufferDesc, icyllis.arc3d.core.Rect2ic, float[], float, int).abstract voidsetViewport(int x, int y, int width, int height) Set viewport, must be called afterbeginRenderPass(icyllis.arc3d.engine.RenderPassDesc, icyllis.arc3d.engine.FramebufferDesc, icyllis.arc3d.core.Rect2ic, float[], float, int).protected abstract booleansubmit(QueueManager queueManager) final voidtrackCommandBufferResource(@SharedPtr Resource resource) Takes a CommandBuffer ref on the Resource that will be released when the command buffer has finished execution.final voidtrackResource(@SharedPtr ManagedResource resource) Takes a ref on the ManagedResource that will be released when the command buffer has finished execution.final voidtrackResource(@SharedPtr Resource resource) Takes a Usage ref on the Resource that will be released when the command buffer has finished execution.protected abstract voidBlocks the current thread and waits for GPU to finish outstanding works.
-
Constructor Details
-
CommandBuffer
public CommandBuffer()
-
-
Method Details
-
beginRenderPass
public abstract boolean beginRenderPass(RenderPassDesc renderPassDesc, FramebufferDesc framebufferDesc, Rect2ic renderPassBounds, float[] clearColors, float clearDepth, int clearStencil) Begin render pass. If successful,endRenderPass()must be called.- Parameters:
renderPassDesc- descriptor to create a render passframebufferDesc- descriptor to create a framebufferrenderPassBounds- content bounds of this render passclearColors- clear color for each color attachmentclearDepth- clear depthclearStencil- clear stencil (unsigned)- Returns:
- success or not
-
setViewport
public abstract void setViewport(int x, int y, int width, int height) Set viewport, must be called afterbeginRenderPass(icyllis.arc3d.engine.RenderPassDesc, icyllis.arc3d.engine.FramebufferDesc, icyllis.arc3d.core.Rect2ic, float[], float, int). -
setScissor
public abstract void setScissor(int x, int y, int width, int height) Set scissor, must be called afterbeginRenderPass(icyllis.arc3d.engine.RenderPassDesc, icyllis.arc3d.engine.FramebufferDesc, icyllis.arc3d.core.Rect2ic, float[], float, int). -
bindGraphicsPipeline
Bind graphics pipeline. Due to async compiling, it may fail. Render pass scope, caller must track the pipeline.- Parameters:
graphicsPipeline- the pipeline object- Returns:
- success or not
-
bindIndexBuffer
Render pass scope, caller must track the buffer.- Parameters:
indexType- seeEngine.IndexType
-
bindVertexBuffer
Render pass scope, caller must track the buffer. -
bindUniformBuffer
public abstract void bindUniformBuffer(int binding, @RawPtr @RawPtr Buffer buffer, long offset, long size) Render pass scope, caller must track the buffer. -
bindTextureSampler
public abstract void bindTextureSampler(int binding, @RawPtr @RawPtr Image texture, @RawPtr @RawPtr Sampler sampler, short swizzle) Bind texture view and sampler to the same binding point (combined image sampler). Render pass scope, caller must track the image and sampler.- Parameters:
binding- the binding indextexture- the texture imagesampler- the sampler stateswizzle- the swizzle of the texture view for shader read, seeSwizzle
-
draw
public abstract void draw(int vertexCount, int baseVertex) Records a non-indexed draw to current command buffer. Render pass scope.- Parameters:
vertexCount- the number of vertices to drawbaseVertex- the index of the first vertex to draw
-
drawIndexed
public abstract void drawIndexed(int indexCount, int baseIndex, int baseVertex) 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.- Parameters:
indexCount- the number of vertices to drawbaseIndex- the base index within the index bufferbaseVertex- the value added to the vertex index before indexing into the vertex buffer
-
drawInstanced
public abstract void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex) 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.- Parameters:
instanceCount- the number of instances to drawbaseInstance- the instance ID of the first instance to drawvertexCount- the number of vertices to drawbaseVertex- the index of the first vertex to draw
-
drawIndexedInstanced
public abstract void drawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex) 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.- Parameters:
indexCount- the number of vertices to drawbaseIndex- the base index within the index bufferinstanceCount- the number of instances to drawbaseInstance- the instance ID of the first instance to drawbaseVertex- the value added to the vertex index before indexing into the vertex buffer
-
endRenderPass
public abstract void endRenderPass()End the current render pass. -
copyBuffer
public final boolean copyBuffer(@RawPtr @RawPtr Buffer srcBuffer, @RawPtr @RawPtr Buffer dstBuffer, long srcOffset, long dstOffset, long size) Performs a buffer-to-buffer copy.Can only be used outside render passes.
The caller must track resources if success.
-
onCopyBuffer
-
copyBufferToImage
public final boolean copyBufferToImage(@RawPtr @RawPtr Buffer srcBuffer, @RawPtr @RawPtr Image dstImage, int srcColorType, int dstColorType, BufferImageCopyData[] copyData) Performs a buffer-to-image copy.Can only be used outside render passes.
The caller must track resources if success.
-
onCopyBufferToImage
-
copyImage
public final boolean copyImage(@RawPtr @RawPtr Image srcImage, int srcL, int srcT, int srcR, int srcB, @RawPtr @RawPtr Image dstImage, int dstX, int dstY, int mipLevel) Perform an image-to-image copy, with the specified regions. Scaling is not allowed.If their dimensions are same and formats are compatible, then this method will attempt to perform copy. Otherwise, this method will attempt to perform blit, which may include format conversion.
Only mipmap level level of 2D images will be copied, without any multisampled buffer and depth/stencil buffer.
Can only be used outside render passes.
The caller must track resources if success.
- Returns:
- success or not
-
onCopyImage
-
trackResource
Takes a Usage ref on the Resource that will be released when the command buffer has finished execution.This is mostly commonly used for host-visible Buffers and shared Resources.
- Parameters:
resource- the resource to move
-
trackResource
Takes a ref on the ManagedResource that will be released when the command buffer has finished execution.- Parameters:
resource- the resource to move
-
trackCommandBufferResource
Takes a CommandBuffer ref on the Resource that will be released when the command buffer has finished execution.CommandBuffer ref allows a Resource to be returned to ResourceCache for reuse while the CommandBuffer is still executing on the GPU. This is most commonly used for GPU-only Resources.
- Parameters:
resource- the resource to move
-
begin
protected abstract void begin() -
submit
-
checkFinishedAndReset
protected abstract boolean checkFinishedAndReset() -
waitUntilFinished
protected abstract void waitUntilFinished()Blocks the current thread and waits for GPU to finish outstanding works. -
callFinishedCallbacks
protected final void callFinishedCallbacks(boolean success) -
releaseResources
protected final void releaseResources()
-