From b215d811a1981e20f35bb31df4e6cd2a74146193 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 4 Nov 2021 10:00:00 +0800 Subject: *misc --- Runtime/Graphics/ShaderCompiler.cpp | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'Runtime/Graphics/ShaderCompiler.cpp') diff --git a/Runtime/Graphics/ShaderCompiler.cpp b/Runtime/Graphics/ShaderCompiler.cpp index ddd21a6..20b19f5 100644 --- a/Runtime/Graphics/ShaderCompiler.cpp +++ b/Runtime/Graphics/ShaderCompiler.cpp @@ -13,18 +13,18 @@ static const char* CMD_END = "CMD_END"; std::string s_CompileError = ""; -// GLS分为四部分 +// GLSL分为四部分 // * CMD_BEGIN 和 CMD_END 之间的命令 // * VERTEX_SHADER_BEGIN 和 VERTEX_SHADER_END之间的顶点着色器 // * FRAGMENT_SHADER_BEGIN 和 FRAGMENT_SHADER_END之间的片段着色器 // * 三者之外的公共部分 -void GLSCompiler::Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& group)/*throw GLSCompileException*/ +void GLSLCompiler::Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& group)/*throw GLSLCompileException*/ { #define CheckLabel(label) {\ int pos = src.find(label);\ if(pos == string::npos || !IsLabelActive(src, label)) {\ s_CompileError = std::string("Compile Shader Error: No ") + #label + " label";\ - throw GLSCompileException(s_CompileError.c_str());\ + throw GLSLCompileException(s_CompileError.c_str());\ }} CheckLabel(VSH_BEGIN); @@ -59,7 +59,7 @@ if(pos == string::npos || !IsLabelActive(src, label)) {\ fsh = common + fsh; } -std::string GLSCompiler::GetContent(std::string& src, const char* from, const char* to) +std::string GLSLCompiler::GetContent(std::string& src, const char* from, const char* to) { int begin = src.find(from); int end = src.find(to); @@ -71,7 +71,7 @@ std::string GLSCompiler::GetContent(std::string& src, const char* from, const ch return content; } -std::string GLSCompiler::TrimContent(std::string& src, const char* from, const char* to) +std::string GLSLCompiler::TrimContent(std::string& src, const char* from, const char* to) { int begin = src.find(from); int end = src.find(to); @@ -79,7 +79,7 @@ std::string GLSCompiler::TrimContent(std::string& src, const char* from, const c return result; } -bool GLSCompiler::IsLabelActive(std::string& src, const char* label) +bool GLSLCompiler::IsLabelActive(std::string& src, const char* label) { int pos = src.find(label); if (pos == string::npos) @@ -98,7 +98,7 @@ bool GLSCompiler::IsLabelActive(std::string& src, const char* label) return true; } -bool GLSCompiler::IsCommandActive(std::string& src, const char* label) +bool GLSLCompiler::IsCommandActive(std::string& src, const char* label) { int pos = src.find(label); if (pos == string::npos) @@ -117,7 +117,7 @@ bool GLSCompiler::IsCommandActive(std::string& src, const char* label) return true; } -void GLSCompiler::ParseCmd(std::string& cmds, RenderCommandGroup& group) +void GLSLCompiler::ParseCmd(std::string& cmds, RenderCommandGroup& group) { istringstream ss = istringstream(cmds); string line; @@ -139,7 +139,7 @@ void GLSCompiler::ParseCmd(std::string& cmds, RenderCommandGroup& group) else { s_CompileError = string("Unknown command " + cmdName); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } } } @@ -147,7 +147,7 @@ void GLSCompiler::ParseCmd(std::string& cmds, RenderCommandGroup& group) #define IsSeperator(c) (c == ' ' || c == '\r' || c == '\n' || c == /*tab*/9) // 找到行内的第一个单词,作为命令名 -bool GLSCompiler::FindCmdPos(std::string& line, int* start, int* end) +bool GLSLCompiler::FindCmdPos(std::string& line, int* start, int* end) { for (int i = 0; i < line.size(); ++i) { @@ -166,7 +166,7 @@ bool GLSCompiler::FindCmdPos(std::string& line, int* start, int* end) return false; } -bool GLSCompiler::IsLineCommentd(std::string& line) +bool GLSLCompiler::IsLineCommentd(std::string& line) { for (int i = 0; i < line.size(); ++i) { @@ -185,7 +185,7 @@ bool GLSCompiler::IsLineCommentd(std::string& line) #define MAX_PARAM 2 -void GLSCompiler::CommandCull(std::string& p, RenderCommandGroup& group) +void GLSLCompiler::CommandCull(std::string& p, RenderCommandGroup& group) { std::string params[1]; GetParams("Cull", p, params, 1); @@ -200,12 +200,12 @@ void GLSCompiler::CommandCull(std::string& p, RenderCommandGroup& group) { delete pCull; s_CompileError = string("Compile Shader Error: Invalid parameter of Cull: " + params[0]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } group.push_back(pCull); } -void GLSCompiler::CommandBlend(std::string& p, RenderCommandGroup& group) +void GLSLCompiler::CommandBlend(std::string& p, RenderCommandGroup& group) { std::string params[2]; GetParams("Blend", p, params, 2); @@ -239,7 +239,7 @@ void GLSCompiler::CommandBlend(std::string& p, RenderCommandGroup& group) { delete pblend; s_CompileError = string("Compile Shader Error: Invalid parameter of Blend: " + params[0]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } if (params[1] == "Zero") blend.dstFac = Cmd_Blend::Blend_Zero; @@ -260,13 +260,13 @@ void GLSCompiler::CommandBlend(std::string& p, RenderCommandGroup& group) { delete pblend; s_CompileError = string("Compile Shader Error: Invalid parameter of Blend: " + params[1]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } group.push_back(pblend); } -void GLSCompiler::CommandDepthTest(std::string& p, RenderCommandGroup& group) +void GLSLCompiler::CommandDepthTest(std::string& p, RenderCommandGroup& group) { std::string params[1]; GetParams("DepthTest", p, params, 1); @@ -286,12 +286,12 @@ void GLSCompiler::CommandDepthTest(std::string& p, RenderCommandGroup& group) { delete pTest; s_CompileError = string("Compile Shader Error: Invalid parameter of DepthTest: " + params[0]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } group.push_back(pTest); } -void GLSCompiler::CommandDepthWrite(std::string& p, RenderCommandGroup& group) +void GLSLCompiler::CommandDepthWrite(std::string& p, RenderCommandGroup& group) { std::string params[1]; GetParams("DepthWrite", p, params, 1); @@ -304,12 +304,12 @@ void GLSCompiler::CommandDepthWrite(std::string& p, RenderCommandGroup& group) { delete pwrite; s_CompileError = string("Compile Shader Error: Invalid parameter of DepthWrite: " + params[0]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } group.push_back(pwrite); } -void GLSCompiler::GetParams(const char* cmdName, std::string& params, std::string* out, int n) +void GLSLCompiler::GetParams(const char* cmdName, std::string& params, std::string* out, int n) { int index = 0; for (int i = 0; i < params.size(); ++i) @@ -324,7 +324,7 @@ void GLSCompiler::GetParams(const char* cmdName, std::string& params, std::strin if (index >= n) { s_CompileError = string("Compile Shader Error: Invalid parameter count of ") + cmdName +" : " + params; - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } if(!IsSeperator(params[j])) out[index++] = params.substr(i, j - i + 1); @@ -337,7 +337,7 @@ void GLSCompiler::GetParams(const char* cmdName, std::string& params, std::strin if (index >= n) { s_CompileError = string("Compile Shader Error: Invalid parameter count of ") + cmdName + " : " + params; - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } out[index++] = params.substr(i, j - i); break; -- cgit v1.1-26-g67d0