Replacing std::format with fmt::format
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "MaterialInstance.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Shader.h"
|
||||
#include <fstream>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Descriptor.h"
|
||||
#include <format>
|
||||
#include <fstream>
|
||||
#include <fmt/core.h>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -281,9 +282,9 @@ ConstantExpression::~ConstantExpression()
|
||||
|
||||
std::string ConstantExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string varName = std::format("const_exp_{}", key);
|
||||
std::string varName = fmt::format("const_exp_{}", key);
|
||||
varState[key] = varName;
|
||||
return std::format("let {} = {};\n", varName, expr);
|
||||
return fmt::format("let {} = {};\n", varName, expr);
|
||||
}
|
||||
|
||||
void ConstantExpression::save(ArchiveBuffer& buffer) const
|
||||
@@ -310,9 +311,9 @@ AddExpression::~AddExpression()
|
||||
|
||||
std::string AddExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string varName = std::format("exp_{}", key);
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
return std::format("let {} = {} + {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
|
||||
return fmt::format("let {} = {} + {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
|
||||
}
|
||||
|
||||
void AddExpression::save(ArchiveBuffer& buffer) const
|
||||
@@ -327,9 +328,9 @@ void AddExpression::load(ArchiveBuffer& buffer)
|
||||
|
||||
std::string SubExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string varName = std::format("exp_{}", key);
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
return std::format("let {} = {} - {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
|
||||
return fmt::format("let {} = {} - {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
|
||||
}
|
||||
|
||||
void SubExpression::save(ArchiveBuffer& buffer) const
|
||||
@@ -344,9 +345,9 @@ void SubExpression::load(ArchiveBuffer& buffer)
|
||||
|
||||
std::string MulExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string varName = std::format("exp_{}", key);
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
return std::format("let {} = {} * {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
|
||||
return fmt::format("let {} = {} * {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
|
||||
}
|
||||
|
||||
void MulExpression::save(ArchiveBuffer& buffer) const
|
||||
@@ -361,7 +362,7 @@ void MulExpression::load(ArchiveBuffer& buffer)
|
||||
|
||||
std::string SwizzleExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string varName = std::format("exp_{}", key);
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
std::string swizzle = "";
|
||||
for(uint32 i = 0; i < 4; ++i)
|
||||
{
|
||||
@@ -388,7 +389,7 @@ std::string SwizzleExpression::evaluate(Map<std::string, std::string>& varState)
|
||||
}
|
||||
}
|
||||
varState[key] = varName;
|
||||
return std::format("let {} = {}.{};\n", varName, varState[inputs.at("target").source], swizzle);
|
||||
return fmt::format("let {} = {}.{};\n", varName, varState[inputs.at("target").source], swizzle);
|
||||
}
|
||||
|
||||
void SwizzleExpression::save(ArchiveBuffer& buffer) const
|
||||
@@ -405,9 +406,9 @@ void SwizzleExpression::load(ArchiveBuffer& buffer)
|
||||
|
||||
std::string SampleExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string varName = std::format("exp_{}", key);
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
return std::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source], varState[inputs.at("sampler").source], varState[inputs.at("coords").source]);
|
||||
return fmt::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source], varState[inputs.at("sampler").source], varState[inputs.at("coords").source]);
|
||||
}
|
||||
|
||||
void SampleExpression::save(ArchiveBuffer& buffer) const
|
||||
|
||||
@@ -58,10 +58,10 @@ struct ShaderParameter : public ShaderExpression
|
||||
// update a descriptorset, in case of a uniform buffer, copy the data to the dst + byteOffset
|
||||
virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) = 0;
|
||||
virtual void generateDeclaration(std::ofstream& stream) const = 0;
|
||||
virtual uint64 getIdentifier() const = 0;
|
||||
virtual uint64 getIdentifier() const override = 0;
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
virtual void save(ArchiveBuffer& buffer) const;
|
||||
virtual void load(ArchiveBuffer& buffer);
|
||||
virtual void save(ArchiveBuffer& buffer) const override;
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(ShaderParameter)
|
||||
struct FloatParameter : public ShaderParameter
|
||||
@@ -145,7 +145,7 @@ struct ConstantExpression : public ShaderExpression
|
||||
ConstantExpression();
|
||||
ConstantExpression(std::string expr, ExpressionType type);
|
||||
virtual ~ConstantExpression();
|
||||
virtual uint64 getIdentifier() const { return IDENTIFIER; }
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
virtual void save(ArchiveBuffer& buffer) const override;
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
@@ -156,7 +156,7 @@ struct AddExpression : public ShaderExpression
|
||||
static constexpr uint64 IDENTIFIER = 0x12;
|
||||
AddExpression();
|
||||
virtual ~AddExpression();
|
||||
virtual uint64 getIdentifier() const { return IDENTIFIER; }
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
virtual void save(ArchiveBuffer& buffer) const override;
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
@@ -167,7 +167,7 @@ struct SubExpression : public ShaderExpression
|
||||
static constexpr uint64 IDENTIFIER = 0x13;
|
||||
SubExpression() {}
|
||||
virtual ~SubExpression() {}
|
||||
virtual uint64 getIdentifier() const { return IDENTIFIER; }
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
virtual void save(ArchiveBuffer& buffer) const override;
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
@@ -178,7 +178,7 @@ struct MulExpression : public ShaderExpression
|
||||
static constexpr uint64 IDENTIFIER = 0x14;
|
||||
MulExpression() {}
|
||||
virtual ~MulExpression() {}
|
||||
virtual uint64 getIdentifier() const { return IDENTIFIER; }
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
virtual void save(ArchiveBuffer& buffer) const override;
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
@@ -190,7 +190,7 @@ struct SwizzleExpression : public ShaderExpression
|
||||
StaticArray<int32, 4> comp = {-1, -1, -1, -1};
|
||||
SwizzleExpression() {}
|
||||
virtual ~SwizzleExpression() {}
|
||||
virtual uint64 getIdentifier() const { return IDENTIFIER; }
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
virtual void save(ArchiveBuffer& buffer) const override;
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
@@ -201,7 +201,7 @@ struct SampleExpression : public ShaderExpression
|
||||
static constexpr uint64 IDENTIFIER = 0x16;
|
||||
SampleExpression() {}
|
||||
virtual ~SampleExpression() {}
|
||||
virtual uint64 getIdentifier() const { return IDENTIFIER; }
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
virtual void save(ArchiveBuffer& buffer) const override;
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
|
||||
Reference in New Issue
Block a user