Fixing missing includes

This commit is contained in:
2025-05-16 13:04:43 +02:00
parent 507e424053
commit 56ec1aa97a
25 changed files with 176 additions and 94 deletions
+8 -9
View File
@@ -41,23 +41,22 @@
"request": "launch",
"program": "${workspaceRoot}/build/Editor",
"args": [],
"stopAtEntry": false,
"environment": [
{
"name": "ASAN_OPTIONS",
"value": "alloc_dealloc_mismatch=0",
}
],
"cwd": "${workspaceRoot}/build",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
],
},
]
}
+1 -1
View File
@@ -22,7 +22,7 @@
"lldb.showDisassembly": "auto",
"lldb.dereferencePointers": true,
"lldb.consoleMode": "commands",
"cmake.generator": "Ninja",
"cmake.generator": "Unix Makefiles",
"editor.tabSize": 4,
"slang.additionalSearchPaths": [
"res/shaders/",
+5
View File
@@ -25,6 +25,8 @@ 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)
@@ -81,6 +83,9 @@ 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()
if(APPLE)
+54
View File
@@ -0,0 +1,54 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 19,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default (Release)",
"description": "Release build without sanitizers",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "default-asan",
"displayName": "Default (Release + ASan)",
"description": "Release build with Address Sanitizer",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address",
"CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address"
}
},
{
"name": "debug",
"displayName": "Debug (no ASan)",
"description": "Debug build without sanitizers",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "debug-asan",
"displayName": "Debug (ASan)",
"description": "Debug build with Address Sanitizer",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address",
"CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address"
}
}
]
}
-53
View File
@@ -1,53 +0,0 @@
{
"buildType": {
"default": "debug",
"description": "Configuration Type",
"choices": {
"asan": {
"short": "ASan",
"long": "Address Sanitizer",
"buildType": "Asan"
},
"debug": {
"short": "Debug",
"long": "Enable debugging and validation",
"buildType": "Debug"
},
"release": {
"short": "Release",
"long": "Optimize binary for speed",
"buildType": "Release"
},
"relwithdebinfo": {
"short": "RelWithDebInfo",
"long": "Release with debug symbols",
"buildType": "RelWithDebInfo"
},
"minsizerel": {
"short": "MinSizeRel",
"long": "Minimal size Release",
"buildType": "MinSizeRel"
}
}
},
"architecture": {
"default": "x64",
"description": "Platform Architecture",
"choices": {
"x64": {
"short": "x64",
"long": "amd64 platform",
"settings": {
"CMAKE_PLATFORM": "x64"
}
},
"arm64": {
"short": "arm64",
"long": "arm64 platform",
"settings": {
"CMAKE_PLATFORM": "arm64"
}
}
}
}
}
+1 -1
View File
@@ -66,7 +66,7 @@ int main() {
// .importPath = "sponza",
//});
AssetImporter::importMesh(MeshImportArgs{
.filePath = sourcePath / "import" / "models" / "rttest.glb",
.filePath = sourcePath / "import" / "models" / "rttest.gltf",
.importPath = "rttest",
});
+1
View File
@@ -13,6 +13,7 @@
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
#include <mutex>
using namespace Seele;
+5 -1
View File
@@ -4,6 +4,7 @@
#include "MemoryResource.h"
#include <algorithm>
#include <assert.h>
#include <cstring>
#include <initializer_list>
#include <iterator>
#include <memory_resource>
@@ -423,6 +424,7 @@ template <typename T> struct Array {
}
arraySize = newSize;
} else {
size_t oldSize = allocated;
allocated = calculateGrowth(newSize);
// The array is not big enough, so we make a new one
T* newData = allocateArray(allocated);
@@ -438,7 +440,7 @@ template <typename T> struct Array {
std::allocator_traits<allocator_type>::construct(allocator, &newData[i], value);
}
}
deallocateArray(_data, allocated);
deallocateArray(_data, oldSize);
arraySize = newSize;
_data = newData;
}
@@ -520,6 +522,7 @@ template <typename T, size_t N> struct StaticArray {
beginIt = iterator(_data);
endIt = iterator(_data + N);
}
constexpr StaticArray(T value) {
for (size_t i = 0; i < N; ++i) {
_data[i] = value;
@@ -527,6 +530,7 @@ template <typename T, size_t N> struct StaticArray {
beginIt = iterator(_data);
endIt = iterator(_data + N);
}
constexpr StaticArray(std::initializer_list<T> init) {
auto beg = init.begin();
for (size_t i = 0; i < N; ++i) {
+1
View File
@@ -1,6 +1,7 @@
#include "MemoryResource.h"
#include "Map.h"
#include <iostream>
#include <mutex>
using namespace Seele;
+1 -1
View File
@@ -22,7 +22,7 @@ struct GraphicsInitializer {
void* windowHandle;
GraphicsInitializer()
: applicationName("SeeleEngine"), engineName("SeeleEngine"), windowLayoutFile(nullptr), layers{"VK_LAYER_LUNARG_monitor"},
: applicationName("SeeleEngine"), engineName("SeeleEngine"), windowLayoutFile(nullptr), layers{},
instanceExtensions{}, deviceExtensions{"VK_KHR_swapchain"}, windowHandle(nullptr) {}
};
struct WindowCreateInfo {
+1
View File
@@ -4,6 +4,7 @@
#include "Material/Material.h"
#include "ThreadPool.h"
#include <fmt/core.h>
#include <mutex>
using namespace Seele;
using namespace Seele::Gfx;
@@ -4,6 +4,7 @@
#include "Graphics/VertexData.h"
#include "Mesh.h"
#include <fstream>
#include <mutex>
using namespace Seele;
+1
View File
@@ -10,6 +10,7 @@
#include <iostream>
#include <meshoptimizer.h>
#include <metis.h>
#include <mutex>
#include <unordered_map>
using namespace Seele;
+4 -2
View File
@@ -11,6 +11,7 @@
#include "Texture.h"
#include "vulkan/vulkan_core.h"
#include <algorithm>
#include <mutex>
#include <ranges>
using namespace Seele;
@@ -201,7 +202,9 @@ DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner)
boundResources.resize(owner->getLayout()->getBindings().size());
for (uint32 i = 0; i < boundResources.size(); ++i) {
boundResources[i].resize(owner->getLayout()->getBindings()[i].descriptorCount);
std::memset(boundResources[i].data(), 0, sizeof(PCommandBoundResource) * boundResources[i].size());
for (size_t x = 0; x < boundResources[i].size(); ++x) {
boundResources[i][x] = nullptr;
}
}
constantData.resize(owner->getLayout()->constantsSize);
}
@@ -248,7 +251,6 @@ void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, G
if (vulkanBuffer->getAlloc() == nullptr)
return;
bufferInfos.add(VkDescriptorBufferInfo{
.buffer = vulkanBuffer->getHandle(),
.offset = 0,
+5 -5
View File
@@ -10,11 +10,11 @@ struct FramebufferDescription {
StaticArray<VkImageView, 16> inputAttachments;
StaticArray<VkImageView, 16> colorAttachments;
StaticArray<VkImageView, 16> resolveAttachments;
VkImageView depthAttachment;
VkImageView depthResolveAttachment;
uint32 numInputAttachments;
uint32 numColorAttachments;
uint32 numResolveAttachments;
VkImageView depthAttachment = VK_NULL_HANDLE;
VkImageView depthResolveAttachment = VK_NULL_HANDLE;
uint32 numInputAttachments = 0;
uint32 numColorAttachments = 0;
uint32 numResolveAttachments = 0;
};
class Framebuffer {
public:
+43 -10
View File
@@ -18,6 +18,7 @@
#include "Window.h"
#include <GLFW/glfw3.h>
#include <cstring>
#include <numeric>
#include <vulkan/vulkan_core.h>
#define VMA_IMPLEMENTATION
@@ -171,8 +172,8 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
return new Viewport(owner, viewportInfo);
}
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name,
Array<uint32> viewMasks, Array<uint32> correlationMasks) {
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea,
std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks) {
// todo: re-introduce render area to renderpass
return new RenderPass(this, std::move(layout), std::move(dependencies), name, std::move(viewMasks), std::move(correlationMasks));
}
@@ -284,9 +285,7 @@ Gfx::PComputePipeline Graphics::createComputePipeline(Gfx::ComputePipelineCreate
return pipelineCache->createPipeline(std::move(createInfo));
}
Gfx::OSampler Graphics::createSampler(const SamplerCreateInfo& createInfo) {
return new Sampler(this, createInfo);
}
Gfx::OSampler Graphics::createSampler(const SamplerCreateInfo& createInfo) { return new Sampler(this, createInfo); }
Gfx::ODescriptorLayout Graphics::createDescriptorLayout(const std::string& name) { return new DescriptorLayout(this, name); }
@@ -450,7 +449,7 @@ void Graphics::buildBottomLevelAccelerationStructures(Array<Gfx::PBottomLevelAS>
};
Array<VkTransformMatrixKHR> matrices;
for (const auto gfxBlas : data) {
for (const auto& gfxBlas : data) {
const auto blas = gfxBlas.cast<BottomLevelAS>();
matrices.add(blas->getTransform());
}
@@ -765,11 +764,15 @@ void Graphics::pickPhysicalDevice() {
physicalDevice = bestDevice;
vkGetPhysicalDeviceProperties2(physicalDevice, &props);
bufferDeviceAddressFeatures = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES,
.pNext = nullptr,
.bufferDeviceAddress = true,
};
rayTracingFeatures = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR,
.pNext = nullptr,
.pNext = &bufferDeviceAddressFeatures,
.rayTracingPipeline = true,
.rayTraversalPrimitiveCulling = true,
};
accelerationFeatures = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR,
@@ -780,6 +783,8 @@ void Graphics::pickPhysicalDevice() {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT,
.taskShader = true,
.meshShader = true,
.multiviewMeshShader = true,
.primitiveFragmentShadingRateMeshShader = false,
.meshShaderQueries = true,
};
features12 = {
@@ -825,6 +830,11 @@ void Graphics::pickPhysicalDevice() {
};
bool rayTracingPipelineSupport = false;
bool accelerationStructureSupport = false;
bool hostOperationsSupport = false;
bool deviceAddressSupport = false;
bool descriptorIndexingSupport = false;
bool spirv14Support = false;
bool shaderFloatControls = false;
uint32 count = 0;
vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &count, nullptr);
Array<VkExtensionProperties> extensionProps(count);
@@ -833,7 +843,6 @@ void Graphics::pickPhysicalDevice() {
if (Gfx::useMeshShading) {
if (std::strcmp(VK_EXT_MESH_SHADER_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
meshShadingEnabled = true;
break;
}
}
if (std::strcmp(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
@@ -842,8 +851,24 @@ void Graphics::pickPhysicalDevice() {
if (std::strcmp(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
accelerationStructureSupport = true;
}
if (std::strcmp(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
hostOperationsSupport = true;
}
rayTracingEnabled = rayTracingPipelineSupport && accelerationStructureSupport;
if (std::strcmp(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
deviceAddressSupport = true;
}
if (std::strcmp(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
descriptorIndexingSupport = true;
}
if (std::strcmp(VK_KHR_SPIRV_1_4_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
spirv14Support = true;
}
if (std::strcmp(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
shaderFloatControls = true;
}
}
rayTracingEnabled = rayTracingPipelineSupport && accelerationStructureSupport && hostOperationsSupport && deviceAddressSupport &&
descriptorIndexingSupport && spirv14Support && shaderFloatControls;
if (meshShadingEnabled) {
features12.pNext = &meshShaderFeatures;
}
@@ -927,9 +952,17 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
initializer.deviceExtensions.add(VK_EXT_MESH_SHADER_EXTENSION_NAME);
}
if (supportRayTracing()) {
// ray tracing itself
initializer.deviceExtensions.add(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME);
initializer.deviceExtensions.add(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
// required by acceleration_structure
initializer.deviceExtensions.add(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
initializer.deviceExtensions.add(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
initializer.deviceExtensions.add(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
// required for ray tracing pipeline
initializer.deviceExtensions.add(VK_KHR_SPIRV_1_4_EXTENSION_NAME);
// required for spirv_1_4
initializer.deviceExtensions.add(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME);
}
initializer.deviceExtensions.add(VK_KHR_MULTIVIEW_EXTENSION_NAME);
#ifdef __APPLE__
+37 -4
View File
@@ -9,6 +9,35 @@ DECLARE_REF(CommandPool)
DECLARE_REF(Queue)
DECLARE_REF(PipelineCache)
DECLARE_REF(Framebuffer)
template <typename T>
concept chainable_struct = requires(T t) { t.pNext; };
template <chainable_struct... T> struct StructChain;
template <> struct StructChain<> {
};
template<chainable_struct Base> struct StructChain<Base> : StructChain<> {
StructChain(Base b):b(b) {}
StructChain(const StructChain<>&, Base b) : b(b) {}
template <chainable_struct Next> StructChain<Next, Base> append(Next next) { return StructChain<Next, Base>(*this, next); }
Base b;
Base& operator*(){
return b;
}
};
template <chainable_struct This, chainable_struct... Right> struct StructChain<This, Right...> : StructChain<Right...> {
StructChain(const StructChain<Right...>& parent, This t) : StructChain<Right...>(parent), t(t) {}
template <chainable_struct Next> StructChain<Next, This, Right...> append(Next next) {
return StructChain<Next, This, Right...>(*this, next);
}
auto& operator*() {
auto& base = StructChain<Right...>::operator*();
t.pNext = base.pNext;
base.pNext = &t;
return base;
}
This t;
};
class Graphics : public Gfx::Graphics {
public:
Graphics();
@@ -34,8 +63,8 @@ class Graphics : public Gfx::Graphics {
virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override;
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name,
Array<uint32> viewMasks, Array<uint32> correlationMasks) override;
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea,
std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks) override;
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
virtual void endRenderPass() override;
virtual void waitDeviceIdle() override;
@@ -117,16 +146,20 @@ class Graphics : public Gfx::Graphics {
thread_local static PCommandPool transferCommands;
std::mutex poolLock;
Array<OCommandPool> pools;
VkQueueFamilyProperties graphicsProps;
VkPhysicalDeviceProperties2 props;
VkPhysicalDeviceRayTracingPipelinePropertiesKHR rayTracingProperties;
VkPhysicalDeviceAccelerationStructurePropertiesKHR accelerationProperties;
VkPhysicalDeviceFeatures2 features;
VkPhysicalDeviceVulkan11Features features11;
VkPhysicalDeviceVulkan12Features features12;
VkPhysicalDeviceMeshShaderFeaturesEXT meshShaderFeatures;
VkPhysicalDeviceBufferDeviceAddressFeatures bufferDeviceAddressFeatures;
VkPhysicalDeviceAccelerationStructureFeaturesKHR accelerationFeatures;
VkPhysicalDeviceAccelerationStructurePropertiesKHR accelerationProperties;
VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingFeatures;
VkPhysicalDeviceRayTracingPipelinePropertiesKHR rayTracingProperties;
VkDebugUtilsMessengerEXT callback;
Map<uint32, OFramebuffer> allocatedFramebuffers;
VmaAllocator allocator;
+1
View File
@@ -2,6 +2,7 @@
#include "Buffer.h"
#include "Graphics.h"
#include "Graphics/Query.h"
#include <condition_variable>
namespace Seele {
namespace Vulkan {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "Command.h"
#include "Enums.h"
#include "Graphics.h"
#include <mutex>
using namespace Seele;
using namespace Seele::Vulkan;
+1 -1
View File
@@ -43,7 +43,7 @@ class TopLevelAS : public Gfx::TopLevelAS {
public:
TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& createInfo);
~TopLevelAS();
const VkAccelerationStructureKHR getHandle() const { return handle; }
VkAccelerationStructureKHR getHandle() const { return handle; }
private:
PGraphics graphics;
@@ -215,7 +215,6 @@ RenderPass::~RenderPass() {
uint32 RenderPass::getFramebufferHash() {
FramebufferDescription description;
std::memset(&description, 0, sizeof(FramebufferDescription));
for (auto& inputAttachment : layout.inputAttachments) {
PTextureBase tex = inputAttachment.getTexture().cast<TextureBase>();
description.inputAttachments[description.numInputAttachments++] = tex->getView();
-2
View File
@@ -8,6 +8,4 @@ CameraUpdater::CameraUpdater(PScene scene) : ComponentSystem<Component::Camera,
CameraUpdater::~CameraUpdater() {}
void CameraUpdater::update(Component::Camera& camera, Component::Transform& transform) {
Vector eyePos = transform.getPosition();
Vector lookAt = eyePos + transform.getForward();
}
+1
View File
@@ -3,6 +3,7 @@
#include "Containers/List.h"
#include <functional>
#include <thread>
#include <condition_variable>
namespace Seele {
class ThreadPool {
+1
View File
@@ -1,5 +1,6 @@
{
"dependencies": [
"vulkan",
"assimp",
"entt",
"stb",