RetroArch
metal_common.h
Go to the documentation of this file.
1 //
2 // metal_common.h
3 // RetroArch_Metal
4 //
5 // Created by Stuart Carnie on 5/14/18.
6 //
7 
8 #ifndef METAL_COMMON_H__
9 #define METAL_COMMON_H__
10 
11 #import <Metal/Metal.h>
12 #import <MetalKit/MetalKit.h>
13 #import "metal/metal_common.h"
14 
15 #include <retro_common_api.h>
16 #include "../drivers_shader/slang_process.h"
17 
18 #ifdef HAVE_CONFIG_H
19 #include "../../config.h"
20 #endif
21 
23 
24 extern MTLPixelFormat glslang_format_to_metal(glslang_format fmt);
25 extern MTLPixelFormat SelectOptimalPixelFormat(MTLPixelFormat fmt);
26 
27 #pragma mark - Classes
28 
29 @interface FrameView : NSObject
30 
31 @property (nonatomic, readonly) RPixelFormat format;
32 @property (nonatomic, readonly) RTextureFilter filter;
33 @property (nonatomic, readwrite) BOOL visible;
34 @property (nonatomic, readwrite) CGRect frame;
35 @property (nonatomic, readwrite) CGSize size;
36 @property (nonatomic, readonly) ViewDrawState drawState;
37 @property (nonatomic, readonly) struct video_shader *shader;
38 @property (nonatomic, readwrite) uint64_t frameCount;
39 
40 - (void)setFilteringIndex:(int)index smooth:(bool)smooth;
41 - (BOOL)setShaderFromPath:(NSString *)path;
42 - (void)updateFrame:(void const *)src pitch:(NSUInteger)pitch;
43 - (bool)readViewport:(uint8_t *)buffer isIdle:(bool)isIdle;
44 
45 @end
46 
47 
48 @interface MetalMenu : NSObject
49 
50 @property (nonatomic, readonly) bool hasFrame;
51 @property (nonatomic, readwrite) bool enabled;
52 @property (nonatomic, readwrite) float alpha;
53 
54 - (void)updateFrame:(void const *)source;
55 
56 - (void)updateWidth:(int)width
57  height:(int)height
58  format:(RPixelFormat)format
59  filter:(RTextureFilter)filter;
60 @end
61 
62 
63 @interface Overlay : NSObject
64 @property (nonatomic, readwrite) bool enabled;
65 @property (nonatomic, readwrite) bool fullscreen;
66 
67 - (bool)loadImages:(const struct texture_image *)images count:(NSUInteger)count;
68 - (void)updateVertexX:(float)x y:(float)y w:(float)w h:(float)h index:(NSUInteger)index;
69 - (void)updateTextureCoordsX:(float)x y:(float)y w:(float)w h:(float)h index:(NSUInteger)index;
70 - (void)updateAlpha:(float)alpha index:(NSUInteger)index;
71 @end
72 
73 @interface MetalDriver : NSObject<MTKViewDelegate>
74 
75 @property (nonatomic, readonly) video_viewport_t *viewport;
76 @property (nonatomic, readwrite) bool keepAspect;
77 @property (nonatomic, readonly) MetalMenu *menu;
78 @property (nonatomic, readonly) FrameView *frameView;
79 @property (nonatomic, readonly) MenuDisplay *display;
80 @property (nonatomic, readonly) Overlay *overlay;
81 @property (nonatomic, readonly) Context *context;
82 @property (nonatomic, readonly) Uniforms *viewportMVP;
83 
84 - (instancetype)initWithVideo:(const video_info_t *)video
85  input:(const input_driver_t **)input
86  inputData:(void **)inputData;
87 
88 - (void)setVideo:(const video_info_t *)video;
89 - (bool)renderFrame:(const void *)data
90  width:(unsigned)width
91  height:(unsigned)height
92  frameCount:(uint64_t)frameCount
93  pitch:(unsigned)pitch
94  msg:(const char *)msg
95  info:(video_frame_info_t *)video_info;
96 
98 - (void)setNeedsResize;
99 - (void)setViewportWidth:(unsigned)width height:(unsigned)height forceFull:(BOOL)forceFull allowRotate:(BOOL)allowRotate;
100 - (void)setRotation:(unsigned)rotation;
101 
102 @end
103 
105 
106 #endif
Definition: MenuDisplay.h:9
GLuint shader
Definition: glext.h:6670
RETRO_BEGIN_DECLS MTLPixelFormat glslang_format_to_metal(glslang_format fmt)
Definition: metal_common.m:1461
ViewDrawState drawState
Definition: metal_common.h:36
#define const
Definition: zconf.h:217
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
Definition: ffmpeg_core.c:151
GLsizeiptr size
Definition: glext.h:6559
uint64_t frameCount
Definition: metal_common.h:38
static const bool fullscreen
Definition: config.def.h:108
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
glslang_format
Definition: glslang_util.h:22
typedef bool(RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index
Definition: video_shader_parse.h:143
Definition: video_driver.h:405
Definition: input_driver.h:132
Definition: metal_common.h:29
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:8417
MTLPixelFormat SelectOptimalPixelFormat(MTLPixelFormat fmt)
Definition: metal_common.m:1510
Definition: video_driver.h:332
BOOL visible
Definition: metal_common.h:33
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
GLfloat GLfloat GLfloat alpha
Definition: glext.h:6290
unsigned int BOOL
Definition: gctypes.h:51
Definition: video_driver.h:686
Definition: metal_common.h:63
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glext.h:6293
Definition: input_overlay.h:98
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7672
Definition: image.h:42
Definition: ShaderTypes.h:70
Definition: metal_common.h:48
unsigned __int64 uint64_t
Definition: stdint.h:136
Context contains the render state used by various components.
Definition: Context.h:26
unsigned char uint8_t
Definition: stdint.h:124
Definition: metal_common.h:73