RetroArch
RendererCommon.h
Go to the documentation of this file.
1 //
2 // RendererCommon.h
3 // MetalRenderer
4 //
5 // Created by Stuart Carnie on 6/3/18.
6 // Copyright © 2018 Stuart Carnie. All rights reserved.
7 //
8 
9 #ifndef RendererCommon_h
10 #define RendererCommon_h
11 
12 #import <Foundation/Foundation.h>
13 #import "ShaderTypes.h"
14 
15 // TODO(sgc): implement triple buffering
17 #define MAX_INFLIGHT 1
18 #define CHAIN_LENGTH 3
19 
20 /* macOS requires constants in a buffer to have a 256 byte alignment. */
21 #ifdef TARGET_OS_MAC
22 #define kMetalBufferAlignment 256
23 #else
24 #define kMetalBufferAlignment 4
25 #endif
26 
27 #define MTL_ALIGN_BUFFER(size) ((size + kMetalBufferAlignment - 1) & (~(kMetalBufferAlignment - 1)))
28 
29 #pragma mark - Pixel Formats
30 
31 typedef NS_ENUM(NSUInteger, RPixelFormat)
32 {
33 
34  RPixelFormatInvalid,
35 
36  /* 16-bit formats */
37  RPixelFormatBGRA4Unorm,
38  RPixelFormatB5G6R5Unorm,
39 
40  RPixelFormatBGRA8Unorm,
41  RPixelFormatBGRX8Unorm, // RetroArch XRGB
42 
43  RPixelFormatCount,
44 };
45 
46 extern NSUInteger RPixelFormatToBPP(RPixelFormat format);
47 extern NSString *NSStringFromRPixelFormat(RPixelFormat format);
48 
49 typedef NS_ENUM(NSUInteger, RTextureFilter)
50 {
51  RTextureFilterNearest,
52  RTextureFilterLinear,
53 
54  RTextureFilterCount,
55 };
56 
57 extern matrix_float4x4 matrix_proj_ortho(float left, float right, float top, float bottom);
58 extern matrix_float4x4 matrix_rotate_z(float rot);
59 extern matrix_float4x4 make_matrix_float4x4(const float *v);
60 
61 #endif /* RendererCommon_h */
matrix_float4x4 matrix_rotate_z(float rot)
Definition: RendererCommon.m:90
GLint GLint bottom
Definition: glext.h:8393
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:11766
GLdouble GLdouble right
Definition: glext.h:11766
NSUInteger RPixelFormatToBPP(RPixelFormat format)
Definition: RendererCommon.m:12
matrix_float4x4 matrix_proj_ortho(float left, float right, float top, float bottom)
Definition: RendererCommon.m:69
NSString * NSStringFromRPixelFormat(RPixelFormat format)
Definition: RendererCommon.m:32
const GLdouble * v
Definition: glext.h:6391
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glext.h:6293
GLint left
Definition: glext.h:8393
matrix_float4x4 make_matrix_float4x4(const float *v)
Definition: RendererCommon.m:55
typedef NS_ENUM(NSUInteger, RPixelFormat)
Definition: RendererCommon.h:31