Various updates and fixes

This commit is contained in:
Jack Andersen 2015-10-15 14:34:47 -10:00
parent a86b5f8c1d
commit 2034a83576
11 changed files with 305 additions and 133 deletions

View File

@ -21,6 +21,7 @@ struct ToolPassInfo
HECL::SystemString pname;
HECL::SystemString cwd;
std::vector<HECL::SystemString> args;
std::vector<HECL::SystemChar> flags;
HECL::SystemString output;
HECL::Database::Project* project = nullptr;
unsigned verbosityLevel = 0;

View File

@ -14,6 +14,11 @@ public:
ToolCook(const ToolPassInfo& info)
: ToolBase(info), m_useProj(info.project)
{
/* Check for recursive flag */
for (HECL::SystemChar arg : info.flags)
if (arg == _S('r'))
m_recursive = true;
/* Scan args */
if (info.args.size())
{
@ -23,17 +28,6 @@ public:
{
if (arg.empty())
continue;
if (arg.size() >= 2 && arg[0] == _S('-'))
{
switch (arg[1])
{
case _S('r'):
m_recursive = true;
break;
default: break;
}
continue;
}
HECL::SystemString subPath;
HECL::ProjectRootPath root = HECL::SearchForProject(MakePathArgAbsolute(arg, info.cwd), subPath);
if (root)
@ -76,7 +70,7 @@ public:
help.secHead(_S("SYNOPSIS"));
help.beginWrap();
help.wrap(_S("hecl cook [-r] [<pathspec>...]\n"));
help.wrap(_S("hecl cook [-rf] [<pathspec>...]\n"));
help.endWrap();
help.secHead(_S("DESCRIPTION"));
@ -119,6 +113,10 @@ public:
help.beginWrap();
help.wrap(_S("Enables recursive file-matching for cooking entire directories of working files.\n"));
help.endWrap();
help.optionHead(_S("-f"), _S("force"));
help.beginWrap();
help.wrap(_S("Forces cooking of all matched files, ignoring timestamp differences.\n"));
help.endWrap();
}
HECL::SystemString toolName() const {return _S("cook");}
@ -132,7 +130,8 @@ public:
[&lineIdx](const HECL::SystemChar* message,
const HECL::SystemChar* submessage,
int lidx, float factor)
{ToolPrintProgress(message, submessage, lidx, factor, lineIdx);}, m_recursive);
{ToolPrintProgress(message, submessage, lidx, factor, lineIdx);},
m_recursive, m_info.force);
}
return 0;
}

View File

@ -64,8 +64,6 @@ static void printHelp(const HECL::SystemChar* pname)
/* Regex patterns */
static const HECL::SystemRegex regOPEN(_S("-o([^\"]*|\\S*)"), std::regex::ECMAScript|std::regex::optimize);
static const HECL::SystemRegex regVERBOSE(_S("-v(v*)"), std::regex::ECMAScript|std::regex::optimize);
static const HECL::SystemRegex regFORCE(_S("-f"), std::regex::ECMAScript|std::regex::optimize);
/* SIGINT will gracefully close blender connections and delete blends in progress */
static void SIGINTHandler(int sig)
@ -187,32 +185,27 @@ int main(int argc, const char** argv)
++it;
}
/* Count verbosity */
/* Iterate flags */
for (auto it = args.cbegin() ; it != args.cend() ;)
{
const HECL::SystemString& arg = *it;
HECL::SystemRegexMatch vMatch;
if (std::regex_search(arg, vMatch, regVERBOSE))
if (arg.empty() || arg[0] != _S('-'))
{
++info.verbosityLevel;
info.verbosityLevel += vMatch[1].str().size();
it = args.erase(it);
++it;
continue;
}
++it;
}
/* Check force argument */
for (auto it = args.cbegin() ; it != args.cend() ;)
{
const HECL::SystemString& arg = *it;
if (std::regex_search(arg, regFORCE))
for (auto chit = arg.cbegin() + 1 ; chit != arg.cend() ; ++chit)
{
info.force = true;
it = args.erase(it);
continue;
if (*chit == _S('v'))
++info.verbosityLevel;
else if (*chit == _S('f'))
info.force = true;
else
info.flags.push_back(*chit);
}
++it;
it = args.erase(it);
}
/* Gather remaining args */

2
hecl/extern/Athena vendored

@ -1 +1 @@
Subproject commit 418f3e763fed8234ae1498c56dcd574bdd66b020
Subproject commit 25de226e65934377daac37364b53c92a510841ca

View File

@ -35,7 +35,8 @@ struct GX : IBackend
TEVPREV = 0,
TEVREG0 = 1,
TEVREG1 = 2,
TEVREG2 = 3
TEVREG2 = 3,
TEVLAZY = 5
};
enum TevColorArg
@ -55,7 +56,10 @@ struct GX : IBackend
CC_ONE = 12,
CC_HALF = 13,
CC_KONST = 14,
CC_ZERO = 15 /*!< Use to pass zero value */
CC_ZERO = 15, /*!< Use to pass zero value */
/* Non-GX */
CC_LAZY /*!< Lazy register allocation */
};
enum TevAlphaArg
@ -67,7 +71,10 @@ struct GX : IBackend
CA_TEXA = 4, /*!< Use the alpha value from texture */
CA_RASA = 5, /*!< Use the alpha value from rasterizer */
CA_KONST = 6,
CA_ZERO = 7 /*!< Use to pass zero value */
CA_ZERO = 7, /*!< Use to pass zero value */
/* Non-GX */
CA_LAZY /*!< Lazy register allocation */
};
enum TevKColorSel
@ -206,6 +213,9 @@ struct GX : IBackend
TevKColorSel m_kColor = TEV_KCSEL_1;
TevKAlphaSel m_kAlpha = TEV_KASEL_1;
TevRegID m_regOut = TEVPREV;
int m_lazyCInIdx = -1;
int m_lazyAInIdx = -1;
int m_lazyOutIdx = -1;
int m_texMapIdx = -1;
int m_texGenIdx = -1;
@ -216,6 +226,23 @@ struct GX : IBackend
unsigned m_tevCount = 0;
TEVStage m_tevs[16];
int m_cRegMask = 0;
int m_cRegLazy = 0;
int pickCLazy(Diagnostics& diag, const SourceLocation& loc)
{
for (int i=0 ; i<3 ; ++i)
{
if (!(m_cRegMask & (1 << i)))
{
m_cRegMask |= 1 << i;
return i;
}
}
diag.reportBackendErr(loc, "TEV C Register overflow");
return -1;
}
enum BlendFactor
{
BL_ZERO,
@ -301,11 +328,17 @@ private:
unsigned addTexCoordGen(Diagnostics& diag, const SourceLocation& loc,
TexGenSrc src, TexMtx mtx);
TEVStage& addTEVStage(Diagnostics& diag, const SourceLocation& loc);
void PreTraceColor(const IR& ir, Diagnostics& diag,
const IR::Instruction& inst);
void PreTraceAlpha(const IR& ir, Diagnostics& diag,
const IR::Instruction& inst);
TraceResult RecursiveTraceColor(const IR& ir, Diagnostics& diag,
const IR::Instruction& inst);
TraceResult RecursiveTraceAlpha(const IR& ir, Diagnostics& diag,
const IR::Instruction& inst);
unsigned RecursiveTraceTexGen(const IR& ir, Diagnostics& diag, const IR::Instruction& inst, TexMtx mtx);
unsigned RecursiveTraceTexGen(const IR& ir, Diagnostics& diag,
const IR::Instruction& inst,
TexMtx mtx);
};
}

View File

@ -412,7 +412,7 @@ public:
* This method blocks execution during the procedure, with periodic
* feedback delivered via feedbackCb.
*/
bool cookPath(const ProjectPath& path, FProgress feedbackCb, bool recursive=false);
bool cookPath(const ProjectPath& path, FProgress feedbackCb, bool recursive=false, bool force=false);
/**
* @brief Interrupts a cook in progress (call from SIGINT handler)

View File

@ -24,9 +24,12 @@ class Diagnostics
{
std::string m_name;
std::string m_source;
std::string m_backend = "Backend";
std::string sourceDiagString(const SourceLocation& l, bool ansi=false) const;
public:
void reset(const std::string& name, const std::string& source) {m_name = name; m_source = source;}
void setBackend(const std::string& backend) {m_backend = backend;}
void setBackend(const char* backend) {m_backend = backend;}
void reportParserErr(const SourceLocation& l, const char* format, ...);
void reportLexerErr(const SourceLocation& l, const char* format, ...);
void reportCompileErr(const SourceLocation& l, const char* format, ...);

View File

@ -130,6 +130,7 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
{
const IR::Instruction& idxInst = inst.getChildInst(ir, 0);
unsigned idx = unsigned(idxInst.getImmVec().vec[0]);
m_cRegMask |= 1 << idx;
return TraceResult(GX::TevColorArg(CC_C0 + idx * 2));
}
else if (!name.compare("Lighting"))
@ -154,9 +155,36 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
{
ArithmeticOp op = inst.m_arithmetic.m_op;
const IR::Instruction& aInst = inst.getChildInst(ir, 0);
TraceResult aTrace = RecursiveTraceColor(ir, diag, aInst);
const IR::Instruction& bInst = inst.getChildInst(ir, 1);
TraceResult bTrace = RecursiveTraceColor(ir, diag, bInst);
TraceResult aTrace;
TraceResult bTrace;
if (aInst.m_op != IR::OpArithmetic && bInst.m_op == IR::OpArithmetic)
{
bTrace = RecursiveTraceColor(ir, diag, bInst);
aTrace = RecursiveTraceColor(ir, diag, aInst);
}
else
{
aTrace = RecursiveTraceColor(ir, diag, aInst);
bTrace = RecursiveTraceColor(ir, diag, bInst);
}
TevKColorSel newKColor = TEV_KCSEL_1;
if (aTrace.type == TraceResult::TraceTEVKColorSel &&
bTrace.type == TraceResult::TraceTEVKColorSel)
diag.reportBackendErr(inst.m_loc, "unable to handle 2 KColors in one stage");
else if (aTrace.type == TraceResult::TraceTEVKColorSel)
{
newKColor = aTrace.tevKColorSel;
aTrace.type = TraceResult::TraceTEVColorArg;
aTrace.tevColorArg = CC_KONST;
}
else if (bTrace.type == TraceResult::TraceTEVKColorSel)
{
newKColor = bTrace.tevKColorSel;
bTrace.type = TraceResult::TraceTEVColorArg;
bTrace.tevColorArg = CC_KONST;
}
switch (op)
{
@ -168,8 +196,34 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
TEVStage* a = aTrace.tevStage;
TEVStage* b = bTrace.tevStage;
if (b->m_prev != a)
diag.reportBackendErr(inst.m_loc, "TEV stages must have monotonic progression");
b->m_color[3] = CC_CPREV;
{
a->m_regOut = TEVLAZY;
b->m_color[3] = CC_LAZY;
b->m_lazyCInIdx = m_cRegLazy;
a->m_lazyOutIdx = m_cRegLazy++;
}
else
b->m_color[3] = CC_APREV;
return TraceResult(b);
}
else if (aTrace.type == TraceResult::TraceTEVStage &&
bTrace.type == TraceResult::TraceTEVColorArg)
{
TEVStage* a = aTrace.tevStage;
if (a->m_color[3] != CC_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for add combine");
a->m_color[3] = bTrace.tevColorArg;
a->m_kColor = newKColor;
return TraceResult(a);
}
else if (aTrace.type == TraceResult::TraceTEVColorArg &&
bTrace.type == TraceResult::TraceTEVStage)
{
TEVStage* b = bTrace.tevStage;
if (b->m_color[3] != CC_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for add combine");
b->m_color[3] = aTrace.tevColorArg;
b->m_kColor = newKColor;
return TraceResult(b);
}
break;
@ -182,11 +236,28 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
TEVStage* a = aTrace.tevStage;
TEVStage* b = bTrace.tevStage;
if (b->m_prev != a)
diag.reportBackendErr(inst.m_loc, "TEV stages must have monotonic progression");
{
a->m_regOut = TEVLAZY;
b->m_color[3] = CC_LAZY;
b->m_lazyCInIdx = m_cRegLazy;
a->m_lazyOutIdx = m_cRegLazy++;
}
else
b->m_color[3] = CC_APREV;
b->m_op = TEV_SUB;
b->m_color[3] = CC_CPREV;
return TraceResult(b);
}
else if (aTrace.type == TraceResult::TraceTEVStage &&
bTrace.type == TraceResult::TraceTEVColorArg)
{
TEVStage* a = aTrace.tevStage;
if (a->m_color[3] != CC_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for subtract combine");
a->m_color[3] = bTrace.tevColorArg;
a->m_kColor = newKColor;
a->m_op = TEV_SUB;
return TraceResult(a);
}
break;
}
case ArithmeticOp::ArithmeticOpMultiply:
@ -197,12 +268,18 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
TEVStage* a = aTrace.tevStage;
TEVStage* b = bTrace.tevStage;
if (b->m_prev != a)
diag.reportBackendErr(inst.m_loc, "TEV stages must have monotonic progression");
{
a->m_regOut = TEVLAZY;
b->m_color[2] = CC_LAZY;
b->m_lazyCInIdx = m_cRegLazy;
a->m_lazyOutIdx = m_cRegLazy++;
}
else
b->m_color[2] = CC_CPREV;
if (a->m_color[2] != CC_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for multiply combine");
b->m_color[1] = b->m_color[0];
b->m_color[0] = CC_ZERO;
b->m_color[2] = CC_CPREV;
b->m_color[3] = CC_ZERO;
return TraceResult(b);
}
@ -212,6 +289,7 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
TEVStage& stage = addTEVStage(diag, inst.m_loc);
stage.m_color[1] = aTrace.tevColorArg;
stage.m_color[2] = bTrace.tevColorArg;
stage.m_kColor = newKColor;
return TraceResult(&stage);
}
else if (aTrace.type == TraceResult::TraceTEVStage &&
@ -223,6 +301,7 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
a->m_color[1] = a->m_color[0];
a->m_color[0] = CC_ZERO;
a->m_color[2] = bTrace.tevColorArg;
a->m_kColor = newKColor;
return TraceResult(a);
}
else if (aTrace.type == TraceResult::TraceTEVColorArg &&
@ -234,34 +313,7 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
b->m_color[1] = b->m_color[0];
b->m_color[0] = CC_ZERO;
b->m_color[2] = bTrace.tevColorArg;
return TraceResult(b);
}
else if (aTrace.type == TraceResult::TraceTEVStage &&
bTrace.type == TraceResult::TraceTEVKColorSel)
{
TEVStage* a = aTrace.tevStage;
if (a->m_kColor != TEV_KCSEL_1)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for KColor combine");
if (a->m_color[1] != CC_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for multiply combine");
a->m_color[1] = a->m_color[0];
a->m_color[0] = CC_ZERO;
a->m_color[2] = CC_KONST;
a->m_kColor = bTrace.tevKColorSel;
return TraceResult(a);
}
else if (aTrace.type == TraceResult::TraceTEVKColorSel &&
bTrace.type == TraceResult::TraceTEVStage)
{
TEVStage* b = bTrace.tevStage;
if (b->m_kColor != TEV_KCSEL_1)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for KColor combine");
if (b->m_color[1] != CC_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for multiply combine");
b->m_color[1] = b->m_color[0];
b->m_color[0] = CC_ZERO;
b->m_color[2] = CC_KONST;
b->m_kColor = aTrace.tevKColorSel;
b->m_kColor = newKColor;
return TraceResult(b);
}
break;
@ -342,6 +394,7 @@ GX::TraceResult GX::RecursiveTraceAlpha(const IR& ir, Diagnostics& diag, const I
{
const IR::Instruction& idxInst = inst.getChildInst(ir, 0);
unsigned idx = unsigned(idxInst.getImmVec().vec[0]);
m_cRegMask |= 1 << idx;
return TraceResult(GX::TevAlphaArg(CA_A0 + idx));
}
else if (!name.compare("Lighting"))
@ -364,9 +417,36 @@ GX::TraceResult GX::RecursiveTraceAlpha(const IR& ir, Diagnostics& diag, const I
{
ArithmeticOp op = inst.m_arithmetic.m_op;
const IR::Instruction& aInst = inst.getChildInst(ir, 0);
TraceResult aTrace = RecursiveTraceAlpha(ir, diag, aInst);
const IR::Instruction& bInst = inst.getChildInst(ir, 1);
TraceResult bTrace = RecursiveTraceAlpha(ir, diag, bInst);
TraceResult aTrace;
TraceResult bTrace;
if (aInst.m_op != IR::OpArithmetic && bInst.m_op == IR::OpArithmetic)
{
bTrace = RecursiveTraceAlpha(ir, diag, bInst);
aTrace = RecursiveTraceAlpha(ir, diag, aInst);
}
else
{
aTrace = RecursiveTraceAlpha(ir, diag, aInst);
bTrace = RecursiveTraceAlpha(ir, diag, bInst);
}
TevKAlphaSel newKAlpha = TEV_KASEL_1;
if (aTrace.type == TraceResult::TraceTEVKAlphaSel &&
bTrace.type == TraceResult::TraceTEVKAlphaSel)
diag.reportBackendErr(inst.m_loc, "unable to handle 2 KAlphas in one stage");
else if (aTrace.type == TraceResult::TraceTEVKAlphaSel)
{
newKAlpha = aTrace.tevKAlphaSel;
aTrace.type = TraceResult::TraceTEVAlphaArg;
aTrace.tevAlphaArg = CA_KONST;
}
else if (bTrace.type == TraceResult::TraceTEVKAlphaSel)
{
newKAlpha = bTrace.tevKAlphaSel;
bTrace.type = TraceResult::TraceTEVAlphaArg;
bTrace.tevAlphaArg = CA_KONST;
}
switch (op)
{
@ -378,8 +458,39 @@ GX::TraceResult GX::RecursiveTraceAlpha(const IR& ir, Diagnostics& diag, const I
TEVStage* a = aTrace.tevStage;
TEVStage* b = bTrace.tevStage;
if (b->m_prev != a)
diag.reportBackendErr(inst.m_loc, "TEV stages must have monotonic progression");
b->m_alpha[3] = CA_APREV;
{
a->m_regOut = TEVLAZY;
b->m_alpha[3] = CA_LAZY;
if (a->m_lazyOutIdx != -1)
b->m_lazyAInIdx = a->m_lazyOutIdx;
else
{
b->m_lazyAInIdx = m_cRegLazy;
a->m_lazyOutIdx = m_cRegLazy++;
}
}
else
b->m_alpha[3] = CA_APREV;
return TraceResult(b);
}
else if (aTrace.type == TraceResult::TraceTEVStage &&
bTrace.type == TraceResult::TraceTEVAlphaArg)
{
TEVStage* a = aTrace.tevStage;
if (a->m_alpha[3] != CA_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for add combine");
a->m_alpha[3] = bTrace.tevAlphaArg;
a->m_kAlpha = newKAlpha;
return TraceResult(a);
}
else if (aTrace.type == TraceResult::TraceTEVAlphaArg &&
bTrace.type == TraceResult::TraceTEVStage)
{
TEVStage* b = bTrace.tevStage;
if (b->m_alpha[3] != CA_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for add combine");
b->m_alpha[3] = aTrace.tevAlphaArg;
b->m_kAlpha = newKAlpha;
return TraceResult(b);
}
break;
@ -391,13 +502,36 @@ GX::TraceResult GX::RecursiveTraceAlpha(const IR& ir, Diagnostics& diag, const I
{
TEVStage* a = aTrace.tevStage;
TEVStage* b = bTrace.tevStage;
if (b->m_prev != a)
diag.reportBackendErr(inst.m_loc, "TEV stages must have monotonic progression");
if (b->m_op != TEV_SUB)
diag.reportBackendErr(inst.m_loc, "unable to integrate alpha subtraction into stage chain");
b->m_alpha[3] = CA_APREV;
if (b->m_prev != a)
{
a->m_regOut = TEVLAZY;
b->m_alpha[3] = CA_LAZY;
if (a->m_lazyOutIdx != -1)
b->m_lazyAInIdx = a->m_lazyOutIdx;
else
{
b->m_lazyAInIdx = m_cRegLazy;
a->m_lazyOutIdx = m_cRegLazy++;
}
}
else
b->m_alpha[3] = CA_APREV;
return TraceResult(b);
}
else if (aTrace.type == TraceResult::TraceTEVStage &&
bTrace.type == TraceResult::TraceTEVAlphaArg)
{
TEVStage* a = aTrace.tevStage;
if (a->m_op != TEV_SUB)
diag.reportBackendErr(inst.m_loc, "unable to integrate alpha subtraction into stage chain");
if (a->m_alpha[3] != CA_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for add combine");
a->m_alpha[3] = bTrace.tevAlphaArg;
a->m_kAlpha = newKAlpha;
return TraceResult(a);
}
break;
}
case ArithmeticOp::ArithmeticOpMultiply:
@ -408,12 +542,18 @@ GX::TraceResult GX::RecursiveTraceAlpha(const IR& ir, Diagnostics& diag, const I
TEVStage* a = aTrace.tevStage;
TEVStage* b = bTrace.tevStage;
if (b->m_prev != a)
diag.reportBackendErr(inst.m_loc, "TEV stages must have monotonic progression");
{
a->m_regOut = TEVLAZY;
b->m_alpha[2] = CA_LAZY;
b->m_lazyAInIdx = m_cRegLazy;
a->m_lazyOutIdx = m_cRegLazy++;
}
else
b->m_alpha[2] = CA_APREV;
if (a->m_alpha[2] != CA_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for multiply combine");
b->m_alpha[1] = b->m_alpha[0];
b->m_alpha[0] = CA_ZERO;
b->m_alpha[2] = CA_APREV;
b->m_alpha[3] = CA_ZERO;
return TraceResult(b);
}
@ -424,10 +564,11 @@ GX::TraceResult GX::RecursiveTraceAlpha(const IR& ir, Diagnostics& diag, const I
stage.m_color[3] = CC_CPREV;
stage.m_alpha[1] = aTrace.tevAlphaArg;
stage.m_alpha[2] = bTrace.tevAlphaArg;
stage.m_kAlpha = newKAlpha;
return TraceResult(&stage);
}
else if (aTrace.type == TraceResult::TraceTEVStage &&
bTrace.type == TraceResult::TraceTEVColorArg)
bTrace.type == TraceResult::TraceTEVAlphaArg)
{
TEVStage* a = aTrace.tevStage;
if (a->m_alpha[1] != CA_ZERO)
@ -435,9 +576,10 @@ GX::TraceResult GX::RecursiveTraceAlpha(const IR& ir, Diagnostics& diag, const I
a->m_alpha[1] = a->m_alpha[0];
a->m_alpha[0] = CA_ZERO;
a->m_alpha[2] = bTrace.tevAlphaArg;
a->m_kAlpha = newKAlpha;
return TraceResult(a);
}
else if (aTrace.type == TraceResult::TraceTEVColorArg &&
else if (aTrace.type == TraceResult::TraceTEVAlphaArg &&
bTrace.type == TraceResult::TraceTEVStage)
{
TEVStage* b = bTrace.tevStage;
@ -446,34 +588,7 @@ GX::TraceResult GX::RecursiveTraceAlpha(const IR& ir, Diagnostics& diag, const I
b->m_alpha[1] = b->m_alpha[0];
b->m_alpha[0] = CA_ZERO;
b->m_alpha[2] = bTrace.tevAlphaArg;
return TraceResult(b);
}
else if (aTrace.type == TraceResult::TraceTEVStage &&
bTrace.type == TraceResult::TraceTEVKColorSel)
{
TEVStage* a = aTrace.tevStage;
if (a->m_kAlpha != TEV_KASEL_1)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for KAlpha combine");
if (a->m_alpha[1] != CA_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for multiply combine");
a->m_alpha[1] = a->m_alpha[0];
a->m_alpha[0] = CA_ZERO;
a->m_alpha[2] = CA_KONST;
a->m_kAlpha = bTrace.tevKAlphaSel;
return TraceResult(a);
}
else if (aTrace.type == TraceResult::TraceTEVKColorSel &&
bTrace.type == TraceResult::TraceTEVStage)
{
TEVStage* b = bTrace.tevStage;
if (b->m_kAlpha != TEV_KASEL_1)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for KAlpha combine");
if (b->m_alpha[1] != CA_ZERO)
diag.reportBackendErr(inst.m_loc, "unable to modify TEV stage for multiply combine");
b->m_alpha[1] = b->m_alpha[0];
b->m_alpha[0] = CA_ZERO;
b->m_alpha[2] = CA_KONST;
b->m_kAlpha = aTrace.tevKAlphaSel;
b->m_kAlpha = newKAlpha;
return TraceResult(b);
}
break;
@ -497,6 +612,8 @@ void GX::reset(const IR& ir, Diagnostics& diag)
m_tcgCount = 0;
m_texMtxCount = 0;
m_kcolorCount = 0;
m_cRegMask = 0;
m_cRegLazy = 0;
m_alphaTraceStage = -1;
/* Final instruction is the root call by hecl convention */
@ -543,6 +660,32 @@ void GX::reset(const IR& ir, Diagnostics& diag)
for (int i=m_alphaTraceStage+1 ; i<m_tevCount ; ++i)
m_tevs[i].m_alpha[3] = CA_APREV;
}
/* Resolve lazy color/alpha regs */
if (m_cRegLazy)
{
for (int i=0 ; i<m_tevCount ; ++i)
{
TEVStage& stage = m_tevs[i];
if (stage.m_regOut == TEVLAZY)
{
int picked = pickCLazy(diag, SourceLocation());
stage.m_regOut = TevRegID(TEVREG0 + picked);
for (int j=i+1 ; j<m_tevCount ; ++j)
{
TEVStage& nstage = m_tevs[j];
if (nstage.m_lazyCInIdx == stage.m_lazyOutIdx)
for (int c=0 ; c<4 ; ++c)
if (nstage.m_color[c] == CC_LAZY)
nstage.m_color[c] = TevColorArg(CC_C0 + picked * 2);
if (nstage.m_lazyAInIdx == stage.m_lazyOutIdx)
for (int c=0 ; c<4 ; ++c)
if (nstage.m_alpha[c] == CA_LAZY)
nstage.m_alpha[c] = TevAlphaArg(CA_A0 + picked);
}
}
}
}
}
}

View File

@ -362,7 +362,7 @@ public:
using SpecInst = std::pair<const DataSpecEntry*, std::unique_ptr<IDataSpec>>;
static void VisitFile(const ProjectPath& path,
static void VisitFile(const ProjectPath& path, bool force,
std::vector<SpecInst>& specInsts,
CookProgress& progress)
{
@ -371,7 +371,7 @@ static void VisitFile(const ProjectPath& path,
if (spec.second->canCook(path))
{
ProjectPath cooked = path.getCookedPath(*spec.first);
if (cooked.getPathType() == ProjectPath::PT_NONE ||
if (force || cooked.getPathType() == ProjectPath::PT_NONE ||
path.getModtime() > cooked.getModtime())
{
progress.reportFile(spec.first);
@ -381,7 +381,7 @@ static void VisitFile(const ProjectPath& path,
}
}
static void VisitDirectory(const ProjectPath& dir, bool recursive,
static void VisitDirectory(const ProjectPath& dir, bool recursive, bool force,
std::vector<SpecInst>& specInsts,
CookProgress& progress)
{
@ -421,7 +421,7 @@ static void VisitDirectory(const ProjectPath& dir, bool recursive,
case ProjectPath::PT_FILE:
{
progress.changeFile(child.first.c_str(), progNum++/progDenom);
VisitFile(child.second, specInsts, progress);
VisitFile(child.second, force, specInsts, progress);
break;
}
case ProjectPath::PT_LINK:
@ -430,7 +430,7 @@ static void VisitDirectory(const ProjectPath& dir, bool recursive,
if (target.getPathType() == ProjectPath::PT_FILE)
{
progress.changeFile(target.getLastComponent(), progNum++/progDenom);
VisitFile(target, specInsts, progress);
VisitFile(target, force, specInsts, progress);
}
break;
}
@ -448,7 +448,7 @@ static void VisitDirectory(const ProjectPath& dir, bool recursive,
{
case ProjectPath::PT_DIRECTORY:
{
VisitDirectory(child.second, recursive, specInsts, progress);
VisitDirectory(child.second, recursive, force, specInsts, progress);
break;
}
default: break;
@ -457,7 +457,7 @@ static void VisitDirectory(const ProjectPath& dir, bool recursive,
}
}
static void VisitGlob(const ProjectPath& path, bool recursive,
static void VisitGlob(const ProjectPath& path, bool recursive, bool force,
std::vector<SpecInst>& specInsts,
CookProgress& progress)
{
@ -497,7 +497,7 @@ static void VisitGlob(const ProjectPath& path, bool recursive,
case ProjectPath::PT_FILE:
{
progress.changeFile(child.getLastComponent(), progNum++/progDenom);
VisitFile(child, specInsts, progress);
VisitFile(child, force, specInsts, progress);
break;
}
case ProjectPath::PT_LINK:
@ -506,7 +506,7 @@ static void VisitGlob(const ProjectPath& path, bool recursive,
if (target.getPathType() == ProjectPath::PT_FILE)
{
progress.changeFile(target.getLastComponent(), progNum++/progDenom);
VisitFile(target, specInsts, progress);
VisitFile(target, force, specInsts, progress);
}
break;
}
@ -524,7 +524,7 @@ static void VisitGlob(const ProjectPath& path, bool recursive,
{
case ProjectPath::PT_DIRECTORY:
{
VisitDirectory(child, recursive, specInsts, progress);
VisitDirectory(child, recursive, force, specInsts, progress);
break;
}
default: break;
@ -533,7 +533,7 @@ static void VisitGlob(const ProjectPath& path, bool recursive,
}
}
bool Project::cookPath(const ProjectPath& path, FProgress progress, bool recursive)
bool Project::cookPath(const ProjectPath& path, FProgress progress, bool recursive, bool force)
{
/* Construct DataSpec instances for cooking */
std::vector<SpecInst> specInsts;
@ -550,7 +550,7 @@ bool Project::cookPath(const ProjectPath& path, FProgress progress, bool recursi
case ProjectPath::PT_FILE:
{
cookProg.changeFile(path.getLastComponent(), 0.0);
VisitFile(path, specInsts, cookProg);
VisitFile(path, force, specInsts, cookProg);
break;
}
case ProjectPath::PT_LINK:
@ -559,18 +559,18 @@ bool Project::cookPath(const ProjectPath& path, FProgress progress, bool recursi
if (target.getPathType() == ProjectPath::PT_FILE)
{
cookProg.changeFile(target.getLastComponent(), 0.0);
VisitFile(target, specInsts, cookProg);
VisitFile(target, force, specInsts, cookProg);
}
break;
}
case ProjectPath::PT_DIRECTORY:
{
VisitDirectory(path, recursive, specInsts, cookProg);
VisitDirectory(path, recursive, force, specInsts, cookProg);
break;
}
case ProjectPath::PT_GLOB:
{
VisitGlob(path, recursive, specInsts, cookProg);
VisitGlob(path, recursive, force, specInsts, cookProg);
break;
}
default: break;

View File

@ -123,11 +123,11 @@ void Diagnostics::reportBackendErr(const SourceLocation& l, const char* fmt, ...
#endif
va_end(ap);
if (LogVisor::XtermColor)
LogModule.report(LogVisor::FatalError, CYAN "[Backend]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s",
m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str());
LogModule.report(LogVisor::FatalError, CYAN "[%s]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s",
m_backend.c_str(), m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str());
else
LogModule.report(LogVisor::FatalError, "[Backend] %s @%d:%d\n%s\n%s",
m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str());
LogModule.report(LogVisor::FatalError, "[%s] %s @%d:%d\n%s\n%s",
m_backend.c_str(), m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str());
free(result);
}

View File

@ -337,7 +337,7 @@ void Lexer::consumeAllTokens(Parser& parser)
}
}
if (HECL::VerbosityLevel)
if (HECL::VerbosityLevel > 1)
{
printf("%s\n", m_diag.getSource().c_str());
PrintTree(firstNode);