fixing lots of warnings
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<std::string, uint64> results;
|
||||
for (uint32 i = 0; i < 11; ++i) {
|
||||
auto ts = timestamps->getResult();
|
||||
|
||||
@@ -151,7 +151,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>&
|
||||
uint32 uvIndex = 0;
|
||||
aiTextureMapMode mapMode = aiTextureMapMode_Clamp;
|
||||
float blend = std::numeric_limits<float>::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<PMaterialIns
|
||||
Array<StaticMeshVertexData::BiTangentType> biTangents(mesh->mNumVertices);
|
||||
Array<StaticMeshVertexData::ColorType> 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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ Array<Halfedge> generateEdges() {
|
||||
UVector(13, 10, 14), UVector(10, 11, 14), UVector(14, 11, 15)};
|
||||
Array<Halfedge> 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});
|
||||
|
||||
@@ -5,14 +5,14 @@ namespace Seele {
|
||||
namespace Component {
|
||||
struct KeyboardInput {
|
||||
Seele::StaticArray<bool, static_cast<size_t>(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
|
||||
@@ -83,12 +83,12 @@ template <typename T> struct Array {
|
||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||
using const_reverse_iterator = std::reverse_iterator<const_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 <typename T> struct Array {
|
||||
std::allocator_traits<allocator_type>::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 <typename T> struct Array {
|
||||
}
|
||||
}
|
||||
}
|
||||
constexpr Array(std::initializer_list<T> init, const allocator_type& alloc = allocator_type(debug_resource::get("Array")))
|
||||
constexpr Array(std::initializer_list<T> 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 <container_compatible_range<T> 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<Range> || std::ranges::forward_range<Range>) {
|
||||
arraySize = std::ranges::size(rg);
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
using namespace Seele;
|
||||
|
||||
|
||||
std::atomic_uint64_t& MemoryManager::getAllocationCounter(const std::string& name) {
|
||||
RefPtr<uint64> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
#pragma once
|
||||
#include <memory_resource>
|
||||
#include <map>
|
||||
#include "MinimalEngine.h"
|
||||
|
||||
namespace Seele {
|
||||
class MemoryManager {
|
||||
public:
|
||||
static std::atomic_uint64_t& getAllocationCounter(const std::string& name);
|
||||
static RefPtr<uint64> getAllocationCounter(const std::string& name);
|
||||
static void printAllocations();
|
||||
|
||||
private:
|
||||
static MemoryManager& getInstance();
|
||||
std::mutex allocationMutex;
|
||||
std::map<std::string, std::atomic_uint64_t> allocationCounters;
|
||||
std::map<std::string, OwningPtr<uint64>> 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<uint64> counter;
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -7,11 +7,25 @@ namespace Seele {
|
||||
template <typename KeyType, typename NodeData, typename KeyFun, typename Compare, typename Allocator> 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<Allocator>::template rebind_alloc<Node>;
|
||||
|
||||
@@ -24,49 +38,65 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
using reference = IterType&;
|
||||
using pointer = IterType*;
|
||||
|
||||
constexpr IteratorBase(Node* x = nullptr, Array<Node*>&& beginIt = Array<Node*>()) : 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>::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 <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
Node* getNode() { return node; }
|
||||
Node* getNode() const { return node; }
|
||||
|
||||
private:
|
||||
Node* node;
|
||||
Array<Node*> traversal;
|
||||
};
|
||||
using Iterator = IteratorBase<NodeData>;
|
||||
using ConstIterator = IteratorBase<const NodeData>;
|
||||
@@ -122,8 +151,8 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
}
|
||||
}
|
||||
constexpr Tree(Tree&& other) noexcept
|
||||
: alloc(std::move(other.alloc)), root(std::move(other.root)), iteratorsDirty(true), _size(std::move(other._size)),
|
||||
comp(std::move(other.comp)) {
|
||||
: alloc(std::move(other.alloc)), root(std::move(other.root)), pseudoRoot(std::move(other.pseudoRoot)), iteratorsDirty(true),
|
||||
_size(std::move(other._size)), comp(std::move(other.comp)) {
|
||||
other._size = 0;
|
||||
}
|
||||
constexpr ~Tree() noexcept { clear(); }
|
||||
@@ -147,6 +176,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
alloc = std::move(other.alloc);
|
||||
}
|
||||
root = std::move(other.root);
|
||||
pseudoRoot = std::move(other.pseudoRoot);
|
||||
_size = std::move(other._size);
|
||||
comp = std::move(other.comp);
|
||||
other._size = 0;
|
||||
@@ -159,6 +189,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
root = _remove(root, keyFun(root->data));
|
||||
}
|
||||
root = nullptr;
|
||||
pseudoRoot.setLeftChild(nullptr);
|
||||
markIteratorsDirty();
|
||||
}
|
||||
constexpr iterator begin() {
|
||||
@@ -191,6 +222,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
protected:
|
||||
constexpr iterator find(const key_type& key) {
|
||||
root = _splay(root, key);
|
||||
pseudoRoot.setLeftChild(root);
|
||||
if (root == nullptr || !equal(root->data, key)) {
|
||||
return end();
|
||||
}
|
||||
@@ -213,15 +245,18 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
constexpr Pair<iterator, bool> insert(const NodeData& data) {
|
||||
auto [r, inserted] = _insert(root, data);
|
||||
root = r;
|
||||
pseudoRoot.setLeftChild(root);
|
||||
return Pair<iterator, bool>(iterator(root), inserted);
|
||||
}
|
||||
constexpr Pair<iterator, bool> insert(NodeData&& data) {
|
||||
auto [r, inserted] = _insert(root, std::move(data));
|
||||
root = r;
|
||||
pseudoRoot.setLeftChild(root);
|
||||
return Pair<iterator, bool>(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 <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
iteratorsDirty = false;
|
||||
}
|
||||
constexpr Iterator calcBeginIterator() const {
|
||||
Node* begin = root;
|
||||
Array<Node*> beginTraversal;
|
||||
while (begin != nullptr) {
|
||||
beginTraversal.add(begin);
|
||||
// start at pseudoroot so that if no regular nodes exist begin == end
|
||||
Node* begin = const_cast<Node*>(&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<Node*> 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<Node*>(&pseudoRoot)); }
|
||||
NodeAlloc alloc;
|
||||
Node* root;
|
||||
// where the end iterator points to
|
||||
Node pseudoRoot;
|
||||
Iterator beginIt;
|
||||
Iterator endIt;
|
||||
bool iteratorsDirty;
|
||||
@@ -271,14 +295,14 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
KeyFun keyFun = KeyFun();
|
||||
Node* rotateLeft(Node* x) {
|
||||
Node* y = x->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 <class NodeDataType> Pair<Node*, bool> _insert(Node* r, NodeDataType&& data) {
|
||||
@@ -298,13 +322,13 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
std::allocator_traits<NodeAlloc>::construct(alloc, newNode, nullptr, nullptr, std::forward<NodeDataType>(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<Node*, bool>(newNode, true);
|
||||
@@ -327,7 +351,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
temp = r;
|
||||
|
||||
r = _splay(r->leftChild, key);
|
||||
r->rightChild = temp->rightChild;
|
||||
r->setRightChild(temp->rightChild);
|
||||
}
|
||||
std::allocator_traits<NodeAlloc>::destroy(alloc, temp);
|
||||
alloc.deallocate(temp, 1);
|
||||
@@ -344,11 +368,11 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
return r;
|
||||
|
||||
if (comp(key, keyFun(r->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 <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
return r;
|
||||
|
||||
if (comp(key, keyFun(r->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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Gfx::RayTracingHitGroup> callableGroups;
|
||||
Array<Gfx::PBottomLevelAS> accelerationStructures;
|
||||
Array<InstanceData> 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<Gfx::ORenderCommand> 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"},
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -10,8 +10,8 @@ WaterRenderer::WaterRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescri
|
||||
: graphics(graphics), scene(scene) {
|
||||
skyBox = AssetRegistry::findTexture("", "skyboxsun5deg_tn")->getTexture().cast<Gfx::TextureCube>();
|
||||
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);
|
||||
|
||||
@@ -57,8 +57,8 @@ class WaterRenderer {
|
||||
};
|
||||
StaticArray<DisplaySpectrumSettings, 8> 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;
|
||||
|
||||
@@ -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<PositionType> posData{debug_resource::get("VertexPositions")};
|
||||
Array<PositionType> posData;
|
||||
Array<TexCoordType> texData[MAX_TEXCOORDS];
|
||||
Array<NormalType> norData;
|
||||
Array<TangentType> tanData;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<PCommandBoundResource> 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<PCommandBoundResource> boundResources;
|
||||
VkViewport currentViewport;
|
||||
VkRect2D currentScissor;
|
||||
PGraphics graphics;
|
||||
std::thread::id threadId;
|
||||
VkCommandBuffer handle;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -97,11 +97,11 @@ DescriptorPool::DescriptorPool(PGraphics graphics, PDescriptorLayout layout)
|
||||
perTypeSizes[binding.descriptorType] += 512;
|
||||
}
|
||||
Array<VkDescriptorPoolSize> 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<uint32, VkPipelineLayout> cachedLayouts;
|
||||
|
||||
void PipelineLayout::create() {
|
||||
for (auto [name, desc] : descriptorSetLayouts) {
|
||||
for (const auto& [_, desc] : descriptorSetLayouts) {
|
||||
PDescriptorLayout layout = desc.cast<DescriptorLayout>();
|
||||
layout->create();
|
||||
uint32 parameterIndex = parameterMapping[layout->getName()];
|
||||
|
||||
@@ -24,7 +24,7 @@ class DescriptorLayout : public Gfx::DescriptorLayout {
|
||||
private:
|
||||
PGraphics graphics;
|
||||
uint32 constantsSize = 0;
|
||||
VkShaderStageFlags constantsStages;
|
||||
VkShaderStageFlags constantsStages = 0;
|
||||
Array<VkDescriptorSetLayoutBinding> bindings;
|
||||
Map<std::string, DescriptorMapping> mappings;
|
||||
VkDescriptorSetLayout layoutHandle;
|
||||
@@ -74,7 +74,6 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource {
|
||||
private:
|
||||
std::vector<uint8> constantData;
|
||||
OBufferAllocation constantsBuffer;
|
||||
VkShaderStageFlags constantsStageFlags;
|
||||
List<VkDescriptorImageInfo> imageInfos;
|
||||
List<VkDescriptorBufferInfo> bufferInfos;
|
||||
List<VkWriteDescriptorSetAccelerationStructureKHR> accelerationInfos;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,23 +11,23 @@ using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
|
||||
PipelineCache::PipelineCache(PGraphics graphics, const std::string& cacheFilePath) : graphics(graphics), cacheFile(cacheFilePath) {
|
||||
Array<uint8> 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<uint8> cacheData;
|
||||
uint32 fileSize = static_cast<uint32>(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<uint64>(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<uint8> 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<uint8> 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -34,7 +34,7 @@ void Semaphore::rotateSemaphore() {
|
||||
currentHandle = i;
|
||||
return;
|
||||
}
|
||||
currentHandle = handles.size();
|
||||
currentHandle = (uint32)handles.size();
|
||||
handles.add(new SemaphoreHandle(graphics, "Semaphore"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -11,9 +11,9 @@ struct BoundingSphere {
|
||||
};
|
||||
struct AABB {
|
||||
Vector min = Vector(std::numeric_limits<float>::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<float>::lowest()); // cause of reasons
|
||||
float pad1;
|
||||
float pad1 = 0;
|
||||
BoundingSphere toSphere() const {
|
||||
Vector center = (min + max) / 2.f;
|
||||
StaticArray<Vector, 8> corners;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<Pair<entt::entity, entt::entity>>& overlaps);
|
||||
void traverseDynamicTree(const AABB& aabb, entt::entity source, int32 nodeIndex, Array<Pair<entt::entity, entt::entity>>& overlaps);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class SystemBase {
|
||||
virtual void update() {}
|
||||
|
||||
protected:
|
||||
double deltaTime;
|
||||
double deltaTime = 0.0;
|
||||
entt::registry& registry;
|
||||
PScene scene;
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user