diff --git a/CMakeLists.txt b/CMakeLists.txt index d6653f9..0933451 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,6 @@ target_link_libraries(Engine PUBLIC crcpp) target_link_libraries(Engine PUBLIC fmt::fmt) target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator) target_link_libraries(Engine PUBLIC slang) -target_link_libraries(Engine PUBLIC spirv-cross-glsl spirv-cross-msl) target_link_libraries(Engine PUBLIC glslang::glslang) if(APPLE) target_include_directories(Engine PUBLIC /usr/local/include) @@ -108,11 +107,11 @@ if(MSVC) target_compile_options(Editor PUBLIC /std:c++20 /Zi /MP14 /W4 /DEBUG) target_sources(Engine INTERFACE $ - $ + $ ) install(FILES Seele.natvis - DESTINATION .) + DESTINATION Seele/) else() target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20 -Wno-missing-field-initializers -Wno-unused-function -fsanitize=address) target_compile_options(Editor PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20 -fsanitize=address) @@ -161,7 +160,7 @@ install( EXPORT EngineTargets FILE_SET HEADERS - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Seele) export(EXPORT EngineTargets FILE "${CMAKE_BINARY_DIR}/EngineTargets.cmake" @@ -179,19 +178,22 @@ install(EXPORT EngineTargets NAMESPACE Seele:: DESTINATION - ${CMAKE_INSTALL_PREFIX} + ${CMAKE_INSTALL_PREFIX}/lib/cmake/Seele ) install( FILES ${CMAKE_BINARY_DIR}/SeeleConfig.cmake DESTINATION - ${CMAKE_INSTALL_PREFIX} + ${CMAKE_INSTALL_PREFIX}/lib/cmake/Seele ) install( DIRECTORY - ${CMAKE_SOURCE_DIR}/res + ${CMAKE_SOURCE_DIR}/res/cmake + ${CMAKE_SOURCE_DIR}/res/fonts + ${CMAKE_SOURCE_DIR}/res/shaders + ${CMAKE_SOURCE_DIR}/res/textures DESTINATION - ${CMAKE_INSTALL_PREFIX} + ${CMAKE_INSTALL_PREFIX}/bin ) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 8197fe2..37966c7 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -39,12 +39,12 @@ add_library(crcpp INTERFACE) target_include_directories(crcpp INTERFACE $ - $ + $ ) install(FILES ${CRCPP_ROOT}/inc/CRC.h - DESTINATION ${CMAKE_INSTALL_PREFIX}/include + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Seele ) add_library(metal INTERFACE) diff --git a/res/shaders/BasePass.slang b/res/shaders/BasePass.slang index 0770393..2c73c22 100644 --- a/res/shaders/BasePass.slang +++ b/res/shaders/BasePass.slang @@ -31,5 +31,5 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target //uint lightIndex = pLightCullingData.lightIndexList[startOffset + i]; result += pLightEnv.pointLights[i].illuminate(lightingParams, brdf); } - return float4(params.vertexColor, 1.0f); + return float4(1.0f, 0.1f, 0.5f, 1.0f); } diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 5aab290..8f35875 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -1,20 +1,17 @@ -#include "Graphics/Initializer.h" -#include "Graphics/Metal/Graphics.h" -#include "Window/WindowManager.h" -#include "Window/SceneView.h" -#include "Window/PlayView.h" -#include "Window/InspectorView.h" -#include "Asset/AssetRegistry.h" #include "Asset/AssetImporter.h" -#include "Asset/TextureLoader.h" -#include "Graphics/Vulkan/Graphics.h" -#include "Graphics/Metal/Graphics.h" +#include "Asset/AssetRegistry.h" +#include "Asset/FontLoader.h" +#include "Asset/MaterialLoader.h" #include "Asset/MeshLoader.h" #include "Asset/TextureLoader.h" -#include "Asset/MaterialLoader.h" -#include "Asset/FontLoader.h" -#include "Asset/AssetImporter.h" +#include "Graphics/Initializer.h" +#include "Graphics/Metal/Graphics.h" #include "Graphics/StaticMeshVertexData.h" +#include "Graphics/Vulkan/Graphics.h" +#include "Window/InspectorView.h" +#include "Window/PlayView.h" +#include "Window/SceneView.h" +#include "Window/WindowManager.h" #include using namespace Seele; @@ -23,256 +20,255 @@ using namespace Seele::Editor; // make it global so it gets deleted last and automatically static Gfx::OGraphics graphics; -int main() -{ +int main() { #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"; + std::filesystem::path outputPath = "C:/Users/Dynamitos/MeshShadingDemoGame"; + std::filesystem::path sourcePath = "C:/Users/Dynamitos/MeshShadingDemo"; + std::filesystem::path binaryPath = sourcePath / "bin" / "MeshShadingDemo.dll"; #elif __APPLE__ - std::filesystem::path outputPath = "/Users/dynamitos/TrackClearGame"; - std::filesystem::path sourcePath= "/Users/dynamitos/TrackClear"; - std::filesystem::path binaryPath = sourcePath / "cmake" / "libTrackClear.dylib"; + std::filesystem::path outputPath = "/Users/dynamitos/MeshShadingDemoGame"; + std::filesystem::path sourcePath = "/Users/dynamitos/MeshShadingDemo"; + std::filesystem::path binaryPath = sourcePath / "cmake" / "libMeshShadingDemo.dylib"; #else - std::filesystem::path outputPath = "/home/dynamitos/TrackClearGame"; - std::filesystem::path sourcePath= "/home/dynamitos/TrackClear"; - std::filesystem::path binaryPath = sourcePath / "cmake" / "libTrackClear.so"; + std::filesystem::path outputPath = "/home/dynamitos/MeshShadingDemoGame"; + std::filesystem::path sourcePath = "/home/dynamitos/MeshShadingDemo"; + std::filesystem::path binaryPath = sourcePath / "cmake" / "libMeshShadingDemo.so"; #endif - std::string gameName = "TrackClear"; - std::filesystem::path cmakePath = outputPath / "cmake"; + std::string gameName = "MeshShadingDemo"; + std::filesystem::path cmakePath = outputPath / "cmake"; #ifdef __APPLE__ - graphics = new Metal::Graphics(); + graphics = new Metal::Graphics(); #else - graphics = new Vulkan::Graphics(); + graphics = new Vulkan::Graphics(); #endif - GraphicsInitializer initializer; - graphics->init(initializer); - StaticMeshVertexData* vd = StaticMeshVertexData::getInstance(); - vd->init(graphics); - OWindowManager windowManager = new WindowManager(); - AssetRegistry::init(sourcePath / "Assets", graphics); - AssetImporter::init(graphics); - AssetImporter::importFont(FontImportArgs{ - .filePath = "./fonts/Calibri.ttf", - }); - //AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "old_resources/models/arena.fbx", - // }); - AssetImporter::importMesh(MeshImportArgs{ - .filePath = sourcePath / "old_resources/models/frog.fbx", - }); - AssetImporter::importMesh(MeshImportArgs{ - .filePath = sourcePath / "old_resources/models/train.fbx", - }); - //AssetImporter::importMesh(MeshImportArgs{ - // .filePath= sourcePath / "old_resources/models/bird.fbx", - // }); - AssetImporter::importMesh(MeshImportArgs{ - .filePath= sourcePath / "old_resources/models/cube.fbx", - }); - //AssetImporter::importMesh(MeshImportArgs{ - // .filePath= sourcePath / "old_resources/models/flameThrower.fbx", - // }); - //AssetImporter::importMesh(MeshImportArgs{ - // .filePath= sourcePath / "old_resources/models/player.fbx", - // }); - //AssetImporter::importMesh(MeshImportArgs{ - // .filePath= sourcePath / "old_resources/models/shotgun.fbx", - // }); - //AssetImporter::importMesh(MeshImportArgs{ - // .filePath= sourcePath / "old_resources/models/track.fbx", - // }); - //AssetImporter::importMesh(MeshImportArgs{ - // .filePath= sourcePath / "old_resources/models/zombie.fbx", - // }); + GraphicsInitializer initializer; + graphics->init(initializer); + StaticMeshVertexData* vd = StaticMeshVertexData::getInstance(); + vd->init(graphics); + OWindowManager windowManager = new WindowManager(); + AssetRegistry::init(sourcePath / "Assets", graphics); + AssetImporter::init(graphics); + AssetImporter::importFont(FontImportArgs{ + .filePath = "./fonts/Calibri.ttf", + }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath = sourcePath / "old_resources/models/arena.fbx", + // }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath = sourcePath / "old_resources/models/frog.fbx", + // }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath = sourcePath / "old_resources/models/train.fbx", + // }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath= sourcePath / "old_resources/models/bird.fbx", + // }); + AssetImporter::importMesh(MeshImportArgs{ + .filePath = sourcePath / "import/models/cube.fbx", + }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath= sourcePath / "old_resources/models/flameThrower.fbx", + // }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath= sourcePath / "old_resources/models/player.fbx", + // }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath= sourcePath / "old_resources/models/shotgun.fbx", + // }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath= sourcePath / "old_resources/models/track.fbx", + // }); + // AssetImporter::importMesh(MeshImportArgs{ + // .filePath= sourcePath / "old_resources/models/zombie.fbx", + // }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Dirt.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/DirtGrass.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Grass.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Ice.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Lava.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Obsidian.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Rocks.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Sand.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Water.png", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/Wood.png", - }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Dirt.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/DirtGrass.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Grass.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Ice.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Lava.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Obsidian.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Rocks.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Sand.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Water.png", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/Wood.png", + // }); + // + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level0/blendMap.png", + // .importPath = "level0", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level0/heightMap.png", + // .importPath = "level0", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level0/trackMap.png", + // .importPath = "level0", + // }); + // AssetImporter::importMaterial(MaterialImportArgs{ + // .filePath= sourcePath / "old_resources/shaders/TerrainMaterial.json", + // .importPath = "level0", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level1/blendMap.png", + // .importPath = "level1", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level1/heightMap.png", + // .importPath = "level1", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level1/trackMap.png", + // .importPath = "level1", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level2/blendMap.png", + // .importPath = "level2", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level2/heightMap.png", + // .importPath = "level2", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level2/trackMap.png", + // .importPath = "level2", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level3/blendMap.png", + // .importPath = "level3", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level3/heightMap.png", + // .importPath = "level3", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level3/trackMap.png", + // .importPath = "level3", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level4/blendMap.png", + // .importPath = "level4", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level4/heightMap.png", + // .importPath = "level4", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level4/trackMap.png", + // .importPath = "level4", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level5/blendMap.png", + // .importPath = "level5", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level5/heightMap.png", + // .importPath = "level5", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level5/trackMap.png", + // .importPath = "level5", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level6/blendMap.png", + // .importPath = "level6", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level6/heightMap.png", + // .importPath = "level6", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level6/trackMap.png", + // .importPath = "level6", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level7/blendMap.png", + // .importPath = "level7", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level7/heightMap.png", + // .importPath = "level7", + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/textures/level7/trackMap.png", + // .importPath = "level7", + // }); + // + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/skyboxes/FS000_Day_01.png", + // .type = TextureImportType::TEXTURE_CUBEMAP, + // }); + // AssetImporter::importTexture(TextureImportArgs{ + // .filePath= sourcePath / "old_resources/skyboxes/FS000_Night_01.png", + // .type = TextureImportType::TEXTURE_CUBEMAP, + // }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level0/blendMap.png", - .importPath = "level0", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level0/heightMap.png", - .importPath = "level0", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level0/trackMap.png", - .importPath = "level0", - }); - AssetImporter::importMaterial(MaterialImportArgs{ - .filePath= sourcePath / "old_resources/shaders/TerrainMaterial.json", - .importPath = "level0", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level1/blendMap.png", - .importPath = "level1", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level1/heightMap.png", - .importPath = "level1", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level1/trackMap.png", - .importPath = "level1", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level2/blendMap.png", - .importPath = "level2", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level2/heightMap.png", - .importPath = "level2", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level2/trackMap.png", - .importPath = "level2", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level3/blendMap.png", - .importPath = "level3", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level3/heightMap.png", - .importPath = "level3", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level3/trackMap.png", - .importPath = "level3", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level4/blendMap.png", - .importPath = "level4", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level4/heightMap.png", - .importPath = "level4", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level4/trackMap.png", - .importPath = "level4", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level5/blendMap.png", - .importPath = "level5", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level5/heightMap.png", - .importPath = "level5", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level5/trackMap.png", - .importPath = "level5", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level6/blendMap.png", - .importPath = "level6", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level6/heightMap.png", - .importPath = "level6", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level6/trackMap.png", - .importPath = "level6", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level7/blendMap.png", - .importPath = "level7", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level7/heightMap.png", - .importPath = "level7", - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/textures/level7/trackMap.png", - .importPath = "level7", - }); + WindowCreateInfo mainWindowInfo; + mainWindowInfo.title = "SeeleEngine"; + mainWindowInfo.width = 1920; + mainWindowInfo.height = 1080; + mainWindowInfo.preferredFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB; + auto window = windowManager->addWindow(graphics, mainWindowInfo); + ViewportCreateInfo sceneViewInfo; + sceneViewInfo.dimensions.size.x = 1920; + sceneViewInfo.dimensions.size.y = 1080; + sceneViewInfo.dimensions.offset.x = 0; + sceneViewInfo.dimensions.offset.y = 0; + sceneViewInfo.numSamples = Gfx::SE_SAMPLE_COUNT_1_BIT; + OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string()); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/skyboxes/FS000_Day_01.png", - .type = TextureImportType::TEXTURE_CUBEMAP, - }); - AssetImporter::importTexture(TextureImportArgs{ - .filePath= sourcePath / "old_resources/skyboxes/FS000_Night_01.png", - .type = TextureImportType::TEXTURE_CUBEMAP, - }); + // ViewportCreateInfo inspectorViewInfo; + // inspectorViewInfo.dimensions.size.x = 640; + // inspectorViewInfo.dimensions.size.y = 720; + // inspectorViewInfo.dimensions.offset.x = 640; + // inspectorViewInfo.dimensions.offset.y = 0; + // PInspectorView inspectorView = new InspectorView(graphics, window, inspectorViewInfo); + // window->addView(inspectorView); + sceneView->setFocused(); - WindowCreateInfo mainWindowInfo; - mainWindowInfo.title = "SeeleEngine"; - mainWindowInfo.width = 1920; - mainWindowInfo.height = 1080; - mainWindowInfo.preferredFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB; - auto window = windowManager->addWindow(graphics, mainWindowInfo); - ViewportCreateInfo sceneViewInfo; - sceneViewInfo.dimensions.size.x = 1920; - sceneViewInfo.dimensions.size.y = 1080; - sceneViewInfo.dimensions.offset.x = 0; - sceneViewInfo.dimensions.offset.y = 0; - sceneViewInfo.numSamples = Gfx::SE_SAMPLE_COUNT_1_BIT; - OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string()); - - //ViewportCreateInfo inspectorViewInfo; - //inspectorViewInfo.dimensions.size.x = 640; - //inspectorViewInfo.dimensions.size.y = 720; - //inspectorViewInfo.dimensions.offset.x = 640; - //inspectorViewInfo.dimensions.offset.y = 0; - //PInspectorView inspectorView = new InspectorView(graphics, window, inspectorViewInfo); - //window->addView(inspectorView); - sceneView->setFocused(); - - - while (windowManager->isActive()) - { - windowManager->render(); - } - vd->destroy(); - //export game - if (false) - { - std::filesystem::create_directories(outputPath); - std::system(fmt::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(fmt::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str()); - std::system(fmt::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); + while (windowManager->isActive()) { + windowManager->render(); + } + vd->destroy(); + // export game + if (false) { + std::filesystem::create_directories(outputPath); + std::system(fmt::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(fmt::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str()); + std::system(fmt::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"); + 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; + } + return 0; } \ No newline at end of file diff --git a/src/Engine/Graphics/Metal/Command.mm b/src/Engine/Graphics/Metal/Command.mm index 9c3c1fb..ffd21e6 100644 --- a/src/Engine/Graphics/Metal/Command.mm +++ b/src/Engine/Graphics/Metal/Command.mm @@ -25,6 +25,7 @@ void Command::beginRenderPass(PRenderPass renderPass) { blitEncoder->endEncoding(); blitEncoder = nullptr; } + renderPass->updateRenderPass(); parallelEncoder = cmdBuffer->parallelRenderCommandEncoder(renderPass->getDescriptor()); } diff --git a/src/Engine/Graphics/Metal/Graphics.mm b/src/Engine/Graphics/Metal/Graphics.mm index 6ad4d08..cec352f 100644 --- a/src/Engine/Graphics/Metal/Graphics.mm +++ b/src/Engine/Graphics/Metal/Graphics.mm @@ -31,7 +31,7 @@ void Graphics::init(GraphicsInitializer) queue = new CommandQueue(this); ioQueue = new IOCommandQueue(this); cache = new PipelineCache(this, "pipelines.metal"); - meshShadingEnabled = true; + meshShadingEnabled = false; } Gfx::OWindow Graphics::createWindow(const WindowCreateInfo &createInfo) diff --git a/src/Engine/Graphics/Metal/RenderPass.h b/src/Engine/Graphics/Metal/RenderPass.h index 60c5336..753eddf 100644 --- a/src/Engine/Graphics/Metal/RenderPass.h +++ b/src/Engine/Graphics/Metal/RenderPass.h @@ -12,6 +12,7 @@ class RenderPass : public Gfx::RenderPass public: RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array dependencies, Gfx::PViewport viewport); virtual ~RenderPass(); + void updateRenderPass(); MTL::RenderPassDescriptor* getDescriptor() const { return renderPass; @@ -20,8 +21,6 @@ private: PGraphics graphics; Gfx::PViewport viewport; MTL::RenderPassDescriptor* renderPass; - MTL::RenderPassDepthAttachmentDescriptor* depth; - MTL::RenderPassStencilAttachmentDescriptor* stencil; }; DEFINE_REF(RenderPass) } // namespace Metal diff --git a/src/Engine/Graphics/Metal/RenderPass.mm b/src/Engine/Graphics/Metal/RenderPass.mm index 4eaa092..3c11a81 100644 --- a/src/Engine/Graphics/Metal/RenderPass.mm +++ b/src/Engine/Graphics/Metal/RenderPass.mm @@ -7,55 +7,53 @@ using namespace Seele; using namespace Seele::Metal; -RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, - Array dependencies, +RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array dependencies, Gfx::PViewport viewport) - : Gfx::RenderPass(layout, dependencies), graphics(graphics), - viewport(viewport) { - renderPass = MTL::RenderPassDescriptor::alloc()->init(); + : Gfx::RenderPass(layout, dependencies), graphics(graphics), viewport(viewport) { + renderPass = MTL::RenderPassDescriptor::renderPassDescriptor(); renderPass->setRenderTargetArrayLength(1); renderPass->setRenderTargetWidth(viewport->getWidth()); renderPass->setRenderTargetHeight(viewport->getHeight()); renderPass->setDefaultRasterSampleCount(viewport->getSamples()); for (size_t i = 0; i < layout.colorAttachments.size(); ++i) { - const auto &color = layout.colorAttachments[i]; - MTL::RenderPassColorAttachmentDescriptor *desc = - renderPass->colorAttachments()->object(i); - desc->setClearColor(MTL::ClearColor( - color.clear.color.float32[0], color.clear.color.float32[1], - color.clear.color.float32[2], color.clear.color.float32[3])); + const auto& color = layout.colorAttachments[i]; + MTL::RenderPassColorAttachmentDescriptor* desc = renderPass->colorAttachments()->object(i); + desc->setClearColor(MTL::ClearColor(color.clear.color.float32[0], color.clear.color.float32[1], + color.clear.color.float32[2], color.clear.color.float32[3])); desc->setLoadAction(cast(color.getLoadOp())); desc->setStoreAction(cast(color.getStoreOp())); desc->setLevel(0); - desc->setTexture(color.getTexture().cast()->getTexture()); if (!layout.resolveAttachments.empty()) { - const auto &resolve = layout.resolveAttachments[i]; + const auto& resolve = layout.resolveAttachments[i]; desc->setResolveLevel(0); desc->setStoreAction(MTL::StoreActionStoreAndMultisampleResolve); - desc->setResolveTexture( - resolve.getTexture().cast()->getTexture()); + desc->setResolveTexture(resolve.getTexture().cast()->getTexture()); } } if (layout.depthAttachment.getTexture() != nullptr) { - depth = MTL::RenderPassDepthAttachmentDescriptor::alloc()->init(); + auto depth = renderPass->depthAttachment(); depth->setClearDepth(layout.depthAttachment.clear.depthStencil.depth); depth->setLoadAction(cast(layout.depthAttachment.getLoadOp())); depth->setStoreAction(cast(layout.depthAttachment.getStoreOp())); - depth->setTexture( - layout.depthAttachment.getTexture().cast()->getTexture()); + if (layout.depthResolveAttachment.getTexture() != nullptr) { - depth->setResolveTexture(layout.depthResolveAttachment.getTexture() - .cast() - ->getTexture()); + depth->setResolveTexture(layout.depthResolveAttachment.getTexture().cast()->getTexture()); depth->setStoreAction(MTL::StoreActionStoreAndMultisampleResolve); } - renderPass->setDepthAttachment(depth); } // TODO: stencil } -RenderPass::~RenderPass() { - depth->release(); - stencil->release(); - renderPass->release(); +RenderPass::~RenderPass() {} + +void RenderPass::updateRenderPass() { + for (size_t i = 0; i < layout.colorAttachments.size(); ++i) { + const auto& color = layout.colorAttachments[i]; + auto desc = renderPass->colorAttachments()->object(i); + desc->setTexture(color.getTexture().cast()->getTexture()); + } + if (layout.depthAttachment.getTexture() != nullptr) { + auto depth = renderPass->depthAttachment(); + depth->setTexture(layout.depthAttachment.getTexture().cast()->getTexture()); + } } \ No newline at end of file diff --git a/src/Engine/Graphics/Metal/Window.h b/src/Engine/Graphics/Metal/Window.h index 422df3d..42c18d6 100644 --- a/src/Engine/Graphics/Metal/Window.h +++ b/src/Engine/Graphics/Metal/Window.h @@ -1,4 +1,5 @@ #pragma once +#include "Foundation/NSAutoreleasePool.hpp" #include "Graphics.h" #include "Graphics/Window.h" #include "Resources.h" diff --git a/src/Engine/Graphics/Metal/Window.mm b/src/Engine/Graphics/Metal/Window.mm index 191f6e5..e543b92 100644 --- a/src/Engine/Graphics/Metal/Window.mm +++ b/src/Engine/Graphics/Metal/Window.mm @@ -1,5 +1,6 @@ #include "Window.h" #include "Command.h" +#include "Foundation/NSAutoreleasePool.hpp" #include "Graphics/Initializer.h" #include "Graphics/Metal/Enums.h" #include "Graphics/Texture.h" @@ -80,8 +81,6 @@ Window::Window(PGraphics graphics, const WindowCreateInfo& createInfo) : graphic metalLayer.drawableSize = CGSizeMake(createInfo.width, createInfo.height); metalWindow.contentView.layer = metalLayer; metalWindow.contentView.wantsLayer = YES; - drawable = (__bridge CA::MetalDrawable*)[metalLayer nextDrawable]; - createBackBuffer(); } Window::~Window() { glfwDestroyWindow(static_cast(windowHandle)); } @@ -89,9 +88,6 @@ Window::~Window() { glfwDestroyWindow(static_cast(windowHandle)); } void Window::pollInput() { glfwPollEvents(); } void Window::beginFrame() { - if (drawable) { - drawable->release(); - } drawable = (__bridge CA::MetalDrawable*)[metalLayer nextDrawable]; createBackBuffer(); } @@ -146,7 +142,7 @@ void Window::resize(int width, int height) { framebufferWidth = width; framebufferHeight = height; // Deallocate the textures if they have been created - drawable = (__bridge CA::MetalDrawable*)[metalLayer nextDrawable]; + drawable = (__bridge CA::MetalDrawable*)[[metalLayer nextDrawable] autorelease]; createBackBuffer(); resizeCallback(width, height); } diff --git a/src/Engine/Window/GameView.cpp b/src/Engine/Window/GameView.cpp index 1c34a5c..bb9a8fb 100644 --- a/src/Engine/Window/GameView.cpp +++ b/src/Engine/Window/GameView.cpp @@ -21,7 +21,7 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate renderGraph.addPass(new DepthPrepass(graphics, scene)); renderGraph.addPass(new LightCullingPass(graphics, scene)); renderGraph.addPass(new BasePass(graphics, scene)); - renderGraph.addPass(new DebugPass(graphics, scene)); + //renderGraph.addPass(new DebugPass(graphics, scene)); //renderGraph.addPass(new SkyboxRenderPass(graphics, scene)); renderGraph.setViewport(viewport); renderGraph.createRenderPass();