maps dont work

This commit is contained in:
Dynamitos
2025-03-25 09:17:08 +01:00
parent e7ba74e258
commit a91aeab309
10 changed files with 103 additions and 118 deletions
+1 -1
View File
@@ -140,7 +140,7 @@ target_compile_options(Engine PUBLIC "$<$<CONFIG:DEBUG>:-DENABLE_VALIDATION>")
target_compile_options(Engine PUBLIC "$<$<CONFIG:DEBUG>:-DSEELE_DEBUG>") target_compile_options(Engine PUBLIC "$<$<CONFIG:DEBUG>:-DSEELE_DEBUG>")
add_subdirectory(src/) add_subdirectory(src/)
#add_subdirectory(tests/) add_subdirectory(tests/)
if(WIN32) if(WIN32)
add_custom_target(dll_copy ALL add_custom_target(dll_copy ALL
+6
View File
@@ -7,6 +7,12 @@
#include "MeshAsset.h" #include "MeshAsset.h"
#include "SVGAsset.h" #include "SVGAsset.h"
#include "TextureAsset.h" #include "TextureAsset.h"
#include "Asset/TextureAsset.h"
#include "Asset/FontAsset.h"
#include "Asset/SVGAsset.h"
#include "Asset/MeshAsset.h"
#include "Asset/MaterialAsset.h"
#include "Asset/MaterialInstanceAsset.h"
#include "Window/WindowManager.h" #include "Window/WindowManager.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
+4 -4
View File
@@ -88,7 +88,7 @@ template <typename T> struct Array {
_data = allocateArray(DEFAULT_ALLOC_SIZE); _data = allocateArray(DEFAULT_ALLOC_SIZE);
assert(_data != nullptr); assert(_data != nullptr);
} }
constexpr Array(size_type size, const value_type& value, const allocator_type& alloc = allocator_type()) constexpr Array(size_type size, const value_type& value, const allocator_type& alloc = allocator_type(debug_resource::get("Array")))
: arraySize(size), allocated(size), allocator(alloc) { : arraySize(size), allocated(size), allocator(alloc) {
_data = allocateArray(size); _data = allocateArray(size);
assert(_data != nullptr); assert(_data != nullptr);
@@ -96,7 +96,7 @@ template <typename T> struct Array {
std::allocator_traits<allocator_type>::construct(allocator, &_data[i], value); std::allocator_traits<allocator_type>::construct(allocator, &_data[i], value);
} }
} }
constexpr explicit Array(size_type size, const allocator_type& alloc = allocator_type()) constexpr explicit Array(size_type size, const allocator_type& alloc = allocator_type(debug_resource::get("Array")))
: arraySize(size), allocated(size), allocator(alloc) { : arraySize(size), allocated(size), allocator(alloc) {
_data = allocateArray(size); _data = allocateArray(size);
assert(_data != nullptr); assert(_data != nullptr);
@@ -108,14 +108,14 @@ template <typename T> struct Array {
} }
} }
} }
constexpr Array(std::initializer_list<T> init, const allocator_type& alloc = allocator_type()) constexpr Array(std::initializer_list<T> init, const allocator_type& alloc = allocator_type(debug_resource::get("Array")))
: arraySize(init.size()), allocated(init.size()), allocator(alloc) { : arraySize(init.size()), allocated(init.size()), allocator(alloc) {
_data = allocateArray(init.size()); _data = allocateArray(init.size());
assert(_data != nullptr); assert(_data != nullptr);
std::uninitialized_copy(init.begin(), init.end(), begin()); std::uninitialized_copy(init.begin(), init.end(), begin());
} }
template <container_compatible_range<T> Range> template <container_compatible_range<T> Range>
constexpr Array(std::from_range_t, Range&& rg, const allocator_type& alloc = allocator_type()) constexpr Array(std::from_range_t, Range&& rg, const allocator_type& alloc = allocator_type(debug_resource::get("Array")))
: arraySize(0), allocated(0), allocator(alloc) { : arraySize(0), allocated(0), allocator(alloc) {
if constexpr (std::ranges::sized_range<Range> || std::ranges::forward_range<Range>) { if constexpr (std::ranges::sized_range<Range> || std::ranges::forward_range<Range>) {
arraySize = std::ranges::size(rg); arraySize = std::ranges::size(rg);
+16 -13
View File
@@ -4,31 +4,34 @@
using namespace Seele; using namespace Seele;
std::mutex allocationMutex;
std::map<std::string, std::atomic_uint64_t> allocationCounters;
std::mutex resourcesMutex;
std::map<std::string, debug_resource> debugResources;
std::atomic_uint64_t& MemoryManager::getAllocationCounter(const std::string& name) { std::atomic_uint64_t& MemoryManager::getAllocationCounter(const std::string& name) {
std::unique_lock l(allocationMutex); std::unique_lock l(getInstance().allocationMutex);
return allocationCounters[name]; return getInstance().allocationCounters[name];
} }
void MemoryManager::printAllocations() { void MemoryManager::printAllocations() {
std::unique_lock l(allocationMutex); std::unique_lock l(getInstance().allocationMutex);
for (const auto& [name, counter] : allocationCounters) { for (const auto& [name, counter] : getInstance().allocationCounters) {
if (name.empty()) if (name.empty()) {
{
std::cout << name << ": " << counter << std::endl; std::cout << name << ": " << counter << std::endl;
} } else {
else
{
std::cout << name << ": " << counter << std::endl; std::cout << name << ": " << counter << std::endl;
} }
} }
} }
MemoryManager& MemoryManager::getInstance() {
static MemoryManager instance;
return instance;
}
debug_resource* debug_resource::get(const std::string& name) { debug_resource* debug_resource::get(const std::string& name) {
static std::mutex resourcesMutex;
static std::map<std::string, debug_resource> debugResources;
std::unique_lock l(resourcesMutex); std::unique_lock l(resourcesMutex);
if (!debugResources.count(name)) {
debugResources.emplace(std::pair(name, debug_resource(name)));
}
return &debugResources[name]; return &debugResources[name];
} }
+6
View File
@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <memory_resource> #include <memory_resource>
#include <map>
namespace Seele { namespace Seele {
class MemoryManager { class MemoryManager {
@@ -8,6 +9,9 @@ class MemoryManager {
static void printAllocations(); static void printAllocations();
private: private:
static MemoryManager& getInstance();
std::mutex allocationMutex;
std::map<std::string, std::atomic_uint64_t> allocationCounters;
}; };
class debug_resource : public std::pmr::memory_resource { class debug_resource : public std::pmr::memory_resource {
@@ -17,7 +21,9 @@ class debug_resource : public std::pmr::memory_resource {
debug_resource(std::string name, std::pmr::memory_resource* up = std::pmr::get_default_resource()) debug_resource(std::string name, std::pmr::memory_resource* up = std::pmr::get_default_resource())
: name(name), upstream(up), counter(MemoryManager::getAllocationCounter(name)) {} : name(name), upstream(up), counter(MemoryManager::getAllocationCounter(name)) {}
debug_resource(const debug_resource& other) = delete; debug_resource(const debug_resource& other) = delete;
debug_resource(debug_resource&& other) = default;
debug_resource& operator=(const debug_resource& other) = delete; debug_resource& operator=(const debug_resource& other) = delete;
debug_resource& operator=(debug_resource&& other) = default;
void* do_allocate(size_t bytes, size_t alignment) override { void* do_allocate(size_t bytes, size_t alignment) override {
counter += bytes; counter += bytes;
+48 -58
View File
@@ -1,23 +1,17 @@
#pragma once #pragma once
#include "Array.h" #include "Array.h"
#include "List.h"
#include "Pair.h" #include "Pair.h"
#include <map>
#include <memory_resource>
#include <memory>
namespace Seele { namespace Seele {
template <typename KeyType, typename NodeData, typename KeyFun, typename Compare, typename Allocator> struct Tree { template <typename KeyType, typename NodeData, typename KeyFun, typename Compare, typename Allocator> struct Tree {
protected: protected:
struct Node { struct Node {
Node(const NodeData& data) Node(const NodeData& data) : data(data) {}
: data(data) Node(NodeData&& data) : data(std::move(data)) {}
{}
Node(NodeData&& data)
: data(std::move(data)) {}
Node* parent = nullptr; Node* leftChild = nullptr;
Node* leftChild; Node* rightChild = nullptr;
Node* rightChild;
NodeData data; NodeData data;
}; };
using NodeAlloc = std::allocator_traits<Allocator>::template rebind_alloc<Node>; using NodeAlloc = std::allocator_traits<Allocator>::template rebind_alloc<Node>;
@@ -41,7 +35,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
using pointer = const_pointer; using pointer = const_pointer;
using reference = const value_type&; using reference = const value_type&;
constexpr ConstIterator(Node* x = nullptr) : node(x) {} constexpr ConstIterator(Node* x, List<Node*>&& traversal) : node(x), traversal(std::move(traversal)) {}
constexpr ConstIterator(const ConstIterator& i) = default; constexpr ConstIterator(const ConstIterator& i) = default;
constexpr ConstIterator(ConstIterator&& i) noexcept = default; constexpr ConstIterator(ConstIterator&& i) noexcept = default;
constexpr ConstIterator& operator=(const ConstIterator& other) = default; constexpr ConstIterator& operator=(const ConstIterator& other) = default;
@@ -52,22 +46,30 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
constexpr bool operator!=(const ConstIterator& other) { return node != other.node; } constexpr bool operator!=(const ConstIterator& other) { return node != other.node; }
constexpr std::strong_ordering operator<=>(const ConstIterator& other) { return node <=> other.node; } constexpr std::strong_ordering operator<=>(const ConstIterator& other) { return node <=> other.node; }
constexpr ConstIterator& operator++() noexcept { constexpr ConstIterator& operator++() noexcept {
node = node->rightChild; // walk up tree until we can go a single step to the right
while (node != nullptr && node->leftChild != nullptr) { while (traversal.size() > 0 && node->rightChild == nullptr) {
node = node->leftChild; node = traversal.back();
traversal.popBack();
} }
if (node == nullptr && node->parent != nullptr) { // if there is a right subtree we havent visited yet
node = node->parent; if (node->rightChild != nullptr) {
// go that single step
node = node->rightChild;
// then to the leftmost node of that right subtree
while (node->leftChild != nullptr) {
node = node->leftChild;
}
} }
return *this; return *this;
} }
constexpr ConstIterator& operator--() { constexpr ConstIterator& operator--() {
node = node->leftChild; while (node->leftChild == nullptr) {
while (node != nullptr && node->rightChild != nullptr) { node = traversal.back();
node = node->rightchild; traversal.popBack();
} }
if (node == nullptr && node->parent != nullptr) { node = node->leftChild;
node = node->parent; while (node->rightChild != nullptr) {
node = node->rightChild;
} }
return *this; return *this;
} }
@@ -86,6 +88,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
protected: protected:
Node* node; Node* node;
List<Node*> traversal;
}; };
class Iterator : public ConstIterator { class Iterator : public ConstIterator {
@@ -95,7 +98,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
using pointer = pointer; using pointer = pointer;
using reference = value_type&; using reference = value_type&;
constexpr Iterator(Node* x = nullptr) : ConstIterator(x) {} constexpr Iterator(Node* x, List<Node*>&& traversal) : ConstIterator(x, std::move(traversal)) {}
constexpr Iterator(const Iterator& i) = default; constexpr Iterator(const Iterator& i) = default;
constexpr Iterator(Iterator&& i) noexcept = default; constexpr Iterator(Iterator&& i) noexcept = default;
constexpr Iterator& operator=(const Iterator& other) = default; constexpr Iterator& operator=(const Iterator& other) = default;
@@ -128,25 +131,26 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
using const_reverse_iterator = std::reverse_iterator<const_iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>;
constexpr Tree() noexcept constexpr Tree() noexcept
: alloc(NodeAlloc()), root(nullptr), beginIt(nullptr), endIt(nullptr), iteratorsDirty(true), _size(0), comp(Compare()) {} : alloc(NodeAlloc()), root(nullptr), beginIt(nullptr, {}), endIt(nullptr, {}), iteratorsDirty(true), _size(0), comp(Compare()) {}
constexpr explicit Tree(const Compare& comp, const Allocator& alloc = Allocator()) noexcept(noexcept(Allocator())) constexpr explicit Tree(const Compare& comp, const Allocator& alloc = Allocator()) noexcept(noexcept(Allocator()))
: alloc(alloc), root(nullptr), beginIt(nullptr), endIt(nullptr), iteratorsDirty(true), _size(0), comp(comp) {} : alloc(alloc), root(nullptr), beginIt(nullptr, {}), endIt(nullptr, {}), iteratorsDirty(true), _size(0), comp(comp) {}
constexpr explicit Tree(const Allocator& alloc) noexcept(noexcept(Compare())) constexpr explicit Tree(const Allocator& alloc) noexcept(noexcept(Compare()))
: alloc(alloc), root(nullptr), beginIt(nullptr), endIt(nullptr), iteratorsDirty(true), _size(0), comp(Compare()) {} : alloc(alloc), root(nullptr), beginIt(nullptr, {}), endIt(nullptr, {}), iteratorsDirty(true), _size(0), comp(Compare()) {}
constexpr Tree(std::initializer_list<NodeData> init) constexpr Tree(std::initializer_list<NodeData> init)
: alloc(NodeAlloc()), root(nullptr), beginIt(nullptr), endIt(nullptr), iteratorsDirty(true), _size(0), comp(Compare()) { : alloc(NodeAlloc()), root(nullptr), beginIt(nullptr, {}), endIt(nullptr, {}), iteratorsDirty(true), _size(0), comp(Compare()) {
for (const auto& it : init) { for (const auto& it : init) {
insert(it); insert(it);
} }
} }
constexpr Tree(const Tree& other) : alloc(other.alloc), root(nullptr), iteratorsDirty(true), _size(), comp(other.comp) { constexpr Tree(const Tree& other)
: alloc(other.alloc), root(nullptr), beginIt(nullptr, {}), endIt(nullptr, {}), iteratorsDirty(true), _size(), comp(other.comp) {
for (const auto& elem : other) { for (const auto& elem : other) {
insert(elem); insert(elem);
} }
} }
constexpr Tree(Tree&& other) noexcept constexpr Tree(Tree&& other) noexcept
: alloc(std::move(other.alloc)), root(std::move(other.root)), iteratorsDirty(true), _size(std::move(other._size)), : alloc(std::move(other.alloc)), root(std::move(other.root)), beginIt(nullptr, {}), endIt(nullptr, {}), iteratorsDirty(true),
comp(std::move(other.comp)) { _size(std::move(other._size)), comp(std::move(other.comp)) {
other._size = 0; other._size = 0;
} }
constexpr ~Tree() noexcept { clear(); } constexpr ~Tree() noexcept { clear(); }
@@ -217,7 +221,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
if (root == nullptr || !equal(root->data, key)) { if (root == nullptr || !equal(root->data, key)) {
return end(); return end();
} }
return iterator(root); return iterator(root, {});
} }
constexpr iterator find(const key_type& key) const { constexpr iterator find(const key_type& key) const {
Node* it = root; Node* it = root;
@@ -231,21 +235,21 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
if (it == nullptr) { if (it == nullptr) {
return end(); return end();
} }
return iterator(it); return iterator(it, {});
} }
constexpr Pair<iterator, bool> insert(const NodeData& data) { constexpr Pair<iterator, bool> insert(const NodeData& data) {
const auto& [r, inserted] = _insert(root, data); const auto& [r, inserted] = _insert(root, data);
root = r; root = r;
return Pair<iterator, bool>(iterator(root), inserted); return Pair<iterator, bool>(iterator(root, {}), inserted);
} }
constexpr Pair<iterator, bool> insert(NodeData&& data) { constexpr Pair<iterator, bool> insert(NodeData&& data) {
const auto& [r, inserted] = _insert(root, std::move(data)); const auto& [r, inserted] = _insert(root, std::move(data));
root = r; root = r;
return Pair<iterator, bool>(iterator(root), inserted); return Pair<iterator, bool>(iterator(root, {}), inserted);
} }
constexpr iterator remove(const key_type& key) { constexpr iterator remove(const key_type& key) {
root = _remove(root, key); root = _remove(root, key);
return iterator(root); return iterator(root, {});
} }
private: private:
@@ -263,21 +267,22 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
iteratorsDirty = false; iteratorsDirty = false;
} }
constexpr Iterator calcBeginIterator() const { constexpr Iterator calcBeginIterator() const {
Node* begin = root; Node* beginNode = root;
while (begin != nullptr) { List<Node*> traversal;
begin = begin->leftChild; while (beginNode->leftChild != nullptr) {
traversal.add(beginNode);
beginNode = beginNode->leftChild;
} }
if (begin->parent != nullptr) { return Iterator(beginNode, std::move(traversal));
begin = begin->parent;
}
return Iterator(begin);
} }
constexpr Iterator calcEndIterator() const { constexpr Iterator calcEndIterator() const {
Node* endNode = root; Node* endNode = root;
List<Node*> traversal;
while (endNode != nullptr) { while (endNode != nullptr) {
traversal.add(endNode);
endNode = endNode->rightChild; endNode = endNode->rightChild;
} }
return Iterator(endNode); return Iterator(endNode, std::move(traversal));
} }
NodeAlloc alloc; NodeAlloc alloc;
Node* root; Node* root;
@@ -290,17 +295,13 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
Node* rotateLeft(Node* x) { Node* rotateLeft(Node* x) {
Node* y = x->rightChild; Node* y = x->rightChild;
x->rightChild = y->leftChild; x->rightChild = y->leftChild;
x->rightChild->parent = x;
y->leftChild = x; y->leftChild = x;
y->leftChild->parent = y;
return y; return y;
} }
Node* rotateRight(Node* x) { Node* rotateRight(Node* x) {
Node* y = x->leftChild; Node* y = x->leftChild;
x->leftChild = y->rightChild; x->leftChild = y->rightChild;
x->leftChild->parent = x;
y->rightChild = x; y->rightChild = x;
y->rightChild->parent = y;
return y; return y;
} }
template <class NodeDataType> Pair<Node*, bool> _insert(Node* r, NodeDataType&& data) { template <class NodeDataType> Pair<Node*, bool> _insert(Node* r, NodeDataType&& data) {
@@ -321,15 +322,11 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
if (comp(keyFun(newNode->data), keyFun(r->data))) { if (comp(keyFun(newNode->data), keyFun(r->data))) {
newNode->rightChild = r; newNode->rightChild = r;
newNode->rightChild->parent = newNode;
newNode->leftChild = r->leftChild; newNode->leftChild = r->leftChild;
newNode->leftChild->parent = newNode;
r->leftChild = nullptr; r->leftChild = nullptr;
} else { } else {
newNode->leftChild = r; newNode->leftChild = r;
newNode->leftChild->parent = newNode;
newNode->rightChild = r->rightChild; newNode->rightChild = r->rightChild;
newNode->rightChild->parent = newNode;
r->rightChild = nullptr; r->rightChild = nullptr;
} }
_size++; _size++;
@@ -354,7 +351,6 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
r = _splay(r->leftChild, key); r = _splay(r->leftChild, key);
r->rightChild = temp->rightChild; r->rightChild = temp->rightChild;
r->rightChild->parent = r;
} }
std::allocator_traits<NodeAlloc>::destroy(alloc, temp); std::allocator_traits<NodeAlloc>::destroy(alloc, temp);
alloc.deallocate(temp, 1); alloc.deallocate(temp, 1);
@@ -372,16 +368,13 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
if (comp(key, keyFun(r->leftChild->data))) { if (comp(key, keyFun(r->leftChild->data))) {
r->leftChild->leftChild = _splay(r->leftChild->leftChild, key); r->leftChild->leftChild = _splay(r->leftChild->leftChild, key);
r->leftChild->leftChild->parent = r->leftChild;
r = rotateRight(r); r = rotateRight(r);
} else if (comp(keyFun(r->leftChild->data), key)) { } else if (comp(keyFun(r->leftChild->data), key)) {
r->leftChild->rightChild = _splay(r->leftChild->rightChild, key); r->leftChild->rightChild = _splay(r->leftChild->rightChild, key);
r->leftChild->rightChild->parent = r->leftChild;
if (r->leftChild->rightChild != nullptr) { if (r->leftChild->rightChild != nullptr) {
r->leftChild = rotateLeft(r->leftChild); r->leftChild = rotateLeft(r->leftChild);
r->leftChild->parent = r;
} }
} }
return (r->leftChild == nullptr) ? r : rotateRight(r); return (r->leftChild == nullptr) ? r : rotateRight(r);
@@ -391,15 +384,12 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
if (comp(key, keyFun(r->rightChild->data))) { if (comp(key, keyFun(r->rightChild->data))) {
r->rightChild->leftChild = _splay(r->rightChild->leftChild, key); r->rightChild->leftChild = _splay(r->rightChild->leftChild, key);
r->rightChild->leftChild->parent = r->rightChild;
if (r->rightChild->leftChild != nullptr) { if (r->rightChild->leftChild != nullptr) {
r->rightChild = rotateRight(r->rightChild); r->rightChild = rotateRight(r->rightChild);
r->rightChild->parent = r;
} }
} else if (comp(keyFun(r->rightChild->data), key)) { } else if (comp(keyFun(r->rightChild->data), key)) {
r->rightChild->rightChild = _splay(r->rightChild->rightChild, key); r->rightChild->rightChild = _splay(r->rightChild->rightChild, key);
r->rightChild->rightChild->parent = r->rightChild;
r = rotateLeft(r); r = rotateLeft(r);
} }
+1 -3
View File
@@ -38,6 +38,4 @@ void PipelineLayout::addDescriptorLayout(PDescriptorLayout layout) { descriptorS
void PipelineLayout::addPushConstants(const SePushConstantRange& pushConstant) { pushConstants.add(pushConstant); } void PipelineLayout::addPushConstants(const SePushConstantRange& pushConstant) { pushConstants.add(pushConstant); }
void PipelineLayout::addMapping(std::string name, uint32 index) { void PipelineLayout::addMapping(std::string mappingName, uint32 index) { parameterMapping[mappingName] = index; }
parameterMapping[name] = index;
}
+18 -18
View File
@@ -199,14 +199,14 @@ DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner)
DescriptorSet::~DescriptorSet() {} DescriptorSet::~DescriptorSet() {}
void DescriptorSet::updateConstants(const std::string& name, uint32 offset, void* data) { void DescriptorSet::updateConstants(const std::string& mappingName, uint32 offset, void* data) {
std::memcpy(constantData.data() + owner->getLayout()->mappings[name].constantOffset, (char*)data + offset, std::memcpy(constantData.data() + owner->getLayout()->mappings[mappingName].constantOffset, (char*)data + offset,
owner->getLayout()->mappings[name].constantSize); owner->getLayout()->mappings[name].constantSize);
} }
void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PShaderBuffer shaderBuffer) { void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, Gfx::PShaderBuffer shaderBuffer) {
PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>(); PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>();
const auto& map = owner->getLayout()->mappings[name]; const auto& map = owner->getLayout()->mappings[mappingName];
uint32 binding = map.binding; uint32 binding = map.binding;
if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) { if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
return; return;
@@ -230,9 +230,9 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PSh
boundResources[binding][index] = vulkanBuffer->getAlloc(); boundResources[binding][index] = vulkanBuffer->getAlloc();
} }
void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer indexBuffer) { void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, Gfx::PVertexBuffer indexBuffer) {
PVertexBuffer vulkanBuffer = indexBuffer.cast<VertexBuffer>(); PVertexBuffer vulkanBuffer = indexBuffer.cast<VertexBuffer>();
const auto& map = owner->getLayout()->mappings[name]; const auto& map = owner->getLayout()->mappings[mappingName];
uint32 binding = map.binding; uint32 binding = map.binding;
if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) { if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
return; return;
@@ -257,9 +257,9 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PVe
boundResources[binding][index] = vulkanBuffer->getAlloc(); boundResources[binding][index] = vulkanBuffer->getAlloc();
} }
void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer indexBuffer) { void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, Gfx::PIndexBuffer indexBuffer) {
PIndexBuffer vulkanBuffer = indexBuffer.cast<IndexBuffer>(); PIndexBuffer vulkanBuffer = indexBuffer.cast<IndexBuffer>();
const auto& map = owner->getLayout()->mappings[name]; const auto& map = owner->getLayout()->mappings[mappingName];
uint32 binding = map.binding; uint32 binding = map.binding;
if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) { if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
return; return;
@@ -284,9 +284,9 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PIn
boundResources[binding][index] = vulkanBuffer->getAlloc(); boundResources[binding][index] = vulkanBuffer->getAlloc();
} }
void DescriptorSet::updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) { void DescriptorSet::updateSampler(const std::string& mappingName, uint32 index, Gfx::PSampler samplerState) {
PSampler vulkanSampler = samplerState.cast<Sampler>(); PSampler vulkanSampler = samplerState.cast<Sampler>();
const auto& map = owner->getLayout()->mappings[name]; const auto& map = owner->getLayout()->mappings[mappingName];
uint32 binding = map.binding; uint32 binding = map.binding;
if (boundResources[binding][index] == vulkanSampler->getHandle()) { if (boundResources[binding][index] == vulkanSampler->getHandle()) {
return; return;
@@ -312,9 +312,9 @@ void DescriptorSet::updateSampler(const std::string& name, uint32 index, Gfx::PS
boundResources[binding][index] = vulkanSampler->getHandle(); boundResources[binding][index] = vulkanSampler->getHandle();
} }
void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) { void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTexture2D texture) {
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle(); TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
const auto& map = owner->getLayout()->mappings[name]; const auto& map = owner->getLayout()->mappings[mappingName];
uint32 binding = map.binding; uint32 binding = map.binding;
if (boundResources[binding][index] == vulkanTexture->getHandle()) { if (boundResources[binding][index] == vulkanTexture->getHandle()) {
return; return;
@@ -340,9 +340,9 @@ void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PT
boundResources[binding][index] = vulkanTexture->getHandle(); boundResources[binding][index] = vulkanTexture->getHandle();
} }
void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) { void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTexture3D texture) {
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle(); TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
const auto& map = owner->getLayout()->mappings[name]; const auto& map = owner->getLayout()->mappings[mappingName];
uint32 binding = map.binding; uint32 binding = map.binding;
if (boundResources[binding][index] == vulkanTexture->getHandle()) { if (boundResources[binding][index] == vulkanTexture->getHandle()) {
return; return;
@@ -368,9 +368,9 @@ void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PT
boundResources[binding][index] = vulkanTexture->getHandle(); boundResources[binding][index] = vulkanTexture->getHandle();
} }
void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) { void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTextureCube texture) {
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle(); TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
const auto& map = owner->getLayout()->mappings[name]; const auto& map = owner->getLayout()->mappings[mappingName];
uint32 binding = map.binding; uint32 binding = map.binding;
if (boundResources[binding][index] == vulkanTexture->getHandle()) { if (boundResources[binding][index] == vulkanTexture->getHandle()) {
return; return;
@@ -396,9 +396,9 @@ void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PT
boundResources[binding][index] = vulkanTexture->getHandle(); boundResources[binding][index] = vulkanTexture->getHandle();
} }
void DescriptorSet::updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) { void DescriptorSet::updateAccelerationStructure(const std::string& mappingName, uint32 index, Gfx::PTopLevelAS as) {
auto tlas = as.cast<TopLevelAS>(); auto tlas = as.cast<TopLevelAS>();
uint32 binding = owner->getLayout()->mappings[name].binding; uint32 binding = owner->getLayout()->mappings[mappingName].binding;
accelerationInfos.add(VkWriteDescriptorSetAccelerationStructureKHR{ accelerationInfos.add(VkWriteDescriptorSetAccelerationStructureKHR{
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR, .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,
.pNext = nullptr, .pNext = nullptr,
+2 -2
View File
@@ -88,7 +88,7 @@ TEST(ArraySuite, remove_iterator)
array.add(3); array.add(3);
array.add(4); array.add(4);
array.add(5); array.add(5);
array.remove(array.find(1), false); array.erase(array.find(1), false);
ASSERT_EQ(array[0], 5); ASSERT_EQ(array[0], 5);
ASSERT_EQ(array[1], 2); ASSERT_EQ(array[1], 2);
ASSERT_EQ(array[2], 3); ASSERT_EQ(array[2], 3);
@@ -104,7 +104,7 @@ TEST(ArraySuite, remove_iterator_keep_order)
array.add(3); array.add(3);
array.add(4); array.add(4);
array.add(5); array.add(5);
array.remove(array.find(1)); array.erase(array.find(1));
ASSERT_EQ(array[0], 2); ASSERT_EQ(array[0], 2);
ASSERT_EQ(array[1], 3); ASSERT_EQ(array[1], 3);
ASSERT_EQ(array[2], 4); ASSERT_EQ(array[2], 4);
+1 -19
View File
@@ -35,22 +35,4 @@ TEST(ListSuite, basic_remove)
it = list.remove(it); it = list.remove(it);
ASSERT_EQ(*it, 4); ASSERT_EQ(*it, 4);
ASSERT_EQ(list.size(), 2); ASSERT_EQ(list.size(), 2);
} }
TEST(ListSuite, list_join)
{
List<int> list1;
List<int> list2;
list1.add(2);
list1.add(1);
list1.add(3);
list1.add(4);
list2.add(5);
list2.add(7);
list2.add(8);
list2.add(6);
list2.add(9);
list1.moveElements(std::move(list2));
ASSERT_EQ(list1.size(), 9);
ASSERT_EQ(list2.size(), 0);
}