More efficient cooked resource loading, AQS audio fixes

This commit is contained in:
Jack Andersen 2017-02-14 20:02:30 -10:00
parent 59406a069b
commit 4e01787e09
12 changed files with 94 additions and 68 deletions

View File

@ -474,6 +474,13 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& t
return;
}
/* Cached resolve (try PC first, then original) */
m_cookedPath = path.getCookedPath(*m_parent.m_pcSpec);
if (!m_cookedPath.isFile())
m_cookedPath = path.getCookedPath(*m_parent.m_origSpec);
if (!m_cookedPath.isFile() ||
m_cookedPath.getModtime() < path.getModtime())
{
/* Last chance type validation */
urde::SObjectTag verifyTag = m_parent.TagFromPath(path, hecl::SharedBlenderToken);
if (verifyTag.type != tag.type)
@ -496,6 +503,7 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& t
m_cookTransaction = m_parent.m_clientProc.addCookTransaction(path, m_parent.m_cookSpec.get());
return;
}
}
CookComplete();
}
@ -544,7 +552,8 @@ bool ProjectResourceFactoryBase::AsyncTask::AsyncPump()
return m_failed;
}
bool ProjectResourceFactoryBase::WaitForTagReady(const urde::SObjectTag& tag, const hecl::ProjectPath*& pathOut)
bool ProjectResourceFactoryBase::WaitForTagReady(const urde::SObjectTag& tag,
const hecl::ProjectPath*& pathOut)
{
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
auto search = m_tagToPath.find(tag);
@ -585,6 +594,13 @@ ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag,
return false;
}
/* Cached resolve (try PC first, then original) */
hecl::ProjectPath cooked = path.getCookedPath(*m_pcSpec);
if (!cooked.isFile())
cooked = path.getCookedPath(*m_origSpec);
if (!cooked.isFile() ||
cooked.getModtime() < path.getModtime())
{
/* Last chance type validation */
urde::SObjectTag verifyTag = TagFromPath(path, hecl::SharedBlenderToken);
if (verifyTag.type != tag.type)
@ -596,7 +612,7 @@ ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag,
}
/* Get cooked representation path */
hecl::ProjectPath cooked = GetCookedPath(path, true);
cooked = GetCookedPath(path, true);
/* Perform mod-time comparison */
if (!cooked.isFile() ||
@ -610,6 +626,7 @@ ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag,
return false;
}
}
}
/* Ensure cooked rep is on the filesystem */
fr.emplace(cooked.getAbsolutePath(), 32 * 1024, false);
@ -685,7 +702,8 @@ ProjectResourceFactoryBase::BuildAsyncInternal(const urde::SObjectTag& tag,
{
if (m_asyncLoadList.find(tag) != m_asyncLoadList.end())
return {};
return m_asyncLoadList.emplace(std::make_pair(tag, std::make_unique<AsyncTask>(*this, tag, objOut, paramXfer, selfRef))).first->second;
return m_asyncLoadList.emplace(std::make_pair(tag,
std::make_unique<AsyncTask>(*this, tag, objOut, paramXfer, selfRef))).first->second;
}
void ProjectResourceFactoryBase::BuildAsync(const urde::SObjectTag& tag,
@ -725,7 +743,8 @@ ProjectResourceFactoryBase::LoadResourceAsync(const urde::SObjectTag& tag,
Log.report(logvisor::Fatal, "attempted to access null id");
if (m_asyncLoadList.find(tag) != m_asyncLoadList.end())
return {};
return m_asyncLoadList.emplace(std::make_pair(tag, std::make_shared<AsyncTask>(*this, tag, target))).first->second;
return m_asyncLoadList.emplace(std::make_pair(tag,
std::make_shared<AsyncTask>(*this, tag, target))).first->second;
}
std::shared_ptr<ProjectResourceFactoryBase::AsyncTask>
@ -737,7 +756,8 @@ ProjectResourceFactoryBase::LoadResourcePartAsync(const urde::SObjectTag& tag,
Log.report(logvisor::Fatal, "attempted to access null id");
if (m_asyncLoadList.find(tag) != m_asyncLoadList.end())
return {};
return m_asyncLoadList.emplace(std::make_pair(tag, std::make_shared<AsyncTask>(*this, tag, target, size, off))).first->second;
return m_asyncLoadList.emplace(std::make_pair(tag,
std::make_shared<AsyncTask>(*this, tag, target, size, off))).first->second;
}
std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadResourceSync(const urde::SObjectTag& tag)
@ -904,8 +924,8 @@ void ProjectResourceFactoryBase::AsyncIdle()
for (auto it=m_asyncLoadList.begin() ; it != m_asyncLoadList.end() ;)
{
/* Allow 8 milliseconds (roughly 1/2 frame-time) for each async build cycle */
if (std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start).count() > 8)
std::chrono::steady_clock::time_point resStart = std::chrono::steady_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(resStart - start).count() > 8)
break;
/* Ensure requested resource is in the index */
@ -961,6 +981,7 @@ void ProjectResourceFactoryBase::AsyncIdle()
u32(task.x0_tag.id));
}
}
it = m_asyncLoadList.erase(it);
continue;
}

View File

@ -176,12 +176,6 @@ void ViewManager::TestGameView::draw(boo::IGraphicsCommandQueue *gfxQ)
m_vm.m_moviePlayer->DrawFrame();
}
if (m_frame == 300)
g_GameState->GetWorldTransitionManager()->PleaseStopSoon();
//g_GameState->GetWorldTransitionManager()->Update(1.f / 60.f);
//g_GameState->GetWorldTransitionManager()->Draw();
m_vm.m_projManager.mainDraw();
++m_frame;
@ -415,9 +409,8 @@ bool ViewManager::proc()
m_rootView->draw(gfxQ);
CGraphics::EndScene();
gfxQ->execute();
m_voiceEngine->pumpAndMixVoices();
m_projManager.asyncIdle();
m_mainWindow->waitForRetrace();
m_mainWindow->waitForRetrace(m_voiceEngine.get());
CBooModel::ClearModelUniformCounters();
CGraphics::TickRenderTimings();
return true;

View File

@ -322,6 +322,8 @@ u16 CSfxManager::TranslateSFXID(u16 id)
void CSfxManager::StopSound(const CSfxHandle& handle)
{
if (!handle)
return;
m_doUpdate = true;
if (handle->IsPlaying())
handle->Stop();

View File

@ -307,7 +307,7 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer)
{
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml,
0.f, 2.f / tmb, 0.f, -tpb / tmb,
0.f, 0.f, 1.f / fmn, -g_Proj.x14_near / fmn,
0.f, 0.f, 1.f / fmn, g_Proj.x14_near / fmn,
0.f, 0.f, 0.f, 1.f);
return PlusOneZ * mat2;
}
@ -315,7 +315,7 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer)
{
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml,
0.f, 2.f / tmb, 0.f, -tpb / tmb,
0.f, 0.f, 1.f / fmn, -g_Proj.x14_near / fmn,
0.f, 0.f, 1.f / fmn, g_Proj.x14_near / fmn,
0.f, 0.f, 0.f, 1.f);
return PlusOneZFlip * mat2;
}

View File

@ -19,13 +19,6 @@ private:
EProjection xf8_proj;
union
{
struct
{
float xfc_fov;
float x100_aspect;
float x104_znear;
float x108_zfar;
};
struct
{
float xfc_left;
@ -35,6 +28,13 @@ private:
float x10c_znear;
float x110_zfar;
};
struct
{
float xfc_fov;
float x100_aspect;
float x104_znear;
float x108_zfar;
};
};
public:
CGuiCamera(const CGuiWidgetParms& parms, float left, float right,

View File

@ -268,6 +268,8 @@ bool CGuiTextSupport::_GetIsTextSupportFinishedLoading() const
if (!tok.IsLoaded())
return false;
}
if (!x2cc_font)
return true;
if (x2cc_font.IsLoaded())
return x2cc_font->IsFinishedLoading();
return false;

View File

@ -295,7 +295,7 @@ void CTextExecuteBuffer::TerminateLine()
void CTextExecuteBuffer::TerminateLineLTR()
{
if (!xa4_curLine->xc_curY && x18_textState.IsFinishedLoading())
if (!xa4_curLine->xc_curY /*&& x18_textState.IsFinishedLoading()*/)
{
xa4_curLine->xc_curY = std::max(xa4_curLine->GetHeight(),
x18_textState.x48_font->GetCarriageAdvance());

View File

@ -2008,7 +2008,7 @@ CFrontEndUI::CFrontEndUI()
m_touchBar = NewFrontEndUITouchBar();
m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::None);
x14_phase = EPhase::ExitFrontEnd;
//x14_phase = EPhase::ExitFrontEnd;
}
void CFrontEndUI::StartSlideShow(CArchitectureQueue& queue)

View File

@ -130,6 +130,8 @@ void CWorldTransManager::UpdateEnabled(float dt)
UpdateLights(dt);
}
static float lastTime = 0.f;
void CWorldTransManager::UpdateText(float dt)
{
if (x44_28_textDirty)
@ -151,8 +153,11 @@ void CWorldTransManager::UpdateText(float dt)
x8_textData->Update(dt);
float nextSfxInterval = x3c_sfxInterval + g_tweakGui->GetWorldTransManagerCharsPerSfx();
if (x8_textData->GetNumCharsPrinted() >= nextSfxInterval)
float printed = x8_textData->GetNumCharsPrinted();
if (printed >= nextSfxInterval)
{
printf("%f %f %f\n", x0_curTime, x0_curTime - lastTime, printed);
lastTime = x0_curTime;
x3c_sfxInterval = nextSfxInterval;
CSfxManager::SfxStart(1438, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
@ -307,8 +312,11 @@ void CWorldTransManager::DrawDisabled()
void CWorldTransManager::DrawText()
{
g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f);
CGraphics::SetModelMatrix(zeus::CTransform::Translate(0.f, 0.f, 448.f));
float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
float width = 448.f * vpAspectRatio;
CGraphics::SetOrtho(0.f, width, 448.f, 0.f, -4096.f, 4096.f);
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
CGraphics::SetModelMatrix(zeus::CTransform::Translate((width - 640.f) / 2.f, 0.f, 448.f));
x8_textData->Render();
float filterAlpha = 0.f;

View File

@ -18,8 +18,8 @@ class CAnimationParameters;
class CFluidUVMotion;
class CCameraShakeData;
using FScriptLoader = std::function<CEntity*(CStateManager& mgr, CInputStream& in,
int propCount, const CEntityInfo& info)>;
typedef CEntity*(*FScriptLoader)(CStateManager& mgr, CInputStream& in,
int propCount, const CEntityInfo& info);
class ScriptLoader
{

2
amuse

@ -1 +1 @@
Subproject commit aff8880595b8a30130695f8a09428347d1f75939
Subproject commit 5c8fa2e8ab76cb95dad7a6add9efd8ecb9bfbbfe

2
hecl

@ -1 +1 @@
Subproject commit be31b7d4ac28cf28e441bcdae972fcc21353959d
Subproject commit 055510517d5b3578e9a8c320b60535eb7f4a04fb