Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
GraphicsMemoryBlock.h
Go to the documentation of this file.
1#pragma once
2
3#include <Utility/IMoveOnly.h>
4#include <Common/memory.h>
5#include <Utility/TSpan.h>
6
7#include <cstddef>
8
9namespace ph::editor::ghi
10{
11
12class GraphicsMemoryBlock : private IMoveOnly
13{
14protected:
18
19 void setBlockSource(std::byte* source, std::size_t blockSizeInBytes);
20
21 friend void swap(GraphicsMemoryBlock& first, GraphicsMemoryBlock& second) noexcept;
22
23public:
25
26 std::size_t numAllocatedBytes() const;
27 std::size_t numUsedBytes() const;
28 std::size_t numRemainingBytes() const;
29
34 void clear();
35
41 template<typename T, typename... Args>
42 T* make(Args&&... args);
43
48 template<typename T>
49 TSpan<T> makeArray(std::size_t arraySize);
50
51 bool hasBlockSource() const;
52
53private:
56 std::byte* allocRaw(std::size_t numBytes, std::size_t alignmentInBytes);
57
58 std::byte* m_blockSource;
59 std::size_t m_blockSizeInBytes;
60 std::byte* m_ptrInBlock;
61 std::size_t m_remainingBytesInBlock;
62};
63
64}// end namespace ph::editor::ghi
65
Definition GraphicsMemoryBlock.h:13
void setBlockSource(std::byte *source, std::size_t blockSizeInBytes)
Definition GraphicsMemoryBlock.cpp:34
std::size_t numAllocatedBytes() const
Definition GraphicsMemoryBlock.ipp:15
T * make(Args &&... args)
Make an object of type T as if by calling its constructor with Args.
Definition GraphicsMemoryBlock.ipp:38
GraphicsMemoryBlock()
Definition GraphicsMemoryBlock.cpp:12
bool hasBlockSource() const
Definition GraphicsMemoryBlock.cpp:47
TSpan< T > makeArray(std::size_t arraySize)
Make an array of default constructed objects of type T.
Definition GraphicsMemoryBlock.ipp:53
friend void swap(GraphicsMemoryBlock &first, GraphicsMemoryBlock &second) noexcept
Definition GraphicsMemoryBlock.cpp:52
GraphicsMemoryBlock & operator=(GraphicsMemoryBlock &&rhs) noexcept
Definition GraphicsMemoryBlock.cpp:25
std::size_t numUsedBytes() const
Definition GraphicsMemoryBlock.ipp:20
void clear()
Reset the usage of the block. All memory handed out are effectively deallocated/deleted after this ca...
Definition GraphicsMemoryBlock.ipp:31
std::size_t numRemainingBytes() const
Definition GraphicsMemoryBlock.ipp:26
Definition PlatformDisplay.h:13