diff --git a/src/AssetViewer/main.cpp b/src/AssetViewer/main.cpp index 4cd3ad0..b8d1493 100644 --- a/src/AssetViewer/main.cpp +++ b/src/AssetViewer/main.cpp @@ -74,7 +74,7 @@ int main(int, char**) { uint32 p0 = tris[i].p[0]; uint32 p1 = tris[i].p[1]; uint32 p2 = tris[i].p[2]; - uint32 p3 = positions.size(); + uint32 p3 = (uint32)positions.size(); positions.add(interpolate(positions[p0], positions[p1], positions[p2])); if (mesh->mTextureCoords[0] != nullptr) @@ -102,7 +102,7 @@ int main(int, char**) { //for (uint32 i = 0; i < tris.size(); ++i) { // stats << calcArea(tris[i]) << std::endl; //} - bool tess = false; + //bool tess = false; //while (!tess) { // tess = true; // for (uint32 i = 0; i < tris.size(); ++i) { @@ -143,7 +143,7 @@ int main(int, char**) { mesh->mBitangents = newBit; } - uint32 numFaces = tris.size(); + uint32 numFaces = (uint32)tris.size(); aiFace* newFaces = new aiFace[numFaces]; for (uint32 i = 0; i < numFaces; ++i) { newFaces[i].mNumIndices = 3; @@ -153,10 +153,10 @@ int main(int, char**) { newFaces[i].mIndices[2] = tris[i].p[2]; } - mesh->mNumVertices = positions.size(); + mesh->mNumVertices = (uint32)positions.size(); mesh->mVertices = newPos; mesh->mFaces = newFaces; - mesh->mNumFaces = tris.size(); + mesh->mNumFaces = (uint32)tris.size(); } Assimp::Exporter exporter; diff --git a/src/Benchmark/PlayView.cpp b/src/Benchmark/PlayView.cpp index 3f6cf97..5e7fdfc 100644 --- a/src/Benchmark/PlayView.cpp +++ b/src/Benchmark/PlayView.cpp @@ -28,7 +28,6 @@ PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate "VisibilityMS," << std::endl; uint64 start = 0; - uint64 prevBegin = 0; std::this_thread::sleep_for(std::chrono::milliseconds(500)); stats << std::fixed << std::setprecision(0); while (getGlobals().running) { @@ -37,8 +36,8 @@ PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate auto baseResults = baseQuery->getResults(); auto lightCullResults = lightCullQuery->getResults(); auto visiblityResults = visibilityQuery->getResults(); - int64 renderBegin = renderTimestamp->getResult().time; - int64 renderEnd = renderTimestamp->getResult().time; + //int64 renderBegin = renderTimestamp->getResult().time; + //int64 renderEnd = renderTimestamp->getResult().time; Map results; for (uint32 i = 0; i < 11; ++i) { auto ts = timestamps->getResult(); diff --git a/src/Editor/Asset/MeshLoader.cpp b/src/Editor/Asset/MeshLoader.cpp index 5063a4b..7bd010b 100644 --- a/src/Editor/Asset/MeshLoader.cpp +++ b/src/Editor/Asset/MeshLoader.cpp @@ -151,7 +151,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Array& uint32 uvIndex = 0; aiTextureMapMode mapMode = aiTextureMapMode_Clamp; float blend = std::numeric_limits::max(); - aiTextureOp op; + aiTextureOp op = aiTextureOp_Add; if (material->GetTexture(type, index, &texPath, &mapping, &uvIndex, nullptr, nullptr, nullptr) != AI_SUCCESS) { std::cout << "fuck" << std::endl; } @@ -488,23 +488,23 @@ Vector4 MeshLoader::encodeQTangent(Matrix3 m) { Vector4 r; if (t > 2.9999999) { r = Vector4(0.0, 0.0, 0.0, 1.0); - } else if (t > 0.0000001) { - float s = sqrt(1.0 + t) * 2.0; - r = Vector4(Vector(m[1][2] - m[2][1], m[2][0] - m[0][2], m[0][1] - m[1][0]) / s, s * 0.25); + } else if (t > 0.0000001f) { + float s = sqrt(1.0f + t) * 2.0f; + r = Vector4(Vector(m[1][2] - m[2][1], m[2][0] - m[0][2], m[0][1] - m[1][0]) / s, s * 0.25f); } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) { - float s = sqrt(1.0 + (m[0][0] - (m[1][1] + m[2][2]))) * 2.0; + float s = sqrt(1.0f + (m[0][0] - (m[1][1] + m[2][2]))) * 2.0; r = Vector4(s * 0.25, Vector(m[1][0] - m[0][1], m[2][0] - m[0][2], m[0][2] - m[2][1]) / s); } else if (m[1][1] > m[2][2]) { - float s = sqrt(1.0 + (m[1][1] - (m[0][0] + m[2][2]))) * 2.0; - r = Vector4(Vector(m[1][0] + m[0][1], m[2][1] + m[1][2], m[2][0] - m[0][2]) / s, s * 0.25); + float s = sqrt(1.0f + (m[1][1] - (m[0][0] + m[2][2]))) * 2.0f; + r = Vector4(Vector(m[1][0] + m[0][1], m[2][1] + m[1][2], m[2][0] - m[0][2]) / s, s * 0.25f); r = Vector4(r.x, r.w, r.y, r.z); } else { - float s = sqrt(1.0 + (m[2][2] - (m[0][0] + m[1][1]))) * 2.0; - r = Vector4(Vector(m[2][0] + m[0][2], m[2][1] + m[1][2], m[0][1] - m[1][0]) / s, s * 0.25); + float s = sqrt(1.0f + (m[2][2] - (m[0][0] + m[1][1]))) * 2.0f; + r = Vector4(Vector(m[2][0] + m[0][2], m[2][1] + m[1][2], m[0][1] - m[1][0]) / s, s * 0.25f); r = Vector4(r.x, r.y, r.w, r.z); } r = normalize(r); - const float threshold = 1.0 / 32767.0; + const float threshold = 1.0f / 32767.0f; if (r.w <= threshold) { r = Vector4(Vector(r) * (float)sqrt(1.0 - (threshold * threshold)), (r.w > 0.0) ? threshold : -threshold); } @@ -539,9 +539,9 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array biTangents(mesh->mNumVertices); Array colors(mesh->mNumVertices); - for (int32 i = 0; i < mesh->mNumVertices; ++i) { + for (uint32 i = 0; i < mesh->mNumVertices; ++i) { positions[i] = Vector(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z); - for (size_t j = 0; j < MAX_TEXCOORDS; ++j) { + for (uint32 j = 0; j < MAX_TEXCOORDS; ++j) { if (mesh->HasTextureCoords(j)) { texCoords[j][i] = U16Vector2(mesh->mTextureCoords[j][i].x * 65535, mesh->mTextureCoords[j][i].y * 65535); } else { diff --git a/src/Editor/Window/ViewportControl.cpp b/src/Editor/Window/ViewportControl.cpp index 1c5b22c..8cf7bbc 100644 --- a/src/Editor/Window/ViewportControl.cpp +++ b/src/Editor/Window/ViewportControl.cpp @@ -13,7 +13,7 @@ ViewportControl::ViewportControl(const URect& viewportDimensions, Vector initial ViewportControl::~ViewportControl() {} -void ViewportControl::update(Component::Camera& camera, float deltaTime) { +void ViewportControl::update(Component::Camera&, float deltaTime) { float cameraMove = deltaTime * 20; if (keys[KeyCode::KEY_LEFT_SHIFT]) { cameraMove *= 4; diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 5f0053f..2d3a7a7 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -36,7 +36,7 @@ Array generateEdges() { UVector(13, 10, 14), UVector(10, 11, 14), UVector(14, 11, 15)}; Array edges; for (auto ind : indices) { - uint32 baseIndex = edges.size(); + uint32 baseIndex = (uint32)edges.size(); edges.add(Halfedge{ind.x, baseIndex + 1, baseIndex + 2, UINT32_MAX}); edges.add(Halfedge{ind.y, baseIndex + 2, baseIndex, UINT32_MAX}); edges.add(Halfedge{ind.z, baseIndex, baseIndex + 1, UINT32_MAX}); diff --git a/src/Engine/Component/KeyboardInput.h b/src/Engine/Component/KeyboardInput.h index 9146c08..d11766c 100644 --- a/src/Engine/Component/KeyboardInput.h +++ b/src/Engine/Component/KeyboardInput.h @@ -5,14 +5,14 @@ namespace Seele { namespace Component { struct KeyboardInput { Seele::StaticArray(Seele::KeyCode::KEY_LAST)> keys; - bool mouse1; - bool mouse2; - float mouseX; - float mouseY; - float deltaX; - float deltaY; - float scrollX; - float scrollY; + bool mouse1 = false; + bool mouse2 = false; + float mouseX = 0.0f; + float mouseY = 0.0f; + float deltaX = 0.0f; + float deltaY = 0.0f; + float scrollX = 0.0f; + float scrollY = 0.0f; }; } // namespace Component } // namespace Seele \ No newline at end of file diff --git a/src/Engine/Containers/Array.h b/src/Engine/Containers/Array.h index 0f2e658..be9e799 100644 --- a/src/Engine/Containers/Array.h +++ b/src/Engine/Containers/Array.h @@ -83,12 +83,12 @@ template struct Array { using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - constexpr Array(const allocator_type& alloc = allocator_type(debug_resource::get("Array"))) noexcept + constexpr Array(const allocator_type& alloc = allocator_type()) noexcept : arraySize(0), allocated(DEFAULT_ALLOC_SIZE), allocator(alloc) { _data = allocateArray(DEFAULT_ALLOC_SIZE); assert(_data != nullptr); } - constexpr Array(size_type size, const value_type& value, const allocator_type& alloc = allocator_type(debug_resource::get("Array"))) + constexpr Array(size_type size, const value_type& value, const allocator_type& alloc = allocator_type()) : arraySize(size), allocated(size), allocator(alloc) { _data = allocateArray(size); assert(_data != nullptr); @@ -96,7 +96,7 @@ template struct Array { std::allocator_traits::construct(allocator, &_data[i], value); } } - constexpr explicit Array(size_type size, const allocator_type& alloc = allocator_type(debug_resource::get("Array"))) + constexpr explicit Array(size_type size, const allocator_type& alloc = allocator_type()) : arraySize(size), allocated(size), allocator(alloc) { _data = allocateArray(size); assert(_data != nullptr); @@ -108,14 +108,14 @@ template struct Array { } } } - constexpr Array(std::initializer_list init, const allocator_type& alloc = allocator_type(debug_resource::get("Array"))) + constexpr Array(std::initializer_list init, const allocator_type& alloc = allocator_type()) : arraySize(init.size()), allocated(init.size()), allocator(alloc) { _data = allocateArray(init.size()); assert(_data != nullptr); std::uninitialized_copy(init.begin(), init.end(), begin()); } template Range> - constexpr Array(std::from_range_t, Range&& rg, const allocator_type& alloc = allocator_type(debug_resource::get("Array"))) + constexpr Array(std::from_range_t, Range&& rg, const allocator_type& alloc = allocator_type()) : arraySize(0), allocated(0), allocator(alloc) { if constexpr (std::ranges::sized_range || std::ranges::forward_range) { arraySize = std::ranges::size(rg); diff --git a/src/Engine/Containers/MemoryResource.cpp b/src/Engine/Containers/MemoryResource.cpp index b549c53..5fb97fc 100644 --- a/src/Engine/Containers/MemoryResource.cpp +++ b/src/Engine/Containers/MemoryResource.cpp @@ -5,8 +5,11 @@ using namespace Seele; -std::atomic_uint64_t& MemoryManager::getAllocationCounter(const std::string& name) { +RefPtr MemoryManager::getAllocationCounter(const std::string& name) { std::unique_lock l(getInstance().allocationMutex); + if (!getInstance().allocationCounters.contains(name)) { + getInstance().allocationCounters[name] = new uint64(0); + } return getInstance().allocationCounters[name]; } @@ -14,9 +17,9 @@ void MemoryManager::printAllocations() { std::unique_lock l(getInstance().allocationMutex); for (const auto& [name, counter] : getInstance().allocationCounters) { if (name.empty()) { - std::cout << name << ": " << counter << std::endl; + std::cout << name << ": " << **counter << std::endl; } else { - std::cout << name << ": " << counter << std::endl; + std::cout << name << ": " << **counter << std::endl; } } } diff --git a/src/Engine/Containers/MemoryResource.h b/src/Engine/Containers/MemoryResource.h index 8faeac4..5e58fae 100644 --- a/src/Engine/Containers/MemoryResource.h +++ b/src/Engine/Containers/MemoryResource.h @@ -1,17 +1,18 @@ #pragma once #include #include +#include "MinimalEngine.h" namespace Seele { class MemoryManager { public: - static std::atomic_uint64_t& getAllocationCounter(const std::string& name); + static RefPtr getAllocationCounter(const std::string& name); static void printAllocations(); private: static MemoryManager& getInstance(); std::mutex allocationMutex; - std::map allocationCounters; + std::map> allocationCounters; }; class debug_resource : public std::pmr::memory_resource { @@ -26,13 +27,15 @@ class debug_resource : public std::pmr::memory_resource { debug_resource& operator=(debug_resource&& other) = default; void* do_allocate(size_t bytes, size_t alignment) override { - counter += bytes; +// std::cout << name << " + " << bytes << std::endl; + *counter.getHandle() += bytes; return upstream->allocate(bytes, alignment); } void do_deallocate(void* ptr, size_t bytes, size_t alignment) override { upstream->deallocate(ptr, bytes, alignment); - counter -= bytes; +// std::cout << name << " - " << bytes << std::endl; + *counter.getHandle() -= bytes; } bool do_is_equal(const std::pmr::memory_resource& other) const noexcept override { return this == &other; } @@ -40,6 +43,6 @@ class debug_resource : public std::pmr::memory_resource { private: std::string name; std::pmr::memory_resource* upstream; - std::atomic_uint64_t& counter; + RefPtr counter; }; } // namespace Seele \ No newline at end of file diff --git a/src/Engine/Containers/Tree.h b/src/Engine/Containers/Tree.h index e6a83b6..253feb5 100644 --- a/src/Engine/Containers/Tree.h +++ b/src/Engine/Containers/Tree.h @@ -7,11 +7,25 @@ namespace Seele { template struct Tree { protected: struct Node { + Node() {} Node(Node* left, Node* right, const NodeData& nodeData) : leftChild(left), rightChild(right), data(nodeData) {} Node(Node* left, Node* right, NodeData&& nodeData) : leftChild(left), rightChild(right), data(std::move(nodeData)) {} - Node* leftChild; - Node* rightChild; + Node* leftChild = nullptr; + Node* rightChild = nullptr; + Node* parent = nullptr; NodeData data; + void setLeftChild(Node* child) { + leftChild = child; + if (child != nullptr) { + child->parent = this; + } + } + void setRightChild(Node* child) { + rightChild = child; + if (child != nullptr) { + child->parent = this; + } + } }; using NodeAlloc = std::allocator_traits::template rebind_alloc; @@ -24,49 +38,65 @@ template && beginIt = Array()) : node(x), traversal(std::move(beginIt)) {} - constexpr IteratorBase(const IteratorBase& i) : node(i.node), traversal(i.traversal) {} - constexpr IteratorBase(IteratorBase&& i) noexcept : node(std::move(i.node)), traversal(std::move(i.traversal)) {} + constexpr IteratorBase(Node* x = nullptr) : node(x) {} + constexpr IteratorBase(const IteratorBase& i) : node(i.node) {} + constexpr IteratorBase(IteratorBase&& i) noexcept : node(std::move(i.node)) {} constexpr IteratorBase& operator=(const IteratorBase& other) { if (this != &other) { node = other.node; - traversal = other.traversal; } return *this; } constexpr IteratorBase& operator=(IteratorBase&& other) noexcept { if (this != &other) { node = std::move(other.node); - traversal = std::move(other.traversal); } return *this; } constexpr reference operator*() const { return node->data; } - constexpr pointer operator->() const { return &(node->data); } + constexpr pointer operator->() const { return std::pointer_traits::pointer_to(**this); } constexpr bool operator!=(const IteratorBase& other) { return node != other.node; } constexpr bool operator==(const IteratorBase& other) { return node == other.node; } constexpr std::strong_ordering operator<=>(const IteratorBase& other) { return node <=> other.node; } constexpr IteratorBase& operator++() { - node = node->rightChild; - while (node != nullptr && node->leftChild != nullptr) { - traversal.add(node); - node = node->leftChild; - } - if (node == nullptr && traversal.size() > 0) { - node = traversal.back(); - traversal.pop(); + // if current node has no right subtree + if (node->rightChild == nullptr) { + Node* temp = node; + node = node->parent; + // walk up hierarchy until we were the left subtree of any parent + // this means that that parent is the correct next element + while (node->rightChild == temp) { + temp = node; + node = node->parent; + } + } else { + // if there is a right subtree, descend there + node = node->rightChild; + // and find the leftmost node in that tree + while (node->leftChild != nullptr) { + node = node->leftChild; + } } return *this; } constexpr IteratorBase& operator--() { - node = node->leftChild; - while (node != nullptr && node->rightChild != nullptr) { - traversal.add(node); - node = node->rightchild; - } - if (node == nullptr && traversal.size() > 0) { - node = traversal.back(); - traversal.pop(); + // if current node has no left subtree + if (node->leftChild == nullptr) { + Node* temp = node; + node = node->parent; + // walk up hierarchy until we were the right subtree of any parent + // this means that that parent is the correct next element + while (node->leftChild == temp) { + temp = node; + node = node->parent; + } + } else { + // if there is a left subtree, descend there + node = node->leftChild; + // and find the rightmost node in that tree + while (node->rightChild != nullptr) { + node = node->rightChild; + } } return *this; } @@ -80,11 +110,10 @@ template traversal; }; using Iterator = IteratorBase; using ConstIterator = IteratorBase; @@ -122,8 +151,8 @@ template data)); } root = nullptr; + pseudoRoot.setLeftChild(nullptr); markIteratorsDirty(); } constexpr iterator begin() { @@ -191,6 +222,7 @@ template data, key)) { return end(); } @@ -213,15 +245,18 @@ template insert(const NodeData& data) { auto [r, inserted] = _insert(root, data); root = r; + pseudoRoot.setLeftChild(root); return Pair(iterator(root), inserted); } constexpr Pair insert(NodeData&& data) { auto [r, inserted] = _insert(root, std::move(data)); root = r; + pseudoRoot.setLeftChild(root); return Pair(iterator(root), inserted); } constexpr iterator remove(const key_type& key) { root = _remove(root, key); + pseudoRoot.setLeftChild(root); return iterator(root); } @@ -240,29 +275,18 @@ template beginTraversal; - while (begin != nullptr) { - beginTraversal.add(begin); + // start at pseudoroot so that if no regular nodes exist begin == end + Node* begin = const_cast(&pseudoRoot); + while (begin != nullptr && begin->leftChild != nullptr) { begin = begin->leftChild; } - if (!beginTraversal.empty()) { - begin = beginTraversal.back(); - beginTraversal.pop(); - } - return Iterator(begin, std::move(beginTraversal)); - } - constexpr Iterator calcEndIterator() const { - Node* endIndex = root; - Array endTraversal; - while (endIndex != nullptr) { - endTraversal.add(endIndex); - endIndex = endIndex->rightChild; - } - return Iterator(endIndex, std::move(endTraversal)); + return Iterator(begin); } + constexpr Iterator calcEndIterator() const { return Iterator(const_cast(&pseudoRoot)); } NodeAlloc alloc; Node* root; + // where the end iterator points to + Node pseudoRoot; Iterator beginIt; Iterator endIt; bool iteratorsDirty; @@ -271,14 +295,14 @@ template rightChild; - x->rightChild = y->leftChild; - y->leftChild = x; + x->setRightChild(y->leftChild); + y->setLeftChild(x); return y; } Node* rotateRight(Node* x) { Node* y = x->leftChild; - x->leftChild = y->rightChild; - y->rightChild = x; + x->setLeftChild(y->rightChild); + y->setRightChild(x); return y; } template Pair _insert(Node* r, NodeDataType&& data) { @@ -298,13 +322,13 @@ template ::construct(alloc, newNode, nullptr, nullptr, std::forward(data)); if (comp(keyFun(newNode->data), keyFun(r->data))) { - newNode->rightChild = r; - newNode->leftChild = r->leftChild; - r->leftChild = nullptr; + newNode->setRightChild(r); + newNode->setLeftChild(r->leftChild); + r->setLeftChild(nullptr); } else { - newNode->leftChild = r; - newNode->rightChild = r->rightChild; - r->rightChild = nullptr; + newNode->setLeftChild(r); + newNode->setRightChild(r->rightChild); + r->setRightChild(nullptr); } _size++; return Pair(newNode, true); @@ -327,7 +351,7 @@ template leftChild, key); - r->rightChild = temp->rightChild; + r->setRightChild(temp->rightChild); } std::allocator_traits::destroy(alloc, temp); alloc.deallocate(temp, 1); @@ -344,11 +368,11 @@ template leftChild->data))) { - r->leftChild->leftChild = _splay(r->leftChild->leftChild, key); + r->leftChild->setLeftChild(_splay(r->leftChild->leftChild, key)); r = rotateRight(r); } else if (comp(keyFun(r->leftChild->data), key)) { - r->leftChild->rightChild = _splay(r->leftChild->rightChild, key); + r->leftChild->setRightChild(_splay(r->leftChild->rightChild, key)); if (r->leftChild->rightChild != nullptr) { r->leftChild = rotateLeft(r->leftChild); @@ -360,13 +384,13 @@ template rightChild->data))) { - r->rightChild->leftChild = _splay(r->rightChild->leftChild, key); + r->rightChild->setLeftChild(_splay(r->rightChild->leftChild, key)); if (r->rightChild->leftChild != nullptr) { - r->rightChild = rotateRight(r->rightChild); + r->setRightChild(rotateRight(r->rightChild)); } } else if (comp(keyFun(r->rightChild->data), key)) { - r->rightChild->rightChild = _splay(r->rightChild->rightChild, key); + r->rightChild->setRightChild(_splay(r->rightChild->rightChild, key)); r = rotateLeft(r); } diff --git a/src/Engine/Graphics/Buffer.h b/src/Engine/Graphics/Buffer.h index 0daf8ea..9043cc3 100644 --- a/src/Engine/Graphics/Buffer.h +++ b/src/Engine/Graphics/Buffer.h @@ -52,7 +52,7 @@ class IndexBuffer : public Buffer { virtual void executePipelineBarrier(SeAccessFlags srcAccess, SePipelineStageFlags srcStage, SeAccessFlags dstAccess, SePipelineStageFlags dstStage) = 0; Gfx::SeIndexType indexType; - uint64 numIndices; + uint64 numIndices = 0; }; DEFINE_REF(IndexBuffer) @@ -81,7 +81,7 @@ class ShaderBuffer : public Buffer { virtual void updateContents(uint64 offset, uint64 size, void* data) = 0; virtual void* map() = 0; virtual void unmap() = 0; - constexpr uint32 getNumElements() const { return numElements; } + constexpr uint64 getNumElements() const { return numElements; } virtual void clear() = 0; @@ -91,7 +91,7 @@ class ShaderBuffer : public Buffer { virtual void executePipelineBarrier(SeAccessFlags srcAccess, SePipelineStageFlags srcStage, SeAccessFlags dstAccess, SePipelineStageFlags dstStage) = 0; - uint32 numElements; + uint64 numElements; }; DEFINE_REF(ShaderBuffer) } // namespace Gfx diff --git a/src/Engine/Graphics/RenderPass/RayTracingPass.cpp b/src/Engine/Graphics/RenderPass/RayTracingPass.cpp index 8b6bb0a..b81932a 100644 --- a/src/Engine/Graphics/RenderPass/RayTracingPass.cpp +++ b/src/Engine/Graphics/RenderPass/RayTracingPass.cpp @@ -74,6 +74,8 @@ void RayTracingPass::beginFrame(const Component::Camera& cam) { } void RayTracingPass::render() { + texture->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL, Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR); Array callableGroups; Array accelerationStructures; Array instanceData; @@ -168,15 +170,9 @@ void RayTracingPass::render() { } pass++; std::cout << pass << std::endl; - texture->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, - Gfx::SE_ACCESS_TRANSFER_READ_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT); Array commands; commands.add(std::move(command)); graphics->executeCommands(std::move(commands)); - viewport->getOwner()->getBackBuffer()->changeLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, Gfx::SE_ACCESS_NONE, - Gfx::SE_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, - Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT); - graphics->copyTexture(Gfx::PTexture2D(texture), viewport->getOwner()->getBackBuffer()); } void RayTracingPass::endFrame() {} @@ -200,6 +196,8 @@ void RayTracingPass::publishOutputs() { texture->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL, Gfx::SE_ACCESS_NONE, Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR); + resources->registerRenderPassOutput("BASEPASS_COLOR", Gfx::RenderTargetAttachment(texture, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, + Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)); ShaderCompilationInfo compileInfo = { .name = "RayGenMiss", .modules = {"RayGen", "AnyHit", "Miss"}, diff --git a/src/Engine/Graphics/RenderPass/ToneMappingPass.cpp b/src/Engine/Graphics/RenderPass/ToneMappingPass.cpp index b1808ad..6eb6f34 100644 --- a/src/Engine/Graphics/RenderPass/ToneMappingPass.cpp +++ b/src/Engine/Graphics/RenderPass/ToneMappingPass.cpp @@ -131,7 +131,7 @@ void ToneMappingPass::render() { Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT); histogramLayout->reset(); - Gfx::PDescriptorSet histogramSet = histogramLayout->allocateDescriptorSet(); + histogramSet = histogramLayout->allocateDescriptorSet(); histogramSet->updateConstants("minLogLum", 0, &minLogLum); histogramSet->updateConstants("inverseLogLumRange", 0, &inverseLogLumRange); histogramSet->updateConstants("timeCoeff", 0, &timeCoeff); diff --git a/src/Engine/Graphics/RenderPass/WaterRenderer.cpp b/src/Engine/Graphics/RenderPass/WaterRenderer.cpp index 785b0a2..7468c3d 100644 --- a/src/Engine/Graphics/RenderPass/WaterRenderer.cpp +++ b/src/Engine/Graphics/RenderPass/WaterRenderer.cpp @@ -10,8 +10,8 @@ WaterRenderer::WaterRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescri : graphics(graphics), scene(scene) { skyBox = AssetRegistry::findTexture("", "skyboxsun5deg_tn")->getTexture().cast(); logN = (int)log2(params.N); - threadGroupsX = ceil(params.N / 8.0f); - threadGroupsY = ceil(params.N / 8.0f); + threadGroupsX = (uint32)ceil(params.N / 8.0f); + threadGroupsY = (uint32)ceil(params.N / 8.0f); materialUniforms = graphics->createUniformBuffer(UniformBufferCreateInfo{ .sourceData = @@ -263,7 +263,7 @@ WaterRenderer::WaterRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescri .windSpeed = 2, .windDirection = 22, .fetch = 100000, - .spreadBlend = 0.642, + .spreadBlend = 0.642f, .swell = 1, .peakEnhancement = 1, .shortWavesFade = 0.25f, @@ -523,8 +523,8 @@ void WaterRenderer::updateFFTDescriptor() { spectrumBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT); - params.deltaTime = Gfx::getCurrentFrameDelta(); - params.frameTime = Gfx::getCurrentFrameTime(); + params.deltaTime = (float)Gfx::getCurrentFrameDelta(); + params.frameTime = (float)Gfx::getCurrentFrameTime(); paramsBuffer->updateContents(0, sizeof(ComputeParams), ¶ms); paramsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT); diff --git a/src/Engine/Graphics/RenderPass/WaterRenderer.h b/src/Engine/Graphics/RenderPass/WaterRenderer.h index 33648fc..b995f4c 100644 --- a/src/Engine/Graphics/RenderPass/WaterRenderer.h +++ b/src/Engine/Graphics/RenderPass/WaterRenderer.h @@ -57,8 +57,8 @@ class WaterRenderer { }; StaticArray displaySpectrums; struct ComputeParams { - float frameTime; - float deltaTime; + float frameTime = 0.0f; + float deltaTime = 0.0f; float gravity = 9.81f; float repeatTime = 200.0f; float depth = 20.0f; diff --git a/src/Engine/Graphics/StaticMeshVertexData.h b/src/Engine/Graphics/StaticMeshVertexData.h index f6e811e..20d3815 100644 --- a/src/Engine/Graphics/StaticMeshVertexData.h +++ b/src/Engine/Graphics/StaticMeshVertexData.h @@ -50,7 +50,7 @@ class StaticMeshVertexData : public VertexData { constexpr static const char* BITANGENTS_NAME = "biTangents"; Gfx::OShaderBuffer colors; constexpr static const char* COLORS_NAME = "colors"; - Array posData{debug_resource::get("VertexPositions")}; + Array posData; Array texData[MAX_TEXCOORDS]; Array norData; Array tanData; diff --git a/src/Engine/Graphics/Vulkan/Buffer.cpp b/src/Engine/Graphics/Vulkan/Buffer.cpp index c938c5c..b71fe8e 100644 --- a/src/Engine/Graphics/Vulkan/Buffer.cpp +++ b/src/Engine/Graphics/Vulkan/Buffer.cpp @@ -111,7 +111,7 @@ void BufferAllocation::updateContents(uint64 regionOffset, uint64 regionSize, vo vmaUnmapMemory(graphics->getAllocator(), staging->allocation); Gfx::QueueType prevOwner = owner; - // transferOwnership(Gfx::QueueType::TRANSFER); + transferOwnership(Gfx::QueueType::TRANSFER); PCommand cmd = graphics->getQueueCommands(Gfx::QueueType::GRAPHICS)->getCommands(); VkBufferCopy copy = { @@ -125,7 +125,7 @@ void BufferAllocation::updateContents(uint64 regionOffset, uint64 regionSize, vo pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT); - // transferOwnership(prevOwner); + transferOwnership(prevOwner); graphics->getDestructionManager()->queueResourceForDestruction(std::move(staging)); } @@ -147,7 +147,7 @@ void BufferAllocation::readContents(uint64 regionOffset, uint64 regionSize, void OBufferAllocation staging = new BufferAllocation(graphics, "ReadStaging", stagingInfo, stagingAlloc, Gfx::QueueType::GRAPHICS); Gfx::QueueType prevOwner = owner; - // transferOwnership(Gfx::QueueType::TRANSFER); + transferOwnership(Gfx::QueueType::TRANSFER); PCommandPool pool = graphics->getQueueCommands(Gfx::QueueType::TRANSFER); PCommand cmd = pool->getCommands(); @@ -164,7 +164,7 @@ void BufferAllocation::readContents(uint64 regionOffset, uint64 regionSize, void pool->submitCommands(); cmd->getFence()->wait(1000000); - // transferOwnership(prevOwner); + transferOwnership(prevOwner); uint8* data; VK_CHECK(vmaMapMemory(graphics->getAllocator(), staging->allocation, (void**)&data)); @@ -276,11 +276,11 @@ void Buffer::rotateBuffer(uint64 size, bool preserveContents) { return; } buffers.add(nullptr); - createBuffer(size, buffers.size() - 1); + createBuffer(size, (uint32)buffers.size() - 1); if (preserveContents) { copyBuffer(currentBuffer, buffers.size() - 1); } - currentBuffer = buffers.size() - 1; + currentBuffer = (uint32)buffers.size() - 1; } void Buffer::createBuffer(uint64 size, uint32 destIndex) { diff --git a/src/Engine/Graphics/Vulkan/Command.h b/src/Engine/Graphics/Vulkan/Command.h index eaffadf..cf6f8bb 100644 --- a/src/Engine/Graphics/Vulkan/Command.h +++ b/src/Engine/Graphics/Vulkan/Command.h @@ -18,7 +18,6 @@ class Command { Command(PGraphics graphics, PCommandPool pool); ~Command(); constexpr VkCommandBuffer getHandle() { return handle; } - void reset(); void begin(); void end(); void beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer); @@ -46,8 +45,6 @@ class Command { OFence fence; OSemaphore signalSemaphore; State state; - VkViewport currentViewport; - VkRect2D currentScissor; VkCommandBuffer handle; PRenderPass boundRenderPass; PFramebuffer boundFramebuffer; @@ -91,12 +88,12 @@ class RenderCommand : public Gfx::RenderCommand { virtual void traceRays(uint32 width, uint32 height, uint32 depth) override; private: - PGraphicsPipeline pipeline; - PRayTracingPipeline rtPipeline; - bool ready; + PGraphicsPipeline pipeline = nullptr; + PRayTracingPipeline rtPipeline = nullptr; + bool ready = false; Array boundResources; - VkViewport currentViewport; - VkRect2D currentScissor; + VkViewport currentViewport = VkViewport(); + VkRect2D currentScissor = VkRect2D(); PGraphics graphics; std::thread::id threadId; VkCommandBuffer handle; @@ -123,10 +120,8 @@ class ComputeCommand : public Gfx::ComputeCommand { private: PComputePipeline pipeline; - bool ready; + bool ready = false; Array boundResources; - VkViewport currentViewport; - VkRect2D currentScissor; PGraphics graphics; std::thread::id threadId; VkCommandBuffer handle; diff --git a/src/Engine/Graphics/Vulkan/Debug.cpp b/src/Engine/Graphics/Vulkan/Debug.cpp index 50dc7ec..7af5383 100644 --- a/src/Engine/Graphics/Vulkan/Debug.cpp +++ b/src/Engine/Graphics/Vulkan/Debug.cpp @@ -3,8 +3,8 @@ using namespace Seele::Vulkan; -VkBool32 Seele::Vulkan::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, - const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData) { +VkBool32 Seele::Vulkan::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT, VkDebugUtilsMessageTypeFlagsEXT, + const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void*) { std::cerr << pCallbackData->pMessage << std::endl; return VK_FALSE; } diff --git a/src/Engine/Graphics/Vulkan/Descriptor.cpp b/src/Engine/Graphics/Vulkan/Descriptor.cpp index 2d20d37..975c596 100644 --- a/src/Engine/Graphics/Vulkan/Descriptor.cpp +++ b/src/Engine/Graphics/Vulkan/Descriptor.cpp @@ -97,11 +97,11 @@ DescriptorPool::DescriptorPool(PGraphics graphics, PDescriptorLayout layout) perTypeSizes[binding.descriptorType] += 512; } Array poolSizes; - for (const auto [type, num] : perTypeSizes) { - VkDescriptorPoolSize size; - size.descriptorCount = num; - size.type = cast(type); - poolSizes.add(size); + for (const auto& [type, num] : perTypeSizes) { + poolSizes.add(VkDescriptorPoolSize{ + .type = cast(type), + .descriptorCount = num, + }); } VkDescriptorPoolCreateInfo createInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, @@ -473,7 +473,7 @@ std::mutex layoutLock; Map cachedLayouts; void PipelineLayout::create() { - for (auto [name, desc] : descriptorSetLayouts) { + for (const auto& [_, desc] : descriptorSetLayouts) { PDescriptorLayout layout = desc.cast(); layout->create(); uint32 parameterIndex = parameterMapping[layout->getName()]; diff --git a/src/Engine/Graphics/Vulkan/Descriptor.h b/src/Engine/Graphics/Vulkan/Descriptor.h index ec23b38..5c8188c 100644 --- a/src/Engine/Graphics/Vulkan/Descriptor.h +++ b/src/Engine/Graphics/Vulkan/Descriptor.h @@ -24,7 +24,7 @@ class DescriptorLayout : public Gfx::DescriptorLayout { private: PGraphics graphics; uint32 constantsSize = 0; - VkShaderStageFlags constantsStages; + VkShaderStageFlags constantsStages = 0; Array bindings; Map mappings; VkDescriptorSetLayout layoutHandle; @@ -74,7 +74,6 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource { private: std::vector constantData; OBufferAllocation constantsBuffer; - VkShaderStageFlags constantsStageFlags; List imageInfos; List bufferInfos; List accelerationInfos; diff --git a/src/Engine/Graphics/Vulkan/Graphics.cpp b/src/Engine/Graphics/Vulkan/Graphics.cpp index 3e66038..9a1de05 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.cpp +++ b/src/Engine/Graphics/Vulkan/Graphics.cpp @@ -968,11 +968,11 @@ void Graphics::createDevice(GraphicsInitializer initializer) { transferQueue = 0; queues.add(new Queue(this, graphicsQueueInfo.familyIndex, graphicsQueueInfo.queueIndex)); if (computeQueueInfo.familyIndex != -1) { - computeQueue = queues.size(); + computeQueue = (uint32)queues.size(); queues.add(new Queue(this, computeQueueInfo.familyIndex, computeQueueInfo.queueIndex)); } if (transferQueueInfo.familyIndex != -1) { - transferQueue = queues.size(); + transferQueue = (uint32)queues.size(); queues.add(new Queue(this, transferQueueInfo.familyIndex, transferQueueInfo.queueIndex)); } diff --git a/src/Engine/Graphics/Vulkan/PipelineCache.cpp b/src/Engine/Graphics/Vulkan/PipelineCache.cpp index d28f484..a2b6c03 100644 --- a/src/Engine/Graphics/Vulkan/PipelineCache.cpp +++ b/src/Engine/Graphics/Vulkan/PipelineCache.cpp @@ -11,23 +11,23 @@ using namespace Seele; using namespace Seele::Vulkan; PipelineCache::PipelineCache(PGraphics graphics, const std::string& cacheFilePath) : graphics(graphics), cacheFile(cacheFilePath) { + Array cacheData; std::ifstream stream(cacheFilePath, std::ios::binary | std::ios::ate); - VkPipelineCacheCreateInfo cacheCreateInfo = { - .sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .initialDataSize = 0, - }; if (stream.good()) { - Array cacheData; uint32 fileSize = static_cast(stream.tellg()); cacheData.resize(fileSize); stream.seekg(0); stream.read((char*)cacheData.data(), fileSize); - cacheCreateInfo.initialDataSize = fileSize; - cacheCreateInfo.pInitialData = cacheData.data(); std::cout << "Loaded " << fileSize << " bytes from pipeline cache" << std::endl; } + VkPipelineCacheCreateInfo cacheCreateInfo = { + .sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, + .pNext = nullptr, + .flags = 0, + .initialDataSize = cacheData.size(), + .pInitialData = cacheData.data(), + }; + VK_CHECK(vkCreatePipelineCache(graphics->getDevice(), &cacheCreateInfo, nullptr, &cache)); } @@ -624,7 +624,7 @@ PRayTracingPipeline PipelineCache::createPipeline(Gfx::RayTracingPipelineCreateI const VkBufferUsageFlags sbtBufferUsage = VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; const VmaMemoryUsage sbtMemoryUsage = VMA_MEMORY_USAGE_AUTO; - + uint64 rayGenStride = align(handleSize + createInfo.rayGenGroup.parameters.size(), handleAlignment); uint64 hitStride = handleSize; for (const auto& h : createInfo.hitGroups) { @@ -685,7 +685,6 @@ PRayTracingPipeline PipelineCache::createPipeline(Gfx::RayTracingPipelineCreateI rayGenBuffer->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_READ_BIT, VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR); - Array hitSbt(hitStride * createInfo.hitGroups.size()); for (uint64 i = 0; i < createInfo.hitGroups.size(); ++i) { std::memcpy(hitSbt.data() + i * hitStride, sbt.data() + sbtOffset, handleSize); @@ -695,9 +694,8 @@ PRayTracingPipeline PipelineCache::createPipeline(Gfx::RayTracingPipelineCreateI } hitBuffer->updateContents(0, hitSbt.size(), hitSbt.data()); hitBuffer->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_READ_BIT, - VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR); + VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR); - Array missSbt(missStride * createInfo.missGroups.size()); for (uint64 i = 0; i < createInfo.missGroups.size(); ++i) { std::memcpy(missSbt.data() + i * missStride, sbt.data() + sbtOffset, handleSize); @@ -707,11 +705,11 @@ PRayTracingPipeline PipelineCache::createPipeline(Gfx::RayTracingPipelineCreateI } missBuffer->updateContents(0, missSbt.size(), missSbt.data()); missBuffer->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_READ_BIT, - VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR); + VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR); ORayTracingPipeline pipeline = - new RayTracingPipeline(graphics, pipelineHandle, std::move(rayGenBuffer), rayGenStride, std::move(hitBuffer), - hitStride, std::move(missBuffer), missStride, nullptr, 0, createInfo.pipelineLayout); + new RayTracingPipeline(graphics, pipelineHandle, std::move(rayGenBuffer), rayGenStride, std::move(hitBuffer), hitStride, + std::move(missBuffer), missStride, nullptr, 0, createInfo.pipelineLayout); PRayTracingPipeline handle = pipeline; rayTracingPipelines[hash] = std::move(pipeline); return handle; diff --git a/src/Engine/Graphics/Vulkan/Query.h b/src/Engine/Graphics/Vulkan/Query.h index 28158b1..b4122b0 100644 --- a/src/Engine/Graphics/Vulkan/Query.h +++ b/src/Engine/Graphics/Vulkan/Query.h @@ -23,8 +23,8 @@ class QueryPool { std::string name; VkQueryPipelineStatisticFlags flags; // ring buffer - uint64 head = 0; - uint64 tail = 0; + uint32 head = 0; + uint32 tail = 0; uint64 numAvailable; uint32 numQueries; uint32 resultsStride; diff --git a/src/Engine/Graphics/Vulkan/Resources.cpp b/src/Engine/Graphics/Vulkan/Resources.cpp index 7cca67d..1b5e75e 100644 --- a/src/Engine/Graphics/Vulkan/Resources.cpp +++ b/src/Engine/Graphics/Vulkan/Resources.cpp @@ -34,7 +34,7 @@ void Semaphore::rotateSemaphore() { currentHandle = i; return; } - currentHandle = handles.size(); + currentHandle = (uint32)handles.size(); handles.add(new SemaphoreHandle(graphics, "Semaphore")); } diff --git a/src/Engine/Graphics/slang-compile.cpp b/src/Engine/Graphics/slang-compile.cpp index c8f7037..06d23f2 100644 --- a/src/Engine/Graphics/slang-compile.cpp +++ b/src/Engine/Graphics/slang-compile.cpp @@ -139,7 +139,7 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg slang::ProgramLayout* signature = specializedComponent->getLayout(0, diagnostics.writeRef()); CHECK_DIAGNOSTICS(); - std::cout << info.name << std::endl; + //std::cout << info.name << std::endl; for (uint32 i = 0; i < signature->getParameterCount(); ++i) { auto param = signature->getParameterByIndex(i); layout->addMapping(param->getName(), param->getBindingIndex()); diff --git a/src/Engine/Math/AABB.h b/src/Engine/Math/AABB.h index 8a36fe8..12b7586 100644 --- a/src/Engine/Math/AABB.h +++ b/src/Engine/Math/AABB.h @@ -11,9 +11,9 @@ struct BoundingSphere { }; struct AABB { Vector min = Vector(std::numeric_limits::max()); - float pad0; // So that it can be used directly in shaders + float pad0 = 0; // So that it can be used directly in shaders Vector max = Vector(std::numeric_limits::lowest()); // cause of reasons - float pad1; + float pad1 = 0; BoundingSphere toSphere() const { Vector center = (min + max) / 2.f; StaticArray corners; diff --git a/src/Engine/Physics/BVH.cpp b/src/Engine/Physics/BVH.cpp index 37cf414..8f8f4b5 100644 --- a/src/Engine/Physics/BVH.cpp +++ b/src/Engine/Physics/BVH.cpp @@ -311,7 +311,6 @@ void BVH::validateBVH() const { } for (uint32 i = 0; i < dynamicNodes.size(); ++i) { int32 nodeIdx = i; - size_t counter = dynamicNodes.size(); if (!dynamicNodes[nodeIdx].isValid) continue; while (dynamicNodes[nodeIdx].parentIndex != -1) { diff --git a/src/Engine/Physics/BVH.h b/src/Engine/Physics/BVH.h index 705d105..77fa151 100644 --- a/src/Engine/Physics/BVH.h +++ b/src/Engine/Physics/BVH.h @@ -17,17 +17,17 @@ class BVH { private: struct AABBCenter { AABB bb; - Vector center; - entt::entity id; + Vector center = Vector(); + entt::entity id = entt::entity(); }; struct Node { AABB box; int32 parentIndex = -1; int32 left = -1; int32 right = -1; - bool isLeaf; + bool isLeaf = false; bool isValid = true; - entt::entity owner; + entt::entity owner = entt::entity(); }; void traverseStaticTree(const AABB& aabb, entt::entity source, int32 nodeIndex, Array>& overlaps); void traverseDynamicTree(const AABB& aabb, entt::entity source, int32 nodeIndex, Array>& overlaps); diff --git a/src/Engine/System/KeyboardInput.cpp b/src/Engine/System/KeyboardInput.cpp index 85ce322..f6e37a5 100644 --- a/src/Engine/System/KeyboardInput.cpp +++ b/src/Engine/System/KeyboardInput.cpp @@ -28,8 +28,8 @@ void KeyboardInput::update(Component::KeyboardInput& input) { void KeyboardInput::keyCallback(KeyCode code, InputAction action, KeyModifier) { keys[code] = action != InputAction::RELEASE; } void KeyboardInput::mouseCallback(double x, double y) { - mouseX = x; - mouseY = y; + mouseX = (float)x; + mouseY = (float)y; } void KeyboardInput::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier) { @@ -42,6 +42,6 @@ void KeyboardInput::mouseButtonCallback(MouseButton button, InputAction action, } void KeyboardInput::scrollCallback(double xScroll, double yScroll) { - scrollX = xScroll; - scrollY = yScroll; + scrollX = (float)xScroll; + scrollY = (float)yScroll; } diff --git a/src/Engine/System/SystemBase.h b/src/Engine/System/SystemBase.h index 09d86ff..0437575 100644 --- a/src/Engine/System/SystemBase.h +++ b/src/Engine/System/SystemBase.h @@ -16,7 +16,7 @@ class SystemBase { virtual void update() {} protected: - double deltaTime; + double deltaTime = 0.0; entt::registry& registry; PScene scene; }; diff --git a/src/Engine/Window/GameView.cpp b/src/Engine/Window/GameView.cpp index 2b6582b..8c28137 100644 --- a/src/Engine/Window/GameView.cpp +++ b/src/Engine/Window/GameView.cpp @@ -32,6 +32,7 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate renderGraph.createRenderPass(); if (graphics->supportRayTracing()) { rayTracingGraph.addPass(new RayTracingPass(graphics, scene)); + rayTracingGraph.addPass(new ToneMappingPass(graphics)); rayTracingGraph.setViewport(viewport); rayTracingGraph.createRenderPass(); } diff --git a/tests/Engine/Containers/Map.cpp b/tests/Engine/Containers/Map.cpp index 92371b4..a92b3ed 100644 --- a/tests/Engine/Containers/Map.cpp +++ b/tests/Engine/Containers/Map.cpp @@ -31,7 +31,7 @@ TEST(CachedMap, for_each) map[6] = 4; map[4] = 7; int count = 0; - for(auto [key, val] : map) + for(const auto& [key, val] : map) { count++; }