Specify shaders directly as arrays of bytes in source code.

This allows us to provide all functionality in executable file without providing additional data files.
Added bin2hex utility that does [spirv binary->cpp code] conversion.
Idea is based on vkQuake implementation.
This commit is contained in:
Artem Kharytoniuk
2017-04-05 14:26:15 +03:00
parent a02cb3ee10
commit 76d4deb58a
29 changed files with 609 additions and 95 deletions

40
tools/bin2hex.cpp Normal file
View File

@@ -0,0 +1,40 @@
#include <cstdint>
#include <cstdio>
int main(int argc, char* argv[]) {
if (argc != 3) {
printf("Usage: bin2hex <input_file> <output_array_name>\n");
return - 1;
}
FILE* f = fopen(argv[1], "rb");
if (!f) {
printf("Could not open file for reading: %s\n", argv[1]);
return -1;
}
const int line_length = 16;
long long size = 0;
printf("unsigned char %s[] = {\n\t", argv[2]);
int byte = fgetc(f);
while (byte != EOF) {
printf("0x%.2X", byte);
byte = fgetc(f);
if (byte != EOF) printf(", ");
size++;
if (size % line_length == 0) printf("\n\t");
}
printf("\n};\n");
printf("long long %s_size = %lld;", argv[2], size);
if (!feof(f)) {
printf("Could not read entire file: %s", argv[1]);
}
fclose(f);
return 0;
}