From 10d274daa919579430bf31c80fa95e80289e98ec Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Mon, 30 Dec 2019 14:14:27 +0100 Subject: [PATCH] Pass GmmClientContext to Gmm and GmmResourceInfo Related-To: NEO-3007 Change-Id: Ia590670e93ed93b0941d5a5dc6ac010268cb561e Signed-off-by: Mateusz Jablonski --- .../execution_environment.cpp | 4 +- .../execution_environment.h | 2 + runtime/gmm_helper/gmm.cpp | 14 ++--- runtime/gmm_helper/gmm.h | 10 ++-- runtime/gmm_helper/resource_info.cpp | 8 +-- runtime/gmm_helper/resource_info.h | 11 ++-- runtime/gmm_helper/resource_info_impl.cpp | 14 ++--- runtime/mem_obj/image.cpp | 8 ++- runtime/memory_manager/memory_manager.cpp | 2 +- .../os_agnostic_memory_manager.cpp | 4 +- .../os_interface/linux/drm_memory_manager.cpp | 4 +- runtime/os_interface/windows/wddm/wddm.cpp | 4 +- .../windows/wddm_memory_manager.cpp | 15 ++--- runtime/sharings/gl/gl_buffer.cpp | 3 +- runtime/sharings/gl/gl_texture.cpp | 5 +- .../aub_mem_dump/aub_alloc_dump_tests.cpp | 2 +- .../mem_obj/create_image_aub_tests.cpp | 6 +- unit_tests/built_ins/built_in_tests.cpp | 4 +- .../read_write_buffer_cpu_copy.cpp | 2 +- .../aub_command_stream_receiver_2_tests.cpp | 2 +- .../context/driver_diagnostics_tests.cpp | 4 +- unit_tests/d3d_sharing/d3d9_tests.cpp | 12 ++-- unit_tests/fixtures/d3d_test_fixture.h | 6 +- unit_tests/gen12lp/image_tests_gen12lp.inl | 2 +- unit_tests/gmm_helper/gmm_helper_tests.cpp | 60 +++++++++---------- unit_tests/helpers/hw_helper_tests.cpp | 46 +++++++------- unit_tests/mem_obj/buffer_set_arg_tests.cpp | 2 +- unit_tests/mem_obj/buffer_tests.cpp | 4 +- .../mem_obj/image2d_from_buffer_tests.cpp | 4 +- unit_tests/mem_obj/image3d_tests.cpp | 4 +- unit_tests/mem_obj/image_set_arg_tests.cpp | 12 ++-- unit_tests/mem_obj/image_tests.cpp | 4 +- unit_tests/mem_obj/image_tiled_tests.cpp | 4 +- unit_tests/mem_obj/mem_obj_tests.cpp | 4 +- ...nager_allocate_in_preferred_pool_tests.inl | 5 ++ .../memory_manager/memory_manager_tests.cpp | 10 ++-- .../unified_memory_manager_tests.cpp | 1 + unit_tests/mocks/mock_gmm.h | 6 +- unit_tests/mocks/mock_gmm_resource_info.cpp | 4 +- unit_tests/mocks/mock_memory_manager.cpp | 2 +- .../linux/drm_memory_manager_tests.cpp | 2 +- .../windows/file_logger_win_tests.cpp | 5 +- .../os_interface/windows/wddm20_tests.cpp | 10 ++-- .../windows/wddm_kmdaf_listener_tests.cpp | 8 +-- .../windows/wddm_memory_manager_tests.cpp | 44 +++++++------- .../gl/gl_create_from_texture_tests.cpp | 4 +- .../sharings/gl/gl_reused_buffers_tests.cpp | 2 +- unit_tests/sharings/gl/gl_sharing_tests.cpp | 2 +- unit_tests/sharings/gl/gl_texture_tests.cpp | 2 +- 49 files changed, 208 insertions(+), 191 deletions(-) diff --git a/runtime/execution_environment/execution_environment.cpp b/runtime/execution_environment/execution_environment.cpp index efa8f5c903..835ba9e413 100644 --- a/runtime/execution_environment/execution_environment.cpp +++ b/runtime/execution_environment/execution_environment.cpp @@ -90,7 +90,9 @@ void ExecutionEnvironment::calculateMaxOsContextCount() { GmmHelper *ExecutionEnvironment::getGmmHelper() const { return gmmHelper.get(); } - +GmmClientContext *ExecutionEnvironment::getGmmClientContext() const { + return gmmHelper->getClientContext(); +} CompilerInterface *ExecutionEnvironment::getCompilerInterface() { if (this->compilerInterface.get() == nullptr) { std::lock_guard autolock(this->mtx); diff --git a/runtime/execution_environment/execution_environment.h b/runtime/execution_environment/execution_environment.h index 748a345f82..3e36af934f 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -15,6 +15,7 @@ namespace NEO { class BuiltIns; class CompilerInterface; +class GmmClientContext; class GmmHelper; class MemoryManager; class OSInterface; @@ -46,6 +47,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject void prepareRootDeviceEnvironments(uint32_t numRootDevices); GmmHelper *getGmmHelper() const; + GmmClientContext *getGmmClientContext() const; MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface(); BuiltIns *getBuiltIns(); diff --git a/runtime/gmm_helper/gmm.cpp b/runtime/gmm_helper/gmm.cpp index d01b7dd589..7eac2eb8aa 100644 --- a/runtime/gmm_helper/gmm.cpp +++ b/runtime/gmm_helper/gmm.cpp @@ -18,9 +18,9 @@ #include "runtime/platform/platform.h" namespace NEO { -Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable) : Gmm(alignedPtr, alignedSize, uncacheable, false, true, {}) {} +Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, bool uncacheable) : Gmm(clientContext, alignedPtr, alignedSize, uncacheable, false, true, {}) {} -Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo) { +Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo) : clientContext(clientContext) { resourceParams.Type = RESOURCE_BUFFER; resourceParams.Format = GMM_FORMAT_GENERIC_8BIT; resourceParams.BaseWidth64 = static_cast(alignedSize); @@ -50,18 +50,18 @@ Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable, bool pref applyAuxFlagsForBuffer(preferRenderCompressed); applyMemoryFlags(systemMemoryPool, storageInfo); - gmmResourceInfo.reset(GmmResourceInfo::create(&resourceParams)); + gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, &resourceParams)); } -Gmm::Gmm(GMM_RESOURCE_INFO *inputGmm) { - gmmResourceInfo.reset(GmmResourceInfo::create(inputGmm)); +Gmm::Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm) : clientContext(clientContext) { + gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, inputGmm)); } -Gmm::Gmm(ImageInfo &inputOutputImgInfo, StorageInfo storageInfo) { +Gmm::Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo) : clientContext(clientContext) { this->resourceParams = {}; setupImageResourceParams(inputOutputImgInfo); applyMemoryFlags(!inputOutputImgInfo.useLocalMemory, storageInfo); - this->gmmResourceInfo.reset(GmmResourceInfo::create(&this->resourceParams)); + this->gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, &this->resourceParams)); UNRECOVERABLE_IF(this->gmmResourceInfo == nullptr); queryImageParams(inputOutputImgInfo); diff --git a/runtime/gmm_helper/gmm.h b/runtime/gmm_helper/gmm.h index 4a57db944a..3b293ce88f 100644 --- a/runtime/gmm_helper/gmm.h +++ b/runtime/gmm_helper/gmm.h @@ -20,15 +20,16 @@ enum class OCLPlane; struct HardwareInfo; struct ImageInfo; class GmmResourceInfo; +class GmmClientContext; class Gmm { public: virtual ~Gmm() = default; Gmm() = delete; - Gmm(ImageInfo &inputOutputImgInfo, StorageInfo storageInfo); - Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable); - Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo); - Gmm(GMM_RESOURCE_INFO *inputGmm); + Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo); + Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, bool uncacheable); + Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo); + Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm); void queryImageParams(ImageInfo &inputOutputImgInfo); @@ -55,5 +56,6 @@ class Gmm { protected: void applyAuxFlagsForImage(ImageInfo &imgInfo); void setupImageResourceParams(ImageInfo &imgInfo); + GmmClientContext *clientContext = nullptr; }; } // namespace NEO diff --git a/runtime/gmm_helper/resource_info.cpp b/runtime/gmm_helper/resource_info.cpp index 8240559a0f..0d4e459ed6 100644 --- a/runtime/gmm_helper/resource_info.cpp +++ b/runtime/gmm_helper/resource_info.cpp @@ -8,11 +8,11 @@ #include "runtime/gmm_helper/resource_info.h" namespace NEO { -GmmResourceInfo *GmmResourceInfo::create(GMM_RESCREATE_PARAMS *resourceCreateParams) { - return new GmmResourceInfo(resourceCreateParams); +GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams) { + return new GmmResourceInfo(clientContext, resourceCreateParams); } -GmmResourceInfo *GmmResourceInfo::create(GMM_RESOURCE_INFO *inputGmmResourceInfo) { - return new GmmResourceInfo(inputGmmResourceInfo); +GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) { + return new GmmResourceInfo(clientContext, inputGmmResourceInfo); } } // namespace NEO diff --git a/runtime/gmm_helper/resource_info.h b/runtime/gmm_helper/resource_info.h index 966603f5d8..1e6f3a09d2 100644 --- a/runtime/gmm_helper/resource_info.h +++ b/runtime/gmm_helper/resource_info.h @@ -12,11 +12,12 @@ #include namespace NEO { +class GmmClientContext; class GmmResourceInfo { public: - static GmmResourceInfo *create(GMM_RESCREATE_PARAMS *resourceCreateParams); + static GmmResourceInfo *create(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams); - static GmmResourceInfo *create(GMM_RESOURCE_INFO *inputGmmResourceInfo); + static GmmResourceInfo *create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo); MOCKABLE_VIRTUAL ~GmmResourceInfo() = default; @@ -79,12 +80,14 @@ class GmmResourceInfo { GmmResourceInfo() = default; - GmmResourceInfo(GMM_RESCREATE_PARAMS *resourceCreateParams); + GmmResourceInfo(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams); - GmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo); + GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo); void createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr); UniquePtrType resourceInfo; + + GmmClientContext *clientContext = nullptr; }; } // namespace NEO diff --git a/runtime/gmm_helper/resource_info_impl.cpp b/runtime/gmm_helper/resource_info_impl.cpp index 7d97aa10fc..4b9161de1a 100644 --- a/runtime/gmm_helper/resource_info_impl.cpp +++ b/runtime/gmm_helper/resource_info_impl.cpp @@ -7,26 +7,24 @@ #include "core/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/resource_info.h" -#include "runtime/platform/platform.h" #include "gmm_client_context.h" namespace NEO { -GmmResourceInfo::GmmResourceInfo(GMM_RESCREATE_PARAMS *resourceCreateParams) { - auto resourceInfoPtr = platform()->peekGmmClientContext()->createResInfoObject(resourceCreateParams); +GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams) : clientContext(clientContext) { + auto resourceInfoPtr = clientContext->createResInfoObject(resourceCreateParams); createResourceInfo(resourceInfoPtr); } -GmmResourceInfo::GmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) { - auto resourceInfoPtr = platform()->peekGmmClientContext()->copyResInfoObject(inputGmmResourceInfo); +GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) : clientContext(clientContext) { + auto resourceInfoPtr = clientContext->copyResInfoObject(inputGmmResourceInfo); createResourceInfo(resourceInfoPtr); } void GmmResourceInfo::createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr) { - auto gmmClientContext = platform()->peekGmmClientContext(); - auto customDeleter = [gmmClientContext](GMM_RESOURCE_INFO *gmmResourceInfo) { - gmmClientContext->destroyResInfoObject(gmmResourceInfo); + auto customDeleter = [this](GMM_RESOURCE_INFO *gmmResourceInfo) { + this->clientContext->destroyResInfoObject(gmmResourceInfo); }; this->resourceInfo = UniquePtrType(resourceInfoPtr, customDeleter); } diff --git a/runtime/mem_obj/image.cpp b/runtime/mem_obj/image.cpp index 2d0e41232a..478bd370b2 100644 --- a/runtime/mem_obj/image.cpp +++ b/runtime/mem_obj/image.cpp @@ -127,6 +127,7 @@ Image *Image::create(Context *context, Image *parentImage = castToObject(imageDesc->mem_object); auto &hwHelper = HwHelper::get(context->getDevice(0)->getHardwareInfo().platform.eRenderCoreFamily); auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex(); + auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(); do { size_t imageWidth = imageDesc->image_width; @@ -248,7 +249,7 @@ Image *Image::create(Context *context, if (memoryManager->peekVirtualPaddingSupport() && (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D)) { // Retrieve sizes from GMM and apply virtual padding if buffer storage is not big enough auto queryGmmImgInfo(imgInfo); - auto gmm = std::make_unique(queryGmmImgInfo, StorageInfo{}); + auto gmm = std::make_unique(clientContext, queryGmmImgInfo, StorageInfo{}); auto gmmAllocationSize = gmm->gmmResourceInfo->getSizeAllocation(); if (gmmAllocationSize > memory->getUnderlyingBufferSize()) { memory = memoryManager->createGraphicsAllocationWithPadding(memory, gmmAllocationSize); @@ -275,7 +276,7 @@ Image *Image::create(Context *context, } } } else { - gmm = new Gmm(imgInfo, StorageInfo{}); + gmm = new Gmm(clientContext, imgInfo, StorageInfo{}); memory = memoryManager->allocateGraphicsMemoryWithProperties({rootDeviceIndex, false, imgInfo.size, GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE, false}, hostPtr); memory->setDefaultGmm(gmm); zeroCopy = true; @@ -670,13 +671,14 @@ cl_int Image::getImageParams(Context *context, size_t *imageRowPitch, size_t *imageSlicePitch) { cl_int retVal = CL_SUCCESS; + auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(); ImageInfo imgInfo = {0}; cl_image_desc imageDescriptor = *imageDesc; imgInfo.imgDesc = &imageDescriptor; imgInfo.surfaceFormat = surfaceFormat; - auto gmm = std::make_unique(imgInfo, StorageInfo{}); + auto gmm = std::make_unique(clientContext, imgInfo, StorageInfo{}); *imageRowPitch = imgInfo.rowPitch; *imageSlicePitch = imgInfo.slicePitch; diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index 7307c715c9..43753cf4ad 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -365,7 +365,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData & } GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForImage(const AllocationData &allocationData) { - auto gmm = std::make_unique(*allocationData.imgInfo, allocationData.storageInfo); + auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), *allocationData.imgInfo, allocationData.storageInfo); // AllocationData needs to be reconfigured for System Memory paths AllocationData allocationDataWithSize = allocationData; diff --git a/runtime/memory_manager/os_agnostic_memory_manager.cpp b/runtime/memory_manager/os_agnostic_memory_manager.cpp index 931701de93..840ab49cd1 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager.cpp @@ -158,7 +158,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedH graphicsAllocation->set32BitAllocation(requireSpecificBitness); if (properties.imgInfo) { - Gmm *gmm = new Gmm(*properties.imgInfo, createStorageInfoFromProperties(properties)); + Gmm *gmm = new Gmm(executionEnvironment.getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties)); graphicsAllocation->setDefaultGmm(gmm); } @@ -276,7 +276,7 @@ void OsAgnosticMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage, uin } GraphicsAllocation *OsAgnosticMemoryManager::allocateShareableMemory(const AllocationData &allocationData) { - auto gmm = std::make_unique(allocationData.hostPtr, allocationData.size, false); + auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); GraphicsAllocation *alloc = nullptr; auto ptr = allocateSystemMemory(alignUp(allocationData.size, MemoryConstants::pageSize), MemoryConstants::pageSize); diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index 9b91a16092..bb8b724be8 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -274,7 +274,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(const AllocationData } GraphicsAllocation *DrmMemoryManager::allocateShareableMemory(const AllocationData &allocationData) { - auto gmm = std::make_unique(allocationData.hostPtr, allocationData.size, false); + auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); size_t bufferSize = allocationData.size; uint64_t gpuRange = acquireGpuRange(bufferSize, false, allocationData.rootDeviceIndex); @@ -483,7 +483,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o properties.imgInfo->linearStorage = true; } - Gmm *gmm = new Gmm(*properties.imgInfo, createStorageInfoFromProperties(properties)); + Gmm *gmm = new Gmm(executionEnvironment.getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties)); drmAllocation->setDefaultGmm(gmm); } return drmAllocation; diff --git a/runtime/os_interface/windows/wddm/wddm.cpp b/runtime/os_interface/windows/wddm/wddm.cpp index 134229cd2e..df829e233e 100644 --- a/runtime/os_interface/windows/wddm/wddm.cpp +++ b/runtime/os_interface/windows/wddm/wddm.cpp @@ -628,7 +628,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) { alloc->resourceHandle = OpenResource.hResource; auto resourceInfo = const_cast(allocationInfo[0].pPrivateDriverData); - alloc->setDefaultGmm(new Gmm(static_cast(resourceInfo))); + alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.executionEnvironment.getGmmClientContext(), static_cast(resourceInfo))); return true; } @@ -665,7 +665,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) { alloc->resourceHandle = openResourceFromNtHandle.hResource; auto resourceInfo = const_cast(allocationInfo2[0].pPrivateDriverData); - alloc->setDefaultGmm(new Gmm(static_cast(resourceInfo))); + alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.executionEnvironment.getGmmClientContext(), 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 23fa0ed6b9..f365cdac03 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.cpp +++ b/runtime/os_interface/windows/wddm_memory_manager.cpp @@ -52,7 +52,7 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment) } GraphicsAllocation *WddmMemoryManager::allocateShareableMemory(const AllocationData &allocationData) { - auto gmm = std::make_unique(allocationData.hostPtr, allocationData.size, false); + auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); auto allocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, nullptr, allocationData.size, nullptr, MemoryPool::SystemCpuInaccessible, allocationData.flags.shareable); allocation->setDefaultGmm(gmm.get()); if (!createWddmAllocation(allocation.get(), nullptr)) { @@ -85,7 +85,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const Allocati auto wddmAllocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, nullptr, sizeAligned, nullptr, MemoryPool::System64KBPages); - auto gmm = new Gmm(nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true, {}); + auto gmm = new Gmm(executionEnvironment.getGmmClientContext(), nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true, {}); wddmAllocation->setDefaultGmm(gmm); if (!wddm->createAllocation64k(gmm, wddmAllocation->getHandleToModify(0u))) { @@ -116,7 +116,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const auto wddmAllocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, pSysMem, sizeAligned, nullptr, MemoryPool::System4KBPages); wddmAllocation->setDriverAllocatedCpuPtr(pSysMem); - gmm = new Gmm(pSysMem, sizeAligned, allocationData.flags.uncacheable); + gmm = new Gmm(executionEnvironment.getGmmClientContext(), pSysMem, sizeAligned, allocationData.flags.uncacheable); wddmAllocation->setDefaultGmm(gmm); void *mapPtr = wddmAllocation->getAlignedCpuPtr(); @@ -151,7 +151,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co allocationData.size, nullptr, MemoryPool::System4KBPages); wddmAllocation->setAllocationOffset(offsetInPage); - auto gmm = new Gmm(alignedPtr, alignedSize, false); + auto gmm = new Gmm(executionEnvironment.getGmmClientContext(), alignedPtr, alignedSize, false); wddmAllocation->setDefaultGmm(gmm); @@ -178,7 +178,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const A auto allocation = new WddmAllocation(allocationData.rootDeviceIndex, allocationData.type, const_cast(inputPtr), allocationData.size, reserve, MemoryPool::System4KBPages); allocation->setAllocationOffset(offset); - Gmm *gmm = new Gmm(ptrAligned, sizeAligned, false); + Gmm *gmm = new Gmm(executionEnvironment.getGmmClientContext(), ptrAligned, sizeAligned, false); allocation->setDefaultGmm(gmm); if (createWddmAllocation(allocation, reserve)) { return allocation; @@ -215,7 +215,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All wddmAllocation->set32BitAllocation(true); wddmAllocation->setAllocationOffset(offset); - gmm = new Gmm(ptrAligned, sizeAligned, false); + gmm = new Gmm(executionEnvironment.getGmmClientContext(), ptrAligned, sizeAligned, false); wddmAllocation->setDefaultGmm(gmm); if (!createWddmAllocation(wddmAllocation.get(), nullptr)) { @@ -421,7 +421,8 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle(); handleStorage.fragmentStorageData[i].residency = new ResidencyData(); - handleStorage.fragmentStorageData[i].osHandleStorage->gmm = new Gmm(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, false); + handleStorage.fragmentStorageData[i].osHandleStorage->gmm = new Gmm(executionEnvironment.getGmmClientContext(), handleStorage.fragmentStorageData[i].cpuPtr, + handleStorage.fragmentStorageData[i].fragmentSize, false); allocatedFragmentIndexes[allocatedFragmentsCounter] = i; allocatedFragmentsCounter++; } diff --git a/runtime/sharings/gl/gl_buffer.cpp b/runtime/sharings/gl/gl_buffer.cpp index 11cd1719fe..85a31b5e26 100644 --- a/runtime/sharings/gl/gl_buffer.cpp +++ b/runtime/sharings/gl/gl_buffer.cpp @@ -144,7 +144,8 @@ GraphicsAllocation *GlBuffer::createGraphicsAllocation(Context *context, unsigne sharingFunctions->graphicsAllocationsForGlBufferReuse.push_back(std::make_pair(bufferId, graphicsAllocation)); if (bufferInfo.pGmmResInfo) { DEBUG_BREAK_IF(graphicsAllocation->getDefaultGmm() != nullptr); - graphicsAllocation->setDefaultGmm(new Gmm(bufferInfo.pGmmResInfo)); + auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(); + graphicsAllocation->setDefaultGmm(new Gmm(clientContext, bufferInfo.pGmmResInfo)); } } diff --git a/runtime/sharings/gl/gl_texture.cpp b/runtime/sharings/gl/gl_texture.cpp index 20adc15c03..89e8d6acd2 100644 --- a/runtime/sharings/gl/gl_texture.cpp +++ b/runtime/sharings/gl/gl_texture.cpp @@ -28,6 +28,7 @@ namespace NEO { Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture, cl_int *errcodeRet) { ErrorCodeHelper errorCode(errcodeRet, CL_INVALID_GL_OBJECT); + auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(); auto memoryManager = context->getMemoryManager(); cl_image_desc imgDesc = {}; cl_image_format imgFormat = {}; @@ -56,7 +57,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl } if (texInfo.pGmmResInfo) { DEBUG_BREAK_IF(alloc->getDefaultGmm() != nullptr); - alloc->setDefaultGmm(new Gmm(texInfo.pGmmResInfo)); + alloc->setDefaultGmm(new Gmm(clientContext, texInfo.pGmmResInfo)); } auto gmm = alloc->getDefaultGmm(); @@ -120,7 +121,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl mcsAlloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandleMCS, allocProperties, false); if (texInfo.pGmmResInfoMCS) { DEBUG_BREAK_IF(mcsAlloc->getDefaultGmm() != nullptr); - mcsAlloc->setDefaultGmm(new Gmm(texInfo.pGmmResInfoMCS)); + mcsAlloc->setDefaultGmm(new Gmm(clientContext, texInfo.pGmmResInfoMCS)); } mcsSurfaceInfo.pitch = getValidParam(static_cast(mcsAlloc->getDefaultGmm()->gmmResourceInfo->getRenderPitch() / 128)); mcsSurfaceInfo.qPitch = mcsAlloc->getDefaultGmm()->gmmResourceInfo->getQPitch(); 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 7b8dce46b0..65da1b976f 100644 --- a/unit_tests/aub_mem_dump/aub_alloc_dump_tests.cpp +++ b/unit_tests/aub_mem_dump/aub_alloc_dump_tests.cpp @@ -436,7 +436,7 @@ HWTEST_P(AubSurfaceDumpTests, givenGraphicsAllocationWhenGetDumpSurfaceIsCalledA imgDesc.image_height = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - MockGmm::queryImgParams(imgInfo); + MockGmm::queryImgParams(pDevice->getExecutionEnvironment()->getGmmClientContext(), imgInfo); MockMemoryManager::AllocationData allocationData; allocationData.imgInfo = &imgInfo; auto imageAllocation = memoryManager.allocateGraphicsMemoryForImage(allocationData); diff --git a/unit_tests/aub_tests/mem_obj/create_image_aub_tests.cpp b/unit_tests/aub_tests/mem_obj/create_image_aub_tests.cpp index 7bd01f318c..93ab73bd77 100644 --- a/unit_tests/aub_tests/mem_obj/create_image_aub_tests.cpp +++ b/unit_tests/aub_tests/mem_obj/create_image_aub_tests.cpp @@ -97,7 +97,7 @@ HWTEST_P(AUBCreateImageArray, CheckArrayImages) { auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat); imgInfo.linearStorage = !hwHelper.tilingAllowed(false, Image::isImage1d(imageDesc), false); - auto queryGmm = MockGmm::queryImgParams(imgInfo); + auto queryGmm = MockGmm::queryImgParams(pDevice->getExecutionEnvironment()->getGmmClientContext(), imgInfo); //allocate host_ptr auto pixelSize = 4; @@ -223,7 +223,7 @@ HWTEST_P(CopyHostPtrTest, imageWithDoubledRowPitchThatIsCreatedWithCopyHostPtrFl auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat); - MockGmm::queryImgParams(imgInfo); + MockGmm::queryImgParams(pDevice->getExecutionEnvironment()->getGmmClientContext(), imgInfo); auto lineWidth = imageDesc.image_width * elementSize; auto passedRowPitch = imgInfo.rowPitch * 2; imageDesc.image_row_pitch = passedRowPitch; @@ -292,7 +292,7 @@ HWTEST_P(UseHostPtrTest, imageWithRowPitchCreatedWithUseHostPtrFlagCopiedActuall imageDesc.image_height = 1; auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat); - MockGmm::queryImgParams(imgInfo); + MockGmm::queryImgParams(pDevice->getExecutionEnvironment()->getGmmClientContext(), imgInfo); auto passedRowPitch = imgInfo.rowPitch + 32; imageDesc.image_row_pitch = passedRowPitch; unsigned char *pUseHostPtr = new unsigned char[passedRowPitch * imageDesc.image_height * elementSize]; diff --git a/unit_tests/built_ins/built_in_tests.cpp b/unit_tests/built_ins/built_in_tests.cpp index 128de91bb4..a3c289f633 100644 --- a/unit_tests/built_ins/built_in_tests.cpp +++ b/unit_tests/built_ins/built_in_tests.cpp @@ -569,7 +569,7 @@ HWTEST_F(BuiltInTests, givenAuxToNonAuxTranslationWhenSettingSurfaceStateThenSet cl_int retVal = CL_SUCCESS; auto buffer = std::unique_ptr(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - auto gmm = new Gmm(nullptr, 1, false); + auto gmm = new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); gmm->isRenderCompressed = true; buffer->getGraphicsAllocation()->setDefaultGmm(gmm); @@ -615,7 +615,7 @@ HWTEST_F(BuiltInTests, givenNonAuxToAuxTranslationWhenSettingSurfaceStateThenSet cl_int retVal = CL_SUCCESS; auto buffer = std::unique_ptr(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - auto gmm = new Gmm(nullptr, 1, false); + auto gmm = new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); gmm->isRenderCompressed = true; buffer->getGraphicsAllocation()->setDefaultGmm(gmm); memObjsForAuxTranslation.insert(buffer.get()); 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 60480e3a7c..3c0d0701f1 100644 --- a/unit_tests/command_queue/read_write_buffer_cpu_copy.cpp +++ b/unit_tests/command_queue/read_write_buffer_cpu_copy.cpp @@ -17,7 +17,7 @@ typedef EnqueueReadBufferTypeTest ReadWriteBufferCpuCopyTest; HWTEST_F(ReadWriteBufferCpuCopyTest, givenRenderCompressedGmmWhenAskingForCpuOperationThenDisallow) { cl_int retVal; std::unique_ptr buffer(Buffer::create(context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); - auto gmm = new Gmm(nullptr, 1, false); + auto gmm = new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); gmm->isRenderCompressed = false; buffer->getGraphicsAllocation()->setDefaultGmm(gmm); 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 73b7de3251..e1215ad0c2 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 @@ -670,7 +670,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); aubCsr->setAubWritable(true, *gfxAllocation); - auto gmm = new Gmm(nullptr, 1, false); + auto gmm = new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); gfxAllocation->setDefaultGmm(gmm); for (bool compressed : {false, true}) { diff --git a/unit_tests/context/driver_diagnostics_tests.cpp b/unit_tests/context/driver_diagnostics_tests.cpp index 82de7ef22b..4b23b0c8c9 100644 --- a/unit_tests/context/driver_diagnostics_tests.cpp +++ b/unit_tests/context/driver_diagnostics_tests.cpp @@ -537,7 +537,7 @@ TEST_F(PerformanceHintTest, givenCompressedImageWhenItsCreatedThenProperPerforma auto mockBuffer = std::unique_ptr(new MockBuffer()); StorageInfo info; size_t t = 4; - auto gmm = std::unique_ptr(new Gmm(static_cast(nullptr), t, false, true, true, info)); + auto gmm = std::unique_ptr(new Gmm(device->getExecutionEnvironment()->getGmmClientContext(), static_cast(nullptr), t, false, true, true, info)); gmm->isRenderCompressed = true; mockBuffer->getGraphicsAllocation()->setDefaultGmm(gmm.get()); @@ -657,7 +657,7 @@ TEST_F(PerformanceHintTest, givenUncompressedImageWhenItsCreatedThenProperPerfor auto mockBuffer = std::unique_ptr(new MockBuffer()); StorageInfo info; size_t t = 4; - auto gmm = std::unique_ptr(new Gmm((const void *)nullptr, t, false, true, true, info)); + auto gmm = std::unique_ptr(new Gmm(device->getExecutionEnvironment()->getGmmClientContext(), (const void *)nullptr, t, false, true, true, info)); gmm->isRenderCompressed = false; mockBuffer->getGraphicsAllocation()->setDefaultGmm(gmm.get()); diff --git a/unit_tests/d3d_sharing/d3d9_tests.cpp b/unit_tests/d3d_sharing/d3d9_tests.cpp index 2fb73af31d..686baad069 100644 --- a/unit_tests/d3d_sharing/d3d9_tests.cpp +++ b/unit_tests/d3d_sharing/d3d9_tests.cpp @@ -39,7 +39,7 @@ class MockMM : public OsAgnosticMemoryManager { return alloc; } GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData) override { - auto gmm = std::make_unique(*allocationData.imgInfo, StorageInfo{}); + auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), *allocationData.imgInfo, StorageInfo{}); AllocationProperties properties(allocationData.rootDeviceIndex, nullptr, false, GraphicsAllocation::AllocationType::SHARED_IMAGE, false); auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(1, properties, false); alloc->setDefaultGmm(forceGmm); @@ -82,14 +82,13 @@ class D3D9Tests : public PlatformFixture, public ::testing::Test { imgDesc.image_depth = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - gmm = MockGmm::queryImgParams(imgInfo).release(); + gmm = MockGmm::queryImgParams(pPlatform->peekExecutionEnvironment()->getGmmClientContext(), imgInfo).release(); mockGmmResInfo = reinterpret_cast *>(gmm->gmmResourceInfo.get()); memoryManager->forceGmm = gmm; } void SetUp() override { - dbgRestore = new DebugManagerStateRestore(); PlatformFixture::SetUp(); memoryManager = std::make_unique(*pPlatform->peekExecutionEnvironment()); context = new MockContext(pPlatform->getDevice(0)); @@ -117,13 +116,12 @@ class D3D9Tests : public PlatformFixture, public ::testing::Test { delete gmm; } PlatformFixture::TearDown(); - delete dbgRestore; } NiceMock> *mockSharingFcns; MockContext *context; MockCommandQueue *cmdQ; - DebugManagerStateRestore *dbgRestore; + DebugManagerStateRestore dbgRestore; char dummyD3DSurface; char dummyD3DSurfaceStaging; cl_dx9_surface_info_khr surfaceInfo = {}; @@ -1080,7 +1078,7 @@ TEST_F(D3D9MultiRootDeviceTest, givenD3DHandleIsNullWhenCreatingSharedSurfaceAnd imgDesc.image_depth = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto gmm = MockGmm::queryImgParams(imgInfo).release(); + auto gmm = MockGmm::queryImgParams(device->getExecutionEnvironment()->getGmmClientContext(), imgInfo).release(); auto memoryManager = std::make_unique(*device->executionEnvironment); memoryManager->forceGmm = gmm; @@ -1112,7 +1110,7 @@ TEST_F(D3D9MultiRootDeviceTest, givenD3DHandleIsNotNullWhenCreatingSharedSurface imgDesc.image_depth = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto gmm = MockGmm::queryImgParams(imgInfo).release(); + auto gmm = MockGmm::queryImgParams(device->getExecutionEnvironment()->getGmmClientContext(), imgInfo).release(); auto memoryManager = std::make_unique(*device->executionEnvironment); memoryManager->forceGmm = gmm; diff --git a/unit_tests/fixtures/d3d_test_fixture.h b/unit_tests/fixtures/d3d_test_fixture.h index 70ea0c40b3..5964459e06 100644 --- a/unit_tests/fixtures/d3d_test_fixture.h +++ b/unit_tests/fixtures/d3d_test_fixture.h @@ -74,14 +74,13 @@ class D3DTests : public PlatformFixture, public ::testing::Test { imgDesc.image_depth = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - gmm = MockGmm::queryImgParams(imgInfo).release(); + gmm = MockGmm::queryImgParams(pPlatform->peekExecutionEnvironment()->getGmmClientContext(), imgInfo).release(); mockGmmResInfo = reinterpret_cast *>(gmm->gmmResourceInfo.get()); mockMM->forceGmm = gmm; } void SetUp() override { - dbgRestore = new DebugManagerStateRestore(); PlatformFixture::SetUp(); context = new MockContext(pPlatform->getDevice(0)); context->preferD3dSharedResources = true; @@ -116,7 +115,6 @@ class D3DTests : public PlatformFixture, public ::testing::Test { delete gmm; } PlatformFixture::TearDown(); - delete dbgRestore; } cl_int pickParam(cl_int d3d10, cl_int d3d11) { @@ -187,7 +185,7 @@ class D3DTests : public PlatformFixture, public ::testing::Test { Gmm *gmm = nullptr; NiceMock *mockGmmResInfo = nullptr; - DebugManagerStateRestore *dbgRestore; + DebugManagerStateRestore dbgRestore; std::unique_ptr mockMM; uint8_t d3dMode = 0; diff --git a/unit_tests/gen12lp/image_tests_gen12lp.inl b/unit_tests/gen12lp/image_tests_gen12lp.inl index 93ecfa0479..9adc228be9 100644 --- a/unit_tests/gen12lp/image_tests_gen12lp.inl +++ b/unit_tests/gen12lp/image_tests_gen12lp.inl @@ -93,7 +93,7 @@ GEN12LPTEST_F(ImageClearColorFixture, givenMcsAllocationWhenSetArgIsCalledWithUn auto surfaceState = FamilyType::cmdInitRenderSurfaceState; auto imageHw = static_cast *>(image.get()); - mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); surfaceState.setSurfaceBaseAddress(0xABCDEF1000); imageHw->setMcsSurfaceInfo(msi); imageHw->setMcsAllocation(mcsAlloc); diff --git a/unit_tests/gmm_helper/gmm_helper_tests.cpp b/unit_tests/gmm_helper/gmm_helper_tests.cpp index 08379be8f0..69a5c574da 100644 --- a/unit_tests/gmm_helper/gmm_helper_tests.cpp +++ b/unit_tests/gmm_helper/gmm_helper_tests.cpp @@ -57,7 +57,7 @@ TEST(GmmGlTests, givenGmmWhenAskedforCubeFaceIndexThenProperValueIsReturned) { TEST_F(GmmTests, resourceCreation) { std::unique_ptr mm(new MemoryManagerCreate(false, false, *executionEnvironment)); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(new Gmm(pSysMem, 4096, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, false)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -72,7 +72,7 @@ TEST_F(GmmTests, resourceCreationUncacheable) { std::unique_ptr mm(new MemoryManagerCreate(false, false, *executionEnvironment)); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(new Gmm(pSysMem, 4096, true)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, true)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -88,7 +88,7 @@ TEST_F(GmmTests, resourceCleanupOnDelete) { std::unique_ptr mm(new MemoryManagerCreate(false, false, *executionEnvironment)); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(new Gmm(pSysMem, 4096, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, false)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -100,7 +100,7 @@ TEST_F(GmmTests, givenHostPointerWithHighestBitSetWhenGmmIsCreatedItHasTheSameAd auto address = reinterpret_cast(addressWithHighestBitSet); auto expectedAddress = castToUint64(address); - std::unique_ptr gmm(new Gmm(address, 4096, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), address, 4096, false)); EXPECT_EQ(gmm->resourceParams.pExistingSysMem, expectedAddress); } @@ -110,7 +110,7 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMM MemoryManager *mm = new MemoryManagerCreate(false, false, *executionEnvironment); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - auto gmmRes = new Gmm(pSysMem, maxSize, false); + auto gmmRes = new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, maxSize, false); ASSERT_TRUE(gmmRes->gmmResourceInfo.get() != nullptr); @@ -123,8 +123,8 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMM TEST_F(GmmTests, givenGmmCreatedFromExistingGmmThenHelperDoesNotReleaseParentGmm) { auto size = 4096u; void *incomingPtr = (void *)0x1000; - auto gmmRes = new Gmm(incomingPtr, size, false); - auto gmmRes2 = new Gmm(gmmRes->gmmResourceInfo->peekHandle()); + auto gmmRes = new Gmm(executionEnvironment->getGmmClientContext(), incomingPtr, size, false); + auto gmmRes2 = new Gmm(executionEnvironment->getGmmClientContext(), gmmRes->gmmResourceInfo->peekHandle()); //copy is being made EXPECT_NE(gmmRes2->gmmResourceInfo->peekHandle(), gmmRes->gmmResourceInfo->peekHandle()); @@ -146,7 +146,7 @@ TEST_F(GmmTests, invalidImageTypeQuery) { imgDesc.image_type = 0; // invalid auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - EXPECT_THROW(MockGmm::queryImgParams(imgInfo), std::exception); + EXPECT_THROW(MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo), std::exception); } TEST_F(GmmTests, validImageTypeQuery) { @@ -161,7 +161,7 @@ TEST_F(GmmTests, validImageTypeQuery) { auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto queryGmm = MockGmm::queryImgParams(imgInfo); + auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); EXPECT_GT(imgInfo.size, minSize); EXPECT_GT(imgInfo.rowPitch, 0u); @@ -191,20 +191,20 @@ TEST_F(GmmTests, validImageTypeQuery) { TEST_F(GmmTests, givenWidthWhenCreatingResourceThenSetWidth64Field) { const void *dummyPtr = reinterpret_cast(0x123); size_t allocationSize = std::numeric_limits::max(); - Gmm gmm(dummyPtr, allocationSize, false); + Gmm gmm(executionEnvironment->getGmmClientContext(), dummyPtr, allocationSize, false); EXPECT_EQ(static_cast(allocationSize), gmm.resourceParams.BaseWidth64); } TEST_F(GmmTests, givenNullptrWhenGmmConstructorIsCalledThenNoGfxMemoryIsProperlySet) { void *pSysMem = nullptr; - std::unique_ptr gmm(new Gmm(pSysMem, 4096, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, false)); EXPECT_EQ(gmm->resourceParams.NoGfxMemory, 1u); } TEST_F(GmmTests, givenPtrWhenGmmConstructorIsCalledThenNoGfxMemoryIsProperlySet) { void *pSysMem = reinterpret_cast(0x1111); - std::unique_ptr gmm(new Gmm(pSysMem, 4096, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, false)); EXPECT_EQ(gmm->resourceParams.NoGfxMemory, 0u); } @@ -221,7 +221,7 @@ TEST_F(GmmTests, given2DimageFromBufferParametersWhenGmmResourceIsCreatedThenItH SurfaceFormatInfo surfaceFormat = {{CL_RGBA, CL_FLOAT}, GMM_FORMAT_R32G32B32A32_FLOAT_TYPE, (GFX3DSTATE_SURFACEFORMAT)0, 0, 4, 4, 16}; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormat); - auto queryGmm = MockGmm::queryImgParams(imgInfo); + auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); auto renderSize = queryGmm->gmmResourceInfo->getSizeAllocation(); size_t expectedSize = imgDesc.image_row_pitch * imgDesc.image_height; @@ -242,7 +242,7 @@ TEST_F(GmmTests, given2DimageFromBufferParametersWhenGmmResourceIsCreatedAndPitc auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormat); EXPECT_EQ(imgInfo.imgDesc->image_row_pitch, imgDesc.image_row_pitch); - auto queryGmm = MockGmm::queryImgParams(imgInfo); + auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); auto renderSize = queryGmm->gmmResourceInfo->getSizeAllocation(); size_t expectedSize = imgDesc.image_row_pitch * imgDesc.image_height; @@ -262,14 +262,14 @@ TEST_F(GmmTests, givenPlanarFormatsWhenQueryingImageParamsThenUVOffsetIsQueried) auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormatNV12); imgInfo.yOffsetForUVPlane = 0; - MockGmm::queryImgParams(imgInfo); + MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); EXPECT_NE(0u, imgInfo.yOffsetForUVPlane); imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormatP010); imgInfo.yOffsetForUVPlane = 0; - MockGmm::queryImgParams(imgInfo); + MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); EXPECT_NE(0u, imgInfo.yOffsetForUVPlane); } @@ -282,7 +282,7 @@ TEST_F(GmmTests, givenTilingModeSetToTileYWhenHwSupportsTilingThenTileYFlagIsSet auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); imgInfo.linearStorage = false; - auto gmm = std::make_unique(imgInfo, StorageInfo{}); + auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), imgInfo, StorageInfo{}); EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 0u); EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 0u); @@ -297,7 +297,7 @@ TEST_F(GmmTests, givenTilingModeSetToNonTiledWhenCreatingGmmThenLinearFlagIsSet) auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); imgInfo.linearStorage = true; - auto gmm = std::make_unique(imgInfo, StorageInfo{}); + auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), imgInfo, StorageInfo{}); EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 1u); EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 0u); @@ -381,7 +381,7 @@ TEST_F(GmmTests, givenMipmapedInputWhenAskedForHalingThenNonDefaultValueIsReturn auto imgInfo = MockGmm::initImgInfo(imgDesc, mipLevel, nullptr); - auto queryGmm = MockGmm::queryImgParams(imgInfo); + auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); EXPECT_EQ(static_cast(queryGmm->resourceParams.MaxLod), mipLevel); } @@ -398,7 +398,7 @@ struct GmmMediaCompressedTests : public GmmTests { void SetUp() override { GmmTests::SetUp(); StorageInfo info; - gmm = std::make_unique(nullptr, 4, false, true, true, info); + gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 4, false, true, true, info); flags = gmm->gmmResourceInfo->getResourceFlags(); flags->Gpu.CCS = true; flags->Gpu.UnifiedAuxSurface = true; @@ -516,7 +516,7 @@ TEST_P(GmmImgTest, updateImgInfoAndDesc) { } auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto queryGmm = MockGmm::queryImgParams(imgInfo); + auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); auto mockResInfo = new NiceMock(&queryGmm->resourceParams); queryGmm->gmmResourceInfo.reset(mockResInfo); @@ -580,7 +580,7 @@ TEST(GmmImgTest, givenImgInfoWhenUpdatingOffsetsCallGmmToGetOffsets) { imgDesc.image_array_size = 10; ImageInfo imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - std::unique_ptr gmm = MockGmm::queryImgParams(imgInfo); + std::unique_ptr gmm = MockGmm::queryImgParams(platform()->peekExecutionEnvironment()->getGmmClientContext(), imgInfo); MyMockGmmResourceInfo *mockGmmResourceInfo = new MyMockGmmResourceInfo(&gmm->resourceParams); gmm->gmmResourceInfo.reset(mockGmmResourceInfo); @@ -604,7 +604,7 @@ TEST_F(GmmTests, copyResourceBlt) { auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto gmm = MockGmm::queryImgParams(imgInfo); + auto gmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); auto mockResInfo = reinterpret_cast *>(gmm->gmmResourceInfo.get()); GMM_RES_COPY_BLT requestedCpuBlt = {}; @@ -664,7 +664,7 @@ TEST_F(GmmTests, copyResourceBlt) { } TEST(GmmTest, givenAllValidFlagsWhenAskedForUnifiedAuxTranslationCapabilityThenReturnTrue) { - auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->setUnifiedAuxTranslationCapable(); @@ -677,7 +677,7 @@ TEST(GmmTest, givenAllValidFlagsWhenAskedForUnifiedAuxTranslationCapabilityThenR } TEST(GmmTest, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapabilityThenReturnFalse) { - auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(nullptr, nullptr, 1, false)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->mockResourceCreateParams.Flags.Gpu.CCS = 0; @@ -699,8 +699,8 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) { struct MyMockResourecInfo : public GmmResourceInfo { using GmmResourceInfo::resourceInfo; - MyMockResourecInfo(GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(inputParams){}; - MyMockResourecInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) : GmmResourceInfo(inputGmmResourceInfo){}; + MyMockResourecInfo(GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(platform()->peekExecutionEnvironment()->getGmmClientContext(), inputParams){}; + MyMockResourecInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) : GmmResourceInfo(platform()->peekExecutionEnvironment()->getGmmClientContext(), inputGmmResourceInfo){}; }; GMM_RESCREATE_PARAMS gmmParams = {}; @@ -724,12 +724,12 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) { } TEST(GmmTest, givenGmmWithNotSetMCSInResourceInfoGpuFlagsWhenCallHasMultisampleControlSurfaceThenReturnFalse) { - auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(nullptr, nullptr, 1, false)); EXPECT_FALSE(gmm->hasMultisampleControlSurface()); } TEST(GmmTest, givenGmmWithSetMCSInResourceInfoGpuFlagsWhenCallhasMultisampleControlSurfaceThenReturnTrue) { - auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(nullptr, nullptr, 1, false)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->setMultisampleControlSurface(); EXPECT_TRUE(gmm->hasMultisampleControlSurface()); @@ -743,7 +743,7 @@ TEST(GmmHelperTest, whenGmmHelperIsInitializedThenClientContextIsSet) { TEST(GmmHelperTest, givenPlatformAlreadyDestroyedWhenResourceIsBeingDestroyedThenObserveNoExceptions) { struct MockGmmResourecInfo : public GmmResourceInfo { using GmmResourceInfo::resourceInfo; - MockGmmResourecInfo(GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(inputParams){}; + MockGmmResourecInfo(GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(platform()->peekExecutionEnvironment()->getGmmClientContext(), inputParams){}; }; GMM_RESCREATE_PARAMS gmmParams = {}; diff --git a/unit_tests/helpers/hw_helper_tests.cpp b/unit_tests/helpers/hw_helper_tests.cpp index 603b9675d3..a5c34ae627 100644 --- a/unit_tests/helpers/hw_helper_tests.cpp +++ b/unit_tests/helpers/hw_helper_tests.cpp @@ -255,8 +255,8 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenNoAllocationProvidedThe using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; - ExecutionEnvironment &ee = *pDevice->getExecutionEnvironment(); - auto gmmHelper = ee.getGmmHelper(); + ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment(); + auto gmmHelper = executionEnvironment.getGmmHelper(); void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); ASSERT_NE(nullptr, stateBuffer); @@ -271,7 +271,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenNoAllocationProvidedThe size_t offset = 0x1000; uint32_t pitch = 0x40; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; - helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, offset, pitch, nullptr, false, type, true); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, offset, pitch, nullptr, false, type, true); RENDER_SURFACE_STATE *state = reinterpret_cast(stateBuffer); EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth()); @@ -287,7 +287,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenNoAllocationProvidedThe size = 0x1003; length.Length = static_cast(alignUp(size, 4) - 1); bool isReadOnly = false; - helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, nullptr, isReadOnly, type, true); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, nullptr, isReadOnly, type, true); EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), state->getMemoryObjectControlState()); EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth()); EXPECT_EQ(length.SurfaceState.Width + 1u, state->getWidth()); @@ -297,7 +297,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenNoAllocationProvidedThe size = 0x1000; addr = 0x2001; length.Length = static_cast(size - 1); - helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, nullptr, isReadOnly, type, true); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, nullptr, isReadOnly, type, true); EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), state->getMemoryObjectControlState()); EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth()); EXPECT_EQ(length.SurfaceState.Width + 1u, state->getWidth()); @@ -308,7 +308,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenNoAllocationProvidedThe size = 0x1005; length.Length = static_cast(alignUp(size, 4) - 1); isReadOnly = true; - helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, nullptr, isReadOnly, type, true); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, nullptr, isReadOnly, type, true); EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), state->getMemoryObjectControlState()); EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth()); EXPECT_EQ(length.SurfaceState.Width + 1u, state->getWidth()); @@ -323,7 +323,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; - ExecutionEnvironment &ee = *pDevice->getExecutionEnvironment(); + ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment(); void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); ASSERT_NE(nullptr, stateBuffer); RENDER_SURFACE_STATE *state = reinterpret_cast(stateBuffer); @@ -341,9 +341,9 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU size_t allocSize = size; length.Length = static_cast(allocSize - 1); GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); - allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.setDefaultGmm(new Gmm(executionEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; - helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, false, type, true); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, true); EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth()); EXPECT_EQ(length.SurfaceState.Width + 1u, state->getWidth()); EXPECT_EQ(length.SurfaceState.Height + 1u, state->getHeight()); @@ -362,7 +362,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; - ExecutionEnvironment &ee = *pDevice->getExecutionEnvironment(); + ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment(); void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); ASSERT_NE(nullptr, stateBuffer); RENDER_SURFACE_STATE *state = reinterpret_cast(stateBuffer); @@ -378,10 +378,10 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); - allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.setDefaultGmm(new Gmm(executionEnvironment.getGmmClientContext(), 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, false, type, false); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, 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()); @@ -394,7 +394,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionEnabledAn using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; - ExecutionEnvironment &ee = *pDevice->getExecutionEnvironment(); + ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment(); void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); ASSERT_NE(nullptr, stateBuffer); RENDER_SURFACE_STATE *state = reinterpret_cast(stateBuffer); @@ -410,10 +410,10 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionEnabledAn uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); - allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.setDefaultGmm(new Gmm(executionEnvironment.getGmmClientContext(), 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, false, type, false); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, 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()); @@ -426,7 +426,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionDisabledA using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; - ExecutionEnvironment &ee = *pDevice->getExecutionEnvironment(); + ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment(); void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); ASSERT_NE(nullptr, stateBuffer); RENDER_SURFACE_STATE *state = reinterpret_cast(stateBuffer); @@ -442,9 +442,9 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionDisabledA uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); - allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.setDefaultGmm(new Gmm(executionEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; - helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, false, type, false); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, 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()); @@ -457,7 +457,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; - ExecutionEnvironment &ee = *pDevice->getExecutionEnvironment(); + ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment(); void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); ASSERT_NE(nullptr, stateBuffer); RENDER_SURFACE_STATE *state = reinterpret_cast(stateBuffer); @@ -473,10 +473,10 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); - allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.setDefaultGmm(new Gmm(executionEnvironment.getGmmClientContext(), 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, false, type, true); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, 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()); @@ -519,7 +519,7 @@ HWTEST_F(HwHelperTest, DISABLED_profilingCreationOfRenderSurfaceStateVsMemcpyOfC copyBuffers.push_back(copyBuffer); } - ExecutionEnvironment &ee = *pDevice->getExecutionEnvironment(); + ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment(); auto &helper = HwHelper::get(renderCoreFamily); size_t size = 0x1000; @@ -529,7 +529,7 @@ HWTEST_F(HwHelperTest, DISABLED_profilingCreationOfRenderSurfaceStateVsMemcpyOfC for (uint32_t i = 0; i < maxLoop; ++i) { auto t1 = std::chrono::high_resolution_clock::now(); - helper.setRenderSurfaceStateForBuffer(ee, surfaceStates[i], size, addr, 0, pitch, nullptr, false, type, true); + helper.setRenderSurfaceStateForBuffer(executionEnvironment, surfaceStates[i], size, addr, 0, pitch, nullptr, false, type, true); auto t2 = std::chrono::high_resolution_clock::now(); timesCreate.push_back(t1); timesCreate.push_back(t2); diff --git a/unit_tests/mem_obj/buffer_set_arg_tests.cpp b/unit_tests/mem_obj/buffer_set_arg_tests.cpp index 32ec5254b5..ff83c0528e 100644 --- a/unit_tests/mem_obj/buffer_set_arg_tests.cpp +++ b/unit_tests/mem_obj/buffer_set_arg_tests.cpp @@ -187,7 +187,7 @@ HWTEST_F(BufferSetArgTest, givenNonPureStatefulArgWhenRenderCompressedBufferIsSe auto surfaceState = reinterpret_cast(ptrOffset(pKernel->getSurfaceStateHeap(), pKernelInfo->kernelArgInfo[0].offsetHeap)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - buffer->getGraphicsAllocation()->setDefaultGmm(new Gmm(buffer->getGraphicsAllocation()->getUnderlyingBuffer(), buffer->getSize(), false)); + buffer->getGraphicsAllocation()->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), 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 a9ee352605..03babf672c 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -2170,7 +2170,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); + auto gmm = new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); buffer->getGraphicsAllocation()->setDefaultGmm(gmm); gmm->isRenderCompressed = true; @@ -2194,7 +2194,7 @@ HWTEST_F(BufferSetSurfaceTests, givenNonRenderCompressedGmmResourceWhenSurfaceSt auto retVal = CL_SUCCESS; std::unique_ptr buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); - auto gmm = new Gmm(nullptr, 1, false); + auto gmm = new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); buffer->getGraphicsAllocation()->setDefaultGmm(gmm); gmm->isRenderCompressed = false; diff --git a/unit_tests/mem_obj/image2d_from_buffer_tests.cpp b/unit_tests/mem_obj/image2d_from_buffer_tests.cpp index 1b2c45552e..0ae7903556 100644 --- a/unit_tests/mem_obj/image2d_from_buffer_tests.cpp +++ b/unit_tests/mem_obj/image2d_from_buffer_tests.cpp @@ -297,7 +297,7 @@ TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImag EXPECT_EQ(this->size, bufferGraphicsAllocation->getUnderlyingBufferSize()); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, &imageFromBuffer->getSurfaceFormatInfo()); - auto queryGmm = MockGmm::queryImgParams(imgInfo); + auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); EXPECT_TRUE(queryGmm->gmmResourceInfo->getSizeAllocation() >= this->size); @@ -334,7 +334,7 @@ TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImag EXPECT_EQ(bufferSize, bufferGraphicsAllocation->getUnderlyingBufferSize()); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, &imageFromBuffer->getSurfaceFormatInfo()); - auto queryGmm = MockGmm::queryImgParams(imgInfo); + auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); EXPECT_GT(queryGmm->gmmResourceInfo->getSizeAllocation(), bufferSize); diff --git a/unit_tests/mem_obj/image3d_tests.cpp b/unit_tests/mem_obj/image3d_tests.cpp index 13c1a40abe..300e81e9b2 100644 --- a/unit_tests/mem_obj/image3d_tests.cpp +++ b/unit_tests/mem_obj/image3d_tests.cpp @@ -89,7 +89,7 @@ HWTEST_F(CreateImage3DTest, calculate3dImageQpitchTiledAndLinear) { imageDesc.image_height = 1; auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imageFormat); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat); - MockGmm::queryImgParams(imgInfo); + MockGmm::queryImgParams(context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); auto image = Image::create( context, @@ -113,7 +113,7 @@ HWTEST_F(CreateImage3DTest, calculate3dImageQpitchTiledAndLinear) { // query again surfaceFormat = Image::getSurfaceFormatFromTable(0, &imageFormat); - MockGmm::queryImgParams(imgInfo); + MockGmm::queryImgParams(context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); image = Image::create( context, diff --git a/unit_tests/mem_obj/image_set_arg_tests.cpp b/unit_tests/mem_obj/image_set_arg_tests.cpp index 2f3e72b9ea..f58627eff0 100644 --- a/unit_tests/mem_obj/image_set_arg_tests.cpp +++ b/unit_tests/mem_obj/image_set_arg_tests.cpp @@ -275,7 +275,7 @@ HWTEST_F(ImageSetArgTest, givenImageArraySizeGreaterThanOneButTypeIsNotImageArra imageInfo.imgDesc = &imageDesc; imageInfo.plane = GMM_NO_PLANE; - auto gmm = MockGmm::queryImgParams(imageInfo); + auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imageInfo); allocation->setDefaultGmm(gmm.release()); auto image = std::unique_ptr{Image::createSharedImage( @@ -512,7 +512,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->setDefaultGmm(new Gmm(nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -611,7 +611,7 @@ 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->setDefaultGmm(new Gmm(nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -672,7 +672,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -702,7 +702,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -731,7 +731,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index bb0c93938b..f4d9e767b6 100644 --- a/unit_tests/mem_obj/image_tests.cpp +++ b/unit_tests/mem_obj/image_tests.cpp @@ -1454,7 +1454,7 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif auto image = std::unique_ptr(ImageHelper::create(&context)); auto surfaceState = FamilyType::cmdInitRenderSurfaceState; auto imageHw = static_cast *>(image.get()); - auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); uint64_t surfBsaseAddress = 0xABCDEF1000; surfaceState.setSurfaceBaseAddress(surfBsaseAddress); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); @@ -1547,7 +1547,7 @@ HWTEST_F(HwImageTest, givenImageHwWithUnifiedSurfaceAndMcsWhenSettingParamsForMu McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context.getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); auto mockMcsGmmResInfo = reinterpret_cast<::testing::NiceMock *>(mcsAlloc->getDefaultGmm()->gmmResourceInfo.get()); mockMcsGmmResInfo->setUnifiedAuxTranslationCapable(); diff --git a/unit_tests/mem_obj/image_tiled_tests.cpp b/unit_tests/mem_obj/image_tiled_tests.cpp index fcac8587e9..e1e1d2e010 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) { info.imgDesc = &imageDesc; info.plane = GMM_NO_PLANE; - auto gmm = MockGmm::queryImgParams(info); + auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), info); alloc->setDefaultGmm(gmm.release()); @@ -136,7 +136,7 @@ TEST_P(CreateNonTiledImageTest, isTiledImageIsNotSetForNonTiledSharedImage) { info.imgDesc = &imageDesc; info.plane = GMM_NO_PLANE; - auto gmm = MockGmm::queryImgParams(info); + auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), info); alloc->setDefaultGmm(gmm.release()); diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index 3545e40174..1d38287300 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -305,7 +305,7 @@ TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) { context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->setDefaultGmm(new Gmm(nullptr, 1, false)); + allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_WRITE, 0, 0); MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); @@ -339,7 +339,7 @@ TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) { context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->setDefaultGmm(new Gmm(nullptr, 1, false)); + allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_WRITE, 0, 0); MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); diff --git a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl index 00dbee261c..1cbe56deb0 100644 --- a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl +++ b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl @@ -114,6 +114,7 @@ TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest, givenAllocatio AllocationProperties properties(0, true, 0, allocType, false); MockMemoryManager mockMemoryManager; + mockMemoryManager.mockExecutionEnvironment->initGmm(); MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); EXPECT_TRUE(allocData.flags.allow32Bit); @@ -127,6 +128,7 @@ TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest, given64kbAllow AllocationProperties properties(0, true, 10, allocType, false); MockMemoryManager mockMemoryManager(true, false); + mockMemoryManager.mockExecutionEnvironment->initGmm(); MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); bool bufferCompressedType = (allocType == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); EXPECT_TRUE(allocData.flags.allow64kbPages); @@ -204,6 +206,7 @@ TEST(MemoryManagerTest, givenForced32BitSetWhenGraphicsMemoryFor32BitAllowedType TEST(MemoryManagerTest, givenEnabledShareableWhenGraphicsAllocationIsAllocatedThenAllocationIsReturned) { MockExecutionEnvironment executionEnvironment(*platformDevices); + executionEnvironment.initGmm(); MockMemoryManager memoryManager(false, false, executionEnvironment); AllocationData allocData; @@ -221,6 +224,7 @@ TEST(MemoryManagerTest, givenEnabledShareableWhenGraphicsAllocationIsAllocatedTh TEST(MemoryManagerTest, givenEnabledShareableWhenGraphicsAllocationIsCalledAndSystemMemoryFailsThenNullAllocationIsReturned) { MockExecutionEnvironment executionEnvironment(*platformDevices); + executionEnvironment.initGmm(); MockMemoryManager memoryManager(false, false, executionEnvironment); AllocationData allocData; @@ -274,6 +278,7 @@ TEST(MemoryManagerTest, givenForced32BitDisabledWhenGraphicsMemoryWith32BitFlagF TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryMustBeHostMemoryAndIsAllocatedWithNullptrForBufferThen64kbAllocationIsReturned) { MockExecutionEnvironment executionEnvironment(*platformDevices); + executionEnvironment.initGmm(); MockMemoryManager memoryManager(true, false, executionEnvironment); AllocationData allocData; AllocationProperties properties(0, true, 10, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, false); diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 38f00a6496..e93f5a9e80 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -763,9 +763,10 @@ TEST(OsAgnosticMemoryManager, givenHostPointerRequiringCopyWhenAllocateGraphicsM TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerAndUnifiedAuxCapableAllocationWhenMappingThenReturnFalse) { MockExecutionEnvironment executionEnvironment(*platformDevices); + executionEnvironment.initGmm(); OsAgnosticMemoryManager memoryManager(executionEnvironment); - auto gmm = new Gmm(nullptr, 123, false); + auto gmm = new Gmm(executionEnvironment.getGmmClientContext(), nullptr, 123, false); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->setDefaultGmm(gmm); @@ -790,6 +791,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateGraphicsMemoryIsCall TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemory64kbIsCalledThenMemoryPoolIsSystem64KBPages) { MockExecutionEnvironment executionEnvironment(*platformDevices); + executionEnvironment.initGmm(); MockMemoryManager memoryManager(true, false, executionEnvironment); AllocationData allocationData; allocationData.size = 4096u; @@ -1290,7 +1292,7 @@ TEST(MemoryManager, givenInteProcessShareableWhenAllocatingGraphicsMemoryThenAll } TEST_F(MemoryAllocatorTest, GivenSizeWhenGmmIsCreatedThenSuccess) { - Gmm *gmm = new Gmm(nullptr, 65536, false); + Gmm *gmm = new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 65536, false); EXPECT_NE(nullptr, gmm); delete gmm; } @@ -1836,7 +1838,7 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIs64KSuitableThenStandard64kHeapIsUsed) { GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; - auto gmm = std::make_unique(nullptr, 0, false); + auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = true; allocation.setDefaultGmm(gmm.get()); @@ -1845,7 +1847,7 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIsNot64KSuitableThenStandardHeapIsUsed) { GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; - auto gmm = std::make_unique(nullptr, 0, false); + auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = false; allocation.setDefaultGmm(gmm.get()); diff --git a/unit_tests/memory_manager/unified_memory_manager_tests.cpp b/unit_tests/memory_manager/unified_memory_manager_tests.cpp index 626db0fa48..d9b4d115c7 100644 --- a/unit_tests/memory_manager/unified_memory_manager_tests.cpp +++ b/unit_tests/memory_manager/unified_memory_manager_tests.cpp @@ -28,6 +28,7 @@ struct SVMMemoryAllocatorFixture { if (!svmSupported) { GTEST_SKIP(); } + executionEnvironment.initGmm(); memoryManager = std::make_unique(false, enableLocalMemory, executionEnvironment); svmManager = std::make_unique(memoryManager.get()); if (enableLocalMemory) { diff --git a/unit_tests/mocks/mock_gmm.h b/unit_tests/mocks/mock_gmm.h index 01189b39cd..df5a2444fc 100644 --- a/unit_tests/mocks/mock_gmm.h +++ b/unit_tests/mocks/mock_gmm.h @@ -22,10 +22,10 @@ class MockGmm : public Gmm { using Gmm::Gmm; using Gmm::setupImageResourceParams; - MockGmm() : Gmm(nullptr, 1, false){}; + MockGmm() : Gmm(nullptr, nullptr, 1, false){}; - static std::unique_ptr queryImgParams(ImageInfo &imgInfo) { - return std::unique_ptr(new Gmm(imgInfo, {})); + static std::unique_ptr queryImgParams(GmmClientContext *clientContext, ImageInfo &imgInfo) { + return std::unique_ptr(new Gmm(clientContext, imgInfo, {})); } static ImageInfo initImgInfo(cl_image_desc &imgDesc, int baseMipLevel, const SurfaceFormatInfo *surfaceFormat) { diff --git a/unit_tests/mocks/mock_gmm_resource_info.cpp b/unit_tests/mocks/mock_gmm_resource_info.cpp index b96ba3e146..96a5f4cbaf 100644 --- a/unit_tests/mocks/mock_gmm_resource_info.cpp +++ b/unit_tests/mocks/mock_gmm_resource_info.cpp @@ -13,14 +13,14 @@ using namespace ::testing; namespace NEO { -GmmResourceInfo *GmmResourceInfo::create(GMM_RESCREATE_PARAMS *resourceCreateParams) { +GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams) { if (resourceCreateParams->Type == GMM_RESOURCE_TYPE::RESOURCE_INVALID) { return nullptr; } return new ::testing::NiceMock(resourceCreateParams); } -GmmResourceInfo *GmmResourceInfo::create(GMM_RESOURCE_INFO *inputGmmResourceInfo) { +GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) { return new ::testing::NiceMock(inputGmmResourceInfo); } diff --git a/unit_tests/mocks/mock_memory_manager.cpp b/unit_tests/mocks/mock_memory_manager.cpp index be526609c9..13d0942063 100644 --- a/unit_tests/mocks/mock_memory_manager.cpp +++ b/unit_tests/mocks/mock_memory_manager.cpp @@ -61,7 +61,7 @@ GraphicsAllocation *MockMemoryManager::allocateGraphicsMemory64kb(const Allocati auto allocation = OsAgnosticMemoryManager::allocateGraphicsMemory64kb(allocationData); if (allocation) { - allocation->setDefaultGmm(new Gmm(allocation->getUnderlyingBuffer(), allocationData.size, false, preferRenderCompressedFlagPassed, true, {})); + allocation->setDefaultGmm(new Gmm(executionEnvironment.getGmmClientContext(), allocation->getUnderlyingBuffer(), allocationData.size, false, preferRenderCompressedFlagPassed, true, {})); allocation->getDefaultGmm()->isRenderCompressed = preferRenderCompressedFlagPassed; } return allocation; 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 54461573e3..8a3621b131 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -2132,7 +2132,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndUnifiedAuxCapableAllocation mock->ioctl_expected.gemWait = 1; mock->ioctl_expected.gemClose = 1; - auto gmm = new Gmm(nullptr, 123, false); + auto gmm = new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 123, false); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->setDefaultGmm(gmm); diff --git a/unit_tests/os_interface/windows/file_logger_win_tests.cpp b/unit_tests/os_interface/windows/file_logger_win_tests.cpp index 61ddda4b86..f856609c6f 100644 --- a/unit_tests/os_interface/windows/file_logger_win_tests.cpp +++ b/unit_tests/os_interface/windows/file_logger_win_tests.cpp @@ -7,6 +7,7 @@ #include "core/debug_settings/debug_settings_manager.h" #include "runtime/gmm_helper/gmm.h" +#include "runtime/platform/platform.h" #include "test.h" #include "unit_tests/os_interface/windows/mock_wddm_allocation.h" #include "unit_tests/utilities/file_logger_tests.h" @@ -27,7 +28,7 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { allocation.handle = 4; allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; - auto gmm = std::make_unique(nullptr, 0, false); + auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false); allocation.setDefaultGmm(gmm.get()); allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; @@ -64,7 +65,7 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIsNotLogg allocation.handle = 4; allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; - auto gmm = std::make_unique(nullptr, 0, false); + auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false); allocation.setDefaultGmm(gmm.get()); allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index ec418d48b8..8b7c4175aa 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -48,7 +48,7 @@ Gmm *getGmm(void *ptr, size_t size) { size_t alignedSize = alignSizeWholePage(ptr, size); void *alignedPtr = alignUp(ptr, 4096); - Gmm *gmm = new Gmm(alignedPtr, alignedSize, false); + Gmm *gmm = new Gmm(platform()->peekExecutionEnvironment()->getGmmClientContext(), alignedPtr, alignedSize, false); EXPECT_NE(gmm->gmmResourceInfo.get(), nullptr); return gmm; } @@ -80,7 +80,7 @@ TEST_F(Wddm20Tests, doubleCreation) { } TEST_F(Wddm20Tests, givenNullPageTableManagerAndRenderCompressedResourceWhenMappingGpuVaThenDontUpdateAuxTable) { - auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 1, false)); auto mockGmmRes = reinterpret_cast(gmm->gmmResourceInfo.get()); mockGmmRes->setUnifiedAuxTranslationCapable(); @@ -450,7 +450,7 @@ TEST_F(Wddm20Tests, makeResidentNonResident) { TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenGraphicsAllocationWithSharedPropertiesIsCreated) { void *pSysMem = (void *)0x1000; - std::unique_ptr gmm(new Gmm(pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); EXPECT_EQ(0u, status); @@ -487,7 +487,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenMapGpuVaWithCpuPtrDepensOnBitness) { void *pSysMem = (void *)0x1000; - std::unique_ptr gmm(new Gmm(pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); EXPECT_EQ(0u, status); @@ -783,7 +783,7 @@ TEST_F(Wddm20Tests, whenCreateAllocation64kFailsThenReturnFalse) { gdi->createAllocation = FailingCreateAllocation::mockCreateAllocation; void *fakePtr = reinterpret_cast(0x123); - auto gmm = std::make_unique(fakePtr, 100, false); + auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), fakePtr, 100, false); WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, fakePtr, 100, nullptr, MemoryPool::MemoryNull); allocation.setDefaultGmm(gmm.get()); 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 a8c8909c7c..2d141d6262 100644 --- a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -77,7 +77,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafListen TEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDafListenerNotifyMapGpuVAIsFedWithCorrectParams) { uint64_t gpuPtr = 0u; - auto gmm = std::make_unique(nullptr, 1, false); + auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 1, false); wddmWithKmDafMock->mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddmWithKmDafMock->getGfxPartition().Standard.Base, wddmWithKmDafMock->getGfxPartition().Standard.Limit, 0u, gpuPtr); @@ -130,7 +130,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenEvictIsCalledThenKmDafListenerNotifyE } TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { - auto gmm = std::make_unique(nullptr, 1, false); + auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 1, false); auto handle = 0u; auto ptr = reinterpret_cast(0x10000); @@ -144,7 +144,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafList } TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { - auto gmm = std::make_unique(nullptr, 1, false); + auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 1, false); auto handle = 0u; wddmWithKmDafMock->createAllocation64k(gmm.get(), handle); @@ -159,7 +159,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafLi TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalledThenKmDafListenerNotifyWriteTargetAndMapGpuVAIsFedWithCorrectParams) { OsHandleStorage storage; OsHandle osHandle = {0}; - auto gmm = std::unique_ptr(new Gmm(nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 1, false)); storage.fragmentStorageData[0].osHandleStorage = &osHandle; storage.fragmentStorageData[0].fragmentSize = 100; storage.fragmentStorageData[0].osHandleStorage->gmm = gmm.get(); 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 4ac241ea3c..f20df59548 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -206,7 +206,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenCreateAllocationFromHa memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - std::unique_ptr gmm(new Gmm(nullptr, 0, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 0, false)); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -226,7 +226,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenAllocationPropertiesWhenCreateAllocatio memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - std::unique_ptr gmm(new Gmm(nullptr, 0, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 0, false)); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -252,7 +252,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenCreateAllocationFromHandleAndMapCallFail memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - auto gmm = std::make_unique(nullptr, 0, false); + auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 0, false); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -448,7 +448,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, 4096u, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0); @@ -465,7 +465,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCalledThenNonNullGraphicsAllocationIsReturned) { void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast(1), 0); @@ -497,7 +497,7 @@ TEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleReturns32BitAllocW auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); memoryManager->setForce32BitAllocations(true); @@ -520,7 +520,7 @@ TEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleDoesNotReturn32Bit auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); memoryManager->setForce32BitAllocations(true); @@ -542,7 +542,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenFreeAllocFromSharedHandl auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, 4096u, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0); @@ -564,7 +564,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerSizeZeroWhenCreateFromShared auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(pSysMem, size, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, size, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0); @@ -579,7 +579,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleFa auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(pSysMem, size, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, size, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); wddm->failOpenSharedHandle = true; @@ -910,7 +910,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT storage.fragmentStorageData[0].osHandleStorage->handle = ALLOCATION_HANDLE; storage.fragmentStorageData[0].freeTheFragment = true; - storage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(pSysMem, 4096u, false); + storage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false); storage.fragmentStorageData[1].osHandleStorage = new OsHandle; storage.fragmentStorageData[1].osHandleStorage->handle = ALLOCATION_HANDLE; @@ -921,7 +921,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT storage.fragmentStorageData[2].osHandleStorage = new OsHandle; storage.fragmentStorageData[2].osHandleStorage->handle = ALLOCATION_HANDLE; storage.fragmentStorageData[2].freeTheFragment = true; - storage.fragmentStorageData[2].osHandleStorage->gmm = new Gmm(pSysMem, 4096u, false); + storage.fragmentStorageData[2].osHandleStorage->gmm = new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false); storage.fragmentStorageData[2].residency = new ResidencyData; memoryManager->cleanOsHandles(storage, 0); @@ -966,7 +966,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCpuMemNotMeetRestriction TEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGpuVaFailThenFailToCreateAllocation) { void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(ptr, size, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false)); memoryManager->setDeferredDeleter(nullptr); setMapGpuVaFailConfigFcn(0, 1); @@ -980,7 +980,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGpuV TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstMapGpuVaFailSecondAfterDrainSuccessThenCreateAllocation) { void *ptr = reinterpret_cast(0x10000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(ptr, size, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false)); MockDeferredDeleter *deleter = new MockDeferredDeleter; memoryManager->setDeferredDeleter(deleter); @@ -996,7 +996,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstMap TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAndMapGpuVaFailSecondAfterDrainFailThenFailToCreateAllocation) { void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(ptr, size, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false)); MockDeferredDeleter *deleter = new MockDeferredDeleter; memoryManager->setDeferredDeleter(deleter); @@ -1160,7 +1160,7 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati handleStorage.fragmentStorageData[0].osHandleStorage = new OsHandle(); handleStorage.fragmentStorageData[0].residency = new ResidencyData(); handleStorage.fragmentStorageData[0].freeTheFragment = true; - handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(ptr, size, false); + handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false); handleStorage.fragmentCount = 1; FragmentStorage fragment = {}; @@ -1194,7 +1194,7 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati handleStorage.fragmentStorageData[0].osHandleStorage = new OsHandle(); handleStorage.fragmentStorageData[0].residency = new ResidencyData(); handleStorage.fragmentStorageData[0].freeTheFragment = true; - handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(ptr, size, false); + handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false); handleStorage.fragmentCount = 1; FragmentStorage fragment = {}; @@ -1459,7 +1459,7 @@ TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThen } TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVaThenMapAuxVa) { - std::unique_ptr gmm(new Gmm(reinterpret_cast(123), 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = true; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm(*executionEnvironment->rootDeviceEnvironments[1].get()); @@ -1530,7 +1530,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleasei } TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGpuVaThenDontMapAuxVa) { - std::unique_ptr gmm(new Gmm(reinterpret_cast(123), 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm(*executionEnvironment->rootDeviceEnvironments[0].get()); @@ -1547,7 +1547,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGp } TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenReturnFalse) { - std::unique_ptr gmm(new Gmm(reinterpret_cast(123), 4096u, false)); + std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm(*executionEnvironment->rootDeviceEnvironments[1].get()); @@ -1567,7 +1567,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUnse auto mockMngr = new NiceMock(); executionEnvironment->rootDeviceEnvironments[1]->pageTableManager.reset(mockMngr); - auto myGmm = new Gmm(reinterpret_cast(123), 4096u, false); + auto myGmm = new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false); myGmm->isRenderCompressed = false; myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1; @@ -1591,7 +1591,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsSetT auto mockMngr = new NiceMock(); executionEnvironment->rootDeviceEnvironments[1]->pageTableManager.reset(mockMngr); - auto myGmm = new Gmm(reinterpret_cast(123), 4096u, false); + auto myGmm = new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false); myGmm->isRenderCompressed = true; myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1; 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 3d73fee88a..ca5e08af07 100644 --- a/unit_tests/sharings/gl/gl_create_from_texture_tests.cpp +++ b/unit_tests/sharings/gl/gl_create_from_texture_tests.cpp @@ -58,7 +58,7 @@ class CreateFromGlTexture : public ::testing::Test { void updateImgInfoAndForceGmm() { imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - gmm = MockGmm::queryImgParams(imgInfo); + gmm = MockGmm::queryImgParams(clContext.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); tempMM.forceAllocationSize = imgInfo.size; tempMM.forceGmm = gmm.get(); @@ -70,7 +70,7 @@ class CreateFromGlTexture : public ::testing::Test { mcsImgDesc.image_width = 128; mcsImgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto mcsImgInfo = MockGmm::initImgInfo(mcsImgDesc, 0, nullptr); - mcsGmm = MockGmm::queryImgParams(mcsImgInfo); + mcsGmm = MockGmm::queryImgParams(clContext.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), mcsImgInfo); tempMM.forceMcsGmm = mcsGmm.get(); } } diff --git a/unit_tests/sharings/gl/gl_reused_buffers_tests.cpp b/unit_tests/sharings/gl/gl_reused_buffers_tests.cpp index 27c7627e2e..99d16bd41f 100644 --- a/unit_tests/sharings/gl/gl_reused_buffers_tests.cpp +++ b/unit_tests/sharings/gl/gl_reused_buffers_tests.cpp @@ -83,7 +83,7 @@ TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenReleasin TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenCreatingThenReuseGmmResourceToo) { std::unique_ptr glBuffer1(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal)); - glBuffer1->getGraphicsAllocation()->setDefaultGmm(new Gmm((void *)0x100, 1, false)); + glBuffer1->getGraphicsAllocation()->setDefaultGmm(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), (void *)0x100, 1, false)); std::unique_ptr glBuffer2(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal)); diff --git a/unit_tests/sharings/gl/gl_sharing_tests.cpp b/unit_tests/sharings/gl/gl_sharing_tests.cpp index 13b925720e..5de2cf0180 100644 --- a/unit_tests/sharings/gl/gl_sharing_tests.cpp +++ b/unit_tests/sharings/gl/gl_sharing_tests.cpp @@ -249,7 +249,7 @@ TEST_F(glSharingTests, givenClGLBufferWhenItIsAcquiredTwiceThenAcuqireIsNotCalle TEST_F(glSharingTests, givenClGLBufferWhenItIsCreatedAndGmmIsAvailableThenItIsUsedInGraphicsAllocation) { void *ptr = (void *)0x1000; - auto gmm = new Gmm(ptr, 4096u, false); + auto gmm = new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), ptr, 4096u, false); mockGlSharing->m_bufferInfoOutput.pGmmResInfo = gmm->gmmResourceInfo->peekHandle(); mockGlSharing->uploadDataToBufferInfo(); diff --git a/unit_tests/sharings/gl/gl_texture_tests.cpp b/unit_tests/sharings/gl/gl_texture_tests.cpp index 7465b45782..721bbb6779 100644 --- a/unit_tests/sharings/gl/gl_texture_tests.cpp +++ b/unit_tests/sharings/gl/gl_texture_tests.cpp @@ -65,7 +65,7 @@ class GlSharingTextureTests : public ::testing::Test { clContext->setSharingFunctions(mockGlSharingFunctions); ASSERT_FALSE(overrideCommandStreamReceiverCreation); - tempMM->forceGmm = MockGmm::queryImgParams(imgInfo); + tempMM->forceGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); tempMM->forceAllocationSize = textureSize; textureSize = imgInfo.size; textureId = 1;