material serialization fixes

This commit is contained in:
Dynamitos
2023-04-09 16:39:53 +02:00
parent b79525c1a6
commit 96d5cf67cb
11 changed files with 75 additions and 33 deletions
+2 -2
View File
@@ -8,10 +8,10 @@
"name": "Editor", "name": "Editor",
"type": "cppvsdbg", "type": "cppvsdbg",
"request": "launch", "request": "launch",
"program": "${workspaceRoot}/bin/Debug/Editor.exe", "program": "${workspaceRoot}/bin/Editor.exe",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceRoot}/bin/Debug", "cwd": "${workspaceRoot}/bin",
"console": "internalConsole", "console": "internalConsole",
"environment": [], "environment": [],
"symbolSearchPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\lib\\x64", "symbolSearchPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\lib\\x64",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"telemetry.enableTelemetry": false, "telemetry.enableTelemetry": false,
"cmake.buildDirectory": "${workspaceFolder}/bin/${buildType}", "cmake.buildDirectory": "${workspaceFolder}/bin",
"files.associations": { "files.associations": {
"*.h": "cpp", "*.h": "cpp",
"*.ush": "hlsl", "*.ush": "hlsl",
+9 -6
View File
@@ -39,13 +39,15 @@ project (Seele)
include(cmake/Superbuild.cmake) include(cmake/Superbuild.cmake)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
#Workaround for vs, because it places artifacts into an additional subfolder #Workaround for vs, because it places artifacts into an additional subfolder
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/Release) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/Release) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_STATIC_LIBS OFF)
if(WIN32) if(WIN32)
@@ -113,6 +115,7 @@ target_precompile_headers(Engine
if(MSVC) if(MSVC)
set(_CRT_SECURE_NO_WARNINGS) set(_CRT_SECURE_NO_WARNINGS)
target_compile_options(Engine PUBLIC /Zi /MP14 /W4 /DEBUG "/WX-") target_compile_options(Engine PUBLIC /Zi /MP14 /W4 /DEBUG "/WX-")
target_compile_options(Editor PUBLIC /Zi /MP14 /W4 /DEBUG "/WX-")
target_sources(Engine INTERFACE target_sources(Engine INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Seele.natvis> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Seele.natvis>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/Seele.natvis> $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/Seele.natvis>
+7 -10
View File
@@ -6,20 +6,17 @@
"debug": { "debug": {
"short": "Debug", "short": "Debug",
"long": "Enable debugging and validation", "long": "Enable debugging and validation",
"buildType": "Debug", "buildType": "Debug"
"settings": {
"CMAKE_DEBUG_POSTFIX": "d",
"CMAKE_BUILD_TYPE": "Debug"
}
}, },
"release": { "release": {
"short": "Release", "short": "Release",
"long": "Optimize binary for speed", "long": "Optimize binary for speed",
"buildType": "Release", "buildType": "Release"
"settings": { },
"CMAKE_DEBUG_POSTFIX": "", "relwithdebinfo": {
"CMAKE_BUILD_TYPE": "Release" "short": "RelWithDebInfo",
} "long": "Release with debug symbols",
"buildType": "RelWithDebInfo"
} }
} }
}, },
+21 -5
View File
@@ -19,12 +19,19 @@ extern AssetRegistry* instance;
int main() int main()
{ {
std::string outputPath = "C:/Users/Dynamitos/TrackClearGame";
std::string cmakePath = "C:/Users/Dynamitos/TrackClearGame/cmake";
std::string gameName = "TrackClear";
std::string sourcePath = "C:/Users/Dynamitos/TrackClear/";
std::string binaryPath = "C:/Users/Dynamitos/TrackClear/bin/TrackClear.dll";
Gfx::PGraphics graphics = new Vulkan::Graphics(); Gfx::PGraphics graphics = new Vulkan::Graphics();
GraphicsInitializer initializer; GraphicsInitializer initializer;
graphics->init(initializer); graphics->init(initializer);
PWindowManager windowManager = new WindowManager(); PWindowManager windowManager = new WindowManager();
AssetRegistry::init(std::string("C:\\Users\\Dynamitos\\TrackClear\\Assets"), graphics); AssetRegistry::init(std::string("C:/Users/Dynamitos/TrackClear/Assets"), graphics);
AssetImporter::init(graphics, instance); AssetImporter::init(graphics, instance);
AssetImporter::importFont(FontImportArgs{ AssetImporter::importFont(FontImportArgs{
.filePath = "./fonts/Calibri.ttf", .filePath = "./fonts/Calibri.ttf",
@@ -213,7 +220,7 @@ int main()
sceneViewInfo.dimensions.size.y = 720; sceneViewInfo.dimensions.size.y = 720;
sceneViewInfo.dimensions.offset.x = 0; sceneViewInfo.dimensions.offset.x = 0;
sceneViewInfo.dimensions.offset.y = 0; sceneViewInfo.dimensions.offset.y = 0;
PGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, "C:\\Users\\Dynamitos\\TrackClear\\bin\\TrackCleard.dll"); PGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath);
//ViewportCreateInfo inspectorViewInfo; //ViewportCreateInfo inspectorViewInfo;
//inspectorViewInfo.dimensions.size.x = 640; //inspectorViewInfo.dimensions.size.x = 640;
@@ -226,9 +233,18 @@ int main()
window->render(); window->render();
//export game //export game
std::string outputPath = "C:\\Users\\Dynamitos\\TrackClearGame";
std::filesystem::create_directories(outputPath);
std::system("cmake --configure"); 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");
return 0; return 0;
} }
+1
View File
@@ -26,5 +26,6 @@ void MaterialAsset::load(ArchiveBuffer& buffer)
{ {
material = new Material(); material = new Material();
material->load(buffer); material->load(buffer);
material->compile();
} }
+5 -3
View File
@@ -7,10 +7,12 @@ template<class F, class... Args>
concept invocable = std::invocable<F, Args...>; concept invocable = std::invocable<F, Args...>;
template<class T, class Archive> template<class T, class Archive>
concept serializable = requires(T t, Archive& a) concept serializable = requires(const T t, Archive& a)
{ {
t->save(a); t.save(a);
t->load(a); } && requires(T t, Archive& a)
{
t.load(a);
}; };
template<typename T> template<typename T>
concept enumeration = std::is_enum_v<T>; concept enumeration = std::is_enum_v<T>;
+3 -1
View File
@@ -52,8 +52,9 @@ Gfx::PDescriptorSet Material::createDescriptorSet()
void Material::save(ArchiveBuffer& buffer) const void Material::save(ArchiveBuffer& buffer) const
{ {
MaterialInterface::save(buffer); MaterialInterface::save(buffer);
Serialization::save(buffer,materialName); Serialization::save(buffer, materialName);
Serialization::save(buffer, layout->getSetIndex()); Serialization::save(buffer, layout->getSetIndex());
Serialization::save2(buffer, brdf);
const auto& bindings = layout->getBindings(); const auto& bindings = layout->getBindings();
Serialization::save(buffer, bindings.size()); Serialization::save(buffer, bindings.size());
for (const auto& binding : bindings) for (const auto& binding : bindings)
@@ -73,6 +74,7 @@ void Material::load(ArchiveBuffer& buffer)
Serialization::load(buffer, materialName); Serialization::load(buffer, materialName);
uint32 setIndex; uint32 setIndex;
Serialization::load(buffer, setIndex); Serialization::load(buffer, setIndex);
Serialization::load2(buffer, brdf);
uint64 numBindings; uint64 numBindings;
Serialization::load(buffer, numBindings); Serialization::load(buffer, numBindings);
layout = graphics->createDescriptorLayout(); layout = graphics->createDescriptorLayout();
+10
View File
@@ -65,6 +65,16 @@ namespace Serialization
{ {
buffer.readBytes(&type, sizeof(type)); buffer.readBytes(&type, sizeof(type));
} }
template<typename T>
static void save2(ArchiveBuffer& buffer, const T& type) requires(serializable<T>)
{
type.save(buffer);
}
template<typename T>
static void load2(ArchiveBuffer& buffer, T& type) requires(serializable<T>)
{
type.load(buffer);
}
//template<class T> //template<class T>
//static void save(ArchiveBuffer& buffer, const T& type) //static void save(ArchiveBuffer& buffer, const T& type)
//{ //{
+14 -5
View File
@@ -19,11 +19,7 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate
SkyboxRenderPass(graphics) SkyboxRenderPass(graphics)
)) ))
{ {
scene = new Scene(graphics); reloadGame();
gameInterface.reload(instance);
systemGraph = new SystemGraph();
gameInterface.getGame()->setupScene(scene, systemGraph);
renderGraph.updateViewport(viewport); renderGraph.updateViewport(viewport);
} }
@@ -74,6 +70,15 @@ void GameView::render()
}); });
} }
void GameView::reloadGame()
{
scene = new Scene(graphics);
gameInterface.reload(instance);
systemGraph = new SystemGraph();
gameInterface.getGame()->setupScene(scene, systemGraph);
}
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier) void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier)
{ {
scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input) scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input)
@@ -99,6 +104,10 @@ void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier)
// showDebug = !showDebug; // showDebug = !showDebug;
// debugPassData.vertices.clear(); // debugPassData.vertices.clear();
//} //}
if(code == KeyCode::KEY_R && action == InputAction::PRESS)
{
reloadGame();
}
input.keys[code] = action != InputAction::RELEASE; input.keys[code] = action != InputAction::RELEASE;
}); });
+2
View File
@@ -20,6 +20,8 @@ public:
virtual void prepareRender() override; virtual void prepareRender() override;
virtual void render() override; virtual void render() override;
void reloadGame();
private: private:
GameInterface gameInterface; GameInterface gameInterface;
RenderGraph< RenderGraph<