Temp fix for NZSL update

This commit is contained in:
SirLynix 2022-06-15 20:26:14 +02:00
parent b10e0a7408
commit 8e8bee7037
8 changed files with 19 additions and 11 deletions

View File

@ -67,7 +67,7 @@ namespace Nz
inline FaceFilling GetFaceFilling() const;
inline MaterialPassFlags GetFlags() const;
inline float GetLineWidth() const;
inline const nzsl::Ast::ConstantValue& GetOptionValue(std::size_t optionIndex) const;
inline const nzsl::Ast::ConstantSingleValue& GetOptionValue(std::size_t optionIndex) const;
inline const std::shared_ptr<MaterialPipeline>& GetPipeline() const;
inline const MaterialPipelineInfo& GetPipelineInfo() const;
inline float GetPointSize() const;
@ -98,7 +98,7 @@ namespace Nz
inline void SetFaceCulling(FaceSide faceSide);
inline void SetFaceFilling(FaceFilling filling);
inline void SetLineWidth(float lineWidth);
inline void SetOptionValue(std::size_t optionIndex, nzsl::Ast::ConstantValue value);
inline void SetOptionValue(std::size_t optionIndex, nzsl::Ast::ConstantSingleValue value);
inline void SetPointSize(float pointSize);
inline void SetPrimitiveMode(PrimitiveMode mode);
inline void SetTexture(std::size_t textureIndex, std::shared_ptr<Texture> texture);
@ -142,7 +142,7 @@ namespace Nz
bool dataInvalidated = true;
};
std::array<nzsl::Ast::ConstantValue, 64> m_optionValues;
std::array<nzsl::Ast::ConstantSingleValue, 64> m_optionValues;
std::shared_ptr<const MaterialSettings> m_settings;
std::vector<MaterialTexture> m_textures;
std::vector<ShaderEntry> m_shaders;

View File

@ -319,7 +319,7 @@ namespace Nz
return m_pipelineInfo.lineWidth;
}
inline const nzsl::Ast::ConstantValue& MaterialPass::GetOptionValue(std::size_t optionIndex) const
inline const nzsl::Ast::ConstantSingleValue& MaterialPass::GetOptionValue(std::size_t optionIndex) const
{
assert(optionIndex < m_optionValues.size());
return m_optionValues[optionIndex];
@ -566,7 +566,7 @@ namespace Nz
InvalidatePipeline();
}
inline void MaterialPass::SetOptionValue(std::size_t optionIndex, nzsl::Ast::ConstantValue value)
inline void MaterialPass::SetOptionValue(std::size_t optionIndex, nzsl::Ast::ConstantSingleValue value)
{
assert(optionIndex < m_optionValues.size());
if (m_optionValues[optionIndex] != value)

View File

@ -25,7 +25,7 @@ namespace Nz
struct Option
{
UInt32 hash;
nzsl::Ast::ConstantValue value;
nzsl::Ast::ConstantSingleValue value;
};
struct Shader

View File

@ -43,7 +43,7 @@ namespace Nz
struct Config
{
std::unordered_map<UInt32, nzsl::Ast::ConstantValue> optionValues;
std::unordered_map<UInt32, nzsl::Ast::ConstantSingleValue> optionValues;
};
struct ConfigEqual

View File

@ -49,10 +49,11 @@ namespace Nz
renderPipelineInfo.pipelineLayout = m_pipelineInfo.settings->GetRenderPipelineLayout();
std::unordered_map<UInt32, nzsl::Ast::ConstantValue> optionValues;
std::unordered_map<UInt32, nzsl::Ast::ConstantSingleValue> optionValues;
for (std::size_t i = 0; i < m_pipelineInfo.optionCount; ++i)
{
const auto& option = m_pipelineInfo.optionValues[i];
optionValues[option.hash] = option.value;
}

View File

@ -71,7 +71,14 @@ namespace Nz
if (it == m_combinations.end())
{
nzsl::ShaderWriter::States states;
states.optionValues = config.optionValues;
// TODO: Remove this when arrays are accepted as config values
for (const auto& [optionHash, optionValue] : config.optionValues)
{
std::visit([&](auto&& arg)
{
states.optionValues[optionHash] = arg;
}, optionValue);
}
states.shaderModuleResolver = Graphics::Instance()->GetShaderModuleResolver();
std::shared_ptr<ShaderModule> stage = Graphics::Instance()->GetRenderDevice()->InstantiateShaderModule(m_shaderStages, *m_shaderModule, std::move(states));

View File

@ -26,7 +26,7 @@ task("compile-shaders")
print("Compiling shaders...")
for _, filepath in pairs(os.files("src/Nazara/*/Resources/**.nzsl")) do
print(" - Compiling " .. filepath)
local argv = {"--compile=nzslb", "--partial", "--header-file", filepath }
local argv = {"--compile=nzslb-header", "--partial", filepath }
if option.get("measure") then
table.insert(argv, "--measure")
end

View File

@ -11,7 +11,7 @@ rule("nzsl.compile.shaders")
-- add commands
batchcmds:show_progress(opt.progress, "${color.build.object}compiling shader %s", shaderfile)
local argv = {"--compile=nzslb", "--partial", "--header-file"}
local argv = {"--compile=nzslb-header", "--partial"}
-- handle --log-format
local kind = target:data("plugin.project.kind") or ""