Skip to content

Commit

Permalink
Misc Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuria-Shikibe committed Jun 11, 2024
1 parent e8ddaf2 commit a7a22f3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 82 deletions.
74 changes: 0 additions & 74 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,80 +157,6 @@ struct Print{
}
};



int main_(){
return 0;
// ext::StringMap<int> map{};

Graphic::TextureAtlas atlas{};

Assets::TexturePage* mainPage = atlas.registerPage("main");
Assets::TexturePage* lightPage = atlas.registerPage("light");
Assets::TexturePage* fontPage = atlas.registerPage("font");

OS::File testTextureDir{R"(D:\projects\GameEngine\properties\resource\assets\texture\main)"};

const std::vector<Font::CharCode> targetChars = std::ranges::views::iota(' ' + 1, '~' + 1) | std::ranges::to<std::vector<Font::CharCode>>();// {{' ' + 1, '~'}};

Font::loadGlobalFreeTypeLib();

using namespace Assets::Load;
//
LoadManager loadManager{};
TexturePacker packer{};
FontLoader fontLoader{};
MiscTaskManager<> miscTaskManager{};

fontLoader.registerFont(new Font::FontFace{OS::File(R"(D:\projects\GameEngine\properties\resource\assets\fonts\consola.ttf)" ), targetChars});
fontLoader.setBindedPage(fontPage);

packer.setCacheDir(OS::File{R"(D:\projects\GameEngine\properties\resource\cache)"});

testTextureDir.subFile("base").forAllSubs([&](auto&& file){
mainPage->pushRequest<Assets::FileImportData>(file.stem(), file);
});

testTextureDir.subFile("light").forAllSubs([&](auto&& file){
auto name = file.stem();
auto pos = name.find_first_of('.');
name = name.substr(0, pos);

lightPage->pushRequest<Assets::FileImportData>(name, file);
});

// fontLoader.blockLoad(fontPage, OS::File{R"(D:\projects\GameEngine\properties\resource\cache)"});


// std::cout << "done" << std::endl;
// lightPage.dependency = &mainPage;
packer.pushPage(mainPage);
packer.pushPage(lightPage);
packer.pushPage(fontPage);

miscTaskManager.push(Phase::end, [&atlas]{
atlas.flush();
});

loadManager.registerTask(packer);
loadManager.registerTask(fontLoader);
loadManager.registerTask(miscTaskManager);
//
loadManager.launch();
//
while(!loadManager.isFinished()){
loadManager.processRequests();
}

loadManager.requestDone();
// page.p

for (auto& [name, region] : atlas.getRegions()){
std::println("Loaded {}", name);
}

}

//TODO temp global static mut should be remove


Expand Down
1 change: 0 additions & 1 deletion src/arc-impl/AssetsLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ void Assets::Load::MainLoader::loadWith(Core::Renderer* renderer){

while (!Core::platform->shouldExit()){
if(isFinished()) {
requestDone();
if(loadRenderer.lastProgress > 0.999f) {
break;
}
Expand Down
10 changes: 5 additions & 5 deletions src/arc/asset/load/AssetsLoadCore.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,14 @@ export namespace Assets::Load{

void requestDone(){
//TODO set wait time for timeout handle
for (auto& [task, future] : tasks){
for (auto& future : tasks | std::views::values){
if(future.valid())future.get();
}

taskCurrentProgress = 1.f;
tasks.clear();

std::println("Task {} Finished | Cost Time: {}", taskName, std::chrono::duration_cast<std::chrono::milliseconds>(timer.get()));
}

void tryThrowException() const;
Expand Down Expand Up @@ -258,9 +261,6 @@ namespace Assets::Load{

void LoadManager::afterArrival() noexcept{
if(std::to_underlying(currentPhase) < MaxPhaseCount){
//TODO move this to other place
std::println("[{}]: Phase {} Reached | {:.1f}% Completed.", taskName, std::to_underlying(currentPhase), calCurrentProgress() * 100.f);
std::cout.flush();
for (const auto task : tasks | std::views::keys){
task->postEventManager.fire(currentPhase);
}
Expand All @@ -274,7 +274,7 @@ namespace Assets::Load{
}

void LoadManager::launch(){
std::println("Launch Assets Load | Main Thread: {}", std::this_thread::get_id());
std::println("Task {} Launched | On Thread: {}", taskName, std::this_thread::get_id());
setupBarrier();

for (auto& [task, future] : tasks){
Expand Down
2 changes: 0 additions & 2 deletions src/arc/asset/load/FontLoader.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ export namespace Assets::Load{
while(!instantManager.isFinished()){
instantManager.processRequests();
}

instantManager.requestDone();
}
};
}

0 comments on commit a7a22f3

Please sign in to comment.