More conservative prewarm shader selection

This commit is contained in:
Jack Andersen 2017-11-01 23:35:07 -10:00
parent f2eb73e20e
commit d301491bd6
4 changed files with 39 additions and 20 deletions

View File

@ -319,10 +319,14 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
/* Binding for each surface */ /* Binding for each surface */
newInst.m_shaderDataBindings.reserve(x0_surfaces->size()); newInst.m_shaderDataBindings.reserve(x0_surfaces->size());
boo::ITexture* texs[8] = {}; boo::ITexture* mbShadowTexs[8] = {g_Renderer->m_ballShadowId,
boo::ITexture* mbShadowTexs[] = {g_Renderer->m_ballShadowId,
g_Renderer->x220_sphereRamp, g_Renderer->x220_sphereRamp,
g_Renderer->m_ballFade}; g_Renderer->m_ballFade,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp};
size_t thisOffs[4]; size_t thisOffs[4];
size_t thisSizes[4]; size_t thisSizes[4];
@ -337,6 +341,14 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
{ {
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx); const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
boo::ITexture* texs[8] = {g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp,
g_Renderer->x220_sphereRamp};
u32 texCount = 0; u32 texCount = 0;
for (atUint32 idx : mat.textureIdxs) for (atUint32 idx : mat.textureIdxs)
{ {
@ -351,7 +363,8 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
else else
{ {
TCachedToken<CTexture>& tex = x1c_textures[idx]; TCachedToken<CTexture>& tex = x1c_textures[idx];
texs[texCount++] = tex.GetObj()->GetBooTexture(); if (boo::ITexture* btex = tex.GetObj()->GetBooTexture())
texs[texCount++] = btex;
} }
} }
@ -375,7 +388,10 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
bool useReflection = mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye(); bool useReflection = mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye();
if (useReflection) if (useReflection)
{ {
if (g_Renderer->x14c_reflectionTex)
texs[texCount] = g_Renderer->x14c_reflectionTex; texs[texCount] = g_Renderer->x14c_reflectionTex;
else
texs[texCount] = g_Renderer->x220_sphereRamp;
thisOffs[3] = curReflect; thisOffs[3] = curReflect;
curReflect += 256; curReflect += 256;
} }
@ -394,39 +410,36 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
int idx = 0; int idx = 0;
for (boo::IShaderPipeline* pipeline : pipelines->m_pipelines) for (boo::IShaderPipeline* pipeline : pipelines->m_pipelines)
{ {
size_t texCount;
boo::ITexture** ltexs; boo::ITexture** ltexs;
if (idx == EExtendedShader::Thermal) if (idx == EExtendedShader::Thermal)
{ {
texCount = 8;
texs[7] = g_Renderer->x220_sphereRamp; texs[7] = g_Renderer->x220_sphereRamp;
ltexs = texs; ltexs = texs;
} }
else if (idx == EExtendedShader::MorphBallShadow) else if (idx == EExtendedShader::MorphBallShadow)
{ {
texCount = 3;
ltexs = mbShadowTexs; ltexs = mbShadowTexs;
} }
else if (idx == EExtendedShader::WorldShadow) else if (idx == EExtendedShader::WorldShadow)
{ {
texCount = 8; if (g_shadowMap)
texs[7] = g_shadowMap; texs[7] = g_shadowMap;
else
texs[7] = g_Renderer->x220_sphereRamp;
ltexs = texs; ltexs = texs;
} }
else if (useReflection) else if (useReflection)
{ {
texCount = mat.textureIdxs.size() + 1;
ltexs = texs; ltexs = texs;
} }
else else
{ {
texCount = mat.textureIdxs.size();
ltexs = texs; ltexs = texs;
} }
extendeds.push_back( extendeds.push_back(
ctx.newShaderDataBinding(pipeline, newInst.GetBooVtxFmt(*this, ctx), ctx.newShaderDataBinding(pipeline, newInst.GetBooVtxFmt(*this, ctx),
newInst.GetBooVBO(*this, ctx), nullptr, m_staticIbo, 4, bufs, newInst.GetBooVBO(*this, ctx), nullptr, m_staticIbo, 4, bufs,
stages, thisOffs, thisSizes, texCount, ltexs, nullptr, nullptr)); stages, thisOffs, thisSizes, 8, ltexs, nullptr, nullptr));
++idx; ++idx;
} }
} }
@ -632,11 +645,15 @@ void CBooModel::WarmupDrawSurface(const CBooSurface& surf) const
return; return;
const ModelInstance& inst = m_instances[m_uniUpdateCount-1]; const ModelInstance& inst = m_instances[m_uniUpdateCount-1];
for (boo::IShaderDataBinding* binding : inst.m_shaderDataBindings[surf.selfIdx]) // Only warmup normal lighting and thermal visor
#if 0
for (int i=1 ; i<=2 ; ++i)
{ {
boo::IShaderDataBinding* binding = inst.m_shaderDataBindings[surf.selfIdx][i];
CGraphics::SetShaderDataBinding(binding); CGraphics::SetShaderDataBinding(binding);
CGraphics::DrawArrayIndexed(surf.m_data.idxStart, std::min(u32(3), surf.m_data.idxCount)); CGraphics::DrawArrayIndexed(surf.m_data.idxStart, std::min(u32(3), surf.m_data.idxCount));
} }
#endif
} }
void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimation& anim) void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimation& anim)

View File

@ -147,11 +147,11 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None); false, true, false, boo::CullMode::None);
m_noTexAlpha = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 1, nullptr, 1, UniNames, m_noTexAlpha = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None); false, true, false, boo::CullMode::None);
m_noTexAdditive = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 1, nullptr, 1, UniNames, m_noTexAdditive = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None); false, true, false, boo::CullMode::None);

View File

@ -143,7 +143,7 @@ struct VulkanParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>:
CSwooshDescription* desc = gen.GetDesc(); CSwooshDescription* desc = gen.GetDesc();
CUVElement* texr = desc->x3c_TEXR.get(); CUVElement* texr = desc->x3c_TEXR.get();
boo::ITexture* textures[] = {texr->GetValueTexture(0).GetObj()->GetBooTexture()}; boo::ITexture* textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr};
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf};
gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat, gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat,

View File

@ -437,7 +437,7 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
//CStreamAudioManager::Start(false, "Audio/rui_samusL.dsp|Audio/rui_samusR.dsp", 0x7f, true, 1.f, 1.f); //CStreamAudioManager::Start(false, "Audio/rui_samusL.dsp|Audio/rui_samusR.dsp", 0x7f, true, 1.f, 1.f);
} }
static logvisor::Module WarmupLog("Shader Warmup"); static logvisor::Module WarmupLog("ShaderWarmup");
void CMain::WarmupShaders() void CMain::WarmupShaders()
{ {
@ -511,7 +511,9 @@ void CMain::Draw()
auto startTime = std::chrono::steady_clock::now(); auto startTime = std::chrono::steady_clock::now();
while (m_warmupIt != m_warmupTags.end()) while (m_warmupIt != m_warmupTags.end())
{ {
WarmupLog.report(logvisor::Info, "Warming %.4s %08X", m_warmupIt->type.getChars(), m_warmupIt->id.Value()); WarmupLog.report(logvisor::Info, "[%d / %d] Warming %.4s %08X",
int(m_warmupIt - m_warmupTags.begin() + 1), int(m_warmupTags.size()),
m_warmupIt->type.getChars(), m_warmupIt->id.Value());
if (m_warmupIt->type == FOURCC('CMDL')) if (m_warmupIt->type == FOURCC('CMDL'))
CModel::WarmupShaders(*m_warmupIt); CModel::WarmupShaders(*m_warmupIt);