Skip to content

Commit

Permalink
Workaround errors when loading wallpapers made recently (#244)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
moetayuko authored Sep 2, 2024
1 parent d4687f0 commit 5a45c9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/WallpaperEngine/Render/Objects/Effects/CPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void CPass::setupUniforms () {
// resolve the texture first
const ITexture* textureRef;

if (textureName.find ("_rt_") == 0) {
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
textureRef = this->getMaterial ()->getEffect ()->findFBO (textureName);

if (textureRef == nullptr)
Expand Down
18 changes: 14 additions & 4 deletions src/WallpaperEngine/Render/Shaders/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ void Compiler::precompile () {
this->m_includesContent += this->lookupShaderFile (filename);
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 {
this->m_compiledContent += '#';
++it;
Expand Down Expand Up @@ -694,7 +703,7 @@ void Compiler::parseParameterConfiguration (const std::string& type, const std::
value = *constant->second->as<CShaderConstantInteger> ()->getValue ();

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
// if needed
const auto textureName = data.find ("default");
Expand Down Expand Up @@ -755,7 +764,8 @@ const std::map<int, std::string>& Compiler::getTextures () const {
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

0 comments on commit 5a45c9a

Please sign in to comment.