Show binarization indicator for 2D packed mipchain EXR files

This commit is contained in:
Robert Beckebans 2024-06-28 23:40:14 +02:00
parent 7a94a9c466
commit 1759ecb1ed
4 changed files with 68 additions and 59 deletions

View file

@ -285,40 +285,44 @@ void idCommonLocal::Draw()
// draw general progress bar
DrawLoadPacifierProgressbar();
// update our progress estimates
int time = Sys_Milliseconds();
if( loadPacifierBinarizeProgress > 0.0f )
if( loadPacifierBinarizeActive )
{
loadPacifierBinarizeTimeLeft = ( 1.0 - loadPacifierBinarizeProgress ) * ( time - loadPacifierBinarizeStartTime ) * 0.001f / loadPacifierBinarizeProgress;
}
else
{
loadPacifierBinarizeTimeLeft = -1.0f;
}
// update our progress estimates
int time = Sys_Milliseconds();
if( loadPacifierBinarizeProgress > 0.0f )
{
loadPacifierBinarizeTimeLeft = ( 1.0 - loadPacifierBinarizeProgress ) * ( time - loadPacifierBinarizeStartTime ) * 0.001f / loadPacifierBinarizeProgress;
}
else
{
loadPacifierBinarizeTimeLeft = -1.0f;
}
// prepare our strings
const char* text;
if( loadPacifierBinarizeTimeLeft >= 99.5f )
{
text = va( "Binarizing %3.0f%% ETA %2.0f minutes", loadPacifierBinarizeProgress * 100.0f, loadPacifierBinarizeTimeLeft / 60.0f );
}
else if( loadPacifierBinarizeTimeLeft )
{
text = va( "Binarizing %3.0f%% ETA %2.0f seconds", loadPacifierBinarizeProgress * 100.0f, loadPacifierBinarizeTimeLeft );
}
else
{
text = va( "Binarizing %3.0f%%", loadPacifierBinarizeProgress * 100.0f );
}
// prepare our strings
const char* text;
if( loadPacifierBinarizeTimeLeft >= 99.5f )
{
text = va( "Binarizing %3.0f%% ETA %2.0f minutes", loadPacifierBinarizeProgress * 100.0f, loadPacifierBinarizeTimeLeft / 60.0f );
}
else if( loadPacifierBinarizeTimeLeft )
{
text = va( "Binarizing %3.0f%% ETA %2.0f seconds", loadPacifierBinarizeProgress * 100.0f, loadPacifierBinarizeTimeLeft );
}
else
{
text = va( "Binarizing %3.0f%%", loadPacifierBinarizeProgress * 100.0f );
}
// draw our basic overlay
renderSystem->SetColor( idVec4( 0.0f, 0.0f, 0.5f, 1.0f ) );
renderSystem->DrawStretchPic( 0, renderSystem->GetVirtualHeight() - 48, renderSystem->GetVirtualWidth(), 48, 0, 0, 1, 1, whiteMaterial );
renderSystem->SetColor( idVec4( 0.0f, 0.5f, 0.8f, 1.0f ) );
renderSystem->DrawStretchPic( 0, renderSystem->GetVirtualHeight() - 48, loadPacifierBinarizeProgress * renderSystem->GetVirtualWidth(), 32, 0, 0, 1, 1, whiteMaterial );
renderSystem->DrawSmallStringExt( 0, renderSystem->GetVirtualHeight() - 48, loadPacifierBinarizeFilename.c_str(), idVec4( 1.0f, 1.0f, 1.0f, 1.0f ), true );
renderSystem->DrawSmallStringExt( 0, renderSystem->GetVirtualHeight() - 32, va( "%s %d/%d lvls", loadPacifierBinarizeInfo.c_str(), loadPacifierBinarizeMiplevel, loadPacifierBinarizeMiplevelTotal ), idVec4( 1.0f, 1.0f, 1.0f, 1.0f ), true );
renderSystem->DrawSmallStringExt( 0, renderSystem->GetVirtualHeight() - 16, text, idVec4( 1.0f, 1.0f, 1.0f, 1.0f ), true );
// draw our basic overlay
renderSystem->SetColor( idVec4( 0.0f, 0.0f, 0.0f, 0.75f ) );
renderSystem->DrawStretchPic( 0, renderSystem->GetVirtualHeight() - 48, renderSystem->GetVirtualWidth(), 48, 0, 0, 1, 1, whiteMaterial );
//renderSystem->SetColor( idVec4( 0.0f, 0.5f, 0.8f, 1.0f ) );
renderSystem->SetColor( colorBrown );
renderSystem->DrawStretchPic( 0, renderSystem->GetVirtualHeight() - 48, loadPacifierBinarizeProgress * renderSystem->GetVirtualWidth(), 16, 0, 0, 1, 1, whiteMaterial );
renderSystem->DrawSmallStringExt( 0, renderSystem->GetVirtualHeight() - 48, loadPacifierBinarizeFilename.c_str(), idVec4( 1.0f, 1.0f, 1.0f, 1.0f ), true );
renderSystem->DrawSmallStringExt( 0, renderSystem->GetVirtualHeight() - 32, va( "%s %d/%d lvls", loadPacifierBinarizeInfo.c_str(), loadPacifierBinarizeMiplevel, loadPacifierBinarizeMiplevelTotal ), idVec4( 1.0f, 1.0f, 1.0f, 1.0f ), true );
renderSystem->DrawSmallStringExt( 0, renderSystem->GetVirtualHeight() - 16, text, idVec4( 1.0f, 1.0f, 1.0f, 1.0f ), true );
}
}
else if( loadGUI != NULL )
{

View file

@ -413,6 +413,8 @@ void idBinaryImage::Load2DAtlasMipchainFromMemory( int width, int height, const
#endif
}
}
common->LoadPacifierBinarizeProgressIncrement( rect.x * rect.y );
// RB end
common->LoadPacifierBinarizeMiplevel( level + 1, numLevels );

View file

@ -149,6 +149,7 @@ void R_ListImages_f( const idCmdArgs& args )
bool duplicated = false;
bool overSized = false;
bool sortByName = false;
bool deferred = false;
if( args.Argc() == 1 )
{
@ -181,6 +182,10 @@ void R_ListImages_f( const idCmdArgs& args )
sorted = true;
overSized = true;
}
else if( idStr::Icmp( args.Argv( 1 ), "deferred" ) == 0 )
{
deferred = true;
}
else
{
failed = true;
@ -202,14 +207,23 @@ void R_ListImages_f( const idCmdArgs& args )
totalSize = 0;
idList< idImage* >& images = globalImages->images;
const int numImages = images.Num();
const idList< idImage*, TAG_IDLIB_LIST_IMAGE >* images;
if( deferred )
{
images = &globalImages->imagesToLoad;
}
else
{
images = &globalImages->images;
}
const int numImages = images->Num();
sortedImage_t* sortedArray = ( sortedImage_t* )alloca( sizeof( sortedImage_t ) * numImages );
for( i = 0 ; i < numImages; i++ )
{
image = images[ i ];
image = ( *images )[ i ];
if( uncompressedOnly )
{
@ -229,7 +243,7 @@ void R_ListImages_f( const idCmdArgs& args )
int j;
for( j = i + 1 ; j < numImages ; j++ )
{
if( idStr::Icmp( image->GetName(), images[ j ]->GetName() ) == 0 )
if( idStr::Icmp( image->GetName(), ( *images )[ j ]->GetName() ) == 0 )
{
break;
}

View file

@ -635,37 +635,26 @@ void idImage::FinalizeImage( bool fromBackEnd, nvrhi::ICommandList* commandList
DeriveOpts();
// foresthale 2014-05-30: give a nice progress display when binarizing
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
if( opts.numLevels > 1 )
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 * 4 / 3 );
}
else
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 );
}
commonLocal.LoadPacifierBinarizeEnd();
// foresthale 2014-05-30: give a nice progress display when binarizing
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
if( opts.numLevels > 1 )
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 * 4 / 3 );
}
else
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 );
}
// RB: convert to compressed DXT or whatever choosen target format
if( cubeFiles == CF_2D_PACKED_MIPCHAIN )
{
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
commonLocal.LoadPacifierBinarizeProgressTotal( width * opts.height );
im.Load2DAtlasMipchainFromMemory( width, opts.height, pic, opts.numLevels, opts.format, opts.colorFormat );
}
else
{
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
if( opts.numLevels > 1 )
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height * 4 / 3 );
}
else
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height );
}
im.Load2DFromMemory( opts.width, opts.height, pic, opts.numLevels, opts.format, opts.colorFormat, opts.gammaMips );
}
commonLocal.LoadPacifierBinarizeEnd();