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