summaryrefslogtreecommitdiff
path: root/sc/sc.cpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-12-15 10:33:09 +1100
committerquou <quou@disroot.org>2024-12-15 10:33:09 +1100
commitb9550388afdf53b1efc858cd568181217b060897 (patch)
treec55539f471c96cce783ce0ac184e49acff1d252f /sc/sc.cpp
parent44e48ddc2785b037abd202a8d38b2ef2e8c36600 (diff)
use the Shader_Type in the shader compiler instead of another stage enum
Diffstat (limited to 'sc/sc.cpp')
-rw-r--r--sc/sc.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/sc/sc.cpp b/sc/sc.cpp
index ae4ae02..a385619 100644
--- a/sc/sc.cpp
+++ b/sc/sc.cpp
@@ -115,11 +115,6 @@ int type_from_string(const char* s) {
}
struct Desc {
- enum {
- VERTEX,
- FRAGMENT,
- stage_count
- };
struct Variable {
int type;
std::string name;
@@ -128,7 +123,7 @@ struct Desc {
int type;
std::vector<Variable> attrs;
std::vector<Variable> trgts;
- std::string entrypoints[stage_count];
+ std::string entrypoints[shader_type_count];
void read_var(Variable& d, cfg_Object* desc) {
const char* stype = find_string_default(desc, "type", 0);
if (!stype) {
@@ -159,13 +154,13 @@ struct Desc {
print_err("Graphics programs must define a vertex shader entry point.\n");
pbreak(301);
}
- entrypoints[VERTEX] = sv;
+ entrypoints[shader_type_vertex] = sv;
const char* sf = find_string_default(desc, "fragment", 0);
if (!sf) {
print_err("Graphics programs must define a fragment shader entry point.\n");
pbreak(302);
}
- entrypoints[FRAGMENT] = sf;
+ entrypoints[shader_type_fragment] = sf;
desc = desc->next;
while (desc) {
Variable v;
@@ -277,12 +272,12 @@ void configure(
std::string& ps
) {
switch (stage) {
- case Desc::VERTEX:
+ case shader_type_vertex:
dfn = "VERTEX_SHADER";
l = EShLangVertex;
ps += d.build_vs();
break;
- case Desc::FRAGMENT:
+ case shader_type_fragment:
dfn = "FRAGMENT_SHADER";
l = EShLangFragment;
ps += d.build_fs();
@@ -298,7 +293,7 @@ void compile_shaders(
const char* define;
EShLanguage lang;
int i;
- for (i = 0; i < Desc::stage_count; i++) {
+ for (i = 0; i < shader_type_count; i++) {
if (!d.entrypoints[i].empty()) {
std::string ps;
configure(d, i, define, lang, ps);
@@ -343,7 +338,7 @@ void write_csh(
fwrite(&t.type, 4, 1, f);
hsize += 32;
}
- for (i = 0, coff = 0; i < Desc::stage_count; i++) {
+ for (i = 0, coff = 0; i < shader_type_count; i++) {
int o = 0;
if (d.entrypoints[i].empty())
fwrite(&o, 4, 1, f);
@@ -353,7 +348,7 @@ void write_csh(
coff += stages[i].size() * sizeof(uint32_t);
}
}
- for (i = 0; i < Desc::stage_count; i++)
+ for (i = 0; i < shader_type_count; i++)
if (!d.entrypoints[i].empty()) {
auto& stage = stages[i];
fwrite(&stage[0], sizeof(uint32_t), stage.size(), f);
@@ -364,7 +359,7 @@ int main(int argc, const char** argv) {
char* src;
size_t src_size;
std::string desc_src;
- std::vector<uint32_t> spv[Desc::stage_count];
+ std::vector<uint32_t> spv[shader_type_count];
cfg_Object* cdesc;
void* dp_mem;
Desc desc;