| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include "common/aglGPUMemBlock.h" |
| 4 | #include "detail/aglMemoryPoolHeap.h" |
| 5 | |
| 6 | namespace sead { |
| 7 | class Heap; |
| 8 | } |
| 9 | |
| 10 | namespace agl { |
| 11 | class GPUMemAddrBase { |
| 12 | public: |
| 13 | GPUMemAddrBase() {} |
| 14 | GPUMemAddrBase(const GPUMemAddrBase& other, int alignmentOffset) |
| 15 | : mMemoryPool(other.mMemoryPool), mAlignmentAddr(other.mAlignmentAddr + alignmentOffset), |
| 16 | mMemoryBlock(other.mMemoryBlock) {} |
| 17 | GPUMemAddrBase(const GPUMemBlockBase& memBlock, u64 offset); |
| 18 | |
| 19 | u32 verify_() const; |
| 20 | void deleteGPUMemBlock() const; |
| 21 | void invalidate(); |
| 22 | u32 getAlignmentAddress() const; |
| 23 | void setByteOffsetByPtr(void* ptr); |
| 24 | void roundUp(int addr); |
| 25 | void flushCPUCache(u64); |
| 26 | void invalidateCPUCache(u64); |
| 27 | |
| 28 | bool isValid() const { return mMemoryPool != nullptr; } |
| 29 | |
| 30 | private: |
| 31 | detail::MemoryPool* mMemoryPool = nullptr; |
| 32 | int mAlignmentAddr = 0; |
| 33 | GPUMemBlockBase* mMemoryBlock = nullptr; |
| 34 | }; |
| 35 | |
| 36 | template <typename T> |
| 37 | class GPUMemAddr : public GPUMemAddrBase {}; |
| 38 | } // namespace agl |
| 39 |