mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-29 00:58:39 +08:00
Move static methods from Gmm to new GmmHelper class
Change-Id: I84fbe94f0e1072324164086b456c71a46ae5040c
This commit is contained in:
committed by
sys_ocldev
parent
a95cca71e4
commit
e18e9fb94e
@@ -75,8 +75,8 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) {
|
||||
DeviceFactory::numDevices = devNum;
|
||||
DeviceFactory::hwInfos = ptr;
|
||||
|
||||
return Gmm::initContext(hwInfos->pPlatform, hwInfos->pSkuTable,
|
||||
hwInfos->pWaTable, hwInfos->pSysInfo);
|
||||
return GmmHelper::initContext(hwInfos->pPlatform, hwInfos->pSkuTable,
|
||||
hwInfos->pWaTable, hwInfos->pSysInfo);
|
||||
}
|
||||
|
||||
void DeviceFactory::releaseDevices() {
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "drm/i915_drm.h"
|
||||
#include "drm/drm.h"
|
||||
|
||||
#include "runtime/gmm_helper/gmm.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/gmm_helper/resource_info.h"
|
||||
|
||||
@@ -209,7 +210,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t
|
||||
}
|
||||
|
||||
GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) {
|
||||
if (!Gmm::allowTiling(*imgInfo.imgDesc)) {
|
||||
if (!GmmHelper::allowTiling(*imgInfo.imgDesc)) {
|
||||
auto alloc = allocateGraphicsMemory(imgInfo.size, MemoryConstants::preferredAlignment);
|
||||
if (alloc) {
|
||||
alloc->gmm = gmm;
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = nullptr;
|
||||
decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr;
|
||||
decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr;
|
||||
decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr;
|
||||
decltype(GmmHelper::initGlobalContextFunc) GmmHelper::initGlobalContextFunc = nullptr;
|
||||
decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFunc = nullptr;
|
||||
decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr;
|
||||
decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr;
|
||||
|
||||
void Gmm::loadLib() {
|
||||
Gmm::initGlobalContextFunc = GmmInitGlobalContext;
|
||||
Gmm::destroyGlobalContextFunc = GmmDestroyGlobalContext;
|
||||
Gmm::createClientContextFunc = GmmCreateClientContext;
|
||||
Gmm::deleteClientContextFunc = GmmDeleteClientContext;
|
||||
void GmmHelper::loadLib() {
|
||||
GmmHelper::initGlobalContextFunc = GmmInitGlobalContext;
|
||||
GmmHelper::destroyGlobalContextFunc = GmmDestroyGlobalContext;
|
||||
GmmHelper::createClientContextFunc = GmmCreateClientContext;
|
||||
GmmHelper::deleteClientContextFunc = GmmDeleteClientContext;
|
||||
isLoaded = true;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -34,13 +34,13 @@ GMM_STATUS(GMM_STDCALL *myPfnCreateSingletonContext)
|
||||
GMM_STATUS GMM_STDCALL myGmmInitGlobalContext(const PLATFORM Platform, const SKU_FEATURE_TABLE *pSkuTable, const WA_TABLE *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo, GMM_CLIENT ClientType) {
|
||||
return myPfnCreateSingletonContext(Platform, pSkuTable, pWaTable, pGtSysInfo);
|
||||
}
|
||||
decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = &myGmmInitGlobalContext;
|
||||
decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr;
|
||||
decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr;
|
||||
decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr;
|
||||
decltype(GmmHelper::initGlobalContextFunc) GmmHelper::initGlobalContextFunc = &myGmmInitGlobalContext;
|
||||
decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFunc = nullptr;
|
||||
decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr;
|
||||
decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr;
|
||||
|
||||
std::unique_ptr<OsLibrary> gmmLib;
|
||||
void Gmm::loadLib() {
|
||||
void GmmHelper::loadLib() {
|
||||
gmmLib.reset(OsLibrary::load(Os::gmmDllName));
|
||||
|
||||
UNRECOVERABLE_IF(!gmmLib);
|
||||
@@ -50,10 +50,10 @@ void Gmm::loadLib() {
|
||||
auto status = openGmmFunc(&entries);
|
||||
if (status == GMM_SUCCESS) {
|
||||
myPfnCreateSingletonContext = entries.pfnCreateSingletonContext;
|
||||
Gmm::destroyGlobalContextFunc = entries.pfnDestroySingletonContext;
|
||||
Gmm::createClientContextFunc = entries.pfnCreateClientContext;
|
||||
Gmm::deleteClientContextFunc = entries.pfnDeleteClientContext;
|
||||
isLoaded = myPfnCreateSingletonContext && Gmm::destroyGlobalContextFunc && Gmm::createClientContextFunc && Gmm::deleteClientContextFunc;
|
||||
GmmHelper::destroyGlobalContextFunc = entries.pfnDestroySingletonContext;
|
||||
GmmHelper::createClientContextFunc = entries.pfnCreateClientContext;
|
||||
GmmHelper::deleteClientContextFunc = entries.pfnDeleteClientContext;
|
||||
isLoaded = myPfnCreateSingletonContext && GmmHelper::destroyGlobalContextFunc && GmmHelper::createClientContextFunc && GmmHelper::deleteClientContextFunc;
|
||||
}
|
||||
}
|
||||
UNRECOVERABLE_IF(!isLoaded);
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = nullptr;
|
||||
decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr;
|
||||
decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr;
|
||||
decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr;
|
||||
decltype(GmmHelper::initGlobalContextFunc) GmmHelper::initGlobalContextFunc = nullptr;
|
||||
decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFunc = nullptr;
|
||||
decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr;
|
||||
decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr;
|
||||
|
||||
void Gmm::loadLib() {
|
||||
Gmm::initGlobalContextFunc = GmmInitGlobalContext;
|
||||
Gmm::destroyGlobalContextFunc = GmmDestroyGlobalContext;
|
||||
Gmm::createClientContextFunc = GmmCreateClientContext;
|
||||
Gmm::deleteClientContextFunc = GmmDeleteClientContext;
|
||||
void GmmHelper::loadLib() {
|
||||
GmmHelper::initGlobalContextFunc = GmmInitGlobalContext;
|
||||
GmmHelper::destroyGlobalContextFunc = GmmDestroyGlobalContext;
|
||||
GmmHelper::createClientContextFunc = GmmCreateClientContext;
|
||||
GmmHelper::deleteClientContextFunc = GmmDeleteClientContext;
|
||||
isLoaded = true;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/os_interface/windows/gdi_interface.h"
|
||||
#include "runtime/os_interface/windows/kmdaf_listener.h"
|
||||
#include "runtime/gmm_helper/gmm.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/gmm_helper/resource_info.h"
|
||||
#include "runtime/gmm_helper/page_table_mngr.h"
|
||||
@@ -395,7 +396,7 @@ bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr
|
||||
}
|
||||
|
||||
status = gdi->mapGpuVirtualAddress(&MapGPUVA);
|
||||
gpuPtr = Gmm::canonize(MapGPUVA.VirtualAddress);
|
||||
gpuPtr = GmmHelper::canonize(MapGPUVA.VirtualAddress);
|
||||
|
||||
if (status == STATUS_PENDING) {
|
||||
interlockedMax(currentPagingFenceValue, MapGPUVA.PagingFenceValue);
|
||||
@@ -420,7 +421,7 @@ bool Wddm::freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DKMT_FREEGPUVIRTUALADDRESS FreeGPUVA = {0};
|
||||
FreeGPUVA.hAdapter = adapter;
|
||||
FreeGPUVA.BaseAddress = Gmm::decanonize(gpuPtr);
|
||||
FreeGPUVA.BaseAddress = GmmHelper::decanonize(gpuPtr);
|
||||
FreeGPUVA.Size = size;
|
||||
|
||||
status = gdi->freeGpuVirtualAddress(&FreeGPUVA);
|
||||
@@ -632,7 +633,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
|
||||
alloc->handle = allocationInfo[0].hAllocation;
|
||||
alloc->resourceHandle = OpenResource.hResource;
|
||||
|
||||
alloc->gmm = Gmm::create((PGMM_RESOURCE_INFO)(allocationInfo[0].pPrivateDriverData));
|
||||
alloc->gmm = GmmHelper::create((PGMM_RESOURCE_INFO)(allocationInfo[0].pPrivateDriverData));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -668,7 +669,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
|
||||
alloc->handle = allocationInfo2[0].hAllocation;
|
||||
alloc->resourceHandle = openResourceFromNtHandle.hResource;
|
||||
|
||||
alloc->gmm = Gmm::create((PGMM_RESOURCE_INFO)(allocationInfo2[0].pPrivateDriverData));
|
||||
alloc->gmm = GmmHelper::create((PGMM_RESOURCE_INFO)(allocationInfo2[0].pPrivateDriverData));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "runtime/memory_manager/host_ptr_defines.h"
|
||||
#include "runtime/utilities/debug_settings_reader.h"
|
||||
#include "runtime/gmm_helper/gmm_lib.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "gmm_memory.h"
|
||||
#include <memory>
|
||||
|
||||
@@ -42,13 +42,13 @@ Wddm::VirtualAllocFcn getVirtualAlloc() {
|
||||
}
|
||||
|
||||
bool Wddm::initGmmContext() {
|
||||
return Gmm::initContext(gfxPlatform.get(),
|
||||
featureTable.get(),
|
||||
waTable.get(),
|
||||
gtSystemInfo.get());
|
||||
return GmmHelper::initContext(gfxPlatform.get(),
|
||||
featureTable.get(),
|
||||
waTable.get(),
|
||||
gtSystemInfo.get());
|
||||
}
|
||||
|
||||
void Wddm::destroyGmmContext() {
|
||||
Gmm::destroyContext();
|
||||
GmmHelper::destroyContext();
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/ptr_math.h"
|
||||
#include "runtime/gmm_helper/gmm.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/gmm_helper/resource_info.h"
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
@@ -60,7 +61,7 @@ void APIENTRY WddmMemoryManager::trimCallback(_Inout_ D3DKMT_TRIMNOTIFICATION *t
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) {
|
||||
if (!Gmm::allowTiling(*imgInfo.imgDesc) && imgInfo.mipCount == 0) {
|
||||
if (!GmmHelper::allowTiling(*imgInfo.imgDesc) && imgInfo.mipCount == 0) {
|
||||
delete gmm;
|
||||
return allocateGraphicsMemory(imgInfo.size, MemoryConstants::preferredAlignment);
|
||||
}
|
||||
@@ -80,7 +81,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, s
|
||||
|
||||
auto wddmAllocation = new WddmAllocation(nullptr, sizeAligned, nullptr, sizeAligned, nullptr);
|
||||
|
||||
gmm = Gmm::create(nullptr, sizeAligned, false);
|
||||
gmm = GmmHelper::create(nullptr, sizeAligned, false);
|
||||
wddmAllocation->gmm = gmm;
|
||||
|
||||
if (!wddm->createAllocation64k(wddmAllocation)) {
|
||||
@@ -114,7 +115,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_
|
||||
auto wddmAllocation = new WddmAllocation(pSysMem, sizeAligned, pSysMem, sizeAligned, nullptr);
|
||||
wddmAllocation->cpuPtrAllocated = true;
|
||||
|
||||
gmm = Gmm::create(pSysMem, sizeAligned, uncacheable);
|
||||
gmm = GmmHelper::create(pSysMem, sizeAligned, uncacheable);
|
||||
|
||||
wddmAllocation->gmm = gmm;
|
||||
|
||||
@@ -149,7 +150,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, const
|
||||
auto allocation = new WddmAllocation(ptr, size, ptrAligned, sizeAligned, reserve);
|
||||
allocation->allocationOffset = offset;
|
||||
|
||||
Gmm *gmm = Gmm::create(ptrAligned, sizeAligned, false);
|
||||
Gmm *gmm = GmmHelper::create(ptrAligned, sizeAligned, false);
|
||||
allocation->gmm = gmm;
|
||||
if (createWddmAllocation(allocation, AllocationOrigin::EXTERNAL_ALLOCATION)) {
|
||||
return allocation;
|
||||
@@ -188,7 +189,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size,
|
||||
wddmAllocation->is32BitAllocation = true;
|
||||
wddmAllocation->allocationOffset = offset;
|
||||
|
||||
gmm = Gmm::create(ptrAligned, sizeAligned, false);
|
||||
gmm = GmmHelper::create(ptrAligned, sizeAligned, false);
|
||||
wddmAllocation->gmm = gmm;
|
||||
|
||||
if (!createWddmAllocation(wddmAllocation, allocationOrigin)) {
|
||||
@@ -200,7 +201,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size,
|
||||
|
||||
wddmAllocation->is32BitAllocation = true;
|
||||
auto baseAddress = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? allocator32Bit->getBase() : this->wddm->getGfxPartition().Heap32[1].Base;
|
||||
wddmAllocation->gpuBaseAddress = Gmm::canonize(baseAddress);
|
||||
wddmAllocation->gpuBaseAddress = GmmHelper::canonize(baseAddress);
|
||||
|
||||
return wddmAllocation;
|
||||
}
|
||||
@@ -231,7 +232,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
|
||||
} else if (requireSpecificBitness && this->force32bitAllocations) {
|
||||
is32BitAllocation = true;
|
||||
allocation->is32BitAllocation = true;
|
||||
allocation->gpuBaseAddress = Gmm::canonize(allocator32Bit->getBase());
|
||||
allocation->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase());
|
||||
}
|
||||
status = wddm->mapGpuVirtualAddress(allocation, ptr, size, is32BitAllocation, false, false);
|
||||
DEBUG_BREAK_IF(!status);
|
||||
@@ -363,7 +364,7 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle();
|
||||
handleStorage.fragmentStorageData[i].residency = new ResidencyData();
|
||||
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage->gmm = Gmm::create(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, false);
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage->gmm = GmmHelper::create(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, false);
|
||||
allocatedFragmentIndexes[allocatedFragmentsCounter] = i;
|
||||
allocatedFragmentsCounter++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user