From 155ff5bdcc0ff87ca6bd346940a5a2463c0884fa Mon Sep 17 00:00:00 2001 From: Jason Tang Date: Mon, 15 Jun 2020 14:45:23 -0400 Subject: [PATCH] Merge pal Resource mapLayers/unmapLayers logic into map/unmap Change-Id: I0198fb96f104539fb557f91160665e60ba576132 --- rocclr/device/pal/palresource.cpp | 52 +++++++++---------------------- rocclr/device/pal/palresource.hpp | 12 ------- 2 files changed, 14 insertions(+), 50 deletions(-) diff --git a/rocclr/device/pal/palresource.cpp b/rocclr/device/pal/palresource.cpp index 6ebff35e82..5ca0fe01ec 100644 --- a/rocclr/device/pal/palresource.cpp +++ b/rocclr/device/pal/palresource.cpp @@ -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(memRef_->cpuAddress_) + subOffset_; } else { - // Map current resource - if (memRef_->cpuAddress_ != nullptr) { - // Suballocations are mapped by the memory suballocator - address_ = reinterpret_cast(memRef_->cpuAddress_) + subOffset_; - } else { - address_ = gpuMemoryMap(&desc_.pitch_, flags, iMem()); - address_ = reinterpret_cast
(address_) + offset_; - } - if (address_ == nullptr) { - LogError("cal::ResMap failed!"); - --mapCount_; - return nullptr; - } + address_ = gpuMemoryMap(&desc_.pitch_, flags, iMem()); + address_ = reinterpret_cast
(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 = diff --git a/rocclr/device/pal/palresource.hpp b/rocclr/device/pal/palresource.hpp index 773394f82d..4bb25a8787 100644 --- a/rocclr/device/pal/palresource.hpp +++ b/rocclr/device/pal/palresource.hpp @@ -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