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
This commit is contained in:
moetayuko 2024-09-03 06:23:56 +08:00 committed by GitHub
parent d4687f09ec
commit 5a45c9a26b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View File

@ -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)

View File

@ -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 = { std::vector<std::string> Compiler::sTypes = {"vec4", "uvec4", "ivec4", "dvec4", "bvec4", "vec3",
"vec4", "uvec4", "ivec4", "dvec4", "bvec4", "vec3", "uvec3", "ivec3", "dvec3", "bvec3", "vec2", "uvec3", "ivec3", "dvec3", "bvec3", "vec2", "uvec2",
"uvec2", "ivec2", "dvec2", "bvec2", "float", "sampler2D", "mat4x3", "mat4", "mat3", "uint4", "void"}; "ivec2", "dvec2", "bvec2", "float", "sampler2D", "sampler2DComparison",
"mat4x3", "mat4", "mat3", "uint", "uint4", "void"};
} // namespace WallpaperEngine::Render::Shaders } // namespace WallpaperEngine::Render::Shaders