Commit 275bc244 authored by Lukas Tietze's avatar Lukas Tietze

Kleine uMräumaktion

parent 79eacc65
......@@ -75,6 +75,10 @@ add_library(
src/Lib/src/VkUtil/OneTimeCommandBuffer.cpp
src/Lib/src/VkUtil/StbImageImpl.cpp
src/Lib/src/VkUtil/Memory/MappedMemory.cpp
src/Lib/src/VkUtil/Memory/Memory.cpp
src/Lib/src/VkUtil/Memory/OutOfMemoryException.cpp
src/submodules/dearImGui/imgui_demo.cpp
src/submodules/dearImGui/imgui_draw.cpp
src/submodules/dearImGui/imgui_widgets.cpp
......
......@@ -17,8 +17,8 @@
#include "Util/GenericVertex.hpp"
#include "Util/NameList.hpp"
#include "VkUtil/BottomLevelAccelerationStructure.hpp"
#include "VkUtil/Buffer.hpp"
#include "VkUtil/StagedBuffer.hpp"
#include "VkUtil/Memory/Buffer.hpp"
#include "VkUtil/Memory/StagedBuffer.hpp"
#include "VkUtil/OneTimeCommandBuffer.hpp"
#include "VkUtil/Shader.hpp"
#include "VkUtil/TopLevelAccelerationStructure.hpp"
......
......@@ -4,7 +4,7 @@
#include "VkUtil/RenderTarget.hpp"
#include "GlfwAndVulkan.hpp"
#include "VkUtil/StagedBuffer.hpp"
#include "VkUtil/Memory/StagedBuffer.hpp"
namespace lib
{
......
......@@ -5,7 +5,7 @@
#include <memory>
#include "VkUtil/VkUtil.hpp"
#include "VkUtil/Buffer.hpp"
#include "VkUtil/Memory/Buffer.hpp"
namespace lib
{
......
#pragma once
#include "GlfwAndVulkan.hpp"
namespace lib
{
class CgContext;
class BufferPool
{
private:
class Buffer
{
private:
friend BufferPool;
vk::Buffer handle;
vk::DeviceSize size;
void *data;
public:
Buffer(BufferPool *parent);
void WriteData();
};
vk::DeviceMemory memory;
vk::DeviceSize totalAllocation = 0;
vk::DeviceSize allocatedMemory = 0;
CgContext *context;
public:
BufferPool(CgContext *context, vk::MemoryPropertyFlags memoryPropertyFlags);
BufferPool::Buffer AcquireBuffer(vk::BufferUsageFlags flags, const std::vector<uint32_t> &familyIndices);
};
} // namespace lib
#pragma once
#include "GlfwAndVulkan.hpp"
namespace lib
{
class CgContext;
class BufferPool
{
private:
class Buffer
{
private:
friend BufferPool;
vk::Buffer handle;
vk::DeviceSize size;
void *data;
public:
Buffer(BufferPool *parent);
void WriteData();
};
vk::DeviceMemory memory;
vk::DeviceSize totalAllocation = 0;
vk::DeviceSize allocatedMemory = 0;
CgContext *context;
public:
BufferPool(CgContext *context, vk::MemoryPropertyFlags memoryPropertyFlags);
BufferPool::Buffer AcquireBuffer(vk::BufferUsageFlags flags, const std::vector<uint32_t> &familyIndices);
};
} // namespace lib
#pragma once
#include "GlfwAndVulkan.hpp"
#include <map>
class CgContext;
namespace lib
{
struct Allocation
{
vk::DeviceMemory memory;
vk::DeviceSize offset;
};
class MemoryAllocator
{
private:
struct Memory
{
vk::DeviceMemory memory;
vk::DeviceSize size;
};
std::map<uint32_t, Memory> memoryPerType;
vk::DeviceSize totalSize = 0;
CgContext *context = nullptr;
public:
MemoryAllocator(CgContext *context);
~MemoryAllocator();
Allocation Acquire(vk::DeviceSize size) const;
void Allocate() const;
void Reserve(vk::DeviceSize size) const;
};
class OutOfMemoryException : public std::exception
{
private:
friend MemoryAllocator;
OutOfMemoryException();
};
class MappedMemory
{
private:
friend MemoryAllocator;
vk::DeviceSize offset;
vk::DeviceSize size;
MappedMemory(vk::DeviceSize offset, vk::DeviceSize size, CgContext *);
public:
~MappedMemory();
void Write(const void *data, const size_t len);
template <typename T>
void Write(const T &data)
{
this->Write(static_cast<void *>(&data), sizeof(data));
}
template <typename T>
void Write(const std::vector<T> &data)
{
this->Write(data.data(), data.size() * sizeof(T));
}
};
class WriteOutOfBoundsException : public std::exception
{
private:
friend MappedMemory;
WriteOutOfBoundsException(const MappedMemory &errorMemory);
};
} // namespace lib
......@@ -5,7 +5,7 @@
#include <exception>
#include "GlfwAndVulkan.hpp"
#include "VkUtil/Buffer.hpp"
#include "VkUtil/Memory/Buffer.hpp"
namespace lib
{
......
#include "Core/CgContext.hpp"
#include "VkUtil/Buffer.hpp"
#include "VkUtil/Memory/Buffer.hpp"
#include "Util/Utils.hpp"
#include "VkUtil/VkUtil.hpp"
#include "Util/Logging.hpp"
......
#include "Core/CgContext.hpp"
#include "VkUtil/StagedBuffer.hpp"
#include "VkUtil/Memory/StagedBuffer.hpp"
#include "Util/Utils.hpp"
#include "VkUtil/VkUtil.hpp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment