Merge pal Resource mapLayers/unmapLayers logic into map/unmap

Change-Id: I0198fb96f104539fb557f91160665e60ba576132
Этот коммит содержится в:
Jason Tang
2020-06-15 14:45:23 -04:00
коммит произвёл Jason Tang
родитель 1bd265f8d6
Коммит 155ff5bdcc
2 изменённых файлов: 14 добавлений и 50 удалений
+14 -38
Просмотреть файл
@@ -1843,28 +1843,19 @@ void* Resource::map(VirtualGPU* gpu, uint flags, uint startLayer, uint numLayers
// Check if memory wasn't mapped yet
if (++mapCount_ == 1) {
if ((desc().dimSize_ == 3) || desc().imageArray_ ||
((desc().type_ == ImageView) && viewOwner_->mipMapped())) {
// Save map info for multilayer map/unmap
startLayer_ = startLayer;
numLayers_ = numLayers;
mapFlags_ = flags;
// Map with layers
address_ = mapLayers(gpu, flags);
// Map current resource
if (memRef_->cpuAddress_ != nullptr) {
// Suballocations are mapped by the memory suballocator
address_ = reinterpret_cast<uint8_t*>(memRef_->cpuAddress_) + subOffset_;
} else {
// Map current resource
if (memRef_->cpuAddress_ != nullptr) {
// Suballocations are mapped by the memory suballocator
address_ = reinterpret_cast<uint8_t*>(memRef_->cpuAddress_) + subOffset_;
} else {
address_ = gpuMemoryMap(&desc_.pitch_, flags, iMem());
address_ = reinterpret_cast<address>(address_) + offset_;
}
if (address_ == nullptr) {
LogError("cal::ResMap failed!");
--mapCount_;
return nullptr;
}
address_ = gpuMemoryMap(&desc_.pitch_, flags, iMem());
address_ = reinterpret_cast<address>(address_) + offset_;
}
if (address_ == nullptr) {
LogError("cal::ResMap failed!");
--mapCount_;
return nullptr;
}
}
@@ -1881,12 +1872,6 @@ void* Resource::map(VirtualGPU* gpu, uint flags, uint startLayer, uint numLayers
return address_;
}
// ================================================================================================
void* Resource::mapLayers(VirtualGPU* gpu, uint flags) {
Unimplemented();
return nullptr;
}
// ================================================================================================
void Resource::unmap(VirtualGPU* gpu) {
if (isMemoryType(Pinned)) {
@@ -1898,14 +1883,8 @@ void Resource::unmap(VirtualGPU* gpu) {
// Check if it's the last unmap
if (count == 0) {
if ((desc().dimSize_ == 3) || desc().imageArray_ ||
((desc().type_ == ImageView) && viewOwner_->mipMapped())) {
// Unmap layers
unmapLayers(gpu);
} else {
// Unmap current resource
gpuMemoryUnmap(iMem());
}
// Unmap current resource
gpuMemoryUnmap(iMem());
address_ = nullptr;
} else if (count < 0) {
LogError("dev().serialCalResUnmap failed!");
@@ -1914,9 +1893,6 @@ void Resource::unmap(VirtualGPU* gpu) {
}
}
// ================================================================================================
void Resource::unmapLayers(VirtualGPU* gpu) { Unimplemented(); }
// ================================================================================================
bool MemorySubAllocator::InitAllocator(GpuMemoryReference* mem_ref) {
MemBuddyAllocator* allocator =
-12
Просмотреть файл
@@ -460,18 +460,6 @@ class Resource : public amd::HeapObject {
//! Disable operator=
Resource& operator=(const Resource&);
/*! \brief Locks the resource with layers and returns a physical pointer
*
* \return Pointer to the physical memory
*/
void* mapLayers(VirtualGPU* gpu, //!< Virtual GPU device object
uint flags = 0 //!< flags for the map operation
);
//! Unlocks the resource with layers if it was locked
void unmapLayers(VirtualGPU* gpu //!< Virtual GPU device object
);
//! Calls PAL to map a resource
void* gpuMemoryMap(size_t* pitch, //!< Pitch value for the image
uint flags, //!< Map flags