diff options
| author | bunnei <bunneidev@gmail.com> | 2019-08-29 13:07:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-29 13:07:01 -0400 |
| commit | e4246158393fc011b16a4c1ef023c167cde9d4f8 (patch) | |
| tree | 461f4e0a45a1d44bc2f81a3ef7f35cb10cece680 /src/video_core/buffer_cache/buffer_block.h | |
| parent | f8cc5668f80d0c63f5ce850286760807462e1d72 (diff) | |
| parent | 83ec2091c1836bf32e9070d0ddf2a53288871d69 (diff) | |
Merge pull request #2783 from FernandoS27/new-buffer-cache
Implement a New LLE Buffer Cache
Diffstat (limited to 'src/video_core/buffer_cache/buffer_block.h')
| -rw-r--r-- | src/video_core/buffer_cache/buffer_block.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/video_core/buffer_cache/buffer_block.h b/src/video_core/buffer_cache/buffer_block.h new file mode 100644 index 000000000..d2124443f --- /dev/null +++ b/src/video_core/buffer_cache/buffer_block.h @@ -0,0 +1,77 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <unordered_set> +#include <utility> + +#include "common/alignment.h" +#include "common/common_types.h" +#include "video_core/gpu.h" + +namespace VideoCommon { + +class BufferBlock { +public: + bool Overlaps(const CacheAddr start, const CacheAddr end) const { + return (cache_addr < end) && (cache_addr_end > start); + } + + bool IsInside(const CacheAddr other_start, const CacheAddr other_end) const { + return cache_addr <= other_start && other_end <= cache_addr_end; + } + + u8* GetWritableHostPtr() const { + return FromCacheAddr(cache_addr); + } + + u8* GetWritableHostPtr(std::size_t offset) const { + return FromCacheAddr(cache_addr + offset); + } + + std::size_t GetOffset(const CacheAddr in_addr) { + return static_cast<std::size_t>(in_addr - cache_addr); + } + + CacheAddr GetCacheAddr() const { + return cache_addr; + } + + CacheAddr GetCacheAddrEnd() const { + return cache_addr_end; + } + + void SetCacheAddr(const CacheAddr new_addr) { + cache_addr = new_addr; + cache_addr_end = new_addr + size; + } + + std::size_t GetSize() const { + return size; + } + + void SetEpoch(u64 new_epoch) { + epoch = new_epoch; + } + + u64 GetEpoch() { + return epoch; + } + +protected: + explicit BufferBlock(CacheAddr cache_addr, const std::size_t size) : size{size} { + SetCacheAddr(cache_addr); + } + ~BufferBlock() = default; + +private: + CacheAddr cache_addr{}; + CacheAddr cache_addr_end{}; + u64 pages{}; + std::size_t size{}; + u64 epoch{}; +}; + +} // namespace VideoCommon |
