3700 FPS here we go

This commit is contained in:
Dynamitos
2021-04-25 23:43:40 +02:00
parent 312ae2af9a
commit 4a078bd24c
35 changed files with 160 additions and 73 deletions
+2 -7
View File
@@ -45,17 +45,12 @@ PMeshAsset AssetRegistry::findMesh(const std::string &filePath)
{
auto it = get().meshes.find(filePath);
assert(it != get().meshes.end());
return it->value;
return it->second;
}
PTextureAsset AssetRegistry::findTexture(const std::string &filePath)
{
PTextureAsset result = get().textures[filePath];
if(result == nullptr)
{
return get().textureLoader->getPlaceholderTexture();
}
return result;
return get().textures[filePath];
}
PMaterialAsset AssetRegistry::findMaterial(const std::string &filePath)
+5 -3
View File
@@ -2,6 +2,7 @@
#include "MinimalEngine.h"
#include "Asset.h"
#include <string>
#include <map>
namespace Seele
{
@@ -46,9 +47,10 @@ private:
std::ifstream internalCreateReadStream(const std::string& relaitvePath, std::ios_base::openmode openmode = std::ios::in);
std::filesystem::path rootFolder;
Map<std::string, PTextureAsset> textures;
Map<std::string, PMeshAsset> meshes;
Map<std::string, PMaterialAsset> materials;
//Todo: Seele::Map doesn't really work with strings for some reason, so just use std::map for now
std::map<std::string, PTextureAsset> textures;
std::map<std::string, PMeshAsset> meshes;
std::map<std::string, PMaterialAsset> materials;
UPTextureLoader textureLoader;
UPMeshLoader meshLoader;
UPMaterialLoader materialLoader;
+1
View File
@@ -19,6 +19,7 @@ public:
}
Gfx::PTexture getTexture()
{
std::scoped_lock lck(lock);
return texture;
}
private:
+3 -2
View File
@@ -16,6 +16,7 @@ TextureLoader::TextureLoader(Gfx::PGraphics graphics)
placeholderTexture = import("./textures/placeholder.png");
placeholderAsset->setTexture(placeholderTexture);
placeholderAsset->setStatus(Asset::Status::Ready);
AssetRegistry::get().textures[""] = placeholderAsset;
}
TextureLoader::~TextureLoader()
@@ -28,13 +29,13 @@ void TextureLoader::importAsset(const std::filesystem::path& filePath)
PTextureAsset asset = new TextureAsset(assetFileName.replace_extension("asset").filename().generic_string());
asset->setStatus(Asset::Status::Loading);
asset->setTexture(placeholderTexture);
std::cout << "Loading texture, placeholder" << std::endl;
AssetRegistry::get().textures[asset->getFileName()] = asset;
futures.add(std::async(std::launch::async, [this, filePath, asset] () mutable {
using namespace std::chrono_literals;
std::this_thread::sleep_for(5s);
Gfx::PTexture2D texture = import(filePath);
asset->setTexture(texture);
asset->setStatus(Asset::Status::Ready);
std::cout << "Finished loading texture" << std::endl;
}));
}