mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Store GmmHelper in Gmm class
Store GmmHelper in Gmm class instead of GmmClientContext Related-To: NEO-6523 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7eb70775ea
commit
9b778863b4
@@ -20,8 +20,8 @@
|
||||
#include "shared/source/memory_manager/allocation_type.h"
|
||||
|
||||
namespace NEO {
|
||||
Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage,
|
||||
bool preferCompressed, StorageInfo storageInfo, bool allowLargePages) : clientContext(clientContext) {
|
||||
Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_t alignment, GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage,
|
||||
bool preferCompressed, StorageInfo storageInfo, bool allowLargePages) : gmmHelper(gmmHelper) {
|
||||
resourceParams.Type = RESOURCE_BUFFER;
|
||||
resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
|
||||
resourceParams.BaseWidth64 = static_cast<uint64_t>(alignedSize);
|
||||
@@ -57,24 +57,24 @@ Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t aligned
|
||||
applyAppResource(storageInfo);
|
||||
applyDebugOverrides();
|
||||
|
||||
gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, &resourceParams));
|
||||
gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &resourceParams));
|
||||
}
|
||||
|
||||
Gmm::Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm) : clientContext(clientContext) {
|
||||
gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, inputGmm));
|
||||
Gmm::Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm) : gmmHelper(gmmHelper) {
|
||||
gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), inputGmm));
|
||||
applyDebugOverrides();
|
||||
}
|
||||
|
||||
Gmm::~Gmm() = default;
|
||||
|
||||
Gmm::Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo, bool preferCompressed) : clientContext(clientContext) {
|
||||
Gmm::Gmm(GmmHelper *gmmHelper, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo, bool preferCompressed) : gmmHelper(gmmHelper) {
|
||||
this->resourceParams = {};
|
||||
setupImageResourceParams(inputOutputImgInfo, preferCompressed);
|
||||
applyMemoryFlags(storageInfo);
|
||||
applyAppResource(storageInfo);
|
||||
applyDebugOverrides();
|
||||
|
||||
this->gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, &this->resourceParams));
|
||||
this->gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &this->resourceParams));
|
||||
UNRECOVERABLE_IF(this->gmmResourceInfo == nullptr);
|
||||
|
||||
queryImageParams(inputOutputImgInfo);
|
||||
@@ -113,11 +113,11 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferCompressed) {
|
||||
|
||||
resourceParams.Flags.Info.Linear = imgInfo.linearStorage;
|
||||
|
||||
auto &hwHelper = HwHelper::get(clientContext->getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
auto &hwHelper = HwHelper::get(gmmHelper->getClientContext()->getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
|
||||
resourceParams.NoGfxMemory = 1; // dont allocate, only query for params
|
||||
|
||||
resourceParams.Usage = CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false, *clientContext->getHardwareInfo());
|
||||
resourceParams.Usage = CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false, *gmmHelper->getClientContext()->getHardwareInfo());
|
||||
|
||||
resourceParams.Format = imgInfo.surfaceFormat->GMMSurfaceFormat;
|
||||
resourceParams.Flags.Gpu.Texture = 1;
|
||||
@@ -136,7 +136,7 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferCompressed) {
|
||||
}
|
||||
|
||||
void Gmm::applyAuxFlagsForBuffer(bool preferCompression) {
|
||||
auto hardwareInfo = clientContext->getHardwareInfo();
|
||||
auto hardwareInfo = gmmHelper->getClientContext()->getHardwareInfo();
|
||||
bool allowCompression = HwHelper::compressedBuffersSupported(*hardwareInfo) &&
|
||||
preferCompression;
|
||||
|
||||
@@ -153,13 +153,13 @@ void Gmm::applyAuxFlagsForBuffer(bool preferCompression) {
|
||||
void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferCompressed) {
|
||||
uint8_t compressionFormat;
|
||||
if (this->resourceParams.Flags.Info.MediaCompressed) {
|
||||
compressionFormat = clientContext->getMediaSurfaceStateCompressionFormat(imgInfo.surfaceFormat->GMMSurfaceFormat);
|
||||
compressionFormat = gmmHelper->getClientContext()->getMediaSurfaceStateCompressionFormat(imgInfo.surfaceFormat->GMMSurfaceFormat);
|
||||
} else {
|
||||
compressionFormat = clientContext->getSurfaceStateCompressionFormat(imgInfo.surfaceFormat->GMMSurfaceFormat);
|
||||
compressionFormat = gmmHelper->getClientContext()->getSurfaceStateCompressionFormat(imgInfo.surfaceFormat->GMMSurfaceFormat);
|
||||
}
|
||||
|
||||
bool compressionFormatSupported = false;
|
||||
if (clientContext->getHardwareInfo()->featureTable.flags.ftrFlatPhysCCS) {
|
||||
if (gmmHelper->getClientContext()->getHardwareInfo()->featureTable.flags.ftrFlatPhysCCS) {
|
||||
compressionFormatSupported = compressionFormat != GMM_FLATCCS_FORMAT::GMM_FLATCCS_FORMAT_INVALID;
|
||||
} else {
|
||||
compressionFormatSupported = compressionFormat != GMM_E2ECOMP_FORMAT::GMM_E2ECOMP_FORMAT_INVALID;
|
||||
@@ -170,7 +170,7 @@ void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferCompressed) {
|
||||
imgInfo.surfaceFormat->GMMSurfaceFormat == GMM_FORMAT_YVYU ||
|
||||
imgInfo.surfaceFormat->GMMSurfaceFormat == GMM_FORMAT_VYUY;
|
||||
|
||||
auto hwInfo = clientContext->getHardwareInfo();
|
||||
auto hwInfo = gmmHelper->getClientContext()->getHardwareInfo();
|
||||
|
||||
bool allowCompression = HwHelper::compressedImagesSupported(*hwInfo) &&
|
||||
preferCompressed &&
|
||||
@@ -248,7 +248,7 @@ void Gmm::queryImageParams(ImageInfo &imgInfo) {
|
||||
}
|
||||
|
||||
uint32_t Gmm::queryQPitch(GMM_RESOURCE_TYPE resType) {
|
||||
if (clientContext->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_GEN8_CORE && resType == GMM_RESOURCE_TYPE::RESOURCE_3D) {
|
||||
if (gmmHelper->getClientContext()->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_GEN8_CORE && resType == GMM_RESOURCE_TYPE::RESOURCE_3D) {
|
||||
return 0;
|
||||
}
|
||||
return gmmResourceInfo->getQPitch();
|
||||
@@ -332,7 +332,7 @@ uint32_t Gmm::getAuxQPitch() {
|
||||
}
|
||||
|
||||
void Gmm::applyMemoryFlags(StorageInfo &storageInfo) {
|
||||
auto hardwareInfo = clientContext->getHardwareInfo();
|
||||
auto hardwareInfo = gmmHelper->getClientContext()->getHardwareInfo();
|
||||
|
||||
if (hardwareInfo->featureTable.flags.ftrLocalMemory) {
|
||||
if (storageInfo.systemMemoryPlacement) {
|
||||
|
||||
@@ -18,16 +18,16 @@ enum class ImagePlane;
|
||||
struct HardwareInfo;
|
||||
struct ImageInfo;
|
||||
class GmmResourceInfo;
|
||||
class GmmClientContext;
|
||||
class GmmHelper;
|
||||
|
||||
class Gmm {
|
||||
public:
|
||||
virtual ~Gmm();
|
||||
Gmm() = delete;
|
||||
Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo, bool preferCompressed);
|
||||
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment,
|
||||
Gmm(GmmHelper *gmmHelper, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo, bool preferCompressed);
|
||||
Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_t alignment,
|
||||
GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage, bool preferCompressed, StorageInfo storageInfo, bool allowLargePages);
|
||||
Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm);
|
||||
Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm);
|
||||
|
||||
void queryImageParams(ImageInfo &inputOutputImgInfo);
|
||||
|
||||
@@ -57,6 +57,6 @@ class Gmm {
|
||||
bool extraMemoryFlagsRequired();
|
||||
void applyExtraMemoryFlags(const StorageInfo &storageInfo);
|
||||
void applyDebugOverrides();
|
||||
GmmClientContext *clientContext = nullptr;
|
||||
GmmHelper *gmmHelper = nullptr;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -572,7 +572,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
|
||||
}
|
||||
|
||||
GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForImage(const AllocationData &allocationData) {
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo,
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), *allocationData.imgInfo,
|
||||
allocationData.storageInfo, allocationData.flags.preferCompressed);
|
||||
|
||||
// AllocationData needs to be reconfigured for System Memory paths
|
||||
|
||||
@@ -109,7 +109,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment
|
||||
auto pHwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
if (HwHelper::get(pHwInfo->platform.eRenderCoreFamily).compressedBuffersSupported(*pHwInfo) &&
|
||||
allocationData.flags.preferCompressed) {
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(),
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(),
|
||||
allocationData.hostPtr,
|
||||
sizeAligned,
|
||||
alignment,
|
||||
@@ -160,7 +160,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(const Al
|
||||
if (memoryAllocation) {
|
||||
static_cast<MemoryAllocation *>(memoryAllocation)->overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
if (memoryAllocation->getDefaultGmm() == nullptr) {
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(),
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(),
|
||||
allocationData.hostPtr,
|
||||
allocationDataAlign.size,
|
||||
allocationDataAlign.alignment,
|
||||
@@ -231,7 +231,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedH
|
||||
graphicsAllocation->set32BitAllocation(requireSpecificBitness);
|
||||
|
||||
if (properties.imgInfo) {
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties), false);
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmHelper(), *properties.imgInfo, createStorageInfoFromProperties(properties), false);
|
||||
graphicsAllocation->setDefaultGmm(gmm);
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ void OsAgnosticMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage, uin
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocateMemoryByKMD(const AllocationData &allocationData) {
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr,
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr,
|
||||
allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, *hwInfo),
|
||||
allocationData.flags.preferCompressed, allocationData.storageInfo, true);
|
||||
|
||||
@@ -479,7 +479,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
|
||||
if (allocationData.type == AllocationType::IMAGE ||
|
||||
allocationData.type == AllocationType::SHARED_RESOURCE_COPY) {
|
||||
allocationData.imgInfo->useLocalMemory = true;
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo,
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), *allocationData.imgInfo,
|
||||
allocationData.storageInfo, allocationData.flags.preferCompressed);
|
||||
sizeAligned64k = alignUp(allocationData.imgInfo->size, MemoryConstants::pageSize64k);
|
||||
} else {
|
||||
@@ -487,7 +487,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
|
||||
if (DebugManager.flags.RenderCompressedBuffersEnabled.get() &&
|
||||
allocationData.flags.preferCompressed) {
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(),
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(),
|
||||
allocationData.hostPtr,
|
||||
sizeAligned64k,
|
||||
MemoryConstants::pageSize64k,
|
||||
|
||||
@@ -506,7 +506,7 @@ GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData &
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
StorageInfo systemMemoryStorageInfo = {};
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr,
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr,
|
||||
allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, *hwInfo), false, systemMemoryStorageInfo, true);
|
||||
size_t bufferSize = allocationData.size;
|
||||
uint64_t gpuRange = acquireGpuRange(bufferSize, allocationData.rootDeviceIndex, HeapIndex::HEAP_STANDARD64KB);
|
||||
@@ -723,7 +723,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
}
|
||||
}
|
||||
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmClientContext(), *properties.imgInfo,
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmHelper(), *properties.imgInfo,
|
||||
createStorageInfoFromProperties(properties), properties.flags.preferCompressed);
|
||||
|
||||
drmAllocation->setDefaultGmm(gmm);
|
||||
@@ -1222,7 +1222,7 @@ void DrmMemoryManager::unlockResourceInLocalMemoryImpl(BufferObject *bo) {
|
||||
bo->setLockedAddress(nullptr);
|
||||
}
|
||||
|
||||
void createColouredGmms(GmmClientContext *clientContext, DrmAllocation &allocation, const StorageInfo &storageInfo, bool compression) {
|
||||
void createColouredGmms(GmmHelper *gmmHelper, DrmAllocation &allocation, const StorageInfo &storageInfo, bool compression) {
|
||||
DEBUG_BREAK_IF(storageInfo.colouringPolicy == ColouringPolicy::DeviceCountBased && storageInfo.colouringGranularity != MemoryConstants::pageSize64k);
|
||||
|
||||
auto remainingSize = alignUp(allocation.getUnderlyingBufferSize(), storageInfo.colouringGranularity);
|
||||
@@ -1251,11 +1251,11 @@ void createColouredGmms(GmmClientContext *clientContext, DrmAllocation &allocati
|
||||
remainingSize -= currentSize;
|
||||
StorageInfo limitedStorageInfo = storageInfo;
|
||||
limitedStorageInfo.memoryBanks &= (1u << (handleId % banksCnt));
|
||||
auto gmm = new Gmm(clientContext,
|
||||
auto gmm = new Gmm(gmmHelper,
|
||||
nullptr,
|
||||
currentSize,
|
||||
0u,
|
||||
CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false, *clientContext->getHardwareInfo()),
|
||||
CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false, *gmmHelper->getHardwareInfo()),
|
||||
compression,
|
||||
limitedStorageInfo,
|
||||
true);
|
||||
@@ -1263,14 +1263,14 @@ void createColouredGmms(GmmClientContext *clientContext, DrmAllocation &allocati
|
||||
}
|
||||
}
|
||||
|
||||
void fillGmmsInAllocation(GmmClientContext *clientContext, DrmAllocation *allocation, const StorageInfo &storageInfo) {
|
||||
void fillGmmsInAllocation(GmmHelper *gmmHelper, DrmAllocation *allocation, const StorageInfo &storageInfo) {
|
||||
auto alignedSize = alignUp(allocation->getUnderlyingBufferSize(), MemoryConstants::pageSize64k);
|
||||
for (auto handleId = 0u; handleId < storageInfo.getNumBanks(); handleId++) {
|
||||
StorageInfo limitedStorageInfo = storageInfo;
|
||||
limitedStorageInfo.memoryBanks &= 1u << handleId;
|
||||
limitedStorageInfo.pageTablesVisibility &= 1u << handleId;
|
||||
auto gmm = new Gmm(clientContext, nullptr, alignedSize, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false, *clientContext->getHardwareInfo()), false, limitedStorageInfo, true);
|
||||
auto gmm = new Gmm(gmmHelper, nullptr, alignedSize, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false, *gmmHelper->getHardwareInfo()), false, limitedStorageInfo, true);
|
||||
allocation->setGmm(gmm, handleId);
|
||||
}
|
||||
}
|
||||
@@ -1337,7 +1337,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
|
||||
bool createSingleHandle = 1 == numHandles;
|
||||
if (allocationData.type == AllocationType::IMAGE) {
|
||||
allocationData.imgInfo->useLocalMemory = true;
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo,
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), *allocationData.imgInfo,
|
||||
allocationData.storageInfo, allocationData.flags.preferCompressed);
|
||||
sizeAligned = alignUp(allocationData.imgInfo->size, MemoryConstants::pageSize64k);
|
||||
} else {
|
||||
@@ -1348,7 +1348,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
|
||||
}
|
||||
if (createSingleHandle) {
|
||||
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(),
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(),
|
||||
nullptr,
|
||||
sizeAligned,
|
||||
0u,
|
||||
@@ -1372,12 +1372,12 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
|
||||
if (createSingleHandle) {
|
||||
allocation->setDefaultGmm(gmm.release());
|
||||
} else if (allocationData.storageInfo.multiStorage) {
|
||||
createColouredGmms(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(),
|
||||
createColouredGmms(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(),
|
||||
*allocation,
|
||||
allocationData.storageInfo,
|
||||
allocationData.flags.preferCompressed);
|
||||
} else {
|
||||
fillGmmsInAllocation(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocation.get(), allocationData.storageInfo);
|
||||
fillGmmsInAllocation(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocation.get(), allocationData.storageInfo);
|
||||
}
|
||||
allocation->storageInfo = allocationData.storageInfo;
|
||||
allocation->setFlushL3Required(allocationData.flags.flushL3);
|
||||
|
||||
@@ -706,7 +706,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
|
||||
alloc->resourceHandle = OpenResource.hResource;
|
||||
|
||||
auto resourceInfo = const_cast<void *>(allocationInfo[0].pPrivateDriverData);
|
||||
alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), static_cast<GMM_RESOURCE_INFO *>(resourceInfo)));
|
||||
alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmHelper(), static_cast<GMM_RESOURCE_INFO *>(resourceInfo)));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -751,7 +751,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
|
||||
alloc->resourceHandle = openResourceFromNtHandle.hResource;
|
||||
|
||||
auto resourceInfo = const_cast<void *>(allocationInfo2[0].pPrivateDriverData);
|
||||
alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), static_cast<GMM_RESOURCE_INFO *>(resourceInfo)));
|
||||
alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmHelper(), static_cast<GMM_RESOURCE_INFO *>(resourceInfo)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ GraphicsAllocation *WddmMemoryManager::allocateMemoryByKMD(const AllocationData
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
StorageInfo systemMemoryStorageInfo = {};
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr, allocationData.size, 0u,
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr, allocationData.size, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, *hwInfo), false, systemMemoryStorageInfo, true);
|
||||
auto allocation = std::make_unique<WddmAllocation>(allocationData.rootDeviceIndex,
|
||||
1u, // numGmms
|
||||
@@ -126,7 +126,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryUsingKmdAndMapItToC
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), nullptr,
|
||||
auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), nullptr,
|
||||
sizeAligned, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo),
|
||||
allocationData.flags.preferCompressed,
|
||||
@@ -194,7 +194,7 @@ GraphicsAllocation *WddmMemoryManager::allocateHugeGraphicsMemory(const Allocati
|
||||
auto sizeRemaining = alignedSize;
|
||||
for (auto gmmId = 0u; gmmId < numGmms; ++gmmId) {
|
||||
auto size = sizeRemaining > chunkSize ? chunkSize : sizeRemaining;
|
||||
auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(),
|
||||
auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(),
|
||||
static_cast<char *>(alignedPtr) + gmmId * chunkSize, size, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!uncacheable, *hwInfo), false, {}, true);
|
||||
wddmAllocation->setGmm(gmm, gmmId);
|
||||
@@ -251,7 +251,7 @@ GraphicsAllocation *WddmMemoryManager::allocateSystemMemoryAndCreateGraphicsAllo
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), pSysMem, sizeAligned, 0u,
|
||||
gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), pSysMem, sizeAligned, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo),
|
||||
allocationData.flags.preferCompressed, allocationData.storageInfo, true);
|
||||
|
||||
@@ -299,7 +299,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), alignedPtr, alignedSize, 0u,
|
||||
auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), alignedPtr, alignedSize, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), false, {}, true);
|
||||
|
||||
wddmAllocation->setDefaultGmm(gmm);
|
||||
@@ -338,7 +338,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const A
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), ptrAligned, sizeAligned, 0u,
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), ptrAligned, sizeAligned, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), false, {}, true);
|
||||
allocation->setDefaultGmm(gmm);
|
||||
if (createWddmAllocation(allocation, reserve)) {
|
||||
@@ -385,7 +385,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), ptrAligned, sizeAligned, 0u,
|
||||
gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), ptrAligned, sizeAligned, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), false, {}, true);
|
||||
wddmAllocation->setDefaultGmm(gmm);
|
||||
|
||||
@@ -620,7 +620,7 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage = osHandle;
|
||||
handleStorage.fragmentStorageData[i].residency = new ResidencyData(maxOsContextCount);
|
||||
|
||||
osHandle->gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmClientContext(), handleStorage.fragmentStorageData[i].cpuPtr,
|
||||
osHandle->gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper(), handleStorage.fragmentStorageData[i].cpuPtr,
|
||||
handleStorage.fragmentStorageData[i].fragmentSize, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(AllocationType::EXTERNAL_HOST_PTR, false, *hwInfo), false, {}, true);
|
||||
allocatedFragmentIndexes[allocatedFragmentsCounter] = i;
|
||||
@@ -920,7 +920,7 @@ bool WddmMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphics
|
||||
return true;
|
||||
}
|
||||
|
||||
void createColouredGmms(GmmClientContext *clientContext, WddmAllocation &allocation, const StorageInfo &storageInfo, bool compression) {
|
||||
void createColouredGmms(GmmHelper *gmmHelper, WddmAllocation &allocation, const StorageInfo &storageInfo, bool compression) {
|
||||
auto remainingSize = allocation.getAlignedSize();
|
||||
auto handles = storageInfo.getNumBanks();
|
||||
/* This logic is to colour resource as equally as possible.
|
||||
@@ -941,34 +941,34 @@ void createColouredGmms(GmmClientContext *clientContext, WddmAllocation &allocat
|
||||
remainingSize -= currentSize;
|
||||
StorageInfo limitedStorageInfo = storageInfo;
|
||||
limitedStorageInfo.memoryBanks &= static_cast<uint32_t>(1u << handleId);
|
||||
auto gmm = new Gmm(clientContext,
|
||||
auto gmm = new Gmm(gmmHelper,
|
||||
nullptr,
|
||||
currentSize,
|
||||
0u,
|
||||
CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false, *clientContext->getHardwareInfo()),
|
||||
CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false, *gmmHelper->getHardwareInfo()),
|
||||
compression,
|
||||
limitedStorageInfo, true);
|
||||
allocation.setGmm(gmm, handleId);
|
||||
}
|
||||
}
|
||||
|
||||
void fillGmmsInAllocation(GmmClientContext *clientContext, WddmAllocation *allocation, const StorageInfo &storageInfo) {
|
||||
void fillGmmsInAllocation(GmmHelper *gmmHelper, WddmAllocation *allocation, const StorageInfo &storageInfo) {
|
||||
for (auto handleId = 0u; handleId < storageInfo.getNumBanks(); handleId++) {
|
||||
StorageInfo limitedStorageInfo = storageInfo;
|
||||
limitedStorageInfo.memoryBanks &= static_cast<uint32_t>(1u << handleId);
|
||||
limitedStorageInfo.pageTablesVisibility &= static_cast<uint32_t>(1u << handleId);
|
||||
auto gmm = new Gmm(clientContext, nullptr, allocation->getAlignedSize(), 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false, *clientContext->getHardwareInfo()), false, limitedStorageInfo, true);
|
||||
auto gmm = new Gmm(gmmHelper, nullptr, allocation->getAlignedSize(), 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false, *gmmHelper->getHardwareInfo()), false, limitedStorageInfo, true);
|
||||
allocation->setGmm(gmm, handleId);
|
||||
}
|
||||
}
|
||||
|
||||
void splitGmmsInAllocation(GmmClientContext *clientContext, WddmAllocation *wddmAllocation, size_t alignment, size_t chunkSize, StorageInfo &storageInfo) {
|
||||
void splitGmmsInAllocation(GmmHelper *gmmHelper, WddmAllocation *wddmAllocation, size_t alignment, size_t chunkSize, StorageInfo &storageInfo) {
|
||||
auto sizeRemaining = wddmAllocation->getAlignedSize();
|
||||
for (auto gmmId = 0u; gmmId < wddmAllocation->getNumGmms(); ++gmmId) {
|
||||
auto size = sizeRemaining > chunkSize ? chunkSize : sizeRemaining;
|
||||
auto gmm = new Gmm(clientContext, nullptr, size, alignment,
|
||||
CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), false, *clientContext->getHardwareInfo()), false, storageInfo, true);
|
||||
auto gmm = new Gmm(gmmHelper, nullptr, size, alignment,
|
||||
CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), false, *gmmHelper->getHardwareInfo()), false, storageInfo, true);
|
||||
wddmAllocation->setGmm(gmm, gmmId);
|
||||
sizeRemaining -= size;
|
||||
}
|
||||
@@ -995,6 +995,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
|
||||
}
|
||||
|
||||
auto gmmClientContext = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext();
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper();
|
||||
|
||||
std::unique_ptr<Gmm> gmm;
|
||||
size_t sizeAligned = 0;
|
||||
@@ -1004,7 +1005,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
|
||||
if (allocationData.type == AllocationType::IMAGE ||
|
||||
allocationData.type == AllocationType::SHARED_RESOURCE_COPY) {
|
||||
allocationData.imgInfo->useLocalMemory = true;
|
||||
gmm = std::make_unique<Gmm>(gmmClientContext, *allocationData.imgInfo, allocationData.storageInfo, allocationData.flags.preferCompressed);
|
||||
gmm = std::make_unique<Gmm>(gmmHelper, *allocationData.imgInfo, allocationData.storageInfo, allocationData.flags.preferCompressed);
|
||||
alignment = MemoryConstants::pageSize64k;
|
||||
sizeAligned = allocationData.imgInfo->size;
|
||||
} else {
|
||||
@@ -1012,7 +1013,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
|
||||
sizeAligned = alignUp(allocationData.size, alignment);
|
||||
|
||||
if (singleBankAllocation) {
|
||||
gmm = std::make_unique<Gmm>(gmmClientContext,
|
||||
gmm = std::make_unique<Gmm>(gmmHelper,
|
||||
nullptr,
|
||||
sizeAligned,
|
||||
alignment,
|
||||
@@ -1030,14 +1031,14 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
|
||||
allocationData.type, nullptr, sizeAligned, nullptr, MemoryPool::LocalMemory, allocationData.flags.shareable, maxOsContextCount);
|
||||
if (singleBankAllocation) {
|
||||
if (numGmms > 1) {
|
||||
splitGmmsInAllocation(gmmClientContext, wddmAllocation.get(), alignment, chunkSize, const_cast<StorageInfo &>(allocationData.storageInfo));
|
||||
splitGmmsInAllocation(gmmHelper, wddmAllocation.get(), alignment, chunkSize, const_cast<StorageInfo &>(allocationData.storageInfo));
|
||||
} else {
|
||||
wddmAllocation->setDefaultGmm(gmm.release());
|
||||
}
|
||||
} else if (allocationData.storageInfo.multiStorage) {
|
||||
createColouredGmms(gmmClientContext, *wddmAllocation, allocationData.storageInfo, allocationData.flags.preferCompressed);
|
||||
createColouredGmms(gmmHelper, *wddmAllocation, allocationData.storageInfo, allocationData.flags.preferCompressed);
|
||||
} else {
|
||||
fillGmmsInAllocation(gmmClientContext, wddmAllocation.get(), allocationData.storageInfo);
|
||||
fillGmmsInAllocation(gmmHelper, wddmAllocation.get(), allocationData.storageInfo);
|
||||
}
|
||||
wddmAllocation->storageInfo = allocationData.storageInfo;
|
||||
wddmAllocation->setFlushL3Required(allocationData.flags.flushL3);
|
||||
|
||||
Reference in New Issue
Block a user