// // Context.h // MetalRenderer // // Created by Stuart Carnie on 6/9/18. // Copyright © 2018 Stuart Carnie. All rights reserved. // #import #import #import "RendererCommon.h" @interface Texture : NSObject @property (nonatomic, readonly) id texture; @property (nonatomic, readonly) id sampler; @end typedef struct { void *data; NSUInteger offset; __unsafe_unretained id buffer; } BufferRange; /*! @brief Context contains the render state used by various components */ @interface Context : NSObject @property (nonatomic, readonly) id device; @property (nonatomic, readonly) id library; @property (nonatomic, readwrite) MTLClearColor clearColor; /*! @brief Returns the command buffer used for pre-render work, * such as mip maps for applying filters * */ @property (nonatomic, readonly) id blitCommandBuffer; /*! @brief Returns the command buffer for the current frame */ @property (nonatomic, readonly) id commandBuffer; @property (nonatomic, readonly) id nextDrawable; /*! @brief Main render encoder to back buffer */ @property (nonatomic, readonly) id rce; - (instancetype)initWithDevice:(id)d layer:(CAMetalLayer *)layer library:(id)l; - (Texture *)newTexture:(struct texture_image)image filter:(enum texture_filter_type)filter; - (void)convertFormat:(RPixelFormat)fmt from:(id)src to:(id)dst; - (bool)allocRange:(BufferRange *)range length:(NSUInteger)length; /*! @brief begin marks the beginning of a frame */ - (void)begin; /*! @brief end commits the command buffer */ - (void)end; @end