diff --git a/src/renderer_mtl.h b/src/renderer_mtl.h index 805fa1eaf..21ebef206 100644 --- a/src/renderer_mtl.h +++ b/src/renderer_mtl.h @@ -65,23 +65,45 @@ namespace bgfx { namespace mtl typedef void (*mtlCallback)(void* userData); MTL_CLASS(BlitCommandEncoder) - void copyFromTexture(id _sourceTexture, NSUInteger _sourceSlice, NSUInteger _sourceLevel, MTLOrigin _sourceOrigin, MTLSize _sourceSize, - id _destinationTexture, NSUInteger _destinationSlice, NSUInteger _destinationLevel, MTLOrigin _destinationOrigin) + void copyFromTexture( + id _sourceTexture + , NSUInteger _sourceSlice + , NSUInteger _sourceLevel + , MTLOrigin _sourceOrigin + , MTLSize _sourceSize + , id _destinationTexture + , NSUInteger _destinationSlice + , NSUInteger _destinationLevel + , MTLOrigin _destinationOrigin + ) { [m_obj copyFromTexture:_sourceTexture sourceSlice:_sourceSlice sourceLevel:_sourceLevel sourceOrigin:_sourceOrigin sourceSize:_sourceSize toTexture:_destinationTexture destinationSlice:_destinationSlice destinationLevel:_destinationLevel destinationOrigin:_destinationOrigin]; } - void copyFromBuffer(id _sourceBuffer, NSUInteger _sourceOffset, id _destinationBuffer, - NSUInteger _destinationOffset, NSUInteger _size) + void copyFromBuffer( + id _sourceBuffer + , NSUInteger _sourceOffset + , id _destinationBuffer + , NSUInteger _destinationOffset + , NSUInteger _size + ) { [m_obj copyFromBuffer:_sourceBuffer sourceOffset:_sourceOffset toBuffer:_destinationBuffer destinationOffset:_destinationOffset size:_size]; } - void copyFromBuffer(id _sourceBuffer, NSUInteger _sourceOffset, NSUInteger _sourceBytesPerRow, - NSUInteger _sourceBytesPerImage, MTLSize _sourceSize, id _destinationTexture, - NSUInteger _destinationSlice, NSUInteger _destinationLevel, MTLOrigin _destinationOrigin) + void copyFromBuffer( + id _sourceBuffer + , NSUInteger _sourceOffset + , NSUInteger _sourceBytesPerRow + , NSUInteger _sourceBytesPerImage + , MTLSize _sourceSize + , id _destinationTexture + , NSUInteger _destinationSlice + , NSUInteger _destinationLevel + , MTLOrigin _destinationOrigin + ) { [m_obj copyFromBuffer:_sourceBuffer sourceOffset:_sourceOffset sourceBytesPerRow:_sourceBytesPerRow sourceBytesPerImage:_sourceBytesPerImage sourceSize:_sourceSize toTexture:_destinationTexture @@ -120,7 +142,7 @@ namespace bgfx { namespace mtl MTL_CLASS(CommandBuffer) // Creating Command Encoders - id renderCommandEncoderWithDescriptor( MTLRenderPassDescriptor* _renderPassDescriptor){ + id renderCommandEncoderWithDescriptor(MTLRenderPassDescriptor* _renderPassDescriptor){ return [m_obj renderCommandEncoderWithDescriptor:_renderPassDescriptor]; } @@ -281,7 +303,11 @@ namespace bgfx { namespace mtl return state; } - id newRenderPipelineStateWithDescriptor(MTLRenderPipelineDescriptor* _descriptor, MTLPipelineOption _options, MTLRenderPipelineReflection** _reflection) + id newRenderPipelineStateWithDescriptor( + MTLRenderPipelineDescriptor* _descriptor + , MTLPipelineOption _options + , MTLRenderPipelineReflection** _reflection + ) { NSError* error; id state = [m_obj newRenderPipelineStateWithDescriptor:_descriptor options:_options reflection:_reflection error:&error]; @@ -325,7 +351,10 @@ namespace bgfx { namespace mtl MTL_CLASS_END MTL_CLASS(Function) - NSArray* vertexAttributes() { return m_obj.vertexAttributes; } + NSArray* vertexAttributes() + { + return m_obj.vertexAttributes; + } void setLabel(const char* _label) { @@ -337,7 +366,10 @@ namespace bgfx { namespace mtl MTL_CLASS_END MTL_CLASS(Library) - id newFunctionWithName(const char* _functionName) { return [m_obj newFunctionWithName:@(_functionName)]; } + id newFunctionWithName(const char* _functionName) + { + return [m_obj newFunctionWithName:@(_functionName)]; + } MTL_CLASS_END MTL_CLASS(RenderCommandEncoder) @@ -431,12 +463,24 @@ namespace bgfx { namespace mtl //Drawing Geometric Primitives //NOTE: not exposing functions without instanceCount, it seems they are just wrappers - void drawIndexedPrimitives(MTLPrimitiveType _primitiveType, NSUInteger _indexCount, MTLIndexType _indexType, id _indexBuffer, NSUInteger _indexBufferOffset, NSUInteger _instanceCount) + void drawIndexedPrimitives( + MTLPrimitiveType _primitiveType + , NSUInteger _indexCount + , MTLIndexType _indexType + , id _indexBuffer + , NSUInteger _indexBufferOffset + , NSUInteger _instanceCount + ) { [m_obj drawIndexedPrimitives:_primitiveType indexCount:_indexCount indexType:_indexType indexBuffer:_indexBuffer indexBufferOffset:_indexBufferOffset instanceCount:_instanceCount]; } - void drawPrimitives(MTLPrimitiveType _primitiveType, NSUInteger _vertexStart, NSUInteger _vertexCount, NSUInteger _instanceCount) + void drawPrimitives( + MTLPrimitiveType _primitiveType + , NSUInteger _vertexStart + , NSUInteger _vertexCount + , NSUInteger _instanceCount + ) { [m_obj drawPrimitives:_primitiveType vertexStart:_vertexStart vertexCount:_vertexCount instanceCount:_instanceCount]; } @@ -603,10 +647,10 @@ namespace bgfx { namespace mtl return [_str UTF8String]; } -#define MTL_RELEASE(_obj) \ +#define MTL_RELEASE(_obj) \ BX_MACRO_BLOCK_BEGIN \ - [_obj release]; \ - _obj = nil; \ + [_obj release]; \ + _obj = nil; \ BX_MACRO_BLOCK_END // end of c++ wrapper @@ -670,7 +714,9 @@ namespace bgfx { namespace mtl , m_bufferIndex(0) { for (uint32_t ii = 0; ii < MTL_MAX_FRAMES_IN_FLIGHT; ++ii) + { m_buffers[ii] = NULL; + } } void create(uint32_t _size, void* _data, uint16_t _flags, uint16_t _stride = 0, bool _vertex = false); @@ -682,6 +728,7 @@ namespace bgfx { namespace mtl { MTL_RELEASE(m_buffers[ii]); } + m_dynamic = false; } @@ -748,9 +795,15 @@ namespace bgfx { namespace mtl void create(const ShaderMtl* _vsh, const ShaderMtl* _fsh); void destroy(); - RenderPipelineState getRenderPipelineState(uint64_t _state, uint32_t _rgba, FrameBufferHandle _fbHandle, VertexDeclHandle _declHandle, uint16_t _numInstanceData); + RenderPipelineState getRenderPipelineState( + uint64_t _state + , uint32_t _rgba + , FrameBufferHandle _fbHandle + , VertexDeclHandle _declHandle + , uint16_t _numInstanceData + ); - StateCacheT m_renderPipelineStateCache; + StateCacheT m_renderPipelineStateCache; uint8_t m_used[Attrib::Count+1]; // dense uint32_t m_attributes[Attrib::Count]; // sparse @@ -808,8 +861,21 @@ namespace bgfx { namespace mtl MTL_RELEASE(m_ptr); MTL_RELEASE(m_ptrStencil); } - void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem); - void commit(uint8_t _stage, bool _vertex, bool _fragment, uint32_t _flags = BGFX_TEXTURE_INTERNAL_DEFAULT_SAMPLER); + void update( + uint8_t _side + , uint8_t _mip + , const Rect& _rect + , uint16_t _z + , uint16_t _depth + , uint16_t _pitch + , const Memory* _mem + ); + void commit( + uint8_t _stage + , bool _vertex + , bool _fragment + , uint32_t _flags = BGFX_TEXTURE_INTERNAL_DEFAULT_SAMPLER + ); Texture m_ptr; Texture m_ptrMSAA; @@ -836,7 +902,13 @@ namespace bgfx { namespace mtl } void create(uint8_t _num, const Attachment* _attachment); - void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat); + void create( + uint16_t _denseIdx + , void* _nwh + , uint32_t _width + , uint32_t _height + , TextureFormat::Enum _depthFormat + ); void postReset(); uint16_t destroy(); @@ -854,7 +926,9 @@ namespace bgfx { namespace mtl struct CommandQueueMtl { - CommandQueueMtl() : m_releaseWriteIndex(0), m_releaseReadIndex(0) + CommandQueueMtl() + : m_releaseWriteIndex(0) + , m_releaseReadIndex(0) { } @@ -880,7 +954,7 @@ namespace bgfx { namespace mtl struct TimerQueryMtl { TimerQueryMtl() - : m_control(4) + : m_control(4) { }