diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dad377..71ff025 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ if(MSVC) Seele.natvis DESTINATION .) else() - target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-delete-incomplete -pedantic -fcoroutines) + target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-delete-incomplete -pedantic -std=c++20) endif() add_subdirectory(src/) @@ -189,4 +189,4 @@ install( ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_PREFIX} -) \ No newline at end of file +) diff --git a/compile_commands.json b/compile_commands.json new file mode 120000 index 0000000..b8bca52 --- /dev/null +++ b/compile_commands.json @@ -0,0 +1 @@ +bin/compile_commands.json \ No newline at end of file diff --git a/src/Engine/Containers/Map.h b/src/Engine/Containers/Map.h index 8136b64..1af971b 100644 --- a/src/Engine/Containers/Map.h +++ b/src/Engine/Containers/Map.h @@ -196,7 +196,7 @@ public: , comp(comp) { } - constexpr explicit Map(const Allocator& alloc) noexcept(noexcept(Compare)) + constexpr explicit Map(const Allocator& alloc) noexcept(noexcept(Compare())) : nodeContainer(alloc) , root(SIZE_MAX) , beginIt(SIZE_MAX) @@ -662,4 +662,4 @@ private: return !comp(a, b) && !comp(b, a); } }; -} // namespace Seele \ No newline at end of file +} // namespace Seele diff --git a/src/Engine/Graphics/Buffer.cpp b/src/Engine/Graphics/Buffer.cpp index 2ba96c5..c1dfd24 100644 --- a/src/Engine/Graphics/Buffer.cpp +++ b/src/Engine/Graphics/Buffer.cpp @@ -40,8 +40,8 @@ bool UniformBuffer::updateContents(const BulkResourceData& resourceData) ShaderBuffer::ShaderBuffer(QueueFamilyMapping mapping, uint32 stride, uint32 numElements, const BulkResourceData& resourceData) : Buffer(mapping, resourceData.owner) , contents(resourceData.size) - , stride(stride) , numElements(numElements) + , stride(stride) { if (resourceData.data != nullptr) { @@ -88,4 +88,4 @@ IndexBuffer::IndexBuffer(QueueFamilyMapping mapping, uint64 size, Gfx::SeIndexTy } IndexBuffer::~IndexBuffer() { -} \ No newline at end of file +} diff --git a/src/Engine/Graphics/Descriptor.h b/src/Engine/Graphics/Descriptor.h index 8684c33..d488067 100644 --- a/src/Engine/Graphics/Descriptor.h +++ b/src/Engine/Graphics/Descriptor.h @@ -18,6 +18,17 @@ public: : binding(other.binding), descriptorType(other.descriptorType), descriptorCount(other.descriptorCount), shaderStages(other.shaderStages) { } + DescriptorBinding& operator=(const DescriptorBinding& other) + { + if(this != &other) + { + binding = other.binding; + descriptorType = other.descriptorType; + descriptorCount = other.descriptorCount; + shaderStages = other.shaderStages; + } + return *this; + } uint32 binding; SeDescriptorType descriptorType; uint32 descriptorCount; @@ -64,7 +75,14 @@ public: , name(name) { } - virtual ~DescriptorLayout() {} + DescriptorLayout(const DescriptorLayout& other) + { + descriptorBindings.resize(other.descriptorBindings.size()); + for(uint32 i = 0; i < descriptorBindings.size(); ++i) + { + descriptorBindings[i] = other.descriptorBindings[i]; + } + } DescriptorLayout& operator=(const DescriptorLayout& other) { if (this != &other) @@ -77,6 +95,7 @@ public: } return *this; } + virtual ~DescriptorLayout() {} virtual void create() = 0; virtual void addDescriptorBinding(uint32 binding, SeDescriptorType type, uint32 arrayCount = 1, SeDescriptorBindingFlags bindingFlags = 0, SeShaderStageFlags shaderStages = SeShaderStageFlagBits::SE_SHADER_STAGE_ALL); virtual void reset(); @@ -119,4 +138,4 @@ protected: }; DEFINE_REF(PipelineLayout) } -} \ No newline at end of file +} diff --git a/src/Engine/Graphics/StaticMeshVertexData.cpp b/src/Engine/Graphics/StaticMeshVertexData.cpp index a9b19c9..ebad999 100644 --- a/src/Engine/Graphics/StaticMeshVertexData.cpp +++ b/src/Engine/Graphics/StaticMeshVertexData.cpp @@ -6,6 +6,7 @@ extern List vertexDataList; StaticMeshVertexData::StaticMeshVertexData(Gfx::PGraphics graphics) : VertexData(graphics) + , head(0) { vertexDataList.add(this); } @@ -13,3 +14,10 @@ StaticMeshVertexData::StaticMeshVertexData(Gfx::PGraphics graphics) StaticMeshVertexData::~StaticMeshVertexData() {} +MeshId StaticMeshVertexData::allocateVertexData(uint64 numVertices) +{ + MeshId res{idCounter++}; + meshOffsets[res] = head; + head += numVertices; + return res; +} diff --git a/src/Engine/Graphics/StaticMeshVertexData.h b/src/Engine/Graphics/StaticMeshVertexData.h index 80ffe1b..3385a46 100644 --- a/src/Engine/Graphics/StaticMeshVertexData.h +++ b/src/Engine/Graphics/StaticMeshVertexData.h @@ -1,3 +1,4 @@ +#pragma once #include "VertexData.h" namespace Seele @@ -7,6 +8,24 @@ class StaticMeshVertexData : public VertexData public: StaticMeshVertexData(Gfx::PGraphics graphics); virtual ~StaticMeshVertexData(); + virtual MeshId allocateVertexData(uint64 numVertices) override; + void loadPositions(MeshId id, const Array& data); + void loadTexCoords(MeshId id, const Array& data); + void loadNormals(MeshId id, const Array& data); + void loadTangents(MeshId id, const Array& data); + void loadBiTangents(MeshId id, const Array& data); private: + Gfx::PShaderBuffer positions; + Array positionData; + Gfx::PShaderBuffer texCoords; + Array texCoordsData; + Gfx::PShaderBuffer normals; + Array normalData; + Gfx::PShaderBuffer tangents; + Array tangentData; + Gfx::PShaderBuffer biTangents; + Array biTangentData; + Map meshOffsets; + uint64 head; }; -} \ No newline at end of file +} diff --git a/src/Engine/Graphics/VertexData.cpp b/src/Engine/Graphics/VertexData.cpp index 89be4fd..af6af5a 100644 --- a/src/Engine/Graphics/VertexData.cpp +++ b/src/Engine/Graphics/VertexData.cpp @@ -76,6 +76,7 @@ List VertexData::getList() VertexData::VertexData(Gfx::PGraphics graphics) : graphics(graphics) + , idCounter(0) { instanceDataLayout = graphics->createDescriptorLayout("VertexDataInstanceLayout"); instanceDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); @@ -94,4 +95,4 @@ VertexData::VertexData(Gfx::PGraphics graphics) }); } instanceDataLayout->create(); -} \ No newline at end of file +} diff --git a/src/Engine/Graphics/VertexData.h b/src/Engine/Graphics/VertexData.h index 5478da4..f59af0e 100644 --- a/src/Engine/Graphics/VertexData.h +++ b/src/Engine/Graphics/VertexData.h @@ -48,6 +48,7 @@ public: void resetMeshData(); void updateMesh(const Component::Transform& transform, const Component::Mesh& mesh); void createDescriptors(); + virtual MeshId allocateVertexData(uint64 numVertices) = 0; virtual void bindBuffers(Gfx::PRenderCommand command) = 0; virtual Gfx::PDescriptorLayout getVertexDataLayout() = 0; virtual Gfx::PDescriptorSet getVertexDataSet() = 0; @@ -82,5 +83,6 @@ protected: // for legacy pipeline Gfx::PIndexBuffer indexBuffer; VertexData(Gfx::PGraphics graphics); + uint64 idCounter; }; -} \ No newline at end of file +} diff --git a/src/Engine/MinimalEngine.h b/src/Engine/MinimalEngine.h index a732fa2..025d1dd 100644 --- a/src/Engine/MinimalEngine.h +++ b/src/Engine/MinimalEngine.h @@ -104,14 +104,14 @@ class RefPtr { public: constexpr RefPtr() noexcept + : object(nullptr) { - object = nullptr; } - constexpr RefPtr(nullptr_t) noexcept + constexpr RefPtr(std::nullptr_t) noexcept + : object(nullptr) { - object = nullptr; } - constexpr RefPtr(T *ptr, Deleter deleter = Deleter()) + RefPtr(T *ptr, Deleter deleter = Deleter()) { std::scoped_lock l(getRegisteredObjectLock()); auto registeredObj = getRegisteredObjects().find(ptr); @@ -270,7 +270,7 @@ public: : handle(nullptr) { } - UniquePtr(nullptr_t) + UniquePtr(std::nullptr_t) : handle(nullptr) { }