SWDEV-355281 - Add offset calculation

Calculate memory location offset for requested memory

Change-Id: I7919523df1790d9eaad5827ee5bd98e4263a7554
Этот коммит содержится в:
German Andryeyev
2023-01-13 17:46:06 -05:00
родитель d97b4e8c74
Коммит 5d83345c20
2 изменённых файлов: 6 добавлений и 2 удалений
+4 -1
Просмотреть файл
@@ -296,7 +296,7 @@ void MemObjMap::RemoveMemObj(const void* k) {
}
}
amd::Memory* MemObjMap::FindMemObj(const void* k) {
amd::Memory* MemObjMap::FindMemObj(const void* k, size_t* offset) {
amd::ScopedLock lock(AllocatedLock_);
uintptr_t key = reinterpret_cast<uintptr_t>(k);
auto it = MemObjMap_.upper_bound(key);
@@ -307,6 +307,9 @@ amd::Memory* MemObjMap::FindMemObj(const void* k) {
--it;
amd::Memory* mem = it->second;
if (key >= it->first && key < (it->first + mem->getSize())) {
if (offset != nullptr) {
*offset = key - it->first;
}
// the k is in the range
return mem;
} else {