11// The Axmol Shader Compiler spec, define macros and structs, can be include anywhere
2- // match with axslcc-3.0 .0+
2+ // match with axslcc-3.1 .0+
33
44#pragma once
55
66#include < stdint.h>
77
8- namespace axslc {
8+ namespace axslc
9+ {
910
1011#define sc_makefourcc (_a, _b, _c, _d ) \
1112 (((uint32_t )(_a) | ((uint32_t )(_b) << 8 ) | ((uint32_t )(_c) << 16 ) | ((uint32_t )(_d) << 24 )))
1213
1314#pragma pack(push, 1)
1415
15- #define SC_CHUNK sc_makefourcc (' A' , ' X' , ' S' , ' C' )
16- #define SC_CHUNK_STAG sc_makefourcc (' S' , ' T' , ' A' , ' G' )
17- #define SC_CHUNK_REFL sc_makefourcc (' R' , ' E' , ' F' , ' L' )
18- #define SC_CHUNK_CODE sc_makefourcc (' C' , ' O' , ' D' , ' E' )
19- #define SC_CHUNK_DATA sc_makefourcc (' D' , ' A' , ' T' , ' A' )
16+ #define SC_CHUNK sc_makefourcc (' A' , ' X' , ' S' , ' C' )
17+ #define SC_CHUNK_STAG sc_makefourcc (' S' , ' T' , ' A' , ' G' )
18+ #define SC_CHUNK_REFL sc_makefourcc (' R' , ' E' , ' F' , ' L' )
19+ #define SC_CHUNK_CODE sc_makefourcc (' C' , ' O' , ' D' , ' E' )
20+ #define SC_CHUNK_DATA sc_makefourcc (' D' , ' A' , ' T' , ' A' )
2021
21- #define SC_LANG_GLES sc_makefourcc (' G' , ' L' , ' E' , ' S' )
22- #define SC_LANG_HLSL sc_makefourcc (' H' , ' L' , ' S' , ' L' )
23- #define SC_LANG_GLSL sc_makefourcc (' G' , ' L' , ' S' , ' L' )
24- #define SC_LANG_MSL sc_makefourcc (' M' , ' S' , ' L' , ' ' )
25- #define SC_LANG_SPIRV sc_makefourcc (' S' , ' P' , ' I' , ' R' )
22+ #define SC_LANG_GLES sc_makefourcc (' G' , ' L' , ' E' , ' S' )
23+ #define SC_LANG_HLSL sc_makefourcc (' H' , ' L' , ' S' , ' L' )
24+ #define SC_LANG_GLSL sc_makefourcc (' G' , ' L' , ' S' , ' L' )
25+ #define SC_LANG_MSL sc_makefourcc (' M' , ' S' , ' L' , ' ' )
26+ #define SC_LANG_SPIRV sc_makefourcc (' S' , ' P' , ' I' , ' R' )
2627
27- #define SC_VERTEXFORMAT_FLOAT sc_makefourcc (' F' , ' L' , ' T' , ' 1' )
28+ #define SC_VERTEXFORMAT_FLOAT sc_makefourcc (' F' , ' L' , ' T' , ' 1' )
2829#define SC_VERTEXFORMAT_FLOAT2 sc_makefourcc (' F' , ' L' , ' T' , ' 2' )
2930#define SC_VERTEXFORMAT_FLOAT3 sc_makefourcc (' F' , ' L' , ' T' , ' 3' )
3031#define SC_VERTEXFORMAT_FLOAT4 sc_makefourcc (' F' , ' L' , ' T' , ' 4' )
31- #define SC_VERTEXFORMAT_INT sc_makefourcc (' I' , ' N' , ' T' , ' 1' )
32- #define SC_VERTEXFORMAT_INT2 sc_makefourcc (' I' , ' N' , ' T' , ' 2' )
33- #define SC_VERTEXFORMAT_INT3 sc_makefourcc (' I' , ' N' , ' T' , ' 3' )
34- #define SC_VERTEXFORMAT_INT4 sc_makefourcc (' I' , ' N' , ' T' , ' 4' )
35- #define SC_VERTEXFORMAT_MAT3 sc_makefourcc (' M' , ' A' , ' T' , ' 3' )
36- #define SC_VERTEXFORMAT_MAT4 sc_makefourcc (' M' , ' A' , ' T' , ' 4' )
37-
38- #define SC_STAGE_VERTEX sc_makefourcc (' V' , ' E' , ' R' , ' T' )
39- #define SC_STAGE_FRAGMENT sc_makefourcc (' F' , ' R' , ' A' , ' G' )
40- #define SC_STAGE_COMPUTE sc_makefourcc (' C' , ' O' , ' M' , ' P' )
41-
42- #define SC_IMAGEDIM_1D sc_makefourcc (' 1' , ' D' , ' ' , ' ' )
43- #define SC_IMAGEDIM_2D sc_makefourcc (' 2' , ' D' , ' ' , ' ' )
44- #define SC_IMAGEDIM_3D sc_makefourcc (' 3' , ' D' , ' ' , ' ' )
45- #define SC_IMAGEDIM_CUBE sc_makefourcc (' C' , ' U' , ' B' , ' E' )
46- #define SC_IMAGEDIM_RECT sc_makefourcc (' R' , ' E' , ' C' , ' T' )
47- #define SC_IMAGEDIM_BUFFER sc_makefourcc (' B' , ' U' , ' F' , ' F' )
48- #define SC_IMAGEDIM_SUBPASS sc_makefourcc (' S' , ' U' , ' B' , ' P' )
49-
50- enum Dim {
51- Dim1D = 0 ,
52- Dim2D = 1 ,
53- Dim3D = 2 ,
54- DimCube = 3 ,
55- DimRect = 4 ,
56- DimBuffer = 5 ,
32+ #define SC_VERTEXFORMAT_INT sc_makefourcc (' I' , ' N' , ' T' , ' 1' )
33+ #define SC_VERTEXFORMAT_INT2 sc_makefourcc (' I' , ' N' , ' T' , ' 2' )
34+ #define SC_VERTEXFORMAT_INT3 sc_makefourcc (' I' , ' N' , ' T' , ' 3' )
35+ #define SC_VERTEXFORMAT_INT4 sc_makefourcc (' I' , ' N' , ' T' , ' 4' )
36+ #define SC_VERTEXFORMAT_MAT3 sc_makefourcc (' M' , ' A' , ' T' , ' 3' )
37+ #define SC_VERTEXFORMAT_MAT4 sc_makefourcc (' M' , ' A' , ' T' , ' 4' )
38+
39+ #define SC_STAGE_VERTEX sc_makefourcc (' V' , ' E' , ' R' , ' T' )
40+ #define SC_STAGE_FRAGMENT sc_makefourcc (' F' , ' R' , ' A' , ' G' )
41+ #define SC_STAGE_COMPUTE sc_makefourcc (' C' , ' O' , ' M' , ' P' )
42+
43+ #define SC_IMAGEDIM_1D sc_makefourcc (' 1' , ' D' , ' ' , ' ' )
44+ #define SC_IMAGEDIM_2D sc_makefourcc (' 2' , ' D' , ' ' , ' ' )
45+ #define SC_IMAGEDIM_3D sc_makefourcc (' 3' , ' D' , ' ' , ' ' )
46+ #define SC_IMAGEDIM_CUBE sc_makefourcc (' C' , ' U' , ' B' , ' E' )
47+ #define SC_IMAGEDIM_RECT sc_makefourcc (' R' , ' E' , ' C' , ' T' )
48+ #define SC_IMAGEDIM_BUFFER sc_makefourcc (' B' , ' U' , ' F' , ' F' )
49+ #define SC_IMAGEDIM_SUBPASS sc_makefourcc (' S' , ' U' , ' B' , ' P' )
50+
51+ enum Dim
52+ {
53+ Dim1D = 0 ,
54+ Dim2D = 1 ,
55+ Dim3D = 2 ,
56+ DimCube = 3 ,
57+ DimRect = 4 ,
58+ DimBuffer = 5 ,
5759 DimSubpassData = 6
5860};
5961
6062// sc chunk aka file header
61- struct sc_chunk {
62- uint16_t major; // SC_VERSION_MAJOR
63- uint16_t minor; // SC_VERSION_MINOR
64- uint32_t lang; // shader lang
65- uint32_t profile_ver; // target profile version
63+ struct sc_chunk
64+ {
65+ uint16_t major; // SC_VERSION_MAJOR
66+ uint16_t minor; // SC_VERSION_MINOR
67+ uint32_t lang; // shader lang
68+ uint32_t profile_ver; // target profile version
6669};
6770
6871// REFL
69- struct sc_chunk_refl {
72+ struct sc_chunk_refl
73+ {
7074 char name[32 ];
7175 uint32_t num_inputs;
7276 uint32_t num_textures;
@@ -83,7 +87,8 @@ struct sc_chunk_refl {
8387 // storage_buffers: sc_refl_buffer[num_storage_buffers]
8488};
8589
86- struct sc_refl_input {
90+ struct sc_refl_input
91+ {
8792 char name[32 ];
8893 int32_t loc;
8994 char semantic[32 ];
@@ -92,33 +97,37 @@ struct sc_refl_input {
9297};
9398
9499// @since 3.0.0, modified
95- struct sc_refl_texture {
100+ struct sc_refl_texture
101+ {
96102 char name[32 ];
97103 int32_t binding;
98- uint8_t image_dim; // @see enum Dim: Dim1D, Dim2D, Dim3D, DimCube ...
99- uint8_t multisample : 1 ; // whether sampler2DMS
100- uint8_t arrayed : 1 ; // whether samplerXXArray
101- uint8_t reserved : 6 ; // reserved field
102- uint8_t count; // count: 0~255
103- uint8_t sampler_slot; // sampler_slot: 0~255
104+ uint8_t image_dim; // @see enum Dim: Dim1D, Dim2D, Dim3D, DimCube ...
105+ uint8_t multisample : 1 ; // whether sampler2DMS
106+ uint8_t arrayed : 1 ; // whether samplerXXArray
107+ uint8_t reserved : 6 ; // reserved field
108+ uint8_t count; // count: 0~255
109+ uint8_t sampler_slot; // sampler_slot: 0~255
104110};
105111
106- struct sc_refl_buffer {
112+ struct sc_refl_buffer
113+ {
107114 char name[32 ];
108115 int32_t binding;
109116 uint32_t size_bytes;
110117 uint32_t array_stride;
111118};
112119
113- typedef struct sc_refl_uniformbuffer {
120+ typedef struct sc_refl_uniformbuffer
121+ {
114122 char name[32 ];
115123 int32_t binding;
116124 uint32_t size_bytes;
117125 uint16_t array_size;
118126 uint16_t num_members;
119127} sc_refl_ub;
120128
121- typedef struct sc_refl_uniformbuffer_member {
129+ typedef struct sc_refl_uniformbuffer_member
130+ {
122131 char name[32 ];
123132 int32_t offset;
124133 uint32_t format;
@@ -127,4 +136,4 @@ typedef struct sc_refl_uniformbuffer_member {
127136} sc_refl_ub_member;
128137#pragma pack(pop)
129138
130- } // namespace axslc
139+ } // namespace axslc
0 commit comments