mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-24 11:35:38 +01:00
Implement IsBlockContinous
This detects when a GPU Memory Block is not continous within host cpu memory.
This commit is contained in:
parent
13d626fc21
commit
d0082de82a
@ -199,6 +199,14 @@ const u8* MemoryManager::GetPointer(GPUVAddr addr) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool MemoryManager::IsBlockContinous(const GPUVAddr start, const std::size_t size) {
|
||||
const GPUVAddr end = start + size;
|
||||
const auto host_ptr_start = reinterpret_cast<std::uintptr_t>(GetPointer(start));
|
||||
const auto host_ptr_end = reinterpret_cast<std::uintptr_t>(GetPointer(end));
|
||||
const std::size_t range = static_cast<std::size_t>(host_ptr_end - host_ptr_start);
|
||||
return range == size;
|
||||
}
|
||||
|
||||
void MemoryManager::ReadBlock(GPUVAddr src_addr, void* dest_buffer, const std::size_t size) const {
|
||||
std::size_t remaining_size{size};
|
||||
std::size_t page_index{src_addr >> page_bits};
|
||||
|
@ -65,7 +65,10 @@ public:
|
||||
u8* GetPointer(GPUVAddr addr);
|
||||
const u8* GetPointer(GPUVAddr addr) const;
|
||||
|
||||
/*
|
||||
// Returns true if the block is continous in host memory, false otherwise
|
||||
bool IsBlockContinous(const GPUVAddr start, const std::size_t size);
|
||||
|
||||
/**
|
||||
* ReadBlock and WriteBlock are full read and write operations over virtual
|
||||
* GPU Memory. It's important to use these when GPU memory may not be continous
|
||||
* in the Host Memory counterpart. Note: This functions cause Host GPU Memory
|
||||
@ -75,7 +78,7 @@ public:
|
||||
void WriteBlock(GPUVAddr dest_addr, const void* src_buffer, const std::size_t size);
|
||||
void CopyBlock(GPUVAddr dest_addr, GPUVAddr src_addr, const std::size_t size);
|
||||
|
||||
/*
|
||||
/**
|
||||
* ReadBlockUnsafe and WriteBlockUnsafe are special versions of ReadBlock and
|
||||
* WriteBlock respectively. In this versions, no flushing or invalidation is actually
|
||||
* done and their performance is similar to a memcpy. This functions can be used
|
||||
|
Loading…
Reference in New Issue
Block a user