2018-06-21 04:29:53 +00:00
|
|
|
//
|
|
|
|
// Context.h
|
|
|
|
// MetalRenderer
|
|
|
|
//
|
|
|
|
// Created by Stuart Carnie on 6/9/18.
|
|
|
|
// Copyright © 2018 Stuart Carnie. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#import <Metal/Metal.h>
|
2018-06-30 05:57:48 +00:00
|
|
|
#import "RendererCommon.h"
|
2018-06-21 04:29:53 +00:00
|
|
|
|
2018-06-30 05:57:48 +00:00
|
|
|
@interface Texture : NSObject
|
|
|
|
@property (readonly) id<MTLTexture> texture;
|
|
|
|
@property (readonly) id<MTLSamplerState> sampler;
|
|
|
|
@end
|
2018-06-21 04:29:53 +00:00
|
|
|
|
2018-06-30 05:57:48 +00:00
|
|
|
/*! @brief Context contains the render state used by various components */
|
2018-06-21 04:29:53 +00:00
|
|
|
@interface Context : NSObject
|
|
|
|
|
|
|
|
@property (readonly) id<MTLDevice> device;
|
|
|
|
@property (readonly) id<MTLLibrary> library;
|
|
|
|
/*! @brief Returns the command buffer for the current frame */
|
|
|
|
@property (readonly) id<MTLCommandBuffer> commandBuffer;
|
|
|
|
@property (readonly) id<CAMetalDrawable> nextDrawable;
|
|
|
|
@property (readonly) id<MTLTexture> renderTexture;
|
|
|
|
|
2018-06-30 05:57:48 +00:00
|
|
|
- (instancetype)initWithDevice:(id<MTLDevice>)d
|
|
|
|
layer:(CAMetalLayer *)layer
|
|
|
|
library:(id<MTLLibrary>)l;
|
|
|
|
|
|
|
|
- (Texture *)newTexture:(struct texture_image)image filter:(enum texture_filter_type)filter;
|
|
|
|
- (void)convertFormat:(RPixelFormat)fmt from:(id<MTLBuffer>)src to:(id<MTLTexture>)dst;
|
2018-06-21 04:29:53 +00:00
|
|
|
|
|
|
|
/*! @brief begin marks the beginning of a frame */
|
|
|
|
- (void)begin;
|
|
|
|
|
|
|
|
/*! @brief end commits the command buffer */
|
|
|
|
- (void)end;
|
|
|
|
|
|
|
|
@end
|