Axmol Engine 2.4.0-258ceca
Loading...
Searching...
No Matches
CommandBufferMTL Class Reference

Store encoded commands for the GPU to execute. More...

#include <CommandBufferMTL.h>

Inherits CommandBuffer.

Public Member Functions

Constructor, Destructor and Initializers
 CommandBufferMTL (DriverMTL *driver)
 
void setDepthStencilState (DepthStencilState *depthStencilState) override
 Set depthStencil status.
 
void setRenderPipeline (RenderPipeline *renderPipeline) override
 Sets the current render pipeline state object once.
 
void setStencilReferenceValue (unsigned int value)
 Update both front and back stencil reference value.
 
void setStencilReferenceValue (unsigned int frontRef, unsigned int backRef)
 Update stencil reference value.
 
- Public Member Functions inherited from Object
void retain ()
 Retains the ownership.
 
void release ()
 Releases the ownership immediately.
 
Objectautorelease ()
 Releases the ownership sometime soon automatically.
 
unsigned int getReferenceCount () const
 Returns the Object's current reference count.
 
virtual ~Object ()
 Destructor.
 

Setters & Getters

bool beginFrame () override
 Indicate the begining of a frame Wait until the inflight command buffer has completed its work.
 
void beginRenderPass (const RenderTarget *renderTarget, const RenderPassDescriptor &descriptor) override
 Create a MTLRenderCommandEncoder object for graphics rendering to an attachment in a RenderPassDescriptor.
 
void updateDepthStencilState (const DepthStencilDescriptor &descriptor) override
 Update depthStencil status, improvment: for metal backend cache it.
 
void updatePipelineState (const RenderTarget *rt, const PipelineDescriptor &descriptor) override
 Update render pipeline status Building a programmable pipeline involves an expensive evaluation of GPU state.
 
void setViewport (int x, int y, unsigned int w, unsigned int h) override
 Fixed-function state.
 
void setCullMode (CullMode mode) override
 Fixed-function state.
 
void setWinding (Winding winding) override
 Fixed-function state.
 
void setVertexBuffer (Buffer *buffer) override
 Set a global buffer for all vertex shaders at the given bind point index 0.
 
void setProgramState (ProgramState *programState) override
 Set the uniform data at a given vertex and fragment buffer binding point 1 Set a global texture for all vertex and fragment shaders at the given bind location.
 
void setIndexBuffer (Buffer *buffer) override
 Set indexes when drawing primitives with index list @ buffer A buffer object that the device will read indexes from.
 
void setInstanceBuffer (Buffer *buffer) override
 Set matrix tranform when drawing instances of the same model @ buffer A buffer object that the device will read matrices from.
 
void drawArrays (PrimitiveType primitiveType, std::size_t start, std::size_t count, bool wireframe) override
 Draw primitives without an index list.
 
void drawElements (PrimitiveType primitiveType, IndexFormat indexType, std::size_t count, std::size_t offset, bool wireframe) override
 Draw primitives with an index list.
 
void drawElementsInstanced (PrimitiveType primitiveType, IndexFormat indexType, std::size_t count, std::size_t offset, int instanceCount, bool wireframe=false) override
 Draw primitives with an index list instanced.
 
void endRenderPass () override
 Do some resources release.
 
void endFrame () override
 Present a drawable and commit a command buffer so it can be executed as soon as possible.
 
void setScissorRect (bool isEnabled, float x, float y, float width, float height) override
 Fixed-function state.
 
void readPixels (RenderTarget *rt, std::function< void(const PixelBufferDescriptor &)> callback) override
 Read pixels from RenderTarget.
 

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 

Detailed Description

Store encoded commands for the GPU to execute.

A command buffer stores encoded commands until the buffer is committed for execution by the GPU

Constructor & Destructor Documentation

◆ CommandBufferMTL()

Parameters
driverThe device for which MTLCommandQueue object was created.

Member Function Documentation

◆ setDepthStencilState()

void setDepthStencilState ( DepthStencilState * depthStencilState)
overridevirtual

Set depthStencil status.

Parameters
depthStencilStateSpecifies the depth and stencil status

Implements CommandBuffer.

◆ setRenderPipeline()

void setRenderPipeline ( RenderPipeline * renderPipeline)
overridevirtual

Sets the current render pipeline state object once.

Parameters
renderPipelineAn object that contains the graphics functions and configuration state used in a render pass.

Implements CommandBuffer.

◆ beginFrame()

bool beginFrame ( )
overridevirtual

Indicate the begining of a frame Wait until the inflight command buffer has completed its work.

Then create MTLCommandBuffer and enqueue it to MTLCommandQueue. Then start schedule available MTLBuffer

Implements CommandBuffer.

◆ beginRenderPass()

void beginRenderPass ( const RenderTarget * renderTarget,
const RenderPassDescriptor & descriptor )
overridevirtual

Create a MTLRenderCommandEncoder object for graphics rendering to an attachment in a RenderPassDescriptor.

MTLRenderCommandEncoder is cached if current RenderPassDescriptor is identical to previous one.

Parameters
descriptorSpecifies a group of render targets that hold the results of a render pass.

Implements CommandBuffer.

◆ updateDepthStencilState()

void updateDepthStencilState ( const DepthStencilDescriptor & descriptor)
overridevirtual

Update depthStencil status, improvment: for metal backend cache it.

Parameters
depthStencilStateSpecifies the depth and stencil status

Implements CommandBuffer.

◆ updatePipelineState()

void updatePipelineState ( const RenderTarget * rt,
const PipelineDescriptor & descriptor )
overridevirtual

Update render pipeline status Building a programmable pipeline involves an expensive evaluation of GPU state.

So a new render pipeline object will be created only if it hasn't been created before.

Parameters
rtSpecifies the render target.
pipelineDescriptorSpecifies the pipeline descriptor.

Implements CommandBuffer.

◆ setViewport()

void setViewport ( int x,
int y,
unsigned int w,
unsigned int h )
overridevirtual

Fixed-function state.

Parameters
xThe x coordinate of the upper-left corner of the viewport.
yThe y coordinate of the upper-left corner of the viewport.
wThe width of the viewport, in pixels.
hThe height of the viewport, in pixels.

Implements CommandBuffer.

◆ setCullMode()

void setCullMode ( CullMode mode)
overridevirtual

Fixed-function state.

Parameters
modeControls if primitives are culled when front facing, back facing, or not culled at all.

Implements CommandBuffer.

◆ setWinding()

void setWinding ( Winding winding)
overridevirtual

Fixed-function state.

Parameters
windingThe winding order of front-facing primitives.

Implements CommandBuffer.

◆ setVertexBuffer()

void setVertexBuffer ( Buffer * buffer)
overridevirtual

Set a global buffer for all vertex shaders at the given bind point index 0.

Parameters
bufferThe buffer to set in the buffer argument table.

Implements CommandBuffer.

◆ setProgramState()

void setProgramState ( ProgramState * programState)
overridevirtual

Set the uniform data at a given vertex and fragment buffer binding point 1 Set a global texture for all vertex and fragment shaders at the given bind location.

Parameters
programStateA programState object that hold the uniform and texture data.

Implements CommandBuffer.

◆ setIndexBuffer()

void setIndexBuffer ( Buffer * buffer)
overridevirtual

Set indexes when drawing primitives with index list @ buffer A buffer object that the device will read indexes from.

@ see drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset)

Implements CommandBuffer.

◆ drawArrays()

void drawArrays ( PrimitiveType primitiveType,
std::size_t start,
std::size_t count,
bool wireframe )
overridevirtual

Draw primitives without an index list.

Parameters
primitiveTypeThe type of primitives that elements are assembled into.
startFor each instance, the first index to draw
countFor each instance, the number of indexes to draw
See also
drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset)

TODO: Implement a wireframe mode for METAL devices. Refer to: https://forums.ogre3d.org/viewtopic.php?t=95089

Implements CommandBuffer.

◆ drawElements()

void drawElements ( PrimitiveType primitiveType,
IndexFormat indexType,
std::size_t count,
std::size_t offset,
bool wireframe )
overridevirtual

Draw primitives with an index list.

Parameters
primitiveTypeThe type of primitives that elements are assembled into.
indexTypeThe type if indexes, either 16 bit integer or 32 bit integer.
countThe number of indexes to read from the index buffer for each instance.
offsetByte offset within indexBuffer to start reading indexes from.
See also
setIndexBuffer(Buffer* buffer)
drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count)

TODO: Implement a wireframe mode for METAL devices. Refer to: https://forums.ogre3d.org/viewtopic.php?t=95089

Implements CommandBuffer.

◆ drawElementsInstanced()

void drawElementsInstanced ( PrimitiveType primitiveType,
IndexFormat indexType,
std::size_t count,
std::size_t offset,
int instanceCount,
bool wireframe = false )
overridevirtual

Draw primitives with an index list instanced.

Parameters
primitiveTypeThe type of primitives that elements are assembled into.
indexTypeThe type if indexes, either 16 bit integer or 32 bit integer.
countThe number of indexes to read from the index buffer for each instance.
offsetByte offset within indexBuffer to start reading indexes from.
instanceCount of instances to draw at once.
See also
setIndexBuffer(Buffer* buffer)
drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count)

Implements CommandBuffer.

◆ setScissorRect()

void setScissorRect ( bool isEnabled,
float x,
float y,
float width,
float height )
overridevirtual

Fixed-function state.

Parameters
x,ySpecifies the lower left corner of the scissor box
wdithSpecifies the width of the scissor box
heightSpecifies the height of the scissor box

Implements CommandBuffer.

◆ readPixels()

void readPixels ( RenderTarget * rt,
std::function< void(const PixelBufferDescriptor &)> callback )
overridevirtual

Read pixels from RenderTarget.

Parameters
callbackA callback to deal with pixel data read.

Implements CommandBuffer.


The documentation for this class was generated from the following file: