From 5a46ebda36b03d28237e982ccddb19b92f6c0add Mon Sep 17 00:00:00 2001 From: SirLynix Date: Wed, 7 Feb 2024 15:55:14 +0100 Subject: [PATCH] Graphics/PropertyHandler: Warn if an option if set but doesn't exist in material --- .../OptionValuePropertyHandler.cpp | 2 ++ .../PropertyHandler/TexturePropertyHandler.cpp | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Nazara/Graphics/PropertyHandler/OptionValuePropertyHandler.cpp b/src/Nazara/Graphics/PropertyHandler/OptionValuePropertyHandler.cpp index d09805d3d..5476dff56 100644 --- a/src/Nazara/Graphics/PropertyHandler/OptionValuePropertyHandler.cpp +++ b/src/Nazara/Graphics/PropertyHandler/OptionValuePropertyHandler.cpp @@ -34,6 +34,8 @@ namespace Nz m_optionHash = optionData->hash; m_propertyIndex = propertyIndex; } + else + NazaraWarningFmt("option {0} not found in shader for property {1}", m_optionName, m_propertyName); } void OptionValuePropertyHandler::Update(MaterialInstance& materialInstance) const diff --git a/src/Nazara/Graphics/PropertyHandler/TexturePropertyHandler.cpp b/src/Nazara/Graphics/PropertyHandler/TexturePropertyHandler.cpp index 08e44d3d5..47a951c1c 100644 --- a/src/Nazara/Graphics/PropertyHandler/TexturePropertyHandler.cpp +++ b/src/Nazara/Graphics/PropertyHandler/TexturePropertyHandler.cpp @@ -42,15 +42,20 @@ namespace Nz m_propertyIndex = propertyIndex; m_optionHash = 0; - if (const ShaderReflection::OptionData* optionData = reflection.GetOptionByName(m_optionName)) + if (!m_optionName.empty()) { - if (IsPrimitiveType(optionData->type) && std::get(optionData->type) == nzsl::Ast::PrimitiveType::Boolean) + if (const ShaderReflection::OptionData* optionData = reflection.GetOptionByName(m_optionName)) { - NazaraAssert(optionData->hash != 0, "unexpected option hash"); - m_optionHash = optionData->hash; + if (IsPrimitiveType(optionData->type) && std::get(optionData->type) == nzsl::Ast::PrimitiveType::Boolean) + { + NazaraAssert(optionData->hash != 0, "unexpected option hash"); + m_optionHash = optionData->hash; + } + else + NazaraErrorFmt("option {0} is not a boolean option (got {1})", m_optionName, nzsl::Ast::ToString(optionData->type)); } else - NazaraErrorFmt("option {0} is not a boolean option (got {1})", m_optionName, nzsl::Ast::ToString(optionData->type)); + NazaraWarningFmt("option {0} not found in shader for property {1}", m_optionName, m_propertyName); } }