diff --git a/.vscode/launch.json b/.vscode/launch.json index 870709b..5e6075f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,22 +18,9 @@ "name": "Editor (Mac)", "type": "lldb", "request": "launch", - "program": "${workspaceRoot}/build/Editor", + "program": "${workspaceRoot}/build/external/Seele/Debug/Editor", "args": [], - "stopAtEntry": false, - "cwd": "${workspaceRoot}/build", - "environment": [ - { - "name": "VK_LAYER_PATH", - "value": "/opt/homebrew/opt/vulkan-validationlayers/share/vulkan/explicit_layer.d" - } - ], - "logging": { - "moduleLoad": false - }, - "externalConsole": false, - "MIMode": "lldb", - "targetArchitecture": "arm64" + "cwd": "${workspaceRoot}/build/external/Seele/Debug", }, { "name": "Editor (Linux)", diff --git a/CMakeLists.txt b/CMakeLists.txt index feed85d..5dcaefd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,14 +22,6 @@ set(CMAKE_TOOLCHAIN_FILE ${EXTERNAL_ROOT}/vcpkg/scripts/buildsystems/vcpkg.cmake set(CRCPP_ROOT ${EXTERNAL_ROOT}/CRCpp) set(METAL_ROOT ${EXTERNAL_ROOT}/metal-cpp) -if(WIN32) - set(VCPKG_BASE_FOLDER ${CMAKE_BINARY_DIR}/vcpkg_installed/x64-windows/) -elseif(APPLE) - set(VCPKG_BASE_FOLDER ${CMAKE_BINARY_DIR}/vcpkg_installed/arm64-osx/) -else() - set(VCPKG_BASE_FOLDER ${CMAKE_BINARY_DIR}/vcpkg_installed/x64-linux/) -endif() - set(Boost_NO_WARN_NEW_VERSIONS 1) project (Seele) @@ -48,9 +40,12 @@ find_package(Ktx CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED) find_package(fmt CONFIG REQUIRED) find_package(lunasvg CONFIG REQUIRED) +find_package(slang CONFIG REQUIRED) find_package(metis CONFIG REQUIRED) find_package(meshoptimizer CONFIG REQUIRED) -find_package(VulkanMemoryAllocator CONFIG REQUIRED) +if(NOT APPLE) + find_package(VulkanMemoryAllocator CONFIG REQUIRED) +endif() if(UNIX) find_package(Threads REQUIRED) @@ -63,8 +58,11 @@ endif() add_library(Engine SHARED "") target_include_directories(Engine PRIVATE src/Engine) -target_include_directories(Engine PRIVATE ${VCPKG_BASE_FOLDER}/include/) -target_link_libraries(Engine PUBLIC Vulkan::Vulkan) +if(NOT APPLE) + target_link_libraries(Engine PUBLIC Vulkan::Vulkan) + target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator) + target_link_libraries(Engine PUBLIC slang::slang-glslang) +endif() target_link_libraries(Engine PUBLIC EnTT::EnTT) target_link_libraries(Engine PUBLIC glfw) target_link_libraries(Engine PUBLIC glm::glm) @@ -77,17 +75,9 @@ target_link_libraries(Engine PUBLIC nlohmann_json::nlohmann_json) target_link_libraries(Engine PUBLIC crcpp) target_link_libraries(Engine PUBLIC fmt::fmt) target_link_libraries(Engine PUBLIC lunasvg::lunasvg) -target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator) target_link_libraries(Engine PUBLIC metis) target_link_libraries(Engine PUBLIC meshoptimizer::meshoptimizer) -if(WIN32) - target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/lib/slang.lib) -elseif(APPLE) - target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/debug/lib/libslang.dylib) -else() - target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/lib/libslang.so) - target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/lib/libslang-glslang.so) -endif() +target_link_libraries(Engine PUBLIC slang::slang) if(APPLE) target_link_libraries(Engine PUBLIC metal) @@ -142,8 +132,6 @@ add_subdirectory(src/) if(WIN32) add_custom_target(dll_copy ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VCPKG_BASE_FOLDER}/bin/slang.dll $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VCPKG_BASE_FOLDER}/bin/slang-glslang.dll $ COMMAND_EXPAND_LISTS DEPENDS Editor) elseif(APPLE) diff --git a/CMakePresets.json b/CMakePresets.json index f2c9ce5..256b3e5 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -40,6 +40,17 @@ "CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele" } }, + { + "name": "debug-mac", + "displayName": "Debug Mac (no ASan)", + "description": "Debug Mac build without sanitizers", + "binaryDir": "${sourceDir}/build", + "generator": "Xcode", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele" + } + }, { "name": "debug-asan", "displayName": "Debug (ASan)", @@ -71,6 +82,11 @@ "displayName": "Debug (no ASan)", "configurePreset": "debug" }, + { + "name": "debug-mac", + "displayName": "Debug Mac (no ASan)", + "configurePreset": "debug-mac" + }, { "name": "debug-asan", "displayName": "Debug (ASan)", diff --git a/src/Editor/Asset/TextureLoader.cpp b/src/Editor/Asset/TextureLoader.cpp index 6c0bc94..06075ad 100644 --- a/src/Editor/Asset/TextureLoader.cpp +++ b/src/Editor/Asset/TextureLoader.cpp @@ -2,7 +2,6 @@ #include "Asset/AssetRegistry.h" #include "Asset/TextureAsset.h" #include "Graphics/Graphics.h" -#include "Graphics/Vulkan/Enums.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-compare" @@ -15,7 +14,7 @@ #pragma GCC diagnostic pop #include "ktx.h" #include -#include +#include using namespace Seele; @@ -60,9 +59,8 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) { int totalWidth = 0, totalHeight = 0, n = 0; unsigned char* data = stbi_load(args.filePath.string().c_str(), &totalWidth, &totalHeight, &n, 4); ktxTexture2* kTexture = nullptr; - VkFormat format = VK_FORMAT_R8G8B8A8_SRGB; ktxTextureCreateInfo createInfo = { - .vkFormat = (uint32)format, + .vkFormat = 43, // rgba8srgb .baseDepth = 1, .numLevels = 1, .numLayers = 1, diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index c77a4f7..66c47d0 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -4,11 +4,11 @@ #include "Asset/FontLoader.h" #include "Asset/MaterialLoader.h" #include "Asset/MeshLoader.h" +#include "Graphics/Vulkan/Graphics.h" #include "Asset/TextureLoader.h" #include "Graphics/Initializer.h" #include "Material/Material.h" #include "Graphics/StaticMeshVertexData.h" -#include "Graphics/Vulkan/Graphics.h" #include "Window/PlayView.h" #include "Window/WindowManager.h" #include @@ -30,7 +30,7 @@ int main() { #else std::string libraryEnding = "so"; #endif - std::filesystem::path binaryPath = sourcePath / "bin" / fmt::format("{}.{}", gameName, libraryEnding); + std::filesystem::path binaryPath = sourcePath / "build/Debug" / fmt::format("{}.{}", gameName, libraryEnding); std::filesystem::path cmakePath = outputPath / "cmake"; if (true) { graphics = new Vulkan::Graphics(); diff --git a/src/Engine/Asset/TextureAsset.cpp b/src/Engine/Asset/TextureAsset.cpp index 88118c5..cb345b5 100644 --- a/src/Engine/Asset/TextureAsset.cpp +++ b/src/Engine/Asset/TextureAsset.cpp @@ -1,7 +1,6 @@ #include "TextureAsset.h" #include "Graphics/Graphics.h" #include "Graphics/Texture.h" -#include "Graphics/Vulkan/Enums.h" #include "Window/WindowManager.h" #include "ktx.h" diff --git a/src/Engine/Containers/List.h b/src/Engine/Containers/List.h index 10169c8..cd1a2f3 100644 --- a/src/Engine/Containers/List.h +++ b/src/Engine/Containers/List.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include diff --git a/src/Engine/Containers/MemoryResource.h b/src/Engine/Containers/MemoryResource.h index ccb21f2..144fdb2 100644 --- a/src/Engine/Containers/MemoryResource.h +++ b/src/Engine/Containers/MemoryResource.h @@ -1,4 +1,5 @@ #pragma once +#include #include #include #include diff --git a/src/Engine/Graphics/Metal/Descriptor.mm b/src/Engine/Graphics/Metal/Descriptor.mm index 044092b..00cf5a3 100644 --- a/src/Engine/Graphics/Metal/Descriptor.mm +++ b/src/Engine/Graphics/Metal/Descriptor.mm @@ -34,7 +34,7 @@ void DescriptorLayout::create() { MTL::ArgumentDescriptor** objects = new MTL::ArgumentDescriptor*[descriptorBindings.size()]; uint32 mappingCounter = 0; for (uint32 i = 0; i < descriptorBindings.size(); ++i) { - if (descriptorBindings[i].descriptorType != Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER) { + if (descriptorBindings[i].descriptorType != Gfx::SE_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK) { plainDescriptor = false; } objects[i] = MTL::ArgumentDescriptor::alloc()->init(); diff --git a/src/Engine/Graphics/Metal/Query.mm b/src/Engine/Graphics/Metal/Query.mm index a79ea1f..0840f3c 100644 --- a/src/Engine/Graphics/Metal/Query.mm +++ b/src/Engine/Graphics/Metal/Query.mm @@ -5,7 +5,6 @@ #include "Enums.h" #include "Graphics.h" #include "Graphics/Query.h" -#include using namespace Seele; using namespace Seele::Metal; @@ -71,4 +70,4 @@ Gfx::Timestamp TimestampQuery::getResult() { .name = "Test", .time = 0, }; -} \ No newline at end of file +} diff --git a/src/Engine/Graphics/RenderPass/CachedDepthPass.cpp b/src/Engine/Graphics/RenderPass/CachedDepthPass.cpp index 915f384..9906d36 100644 --- a/src/Engine/Graphics/RenderPass/CachedDepthPass.cpp +++ b/src/Engine/Graphics/RenderPass/CachedDepthPass.cpp @@ -11,6 +11,7 @@ CachedDepthPass::CachedDepthPass(Gfx::PGraphics graphics, PScene scene) : Render .stageFlags = Gfx::SE_SHADER_STAGE_TASK_BIT_EXT | Gfx::SE_SHADER_STAGE_VERTEX_BIT, .offset = 0, .size = sizeof(VertexData::DrawCallOffsets), + .name = "pOffsets" }); if (graphics->supportMeshShading()) { graphics->getShaderCompiler()->registerRenderPass("CachedDepthPass", Gfx::PassConfig{ diff --git a/src/Engine/Graphics/RenderPass/DepthCullingPass.cpp b/src/Engine/Graphics/RenderPass/DepthCullingPass.cpp index 4c0ae75..7b9d2bb 100644 --- a/src/Engine/Graphics/RenderPass/DepthCullingPass.cpp +++ b/src/Engine/Graphics/RenderPass/DepthCullingPass.cpp @@ -25,6 +25,7 @@ DepthCullingPass::DepthCullingPass(Gfx::PGraphics graphics, PScene scene) : Rend .stageFlags = Gfx::SE_SHADER_STAGE_TASK_BIT_EXT | Gfx::SE_SHADER_STAGE_VERTEX_BIT, .offset = 0, .size = sizeof(VertexData::DrawCallOffsets), + .name = "pOffsets" }); depthComputeLayout = graphics->createPipelineLayout("DepthComputeLayout"); @@ -34,6 +35,7 @@ DepthCullingPass::DepthCullingPass(Gfx::PGraphics graphics, PScene scene) : Rend .stageFlags = Gfx::SE_SHADER_STAGE_COMPUTE_BIT, .offset = 0, .size = sizeof(MipParam), + .name = "pMipParam" }); if (graphics->supportMeshShading()) { diff --git a/src/Engine/Graphics/RenderPass/RayTracingPass.cpp b/src/Engine/Graphics/RenderPass/RayTracingPass.cpp index e3a684a..678079a 100644 --- a/src/Engine/Graphics/RenderPass/RayTracingPass.cpp +++ b/src/Engine/Graphics/RenderPass/RayTracingPass.cpp @@ -53,6 +53,7 @@ RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPa .stageFlags = Gfx::SE_SHADER_STAGE_RAYGEN_BIT_KHR, .offset = 0, .size = sizeof(SampleParams), + .name = "pSamps", }); graphics->getShaderCompiler()->registerRenderPass("RayTracing", Gfx::PassConfig{ .baseLayout = pipelineLayout, diff --git a/src/Engine/Graphics/RenderPass/ShadowPass.cpp b/src/Engine/Graphics/RenderPass/ShadowPass.cpp index d819bdf..c820197 100644 --- a/src/Engine/Graphics/RenderPass/ShadowPass.cpp +++ b/src/Engine/Graphics/RenderPass/ShadowPass.cpp @@ -16,6 +16,7 @@ ShadowPass::ShadowPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graph .stageFlags = Gfx::SE_SHADER_STAGE_TASK_BIT_EXT | Gfx::SE_SHADER_STAGE_VERTEX_BIT, .offset = 0, .size = sizeof(VertexData::DrawCallOffsets), + .name = "pOffsets", }); if (graphics->supportMeshShading()) { graphics->getShaderCompiler()->registerRenderPass("ShadowPass", Gfx::PassConfig{ @@ -253,7 +254,6 @@ void ShadowPass::render() { } graphics->executeCommands(std::move(commands)); graphics->endRenderPass(); - graphics->waitDeviceIdle(); } graphics->endDebugRegion(); } diff --git a/src/Engine/Graphics/Shader.cpp b/src/Engine/Graphics/Shader.cpp index 7f94288..bfae762 100644 --- a/src/Engine/Graphics/Shader.cpp +++ b/src/Engine/Graphics/Shader.cpp @@ -134,7 +134,7 @@ void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipeline } // createInfo.typeParameter.add({Pair("IVertexData", permutation.vertexDataName)}); createInfo.modules.add(permutation.vertexDataName); - // createInfo.dumpIntermediate = true; + createInfo.dumpIntermediate = true; if (permutation.useMeshShading) { if (permutation.hasTaskShader) { diff --git a/vcpkg.json b/vcpkg.json index 54bb3be..c9d8af0 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,8 +1,14 @@ { "dependencies": [ - "vulkan", + { + "name": "vulkan", + "platform": "!osx" + }, + { + "name": "vulkan-memory-allocator", + "platform": "!osx" + }, "assimp", - "entt", "stb", "entt", "freetype", @@ -12,7 +18,6 @@ "nlohmann-json", "fmt", "gtest", - "vulkan-memory-allocator", "lunasvg", "harfbuzz", "shader-slang",