This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathsgs-file.h
114 lines (96 loc) · 3.79 KB
/
sgs-file.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//
// Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved.
// License: https://github.com/septag/glslcc#license-bsd-2-clause
//
//
// File version: 1.1.0
// File endianness: little
//
// v1.1.0 CHANGES
// - added num_storages_images, num_storage_buffers (CS specific) variables to sgs_chunk_refl
//
#pragma once
#include "sx/allocator.h"
#pragma pack(push, 1)
#define SGS_CHUNK sx_makefourcc('S', 'G', 'S', ' ')
#define SGS_CHUNK_STAG sx_makefourcc('S', 'T', 'A', 'G')
#define SGS_CHUNK_REFL sx_makefourcc('R', 'E', 'F', 'L')
#define SGS_CHUNK_CODE sx_makefourcc('C', 'O', 'D', 'E')
#define SGS_CHUNK_DATA sx_makefourcc('D', 'A', 'T', 'A')
#define SGS_LANG_GLES sx_makefourcc('G', 'L', 'E', 'S')
#define SGS_LANG_HLSL sx_makefourcc('H', 'L', 'S', 'L')
#define SGS_LANG_GLSL sx_makefourcc('G', 'L', 'S', 'L')
#define SGS_LANG_MSL sx_makefourcc('M', 'S', 'L', ' ')
#define SGS_VERTEXFORMAT_FLOAT sx_makefourcc('F', 'L', 'T', '1')
#define SGS_VERTEXFORMAT_FLOAT2 sx_makefourcc('F', 'L', 'T', '2')
#define SGS_VERTEXFORMAT_FLOAT3 sx_makefourcc('F', 'L', 'T', '3')
#define SGS_VERTEXFORMAT_FLOAT4 sx_makefourcc('F', 'L', 'T', '4')
#define SGS_VERTEXFORMAT_INT sx_makefourcc('I', 'N', 'T', '1')
#define SGS_VERTEXFORMAT_INT2 sx_makefourcc('I', 'N', 'T', '2')
#define SGS_VERTEXFORMAT_INT3 sx_makefourcc('I', 'N', 'T', '3')
#define SGS_VERTEXFORMAT_INT4 sx_makefourcc('I', 'N', 'T', '4')
#define SGS_STAGE_VERTEX sx_makefourcc('V', 'E', 'R', 'T')
#define SGS_STAGE_FRAGMENT sx_makefourcc('F', 'R', 'A', 'G')
#define SGS_STAGE_COMPUTE sx_makefourcc('C', 'O', 'M', 'P')
#define SGS_IMAGEDIM_1D sx_makefourcc('1', 'D', ' ', ' ')
#define SGS_IMAGEDIM_2D sx_makefourcc('2', 'D', ' ', ' ')
#define SGS_IMAGEDIM_3D sx_makefourcc('3', 'D', ' ', ' ')
#define SGS_IMAGEDIM_CUBE sx_makefourcc('C', 'U', 'B', 'E')
#define SGS_IMAGEDIM_RECT sx_makefourcc('R', 'E', 'C', 'T')
#define SGS_IMAGEDIM_BUFFER sx_makefourcc('B', 'U', 'F', 'F')
#define SGS_IMAGEDIM_SUBPASS sx_makefourcc('S', 'U', 'B', 'P')
// SGS chunk
struct sgs_chunk {
uint32_t lang; // sgs_shader_lang
uint32_t profile_ver; //
};
// REFL
struct sgs_chunk_refl {
char name[32];
uint32_t num_inputs;
uint32_t num_textures;
uint32_t num_uniform_buffers;
uint32_t num_storage_images;
uint32_t num_storage_buffers;
uint16_t flatten_ubos;
uint16_t debug_info;
// inputs: sgs_refl_input[num_inputs]
// uniform-buffers: sgs_refl_uniformbuffer[num_uniform_buffers]
// textures: sgs_refl_texture[num_textures]
// storage_images: sgs_refl_texture[num_storage_images]
// storage_buffers: sgs_refl_buffer[num_storage_buffers]
};
struct sgs_refl_input {
char name[32];
int32_t loc;
char semantic[32];
uint32_t semantic_index;
uint32_t format;
};
struct sgs_refl_texture {
char name[32];
int32_t binding;
uint32_t image_dim;
uint8_t multisample;
uint8_t is_array;
};
struct sgs_refl_buffer {
char name[32];
int32_t binding;
uint32_t size_bytes;
uint32_t array_stride;
};
struct sgs_refl_uniformbuffer {
char name[32];
int32_t binding;
uint32_t size_bytes;
uint16_t array_size;
};
#pragma pack(pop)
struct sgs_file;
sgs_file* sgs_create_file(const sx_alloc* alloc, const char* filepath, uint32_t lang, uint32_t profile_ver);
void sgs_destroy_file(sgs_file* f);
void sgs_add_stage_code(sgs_file* f, uint32_t stage, const char* code);
void sgs_add_stage_code_bin(sgs_file* f, uint32_t stage, const void* bytecode, int len);
void sgs_add_stage_reflect(sgs_file* f, uint32_t stage, const void* reflect, int reflect_size);
bool sgs_commit(sgs_file* f);