RetroArch
ShaderTypes.h
Go to the documentation of this file.
1 //
2 // ShaderTypes.h
3 // MetalRenderer
4 //
5 // Created by Stuart Carnie on 5/31/18.
6 // Copyright © 2018 Stuart Carnie. All rights reserved.
7 //
8 
9 //
10 // Header containing types and enum constants shared between Metal shaders and Swift/ObjC source
11 //
12 #ifndef ShaderTypes_h
13 #define ShaderTypes_h
14 
15 #ifdef __METAL_VERSION__
16 #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
17 #define NSInteger metal::int32_t
18 
19 #define METAL_ATTRIBUTE(x) [[attribute(x)]]
20 #define METAL_POSITION [[position]]
21 #else
22 #import <Foundation/Foundation.h>
23 #define METAL_ATTRIBUTE(x)
24 #define METAL_POSITION
25 #endif
26 
27 #include <simd/simd.h>
28 
29 typedef NS_ENUM(NSInteger, BufferIndex)
30 {
31  BufferIndexPositions = 0,
32  BufferIndexUniforms = 1
33 };
34 
35 typedef NS_ENUM(NSInteger, VertexAttribute)
36 {
37  VertexAttributePosition = 0,
38  VertexAttributeTexcoord = 1,
39  VertexAttributeColor = 2,
40 };
41 
42 typedef NS_ENUM(NSInteger, TextureIndex)
43 {
44  TextureIndexColor = 0,
45 };
46 
47 typedef NS_ENUM(NSInteger, SamplerIndex)
48 {
49  SamplerIndexDraw = 0,
50 };
51 
52 typedef struct
53 {
54  vector_float3 position METAL_ATTRIBUTE(VertexAttributePosition);
55  vector_float2 texCoord METAL_ATTRIBUTE(VertexAttributeTexcoord);
56 } Vertex;
57 
58 typedef struct
59 {
60  vector_float4 position;
61  vector_float2 texCoord;
62 } VertexSlang;
63 
64 typedef struct
65 {
66  vector_float4 position METAL_POSITION;
67  vector_float2 texCoord;
68 } ColorInOut;
69 
70 typedef struct
71 {
72  matrix_float4x4 projectionMatrix;
73  vector_float2 outputSize;
74  float time;
75 } Uniforms;
76 
77 typedef struct
78 {
79  vector_float2 position METAL_ATTRIBUTE(VertexAttributePosition);
80  vector_float2 texCoord METAL_ATTRIBUTE(VertexAttributeTexcoord);
81  vector_float4 color METAL_ATTRIBUTE(VertexAttributeColor);
82 } SpriteVertex;
83 
84 typedef struct
85 {
86  vector_float4 position METAL_POSITION;
87  vector_float2 texCoord;
88  vector_float4 color;
90 
91 #endif /* ShaderTypes_h */
92 
matrix_float4x4 projectionMatrix
Definition: ShaderTypes.h:72
Definition: ShaderTypes.h:84
Definition: ShaderTypes.h:64
vector_float4 position METAL_POSITION
Definition: ShaderTypes.h:86
Definition: ShaderTypes.h:77
Definition: ShaderTypes.h:58
vector_float4 position METAL_POSITION
Definition: ShaderTypes.h:66
typedef NS_ENUM(NSInteger, BufferIndex)
Definition: ShaderTypes.h:29
#define METAL_ATTRIBUTE(x)
Definition: ShaderTypes.h:23
struct Vertex Vertex
vector_float4 position
Definition: ShaderTypes.h:60
vector_float2 texCoord
Definition: ShaderTypes.h:61
vector_float2 outputSize
Definition: ShaderTypes.h:73
GLuint color
Definition: glext.h:6883
Definition: ShaderTypes.h:70
vector_float2 texCoord
Definition: ShaderTypes.h:67
float time
Definition: ShaderTypes.h:74
vector_float2 texCoord
Definition: ShaderTypes.h:87
vector_float4 color
Definition: ShaderTypes.h:88