mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-13 22:22:05 +00:00
A small loading screen progressbar experiment
This commit is contained in:
parent
c226650c0c
commit
5aedf14510
7 changed files with 188 additions and 12 deletions
|
@ -229,9 +229,12 @@ public:
|
|||
// DG end
|
||||
|
||||
virtual void UpdateLevelLoadPacifier() = 0;
|
||||
//virtual void UpdateLevelLoadPacifier( int mProgress ) = 0;
|
||||
//virtual void UpdateLevelLoadPacifier( bool updateSecondary ) = 0;
|
||||
//virtual void UpdateLevelLoadPacifier( bool updateSecondary, int Progress ) = 0;
|
||||
// RB begin
|
||||
virtual void LoadPacifierInfo( VERIFY_FORMAT_STRING const char* fmt, ... ) = 0;
|
||||
virtual void LoadPacifierProgressTotal( int total ) = 0;
|
||||
virtual void LoadPacifierProgressIncrement( int step ) = 0;
|
||||
virtual bool LoadPacifierRunning() = 0;
|
||||
// RB end
|
||||
|
||||
// Checks for and removes command line "+set var arg" constructs.
|
||||
// If match is NULL, all set commands will be executed, otherwise
|
||||
|
|
|
@ -772,7 +772,9 @@ void idCommonLocal::UpdateLevelLoadPacifier()
|
|||
}
|
||||
txtVal->SetStrokeInfo( true, 1.75f, 0.75f );
|
||||
}
|
||||
|
||||
UpdateScreen( false );
|
||||
|
||||
if( autoswapsRunning )
|
||||
{
|
||||
renderSystem->BeginAutomaticBackgroundSwaps( icon );
|
||||
|
@ -780,6 +782,83 @@ void idCommonLocal::UpdateLevelLoadPacifier()
|
|||
}
|
||||
}
|
||||
|
||||
// RB begin
|
||||
void idCommonLocal::LoadPacifierInfo( VERIFY_FORMAT_STRING const char* fmt, ... )
|
||||
{
|
||||
char msg[256];
|
||||
|
||||
va_list argptr;
|
||||
va_start( argptr, fmt );
|
||||
idStr::vsnPrintf( msg, 256 - 1, fmt, argptr );
|
||||
msg[ sizeof( msg ) - 1 ] = '\0';
|
||||
va_end( argptr );
|
||||
|
||||
loadPacifierStatus = msg;
|
||||
|
||||
//if( com_refreshOnPrint )
|
||||
//{
|
||||
// UpdateScreen( false );
|
||||
//}
|
||||
}
|
||||
|
||||
void idCommonLocal::LoadPacifierProgressTotal( int total )
|
||||
{
|
||||
loadPacifierCount = 0;
|
||||
loadPacifierExpectedCount = total;
|
||||
loadPacifierTics = 0;
|
||||
loadPacifierNextTicCount = 0;
|
||||
}
|
||||
|
||||
void idCommonLocal::LoadPacifierProgressIncrement( int step )
|
||||
{
|
||||
loadPacifierCount += step;
|
||||
|
||||
// don't refresh the UI with every step if there are e.g. 1300 steps
|
||||
if( ( ( loadPacifierCount + 1 ) >= loadPacifierNextTicCount ) && loadPacifierExpectedCount > 0 )
|
||||
{
|
||||
size_t ticsNeeded = ( size_t )( ( ( double )( loadPacifierCount + 1 ) / loadPacifierExpectedCount ) * 50.0 );
|
||||
|
||||
//do
|
||||
//{
|
||||
//common->Printf( "*" );
|
||||
//}
|
||||
//while( ++loadPacifierTics < ticsNeeded );
|
||||
loadPacifierTics = ticsNeeded;
|
||||
|
||||
loadPacifierNextTicCount = ( size_t )( ( loadPacifierTics / 50.0 ) * loadPacifierExpectedCount );
|
||||
if( loadPacifierCount == ( loadPacifierExpectedCount - 1 ) )
|
||||
{
|
||||
// reset
|
||||
|
||||
//if( tics < 51 )
|
||||
//{
|
||||
// common->Printf( "*" );
|
||||
//}
|
||||
//common->Printf( "\n" );
|
||||
|
||||
//stateUI.progress = 1;
|
||||
|
||||
//loadPacifierCount = 0;
|
||||
//loadPacifierExpectedCount = 0;
|
||||
//loadPacifierTics = 0;
|
||||
//loadPacifierNextTicCount = 0;
|
||||
}
|
||||
|
||||
UpdateLevelLoadPacifier();
|
||||
}
|
||||
|
||||
if( loadPacifierCount >= loadPacifierExpectedCount )
|
||||
{
|
||||
loadPacifierExpectedCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool idCommonLocal::LoadPacifierRunning()
|
||||
{
|
||||
return loadPacifierExpectedCount > 0;
|
||||
}
|
||||
// RB end
|
||||
|
||||
// foresthale 2014-05-30: loading progress pacifier for binarize operations only
|
||||
void idCommonLocal::LoadPacifierBinarizeFilename( const char* filename, const char* reason )
|
||||
{
|
||||
|
@ -817,8 +896,11 @@ void idCommonLocal::LoadPacifierBinarizeProgress( float progress )
|
|||
// binarized for one filename, we don't give bogus estimates...
|
||||
loadPacifierBinarizeStartTime = Sys_Milliseconds();
|
||||
}
|
||||
|
||||
loadPacifierBinarizeProgress = progress;
|
||||
if( ( time - lastUpdateTime ) >= 16 )
|
||||
|
||||
// RB: update every 2 milliseconds have passed
|
||||
if( ( time - lastUpdateTime ) >= 2 )
|
||||
{
|
||||
lastUpdateTime = time;
|
||||
loadPacifierBinarizeActive = true;
|
||||
|
|
|
@ -157,9 +157,6 @@ public:
|
|||
virtual void UpdateScreen( bool captureToImage, bool releaseMouse = true );
|
||||
// DG end
|
||||
virtual void UpdateLevelLoadPacifier(); // Indefinate
|
||||
// virtual void UpdateLevelLoadPacifier( int mProgress );
|
||||
// virtual void UpdateLevelLoadPacifier( bool Secondary );
|
||||
// virtual void UpdateLevelLoadPacifier( bool updateSecondary, int mProgress );
|
||||
virtual void StartupVariable( const char* match );
|
||||
virtual void InitTool( const toolFlag_t tool, const idDict* dict, idEntity* entity );
|
||||
virtual void WriteConfigToFile( const char* filename );
|
||||
|
@ -440,6 +437,13 @@ public:
|
|||
}
|
||||
// SRS end
|
||||
|
||||
// RB begin
|
||||
virtual void LoadPacifierInfo( VERIFY_FORMAT_STRING const char* fmt, ... );
|
||||
virtual void LoadPacifierProgressTotal( int total );
|
||||
virtual void LoadPacifierProgressIncrement( int step );
|
||||
virtual bool LoadPacifierRunning();
|
||||
// RB end
|
||||
|
||||
// foresthale 2014-05-30: a special binarize pacifier has to be shown in
|
||||
// some cases, which includes filename and ETA information, note that
|
||||
// the progress function takes 0-1 float, not 0-100, and can be called
|
||||
|
@ -655,6 +659,14 @@ private:
|
|||
int lastPacifierGuiTime;
|
||||
bool lastPacifierDialogState;
|
||||
|
||||
// RB begin
|
||||
idStrStatic<256> loadPacifierStatus = "-";
|
||||
int loadPacifierCount = 0;
|
||||
int loadPacifierExpectedCount = 0;
|
||||
size_t loadPacifierTics = 0;
|
||||
size_t loadPacifierNextTicCount = 0;
|
||||
// RB end
|
||||
|
||||
// foresthale 2014-05-30: a special binarize pacifier has to be shown in some cases, which includes filename and ETA information
|
||||
bool loadPacifierBinarizeActive;
|
||||
int loadPacifierBinarizeStartTime;
|
||||
|
@ -738,6 +750,7 @@ private:
|
|||
|
||||
// called by Draw when the scene to scene wipe is still running
|
||||
void DrawWipeModel();
|
||||
void DrawLoadPacifierProgressbar(); // RB
|
||||
void StartWipe( const char* materialName, bool hold = false );
|
||||
void CompleteWipe();
|
||||
void ClearWipe();
|
||||
|
|
|
@ -234,6 +234,27 @@ void idCommonLocal::DrawWipeModel()
|
|||
renderSystem->DrawStretchPic( 0, 0, renderSystem->GetVirtualWidth(), renderSystem->GetVirtualHeight(), 0, 0, 1, 1, wipeMaterial );
|
||||
}
|
||||
|
||||
// RB begin
|
||||
void idCommonLocal::DrawLoadPacifierProgressbar()
|
||||
{
|
||||
if( loadPacifierExpectedCount <= 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float loadPacifierProgress = float( loadPacifierCount ) / loadPacifierExpectedCount;
|
||||
|
||||
// draw our basic overlay
|
||||
renderSystem->SetColor( idVec4( 0.55f, 0.0f, 0.0f, 1.0f ) );
|
||||
renderSystem->DrawStretchPic( 0, renderSystem->GetVirtualHeight() - 64, renderSystem->GetVirtualWidth(), 16, 0, 0, 1, 1, whiteMaterial );
|
||||
//renderSystem->SetColor( idVec4( 0.0f, 0.5f, 0.8f, 1.0f ) );
|
||||
renderSystem->SetColor( colorGold );
|
||||
renderSystem->DrawStretchPic( 0, renderSystem->GetVirtualHeight() - 64, loadPacifierProgress * renderSystem->GetVirtualWidth(), 16, 0, 0, 1, 1, whiteMaterial );
|
||||
|
||||
renderSystem->DrawSmallStringExt( 0, renderSystem->GetVirtualHeight() - 64, loadPacifierStatus, idVec4( 1.0f, 1.0f, 1.0f, 1.0f ), true );
|
||||
}
|
||||
// RB end
|
||||
|
||||
/*
|
||||
===============
|
||||
idCommonLocal::Draw
|
||||
|
@ -247,7 +268,7 @@ void idCommonLocal::Draw()
|
|||
Sys_Sleep( com_sleepDraw.GetInteger() );
|
||||
}
|
||||
|
||||
if( loadPacifierBinarizeActive )
|
||||
if( loadPacifierBinarizeActive || LoadPacifierRunning() )
|
||||
{
|
||||
// foresthale 2014-05-30: when binarizing an asset we show a special
|
||||
// overlay indicating progress
|
||||
|
@ -261,6 +282,9 @@ void idCommonLocal::Draw()
|
|||
loadGUI->Render( renderSystem, Sys_Milliseconds() );
|
||||
}
|
||||
|
||||
// draw general progress bar
|
||||
DrawLoadPacifierProgressbar();
|
||||
|
||||
// update our progress estimates
|
||||
int time = Sys_Milliseconds();
|
||||
if( loadPacifierBinarizeProgress > 0.0f )
|
||||
|
|
|
@ -333,7 +333,6 @@ idImage* idImageManager::AllocStandaloneImage( const char* name )
|
|||
AllocDeferredImage
|
||||
|
||||
Allocates an idDeferredImage to load images from memory, adds it to the hash chain
|
||||
|
||||
==============
|
||||
*/
|
||||
idDeferredImage* idImageManager::AllocDeferredImage( const char* name )
|
||||
|
@ -861,6 +860,21 @@ void idImageManager::Preload( const idPreloadManifest& manifest, const bool& map
|
|||
int numLoaded = 0;
|
||||
|
||||
//fileSystem->StartPreload( preloadImageFiles );
|
||||
|
||||
// count
|
||||
int numPreload = 0;
|
||||
for( int i = 0; i < manifest.NumResources(); i++ )
|
||||
{
|
||||
const preloadEntry_s& p = manifest.GetPreloadByIndex( i );
|
||||
if( p.resType == PRELOAD_IMAGE && !ExcludePreloadImage( p.resourceName ) )
|
||||
{
|
||||
numPreload++;
|
||||
}
|
||||
}
|
||||
|
||||
common->LoadPacifierInfo( "Preloading images" );
|
||||
common->LoadPacifierProgressTotal( numPreload );
|
||||
|
||||
for( int i = 0; i < manifest.NumResources(); i++ )
|
||||
{
|
||||
const preloadEntry_s& p = manifest.GetPreloadByIndex( i );
|
||||
|
@ -868,6 +882,8 @@ void idImageManager::Preload( const idPreloadManifest& manifest, const bool& map
|
|||
{
|
||||
globalImages->ImageFromFile( p.resourceName, ( textureFilter_t )p.imgData.filter, ( textureRepeat_t )p.imgData.repeat, ( textureUsage_t )p.imgData.usage, ( cubeFiles_t )p.imgData.cubeMap );
|
||||
numLoaded++;
|
||||
|
||||
common->LoadPacifierProgressIncrement( 1 );
|
||||
}
|
||||
}
|
||||
//fileSystem->StopPreload();
|
||||
|
@ -899,15 +915,26 @@ int idImageManager::LoadLevelImages( bool pacifier )
|
|||
commandList = deviceManager->GetDevice()->createCommandList( params );
|
||||
}
|
||||
|
||||
common->UpdateLevelLoadPacifier();
|
||||
//common->UpdateLevelLoadPacifier();
|
||||
|
||||
commandList->open();
|
||||
|
||||
if( pacifier )
|
||||
{
|
||||
common->LoadPacifierInfo( "Loading level images" );
|
||||
common->LoadPacifierProgressTotal( images.Num() );
|
||||
}
|
||||
|
||||
int loadCount = 0;
|
||||
for( int i = 0 ; i < images.Num() ; i++ )
|
||||
{
|
||||
idImage* image = images[ i ];
|
||||
|
||||
if( pacifier )
|
||||
{
|
||||
common->LoadPacifierProgressIncrement( 1 );
|
||||
}
|
||||
|
||||
if( image->generatorFunction )
|
||||
{
|
||||
continue;
|
||||
|
@ -1012,6 +1039,11 @@ void idImageManager::PrintMemInfo( MemInfo_t* mi )
|
|||
|
||||
void idImageManager::LoadDeferredImages( nvrhi::ICommandList* _commandList )
|
||||
{
|
||||
if( insideLevelLoad )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if !defined( DMAP )
|
||||
if( !commandList )
|
||||
{
|
||||
|
@ -1033,10 +1065,22 @@ void idImageManager::LoadDeferredImages( nvrhi::ICommandList* _commandList )
|
|||
thisCmdList->open();
|
||||
}
|
||||
|
||||
bool preloadPacifier = common->LoadPacifierRunning();
|
||||
if( !preloadPacifier )
|
||||
{
|
||||
common->LoadPacifierInfo( "Loading deferred images" );
|
||||
common->LoadPacifierProgressTotal( imagesToLoad.Num() );
|
||||
}
|
||||
|
||||
for( int i = 0; i < globalImages->imagesToLoad.Num(); i++ )
|
||||
{
|
||||
// This is a "deferred" load of textures to the gpu.
|
||||
globalImages->imagesToLoad[i]->FinalizeImage( false, thisCmdList );
|
||||
|
||||
if( !preloadPacifier )
|
||||
{
|
||||
common->LoadPacifierProgressIncrement( 1 );
|
||||
}
|
||||
}
|
||||
#else
|
||||
for( int i = 0; i < globalImages->imagesToLoad.Num(); i++ )
|
||||
|
|
|
@ -5320,6 +5320,9 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
|
|||
GL_StartFrame();
|
||||
|
||||
void* textureId = globalImages->hierarchicalZbufferImage->GetTextureID();
|
||||
|
||||
// RB: we need to load all images left before rendering
|
||||
// this can be expensive here because of the runtime image compression
|
||||
globalImages->LoadDeferredImages( commandList );
|
||||
|
||||
if( !ssaoPass && r_useNewSsaoPass.GetBool() )
|
||||
|
|
|
@ -670,7 +670,7 @@ public:
|
|||
// Initialize everything.
|
||||
// if the OS allows, pass argc/argv directly (without executable name)
|
||||
// otherwise pass the command line in a single string (without executable name)
|
||||
virtual void Init( int argc, const char* const* argv, const char* cmdline ) { };
|
||||
virtual void Init( int argc, const char* const* argv, const char* cmdline ) {}
|
||||
|
||||
// Shuts down everything.
|
||||
virtual void Shutdown() {}
|
||||
|
@ -698,6 +698,13 @@ public:
|
|||
virtual void UpdateScreen( bool captureToImage, bool releaseMouse = true );
|
||||
|
||||
virtual void UpdateLevelLoadPacifier() {}
|
||||
virtual void LoadPacifierInfo( VERIFY_FORMAT_STRING const char* fmt, ... ) {}
|
||||
virtual void LoadPacifierProgressTotal( int total ) {}
|
||||
virtual void LoadPacifierProgressIncrement( int step ) {}
|
||||
virtual bool LoadPacifierRunning()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Checks for and removes command line "+set var arg" constructs.
|
||||
|
@ -706,7 +713,7 @@ public:
|
|||
virtual void StartupVariable( const char* match ) {}
|
||||
|
||||
// Begins redirection of console output to the given buffer.
|
||||
virtual void BeginRedirect( char* buffer, int buffersize, void ( *flush )( const char* ) ) { };
|
||||
virtual void BeginRedirect( char* buffer, int buffersize, void ( *flush )( const char* ) ) {}
|
||||
|
||||
// Stops redirection of console output.
|
||||
virtual void EndRedirect() {}
|
||||
|
|
Loading…
Reference in a new issue