mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 05:46:48 +08:00
chore: fix binds loading, more fixes on pass overrides, should cleanup soon
This commit is contained in:
parent
ace1282522
commit
1a3f789cee
@ -51,7 +51,7 @@ std::vector <EffectPassUniquePtr> EffectParser::parseEffectPasses (const JSON& i
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& cur : it) {
|
for (const auto& cur : it) {
|
||||||
const auto binds = cur.optional ("binds");
|
const auto binds = cur.optional ("bind");
|
||||||
std::optional <PassCommand> command = std::nullopt;
|
std::optional <PassCommand> command = std::nullopt;
|
||||||
|
|
||||||
if (cur.contains ("command")) {
|
if (cur.contains ("command")) {
|
||||||
|
@ -426,7 +426,7 @@ void CPass::setupShaders () {
|
|||||||
// use the combos copied from the pass so it includes the texture format
|
// use the combos copied from the pass so it includes the texture format
|
||||||
this->m_shader = new Render::Shaders::CShader (
|
this->m_shader = new Render::Shaders::CShader (
|
||||||
this->m_image.getContainer (), this->m_pass.shader, this->m_combos,
|
this->m_image.getContainer (), this->m_pass.shader, this->m_combos,
|
||||||
this->m_pass.textures, this->m_override.constants
|
this->m_pass.textures, this->m_override.textures, this->m_override.constants
|
||||||
);
|
);
|
||||||
|
|
||||||
const auto shaders = Shaders::CGLSLContext::get ().toGlsl (
|
const auto shaders = Shaders::CGLSLContext::get ().toGlsl (
|
||||||
|
@ -20,17 +20,19 @@ namespace WallpaperEngine::Render::Shaders {
|
|||||||
CShader::CShader (
|
CShader::CShader (
|
||||||
const CContainer& container, std::string filename,
|
const CContainer& container, std::string filename,
|
||||||
const ComboMap& combos, const TextureMap& textures,
|
const ComboMap& combos, const TextureMap& textures,
|
||||||
|
const TextureMap& overrideTextures,
|
||||||
const ShaderConstantMap& constants
|
const ShaderConstantMap& constants
|
||||||
) :
|
) :
|
||||||
m_file (std::move (filename)),
|
m_file (std::move (filename)),
|
||||||
m_combos (combos),
|
m_combos (combos),
|
||||||
m_passTextures (textures),
|
m_passTextures (textures),
|
||||||
|
m_overrideTextures (overrideTextures),
|
||||||
m_vertex (
|
m_vertex (
|
||||||
CGLSLContext::UnitType_Vertex, filename, container.readVertexShader (filename),
|
CGLSLContext::UnitType_Vertex, filename, container.readVertexShader (filename),
|
||||||
container, constants, textures, combos),
|
container, constants, textures, overrideTextures, combos),
|
||||||
m_fragment (
|
m_fragment (
|
||||||
CGLSLContext::UnitType_Fragment, filename, container.readFragmentShader (filename),
|
CGLSLContext::UnitType_Fragment, filename, container.readFragmentShader (filename),
|
||||||
container, constants, textures, combos) {
|
container, constants, textures, overrideTextures, combos) {
|
||||||
// link shaders between them
|
// link shaders between them
|
||||||
this->m_vertex.linkToUnit (&this->m_fragment);
|
this->m_vertex.linkToUnit (&this->m_fragment);
|
||||||
this->m_fragment.linkToUnit (&this->m_vertex);
|
this->m_fragment.linkToUnit (&this->m_vertex);
|
||||||
|
@ -47,6 +47,7 @@ class CShader {
|
|||||||
CShader (
|
CShader (
|
||||||
const CContainer& container, std::string filename,
|
const CContainer& container, std::string filename,
|
||||||
const ComboMap& combos, const TextureMap& textures,
|
const ComboMap& combos, const TextureMap& textures,
|
||||||
|
const TextureMap& overrideTextures,
|
||||||
const ShaderConstantMap& constants);
|
const ShaderConstantMap& constants);
|
||||||
/**
|
/**
|
||||||
* @return The vertex's shader coude for OpenGL to use
|
* @return The vertex's shader coude for OpenGL to use
|
||||||
@ -101,5 +102,9 @@ class CShader {
|
|||||||
* The list of textures the pass knows about
|
* The list of textures the pass knows about
|
||||||
*/
|
*/
|
||||||
const TextureMap m_passTextures;
|
const TextureMap m_passTextures;
|
||||||
|
/**
|
||||||
|
* The list of the override textures
|
||||||
|
*/
|
||||||
|
const TextureMap& m_overrideTextures;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Render::Shaders
|
} // namespace WallpaperEngine::Render::Shaders
|
||||||
|
@ -57,7 +57,8 @@ using namespace WallpaperEngine::Render::Shaders;
|
|||||||
|
|
||||||
CShaderUnit::CShaderUnit (
|
CShaderUnit::CShaderUnit (
|
||||||
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
|
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
|
||||||
const ShaderConstantMap& constants, const TextureMap& passTextures, const ComboMap& combos
|
const ShaderConstantMap& constants, const TextureMap& passTextures, const TextureMap& overrideTextures,
|
||||||
|
const ComboMap& combos
|
||||||
) :
|
) :
|
||||||
m_type (type),
|
m_type (type),
|
||||||
m_link (nullptr),
|
m_link (nullptr),
|
||||||
@ -66,6 +67,7 @@ CShaderUnit::CShaderUnit (
|
|||||||
m_constants (constants),
|
m_constants (constants),
|
||||||
m_content (std::move(content)),
|
m_content (std::move(content)),
|
||||||
m_passTextures (passTextures),
|
m_passTextures (passTextures),
|
||||||
|
m_overrideTextures (overrideTextures),
|
||||||
m_combos (combos),
|
m_combos (combos),
|
||||||
m_discoveredCombos (),
|
m_discoveredCombos (),
|
||||||
m_usedCombos () {
|
m_usedCombos () {
|
||||||
@ -409,15 +411,17 @@ void CShaderUnit::parseParameterConfiguration (
|
|||||||
const auto requireany = data.find ("requireany");
|
const auto requireany = data.find ("requireany");
|
||||||
const auto require = data.find ("require");
|
const auto require = data.find ("require");
|
||||||
// now convert it to integer
|
// now convert it to integer
|
||||||
|
// TODO: BETTER CONVERSION HERE
|
||||||
size_t index = value - '0';
|
size_t index = value - '0';
|
||||||
|
|
||||||
if (combo != data.end ()) {
|
if (combo != data.end ()) {
|
||||||
|
// TODO: CLEANUP HOW THIS IS DETERMINED FIRST
|
||||||
// if the texture exists (and is not null), add to the combo
|
// if the texture exists (and is not null), add to the combo
|
||||||
auto texture = this->m_passTextures.find (index);
|
auto textureSlotUsed = this->m_passTextures.find (index) != this->m_passTextures.end () || this->m_overrideTextures.find (index) != this->m_overrideTextures.end ();
|
||||||
bool isRequired = false;
|
bool isRequired = false;
|
||||||
int comboValue = 1;
|
int comboValue = 1;
|
||||||
|
|
||||||
if (texture != this->m_passTextures.end ()) {
|
if (textureSlotUsed) {
|
||||||
// nothing extra to do, the texture exists, the combo must be set
|
// nothing extra to do, the texture exists, the combo must be set
|
||||||
// these tend to not have default value
|
// these tend to not have default value
|
||||||
isRequired = true;
|
isRequired = true;
|
||||||
@ -452,7 +456,7 @@ void CShaderUnit::parseParameterConfiguration (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRequired && texture == this->m_passTextures.end ()) {
|
if (isRequired && !textureSlotUsed) {
|
||||||
if (defvalue == data.end ()) {
|
if (defvalue == data.end ()) {
|
||||||
isRequired = false;
|
isRequired = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,7 +27,7 @@ class CShaderUnit {
|
|||||||
CShaderUnit (
|
CShaderUnit (
|
||||||
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
|
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
|
||||||
const ShaderConstantMap& constants, const TextureMap& passTextures,
|
const ShaderConstantMap& constants, const TextureMap& passTextures,
|
||||||
const ComboMap& combos);
|
const TextureMap& overrideTextures, const ComboMap& combos);
|
||||||
~CShaderUnit () = default;
|
~CShaderUnit () = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,7 +145,9 @@ class CShaderUnit {
|
|||||||
*/
|
*/
|
||||||
const ShaderConstantMap& m_constants;
|
const ShaderConstantMap& m_constants;
|
||||||
/** The textures that are already applied to this shader */
|
/** The textures that are already applied to this shader */
|
||||||
const TextureMap m_passTextures = {};
|
const TextureMap& m_passTextures;
|
||||||
|
/** The textures that are being overridden */
|
||||||
|
const TextureMap& m_overrideTextures;
|
||||||
/** The default textures to use when a texture is not applied in a given slot */
|
/** The default textures to use when a texture is not applied in a given slot */
|
||||||
TextureMap m_defaultTextures = {};
|
TextureMap m_defaultTextures = {};
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user