Reducing startup time significantly
This commit is contained in:
@@ -55,7 +55,7 @@ void Camera::buildViewMatrix()
|
||||
Vector eyePos = getTransform().getPosition();//getAbsoluteTransform().getPosition();
|
||||
Vector lookAt = eyePos + glm::normalize(Vector(cos(yaw) * cos(pitch), sin(pitch), sin(yaw) * cos(pitch)));
|
||||
//std::cout << "Eye: " << eyePos << " lookAt: " << lookAt << std::endl;
|
||||
viewMatrix = glm::lookAt(eyePos, lookAt, Vector(0, 1, 0));
|
||||
viewMatrix = glm::lookAt(Vector(100, 0, 10), Vector(0, 0, 0), Vector(0, 1, 0));//glm::lookAt(eyePos, lookAt, Vector(0, 1, 0));
|
||||
|
||||
bNeedsViewBuild = false;
|
||||
}
|
||||
|
||||
@@ -607,10 +607,17 @@ private:
|
||||
{
|
||||
newData[i] = std::forward<Type>(_data[i]);
|
||||
}
|
||||
// As well as default initialize the others
|
||||
for(size_type i = arraySize; i < newSize; ++i)
|
||||
if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>)
|
||||
{
|
||||
std::allocator_traits<allocator_type>::construct(allocator, &newData[i], value);
|
||||
std::memset(&newData[arraySize], 0, sizeof(T) * (newSize - arraySize));
|
||||
}
|
||||
else
|
||||
{
|
||||
// As well as default initialize the others
|
||||
for (size_type i = arraySize; i < newSize; ++i)
|
||||
{
|
||||
std::allocator_traits<allocator_type>::construct(allocator, &newData[i], value);
|
||||
}
|
||||
}
|
||||
deallocateArray(_data, allocated);
|
||||
arraySize = newSize;
|
||||
|
||||
@@ -29,7 +29,7 @@ void VertexData::updateMesh(const Component::Transform& transform, PMesh mesh)
|
||||
matInstanceData.meshes.add(MeshInstanceData{
|
||||
.id = mesh->id,
|
||||
.instance = InstanceData {
|
||||
.transformMatrix = transform.toMatrix(),
|
||||
.transformMatrix = Matrix4(1),//transform.toMatrix(),
|
||||
},
|
||||
.indexBuffer = mesh->indexBuffer,
|
||||
});
|
||||
|
||||
@@ -59,6 +59,7 @@ Allocation::Allocation(PGraphics graphics, PAllocator allocator, VkDeviceSize si
|
||||
allocInfo.memoryTypeIndex = memoryTypeIndex;
|
||||
isDedicated = dedicatedInfo != nullptr;
|
||||
allocInfo.pNext = dedicatedInfo;
|
||||
//std::cout << "New allocation" << std::endl;
|
||||
VK_CHECK(vkAllocateMemory(device, &allocInfo, nullptr, &allocatedMemory));
|
||||
bytesAllocated = size;
|
||||
freeRanges[0] = size;
|
||||
@@ -69,6 +70,7 @@ Allocation::Allocation(PGraphics graphics, PAllocator allocator, VkDeviceSize si
|
||||
|
||||
Allocation::~Allocation()
|
||||
{
|
||||
vkFreeMemory(device, allocatedMemory, nullptr);
|
||||
assert(bytesUsed == 0);
|
||||
}
|
||||
|
||||
@@ -180,7 +182,7 @@ Allocator::Allocator(PGraphics graphics)
|
||||
VkMemoryHeap memoryHeap = memProperties.memoryHeaps[i];
|
||||
HeapInfo heapInfo;
|
||||
heapInfo.maxSize = memoryHeap.size;
|
||||
std::cout << "Creating heap " << i << " with properties " << memoryHeap.flags << " size " << memoryHeap.size << std::endl;
|
||||
//std::cout << "Creating heap " << i << " with properties " << memoryHeap.flags << " size " << memoryHeap.size << std::endl;
|
||||
heaps.add(std::move(heapInfo));
|
||||
}
|
||||
}
|
||||
@@ -212,7 +214,7 @@ OSubAllocation Allocator::allocate(const VkMemoryRequirements2 &memRequirements2
|
||||
{
|
||||
OAllocation newAllocation = new Allocation(graphics, this, requirements.size, memoryTypeIndex, properties, dedicatedInfo);
|
||||
heaps[heapIndex].inUse += newAllocation->bytesAllocated;
|
||||
std::cout << "Heap " << heapIndex << ": " << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl;
|
||||
//std::cout << "Heap " << heapIndex << ": " << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl;
|
||||
heaps[heapIndex].allocations.add(std::move(newAllocation));
|
||||
return heaps[heapIndex].allocations.back()->getSuballocation(requirements.size, requirements.alignment);
|
||||
}
|
||||
@@ -232,12 +234,14 @@ OSubAllocation Allocator::allocate(const VkMemoryRequirements2 &memRequirements2
|
||||
// no suitable allocations found, allocate new block
|
||||
OAllocation newAllocation = new Allocation(graphics, this, (requirements.size > MemoryBlockSize) ? requirements.size : (VkDeviceSize)MemoryBlockSize, memoryTypeIndex, properties, nullptr);
|
||||
heaps[heapIndex].inUse += newAllocation->bytesAllocated;
|
||||
std::cout << "Heap " << heapIndex << ": " << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl; heaps[heapIndex].allocations.add(std::move(newAllocation));
|
||||
//std::cout << "Heap " << heapIndex << ": " << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl;
|
||||
heaps[heapIndex].allocations.add(std::move(newAllocation));
|
||||
return heaps[heapIndex].allocations.back()->getSuballocation(requirements.size, requirements.alignment);
|
||||
}
|
||||
|
||||
void Allocator::free(PAllocation allocation)
|
||||
{
|
||||
//std::cout << "Freeing allocation" << std::endl;
|
||||
for (uint32 heapIndex = 0; heapIndex < heaps.size(); ++heapIndex)
|
||||
{
|
||||
for (uint32 alloc = 0; alloc < heaps[heapIndex].allocations.size(); ++alloc)
|
||||
@@ -245,7 +249,7 @@ void Allocator::free(PAllocation allocation)
|
||||
if (heaps[heapIndex].allocations[alloc] == allocation)
|
||||
{
|
||||
heaps[heapIndex].inUse -= allocation->bytesAllocated;
|
||||
std::cout << "Heap " << heapIndex << ": " << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl;
|
||||
//std::cout << "Heap " << heapIndex << ": " << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl;
|
||||
heaps[heapIndex].allocations.removeAt(alloc, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
vkDestroySwapchainKHR(graphics->getDevice(), swapchain, nullptr);
|
||||
vkDestroySurfaceKHR(instance, surface, nullptr);
|
||||
glfwDestroyWindow(static_cast<GLFWwindow *>(windowHandle));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user