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
@@ -51,7 +51,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
uint32 uniformBufferOffset = 0;
uint32 bindingCounter = 0; // Uniform buffers are always binding 0
uint32 uniformBinding = -1;
int32 uniformBinding = -1;
Map<std::string, OShaderExpression> expressions;
uint32 key = 0;
uint32 auxKey = 0;
@@ -205,7 +205,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
mat.profile = obj["profile"].get<std::string>();
for(auto& val : obj["values"].items())
{
mat.variables[val.key()] = val.value();
mat.variables[val.key()] = referenceExpression(val.value());
}
}
}
+6 -2
View File
@@ -6,6 +6,7 @@
#include "Asset/AssetImporter.h"
#include "Asset/MaterialAsset.h"
#include <set>
#include <format>
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
@@ -249,13 +250,16 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialAss
idxInfo.sourceData.data = (uint8 *)indices.data();
idxInfo.sourceData.owner = Gfx::QueueType::DEDICATED_TRANSFER;
idxInfo.sourceData.size = sizeof(uint32) * indices.size();
Gfx::PIndexBuffer indexBuffer = graphics->createIndexBuffer(idxInfo);
Gfx::OIndexBuffer indexBuffer = graphics->createIndexBuffer(idxInfo);
indexBuffer->transferOwnership(Gfx::QueueType::GRAPHICS);
globalMeshes[meshIndex] = new Mesh();
globalMeshes[meshIndex]->vertexData = vertexData;
globalMeshes[meshIndex]->id = id;
globalMeshes[meshIndex]->referencedMaterial = materials[mesh->mMaterialIndex]->getMaterial()->instantiate();
globalMeshes[meshIndex]->referencedMaterial = materials[mesh->mMaterialIndex]->instantiate(InstantiationParameter{
.name = std::format("{0}_Inst_0", materials[mesh->mMaterialIndex]->getName()),
.folderPath = materials[mesh->mMaterialIndex]->getFolderPath(),
});
globalMeshes[meshIndex]->meshlets = std::move(meshlets);
globalMeshes[meshIndex]->vertexCount = mesh->mNumVertices;
}
+12 -8
View File
@@ -3,10 +3,15 @@
#include "Graphics/Graphics.h"
#include "Asset/AssetRegistry.h"
#include "Graphics/Vulkan/Enums.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#pragma GCC diagnostic ignored "-Wunused-variable"
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
#pragma GCC diagnostic pop
#include "ktx.h"
using namespace Seele;
@@ -17,7 +22,7 @@ TextureLoader::TextureLoader(Gfx::PGraphics graphics)
OTextureAsset placeholder = new TextureAsset();
placeholderAsset = placeholder;
import(TextureImportArgs{
.filePath = std::filesystem::absolute("./textures/placeholder.png"),
.filePath = std::filesystem::absolute("textures/placeholder.png"),
.importPath = "",
}, placeholderAsset);
AssetRegistry::get().assetRoot->textures[""] = std::move(placeholder);
@@ -46,10 +51,9 @@ PTextureAsset TextureLoader::getPlaceholderTexture()
void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
{
int totalWidth, totalHeight, n;
int totalWidth = 0, totalHeight = 0, n = 0;
unsigned char* data = stbi_load(args.filePath.string().c_str(), &totalWidth, &totalHeight, &n, 4);
ktxTexture2* kTexture;
ktxTexture2* kTexture = nullptr;
ktxTextureCreateInfo createInfo;
createInfo.vkFormat = VK_FORMAT_R8G8B8A8_UNORM;
createInfo.baseDepth = 1;
@@ -61,7 +65,7 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
if (args.type == TextureImportType::TEXTURE_CUBEMAP)
{
uint32 faceWidth = totalWidth / 4;
uint32 faceHeight = totalHeight / 3;
// uint32 faceHeight = totalHeight / 3;
// Cube map
createInfo.baseWidth = totalWidth / 4;
createInfo.baseHeight = totalHeight / 3;
@@ -75,9 +79,9 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
auto loadCubeFace = [&kTexture, &faceWidth, &totalWidth, &data](int xPos, int yPos, int faceName)
{
std::vector<unsigned char> vec(faceWidth * faceWidth * 4);
for (int y = 0; y < faceWidth; ++y)
for (uint32 y = 0; y < faceWidth; ++y)
{
for (int x = 0; x < faceWidth; ++x)
for (uint32 x = 0; x < faceWidth; ++x)
{
int imgX = x + (xPos * faceWidth);
int imgY = y + (yPos * faceWidth);
@@ -114,7 +118,7 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
.structSize = sizeof(ktxBasisParams),
.uastc = false,
.threadCount = std::thread::hardware_concurrency(),
.compressionLevel = 5,
.compressionLevel = 0,
.qualityLevel = 0,
};
+1 -1
View File
@@ -5,7 +5,7 @@ using namespace Seele;
using namespace Seele::Editor;
PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath)
: GameView(std::move(graphics), std::move(window), std::move(createInfo), dllPath)
: GameView(graphics, window, createInfo, dllPath)
{
}
-4
View File
@@ -60,15 +60,11 @@ void SceneView::render()
renderGraph.render(viewportCamera);
}
static float cameraSpeed = 1;
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier)
{
cameraSystem.keyCallback(code, action);
}
static bool mouseDown = false;
void SceneView::mouseMoveCallback(double xPos, double yPos)
{
cameraSystem.mouseMoveCallback(xPos, yPos);
+1 -1
View File
@@ -8,8 +8,8 @@ ViewportControl::ViewportControl(const URect& viewportDimensions, Vector initial
: position(initialPos)
, fieldOfView(glm::radians(70.f))
, aspectRatio(static_cast<float>(viewportDimensions.size.x) / viewportDimensions.size.y)
, yaw(glm::pi<float>()/-2.0f)
, pitch(0)
, yaw(glm::pi<float>()/-2.0f)
{
std::cout << yaw << " " << pitch << std::endl;
}
+71 -63
View File
@@ -12,6 +12,7 @@
#include "Asset/FontLoader.h"
#include "Asset/AssetImporter.h"
#include "Graphics/StaticMeshVertexData.h"
#include <format>
using namespace Seele;
using namespace Seele::Editor;
@@ -20,11 +21,17 @@ extern AssetRegistry* instance;
int main()
{
std::string outputPath = "C:/Users/Dynamitos/TrackClearGame";
std::string cmakePath = "C:/Users/Dynamitos/TrackClearGame/cmake";
#ifdef WIN32
std::filesystem::path outputPath = "C:/Users/Dynamitos/TrackClearGame";
std::filesystem::path sourcePath= "C:/Users/Dynamitos/TrackClear";
std::filesystem::path binaryPath = sourcePath / "bin" / "TrackClear.dll";
#else
std::filesystem::path outputPath = "/home/dynamitos/TrackClearGame";
std::filesystem::path sourcePath= "/home/dynamitos/TrackClear";
std::filesystem::path binaryPath = sourcePath / "cmake" / "libTrackClear.so";
#endif
std::string gameName = "TrackClear";
std::string sourcePath = "C:/Users/Dynamitos/TrackClear/";
std::string binaryPath = "C:/Users/Dynamitos/TrackClear/bin/TrackClear.dll";
std::filesystem::path cmakePath = outputPath / "cmake";
Gfx::OGraphics graphics = new Vulkan::Graphics();
@@ -33,177 +40,177 @@ int main()
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
vd->init(graphics);
PWindowManager windowManager = new WindowManager();
AssetRegistry::init(std::string("C:/Users/Dynamitos/TrackClear/Assets"), graphics);
AssetRegistry::init(sourcePath / "Assets", graphics);
AssetImporter::init(graphics, AssetRegistry::getInstance());
AssetImporter::importFont(FontImportArgs{
.filePath = "./fonts/Calibri.ttf",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/arena.fbx",
.filePath = sourcePath / "old_resources/models/arena.fbx",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/train.fbx",
.filePath = sourcePath / "old_resources/models/train.fbx",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/bird.fbx",
.filePath= sourcePath / "old_resources/models/bird.fbx",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/cube.fbx",
.filePath= sourcePath / "old_resources/models/cube.fbx",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/flameThrower.fbx",
.filePath= sourcePath / "old_resources/models/flameThrower.fbx",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/player.fbx",
.filePath= sourcePath / "old_resources/models/player.fbx",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/shotgun.fbx",
.filePath= sourcePath / "old_resources/models/shotgun.fbx",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/track.fbx",
.filePath= sourcePath / "old_resources/models/track.fbx",
});
AssetImporter::importMesh(MeshImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/zombie.fbx",
.filePath= sourcePath / "old_resources/models/zombie.fbx",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Dirt.png",
.filePath= sourcePath / "old_resources/textures/Dirt.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/DirtGrass.png",
.filePath= sourcePath / "old_resources/textures/DirtGrass.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Grass.png",
.filePath= sourcePath / "old_resources/textures/Grass.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Ice.png",
.filePath= sourcePath / "old_resources/textures/Ice.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Lava.png",
.filePath= sourcePath / "old_resources/textures/Lava.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Obsidian.png",
.filePath= sourcePath / "old_resources/textures/Obsidian.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Rocks.png",
.filePath= sourcePath / "old_resources/textures/Rocks.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Sand.png",
.filePath= sourcePath / "old_resources/textures/Sand.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Water.png",
.filePath= sourcePath / "old_resources/textures/Water.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Wood.png",
.filePath= sourcePath / "old_resources/textures/Wood.png",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level0/blendMap.png",
.filePath= sourcePath / "old_resources/textures/level0/blendMap.png",
.importPath = "level0",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level0/heightMap.png",
.filePath= sourcePath / "old_resources/textures/level0/heightMap.png",
.importPath = "level0",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level0/trackMap.png",
.filePath= sourcePath / "old_resources/textures/level0/trackMap.png",
.importPath = "level0",
});
AssetImporter::importMaterial(MaterialImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/shaders/TerrainMaterial.json",
.filePath= sourcePath / "old_resources/shaders/TerrainMaterial.json",
.importPath = "level0",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level1/blendMap.png",
.filePath= sourcePath / "old_resources/textures/level1/blendMap.png",
.importPath = "level1",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level1/heightMap.png",
.filePath= sourcePath / "old_resources/textures/level1/heightMap.png",
.importPath = "level1",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level1/trackMap.png",
.filePath= sourcePath / "old_resources/textures/level1/trackMap.png",
.importPath = "level1",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level2/blendMap.png",
.filePath= sourcePath / "old_resources/textures/level2/blendMap.png",
.importPath = "level2",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level2/heightMap.png",
.filePath= sourcePath / "old_resources/textures/level2/heightMap.png",
.importPath = "level2",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level2/trackMap.png",
.filePath= sourcePath / "old_resources/textures/level2/trackMap.png",
.importPath = "level2",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level3/blendMap.png",
.filePath= sourcePath / "old_resources/textures/level3/blendMap.png",
.importPath = "level3",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level3/heightMap.png",
.filePath= sourcePath / "old_resources/textures/level3/heightMap.png",
.importPath = "level3",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level3/trackMap.png",
.filePath= sourcePath / "old_resources/textures/level3/trackMap.png",
.importPath = "level3",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level4/blendMap.png",
.filePath= sourcePath / "old_resources/textures/level4/blendMap.png",
.importPath = "level4",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level4/heightMap.png",
.filePath= sourcePath / "old_resources/textures/level4/heightMap.png",
.importPath = "level4",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level4/trackMap.png",
.filePath= sourcePath / "old_resources/textures/level4/trackMap.png",
.importPath = "level4",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level5/blendMap.png",
.filePath= sourcePath / "old_resources/textures/level5/blendMap.png",
.importPath = "level5",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level5/heightMap.png",
.filePath= sourcePath / "old_resources/textures/level5/heightMap.png",
.importPath = "level5",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level5/trackMap.png",
.filePath= sourcePath / "old_resources/textures/level5/trackMap.png",
.importPath = "level5",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level6/blendMap.png",
.filePath= sourcePath / "old_resources/textures/level6/blendMap.png",
.importPath = "level6",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level6/heightMap.png",
.filePath= sourcePath / "old_resources/textures/level6/heightMap.png",
.importPath = "level6",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level6/trackMap.png",
.filePath= sourcePath / "old_resources/textures/level6/trackMap.png",
.importPath = "level6",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level7/blendMap.png",
.filePath= sourcePath / "old_resources/textures/level7/blendMap.png",
.importPath = "level7",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level7/heightMap.png",
.filePath= sourcePath / "old_resources/textures/level7/heightMap.png",
.importPath = "level7",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level7/trackMap.png",
.filePath= sourcePath / "old_resources/textures/level7/trackMap.png",
.importPath = "level7",
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/skyboxes/FS000_Day_01.png",
.filePath= sourcePath / "old_resources/skyboxes/FS000_Day_01.png",
.type = TextureImportType::TEXTURE_CUBEMAP,
});
AssetImporter::importTexture(TextureImportArgs{
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/skyboxes/FS000_Night_01.png",
.filePath= sourcePath / "old_resources/skyboxes/FS000_Night_01.png",
.type = TextureImportType::TEXTURE_CUBEMAP,
});
@@ -220,7 +227,7 @@ int main()
sceneViewInfo.dimensions.size.y = 720;
sceneViewInfo.dimensions.offset.x = 0;
sceneViewInfo.dimensions.offset.y = 0;
PGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath);
OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath);
//ViewportCreateInfo inspectorViewInfo;
//inspectorViewInfo.dimensions.size.x = 640;
@@ -235,16 +242,17 @@ int main()
//export game
std::filesystem::create_directories(outputPath);
std::system(std::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath, binaryPath).c_str());
std::system(std::format("cmake -S {} -B {}", cmakePath, cmakePath).c_str());
std::system(std::format("cmake --build {}", cmakePath).c_str());
std::filesystem::copy(std::filesystem::path(sourcePath) / "Assets", std::filesystem::path(outputPath) / "Assets", std::filesystem::copy_options::recursive);
std::filesystem::copy("shaders", std::filesystem::path(outputPath) / "shaders", std::filesystem::copy_options::recursive);
std::filesystem::copy("textures", std::filesystem::path(outputPath) / "textures", std::filesystem::copy_options::recursive);
std::filesystem::copy_file("assimp-vc143-mt.dll", std::filesystem::path(outputPath) / "assimp-vc143-mt.dll");
std::filesystem::copy_file("slang.dll", std::filesystem::path(outputPath) / "slang.dll");
std::filesystem::copy_file("slang-glslang.dll", std::filesystem::path(outputPath) / "slang-glslang.dll");
std::filesystem::copy_file("slang-llvm.dll", std::filesystem::path(outputPath) / "slang-llvm.dll");
std::system(std::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str());
std::system(std::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str());
std::system(std::format("cmake --build {}", cmakePath.generic_string()).c_str());
std::filesystem::copy(sourcePath / "Assets", outputPath / "Assets", std::filesystem::copy_options::recursive);
std::filesystem::copy("shaders", outputPath / "shaders", std::filesystem::copy_options::recursive);
std::filesystem::copy("textures", outputPath / "textures", std::filesystem::copy_options::recursive);
#ifdef WIN32
std::filesystem::copy_file("assimp-vc143-mt.dll", outputPath / "assimp-vc143-mt.dll");
std::filesystem::copy_file("slang.dll", outputPath / "slang.dll");
std::filesystem::copy_file("slang-glslang.dll", outputPath / "slang-glslang.dll");
std::filesystem::copy_file("slang-llvm.dll", outputPath / "slang-llvm.dll");
#endif
return 0;
}