chore: fix binds loading, more fixes on pass overrides, should cleanup soon

This commit is contained in:
Almamu 2025-08-15 00:53:11 +02:00
parent ace1282522
commit 1a3f789cee
6 changed files with 23 additions and 10 deletions

View File

@ -51,7 +51,7 @@ std::vector <EffectPassUniquePtr> EffectParser::parseEffectPasses (const JSON& i
}
for (const auto& cur : it) {
const auto binds = cur.optional ("binds");
const auto binds = cur.optional ("bind");
std::optional <PassCommand> command = std::nullopt;
if (cur.contains ("command")) {

View File

@ -426,7 +426,7 @@ void CPass::setupShaders () {
// use the combos copied from the pass so it includes the texture format
this->m_shader = new Render::Shaders::CShader (
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 (

View File

@ -20,17 +20,19 @@ namespace WallpaperEngine::Render::Shaders {
CShader::CShader (
const CContainer& container, std::string filename,
const ComboMap& combos, const TextureMap& textures,
const TextureMap& overrideTextures,
const ShaderConstantMap& constants
) :
m_file (std::move (filename)),
m_combos (combos),
m_passTextures (textures),
m_overrideTextures (overrideTextures),
m_vertex (
CGLSLContext::UnitType_Vertex, filename, container.readVertexShader (filename),
container, constants, textures, combos),
container, constants, textures, overrideTextures, combos),
m_fragment (
CGLSLContext::UnitType_Fragment, filename, container.readFragmentShader (filename),
container, constants, textures, combos) {
container, constants, textures, overrideTextures, combos) {
// link shaders between them
this->m_vertex.linkToUnit (&this->m_fragment);
this->m_fragment.linkToUnit (&this->m_vertex);

View File

@ -47,6 +47,7 @@ class CShader {
CShader (
const CContainer& container, std::string filename,
const ComboMap& combos, const TextureMap& textures,
const TextureMap& overrideTextures,
const ShaderConstantMap& constants);
/**
* @return The vertex's shader coude for OpenGL to use
@ -101,5 +102,9 @@ class CShader {
* The list of textures the pass knows about
*/
const TextureMap m_passTextures;
/**
* The list of the override textures
*/
const TextureMap& m_overrideTextures;
};
} // namespace WallpaperEngine::Render::Shaders

View File

@ -57,7 +57,8 @@ using namespace WallpaperEngine::Render::Shaders;
CShaderUnit::CShaderUnit (
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_link (nullptr),
@ -66,6 +67,7 @@ CShaderUnit::CShaderUnit (
m_constants (constants),
m_content (std::move(content)),
m_passTextures (passTextures),
m_overrideTextures (overrideTextures),
m_combos (combos),
m_discoveredCombos (),
m_usedCombos () {
@ -409,15 +411,17 @@ void CShaderUnit::parseParameterConfiguration (
const auto requireany = data.find ("requireany");
const auto require = data.find ("require");
// now convert it to integer
// TODO: BETTER CONVERSION HERE
size_t index = value - '0';
if (combo != data.end ()) {
// TODO: CLEANUP HOW THIS IS DETERMINED FIRST
// 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;
int comboValue = 1;
if (texture != this->m_passTextures.end ()) {
if (textureSlotUsed) {
// nothing extra to do, the texture exists, the combo must be set
// these tend to not have default value
isRequired = true;
@ -452,7 +456,7 @@ void CShaderUnit::parseParameterConfiguration (
}
}
if (isRequired && texture == this->m_passTextures.end ()) {
if (isRequired && !textureSlotUsed) {
if (defvalue == data.end ()) {
isRequired = false;
} else {

View File

@ -27,7 +27,7 @@ class CShaderUnit {
CShaderUnit (
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
const ShaderConstantMap& constants, const TextureMap& passTextures,
const ComboMap& combos);
const TextureMap& overrideTextures, const ComboMap& combos);
~CShaderUnit () = default;
/**
@ -145,7 +145,9 @@ class CShaderUnit {
*/
const ShaderConstantMap& m_constants;
/** 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 */
TextureMap m_defaultTextures = {};
/**