Compare commits
No commits in common. "c3316810f5fb0ec164850905e04ea2368d12ca6b" and "2cb665cf192dfd991e17fa5f4cb1d8496f139bd8" have entirely different histories.
c3316810f5
...
2cb665cf19
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
*.lnk
|
*.lnk
|
||||||
build/
|
build/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
CMakeLists.txt
|
||||||
|
|||||||
95
.vscode/settings.json
vendored
Normal file
95
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"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
Normal file
28
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"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,14 +47,6 @@ 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;
|
||||||
|
|||||||
57
shader.cpp
57
shader.cpp
@ -359,61 +359,36 @@ 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,
|
||||||
BlockComment,
|
LineComment,
|
||||||
FalseBranch
|
BlockComment
|
||||||
};
|
};
|
||||||
Context currcontext = Code;
|
Context currcontext = Code;
|
||||||
const size_t keysListSize = preprocKeys.size();
|
bool blockcomment = false;
|
||||||
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)) {
|
||||||
switch (currcontext) {
|
if (!blockcomment) {
|
||||||
case Code:
|
|
||||||
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) {
|
for (int i = 0; i < keysListSize; ++i) {
|
||||||
keysIdx[i] = line.find(preprocKeys[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;
|
ret << line;
|
||||||
} else {
|
} else {
|
||||||
size_t newpos = code.tellg() - line.size() + blockend;
|
|
||||||
line.resize(blockend);
|
}
|
||||||
ret << line;
|
}
|
||||||
code.seekg(newpos);
|
if (keysIdx[0] != std::string::npos) {
|
||||||
continue;
|
if (keysIdx[1] != std::string::npos) {
|
||||||
|
if ( (keysIdx[0] > keysIdx[1]) ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case FalseBranch:
|
|
||||||
ret << line;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret << line;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user