Slight changes to accomodate game

This commit is contained in:
Dynamitos
2025-04-11 18:15:39 +02:00
parent 708ab36377
commit f4f497194a
4 changed files with 21 additions and 21 deletions
+1 -1
View File
@@ -41,7 +41,7 @@
"buildCommandArgs": "",
"ctestCommandArgs": "",
"configurationType": "Debug",
"generator": "Ninja Multi-Config",
"generator": "Ninja",
"intelliSenseMode": "windows-msvc-x64",
"inheritEnvironments": [ "msvc_x64" ],
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
+11 -13
View File
@@ -8,10 +8,6 @@
#include <iterator>
#include <memory_resource>
#ifndef DEFAULT_ALLOC_SIZE
#define DEFAULT_ALLOC_SIZE 16
#endif
namespace Seele {
template <typename T> struct Array {
public:
@@ -84,10 +80,7 @@ template <typename T> struct Array {
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
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);
}
: arraySize(0), allocated(0), _data(nullptr), allocator(alloc) {}
constexpr Array(size_type size, const value_type& value, const allocator_type& alloc = allocator_type())
: arraySize(size), allocated(size), allocator(alloc) {
_data = allocateArray(size);
@@ -313,7 +306,7 @@ template <typename T> struct Array {
}
constexpr void resize(size_type newSize) { resizeInternal(newSize, T()); }
constexpr void resize(size_type newSize, const value_type& value) { resizeInternal(newSize, value); }
constexpr void clear() noexcept {
constexpr void clear(bool preserveAllocation = false) noexcept {
if (_data == nullptr) {
return;
}
@@ -322,10 +315,12 @@ template <typename T> struct Array {
std::allocator_traits<allocator_type>::destroy(allocator, &_data[i]);
}
}
deallocateArray(_data, allocated);
_data = nullptr;
if (!preserveAllocation) {
deallocateArray(_data, allocated);
_data = nullptr;
allocated = 0;
}
arraySize = 0;
allocated = 0;
}
[[nodiscard]] constexpr size_type indexOf(iterator iterator) { return iterator - begin(); }
[[nodiscard]] constexpr size_type indexOf(const_iterator iterator) const { return iterator.p - begin().p; }
@@ -400,7 +395,10 @@ template <typename T> struct Array {
for (size_type i = 0; i < arraySize; ++i) {
std::allocator_traits<allocator_type>::construct(allocator, &tempArray[i], std::forward<Type>(_data[i]));
}
deallocateArray(_data, arraySize);
if (_data != nullptr)
{
deallocateArray(_data, arraySize);
}
_data = tempArray;
}
std::allocator_traits<allocator_type>::construct(allocator, &_data[arraySize], std::forward<Type>(t));
+8 -6
View File
@@ -16,14 +16,16 @@ uint64 VertexData::meshletCount = 0;
void VertexData::resetMeshData() {
std::unique_lock l(materialDataLock);
instanceData.clear();
instanceMeshData.clear();
rayTracingScene.clear();
transparentData.clear();
instanceData.clear(true);
instanceMeshData.clear(true);
rayTracingScene.clear(true);
transparentData.clear(true);
for (auto& mat : materialData) {
for (auto& inst : mat.instances) {
inst.instanceData.clear();
inst.instanceMeshData.clear();
inst.instanceData.clear(true);
inst.instanceMeshData.clear(true);
inst.cullingOffsets.clear(true);
inst.rayTracingData.clear(true);
}
if (mat.material != nullptr) {
mat.material->getDescriptorLayout()->reset();
+1 -1
View File
@@ -56,7 +56,7 @@ class VertexData {
};
void resetMeshData();
void updateMesh(uint32 meshletOffset, PMesh mesh, Component::Transform& transform);
void createDescriptors();
virtual void createDescriptors();
void loadMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
void commitMeshes();
MeshId allocateVertexData(uint64 numVertices);