diff --git a/src/engine/cmdStream.h b/src/engine/cmdStream.h index 6bf7914a2..5c6a18850 100644 --- a/src/engine/cmdStream.h +++ b/src/engine/cmdStream.h @@ -113,13 +113,22 @@ class DivCSPlayer { struct DivCSProgress { int stage, count, total; + int optStage, findTotal; int optCurrent, optTotal; + int findCurrent, expandCurrent; + int origCurrent, origCount; DivCSProgress(): stage(0), count(0), total(0), + optStage(0), + findTotal(0), optCurrent(0), - optTotal(0) {} + optTotal(0), + findCurrent(0), + expandCurrent(0), + origCurrent(0), + origCount(0) {} }; struct DivCSOptions { diff --git a/src/engine/cmdStreamOps.cpp b/src/engine/cmdStreamOps.cpp index 18e2cf157..fa370c85d 100644 --- a/src/engine/cmdStreamOps.cpp +++ b/src/engine/cmdStreamOps.cpp @@ -846,10 +846,18 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector& subBlock matches.clear(); + if (progress!=NULL) { + progress->findTotal=stream->size(); + progress->optStage=0; + } + // fast match algorithm // search for small matches, and then find bigger ones logD("finding possible matches"); for (size_t i=0; isize(); i+=8) { + if (!(i&2047)) { + if (progress!=NULL) progress->findCurrent=i; + } bool storedOrig=false; for (size_t j=i+matchSize; jsize(); j+=8) { if (memcmp(&buf[i],&buf[j],matchSize)==0) { @@ -870,6 +878,9 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector& subBlock if (progress!=NULL) { if ((int)matches.size()>progress->optTotal) progress->optTotal=matches.size(); progress->optCurrent=matches.size(); + progress->origCount=origs.size(); + progress->findCurrent=stream->size(); + progress->optStage=1; } // quit if there isn't anything @@ -877,7 +888,12 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector& subBlock // search for bigger matches for (size_t i=0; iexpandCurrent=i; + } BlockMatch& b=matches[i]; size_t finalLen=b.len; @@ -900,6 +916,11 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector& subBlock b.len=finalLen; } + if (progress!=NULL) { + progress->expandCurrent=matches.size(); + progress->optStage=2; + } + // new code MAN... WHY... // basically the workflow should be: // - test every block position @@ -910,6 +931,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector& subBlock // - pick largest benefit from list // - make sub-blocks!!! logD("testing %d match groups for benefit",(int)origs.size()); + size_t origIndex=0; for (size_t i: origs) { size_t orig=matches[i].orig; size_t minSize=MIN_MATCH_SIZE; @@ -919,6 +941,10 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector& subBlock testMatches.clear(); + if (progress!=NULL) progress->origCurrent=origIndex; + + origIndex++; + // collect matches with this orig value for (size_t j=i; j& subBlock size_t bestOrig=matches[bestBenefit.index].orig; logI("match count %d",(int)workMatches.size()); + if (progress!=NULL) { + progress->optStage=3; + progress->origCurrent=origs.size(); + } + // make sub-block size_t subBlockID=subBlocks.size(); logV("new sub-block %d",(int)subBlockID); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 76c044735..b056a9175 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -6065,7 +6065,11 @@ bool FurnaceGUI::loop() { } else { WAKE_UP; ImGui::Text("Exporting..."); - ImGui::Text("%d/%d",csProgress.optCurrent,csProgress.optTotal); + ImGui::Text("opt stage: %d",csProgress.optStage); + ImGui::Text("pass: %d/%d",csProgress.optCurrent,csProgress.optTotal); + ImGui::Text("find: %d/%d",csProgress.findCurrent,csProgress.findTotal); + ImGui::Text("expand: %d/%d",csProgress.expandCurrent,csProgress.optCurrent); + ImGui::Text("benefit: %d/%d",csProgress.origCurrent,csProgress.origCount); // check whether we're done if (csExportDone) {