Fixing staging buffers not getting deleted

remove vgcore
This commit is contained in:
2023-11-06 15:08:27 +01:00
parent d35f7acddc
commit 4c567b60f3
69 changed files with 505 additions and 304 deletions
+2 -2
View File
@@ -12,9 +12,9 @@ Asset::Asset()
{
}
Asset::Asset(std::string_view _folderPath, std::string_view _name)
: status(Status::Uninitialized)
, folderPath(_folderPath)
: folderPath(_folderPath)
, name(_name)
, status(Status::Uninitialized)
{
if (folderPath.empty())
{
+18 -5
View File
@@ -31,7 +31,7 @@ PMeshAsset AssetRegistry::findMesh(const std::string &filePath)
AssetFolder* folder = get().assetRoot;
std::string fileName = filePath;
size_t slashLoc = filePath.rfind("/");
if(slashLoc != -1)
if(slashLoc != std::string::npos)
{
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
fileName = filePath.substr(slashLoc+1, filePath.size());
@@ -44,7 +44,7 @@ PTextureAsset AssetRegistry::findTexture(const std::string &filePath)
AssetFolder* folder = get().assetRoot;
std::string fileName = filePath;
size_t slashLoc = filePath.rfind("/");
if (slashLoc != -1)
if (slashLoc != std::string::npos)
{
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
fileName = filePath.substr(slashLoc + 1, filePath.size());
@@ -57,7 +57,7 @@ PFontAsset AssetRegistry::findFont(const std::string& filePath)
AssetFolder* folder = get().assetRoot;
std::string fileName = filePath;
size_t slashLoc = filePath.rfind("/");
if(slashLoc != -1)
if(slashLoc != std::string::npos)
{
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
fileName = filePath.substr(slashLoc+1, filePath.size());
@@ -70,7 +70,7 @@ PMaterialAsset AssetRegistry::findMaterial(const std::string &filePath)
AssetFolder* folder = get().assetRoot;
std::string fileName = filePath;
size_t slashLoc = filePath.rfind("/");
if (slashLoc != -1)
if (slashLoc != std::string::npos)
{
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
fileName = filePath.substr(slashLoc + 1, filePath.size());
@@ -78,6 +78,19 @@ PMaterialAsset AssetRegistry::findMaterial(const std::string &filePath)
return folder->materials.at(fileName);
}
PMaterialInstanceAsset AssetRegistry::findMaterialInstance(const std::string &filePath)
{
AssetFolder* folder = get().assetRoot;
std::string fileName = filePath;
size_t slashLoc = filePath.rfind("/");
if (slashLoc != std::string::npos)
{
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
fileName = filePath.substr(slashLoc + 1, filePath.size());
}
return folder->instances.at(fileName);
}
std::ofstream AssetRegistry::createWriteStream(const std::filesystem::path& relativePath, std::ios_base::openmode openmode)
{
return get().internalCreateWriteStream(relativePath, openmode);
@@ -356,7 +369,7 @@ AssetRegistry::AssetFolder* AssetRegistry::getOrCreateFolder(std::string fullPat
while(!fullPath.empty())
{
size_t slashLoc = fullPath.find("/");
if(slashLoc == -1)
if(slashLoc == std::string::npos)
{
if (!result->children.contains(fullPath))
{
+1
View File
@@ -75,6 +75,7 @@ private:
Gfx::PGraphics graphics;
ArchiveBuffer assetBuffer;
bool release = false;
friend class MaterialAsset;
friend class TextureLoader;
friend class FontLoader;
friend class MaterialLoader;
+2
View File
@@ -30,7 +30,9 @@ void FontAsset::save(ArchiveBuffer& buffer) const
Array<uint8> textureData;
ktxTexture2* kTexture;
ktxTextureCreateInfo createInfo = {
.glInternalformat = 0,
.vkFormat = (uint32_t)glyph.texture->getFormat(),
.pDfd = nullptr,
.baseWidth = glyph.texture->getSizeX(),
.baseHeight = glyph.texture->getSizeY(),
.baseDepth = glyph.texture->getSizeZ(),
+2 -2
View File
@@ -18,12 +18,12 @@ LevelAsset::~LevelAsset()
}
void LevelAsset::save(ArchiveBuffer& buffer) const
void LevelAsset::save(ArchiveBuffer&) const
{
}
void LevelAsset::load(ArchiveBuffer& buffer)
void LevelAsset::load(ArchiveBuffer&)
{
}
+7 -4
View File
@@ -2,6 +2,7 @@
#include "Material/Material.h"
#include "Graphics/Graphics.h"
#include "MaterialInstanceAsset.h"
#include "Asset/AssetRegistry.h"
using namespace Seele;
@@ -30,13 +31,15 @@ void MaterialAsset::load(ArchiveBuffer& buffer)
material->compile();
}
OMaterialInstanceAsset Seele::MaterialAsset::instantiate(const InstantiationParameter& params)
PMaterialInstanceAsset MaterialAsset::instantiate(const InstantiationParameter& params)
{
OMaterialInstance instance = material->instantiate();
instance->setBaseMaterial(this);
OMaterialInstanceAsset asset = new MaterialInstanceAsset(params.folderPath, params.name);
asset->setHandle(std::move(instance));
return asset;
asset->setBase(this);
PMaterialInstanceAsset ref = asset;
AssetRegistry::get().saveAsset(ref, MaterialInstanceAsset::IDENTIFIER, ref->getFolderPath(), ref->getName());
AssetRegistry::get().registerMaterialInstance(std::move(asset));
return ref;
}
+1 -1
View File
@@ -20,7 +20,7 @@ public:
virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer) override;
PMaterial getMaterial() const { return material; }
OMaterialInstanceAsset instantiate(const InstantiationParameter& params);
PMaterialInstanceAsset instantiate(const InstantiationParameter& params);
private:
OMaterial material;
friend class MaterialLoader;
+1
View File
@@ -15,6 +15,7 @@ public:
virtual void load(ArchiveBuffer& buffer) override;
void setHandle(OMaterialInstance handle) { material = std::move(handle); }
void setBase(PMaterialAsset base) { baseMaterial = base; }
PMaterialInstance getHandle() const { return material; }
private:
OMaterialInstance material;
PMaterialAsset baseMaterial;
-1
View File
@@ -21,7 +21,6 @@ MeshAsset::~MeshAsset()
void MeshAsset::save(ArchiveBuffer& buffer) const
{
Serialization::save(buffer, meshes);
}
void MeshAsset::load(ArchiveBuffer& buffer)
+7 -1
View File
@@ -2,6 +2,7 @@
#include "Graphics/Graphics.h"
#include "Window/WindowManager.h"
#include "Graphics/Vulkan/Enums.h"
#include "Graphics/Texture.h"
#include "ktx.h"
using namespace Seele;
@@ -22,7 +23,7 @@ TextureAsset::~TextureAsset()
}
void TextureAsset::save(ArchiveBuffer& buffer) const
void TextureAsset::save(ArchiveBuffer&) const
{
/*ktxTexture2* kTexture;
ktxTextureCreateInfo createInfo = {
@@ -113,3 +114,8 @@ void TextureAsset::load(ArchiveBuffer& buffer)
texture->transferOwnership(Gfx::QueueType::GRAPHICS);
ktxTexture_Destroy(ktxTexture(kTexture));
}
void TextureAsset::setTexture(Gfx::OTexture _texture)
{
texture = std::move(_texture);
}
+1 -4
View File
@@ -13,10 +13,7 @@ public:
virtual ~TextureAsset();
virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer) override;
void setTexture(Gfx::OTexture _texture)
{
texture = std::move(_texture);
}
void setTexture(Gfx::OTexture _texture);
Gfx::PTexture getTexture()
{
return texture;