mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-17 04:39:34 +00:00
Rename SimpleBuf -> AlignedVector, use regular aligned memory instead of pages.
This commit is contained in:
parent
f45a7cf06b
commit
321a112eff
@ -47,24 +47,24 @@ void FreeAlignedMemory(void* ptr);
|
||||
|
||||
int GetMemoryProtectPageSize();
|
||||
|
||||
// A simple buffer that bypasses the libc memory allocator. As a result the buffer is always page-aligned.
|
||||
template <typename T>
|
||||
class SimpleBuf {
|
||||
// A buffer that uses aligned memory. Can be useful for image processing.
|
||||
template <typename T, size_t A>
|
||||
class AlignedVector {
|
||||
public:
|
||||
SimpleBuf() : buf_(0), size_(0) {}
|
||||
AlignedVector() : buf_(0), size_(0) {}
|
||||
|
||||
SimpleBuf(size_t size) : buf_(0) {
|
||||
AlignedVector(size_t size) : buf_(0) {
|
||||
resize(size);
|
||||
}
|
||||
|
||||
SimpleBuf(const SimpleBuf &o) : buf_(o.buf_), size_(o.size_) {}
|
||||
AlignedVector(const AlignedVector &o) : buf_(o.buf_), size_(o.size_) {}
|
||||
|
||||
// Move constructor
|
||||
SimpleBuf(SimpleBuf &&o) noexcept : buf_(o.buf_), size_(o.size_) { o.buf_ = nullptr; o.size_ = 0; }
|
||||
AlignedVector(AlignedVector &&o) noexcept : buf_(o.buf_), size_(o.size_) { o.buf_ = nullptr; o.size_ = 0; }
|
||||
|
||||
~SimpleBuf() {
|
||||
~AlignedVector() {
|
||||
if (buf_ != 0) {
|
||||
FreeMemoryPages(buf_, size_ * sizeof(T));
|
||||
FreeAlignedMemory(buf_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,9 +76,9 @@ public:
|
||||
void resize(size_t size) {
|
||||
if (size_ < size) {
|
||||
if (buf_ != 0) {
|
||||
FreeMemoryPages(buf_, size_ * sizeof(T));
|
||||
FreeAlignedMemory(buf_);
|
||||
}
|
||||
buf_ = (T *)AllocateMemoryPages(size * sizeof(T), MEM_PROT_READ | MEM_PROT_WRITE);
|
||||
buf_ = (T *)AllocateAlignedMemory(size * sizeof(T), A);
|
||||
size_ = size;
|
||||
}
|
||||
}
|
||||
|
@ -482,8 +482,8 @@ protected:
|
||||
};
|
||||
std::vector<VideoInfo> videos_;
|
||||
|
||||
SimpleBuf<u32> tmpTexBuf32_;
|
||||
SimpleBuf<u32> tmpTexBufRearrange_;
|
||||
AlignedVector<u32, 16> tmpTexBuf32_;
|
||||
AlignedVector<u32, 16> tmpTexBufRearrange_;
|
||||
|
||||
TexCacheEntry *nextTexture_ = nullptr;
|
||||
bool failedTexture_ = false;
|
||||
|
@ -50,5 +50,5 @@ protected:
|
||||
// depending on the factor and texture sizes, these can get pretty large
|
||||
// maximum is (100 MB total for a 512 by 512 texture with scaling factor 5 and hybrid scaling)
|
||||
// of course, scaling factor 5 is totally silly anyway
|
||||
SimpleBuf<u32> bufDeposter, bufOutput, bufTmp1, bufTmp2, bufTmp3;
|
||||
AlignedVector<u32, 16> bufDeposter, bufOutput, bufTmp1, bufTmp2, bufTmp3;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user