diff --git a/runtime/aub_mem_dump/aub_alloc_dump.inl b/runtime/aub_mem_dump/aub_alloc_dump.inl index 9c0790120e..213a244a4c 100644 --- a/runtime/aub_mem_dump/aub_alloc_dump.inl +++ b/runtime/aub_mem_dump/aub_alloc_dump.inl @@ -55,7 +55,7 @@ void dumpBufferInBinFormat(GraphicsAllocation &gfxAllocation, AubMemDump::AubFil template void dumpImageInBmpFormat(GraphicsAllocation &gfxAllocation, AubMemDump::AubFileStream *stream, uint32_t context) { - auto gmm = gfxAllocation.gmm; + auto gmm = gfxAllocation.getDefaultGmm(); AubMemDump::AubCmdDumpBmpHd cmd; memset(&cmd, 0, sizeof(cmd)); @@ -121,7 +121,7 @@ void dumpBufferInTreFormat(GraphicsAllocation &gfxAllocation, AubMemDump::AubFil template void dumpImageInTreFormat(GraphicsAllocation &gfxAllocation, AubMemDump::AubFileStream *stream, uint32_t context) { using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE; - auto gmm = gfxAllocation.gmm; + auto gmm = gfxAllocation.getDefaultGmm(); if ((gmm->gmmResourceInfo->getNumSamples() > 1) || (gmm->isRenderCompressed)) { DEBUG_BREAK_IF(true); //unsupported return; diff --git a/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl b/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl index b4a4d825d0..e97ae8636c 100644 --- a/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl +++ b/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl @@ -105,8 +105,9 @@ bool CommandStreamReceiverSimulatedCommonHw::getParametersForWriteMem cpuAddress = ptrOffset(graphicsAllocation.getUnderlyingBuffer(), static_cast(graphicsAllocation.getAllocationOffset())); gpuAddress = GmmHelper::decanonize(graphicsAllocation.getGpuAddress()); size = graphicsAllocation.getUnderlyingBufferSize(); - if (graphicsAllocation.gmm && graphicsAllocation.gmm->isRenderCompressed) { - size = graphicsAllocation.gmm->gmmResourceInfo->getSizeAllocation(); + auto gmm = graphicsAllocation.getDefaultGmm(); + if (gmm && gmm->isRenderCompressed) { + size = gmm->gmmResourceInfo->getSizeAllocation(); } if ((size == 0) || !graphicsAllocation.isAubWritable()) diff --git a/runtime/helpers/hw_helper_common.inl b/runtime/helpers/hw_helper_common.inl index 4c07528bb7..342e190a00 100644 --- a/runtime/helpers/hw_helper_common.inl +++ b/runtime/helpers/hw_helper_common.inl @@ -145,7 +145,7 @@ void HwHelperHw::setRenderSurfaceStateForBuffer(ExecutionEnvironment &ex surfaceState->setSurfaceBaseAddress(bufferStateAddress); - Gmm *gmm = gfxAlloc ? gfxAlloc->gmm : nullptr; + Gmm *gmm = gfxAlloc ? gfxAlloc->getDefaultGmm() : nullptr; if (gmm && gmm->isRenderCompressed && !forceNonAuxMode && GraphicsAllocation::AllocationType::BUFFER_COMPRESSED == gfxAlloc->getAllocationType()) { // Its expected to not program pitch/qpitch/baseAddress for Aux surface in CCS scenarios diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index 6b01c95743..6baa5eb66e 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -257,7 +257,8 @@ Buffer *Buffer::create(Context *context, pBuffer->setHostPtrMinSize(size); if (copyMemoryFromHostPtr) { - if ((memory->gmm && memory->gmm->isRenderCompressed) || !MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) { + auto gmm = memory->getDefaultGmm(); + if ((gmm && gmm->isRenderCompressed) || !MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) { auto cmdQ = context->getSpecialQueue(); if (CL_SUCCESS != cmdQ->enqueueWriteBuffer(pBuffer, CL_TRUE, 0, size, hostPtr, 0, nullptr, nullptr)) { errcodeRet = CL_OUT_OF_RESOURCES; @@ -447,7 +448,7 @@ bool Buffer::isReadWriteOnCpuAllowed(cl_bool blocking, cl_uint numEventsInWaitLi return (blocking == CL_TRUE && numEventsInWaitList == 0 && !forceDisallowCPUCopy) && graphicsAllocation->peekSharedHandle() == 0 && (isMemObjZeroCopy() || (reinterpret_cast(ptr) & (MemoryConstants::cacheLineSize - 1)) != 0) && (!context->getDevice(0)->getDeviceInfo().platformLP || (size <= maxBufferSizeForReadWriteOnCpu)) && - !(graphicsAllocation->gmm && graphicsAllocation->gmm->isRenderCompressed) && + !(graphicsAllocation->getDefaultGmm() && graphicsAllocation->getDefaultGmm()->isRenderCompressed) && MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool()); } diff --git a/runtime/mem_obj/buffer.inl b/runtime/mem_obj/buffer.inl index c5440a35ca..229d961f8f 100644 --- a/runtime/mem_obj/buffer.inl +++ b/runtime/mem_obj/buffer.inl @@ -77,7 +77,7 @@ void BufferHw::setArgStateful(void *memory, bool forceNonAuxMode, boo surfaceState->setSurfaceBaseAddress(bufferAddressAligned); - Gmm *gmm = graphicsAllocation ? graphicsAllocation->gmm : nullptr; + Gmm *gmm = graphicsAllocation ? graphicsAllocation->getDefaultGmm() : nullptr; if (gmm && gmm->isRenderCompressed && !forceNonAuxMode && GraphicsAllocation::AllocationType::BUFFER_COMPRESSED == graphicsAllocation->getAllocationType()) { diff --git a/runtime/mem_obj/image.cpp b/runtime/mem_obj/image.cpp index 936f3b2b9b..aef4834b13 100644 --- a/runtime/mem_obj/image.cpp +++ b/runtime/mem_obj/image.cpp @@ -208,7 +208,7 @@ Image *Image::create(Context *context, } } else if (parentImage != nullptr) { memory = parentImage->getGraphicsAllocation(); - memory->gmm->queryImageParams(imgInfo); + memory->getDefaultGmm()->queryImageParams(imgInfo); isTilingAllowed = parentImage->allowTiling(); } else { errcodeRet = CL_OUT_OF_HOST_MEMORY; @@ -233,7 +233,7 @@ Image *Image::create(Context *context, } else { gmm = new Gmm(imgInfo); memory = memoryManager->allocateGraphicsMemoryWithProperties({false, imgInfo.size, GraphicsAllocation::AllocationType::UNDECIDED}, hostPtr); - memory->gmm = gmm; + memory->setDefaultGmm(gmm); zeroCopy = true; } @@ -389,7 +389,7 @@ Image *Image::createImageHw(Context *context, cl_mem_flags flags, size_t size, v Image *Image::createSharedImage(Context *context, SharingHandler *sharingHandler, McsSurfaceInfo &mcsSurfaceInfo, GraphicsAllocation *graphicsAllocation, GraphicsAllocation *mcsAllocation, cl_mem_flags flags, ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount) { - bool isTiledImage = graphicsAllocation->gmm->gmmResourceInfo->getTileModeSurfaceState() != 0; + bool isTiledImage = graphicsAllocation->getDefaultGmm()->gmmResourceInfo->getTileModeSurfaceState() != 0; auto sharedImage = createImageHw(context, flags, graphicsAllocation->getUnderlyingBufferSize(), nullptr, imgInfo.surfaceFormat->OCLImageFormat, *imgInfo.imgDesc, false, graphicsAllocation, false, isTiledImage, baseMipLevel, mipCount, imgInfo.surfaceFormat); diff --git a/runtime/mem_obj/image.inl b/runtime/mem_obj/image.inl index abf7055130..c8862827d5 100644 --- a/runtime/mem_obj/image.inl +++ b/runtime/mem_obj/image.inl @@ -30,7 +30,7 @@ template void ImageHw::setImageArg(void *memory, bool setAsMediaBlockImage, uint32_t mipLevel) { using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT; auto surfaceState = reinterpret_cast(memory); - auto gmm = getGraphicsAllocation()->gmm; + auto gmm = getGraphicsAllocation()->getDefaultGmm(); auto gmmHelper = executionEnvironment->getGmmHelper(); auto imageCount = std::max(getImageDesc().image_depth, getImageDesc().image_array_size); @@ -164,7 +164,7 @@ void ImageHw::setAuxParamsForMultisamples(RENDER_SURFACE_STATE *surfa using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT; if (getMcsAllocation()) { - auto mcsGmm = getMcsAllocation()->gmm; + auto mcsGmm = getMcsAllocation()->getDefaultGmm(); if (mcsGmm->unifiedAuxTranslationCapable() && mcsGmm->hasMultisampleControlSurface()) { setAuxParamsForMCSCCS(surfaceState, mcsGmm); diff --git a/runtime/mem_obj/mem_obj.cpp b/runtime/mem_obj/mem_obj.cpp index 3263fba50c..49293d7f37 100644 --- a/runtime/mem_obj/mem_obj.cpp +++ b/runtime/mem_obj/mem_obj.cpp @@ -328,7 +328,7 @@ bool MemObj::addMappedPtr(void *ptr, size_t ptrLength, cl_map_flags &mapFlags, bool MemObj::mappingOnCpuAllowed() const { return !allowTiling() && !peekSharingHandler() && !isMipMapped(this) && !DebugManager.flags.DisableZeroCopyForBuffers.get() && - !(graphicsAllocation->gmm && graphicsAllocation->gmm->isRenderCompressed) && + !(graphicsAllocation->getDefaultGmm() && graphicsAllocation->getDefaultGmm()->isRenderCompressed) && MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool()); } } // namespace OCLRT diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index 7ba6db6efd..ddbad7ca81 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -166,7 +166,19 @@ class GraphicsAllocation : public IDNode { } static StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties); - Gmm *gmm = nullptr; + Gmm *getDefaultGmm() const { + return getGmm(0u); + } + Gmm *getGmm(uint32_t handleId) const { + return gmms[handleId]; + } + void setDefaultGmm(Gmm *gmm) { + return setGmm(gmm, 0u); + } + void setGmm(Gmm *gmm, uint32_t handleId) { + gmms[handleId] = gmm; + } + OsHandleStorage fragmentsStorage; StorageInfo storageInfo = {}; @@ -230,5 +242,6 @@ class GraphicsAllocation : public IDNode { std::array usageInfos; std::atomic registeredContextsNum{0}; + std::array gmms{}; }; } // namespace OCLRT diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index a702216f3d..fa43544e64 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -346,7 +346,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForImage(const Allocati auto hostPtrAllocation = allocateGraphicsMemoryForImageFromHostPtr(allocationDataWithSize); if (hostPtrAllocation) { - hostPtrAllocation->gmm = gmm.release(); + hostPtrAllocation->setDefaultGmm(gmm.release()); return hostPtrAllocation; } @@ -405,7 +405,7 @@ HeapIndex MemoryManager::selectHeap(const GraphicsAllocation *allocation, const if (ptr) { return HeapIndex::HEAP_SVM; } - if (allocation && allocation->gmm->gmmResourceInfo->is64KBPageSuitable()) { + if (allocation && allocation->getDefaultGmm()->gmmResourceInfo->is64KBPageSuitable()) { return HeapIndex::HEAP_STANDARD64KB; } return HeapIndex::HEAP_STANDARD; diff --git a/runtime/memory_manager/os_agnostic_memory_manager.cpp b/runtime/memory_manager/os_agnostic_memory_manager.cpp index ecaf902151..d667774cbf 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager.cpp @@ -150,7 +150,7 @@ void OsAgnosticMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocat } void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) { - delete gfxAllocation->gmm; + delete gfxAllocation->getDefaultGmm(); if ((uintptr_t)gfxAllocation->getUnderlyingBuffer() == dummyAddress) { delete gfxAllocation; @@ -224,7 +224,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForImageImpl( if (!GmmHelper::allowTiling(*allocationData.imgInfo->imgDesc) && allocationData.imgInfo->mipCount == 0) { alloc = allocateGraphicsMemoryWithAlignment(allocationData); - alloc->gmm = gmm.release(); + alloc->setDefaultGmm(gmm.release()); return alloc; } @@ -236,7 +236,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForImageImpl( } if (alloc) { - alloc->gmm = gmm.release(); + alloc->setDefaultGmm(gmm.release()); } return alloc; diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index d42d59e26c..43a16034eb 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -322,7 +322,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A if (!GmmHelper::allowTiling(*allocationData.imgInfo->imgDesc)) { auto alloc = allocateGraphicsMemoryWithAlignment(allocationData); if (alloc) { - alloc->gmm = gmm.release(); + alloc->setDefaultGmm(gmm.release()); } return alloc; } @@ -353,7 +353,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A auto allocation = new DrmAllocation(allocationData.type, bo, nullptr, (uint64_t)gpuRange, allocationData.imgInfo->size, MemoryPool::SystemCpuInaccessible, false); bo->setAllocationType(allocatorType); - allocation->gmm = gmm.release(); + allocation->setDefaultGmm(gmm.release()); return allocation; } @@ -562,8 +562,8 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) { DrmAllocation *input; input = static_cast(gfxAllocation); - if (input->gmm) - delete input->gmm; + if (input->getDefaultGmm()) + delete input->getDefaultGmm(); alignedFreeWrapper(gfxAllocation->getDriverAllocatedCpuPtr()); diff --git a/runtime/os_interface/windows/wddm/wddm.cpp b/runtime/os_interface/windows/wddm/wddm.cpp index e68c85faa2..448b1a789f 100644 --- a/runtime/os_interface/windows/wddm/wddm.cpp +++ b/runtime/os_interface/windows/wddm/wddm.cpp @@ -290,7 +290,7 @@ bool Wddm::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantT bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr) { void *mapPtr = allocation->getReservedAddress() != nullptr ? allocation->getReservedAddress() : cpuPtr; - return mapGpuVirtualAddressImpl(allocation->gmm, allocation->getDefaultHandle(), mapPtr, allocation->getGpuAddressToModify(), + return mapGpuVirtualAddressImpl(allocation->getDefaultGmm(), allocation->getDefaultHandle(), mapPtr, allocation->getGpuAddressToModify(), MemoryManager::selectHeap(allocation, mapPtr, *hardwareInfoTable[gfxPlatform->eProductFamily])); } @@ -594,7 +594,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) { alloc->resourceHandle = OpenResource.hResource; auto resourceInfo = const_cast(allocationInfo[0].pPrivateDriverData); - alloc->gmm = new Gmm(static_cast(resourceInfo)); + alloc->setDefaultGmm(new Gmm(static_cast(resourceInfo))); return true; } @@ -631,7 +631,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) { alloc->resourceHandle = openResourceFromNtHandle.hResource; auto resourceInfo = const_cast(allocationInfo2[0].pPrivateDriverData); - alloc->gmm = new Gmm(static_cast(resourceInfo)); + alloc->setDefaultGmm(new Gmm(static_cast(resourceInfo))); return true; } diff --git a/runtime/os_interface/windows/wddm_memory_manager.cpp b/runtime/os_interface/windows/wddm_memory_manager.cpp index 0037d09d58..0e19f3d165 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.cpp +++ b/runtime/os_interface/windows/wddm_memory_manager.cpp @@ -49,7 +49,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImageImpl(const } auto allocation = std::make_unique(allocationData.type, nullptr, allocationData.imgInfo->size, nullptr, MemoryPool::SystemCpuInaccessible, false); - allocation->gmm = gmm.get(); + allocation->setDefaultGmm(gmm.get()); if (!createWddmAllocation(allocation.get())) { return nullptr; } @@ -66,7 +66,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const Allocati auto wddmAllocation = std::make_unique(allocationData.type, nullptr, sizeAligned, nullptr, MemoryPool::System64KBPages, !!allocationData.flags.multiOsContextCapable); auto gmm = new Gmm(nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true, {}); - wddmAllocation->gmm = gmm; + wddmAllocation->setDefaultGmm(gmm); if (!wddm->createAllocation64k(gmm, wddmAllocation->getHandleToModify(0u))) { delete gmm; @@ -99,7 +99,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const gmm = new Gmm(pSysMem, sizeAligned, allocationData.flags.uncacheable); - wddmAllocation->gmm = gmm; + wddmAllocation->setDefaultGmm(gmm); if (!createWddmAllocation(wddmAllocation.get())) { delete gmm; @@ -122,7 +122,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co auto gmm = new Gmm(alignedPtr, alignedSize, false); - wddmAllocation->gmm = gmm; + wddmAllocation->setDefaultGmm(gmm); if (!createWddmAllocation(wddmAllocation.get())) { delete gmm; @@ -155,7 +155,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithProperties(cons allocation->setAllocationOffset(offset); Gmm *gmm = new Gmm(ptrAligned, sizeAligned, false); - allocation->gmm = gmm; + allocation->setDefaultGmm(gmm); if (createWddmAllocation(allocation)) { DebugManager.logAllocation(allocation); return allocation; @@ -196,7 +196,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All wddmAllocation->setAllocationOffset(offset); gmm = new Gmm(ptrAligned, sizeAligned, false); - wddmAllocation->gmm = gmm; + wddmAllocation->setDefaultGmm(gmm); if (!createWddmAllocation(wddmAllocation.get())) { delete gmm; @@ -222,7 +222,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl } // Shared objects are passed without size - size_t size = allocation->gmm->gmmResourceInfo->getSizeAllocation(); + size_t size = allocation->getDefaultGmm()->gmmResourceInfo->getSizeAllocation(); allocation->setSize(size); void *ptr = nullptr; @@ -260,7 +260,7 @@ void WddmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAll fragment.osInternalStorage = new OsHandle(); fragment.osInternalStorage->gpuPtr = gfxAllocation->getGpuAddress(); fragment.osInternalStorage->handle = wddmMemory->getDefaultHandle(); - fragment.osInternalStorage->gmm = gfxAllocation->gmm; + fragment.osInternalStorage->gmm = gfxAllocation->getDefaultGmm(); fragment.residency = &wddmMemory->getResidencyData(); hostPtrManager->storeFragment(fragment); } @@ -312,12 +312,13 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation this->getDefaultCommandStreamReceiver(0) && this->getDefaultCommandStreamReceiver(0)->getTagAddress() && gfxAllocation->getTaskCount(defaultEngineIndex) > *this->getDefaultCommandStreamReceiver(0)->getTagAddress()); - if (input->gmm) { - if (input->gmm->isRenderCompressed && wddm->getPageTableManager()) { - auto status = wddm->updateAuxTable(input->getGpuAddress(), input->gmm, false); + auto gmm = input->getDefaultGmm(); + if (gmm) { + if (gmm->isRenderCompressed && wddm->getPageTableManager()) { + auto status = wddm->updateAuxTable(input->getGpuAddress(), gmm, false); DEBUG_BREAK_IF(!status); } - delete input->gmm; + delete gmm; } if (input->peekSharedHandle() == false && @@ -473,7 +474,7 @@ uint64_t WddmMemoryManager::getInternalHeapBaseAddress() { } bool WddmMemoryManager::mapAuxGpuVA(GraphicsAllocation *graphicsAllocation) { - return wddm->updateAuxTable(graphicsAllocation->getGpuAddress(), graphicsAllocation->gmm, true); + return wddm->updateAuxTable(graphicsAllocation->getGpuAddress(), graphicsAllocation->getDefaultGmm(), true); } AlignedMallocRestrictions *WddmMemoryManager::getAlignedMallocRestrictions() { @@ -481,10 +482,10 @@ AlignedMallocRestrictions *WddmMemoryManager::getAlignedMallocRestrictions() { } bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation) { - auto wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->gmm, allocation->getHandleToModify(0u)); + auto wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->getDefaultGmm(), allocation->getHandleToModify(0u)); if (wddmSuccess == STATUS_GRAPHICS_NO_VIDEO_MEMORY && deferredDeleter) { deferredDeleter->drain(true); - wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->gmm, allocation->getHandleToModify(0u)); + wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->getDefaultGmm(), allocation->getHandleToModify(0u)); } if (wddmSuccess == STATUS_SUCCESS) { diff --git a/runtime/sharings/d3d/d3d_surface.cpp b/runtime/sharings/d3d/d3d_surface.cpp index cf3be00516..4d63fb1f99 100644 --- a/runtime/sharings/d3d/d3d_surface.cpp +++ b/runtime/sharings/d3d/d3d_surface.cpp @@ -81,7 +81,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo isSharedResource = true; alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle((osHandle)((UINT_PTR)surfaceInfo->shared_handle), false); - updateImgInfo(alloc->gmm, imgInfo, imgDesc, oclPlane, 0u); + updateImgInfo(alloc->getDefaultGmm(), imgInfo, imgDesc, oclPlane, 0u); } else { lockable = !(surfaceDesc.Usage & D3DResourceFlags::USAGE_RENDERTARGET) || oclPlane != OCLPlane::NO_PLANE; if (!lockable) { @@ -126,7 +126,7 @@ void D3DSurface::synchronizeObject(UpdateData &updateData) { auto pitch = static_cast(lockedRect.Pitch); auto height = static_cast(image->getImageDesc().image_height); - image->getGraphicsAllocation()->gmm->resourceCopyBlt(sys, gpu, pitch, height, 1u, oclPlane); + image->getGraphicsAllocation()->getDefaultGmm()->resourceCopyBlt(sys, gpu, pitch, height, 1u, oclPlane); context->getMemoryManager()->unlockResource(updateData.memObject->getGraphicsAllocation()); @@ -161,7 +161,7 @@ void D3DSurface::releaseResource(MemObj *memObject) { auto pitch = static_cast(lockedRect.Pitch); auto height = static_cast(image->getImageDesc().image_height); - image->getGraphicsAllocation()->gmm->resourceCopyBlt(sys, gpu, pitch, height, 0u, oclPlane); + image->getGraphicsAllocation()->getDefaultGmm()->resourceCopyBlt(sys, gpu, pitch, height, 0u, oclPlane); context->getMemoryManager()->unlockResource(memObject->getGraphicsAllocation()); diff --git a/runtime/sharings/d3d/d3d_texture.cpp b/runtime/sharings/d3d/d3d_texture.cpp index 0595cd70a3..27d92119d5 100644 --- a/runtime/sharings/d3d/d3d_texture.cpp +++ b/runtime/sharings/d3d/d3d_texture.cpp @@ -72,18 +72,18 @@ Image *D3DTexture::create2d(Context *context, D3DTexture2d *d3dTexture, cl_ } DEBUG_BREAK_IF(!alloc); - updateImgInfo(alloc->gmm, imgInfo, imgDesc, oclPlane, arrayIndex); + updateImgInfo(alloc->getDefaultGmm(), imgInfo, imgDesc, oclPlane, arrayIndex); auto d3dTextureObj = new D3DTexture(context, d3dTexture, subresource, textureStaging, sharedResource); if ((textureDesc.Format == DXGI_FORMAT_NV12) || (textureDesc.Format == DXGI_FORMAT_P010) || (textureDesc.Format == DXGI_FORMAT_P016)) { imgInfo.surfaceFormat = findYuvSurfaceFormatInfo(textureDesc.Format, oclPlane, flags); } else { - imgInfo.surfaceFormat = findSurfaceFormatInfo(alloc->gmm->gmmResourceInfo->getResourceFormat(), flags); + imgInfo.surfaceFormat = findSurfaceFormatInfo(alloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(), flags); } - if (alloc->gmm->unifiedAuxTranslationCapable()) { - alloc->gmm->isRenderCompressed = context->getMemoryManager()->mapAuxGpuVA(alloc); + if (alloc->getDefaultGmm()->unifiedAuxTranslationCapable()) { + alloc->getDefaultGmm()->isRenderCompressed = context->getMemoryManager()->mapAuxGpuVA(alloc); } return Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, alloc, nullptr, flags, imgInfo, __GMM_NO_CUBE_MAP, 0, 0); @@ -129,16 +129,16 @@ Image *D3DTexture::create3d(Context *context, D3DTexture3d *d3dTexture, cl_ } DEBUG_BREAK_IF(!alloc); - updateImgInfo(alloc->gmm, imgInfo, imgDesc, OCLPlane::NO_PLANE, 0u); + updateImgInfo(alloc->getDefaultGmm(), imgInfo, imgDesc, OCLPlane::NO_PLANE, 0u); auto d3dTextureObj = new D3DTexture(context, d3dTexture, subresource, textureStaging, sharedResource); - imgInfo.qPitch = alloc->gmm->queryQPitch(GMM_RESOURCE_TYPE::RESOURCE_3D); + imgInfo.qPitch = alloc->getDefaultGmm()->queryQPitch(GMM_RESOURCE_TYPE::RESOURCE_3D); - imgInfo.surfaceFormat = findSurfaceFormatInfo(alloc->gmm->gmmResourceInfo->getResourceFormat(), flags); + imgInfo.surfaceFormat = findSurfaceFormatInfo(alloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(), flags); - if (alloc->gmm->unifiedAuxTranslationCapable()) { - alloc->gmm->isRenderCompressed = context->getMemoryManager()->mapAuxGpuVA(alloc); + if (alloc->getDefaultGmm()->unifiedAuxTranslationCapable()) { + alloc->getDefaultGmm()->isRenderCompressed = context->getMemoryManager()->mapAuxGpuVA(alloc); } return Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, alloc, nullptr, flags, imgInfo, __GMM_NO_CUBE_MAP, 0, 0); diff --git a/runtime/sharings/gl/gl_buffer.cpp b/runtime/sharings/gl/gl_buffer.cpp index b6865cf615..99c161d96e 100644 --- a/runtime/sharings/gl/gl_buffer.cpp +++ b/runtime/sharings/gl/gl_buffer.cpp @@ -141,8 +141,8 @@ GraphicsAllocation *GlBuffer::createGraphicsAllocation(Context *context, unsigne if (!reusedAllocation) { sharingFunctions->graphicsAllocationsForGlBufferReuse.push_back(std::make_pair(bufferId, graphicsAllocation)); if (bufferInfo.pGmmResInfo) { - DEBUG_BREAK_IF(graphicsAllocation->gmm != nullptr); - graphicsAllocation->gmm = new Gmm(bufferInfo.pGmmResInfo); + DEBUG_BREAK_IF(graphicsAllocation->getDefaultGmm() != nullptr); + graphicsAllocation->setDefaultGmm(new Gmm(bufferInfo.pGmmResInfo)); } } diff --git a/runtime/sharings/gl/gl_texture.cpp b/runtime/sharings/gl/gl_texture.cpp index 644028930d..808876701f 100644 --- a/runtime/sharings/gl/gl_texture.cpp +++ b/runtime/sharings/gl/gl_texture.cpp @@ -51,11 +51,11 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl return nullptr; } if (texInfo.pGmmResInfo) { - DEBUG_BREAK_IF(alloc->gmm != nullptr); - alloc->gmm = new Gmm(texInfo.pGmmResInfo); + DEBUG_BREAK_IF(alloc->getDefaultGmm() != nullptr); + alloc->setDefaultGmm(new Gmm(texInfo.pGmmResInfo)); } - auto gmm = alloc->gmm; + auto gmm = alloc->getDefaultGmm(); imgDesc.image_type = getClMemObjectType(target); if (target == GL_TEXTURE_BUFFER) { @@ -114,11 +114,11 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl if (texInfo.globalShareHandleMCS) { mcsAlloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandleMCS, false); if (texInfo.pGmmResInfoMCS) { - DEBUG_BREAK_IF(mcsAlloc->gmm != nullptr); - mcsAlloc->gmm = new Gmm(texInfo.pGmmResInfoMCS); + DEBUG_BREAK_IF(mcsAlloc->getDefaultGmm() != nullptr); + mcsAlloc->setDefaultGmm(new Gmm(texInfo.pGmmResInfoMCS)); } - mcsSurfaceInfo.pitch = getValidParam(static_cast(mcsAlloc->gmm->gmmResourceInfo->getRenderPitch() / 128)); - mcsSurfaceInfo.qPitch = mcsAlloc->gmm->gmmResourceInfo->getQPitch(); + mcsSurfaceInfo.pitch = getValidParam(static_cast(mcsAlloc->getDefaultGmm()->gmmResourceInfo->getRenderPitch() / 128)); + mcsSurfaceInfo.qPitch = mcsAlloc->getDefaultGmm()->gmmResourceInfo->getQPitch(); } mcsSurfaceInfo.multisampleCount = GmmHelper::getRenderMultisamplesCount(static_cast(imgDesc.num_samples)); @@ -133,8 +133,8 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl auto glTexture = new GlTexture(sharingFunctions, getClGlObjectType(target), texture, texInfo, target, std::max(miplevel, 0)); - if (alloc->gmm->unifiedAuxTranslationCapable()) { - alloc->gmm->isRenderCompressed = context->getMemoryManager()->mapAuxGpuVA(alloc); + if (alloc->getDefaultGmm()->unifiedAuxTranslationCapable()) { + alloc->getDefaultGmm()->isRenderCompressed = context->getMemoryManager()->mapAuxGpuVA(alloc); } return Image::createSharedImage(context, glTexture, mcsSurfaceInfo, alloc, mcsAlloc, flags, imgInfo, cubeFaceIndex, std::max(miplevel, 0), imgDesc.num_mip_levels); diff --git a/runtime/sharings/va/va_surface.cpp b/runtime/sharings/va/va_surface.cpp index 43c0c834c6..2ecb99cd61 100644 --- a/runtime/sharings/va/va_surface.cpp +++ b/runtime/sharings/va/va_surface.cpp @@ -61,8 +61,8 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, false); Gmm *gmm = new Gmm(imgInfo); - DEBUG_BREAK_IF(alloc->gmm != nullptr); - alloc->gmm = gmm; + DEBUG_BREAK_IF(alloc->getDefaultGmm()); + alloc->setDefaultGmm(gmm); imgDesc.image_row_pitch = imgInfo.rowPitch; imgDesc.image_slice_pitch = 0u; diff --git a/unit_tests/aub_mem_dump/aub_alloc_dump_tests.cpp b/unit_tests/aub_mem_dump/aub_alloc_dump_tests.cpp index 37b94f0307..a8a0351030 100644 --- a/unit_tests/aub_mem_dump/aub_alloc_dump_tests.cpp +++ b/unit_tests/aub_mem_dump/aub_alloc_dump_tests.cpp @@ -242,7 +242,7 @@ HWTEST_F(AubAllocDumpTests, givenWritableImageWhenDumpAllocationIsCalledAndAubDu EXPECT_EQ(0u, cmd.Xmin); EXPECT_EQ(0u, cmd.Ymin); - auto gmm = gfxAllocation->gmm; + auto gmm = gfxAllocation->getDefaultGmm(); EXPECT_EQ((8 * gmm->gmmResourceInfo->getRenderPitch()) / gmm->gmmResourceInfo->getBitsPerPixel(), cmd.BufferPitch); EXPECT_EQ(gmm->gmmResourceInfo->getBitsPerPixel(), cmd.BitsPerPixel); EXPECT_EQ(static_cast(gmm->gmmResourceInfo->getResourceFormatSurfaceState()), cmd.Format); @@ -285,12 +285,13 @@ HWTEST_F(AubAllocDumpTests, givenWritableImageWhenDumpAllocationIsCalledAndAubDu using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT; EXPECT_EQ(gfxAllocation->getGpuAddress(), cmd.getSurfaceAddress()); - EXPECT_EQ(static_cast(gfxAllocation->gmm->gmmResourceInfo->getBaseWidth()), cmd.surfaceWidth); - EXPECT_EQ(static_cast(gfxAllocation->gmm->gmmResourceInfo->getBaseHeight()), cmd.surfaceHeight); - EXPECT_EQ(static_cast(gfxAllocation->gmm->gmmResourceInfo->getRenderPitch()), cmd.surfacePitch); - EXPECT_EQ(static_cast(gfxAllocation->gmm->gmmResourceInfo->getResourceFormatSurfaceState()), cmd.surfaceFormat); + auto gmm = gfxAllocation->getDefaultGmm(); + EXPECT_EQ(static_cast(gmm->gmmResourceInfo->getBaseWidth()), cmd.surfaceWidth); + EXPECT_EQ(static_cast(gmm->gmmResourceInfo->getBaseHeight()), cmd.surfaceHeight); + EXPECT_EQ(static_cast(gmm->gmmResourceInfo->getRenderPitch()), cmd.surfacePitch); + EXPECT_EQ(static_cast(gmm->gmmResourceInfo->getResourceFormatSurfaceState()), cmd.surfaceFormat); EXPECT_EQ(AubMemDump::CmdServicesMemTraceDumpCompress::DumpTypeValues::Tre, cmd.dumpType); - EXPECT_EQ(gfxAllocation->gmm->gmmResourceInfo->getTileModeSurfaceState(), cmd.surfaceTilingType); + EXPECT_EQ(gmm->gmmResourceInfo->getTileModeSurfaceState(), cmd.surfaceTilingType); EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_2D, cmd.surfaceType); EXPECT_EQ(AubMemDump::CmdServicesMemTraceDumpCompress::AlgorithmValues::Uncompressed, cmd.algorithm); @@ -308,7 +309,7 @@ HWTEST_F(AubAllocDumpTests, givenCompressedImageWritableWhenDumpAllocationIsCall ASSERT_NE(nullptr, image); auto gfxAllocation = image->getGraphicsAllocation(); - gfxAllocation->gmm->isRenderCompressed = true; + gfxAllocation->getDefaultGmm()->isRenderCompressed = true; std::unique_ptr mockAubFileStream(new AubFileStreamMock()); auto handle = static_cast(reinterpret_cast(this)); @@ -326,7 +327,7 @@ HWTEST_F(AubAllocDumpTests, givenMultisampleImageWritableWhenDumpAllocationIsCal ASSERT_NE(nullptr, image); auto gfxAllocation = image->getGraphicsAllocation(); - auto mockGmmResourceInfo = reinterpret_cast(gfxAllocation->gmm->gmmResourceInfo.get()); + auto mockGmmResourceInfo = reinterpret_cast(gfxAllocation->getDefaultGmm()->gmmResourceInfo.get()); mockGmmResourceInfo->mockResourceCreateParams.MSAA.NumSamples = 2; std::unique_ptr mockAubFileStream(new AubFileStreamMock()); diff --git a/unit_tests/command_queue/read_write_buffer_cpu_copy.cpp b/unit_tests/command_queue/read_write_buffer_cpu_copy.cpp index 532853d155..1c13a38860 100644 --- a/unit_tests/command_queue/read_write_buffer_cpu_copy.cpp +++ b/unit_tests/command_queue/read_write_buffer_cpu_copy.cpp @@ -19,7 +19,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenRenderCompressedGmmWhenAskingForCpuOpe std::unique_ptr buffer(Buffer::create(context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); auto gmm = new Gmm(nullptr, 1, false); gmm->isRenderCompressed = false; - buffer->getGraphicsAllocation()->gmm = gmm; + buffer->getGraphicsAllocation()->setDefaultGmm(gmm); auto alignedPtr = alignedMalloc(2, MemoryConstants::cacheLineSize); auto unalignedPtr = ptrOffset(alignedPtr, 1); diff --git a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp index c1c4b51079..f0d8bb03ad 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -688,7 +688,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe gfxAllocation->setAubWritable(true); auto gmm = new Gmm(nullptr, 1, false); - gfxAllocation->gmm = gmm; + gfxAllocation->setDefaultGmm(gmm); for (bool compressed : {false, true}) { gmm->isRenderCompressed = compressed; @@ -696,7 +696,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe aubCsr->writeMemory(*gfxAllocation); if (compressed) { - EXPECT_EQ(gfxAllocation->gmm->gmmResourceInfo->getSizeAllocation(), ppgttMock->receivedSize); + EXPECT_EQ(gfxAllocation->getDefaultGmm()->gmmResourceInfo->getSizeAllocation(), ppgttMock->receivedSize); } else { EXPECT_EQ(gfxAllocation->getUnderlyingBufferSize(), ppgttMock->receivedSize); } diff --git a/unit_tests/d3d_sharing/d3d9_tests.cpp b/unit_tests/d3d_sharing/d3d9_tests.cpp index 722f8dc932..e70742314b 100644 --- a/unit_tests/d3d_sharing/d3d9_tests.cpp +++ b/unit_tests/d3d_sharing/d3d9_tests.cpp @@ -43,14 +43,14 @@ class D3D9Tests : public PlatformFixture, public ::testing::Test { MockMM(const ExecutionEnvironment &executionEnvironment) : OsAgnosticMemoryManager(false, false, const_cast(executionEnvironment)){}; GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override { auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(handle, requireSpecificBitness); - alloc->gmm = forceGmm; + alloc->setDefaultGmm(forceGmm); gmmOwnershipPassed = true; return alloc; } GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData) override { auto gmm = std::make_unique(*allocationData.imgInfo); auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(1, false); - alloc->gmm = forceGmm; + alloc->setDefaultGmm(forceGmm); gmmOwnershipPassed = true; return alloc; } diff --git a/unit_tests/d3d_sharing/d3d_tests.cpp b/unit_tests/d3d_sharing/d3d_tests.cpp index bcf53b8818..4ccba1785a 100644 --- a/unit_tests/d3d_sharing/d3d_tests.cpp +++ b/unit_tests/d3d_sharing/d3d_tests.cpp @@ -61,13 +61,13 @@ class D3DTests : public PlatformFixture, public ::testing::Test { using OsAgnosticMemoryManager::OsAgnosticMemoryManager; GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override { auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(handle, requireSpecificBitness); - alloc->gmm = forceGmm; + alloc->setDefaultGmm(forceGmm); gmmOwnershipPassed = true; return alloc; } GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override { auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle((osHandle)((UINT_PTR)handle), false); - alloc->gmm = forceGmm; + alloc->setDefaultGmm(forceGmm); gmmOwnershipPassed = true; return alloc; } diff --git a/unit_tests/gen10/image_tests_gen10.cpp b/unit_tests/gen10/image_tests_gen10.cpp index d7f37284ad..e24284c665 100644 --- a/unit_tests/gen10/image_tests_gen10.cpp +++ b/unit_tests/gen10/image_tests_gen10.cpp @@ -38,7 +38,7 @@ GEN10TEST_F(gen10ImageTests, givenImageForGen10WhenClearColorParametersAreSetThe EXPECT_EQ(0, memcmp(&surfaceStateBefore, &surfaceStateAfter, sizeof(RENDER_SURFACE_STATE))); - imageHw->setClearColorParams(&surfaceStateAfter, imageHw->getGraphicsAllocation()->gmm); + imageHw->setClearColorParams(&surfaceStateAfter, imageHw->getGraphicsAllocation()->getDefaultGmm()); EXPECT_EQ(0, memcmp(&surfaceStateBefore, &surfaceStateAfter, sizeof(RENDER_SURFACE_STATE))); } diff --git a/unit_tests/helpers/hw_helper_tests.cpp b/unit_tests/helpers/hw_helper_tests.cpp index 4fd06f1aed..731e07bf65 100644 --- a/unit_tests/helpers/hw_helper_tests.cpp +++ b/unit_tests/helpers/hw_helper_tests.cpp @@ -349,8 +349,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU size_t allocSize = size; length.Length = static_cast(allocSize - 1); GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false); - allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false); - ASSERT_NE(nullptr, allocation.gmm); + allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, 0, type, true); EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth()); @@ -362,7 +361,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, state->getCoherencyType()); EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, state->getAuxiliarySurfaceMode()); - delete allocation.gmm; + delete allocation.getDefaultGmm(); alignedFree(stateBuffer); } @@ -387,15 +386,14 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false); - allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false); - ASSERT_NE(nullptr, allocation.gmm); - allocation.gmm->isRenderCompressed = true; + allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.getDefaultGmm()->isRenderCompressed = true; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, 0, type, false); EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, state->getCoherencyType()); EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E, state->getAuxiliarySurfaceMode()); - delete allocation.gmm; + delete allocation.getDefaultGmm(); alignedFree(stateBuffer); } @@ -420,15 +418,14 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionEnabledAn uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false); - allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false); - ASSERT_NE(nullptr, allocation.gmm); - allocation.gmm->isRenderCompressed = true; + allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.getDefaultGmm()->isRenderCompressed = true; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, 0, type, false); EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, state->getCoherencyType()); EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, state->getAuxiliarySurfaceMode()); - delete allocation.gmm; + delete allocation.getDefaultGmm(); alignedFree(stateBuffer); } @@ -453,14 +450,13 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionDisabledA uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false); - allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false); - ASSERT_NE(nullptr, allocation.gmm); + allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, 0, type, false); EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, state->getCoherencyType()); EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, state->getAuxiliarySurfaceMode()); - delete allocation.gmm; + delete allocation.getDefaultGmm(); alignedFree(stateBuffer); } @@ -485,15 +481,14 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false); - allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false); - ASSERT_NE(nullptr, allocation.gmm); - allocation.gmm->isRenderCompressed = true; + allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.getDefaultGmm()->isRenderCompressed = true; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, 0, type, true); EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, state->getCoherencyType()); EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, state->getAuxiliarySurfaceMode()); - delete allocation.gmm; + delete allocation.getDefaultGmm(); alignedFree(stateBuffer); } diff --git a/unit_tests/mem_obj/buffer_set_arg_tests.cpp b/unit_tests/mem_obj/buffer_set_arg_tests.cpp index 5b151cec84..381e38016e 100644 --- a/unit_tests/mem_obj/buffer_set_arg_tests.cpp +++ b/unit_tests/mem_obj/buffer_set_arg_tests.cpp @@ -160,8 +160,8 @@ HWTEST_F(BufferSetArgTest, givenNonPureStatefulArgWhenRenderCompressedBufferIsSe auto surfaceState = reinterpret_cast(ptrOffset(pKernel->getSurfaceStateHeap(), pKernelInfo->kernelArgInfo[0].offsetHeap)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - buffer->getGraphicsAllocation()->gmm = new Gmm(buffer->getGraphicsAllocation()->getUnderlyingBuffer(), buffer->getSize(), false); - buffer->getGraphicsAllocation()->gmm->isRenderCompressed = true; + buffer->getGraphicsAllocation()->setDefaultGmm(new Gmm(buffer->getGraphicsAllocation()->getUnderlyingBuffer(), buffer->getSize(), false)); + buffer->getGraphicsAllocation()->getDefaultGmm()->isRenderCompressed = true; pKernelInfo->requiresSshForBuffers = true; cl_mem clMem = buffer; diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index ad1b326729..321e41f8dd 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -1374,7 +1374,7 @@ HWTEST_F(BufferSetSurfaceTests, givenRenderCompressedGmmResourceWhenSurfaceState std::unique_ptr buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); auto gmm = new Gmm(nullptr, 1, false); - buffer->getGraphicsAllocation()->gmm = gmm; + buffer->getGraphicsAllocation()->setDefaultGmm(gmm); gmm->isRenderCompressed = true; buffer->setArgStateful(&surfaceState, false, false); @@ -1398,7 +1398,7 @@ HWTEST_F(BufferSetSurfaceTests, givenNonRenderCompressedGmmResourceWhenSurfaceSt std::unique_ptr buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); auto gmm = new Gmm(nullptr, 1, false); - buffer->getGraphicsAllocation()->gmm = gmm; + buffer->getGraphicsAllocation()->setDefaultGmm(gmm); gmm->isRenderCompressed = false; buffer->setArgStateful(&surfaceState, false, false); diff --git a/unit_tests/mem_obj/image_set_arg_tests.cpp b/unit_tests/mem_obj/image_set_arg_tests.cpp index 7ee05c94e6..fe07f03484 100644 --- a/unit_tests/mem_obj/image_set_arg_tests.cpp +++ b/unit_tests/mem_obj/image_set_arg_tests.cpp @@ -380,7 +380,7 @@ HWTEST_F(ImageSetArgTest, clSetKernelArgImage1Darray) { EXPECT_EQ(image1Darray->getImageDesc().image_array_size, surfaceState->getRenderTargetViewExtent()); EXPECT_EQ(image1Darray->getImageDesc().image_row_pitch, surfaceState->getSurfacePitch()); EXPECT_EQ(0u, surfaceState->getSurfaceQpitch() % 4); - EXPECT_EQ(image1Darray->getGraphicsAllocation()->gmm->queryQPitch(GMM_RESOURCE_TYPE::RESOURCE_1D), surfaceState->getSurfaceQpitch()); + EXPECT_EQ(image1Darray->getGraphicsAllocation()->getDefaultGmm()->queryQPitch(GMM_RESOURCE_TYPE::RESOURCE_1D), surfaceState->getSurfaceQpitch()); EXPECT_EQ(image1Darray->getSurfaceFormatInfo().GenxSurfaceFormat, (GFX3DSTATE_SURFACEFORMAT)surfaceState->getSurfaceFormat()); EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_1D, surfaceState->getSurfaceType()); @@ -404,7 +404,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithoutUnifiedAuxC typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->gmm = new Gmm(nullptr, 1, false); + mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -413,7 +413,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithoutUnifiedAuxC image->setMcsAllocation(mcsAlloc); cl_mem memObj = image; - EXPECT_FALSE(mcsAlloc->gmm->unifiedAuxTranslationCapable()); + EXPECT_FALSE(mcsAlloc->getDefaultGmm()->unifiedAuxTranslationCapable()); retVal = clSetKernelArg( pKernel, @@ -503,12 +503,12 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationAndRenderCompressionWhenSetArgOnMult typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->gmm = new Gmm(nullptr, 1, false); + mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; auto image = std::unique_ptr(Image2dHelper<>::create(context, &imgDesc)); - image->getGraphicsAllocation()->gmm->isRenderCompressed = true; + image->getGraphicsAllocation()->getDefaultGmm()->isRenderCompressed = true; image->setMcsSurfaceInfo(msi); image->setMcsAllocation(mcsAlloc); cl_mem memObj = image.get(); @@ -538,7 +538,7 @@ HWTEST_F(ImageSetArgTest, givenDepthFormatAndRenderCompressionWhenSetArgOnMultis imgDesc.num_samples = 8; auto image = std::unique_ptr(Image2dHelper<>::create(context, &imgDesc, &imgFormat)); - image->getGraphicsAllocation()->gmm->isRenderCompressed = true; + image->getGraphicsAllocation()->getDefaultGmm()->isRenderCompressed = true; image->setMcsSurfaceInfo(msi); cl_mem memObj = image.get(); @@ -564,7 +564,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->gmm = new Gmm(nullptr, 1, false); + mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -573,9 +573,9 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa image->setMcsAllocation(mcsAlloc); cl_mem memObj = image.get(); - auto mockMcsGmmResInfo = reinterpret_cast *>(mcsAlloc->gmm->gmmResourceInfo.get()); + auto mockMcsGmmResInfo = reinterpret_cast *>(mcsAlloc->getDefaultGmm()->gmmResourceInfo.get()); mockMcsGmmResInfo->setUnifiedAuxTranslationCapable(); - EXPECT_TRUE(mcsAlloc->gmm->unifiedAuxTranslationCapable()); + EXPECT_TRUE(mcsAlloc->getDefaultGmm()->unifiedAuxTranslationCapable()); retVal = clSetKernelArg(pKernel, 0, sizeof(memObj), &memObj); ASSERT_EQ(CL_SUCCESS, retVal); @@ -594,7 +594,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->gmm = new Gmm(nullptr, 1, false); + mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -603,10 +603,10 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa image->setMcsAllocation(mcsAlloc); cl_mem memObj = image.get(); - auto mockMcsGmmResInfo = reinterpret_cast *>(mcsAlloc->gmm->gmmResourceInfo.get()); + auto mockMcsGmmResInfo = reinterpret_cast *>(mcsAlloc->getDefaultGmm()->gmmResourceInfo.get()); mockMcsGmmResInfo->setUnifiedAuxTranslationCapable(); mockMcsGmmResInfo->setMultisampleControlSurface(); - EXPECT_TRUE(mcsAlloc->gmm->unifiedAuxTranslationCapable()); + EXPECT_TRUE(mcsAlloc->getDefaultGmm()->unifiedAuxTranslationCapable()); retVal = clSetKernelArg(pKernel, 0, sizeof(memObj), &memObj); ASSERT_EQ(CL_SUCCESS, retVal); @@ -623,7 +623,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->gmm = new Gmm(nullptr, 1, false); + mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -632,7 +632,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa image->setMcsAllocation(mcsAlloc); cl_mem memObj = image.get(); - auto mockMcsGmmResInfo = reinterpret_cast *>(mcsAlloc->gmm->gmmResourceInfo.get()); + auto mockMcsGmmResInfo = reinterpret_cast *>(mcsAlloc->getDefaultGmm()->gmmResourceInfo.get()); mockMcsGmmResInfo->setUnifiedAuxTranslationCapable(); mockMcsGmmResInfo->setMultisampleControlSurface(); @@ -641,7 +641,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa mockMcsGmmResInfo->setUnifiedAuxPitchTiles(pitchValue); mockMcsGmmResInfo->setAuxQPitch(qPitchValue); - EXPECT_TRUE(mcsAlloc->gmm->unifiedAuxTranslationCapable()); + EXPECT_TRUE(mcsAlloc->getDefaultGmm()->unifiedAuxTranslationCapable()); retVal = clSetKernelArg(pKernel, 0, sizeof(memObj), &memObj); ASSERT_EQ(CL_SUCCESS, retVal); @@ -766,7 +766,7 @@ HWTEST_F(ImageSetArgTest, givenRenderCompressedResourceWhenSettingImgArgThenSetC auto surfaceState = FamilyType::cmdInitRenderSurfaceState; - srcImage->getGraphicsAllocation()->gmm->isRenderCompressed = true; + srcImage->getGraphicsAllocation()->getDefaultGmm()->isRenderCompressed = true; srcImage->setImageArg(&surfaceState, false, 0); @@ -780,7 +780,7 @@ HWTEST_F(ImageSetArgTest, givenNonRenderCompressedResourceWhenSettingImgArgThenD typedef typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE AUXILIARY_SURFACE_MODE; auto surfaceState = FamilyType::cmdInitRenderSurfaceState; - auto gmm = srcImage->getGraphicsAllocation()->gmm; + auto gmm = srcImage->getGraphicsAllocation()->getDefaultGmm(); auto mockGmmResInfo = reinterpret_cast *>(gmm->gmmResourceInfo.get()); gmm->isRenderCompressed = false; diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index 438bba52f5..2473cfaab0 100644 --- a/unit_tests/mem_obj/image_tests.cpp +++ b/unit_tests/mem_obj/image_tests.cpp @@ -1438,7 +1438,7 @@ HWTEST_F(HwImageTest, givenImageHwWhenSettingCCSParamsThenSetClearColorParamsIsC auto surfaceState = FamilyType::cmdInitRenderSurfaceState; EXPECT_FALSE(mockImage->setClearColorParamsCalled); - mockImage->setAuxParamsForCCS(&surfaceState, graphicsAllocation->gmm); + mockImage->setAuxParamsForCCS(&surfaceState, graphicsAllocation->getDefaultGmm()); EXPECT_TRUE(mockImage->setClearColorParamsCalled); } @@ -1463,13 +1463,13 @@ HWTEST_F(HwImageTest, givenImageHwWithUnifiedSurfaceAndMcsWhenSettingParamsForMu McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context.getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->gmm = new Gmm(nullptr, 1, false); + mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); - auto mockMcsGmmResInfo = reinterpret_cast<::testing::NiceMock *>(mcsAlloc->gmm->gmmResourceInfo.get()); + auto mockMcsGmmResInfo = reinterpret_cast<::testing::NiceMock *>(mcsAlloc->getDefaultGmm()->gmmResourceInfo.get()); mockMcsGmmResInfo->setUnifiedAuxTranslationCapable(); mockMcsGmmResInfo->setMultisampleControlSurface(); - EXPECT_TRUE(mcsAlloc->gmm->unifiedAuxTranslationCapable()); - EXPECT_TRUE(mcsAlloc->gmm->hasMultisampleControlSurface()); + EXPECT_TRUE(mcsAlloc->getDefaultGmm()->unifiedAuxTranslationCapable()); + EXPECT_TRUE(mcsAlloc->getDefaultGmm()->hasMultisampleControlSurface()); mockImage->setMcsSurfaceInfo(msi); mockImage->setMcsAllocation(mcsAlloc); diff --git a/unit_tests/mem_obj/image_tiled_tests.cpp b/unit_tests/mem_obj/image_tiled_tests.cpp index a8e9e84460..10c6b1d55f 100644 --- a/unit_tests/mem_obj/image_tiled_tests.cpp +++ b/unit_tests/mem_obj/image_tiled_tests.cpp @@ -98,7 +98,7 @@ TEST_P(CreateTiledImageTest, isTiledImageIsSetForSharedImages) { auto gmm = MockGmm::queryImgParams(info); - alloc->gmm = gmm.release(); + alloc->setDefaultGmm(gmm.release()); auto image = Image::createSharedImage( &context, @@ -136,7 +136,7 @@ TEST_P(CreateNonTiledImageTest, isTiledImageIsNotSetForNonTiledSharedImage) { auto gmm = MockGmm::queryImgParams(info); - alloc->gmm = gmm.release(); + alloc->setDefaultGmm(gmm.release()); auto image = Image::createSharedImage( &context, diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index 893e81ff54..37858e5b48 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -292,14 +292,14 @@ TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) { context.setMemoryManager(&memoryManager); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->gmm = new Gmm(nullptr, 1, false); + allocation->setDefaultGmm(new Gmm(nullptr, 1, false)); MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); - allocation->gmm->isRenderCompressed = false; + allocation->getDefaultGmm()->isRenderCompressed = false; EXPECT_TRUE(memObj.mappingOnCpuAllowed()); - allocation->gmm->isRenderCompressed = true; + allocation->getDefaultGmm()->isRenderCompressed = true; EXPECT_FALSE(memObj.mappingOnCpuAllowed()); } @@ -326,7 +326,7 @@ TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) { context.setMemoryManager(&memoryManager); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->gmm = new Gmm(nullptr, 1, false); + allocation->setDefaultGmm(new Gmm(nullptr, 1, false)); MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); diff --git a/unit_tests/mem_obj/nv12_image_tests.cpp b/unit_tests/mem_obj/nv12_image_tests.cpp index 36353edfee..3956be0e83 100644 --- a/unit_tests/mem_obj/nv12_image_tests.cpp +++ b/unit_tests/mem_obj/nv12_image_tests.cpp @@ -29,7 +29,7 @@ class Nv12ImageTest : public testing::Test { GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; SurfaceOffsets requestedOffsets = {0}; - auto mockResInfo = reinterpret_cast<::testing::NiceMock *>(image->getGraphicsAllocation()->gmm->gmmResourceInfo.get()); + auto mockResInfo = reinterpret_cast<::testing::NiceMock *>(image->getGraphicsAllocation()->getDefaultGmm()->gmmResourceInfo.get()); mockResInfo->getOffset(reqOffsetInfo); if (image->getImageDesc().mem_object) { diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 458eb171d7..743d513422 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -563,8 +563,8 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor auto imageAllocation = memoryManager.allocateGraphicsMemoryForImage(allocationData); ASSERT_NE(nullptr, imageAllocation); - EXPECT_TRUE(imageAllocation->gmm->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE); - EXPECT_TRUE(imageAllocation->gmm->useSystemMemoryPool); + EXPECT_TRUE(imageAllocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE); + EXPECT_TRUE(imageAllocation->getDefaultGmm()->useSystemMemoryPool); memoryManager.freeGraphicsMemory(imageAllocation); } @@ -667,7 +667,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerAndUnifiedAuxCapableAlloc auto gmm = new Gmm(nullptr, 123, false); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->gmm = gmm; + allocation->setDefaultGmm(gmm); auto mockGmmRes = reinterpret_cast(gmm->gmmResourceInfo.get()); mockGmmRes->setUnifiedAuxTranslationCapable(); @@ -1685,7 +1685,7 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati auto gmm = std::make_unique(nullptr, 0, false); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = true; - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); if (platformDevices[0]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) { return; } @@ -1697,7 +1697,7 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati auto gmm = std::make_unique(nullptr, 0, false); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = false; - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); if (platformDevices[0]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) { return; } diff --git a/unit_tests/mocks/mock_memory_manager.cpp b/unit_tests/mocks/mock_memory_manager.cpp index 76b96029bd..ecc0b02d7e 100644 --- a/unit_tests/mocks/mock_memory_manager.cpp +++ b/unit_tests/mocks/mock_memory_manager.cpp @@ -53,8 +53,8 @@ GraphicsAllocation *MockMemoryManager::allocateGraphicsMemory64kb(const Allocati auto allocation = OsAgnosticMemoryManager::allocateGraphicsMemory64kb(allocationData); if (allocation) { - allocation->gmm = new Gmm(allocation->getUnderlyingBuffer(), allocationData.size, false, preferRenderCompressedFlagPassed, true, {}); - allocation->gmm->isRenderCompressed = preferRenderCompressedFlagPassed; + allocation->setDefaultGmm(new Gmm(allocation->getUnderlyingBuffer(), allocationData.size, false, preferRenderCompressedFlagPassed, true, {})); + allocation->getDefaultGmm()->isRenderCompressed = preferRenderCompressedFlagPassed; } return allocation; } diff --git a/unit_tests/mocks/mock_wddm.cpp b/unit_tests/mocks/mock_wddm.cpp index d5edc20a91..e9c67c7bb5 100644 --- a/unit_tests/mocks/mock_wddm.cpp +++ b/unit_tests/mocks/mock_wddm.cpp @@ -52,7 +52,7 @@ bool WddmMock::freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t si } NTSTATUS WddmMock::createAllocation(WddmAllocation *wddmAllocation) { if (wddmAllocation) { - return createAllocation(wddmAllocation->getAlignedCpuPtr(), wddmAllocation->gmm, wddmAllocation->getHandleToModify(0u)); + return createAllocation(wddmAllocation->getAlignedCpuPtr(), wddmAllocation->getDefaultGmm(), wddmAllocation->getHandleToModify(0u)); } return false; } @@ -71,7 +71,7 @@ NTSTATUS WddmMock::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D bool WddmMock::createAllocation64k(WddmAllocation *wddmAllocation) { if (wddmAllocation) { - return createAllocation64k(wddmAllocation->gmm, wddmAllocation->getHandleToModify(0u)); + return createAllocation64k(wddmAllocation->getDefaultGmm(), wddmAllocation->getHandleToModify(0u)); } return false; } diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index 6db1c8c000..126a08aba4 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -1163,7 +1163,7 @@ TEST_F(DrmMemoryManagerTest, GivenMemoryManagerWhenAllocateGraphicsMemoryForImag EXPECT_NE(0u, imageGraphicsAllocation->getGpuAddress()); EXPECT_EQ(nullptr, imageGraphicsAllocation->getUnderlyingBuffer()); - EXPECT_TRUE(imageGraphicsAllocation->gmm->resourceParams.Usage == + EXPECT_TRUE(imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE); DrmAllocation *drmAllocation = static_cast(imageGraphicsAllocation); @@ -1218,7 +1218,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageWithMipCountZero ASSERT_NE(nullptr, dstImage); auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_TRUE(imageGraphicsAllocation->gmm->resourceParams.Usage == + EXPECT_TRUE(imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE); DrmAllocation *drmAllocation = static_cast(imageGraphicsAllocation); @@ -1265,7 +1265,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageWithMipCountNonZ EXPECT_EQ(static_cast(imageDesc.num_mip_levels), dstImage->peekMipCount()); auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_TRUE(imageGraphicsAllocation->gmm->resourceParams.Usage == + EXPECT_TRUE(imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE); DrmAllocation *drmAllocation = static_cast(imageGraphicsAllocation); @@ -1344,7 +1344,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageIsBeingCreatedFr ASSERT_NE(nullptr, dstImage); auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_TRUE(imageGraphicsAllocation->gmm->resourceParams.Usage == + EXPECT_TRUE(imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE); DrmAllocation *drmAllocation = static_cast(imageGraphicsAllocation); @@ -1430,7 +1430,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenNonTiledImgWithMipCountZer ASSERT_NE(nullptr, dstImage); auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_TRUE(imageGraphicsAllocation->gmm->resourceParams.Usage == + EXPECT_TRUE(imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE); EXPECT_EQ(0u, this->mock->createParamsHandle); @@ -1473,7 +1473,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenNonTiledImgWithMipCountNon EXPECT_EQ(static_cast(imageDesc.num_mip_levels), dstImage->peekMipCount()); auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_TRUE(imageGraphicsAllocation->gmm->resourceParams.Usage == + EXPECT_TRUE(imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE); EXPECT_EQ(0u, this->mock->createParamsHandle); @@ -1999,7 +1999,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndUnifiedAuxCapableAllocation auto gmm = new Gmm(nullptr, 123, false); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->gmm = gmm; + allocation->setDefaultGmm(gmm); auto mockGmmRes = static_cast(gmm->gmmResourceInfo.get()); mockGmmRes->setUnifiedAuxTranslationCapable(); diff --git a/unit_tests/os_interface/windows/debug_settings_manager_win_tests.cpp b/unit_tests/os_interface/windows/debug_settings_manager_win_tests.cpp index ea136d9eed..fcc68ffedd 100644 --- a/unit_tests/os_interface/windows/debug_settings_manager_win_tests.cpp +++ b/unit_tests/os_interface/windows/debug_settings_manager_win_tests.cpp @@ -25,8 +25,8 @@ TEST(DebugSettingsManager, GivenDebugSettingsManagerWithLogAllocationsThenLogsCo allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; auto gmm = std::make_unique(nullptr, 0, false); - allocation.gmm = gmm.get(); - allocation.gmm->resourceParams.Flags.Info.NonLocalOnly = 0; + allocation.setDefaultGmm(gmm.get()); + allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; debugManager.logAllocation(&allocation); @@ -61,8 +61,8 @@ TEST(DebugSettingsManager, GivenDebugSettingsManagerWithoutLogAllocationsThenAll allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; auto gmm = std::make_unique(nullptr, 0, false); - allocation.gmm = gmm.get(); - allocation.gmm->resourceParams.Flags.Info.NonLocalOnly = 0; + allocation.setDefaultGmm(gmm.get()); + allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; debugManager.logAllocation(&allocation); diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index 62fdfba543..7eb530b7ec 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -79,7 +79,7 @@ TEST_F(Wddm20Tests, givenNullPageTableManagerAndRenderCompressedResourceWhenMapp void *fakePtr = reinterpret_cast(0x100); WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, fakePtr, 0x2100, nullptr, MemoryPool::MemoryNull, false); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); allocation.getHandleToModify(0u) = ALLOCATION_HANDLE; EXPECT_TRUE(wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr())); @@ -175,7 +175,7 @@ TEST_F(Wddm20Tests, allocation) { WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, false); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); - allocation.gmm = gmm; + allocation.setDefaultGmm(gmm); auto status = wddm->createAllocation(&allocation); EXPECT_EQ(STATUS_SUCCESS, status); @@ -199,7 +199,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenAllocationSmallerUnderlyingThanAlignedSiz WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, ptr, 0x2100, nullptr, MemoryPool::MemoryNull, false); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getAlignedCpuPtr(), allocation.getAlignedSize()); - allocation.gmm = gmm; + allocation.setDefaultGmm(gmm); auto status = wddm->createAllocation(&allocation); EXPECT_EQ(STATUS_SUCCESS, status); @@ -240,7 +240,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenWddmAllocationWhenMappingGpuVaThenUseGmmS WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, fakePtr, 100, nullptr, MemoryPool::MemoryNull, false); std::unique_ptr gmm(GmmHelperFunctions::getGmm(allocation.getAlignedCpuPtr(), allocation.getAlignedSize())); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); auto status = wddm->createAllocation(&allocation); EXPECT_EQ(STATUS_SUCCESS, status); @@ -261,7 +261,7 @@ TEST_F(Wddm20Tests, createAllocation32bit) { MockWddmAllocation allocation; Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); - allocation.gmm = gmm; + allocation.setDefaultGmm(gmm); allocation.set32BitAllocation(true); // mark 32 bit allocation auto status = wddm->createAllocation(&allocation); @@ -289,7 +289,7 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddr WddmAllocation allocation(GraphicsAllocation::AllocationType::KERNEL_ISA, alignedPtr, alignedSize, nullptr, MemoryPool::MemoryNull, false); allocation.getHandleToModify(0u) = ALLOCATION_HANDLE; - allocation.gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); + allocation.setDefaultGmm(GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize())); EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, allocation.getAlignedCpuPtr(), *hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily])); bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr()); EXPECT_TRUE(ret); @@ -299,7 +299,7 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddr EXPECT_GE(allocation.getGpuAddress(), cannonizedHeapBase); EXPECT_LE(allocation.getGpuAddress(), cannonizedHeapEnd); - delete allocation.gmm; + delete allocation.getDefaultGmm(); } TEST_F(Wddm20WithMockGdiDllTests, GivenThreeOsHandlesWhenAskedForDestroyAllocationsThenAllMarkedAllocationsAreDestroyed) { @@ -339,7 +339,7 @@ TEST_F(Wddm20Tests, mapAndFreeGpuVa) { WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, false); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); - allocation.gmm = gmm; + allocation.setDefaultGmm(gmm); auto status = wddm->createAllocation(&allocation); EXPECT_EQ(STATUS_SUCCESS, status); @@ -365,7 +365,7 @@ TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) { WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 100, nullptr, MemoryPool::MemoryNull, false); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); - allocation.gmm = gmm; + allocation.setDefaultGmm(gmm); auto status = wddm->createAllocation(&allocation); EXPECT_EQ(STATUS_SUCCESS, status); @@ -384,7 +384,7 @@ TEST_F(Wddm20Tests, makeResidentNonResident) { WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, false); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); - allocation.gmm = gmm; + allocation.setDefaultGmm(gmm); auto status = wddm->createAllocation(&allocation); EXPECT_EQ(STATUS_SUCCESS, status); @@ -432,9 +432,9 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF EXPECT_NE(0u, wddmAllocation->getGpuAddress()); EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize()); EXPECT_EQ(nullptr, wddmAllocation->getAlignedCpuPtr()); - EXPECT_NE(nullptr, wddmAllocation->gmm); + EXPECT_NE(nullptr, wddmAllocation->getDefaultGmm()); - EXPECT_EQ(4096u, wddmAllocation->gmm->gmmResourceInfo->getSizeAllocation()); + EXPECT_EQ(4096u, wddmAllocation->getDefaultGmm()->gmmResourceInfo->getSizeAllocation()); mm.freeGraphicsMemory(graphicsAllocation); auto destroyWithResourceHandleCalled = 0u; @@ -735,7 +735,7 @@ TEST_F(Wddm20Tests, whenCreateAllocation64kFailsThenReturnFalse) { void *fakePtr = reinterpret_cast(0x123); auto gmm = std::make_unique(fakePtr, 100, false); WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, fakePtr, 100, nullptr, MemoryPool::MemoryNull, false); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); EXPECT_FALSE(wddm->createAllocation64k(&allocation)); } diff --git a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp index 54690b8671..afca3ae25d 100644 --- a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -77,10 +77,10 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDaf WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false); allocation.setDefaultHandle(ALLOCATION_HANDLE); auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); auto heapIndex = MemoryManager::selectHeap(&allocation, allocation.getUnderlyingBuffer(), *platformDevices[0]); - wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.getDefaultHandle(), allocation.getUnderlyingBuffer(), allocation.getGpuAddressToModify(), heapIndex); + wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.getDefaultGmm(), allocation.getDefaultHandle(), allocation.getUnderlyingBuffer(), allocation.getGpuAddressToModify(), heapIndex); EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.ftrKmdDaf); EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter); @@ -134,7 +134,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenEvictIsCalledThenKmDafListenerNotifyE TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false); auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); auto &handle = allocation.getHandleToModify(0u); wddmWithKmDafMock->createAllocation(allocation.getAlignedCpuPtr(), gmm.get(), handle); @@ -149,7 +149,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafList TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false); auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); auto &handle = allocation.getHandleToModify(0u); wddmWithKmDafMock->createAllocation64k(gmm.get(), handle); diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index 60dc3289b1..a634312036 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -137,7 +137,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemory auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); EXPECT_NE(nullptr, allocation); EXPECT_EQ(MemoryPool::System4KBPages, allocation->getMemoryPool()); - EXPECT_TRUE(allocation->gmm->useSystemMemoryPool); + EXPECT_TRUE(allocation->getDefaultGmm()->useSystemMemoryPool); memoryManager->freeGraphicsMemory(allocation); } @@ -148,7 +148,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesEnabledWhenAl auto allocation = memoryManager->allocateGraphicsMemory64kb(allocationData); EXPECT_NE(nullptr, allocation); EXPECT_EQ(MemoryPool::System64KBPages, allocation->getMemoryPool()); - EXPECT_TRUE(allocation->gmm->useSystemMemoryPool); + EXPECT_TRUE(allocation->getDefaultGmm()->useSystemMemoryPool); memoryManager->freeGraphicsMemory(allocation); } @@ -174,7 +174,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocate32BitGraphicsM ASSERT_NE(nullptr, allocation); EXPECT_EQ(MemoryPool::System4KBPagesWith32BitGpuAddressing, allocation->getMemoryPool()); - EXPECT_TRUE(allocation->gmm->useSystemMemoryPool); + EXPECT_TRUE(allocation->getDefaultGmm()->useSystemMemoryPool); memoryManager->freeGraphicsMemory(allocation); } @@ -186,7 +186,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesDisabledWhenA auto svmAllocation = memoryManager->allocateGraphicsMemoryWithProperties({size, GraphicsAllocation::AllocationType::SVM}); EXPECT_NE(nullptr, svmAllocation); EXPECT_EQ(MemoryPool::System4KBPages, svmAllocation->getMemoryPool()); - EXPECT_TRUE(svmAllocation->gmm->useSystemMemoryPool); + EXPECT_TRUE(svmAllocation->getDefaultGmm()->useSystemMemoryPool); memoryManager->freeGraphicsMemory(svmAllocation); } @@ -349,7 +349,7 @@ TEST_F(WddmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationT EXPECT_EQ(fragment->fragmentCpuPointer, cpuPtr); EXPECT_EQ(fragment->fragmentSize, size); EXPECT_NE(fragment->osInternalStorage, nullptr); - EXPECT_EQ(fragment->osInternalStorage->gmm, gfxAllocation.gmm); + EXPECT_EQ(fragment->osInternalStorage->gmm, gfxAllocation.getDefaultGmm()); EXPECT_EQ(fragment->osInternalStorage->gpuPtr, gpuPtr); EXPECT_EQ(fragment->osInternalStorage->handle, gfxAllocation.handle); EXPECT_NE(fragment->residency, nullptr); @@ -558,7 +558,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenTiledImageWithMipCountZe auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE, imageGraphicsAllocation->gmm->resourceParams.Usage); + EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE, imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage); } TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenTiledImageWithMipCountNonZeroIsBeingCreatedThenallocateGraphicsMemoryForImageIsUsed) { @@ -587,7 +587,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenTiledImageWithMipCountNo auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE, imageGraphicsAllocation->gmm->resourceParams.Usage); + EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE, imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage); } TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenTiledImageIsBeingCreatedFromHostPtrThenallocateGraphicsMemoryForImageIsUsed) { @@ -617,7 +617,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenTiledImageIsBeingCreated auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE, imageGraphicsAllocation->gmm->resourceParams.Usage); + EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE, imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage); } TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenNonTiledImgWithMipCountZeroisBeingCreatedThenAllocateGraphicsMemoryIsUsed) { @@ -645,7 +645,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenNonTiledImgWithMipCountZ auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_BUFFER, imageGraphicsAllocation->gmm->resourceParams.Usage); + EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_BUFFER, imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage); } TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenNonTiledImgWithMipCountNonZeroisBeingCreatedThenAllocateGraphicsMemoryForImageIsUsed) { @@ -673,7 +673,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenNonTiledImgWithMipCountN auto imageGraphicsAllocation = dstImage->getGraphicsAllocation(); ASSERT_NE(nullptr, imageGraphicsAllocation); - EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE, imageGraphicsAllocation->gmm->resourceParams.Usage); + EXPECT_EQ(GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE, imageGraphicsAllocation->getDefaultGmm()->resourceParams.Usage); } TEST_F(WddmMemoryManagerTest, AllocateGpuMemHostPtrOffseted) { @@ -752,8 +752,8 @@ TEST_F(WddmMemoryManagerTest, GivenAlignedPointerWhenAllocate32BitMemoryThenGmmC uint32_t size = 4096; void *ptr = reinterpret_cast(4096); auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, GraphicsAllocation::AllocationType::BUFFER); - EXPECT_EQ(ptr, reinterpret_cast(gpuAllocation->gmm->resourceParams.pExistingSysMem)); - EXPECT_EQ(size, gpuAllocation->gmm->resourceParams.ExistingSysMemSize); + EXPECT_EQ(ptr, reinterpret_cast(gpuAllocation->getDefaultGmm()->resourceParams.pExistingSysMem)); + EXPECT_EQ(size, gpuAllocation->getDefaultGmm()->resourceParams.ExistingSysMemSize); memoryManager->freeGraphicsMemory(gpuAllocation); } @@ -762,8 +762,8 @@ TEST_F(WddmMemoryManagerTest, GivenUnAlignedPointerAndSizeWhenAllocate32BitMemor uint32_t size = 0x1001; void *ptr = reinterpret_cast(0x1001); auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, GraphicsAllocation::AllocationType::BUFFER); - EXPECT_EQ(reinterpret_cast(0x1000), reinterpret_cast(gpuAllocation->gmm->resourceParams.pExistingSysMem)); - EXPECT_EQ(0x2000, gpuAllocation->gmm->resourceParams.ExistingSysMemSize); + EXPECT_EQ(reinterpret_cast(0x1000), reinterpret_cast(gpuAllocation->getDefaultGmm()->resourceParams.pExistingSysMem)); + EXPECT_EQ(0x2000, gpuAllocation->getDefaultGmm()->resourceParams.ExistingSysMemSize); memoryManager->freeGraphicsMemory(gpuAllocation); } @@ -904,7 +904,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGpuV setMapGpuVaFailConfigFcn(0, 1); WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, ptr, size, nullptr, MemoryPool::MemoryNull, false); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); bool ret = memoryManager->createWddmAllocation(&allocation); EXPECT_FALSE(ret); } @@ -920,7 +920,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstMap setMapGpuVaFailConfigFcn(0, 1); WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, ptr, size, nullptr, MemoryPool::MemoryNull, false); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); bool ret = memoryManager->createWddmAllocation(&allocation); EXPECT_TRUE(ret); } @@ -936,7 +936,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd setMapGpuVaFailConfigFcn(0, 2); WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, ptr, size, nullptr, MemoryPool::MemoryNull, false); - allocation.gmm = gmm.get(); + allocation.setDefaultGmm(gmm.get()); bool ret = memoryManager->createWddmAllocation(&allocation); EXPECT_FALSE(ret); } @@ -1285,7 +1285,7 @@ TEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocation EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation->getUnderlyingBufferSize()); EXPECT_NE(0llu, graphicsAllocation->getGpuAddress()); EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer()); - EXPECT_EQ(1u, graphicsAllocation->gmm->resourceParams.Flags.Info.Cacheable); + EXPECT_EQ(1u, graphicsAllocation->getDefaultGmm()->resourceParams.Flags.Info.Cacheable); memoryManager.freeGraphicsMemory(graphicsAllocation); } @@ -1368,7 +1368,7 @@ TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThen GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {}; GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {}; expectedDdiUpdateAuxTable.BaseGpuVA = allocation->getGpuAddress(); - expectedDdiUpdateAuxTable.BaseResInfo = allocation->gmm->gmmResourceInfo->peekHandle(); + expectedDdiUpdateAuxTable.BaseResInfo = allocation->getDefaultGmm()->gmmResourceInfo->peekHandle(); expectedDdiUpdateAuxTable.DoNotWait = true; expectedDdiUpdateAuxTable.Map = true; @@ -1426,12 +1426,12 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenReleaseingT auto wddmAlloc = static_cast(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize})); wddmAlloc->setGpuAddress(gpuVa); - wddmAlloc->gmm->isRenderCompressed = true; + wddmAlloc->getDefaultGmm()->isRenderCompressed = true; GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {}; GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {}; expectedDdiUpdateAuxTable.BaseGpuVA = gpuVa; - expectedDdiUpdateAuxTable.BaseResInfo = wddmAlloc->gmm->gmmResourceInfo->peekHandle(); + expectedDdiUpdateAuxTable.BaseResInfo = wddmAlloc->getDefaultGmm()->gmmResourceInfo->peekHandle(); expectedDdiUpdateAuxTable.DoNotWait = true; expectedDdiUpdateAuxTable.Map = false; @@ -1450,7 +1450,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleasei wddm->resetPageTableManager(mockMngr); auto wddmAlloc = static_cast(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize})); - wddmAlloc->gmm->isRenderCompressed = false; + wddmAlloc->getDefaultGmm()->isRenderCompressed = false; EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0); @@ -1500,8 +1500,8 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUnse myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1; auto wddmAlloc = static_cast(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize})); - delete wddmAlloc->gmm; - wddmAlloc->gmm = myGmm; + delete wddmAlloc->getDefaultGmm(); + wddmAlloc->setDefaultGmm(myGmm); EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0); diff --git a/unit_tests/sharings/gl/gl_create_from_texture_tests.cpp b/unit_tests/sharings/gl/gl_create_from_texture_tests.cpp index b20f5bf6b8..569cbb5a3a 100644 --- a/unit_tests/sharings/gl/gl_create_from_texture_tests.cpp +++ b/unit_tests/sharings/gl/gl_create_from_texture_tests.cpp @@ -29,9 +29,9 @@ class CreateFromGlTexture : public ::testing::Test { GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override { auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(handle, requireSpecificBitness); if (handle == CreateFromGlTexture::mcsHandle) { - alloc->gmm = forceMcsGmm; + alloc->setDefaultGmm(forceMcsGmm); } else { - alloc->gmm = forceGmm; + alloc->setDefaultGmm(forceGmm); } return alloc; } diff --git a/unit_tests/sharings/gl/gl_reused_buffers_tests.cpp b/unit_tests/sharings/gl/gl_reused_buffers_tests.cpp index bcda31b01d..9238741c07 100644 --- a/unit_tests/sharings/gl/gl_reused_buffers_tests.cpp +++ b/unit_tests/sharings/gl/gl_reused_buffers_tests.cpp @@ -83,12 +83,12 @@ TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenReleasin TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenCreatingThenReuseGmmResourceToo) { std::unique_ptr glBuffer1(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal)); - glBuffer1->getGraphicsAllocation()->gmm = new Gmm((void *)0x100, 1, false); + glBuffer1->getGraphicsAllocation()->setDefaultGmm(new Gmm((void *)0x100, 1, false)); std::unique_ptr glBuffer2(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal)); - EXPECT_EQ(glBuffer1->getGraphicsAllocation()->gmm->gmmResourceInfo->peekHandle(), - glBuffer2->getGraphicsAllocation()->gmm->gmmResourceInfo->peekHandle()); + EXPECT_EQ(glBuffer1->getGraphicsAllocation()->getDefaultGmm()->gmmResourceInfo->peekHandle(), + glBuffer2->getGraphicsAllocation()->getDefaultGmm()->gmmResourceInfo->peekHandle()); } TEST_F(GlReusedBufferTests, givenGlobalShareHandleChangedWhenAcquiringSharedBufferThenChangeGraphicsAllocation) { diff --git a/unit_tests/sharings/gl/gl_sharing_tests.cpp b/unit_tests/sharings/gl/gl_sharing_tests.cpp index 42dd1b0874..517efc7c46 100644 --- a/unit_tests/sharings/gl/gl_sharing_tests.cpp +++ b/unit_tests/sharings/gl/gl_sharing_tests.cpp @@ -257,8 +257,8 @@ TEST_F(glSharingTests, givenClGLBufferWhenItIsCreatedAndGmmIsAvailableThenItIsUs auto memObject = castToObject(glBuffer); auto graphicsAllocation = memObject->getGraphicsAllocation(); - ASSERT_NE(nullptr, graphicsAllocation->gmm); - EXPECT_NE(nullptr, graphicsAllocation->gmm->gmmResourceInfo->peekHandle()); + ASSERT_NE(nullptr, graphicsAllocation->getDefaultGmm()); + EXPECT_NE(nullptr, graphicsAllocation->getDefaultGmm()->gmmResourceInfo->peekHandle()); retVal = clReleaseMemObject(glBuffer); EXPECT_EQ(CL_SUCCESS, retVal); diff --git a/unit_tests/sharings/gl/gl_texture_tests.cpp b/unit_tests/sharings/gl/gl_texture_tests.cpp index 33d6f67a3b..0429b3fe2a 100644 --- a/unit_tests/sharings/gl/gl_texture_tests.cpp +++ b/unit_tests/sharings/gl/gl_texture_tests.cpp @@ -28,7 +28,7 @@ class GlSharingTextureTests : public ::testing::Test { GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override { auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(handle, requireSpecificBitness); if (useForcedGmm) { - alloc->gmm = forceGmm.get(); + alloc->setDefaultGmm(forceGmm.get()); } return alloc; } @@ -204,8 +204,8 @@ TEST_F(GlSharingTextureTests, givenGmmResourceAsInputeWhenTextureIsCreatedItHasG ASSERT_NE(nullptr, glTexture); EXPECT_NE(nullptr, glTexture->getGraphicsAllocation()); - ASSERT_NE(nullptr, glTexture->getGraphicsAllocation()->gmm); - ASSERT_NE(nullptr, glTexture->getGraphicsAllocation()->gmm->gmmResourceInfo->peekHandle()); + ASSERT_NE(nullptr, glTexture->getGraphicsAllocation()->getDefaultGmm()); + ASSERT_NE(nullptr, glTexture->getGraphicsAllocation()->getDefaultGmm()->gmmResourceInfo->peekHandle()); delete glTexture; }