From 1759ecb1ed0c68ac2b40ca0e9ab943d39c2413b7 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 28 Jun 2024 23:40:14 +0200 Subject: [PATCH] Show binarization indicator for 2D packed mipchain EXR files --- neo/framework/common_frame.cpp | 66 ++++++++++++++++++---------------- neo/renderer/BinaryImage.cpp | 2 ++ neo/renderer/ImageManager.cpp | 22 +++++++++--- neo/renderer/Image_load.cpp | 37 +++++++------------ 4 files changed, 68 insertions(+), 59 deletions(-) diff --git a/neo/framework/common_frame.cpp b/neo/framework/common_frame.cpp index 418c6aea..9ac7833e 100644 --- a/neo/framework/common_frame.cpp +++ b/neo/framework/common_frame.cpp @@ -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 ) { diff --git a/neo/renderer/BinaryImage.cpp b/neo/renderer/BinaryImage.cpp index 161a93ef..7cdae985 100644 --- a/neo/renderer/BinaryImage.cpp +++ b/neo/renderer/BinaryImage.cpp @@ -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 ); diff --git a/neo/renderer/ImageManager.cpp b/neo/renderer/ImageManager.cpp index 6ba776a0..2aef086b 100644 --- a/neo/renderer/ImageManager.cpp +++ b/neo/renderer/ImageManager.cpp @@ -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; } diff --git a/neo/renderer/Image_load.cpp b/neo/renderer/Image_load.cpp index 3296aff9..20ac4ddd 100644 --- a/neo/renderer/Image_load.cpp +++ b/neo/renderer/Image_load.cpp @@ -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();