RetroArch
Context.h
Go to the documentation of this file.
1 //
2 // Context.h
3 // MetalRenderer
4 //
5 // Created by Stuart Carnie on 6/9/18.
6 // Copyright © 2018 Stuart Carnie. All rights reserved.
7 //
8 
9 #import <Foundation/Foundation.h>
10 #import <Metal/Metal.h>
11 #import "RendererCommon.h"
12 
13 @interface Texture : NSObject
14 @property (nonatomic, readonly) id<MTLTexture> texture;
15 @property (nonatomic, readonly) id<MTLSamplerState> sampler;
16 @end
17 
18 typedef struct
19 {
20  void *data;
21  NSUInteger offset;
22  __unsafe_unretained id<MTLBuffer> buffer;
23 } BufferRange;
24 
26 @interface Context : NSObject
27 
28 @property (nonatomic, readonly) id<MTLDevice> device;
29 @property (nonatomic, readonly) id<MTLLibrary> library;
30 @property (nonatomic, readwrite) MTLClearColor clearColor;
31 @property (nonatomic, readwrite) video_viewport_t *viewport;
32 @property (nonatomic, readonly) Uniforms *uniforms;
33 
35 @property (nonatomic, readwrite) bool displaySyncEnabled;
36 
38 @property (nonatomic, readwrite) bool captureEnabled;
39 
43 @property (nonatomic, readonly) id<MTLCommandBuffer> blitCommandBuffer;
44 
46 @property (nonatomic, readonly) id<MTLCommandBuffer> commandBuffer;
47 @property (nonatomic, readonly) id<CAMetalDrawable> nextDrawable;
48 
50 @property (nonatomic, readonly) id<MTLRenderCommandEncoder> rce;
51 
52 - (instancetype)initWithDevice:(id<MTLDevice>)d
53  layer:(CAMetalLayer *)layer
54  library:(id<MTLLibrary>)l;
55 
56 - (Texture *)newTexture:(struct texture_image)image filter:(enum texture_filter_type)filter;
57 - (id<MTLTexture>)newTexture:(struct texture_image)image mipmapped:(bool)mipmapped;
58 - (void)convertFormat:(RPixelFormat)fmt from:(id<MTLTexture>)src to:(id<MTLTexture>)dst;
59 - (id<MTLRenderPipelineState>)getStockShader:(int)index blend:(bool)blend;
60 
62 - (void)resetRenderViewport;
63 
65 - (void)resetScissorRect;
66 
68 - (void)drawQuadX:(float)x y:(float)y w:(float)w h:(float)h
69  r:(float)r g:(float)g b:(float)b a:(float)a;
70 
71 - (bool)allocRange:(BufferRange *)range length:(NSUInteger)length;
72 
74 - (void)begin;
75 
77 - (void)end;
78 
79 - (void)setRotation:(unsigned)rotation;
80 - (bool)readBackBuffer:(uint8_t *)buffer;
81 
82 @end
Definition: Context.h:18
void * data
Definition: Context.h:20
NSUInteger offset
Definition: Context.h:21
GLenum GLuint id
Definition: glext.h:6233
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
typedef bool(RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index
__unsafe_unretained id< MTLBuffer > buffer
Definition: Context.h:22
texture_filter_type
Definition: video_defines.h:24
Definition: video_driver.h:686
Definition: image.h:42
Definition: metal_common.m:516
Definition: Context.h:13
Definition: ShaderTypes.h:70
GLuint GLuint end
Definition: glext.h:6292
GLuint sampler
Definition: glext.h:7950
struct nk_device device
Definition: nk_common.c:44
Context contains the render state used by various components.
Definition: Context.h:26
unsigned char uint8_t
Definition: stdint.h:124