Prechádzať zdrojové kódy

Workaround errors when loading wallpapers made recently (#244)

* Add sampler2DComparison and uint to known types

* Ignore unsupported `#require` preprocessor directive

`#require LightingV1` is found in generic4.frag, genericimage4.frag, ...

* Mark _alias_* textures as FBOs

Currently not supported, but prevents loading from the file, thereby
avoiding CAssetLoadException
moetayuko 2 rokov pred
rodič
commit
5a45c9a26b

+ 1 - 1
src/WallpaperEngine/Render/Objects/Effects/CPass.cpp

@@ -451,7 +451,7 @@ void CPass::setupUniforms () {
                     // resolve the texture first
                     // resolve the texture first
                     const ITexture* textureRef;
                     const ITexture* textureRef;
 
 
-                    if (textureName.find ("_rt_") == 0) {
+                    if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
                         textureRef = this->getMaterial ()->getEffect ()->findFBO (textureName);
                         textureRef = this->getMaterial ()->getEffect ()->findFBO (textureName);
 
 
                         if (textureRef == nullptr)
                         if (textureRef == nullptr)

+ 14 - 4
src/WallpaperEngine/Render/Shaders/Compiler.cpp

@@ -265,6 +265,15 @@ void Compiler::precompile () {
                     this->m_includesContent += this->lookupShaderFile (filename);
                     this->m_includesContent += this->lookupShaderFile (filename);
                     this->m_includesContent += "\r\n// end of included from file " + filename + "\r\n";
                     this->m_includesContent += "\r\n// end of included from file " + filename + "\r\n";
                 }
                 }
+            } else if (this->peekString ("#require ", it)) {
+                // TODO: PROPERLY IMPLEMENT #require
+                this->m_compiledContent += "// #require ";
+                // ignore whitespaces
+                this->ignoreSpaces (it);
+                BREAK_IF_ERROR
+                std::string name = this->extractName (it);
+                BREAK_IF_ERROR
+                this->m_compiledContent += name;
             } else {
             } else {
                 this->m_compiledContent += '#';
                 this->m_compiledContent += '#';
                 ++it;
                 ++it;
@@ -694,7 +703,7 @@ void Compiler::parseParameterConfiguration (const std::string& type, const std::
             value = *constant->second->as<CShaderConstantInteger> ()->getValue ();
             value = *constant->second->as<CShaderConstantInteger> ()->getValue ();
 
 
         parameter = new Variables::CShaderVariableInteger (value);
         parameter = new Variables::CShaderVariableInteger (value);
-    } else if (type == "sampler2D") {
+    } else if (type == "sampler2D" || type == "sampler2DComparison") {
         // samplers can have special requirements, check what sampler we're working with and create definitions
         // samplers can have special requirements, check what sampler we're working with and create definitions
         // if needed
         // if needed
         const auto textureName = data.find ("default");
         const auto textureName = data.find ("default");
@@ -755,7 +764,8 @@ const std::map<int, std::string>& Compiler::getTextures () const {
     return this->m_textures;
     return this->m_textures;
 }
 }
 
 
-std::vector<std::string> Compiler::sTypes = {
-    "vec4",  "uvec4", "ivec4", "dvec4", "bvec4", "vec3",      "uvec3",  "ivec3", "dvec3", "bvec3", "vec2",
-    "uvec2", "ivec2", "dvec2", "bvec2", "float", "sampler2D", "mat4x3", "mat4",  "mat3",  "uint4", "void"};
+std::vector<std::string> Compiler::sTypes = {"vec4",   "uvec4", "ivec4", "dvec4", "bvec4",     "vec3",
+                                             "uvec3",  "ivec3", "dvec3", "bvec3", "vec2",      "uvec2",
+                                             "ivec2",  "dvec2", "bvec2", "float", "sampler2D", "sampler2DComparison",
+                                             "mat4x3", "mat4",  "mat3",  "uint",  "uint4",     "void"};
 } // namespace WallpaperEngine::Render::Shaders
 } // namespace WallpaperEngine::Render::Shaders