2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

Implement tessellation shader for HLSL

This commit is contained in:
Jack Andersen
2018-06-07 15:15:46 -10:00
parent 1456026875
commit 8f9d7da3ee
17 changed files with 403 additions and 59 deletions

View File

@@ -164,10 +164,14 @@ CElementGen::CElementGen(const TToken<CGenDescription>& gen,
else
x268_PSLT = INT_MAX;
int useMAXP = 256;
if (CIntElement* maxpElem = desc->x28_x1c_MAXP.get())
{
maxpElem->GetValue(x74_curFrame, x90_MAXP);
useMAXP = maxpElem->GetMaxValue();
}
int useMAXP = std::min(x90_MAXP, 256);
useMAXP = std::min(useMAXP, 256);
x30_particles.reserve(useMAXP);
if (x2c_orientType == EModelOrientationType::One)
x50_parentMatrices.resize(useMAXP);
@@ -231,7 +235,7 @@ CElementGen::CElementGen(const TToken<CGenDescription>& gen,
m_shaderClass = CElementGenShaders::GetShaderClass(*this);
}
size_t maxInsts = x26c_30_MBLR ? (m_maxMBSP * x90_MAXP) : x90_MAXP;
size_t maxInsts = x26c_30_MBLR ? (m_maxMBSP * useMAXP) : useMAXP;
maxInsts = (maxInsts == 0 ? 256 : maxInsts);
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)

View File

@@ -60,6 +60,15 @@ bool CIEKeyframeEmitter::GetValue(int frame, int& valOut) const
return false;
}
int CIEKeyframeEmitter::GetMaxValue() const
{
int maxVal = INT_MIN;
for (int k : x18_keys)
if (k > maxVal)
maxVal = k;
return maxVal;
}
bool CIEDeath::GetValue(int frame, int &valOut) const
{
x4_a->GetValue(frame, valOut);
@@ -69,6 +78,11 @@ bool CIEDeath::GetValue(int frame, int &valOut) const
return frame > b;
}
int CIEDeath::GetMaxValue() const
{
return x4_a->GetMaxValue();
}
bool CIEClamp::GetValue(int frame, int& valOut) const
{
int a, b;
@@ -82,6 +96,19 @@ bool CIEClamp::GetValue(int frame, int& valOut) const
return false;
}
int CIEClamp::GetMaxValue() const
{
int a, b, valOut;
a = x4_min->GetMaxValue();
b = x8_max->GetMaxValue();
valOut = xc_val->GetMaxValue();
if (valOut > b)
valOut = b;
if (valOut < a)
valOut = a;
return valOut;
}
bool CIETimeChain::GetValue(int frame, int& valOut) const
{
int v;
@@ -92,6 +119,11 @@ bool CIETimeChain::GetValue(int frame, int& valOut) const
return x4_a->GetValue(frame, valOut);
}
int CIETimeChain::GetMaxValue() const
{
return std::max(x8_b->GetMaxValue(), x4_a->GetMaxValue());
}
bool CIEAdd::GetValue(int frame, int& valOut) const
{
int a, b;
@@ -101,12 +133,25 @@ bool CIEAdd::GetValue(int frame, int& valOut) const
return false;
}
int CIEAdd::GetMaxValue() const
{
int a, b;
a = x4_a->GetMaxValue();
b = x8_b->GetMaxValue();
return a + b;
}
bool CIEConstant::GetValue(int frame, int& valOut) const
{
valOut = x4_val;
return false;
}
int CIEConstant::GetMaxValue() const
{
return x4_val;
}
bool CIEImpulse::GetValue(int frame, int& valOut) const
{
if (frame == 0)
@@ -116,15 +161,28 @@ bool CIEImpulse::GetValue(int frame, int& valOut) const
return false;
}
int CIEImpulse::GetMaxValue() const
{
return x4_a->GetMaxValue();
}
bool CIELifetimePercent::GetValue(int frame, int& valOut) const
{
int a;
x4_percentVal->GetValue(frame, a);
a = std::max(0, a);
valOut = (a / 100.0f) * CParticleGlobals::g_ParticleLifetimeReal;
valOut = (a / 100.0f) * CParticleGlobals::g_ParticleLifetimeReal + 0.5f;
return false;
}
int CIELifetimePercent::GetMaxValue() const
{
int a;
a = x4_percentVal->GetMaxValue();
a = std::max(0, a);
return (a / 100.0f) * 10000 + 0.5f; /* Assume 10000 frames max (not ideal estimate) */
}
bool CIEInitialRandom::GetValue(int frame, int& valOut) const
{
if (frame == 0)
@@ -137,6 +195,11 @@ bool CIEInitialRandom::GetValue(int frame, int& valOut) const
return false;
}
int CIEInitialRandom::GetMaxValue() const
{
return x8_b->GetMaxValue();
}
bool CIEPulse::GetValue(int frame, int& valOut) const
{
int a, b;
@@ -158,6 +221,10 @@ bool CIEPulse::GetValue(int frame, int& valOut) const
return false;
}
int CIEPulse::GetMaxValue() const
{
return std::max(xc_aVal->GetMaxValue(), x10_bVal->GetMaxValue());
}
bool CIEMultiply::GetValue(int frame, int& valOut) const
{
@@ -168,6 +235,11 @@ bool CIEMultiply::GetValue(int frame, int& valOut) const
return false;
}
int CIEMultiply::GetMaxValue() const
{
return x4_a->GetMaxValue() * x8_b->GetMaxValue();
}
bool CIESampleAndHold::GetValue(int frame, int& valOut) const
{
if (x8_nextSampleFrame < frame)
@@ -185,6 +257,11 @@ bool CIESampleAndHold::GetValue(int frame, int& valOut) const
return false;
}
int CIESampleAndHold::GetMaxValue() const
{
return x4_sampleSource->GetMaxValue();
}
bool CIERandom::GetValue(int frame, int& valOut) const
{
int a, b;
@@ -197,6 +274,14 @@ bool CIERandom::GetValue(int frame, int& valOut) const
return false;
}
int CIERandom::GetMaxValue() const
{
if (x4_min->GetMaxValue() > 0)
return x8_max->GetMaxValue();
else
return 65535;
}
bool CIETimeScale::GetValue(int frame, int& valOut) const
{
float a;
@@ -205,24 +290,44 @@ bool CIETimeScale::GetValue(int frame, int& valOut) const
return false;
}
int CIETimeScale::GetMaxValue() const
{
return 10000; /* Assume 10000 frames max (not ideal estimate) */
}
bool CIEGetCumulativeParticleCount::GetValue(int frame, int& valOut) const
{
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetCumulativeParticleCount();
return false;
}
int CIEGetCumulativeParticleCount::GetMaxValue() const
{
return 256;
}
bool CIEGetActiveParticleCount::GetValue(int frame, int &valOut) const
{
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetParticleCount();
return false;
}
int CIEGetActiveParticleCount::GetMaxValue() const
{
return 256;
}
bool CIEGetEmitterTime::GetValue(int frame, int &valOut) const
{
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetEmitterTime();
return false;
}
int CIEGetEmitterTime::GetMaxValue() const
{
return 10000; /* Assume 10000 frames max (not ideal estimate) */
}
bool CIEModulo::GetValue(int frame, int& valOut) const
{
int a, b;
@@ -235,6 +340,17 @@ bool CIEModulo::GetValue(int frame, int& valOut) const
return false;
}
int CIEModulo::GetMaxValue() const
{
int a, b;
a = x4_a->GetMaxValue();
b = x8_b->GetMaxValue();
if (b != 0)
return b - 1;
else
return a;
}
bool CIESubtract::GetValue(int frame, int& valOut) const
{
int a, b;
@@ -244,4 +360,12 @@ bool CIESubtract::GetValue(int frame, int& valOut) const
return false;
}
int CIESubtract::GetMaxValue() const
{
int a, b;
a = x4_a->GetMaxValue();
b = x8_b->GetMaxValue();
return a - b;
}
}

View File

@@ -20,6 +20,7 @@ class CIEKeyframeEmitter : public CIntElement
public:
CIEKeyframeEmitter(CInputStream& in);
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEDeath : public CIntElement
@@ -30,6 +31,7 @@ public:
CIEDeath(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEClamp : public CIntElement
@@ -41,6 +43,7 @@ public:
CIEClamp(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
: x4_min(std::move(a)), x8_max(std::move(b)), xc_val(std::move(c)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIETimeChain : public CIntElement
@@ -52,6 +55,7 @@ public:
CIETimeChain(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
: x4_a(std::move(a)), x8_b(std::move(b)), xc_swFrame(std::move(c)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEAdd : public CIntElement
@@ -62,6 +66,7 @@ public:
CIEAdd(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEConstant : public CIntElement
@@ -70,6 +75,7 @@ class CIEConstant : public CIntElement
public:
CIEConstant(int val) : x4_val(val) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEImpulse : public CIntElement
@@ -79,6 +85,7 @@ public:
CIEImpulse(std::unique_ptr<CIntElement>&& a)
: x4_a(std::move(a)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIELifetimePercent : public CIntElement
@@ -88,6 +95,7 @@ public:
CIELifetimePercent(std::unique_ptr<CIntElement>&& a)
: x4_percentVal(std::move(a)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEInitialRandom : public CIntElement
@@ -98,6 +106,7 @@ public:
CIEInitialRandom(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEPulse : public CIntElement
@@ -111,6 +120,7 @@ public:
std::unique_ptr<CIntElement>&& c, std::unique_ptr<CIntElement>&& d)
: x4_aDuration(std::move(a)), x8_bDuration(std::move(b)), xc_aVal(std::move(c)), x10_bVal(std::move(d)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEMultiply : public CIntElement
@@ -121,6 +131,7 @@ public:
CIEMultiply(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIESampleAndHold : public CIntElement
@@ -135,6 +146,7 @@ public:
std::unique_ptr<CIntElement>&& c)
: x4_sampleSource(std::move(a)), xc_waitFramesMin(std::move(b)), x10_waitFramesMax(std::move(c)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIERandom : public CIntElement
@@ -145,6 +157,7 @@ public:
CIERandom(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_min(std::move(a)), x8_max(std::move(b)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIETimeScale : public CIntElement
@@ -154,24 +167,28 @@ public:
CIETimeScale(std::unique_ptr<CRealElement>&& a)
: x4_a(std::move(a)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEGetCumulativeParticleCount : public CIntElement
{
public:
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIEGetActiveParticleCount : public CIntElement
{
public:
bool GetValue(int frame, int &valOut) const;
int GetMaxValue() const;
};
class CIEGetEmitterTime : public CIntElement
{
public:
bool GetValue(int frame, int &valOut) const;
int GetMaxValue() const;
};
class CIEModulo : public CIntElement
@@ -182,6 +199,7 @@ public:
CIEModulo(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
class CIESubtract : public CIntElement
@@ -192,6 +210,7 @@ public:
CIESubtract(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const;
int GetMaxValue() const;
};
}

View File

@@ -27,6 +27,7 @@ class CIntElement : public IElement
{
public:
virtual bool GetValue(int frame, int& valOut) const=0;
virtual int GetMaxValue() const=0;
};
class CVectorElement : public IElement