Function-scope statics aren't as efficient as file-scope ones

This commit is contained in:
Jack Andersen 2016-04-14 17:26:01 -10:00
parent c91bfade75
commit 86c21a77ac
12 changed files with 70 additions and 66 deletions

View File

@ -352,27 +352,28 @@ static const uint8_t* DecodePaletteSPLT(png_structrp png, png_infop info,
return data;
}
static const png_color C4Colors[] =
{
{0,0,0},
{155,0,0},
{0,155,0},
{0,0,155},
{155,155,0},
{155,0,155},
{0,155,155},
{155,155,155},
{55,55,55},
{255,0,0},
{0,255,0},
{0,0,255},
{255,255,0},
{255,0,255},
{0,255,255},
{255,255,255}
};
static void C4Palette(png_structrp png, png_infop info)
{
static const png_color C4Colors[] =
{
{0,0,0},
{155,0,0},
{0,155,0},
{0,0,155},
{155,155,0},
{155,0,155},
{0,155,155},
{155,155,155},
{55,55,55},
{255,0,0},
{0,255,0},
{0,0,255},
{255,255,0},
{255,0,255},
{0,255,255},
{255,255,255}
};
png_set_PLTE(png, info, C4Colors, 16);
}

View File

@ -40,6 +40,11 @@ SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Databas
DataSpec::UniqueIDBridge::setGlobalProject(m_project);
}
static const hecl::SystemString regNONE = _S("");
static const hecl::SystemString regE = _S("NTSC");
static const hecl::SystemString regJ = _S("NTSC-J");
static const hecl::SystemString regP = _S("PAL");
bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport>& reps)
{
m_disc = nod::OpenDiscFromImage(info.srcpath.c_str(), m_isWii);
@ -67,10 +72,6 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport
return false;
char region = m_disc->getHeader().m_gameID[3];
static const hecl::SystemString regNONE = _S("");
static const hecl::SystemString regE = _S("NTSC");
static const hecl::SystemString regJ = _S("NTSC-J");
static const hecl::SystemString regP = _S("PAL");
const hecl::SystemString* regstr = &regNONE;
switch (region)
{

View File

@ -15,6 +15,16 @@ static int CountBits(uint32_t n)
return ret;
}
static const int DIMS[] =
{
16,
32,
48,
64,
128,
0
};
int main(int argc, char* argv[])
{
if (argc < 2)
@ -32,16 +42,6 @@ int main(int argc, char* argv[])
png_bytep row = malloc(4 * 128);
static const int DIMS[] =
{
16,
32,
48,
64,
128,
0
};
char command[2048];
for (const int* d = DIMS ; *d != 0 ; ++d)

View File

@ -113,21 +113,25 @@ void CPlayerState::PutTo(CBitStreamWriter &stream)
stream.WriteEncoded(x184_, CBitStreamWriter::GetBitCount(0x100));
}
static const float unk[]
{
0.2f, 0.1f, 0.2f, 0.2f, 1.f
};
float CPlayerState::sub_80091204() const
{
static const float unk[] {
0.2f, 0.1f, 0.2f, 0.2f, 1.f
};
return unk[u32(x8_currentBeam)];
}
static const u32 costs[]
{
5, 10, 10, 10, 1
};
u32 CPlayerState::GetMissileCostForAltAttack() const
{
static const u32 costs[] {
5, 10, 10, 10, 1
};
return costs[u32(x8_currentBeam)];
}

View File

@ -131,6 +131,11 @@ void CGraphics::SetModelMatrix(const zeus::CTransform& xf)
SetViewMatrix();
}
static const zeus::CMatrix4f PlusOneZ(1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
0.f, 0.f, 1.f, 1.f,
0.f, 0.f, 0.f, 1.f);
zeus::CMatrix4f CGraphics::CalculatePerspectiveMatrix(float fovy, float aspect,
float near, float far,
bool forRenderer)
@ -177,11 +182,6 @@ zeus::CMatrix4f CGraphics::CalculatePerspectiveMatrix(float fovy, float aspect,
0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, st.x18_far / fmn, st.x14_near * st.x18_far / fmn,
0.f, 0.f, -1.f, 0.f);
static const zeus::CMatrix4f PlusOneZ(1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
0.f, 0.f, 1.f, 1.f,
0.f, 0.f, 0.f, 1.f);
return PlusOneZ * mat2;
}
}
@ -222,11 +222,6 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer)
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, g_Proj.x18_far / fmn, g_Proj.x14_near * g_Proj.x18_far / fmn,
0.f, 0.f, -1.f, 0.f);
static const zeus::CMatrix4f PlusOneZ(1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
0.f, 0.f, 1.f, 1.f,
0.f, 0.f, 0.f, 1.f);
return PlusOneZ * mat2;
}
}

View File

@ -41,12 +41,13 @@ static const char* LightingGLSL =
" return clamp(ret, vec4(0.0,0.0,0.0,0.0), vec4(1.0,1.0,1.0,1.0));\n"
"}\n";
static const char* BlockNames[] = {HECL_GLSL_VERT_UNIFORM_BLOCK_NAME,
HECL_GLSL_TEXMTX_UNIFORM_BLOCK_NAME,
"LightingUniform"};
hecl::Runtime::ShaderCacheExtensions
CModelShaders::GetShaderExtensionsGLSL(boo::IGraphicsDataFactory::Platform plat)
{
static const char* BlockNames[] = {HECL_GLSL_VERT_UNIFORM_BLOCK_NAME,
HECL_GLSL_TEXMTX_UNIFORM_BLOCK_NAME,
"LightingUniform"};
hecl::Runtime::ShaderCacheExtensions ext(plat);
ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {}, 3, BlockNames);
return ext;

View File

@ -40,10 +40,11 @@ static const char* LightingMetal =
" return saturate(ret);\n"
"}\n";
static const char* BlockNames[] = {"LightingUniform"};
hecl::Runtime::ShaderCacheExtensions
CModelShaders::GetShaderExtensionsMetal(boo::IGraphicsDataFactory::Platform plat)
{
static const char* BlockNames[] = {"LightingUniform"};
hecl::Runtime::ShaderCacheExtensions ext(plat);
ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {}, 1, BlockNames);
return ext;

View File

@ -188,10 +188,10 @@ static u32 StaticLoopEnd = 0;
static g72x_state StaticStateLeft = {};
static g72x_state StaticStateRight = {};
static const char* BlockNames[] = {"SpecterViewBlock"};
void CMoviePlayer::Initialize()
{
static const char* BlockNames[] = {"SpecterViewBlock"};
GraphicsData = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
if (!ctx.bindingNeedsVertexFormat())

View File

@ -270,6 +270,13 @@ void CElementGen::Shutdown()
CElementGenShaders::Shutdown();
}
static const size_t ShadClsSizes[] =
{
sizeof(SParticleInstanceTex),
sizeof(SParticleInstanceIndTex),
sizeof(SParticleInstanceNoTex)
};
CElementGen::CElementGen(const TToken<CGenDescription>& gen,
EModelOrientationType orientType,
EOptionalSystemFlags flags)
@ -442,12 +449,6 @@ CElementGen::CElementGen(const TToken<CGenDescription>& gen,
else
{
m_shaderClass = CElementGenShaders::GetShaderClass(*this);
static const size_t ShadClsSizes[] =
{
sizeof(SParticleInstanceTex),
sizeof(SParticleInstanceIndTex),
sizeof(SParticleInstanceNoTex)
};
size_t maxInsts = x224_29_MBLR ? (m_maxMBSP * x70_MAXP) : x70_MAXP;
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{

View File

@ -267,10 +267,10 @@ struct OGLElementDataBindingFactory : CElementGenShaders::IDataBindingFactory
}
};
static const char* UniNames[] = {"ParticleUniform"};
CElementGenShaders::IDataBindingFactory* CElementGenShaders::Initialize(boo::GLDataFactory::Context& ctx)
{
static const char* UniNames[] = {"ParticleUniform"};
m_texZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, "texs", 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, true, true, false);

2
hecl

@ -1 +1 @@
Subproject commit 4c309862829daf1c6c27833ecdf03d86eae23941
Subproject commit 3a48b3b05afacbf61cb5801fa1aa96567aa42a35

@ -1 +1 @@
Subproject commit 65cdadfe16cbb63c0f7d9408e822af31b9d8dab7
Subproject commit e40a836ea15a2a2c06a2a8c8ba511db23d4395de