Make changes for breaking NZSL update
Fix build Fix compilation (again) Fix global included TextureAsset belongs to another branch Add missing include Fix include (should be good, finally)
This commit is contained in:
parent
87bf4563f2
commit
83366e93d4
|
|
@ -95,7 +95,6 @@
|
|||
#include <Nazara/Graphics/SpriteChainRenderer.hpp>
|
||||
#include <Nazara/Graphics/SubmeshRenderer.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Graphics/TextureAsset.hpp>
|
||||
#include <Nazara/Graphics/TextureSamplerCache.hpp>
|
||||
#include <Nazara/Graphics/Tilemap.hpp>
|
||||
#include <Nazara/Graphics/TransferInterface.hpp>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include <Nazara/Utility/UniformBuffer.hpp>
|
||||
#include <NazaraUtils/Signal.hpp>
|
||||
#include <NZSL/Ast/ConstantValue.hpp>
|
||||
#include <NZSL/Ast/Option.hpp>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
|
@ -30,7 +31,7 @@ namespace Nz
|
|||
{
|
||||
MaterialPassFlags flags;
|
||||
RenderStates states;
|
||||
std::unordered_map<UInt32, nzsl::Ast::ConstantSingleValue> options;
|
||||
std::unordered_map<nzsl::Ast::OptionHash, nzsl::Ast::ConstantSingleValue> options;
|
||||
std::vector<std::shared_ptr<UberShader>> shaders;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <Nazara/Renderer/RenderPipelineLayout.hpp>
|
||||
#include <NZSL/Ast/Module.hpp>
|
||||
#include <NZSL/Ast/RecursiveVisitor.hpp>
|
||||
#include <NZSL/Ast/Option.hpp>
|
||||
#include <NZSL/Math/FieldOffsets.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ namespace Nz
|
|||
struct OptionData
|
||||
{
|
||||
nzsl::Ast::ExpressionType type;
|
||||
UInt32 hash;
|
||||
nzsl::Ast::OptionHash hash;
|
||||
};
|
||||
|
||||
struct StructMemberData
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <NazaraUtils/Signal.hpp>
|
||||
#include <NZSL/ModuleResolver.hpp>
|
||||
#include <NZSL/Ast/Module.hpp>
|
||||
#include <NZSL/Ast/Option.hpp>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ namespace Nz
|
|||
|
||||
struct Option
|
||||
{
|
||||
UInt32 hash;
|
||||
nzsl::Ast::OptionHash hash;
|
||||
};
|
||||
|
||||
NazaraSignal(OnShaderUpdated, UberShader* /*uberShader*/);
|
||||
|
|
|
|||
|
|
@ -256,6 +256,8 @@ namespace Nz
|
|||
|
||||
void Graphics::BuildDefaultMaterials()
|
||||
{
|
||||
using namespace nzsl::Ast::Literals;
|
||||
|
||||
std::size_t depthPassIndex = m_materialPassRegistry.GetPassIndex("DepthPass");
|
||||
std::size_t shadowPassIndex = m_materialPassRegistry.GetPassIndex("ShadowPass");
|
||||
std::size_t distanceShadowPassIndex = m_materialPassRegistry.GetPassIndex("DistanceShadowPass");
|
||||
|
|
@ -274,17 +276,17 @@ namespace Nz
|
|||
settings.AddPass(forwardPassIndex, forwardPass);
|
||||
|
||||
MaterialPass depthPass = forwardPass;
|
||||
depthPass.options[CRC32("DepthPass")] = true;
|
||||
depthPass.options["DepthPass"_opt] = true;
|
||||
settings.AddPass(depthPassIndex, depthPass);
|
||||
|
||||
MaterialPass shadowPass = depthPass;
|
||||
shadowPass.options[CRC32("ShadowPass")] = true;
|
||||
shadowPass.options["ShadowPass"_opt] = true;
|
||||
shadowPass.states.frontFace = FrontFace::Clockwise;
|
||||
shadowPass.states.depthClamp = enabledFeatures.depthClamping;
|
||||
settings.AddPass(shadowPassIndex, shadowPass);
|
||||
|
||||
MaterialPass distanceShadowPass = shadowPass;
|
||||
distanceShadowPass.options[CRC32("DistanceDepth")] = true;
|
||||
distanceShadowPass.options["DistanceDepth"_opt] = true;
|
||||
settings.AddPass(distanceShadowPassIndex, distanceShadowPass);
|
||||
|
||||
m_defaultMaterials.materials[MaterialType::Basic].material = std::make_shared<Material>(std::move(settings), "BasicMaterial");
|
||||
|
|
@ -302,17 +304,17 @@ namespace Nz
|
|||
settings.AddPass(forwardPassIndex, forwardPass);
|
||||
|
||||
MaterialPass depthPass = forwardPass;
|
||||
depthPass.options[CRC32("DepthPass")] = true;
|
||||
depthPass.options["DepthPass"_opt] = true;
|
||||
settings.AddPass(depthPassIndex, depthPass);
|
||||
|
||||
MaterialPass shadowPass = depthPass;
|
||||
shadowPass.options[CRC32("ShadowPass")] = true;
|
||||
shadowPass.options["ShadowPass"_opt] = true;
|
||||
shadowPass.states.frontFace = FrontFace::Clockwise;
|
||||
shadowPass.states.depthClamp = enabledFeatures.depthClamping;
|
||||
settings.AddPass(shadowPassIndex, shadowPass);
|
||||
|
||||
MaterialPass distanceShadowPass = shadowPass;
|
||||
distanceShadowPass.options[CRC32("DistanceDepth")] = true;
|
||||
distanceShadowPass.options["DistanceDepth"_opt] = true;
|
||||
settings.AddPass(distanceShadowPassIndex, distanceShadowPass);
|
||||
|
||||
m_defaultMaterials.materials[MaterialType::PhysicallyBased].material = std::make_shared<Material>(std::move(settings), "PhysicallyBasedMaterial");
|
||||
|
|
@ -330,17 +332,17 @@ namespace Nz
|
|||
settings.AddPass(forwardPassIndex, forwardPass);
|
||||
|
||||
MaterialPass depthPass = forwardPass;
|
||||
depthPass.options[CRC32("DepthPass")] = true;
|
||||
depthPass.options["DepthPass"_opt] = true;
|
||||
settings.AddPass(depthPassIndex, depthPass);
|
||||
|
||||
MaterialPass shadowPass = depthPass;
|
||||
shadowPass.options[CRC32("ShadowPass")] = true;
|
||||
shadowPass.options["ShadowPass"_opt] = true;
|
||||
shadowPass.states.frontFace = FrontFace::Clockwise;
|
||||
shadowPass.states.depthClamp = enabledFeatures.depthClamping;
|
||||
settings.AddPass(shadowPassIndex, shadowPass);
|
||||
|
||||
MaterialPass distanceShadowPass = shadowPass;
|
||||
distanceShadowPass.options[CRC32("DistanceDepth")] = true;
|
||||
distanceShadowPass.options["DistanceDepth"_opt] = true;
|
||||
settings.AddPass(distanceShadowPassIndex, distanceShadowPass);
|
||||
|
||||
m_defaultMaterials.materials[MaterialType::Phong].material = std::make_shared<Material>(std::move(settings), "PhongMaterial");
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ namespace Nz
|
|||
Material::Material(MaterialSettings settings, const nzsl::Ast::ModulePtr& referenceModule) :
|
||||
m_settings(std::move(settings))
|
||||
{
|
||||
using namespace nzsl::Ast::Literals;
|
||||
|
||||
NazaraAssert(referenceModule, "invalid module");
|
||||
|
||||
Graphics* graphics = Graphics::Instance();
|
||||
|
|
@ -36,9 +38,9 @@ namespace Nz
|
|||
options.forceAutoBindingResolve = true;
|
||||
options.partialSanitization = true;
|
||||
options.moduleResolver = graphics->GetShaderModuleResolver();
|
||||
options.optionValues[CRC32("MaxLightCount")] = SafeCast<UInt32>(PredefinedLightData::MaxLightCount);
|
||||
options.optionValues[CRC32("MaxLightCascadeCount")] = SafeCast<UInt32>(PredefinedDirectionalLightData::MaxLightCascadeCount);
|
||||
options.optionValues[CRC32("MaxJointCount")] = SafeCast<UInt32>(PredefinedSkeletalData::MaxMatricesCount);
|
||||
options.optionValues["MaxLightCount"_opt] = SafeCast<UInt32>(PredefinedLightData::MaxLightCount);
|
||||
options.optionValues["MaxLightCascadeCount"_opt] = SafeCast<UInt32>(PredefinedDirectionalLightData::MaxLightCascadeCount);
|
||||
options.optionValues["MaxJointCount"_opt] = SafeCast<UInt32>(PredefinedSkeletalData::MaxMatricesCount);
|
||||
|
||||
nzsl::Ast::ModulePtr sanitizedModule = nzsl::Ast::Sanitize(*referenceModule, options);
|
||||
|
||||
|
|
@ -123,6 +125,8 @@ namespace Nz
|
|||
{
|
||||
uberShader->UpdateConfigCallback([=](UberShader::Config& config, const std::vector<RenderPipelineInfo::VertexBufferData>& vertexBuffers)
|
||||
{
|
||||
using namespace nzsl::Ast::Literals;
|
||||
|
||||
if (vertexBuffers.empty())
|
||||
return;
|
||||
|
||||
|
|
@ -135,35 +139,35 @@ namespace Nz
|
|||
switch (component.component)
|
||||
{
|
||||
case VertexComponent::Color:
|
||||
config.optionValues[CRC32("VertexColorLoc")] = locationIndex;
|
||||
config.optionValues["VertexColorLoc"_opt] = locationIndex;
|
||||
break;
|
||||
|
||||
case VertexComponent::Normal:
|
||||
config.optionValues[CRC32("VertexNormalLoc")] = locationIndex;
|
||||
config.optionValues["VertexNormalLoc"_opt] = locationIndex;
|
||||
break;
|
||||
|
||||
case VertexComponent::Position:
|
||||
config.optionValues[CRC32("VertexPositionLoc")] = locationIndex;
|
||||
config.optionValues["VertexPositionLoc"_opt] = locationIndex;
|
||||
break;
|
||||
|
||||
case VertexComponent::SizeSinCos:
|
||||
config.optionValues[CRC32("VertexSizeRotLocation")] = locationIndex;
|
||||
config.optionValues["VertexSizeRotLocation"_opt] = locationIndex;
|
||||
break;
|
||||
|
||||
case VertexComponent::Tangent:
|
||||
config.optionValues[CRC32("VertexTangentLoc")] = locationIndex;
|
||||
config.optionValues["VertexTangentLoc"_opt] = locationIndex;
|
||||
break;
|
||||
|
||||
case VertexComponent::TexCoord:
|
||||
config.optionValues[CRC32("VertexUvLoc")] = locationIndex;
|
||||
config.optionValues["VertexUvLoc"_opt] = locationIndex;
|
||||
break;
|
||||
|
||||
case VertexComponent::JointIndices:
|
||||
config.optionValues[CRC32("VertexJointIndicesLoc")] = locationIndex;
|
||||
config.optionValues["VertexJointIndicesLoc"_opt] = locationIndex;
|
||||
break;
|
||||
|
||||
case VertexComponent::JointWeights:
|
||||
config.optionValues[CRC32("VertexJointWeightsLoc")] = locationIndex;
|
||||
config.optionValues["VertexJointWeightsLoc"_opt] = locationIndex;
|
||||
break;
|
||||
|
||||
case VertexComponent::Unused:
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ namespace Nz
|
|||
throw std::runtime_error("option " + node.optName + " condition must be resolved");
|
||||
|
||||
OptionData& optionData = m_options[node.optName];
|
||||
optionData.hash = CRC32(node.optName);
|
||||
optionData.hash = nzsl::Ast::HashOption(node.optName);
|
||||
optionData.type = node.optType.GetResultingValue();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ namespace Nz
|
|||
//TODO: Check optionType
|
||||
|
||||
optionByName[option.optName] = Option{
|
||||
CRC32(option.optName)
|
||||
nzsl::Ast::HashOption(option.optName)
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ int main()
|
|||
}
|
||||
|
||||
nzsl::ShaderWriter::States states;
|
||||
states.optionValues[Nz::CRC32("red")] = false; //< Try enabling this!
|
||||
states.optionValues[nzsl::Ast::HashOption("red")] = false; //< Try enabling this!
|
||||
states.optimize = true;
|
||||
|
||||
auto fragVertShader = device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, *shaderModule, states);
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ if has_config("platform") then
|
|||
end
|
||||
|
||||
if has_config("renderer") then
|
||||
add_requires("nzsl", { debug = is_mode("debug"), configs = { with_symbols = not is_mode("release"), shared = not is_plat("wasm", "android") and not has_config("static") } })
|
||||
add_requires("nzsl >=2023.12.17+1", { debug = is_mode("debug"), configs = { with_symbols = not is_mode("release"), shared = not is_plat("wasm", "android") and not has_config("static") } })
|
||||
|
||||
local function is_cross_compiling()
|
||||
if os.host() == "windows" then
|
||||
|
|
|
|||
Loading…
Reference in New Issue