diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a3214c..cad6820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,8 +101,10 @@ if(MSVC) Seele.natvis DESTINATION .) else() - target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20 -Wno-missing-field-initializers -Wno-unused-function) - target_compile_options(Editor PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20) + 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) + target_link_options(Engine PUBLIC -fsanitize=address) + target_link_options(Editor PUBLIC -fsanitize=address) endif() target_compile_options(Engine PUBLIC "$<$:-DENABLE_VALIDATION>") target_compile_options(Engine PUBLIC "$<$:-DSEELE_DEBUG>") diff --git a/cmake-variants.json b/cmake-variants.json index d83b2aa..1c67b3c 100644 --- a/cmake-variants.json +++ b/cmake-variants.json @@ -30,6 +30,13 @@ "settings": { "CMAKE_PLATFORM": "x64" } + }, + "arm64": { + "short": "arm64", + "long": "arm64 platform", + "settings": { + "CMAKE_PLATFORM": "arm64" + } } } } diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index b13b68c..d624840 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -27,8 +27,8 @@ int main() std::filesystem::path sourcePath= "C:/Users/Dynamitos/TrackClear"; std::filesystem::path binaryPath = sourcePath / "bin" / "TrackClear.dll"; #elif __APPLE__ - std::filesystem::path outputPath = "/dynamitos/TrackClearGame"; - std::filesystem::path sourcePath= "/dynamitos/TrackClear"; + std::filesystem::path outputPath = "/Users/dynamitos/TrackClearGame"; + std::filesystem::path sourcePath= "/Users/dynamitos/TrackClear"; std::filesystem::path binaryPath = sourcePath / "cmake" / "libTrackClear.dynlib"; #else std::filesystem::path outputPath = "/home/dynamitos/TrackClearGame"; diff --git a/src/Engine/Asset/AssetRegistry.cpp b/src/Engine/Asset/AssetRegistry.cpp index 687260f..b82ec90 100644 --- a/src/Engine/Asset/AssetRegistry.cpp +++ b/src/Engine/Asset/AssetRegistry.cpp @@ -159,7 +159,10 @@ void AssetRegistry::peekFolder(AssetFolder* folder) peekFolder(folder->children[stem]); continue; } - + if(entry.path().filename().compare(".DS_Store") == 0) + { + continue; + } auto stream = std::ifstream(entry.path(), std::ios::binary); ArchiveBuffer buffer(graphics); @@ -180,6 +183,10 @@ void AssetRegistry::loadFolder(AssetFolder* folder) continue; } + if(entry.path().filename().compare(".DS_Store") == 0) + { + continue; + } auto stream = std::ifstream(path, std::ios::binary); ArchiveBuffer buffer(graphics); diff --git a/src/Engine/Graphics/Vulkan/Buffer.cpp b/src/Engine/Graphics/Vulkan/Buffer.cpp index 0b5a625..ff529c0 100644 --- a/src/Engine/Graphics/Vulkan/Buffer.cpp +++ b/src/Engine/Graphics/Vulkan/Buffer.cpp @@ -50,7 +50,7 @@ Buffer::~Buffer() { for (uint32 i = 0; i < numBuffers; ++i) { - graphics->getDestructionManager()->queueBuffer(graphics->getQueueCommands(owner)->getCommands(), buffers[i].buffer); + graphics->getDestructionManager()->queueBuffer(graphics->getQueueCommands(owner)->getCommands(), buffers[i].buffer, buffers[i].allocation); } } @@ -241,7 +241,7 @@ void Buffer::unmap() .size = size, }; vkCmdPipelineBarrier(cmdHandle, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 1, &barrier, 0, nullptr); - vmaDestroyBuffer(graphics->getAllocator(), pending.stagingBuffer, pending.allocation); + graphics->getDestructionManager()->queueBuffer(command, pending.stagingBuffer, pending.allocation); } } // requestOwnershipTransfer(pending.prevQueue); diff --git a/src/Engine/Graphics/Vulkan/Resources.cpp b/src/Engine/Graphics/Vulkan/Resources.cpp index 8e2aa14..2f65c32 100644 --- a/src/Engine/Graphics/Vulkan/Resources.cpp +++ b/src/Engine/Graphics/Vulkan/Resources.cpp @@ -99,14 +99,14 @@ DestructionManager::~DestructionManager() { } -void DestructionManager::queueBuffer(PCommand cmd, VkBuffer buffer) +void DestructionManager::queueBuffer(PCommand cmd, VkBuffer buffer, VmaAllocation alloc) { - buffers[cmd].add(buffer); + buffers[cmd].add({buffer, alloc}); } -void DestructionManager::queueImage(PCommand cmd, VkImage image) +void DestructionManager::queueImage(PCommand cmd, VkImage image, VmaAllocation alloc) { - images[cmd].add(image); + images[cmd].add({image, alloc}); } void DestructionManager::queueImageView(PCommand cmd, VkImageView image) @@ -131,17 +131,17 @@ void DestructionManager::queueDescriptorPool(PCommand cmd, VkDescriptorPool pool void DestructionManager::notifyCmdComplete(PCommand cmd) { - for(auto buf : buffers[cmd]) + for(auto [buf, alloc] : buffers[cmd]) { - vkDestroyBuffer(graphics->getDevice(), buf, nullptr); + vmaDestroyBuffer(graphics->getAllocator(), buf, alloc); } for(auto view : views[cmd]) { vkDestroyImageView(graphics->getDevice(), view, nullptr); } - for(auto img : images[cmd]) + for(auto [img, alloc] : images[cmd]) { - vkDestroyImage(graphics->getDevice(), img, nullptr); + vmaDestroyImage(graphics->getAllocator(), img, alloc); } for (auto sem : sems[cmd]) { diff --git a/src/Engine/Graphics/Vulkan/Resources.h b/src/Engine/Graphics/Vulkan/Resources.h index 3207765..0dea544 100644 --- a/src/Engine/Graphics/Vulkan/Resources.h +++ b/src/Engine/Graphics/Vulkan/Resources.h @@ -1,8 +1,8 @@ #pragma once #include +#include #include "Containers/List.h" #include "Graphics/Resources.h" -#include "Allocator.h" namespace Seele { @@ -56,8 +56,8 @@ class DestructionManager public: DestructionManager(PGraphics graphics); ~DestructionManager(); - void queueBuffer(PCommand cmd, VkBuffer buffer); - void queueImage(PCommand cmd, VkImage image); + void queueBuffer(PCommand cmd, VkBuffer buffer, VmaAllocation alloc); + void queueImage(PCommand cmd, VkImage image, VmaAllocation alloc); void queueImageView(PCommand cmd, VkImageView view); void queueSemaphore(PCommand cmd, VkSemaphore sem); void queueRenderPass(PCommand cmd, VkRenderPass renderPass); @@ -65,8 +65,8 @@ public: void notifyCmdComplete(PCommand cmdbuffer); private: PGraphics graphics; - Map> buffers; - Map> images; + Map>> buffers; + Map>> images; Map> views; Map> sems; Map> renderPasses; diff --git a/src/Engine/Graphics/Vulkan/Texture.cpp b/src/Engine/Graphics/Vulkan/Texture.cpp index 1e067c4..7725a27 100644 --- a/src/Engine/Graphics/Vulkan/Texture.cpp +++ b/src/Engine/Graphics/Vulkan/Texture.cpp @@ -126,6 +126,7 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, }; VmaAllocationCreateInfo alloc = { .usage = VMA_MEMORY_USAGE_AUTO, + .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, }; VK_CHECK(vmaCreateBuffer(graphics->getAllocator(), &stagingInfo, &alloc, &stagingBuffer, &stagingAlloc, nullptr)); vmaMapMemory(graphics->getAllocator(), stagingAlloc, &data); @@ -163,7 +164,8 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, changeLayout(Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); if(stagingBuffer != VK_NULL_HANDLE) { - vmaDestroyBuffer(graphics->getAllocator(), stagingBuffer, stagingAlloc); + vmaUnmapMemory(graphics->getAllocator(), stagingAlloc); + graphics->getDestructionManager()->queueBuffer(commandPool->getCommands(), stagingBuffer, stagingAlloc); } } } @@ -202,7 +204,7 @@ TextureBase::~TextureBase() { if (ownsImage) { - graphics->getDestructionManager()->queueImage(graphics->getQueueCommands(currentOwner)->getCommands(), image); + graphics->getDestructionManager()->queueImage(graphics->getQueueCommands(currentOwner)->getCommands(), image, allocation); } graphics->getDestructionManager()->queueImageView(graphics->getQueueCommands(currentOwner)->getCommands(), imageView); } @@ -251,7 +253,7 @@ void TextureBase::download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Arra .pNext = nullptr, .flags = 0, .size = imageSize, - .usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT, + .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT, .sharingMode = VK_SHARING_MODE_EXCLUSIVE, }; VmaAllocationCreateInfo alloc = {