Minimized shader hash generation; more compatible MultiProgressPrinter

This commit is contained in:
Jack Andersen 2018-04-07 10:52:35 -10:00
parent 1eaa57bba2
commit 396790181a
7 changed files with 33 additions and 10 deletions

View File

@ -26,12 +26,14 @@ class ToolPackage final : public ToolBase
{
if (!hecl::StrCmp(path.getLastComponent().data(), _S("!world.blend")))
AddSelectedItem(path);
#if RUNTIME_ORIGINAL_IDS
else if (!hecl::StrCmp(path.getLastComponent().data(), _S("!original_ids.yaml")))
{
auto pathComps = path.getPathComponents();
if (pathComps.size() == 2 && pathComps[0] != _S("out"))
AddSelectedItem(path);
}
#endif
}
void FindSelectedItems(const hecl::ProjectPath& path, bool checkGeneral)

View File

@ -20,6 +20,8 @@
#include "hecl.hpp"
#define RUNTIME_ORIGINAL_IDS 0
namespace hecl
{
class ClientProcess;

View File

@ -238,11 +238,11 @@ struct IRNode
IRNode(Kind kind, std::string&& str, IRNode&& node, const SourceLocation& loc)
: kind(kind), str(std::move(str)), left(new IRNode(std::move(node))), loc(loc) {}
std::string toString() const { return fmt(0); }
std::string toString(bool stripUVAnims = false) const { return fmt(0, stripUVAnims); }
private:
static std::string rep(int n, std::string_view s);
std::string fmt(int level) const;
std::string fmt(int level, bool stripUVAnims) const;
std::string describe() const;
};

View File

@ -81,6 +81,7 @@ struct Action;
struct Bone;
struct PathMesh;
struct Matrix3f;
struct Matrix4f;
struct PoolSkinIndex;
extern class Token SharedBlenderToken;

View File

@ -239,12 +239,14 @@ void IR::Enumerate<BigDNA::BinarySize>(typename BinarySize::StreamT& sz)
IR Frontend::compileSource(std::string_view source, std::string_view diagName)
{
Hash hash(source);
m_diag.reset(diagName, source);
m_parser.reset(source);
auto insts = m_parser.parse();
IR ir;
ir.m_hash = hash.val64();
std::string stripString;
if (!insts.empty())
stripString = insts.front().toString(true);
ir.m_hash = Hash(stripString).val64();
for (auto& inst : insts)
ir.addInstruction(inst, 0);
return ir;

View File

@ -26,13 +26,29 @@ std::string IRNode::rep(int n, std::string_view s)
return buf;
}
std::string IRNode::fmt(int level) const
std::string IRNode::fmt(int level, bool stripUVAnims) const
{
std::string buf;
auto indent = rep(level, "\t"sv);
switch (kind)
{
case Kind::Call:
if (stripUVAnims && (str == "Texture" || str == "TextureN") && children.size() >= 2)
{
auto it = children.begin();
IRNode& uvNode = const_cast<IRNode&>(*++it);
if (uvNode.str != "UV" && uvNode.str != "Normal" && uvNode.str != "View")
{
std::string replacementName(str);
if (uvNode.str.back() == 'N' && replacementName.back() != 'N')
replacementName += 'N';
IRNode replacementNode(Kind::Call, std::move(replacementName),
std::move(uvNode.children), loc);
auto ret = replacementNode.fmt(level, false);
uvNode.children = std::move(replacementNode.children);
return ret;
}
}
buf.append(indent);
buf.append("Call "sv).append(str);
if (!children.empty())
@ -40,7 +56,7 @@ std::string IRNode::fmt(int level) const
buf.append(" {\n"sv);
for (const IRNode& n : children)
{
buf.append(n.fmt(level + 1));
buf.append(n.fmt(level + 1, stripUVAnims));
buf.append("\n"sv);
}
buf.append(indent);
@ -54,15 +70,15 @@ std::string IRNode::fmt(int level) const
case Kind::Binop:
buf.append(indent);
buf.append("Binop "sv).append(OpToStr(op)).append(" {\n"sv);
buf.append(left->fmt(level + 1)).append("\n"sv);
buf.append(right->fmt(level + 1)).append("\n"sv);
buf.append(left->fmt(level + 1, stripUVAnims)).append("\n"sv);
buf.append(right->fmt(level + 1, stripUVAnims)).append("\n"sv);
buf.append(indent).append("}"sv);
break;
case Kind::Swizzle:
buf.append(indent);
buf.append("Swizzle \""sv).append(str);
buf.append("\" {\n"sv);
buf.append(left->fmt(level + 1)).append("\n"sv);
buf.append(left->fmt(level + 1, stripUVAnims)).append("\n"sv);
buf.append(indent).append("}"sv);
break;
default:

View File

@ -2,7 +2,7 @@
#define BOLD "\033[1m"
#define NORMAL "\033[0m"
#define PREV_LINE "\033[%dF"
#define PREV_LINE "\r\033[%dA"
#define HIDE_CURSOR "\033[?25l"
#define SHOW_CURSOR "\033[?25h"