Compare commits
2 Commits
2cb665cf19
...
c3316810f5
| Author | SHA1 | Date | |
|---|---|---|---|
| c3316810f5 | |||
| 8cb1584a00 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
*.lnk
|
*.lnk
|
||||||
build/
|
build/
|
||||||
.vscode/
|
.vscode/
|
||||||
CMakeLists.txt
|
|
||||||
|
|||||||
95
.vscode/settings.json
vendored
95
.vscode/settings.json
vendored
@ -1,95 +0,0 @@
|
|||||||
{
|
|
||||||
"files.associations": {
|
|
||||||
"iostream": "cpp",
|
|
||||||
"array": "cpp",
|
|
||||||
"atomic": "cpp",
|
|
||||||
"bit": "cpp",
|
|
||||||
"*.tcc": "cpp",
|
|
||||||
"cctype": "cpp",
|
|
||||||
"clocale": "cpp",
|
|
||||||
"cmath": "cpp",
|
|
||||||
"compare": "cpp",
|
|
||||||
"concepts": "cpp",
|
|
||||||
"cstdarg": "cpp",
|
|
||||||
"cstddef": "cpp",
|
|
||||||
"cstdint": "cpp",
|
|
||||||
"cstdio": "cpp",
|
|
||||||
"cstdlib": "cpp",
|
|
||||||
"cwchar": "cpp",
|
|
||||||
"cwctype": "cpp",
|
|
||||||
"deque": "cpp",
|
|
||||||
"string": "cpp",
|
|
||||||
"unordered_map": "cpp",
|
|
||||||
"vector": "cpp",
|
|
||||||
"exception": "cpp",
|
|
||||||
"algorithm": "cpp",
|
|
||||||
"functional": "cpp",
|
|
||||||
"iterator": "cpp",
|
|
||||||
"memory": "cpp",
|
|
||||||
"memory_resource": "cpp",
|
|
||||||
"numeric": "cpp",
|
|
||||||
"optional": "cpp",
|
|
||||||
"random": "cpp",
|
|
||||||
"string_view": "cpp",
|
|
||||||
"system_error": "cpp",
|
|
||||||
"tuple": "cpp",
|
|
||||||
"type_traits": "cpp",
|
|
||||||
"utility": "cpp",
|
|
||||||
"fstream": "cpp",
|
|
||||||
"initializer_list": "cpp",
|
|
||||||
"iosfwd": "cpp",
|
|
||||||
"istream": "cpp",
|
|
||||||
"limits": "cpp",
|
|
||||||
"new": "cpp",
|
|
||||||
"numbers": "cpp",
|
|
||||||
"ostream": "cpp",
|
|
||||||
"sstream": "cpp",
|
|
||||||
"stdexcept": "cpp",
|
|
||||||
"streambuf": "cpp",
|
|
||||||
"cinttypes": "cpp",
|
|
||||||
"typeinfo": "cpp",
|
|
||||||
"charconv": "cpp",
|
|
||||||
"cstring": "cpp",
|
|
||||||
"ctime": "cpp",
|
|
||||||
"format": "cpp",
|
|
||||||
"ios": "cpp",
|
|
||||||
"locale": "cpp",
|
|
||||||
"mutex": "cpp",
|
|
||||||
"queue": "cpp",
|
|
||||||
"ranges": "cpp",
|
|
||||||
"ratio": "cpp",
|
|
||||||
"span": "cpp",
|
|
||||||
"stop_token": "cpp",
|
|
||||||
"thread": "cpp",
|
|
||||||
"xfacet": "cpp",
|
|
||||||
"xiosbase": "cpp",
|
|
||||||
"xlocale": "cpp",
|
|
||||||
"xlocbuf": "cpp",
|
|
||||||
"xlocinfo": "cpp",
|
|
||||||
"xlocmes": "cpp",
|
|
||||||
"xlocmon": "cpp",
|
|
||||||
"xlocnum": "cpp",
|
|
||||||
"xloctime": "cpp",
|
|
||||||
"xmemory": "cpp",
|
|
||||||
"xstring": "cpp",
|
|
||||||
"xtr1common": "cpp",
|
|
||||||
"xutility": "cpp",
|
|
||||||
"chrono": "cpp",
|
|
||||||
"condition_variable": "cpp",
|
|
||||||
"iomanip": "cpp",
|
|
||||||
"semaphore": "cpp",
|
|
||||||
"variant": "cpp",
|
|
||||||
"forward_list": "cpp",
|
|
||||||
"map": "cpp",
|
|
||||||
"xstddef": "cpp",
|
|
||||||
"xtree": "cpp"
|
|
||||||
},
|
|
||||||
"cmake.generator": "Ninja",
|
|
||||||
"cmake.configureSettings": {
|
|
||||||
"CMAKE_MAKE_PROGRAM": "C:/Users/naifa/Documents/Projects/ninja/ninja.exe",
|
|
||||||
"CMAKE_C_COMPILER": "path_to_mingw/bin/gcc.exe",
|
|
||||||
"CMAKE_CXX_COMPILER": "path_to_mingw/bin/g++.exe",
|
|
||||||
"CMAKE_EXPORT_COMPILE_COMMANDS": true
|
|
||||||
},
|
|
||||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
|
|
||||||
}
|
|
||||||
28
.vscode/tasks.json
vendored
28
.vscode/tasks.json
vendored
@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"type": "cppbuild",
|
|
||||||
"label": "C/C++: g++.exe build active file",
|
|
||||||
"command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
|
|
||||||
"args": [
|
|
||||||
"-fdiagnostics-color=always",
|
|
||||||
"-g",
|
|
||||||
"${file}",
|
|
||||||
"-o",
|
|
||||||
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
|
||||||
],
|
|
||||||
"options": {
|
|
||||||
"cwd": "${fileDirname}"
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"detail": "Task generated by Debugger."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": "2.0.0"
|
|
||||||
}
|
|
||||||
@ -47,6 +47,14 @@ protected:
|
|||||||
std::string formatString(const std::string&, const char* shad=nullptr, const std::string& file="", int line=-1);
|
std::string formatString(const std::string&, const char* shad=nullptr, const std::string& file="", int line=-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ShaderUnit {
|
||||||
|
std::string rawSource;
|
||||||
|
std::string preprocSource;
|
||||||
|
std::map<std::string, std::string> defines;
|
||||||
|
std::map<uint8_t, ShaderUnit*> includes;
|
||||||
|
uint8_t vMajor=0, vMinor=0;
|
||||||
|
};
|
||||||
|
|
||||||
class ShaderPreprocessor {
|
class ShaderPreprocessor {
|
||||||
public:
|
public:
|
||||||
typedef ShaderPreprocessorError::Codes Codes;
|
typedef ShaderPreprocessorError::Codes Codes;
|
||||||
|
|||||||
65
shader.cpp
65
shader.cpp
@ -359,36 +359,61 @@ std::stringstream ShaderPreprocessor::process(std::stringstream& code) const {
|
|||||||
std::string line;
|
std::string line;
|
||||||
const std::vector<std::string> preprocKeys = {
|
const std::vector<std::string> preprocKeys = {
|
||||||
"#include",
|
"#include",
|
||||||
"//",
|
"#define",
|
||||||
"/*",
|
"#ifdef",
|
||||||
"*/"
|
"#ifndef",
|
||||||
|
"#endif"
|
||||||
};
|
};
|
||||||
const size_t keysListSize = preprocKeys.size();
|
|
||||||
enum Context : uint8_t {
|
enum Context : uint8_t {
|
||||||
Code,
|
Code,
|
||||||
LineComment,
|
BlockComment,
|
||||||
BlockComment
|
FalseBranch
|
||||||
};
|
};
|
||||||
Context currcontext = Code;
|
Context currcontext = Code;
|
||||||
bool blockcomment = false;
|
const size_t keysListSize = preprocKeys.size();
|
||||||
std::vector<size_t> keysIdx(keysListSize);
|
std::vector<size_t> keysIdx(keysListSize);
|
||||||
|
size_t linecom, blockstart, blockend;
|
||||||
// Use linked list to count char len of each line
|
// Use linked list to count char len of each line
|
||||||
while(std::getline(code, line)) {
|
while(std::getline(code, line)) {
|
||||||
if (!blockcomment) {
|
switch (currcontext) {
|
||||||
for (int i = 0; i < keysListSize; ++i) {
|
case Code:
|
||||||
keysIdx[i] = line.find(preprocKeys[i]);
|
if (linecom != std::string::npos) {
|
||||||
|
size_t preprocIdx;
|
||||||
|
for (int i = 0; i < keysListSize; ++i) {
|
||||||
|
preprocIdx = line.find(preprocKeys[i]);
|
||||||
|
keysIdx[i] = (preprocIdx < linecom) ? preprocIdx: std::string::npos;
|
||||||
|
}
|
||||||
|
} else if (blockstart != std::string::npos) {
|
||||||
|
size_t preprocIdx;
|
||||||
|
for (int i = 0; i < keysListSize; ++i) {
|
||||||
|
preprocIdx = line.find(preprocKeys[i]);
|
||||||
|
keysIdx[i] = (preprocIdx < blockstart) ? preprocIdx: std::string::npos;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < keysListSize; ++i) {
|
||||||
|
keysIdx[i] = line.find(preprocKeys[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (keysIdx[2] == std::string::npos) {
|
|
||||||
|
if (keysIdx)
|
||||||
|
break;
|
||||||
|
case BlockComment:
|
||||||
|
if (blockend == std::string::npos) {
|
||||||
|
ret << line;
|
||||||
|
} else {
|
||||||
|
size_t newpos = code.tellg() - line.size() + blockend;
|
||||||
|
line.resize(blockend);
|
||||||
|
ret << line;
|
||||||
|
code.seekg(newpos);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FalseBranch:
|
||||||
ret << line;
|
ret << line;
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
}
|
ret << line;
|
||||||
}
|
break;
|
||||||
if (keysIdx[0] != std::string::npos) {
|
|
||||||
if (keysIdx[1] != std::string::npos) {
|
|
||||||
if ( (keysIdx[0] > keysIdx[1]) ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user