mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 12:48:32 +09:00
[Chore] (MG_Util/ShaderSourceProcessor): trim unnecessary part of shader source
This commit is contained in:
@@ -4,6 +4,24 @@ namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
namespace ShaderTranspiler {
|
||||
void PreprocessShaderSource(ShaderStage stage, String& source) {
|
||||
// remove #line directives
|
||||
SizeT linedirPos = source.find("#line");
|
||||
while (linedirPos != std::string::npos) {
|
||||
SizeT newlinePos = source.find('\n', linedirPos);
|
||||
source = source.replace(linedirPos, newlinePos - linedirPos, "");
|
||||
linedirPos = source.find("#line", linedirPos);
|
||||
}
|
||||
|
||||
// remove multi-line comment
|
||||
size_t commentStartPos = source.find("/*");
|
||||
while (commentStartPos != std::string::npos) {
|
||||
size_t commentEndPos = source.find("*/", commentStartPos);
|
||||
// + length of "*/"
|
||||
source = source.replace(commentStartPos, commentEndPos - commentStartPos + 2, "");
|
||||
commentStartPos = source.find("/*", commentStartPos);
|
||||
}
|
||||
|
||||
// force #version
|
||||
ShaderProfile profile = ShaderProfile::Core;
|
||||
SizeT versionPos = source.find("#version");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user