refactor: reorder members to reduce internal padding in structs

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-03-25 14:44:36 +00:00
committed by Compute-Runtime-Automation
parent 9b715c3ffc
commit 78a4a92b44
61 changed files with 288 additions and 266 deletions

View File

@@ -111,7 +111,7 @@ class CommandStreamReceiverSimulatedHw : public CommandStreamReceiverSimulatedCo
auto gmm = graphicsAllocation.getDefaultGmm();
if (gmm) {
allocationParams.additionalParams.compressionEnabled = gmm->isCompressionEnabled;
allocationParams.additionalParams.compressionEnabled = gmm->isCompressionEnabled();
allocationParams.additionalParams.uncached = CacheSettingsHelper::isUncachedType(gmm->resourceParams.Usage);
}

View File

@@ -152,7 +152,7 @@ void Gmm::applyAuxFlagsForBuffer(bool preferCompression) {
gfxCoreHelper.applyRenderCompressionFlag(*this, 1);
resourceParams.Flags.Gpu.CCS = 1;
resourceParams.Flags.Gpu.UnifiedAuxSurface = 1;
isCompressionEnabled = true;
compressionEnabled = true;
}
if (debugManager.flags.PrintGmmCompressionParams.get()) {
@@ -160,7 +160,7 @@ void Gmm::applyAuxFlagsForBuffer(bool preferCompression) {
resourceParams.Flags.Gpu.CCS, resourceParams.Flags.Gpu.UnifiedAuxSurface, resourceParams.Flags.Info.RenderCompressed);
}
gfxCoreHelper.applyAdditionalCompressionSettings(*this, !isCompressionEnabled);
gfxCoreHelper.applyAdditionalCompressionSettings(*this, !compressionEnabled);
}
void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferCompressed) {
@@ -199,7 +199,7 @@ void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferCompressed) {
this->resourceParams.Flags.Gpu.CCS = 1;
this->resourceParams.Flags.Gpu.UnifiedAuxSurface = 1;
this->resourceParams.Flags.Gpu.IndirectClearColor = 1;
this->isCompressionEnabled = true;
this->compressionEnabled = true;
}
}
@@ -208,7 +208,7 @@ void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferCompressed) {
resourceParams.Flags.Gpu.CCS, resourceParams.Flags.Gpu.UnifiedAuxSurface, resourceParams.Flags.Info.RenderCompressed);
}
gfxCoreHelper.applyAdditionalCompressionSettings(*this, !isCompressionEnabled);
gfxCoreHelper.applyAdditionalCompressionSettings(*this, !compressionEnabled);
}
void Gmm::queryImageParams(ImageInfo &imgInfo) {
@@ -371,7 +371,7 @@ void Gmm::applyMemoryFlags(const StorageInfo &storageInfo) {
if (extraMemoryFlagsRequired()) {
applyExtraMemoryFlags(storageInfo);
} else if (!storageInfo.isLockable) {
if (isCompressionEnabled || storageInfo.localOnlyRequired) {
if (isCompressionEnabled() || storageInfo.localOnlyRequired) {
resourceParams.Flags.Info.LocalOnly = 1;
}
}

View File

@@ -71,8 +71,8 @@ class Gmm {
std::unique_ptr<GmmResourceInfo> gmmResourceInfo;
const char *getUsageTypeString();
bool isCompressionEnabled = false;
void setCompressionEnabled(bool compresionEnabled) { this->compressionEnabled = compresionEnabled; }
bool isCompressionEnabled() const { return compressionEnabled; }
protected:
void applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferCompressed);
@@ -82,6 +82,7 @@ class Gmm {
void applyDebugOverrides();
GmmHelper *gmmHelper = nullptr;
bool compressionEnabled = false;
bool preferNoCpuAccess = false;
};
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -16,14 +16,18 @@ namespace NEO {
struct StorageInfo {
StorageInfo();
uint32_t getNumBanks() const;
uint32_t getMemoryBanks() const { return static_cast<uint32_t>(memoryBanks.to_ulong()); }
uint32_t getTotalBanksCnt() const;
size_t colouringGranularity = MemoryConstants::pageSize64k;
DeviceBitfield memoryBanks{};
DeviceBitfield pageTablesVisibility{};
DeviceBitfield subDeviceBitfield{};
ColouringPolicy colouringPolicy = ColouringPolicy::deviceCountBased;
uint32_t numOfChunks = 0;
bool cloningOfPageTables = true;
bool tileInstanced = false;
bool multiStorage = false;
ColouringPolicy colouringPolicy = ColouringPolicy::deviceCountBased;
size_t colouringGranularity = MemoryConstants::pageSize64k;
bool readOnlyMultiStorage = false;
bool cpuVisibleSegment = false;
bool isLockable = false;
@@ -31,9 +35,6 @@ struct StorageInfo {
bool systemMemoryPlacement = true;
bool systemMemoryForced = false;
char resourceTag[AppResourceDefines::maxStrLen + 1] = "";
uint32_t getMemoryBanks() const { return static_cast<uint32_t>(memoryBanks.to_ulong()); }
uint32_t getTotalBanksCnt() const;
bool isChunked = false;
uint32_t numOfChunks = 0;
};
} // namespace NEO

View File

@@ -107,7 +107,7 @@ void GraphicsAllocation::setTbxWritable(bool writable, uint32_t banks) {
}
bool GraphicsAllocation::isCompressionEnabled() const {
return (getDefaultGmm() && getDefaultGmm()->isCompressionEnabled);
return (getDefaultGmm() && getDefaultGmm()->isCompressionEnabled());
}
bool GraphicsAllocation::isTbxWritable(uint32_t banks) const {

View File

@@ -316,6 +316,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
return bindlessInfo;
}
MOCKABLE_VIRTUAL void updateCompletionDataForAllocationAndFragments(uint64_t newFenceValue, uint32_t contextId);
void setShareableHostMemory(bool shareableHostMemory) { this->shareableHostMemory = shareableHostMemory; }
bool isShareableHostMemory() const { return shareableHostMemory; }
OsHandleStorage fragmentsStorage;
StorageInfo storageInfo = {};
@@ -325,8 +327,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
constexpr static TaskCountType objectNotResident = std::numeric_limits<TaskCountType>::max();
constexpr static TaskCountType objectNotUsed = std::numeric_limits<TaskCountType>::max();
constexpr static TaskCountType objectAlwaysResident = std::numeric_limits<TaskCountType>::max() - 1;
std::atomic<uint32_t> hostPtrTaskCountAssignment{0};
bool isShareableHostMemory = false;
protected:
struct UsageInfo {
@@ -388,8 +390,9 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
AllocationType allocationType = AllocationType::unknown;
StackVec<UsageInfo, 32> usageInfos;
std::atomic<uint32_t> registeredContextsNum{0};
StackVec<Gmm *, EngineLimits::maxHandleCount> gmms;
ResidencyData residency;
std::atomic<uint32_t> registeredContextsNum{0};
bool shareableHostMemory = false;
};
} // namespace NEO

View File

@@ -48,7 +48,7 @@ MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(Device *device,
auto gmm = allocation->getDefaultGmm();
if (gmm) {
params.additionalParams.compressionEnabled = gmm->isCompressionEnabled;
params.additionalParams.compressionEnabled = gmm->isCompressionEnabled();
params.additionalParams.uncached = CacheSettingsHelper::isUncachedType(gmm->resourceParams.Usage);
}

View File

@@ -152,14 +152,14 @@ class DrmAllocation : public GraphicsAllocation {
OsContextLinux *osContext = nullptr;
BufferObjects bufferObjects{};
StackVec<uint32_t, 1> registeredBoBindHandles;
MemAdviseFlags enabledMemAdviseFlags{};
StackVec<MemoryToUnmap, 1> memoryToUnmap;
uint32_t numHandles = 0u;
std::vector<uint64_t> handles;
void *mmapPtr = nullptr;
void *importedMmapPtr = nullptr;
size_t mmapSize = 0u;
uint32_t numHandles = 0u;
MemAdviseFlags enabledMemAdviseFlags{};
bool usmHostAllocation = false;
};

View File

@@ -2306,7 +2306,7 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
bo.release();
allocation->setDefaultGmm(gmm.release());
allocation->isShareableHostMemory = true;
allocation->setShareableHostMemory(true);
allocation->storageInfo = allocationData.storageInfo;
return allocation.release();
} else {

View File

@@ -1251,7 +1251,7 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c
if (gmm) {
resourceInfo = gmm->gmmResourceInfo->peekGmmResourceInfo();
usageType = gmm->resourceParams.Usage;
compressed = gmm->isCompressionEnabled;
compressed = gmm->isCompressionEnabled();
cachable = gmm->gmmResourceInfo->getResourceFlags()->Info.Cacheable;
}

View File

@@ -575,7 +575,7 @@ bool Wddm::mapGpuVirtualAddress(Gmm *gmm, D3DKMT_HANDLE handle, D3DGPU_VIRTUAL_A
kmDafListener->notifyMapGpuVA(featureTable->flags.ftrKmdDaf, getAdapter(), device, handle, mapGPUVA.VirtualAddress, getGdi()->escape);
bool ret = true;
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
if (gmm->isCompressionEnabled && productHelper.isPageTableManagerSupported(*rootDeviceEnvironment.getHardwareInfo())) {
if (gmm->isCompressionEnabled() && productHelper.isPageTableManagerSupported(*rootDeviceEnvironment.getHardwareInfo())) {
this->forEachContextWithinWddm([&](const EngineControl &engine) {
if (engine.commandStreamReceiver->pageTableManager.get()) {
ret &= engine.commandStreamReceiver->pageTableManager->updateAuxTable(gpuPtr, gmm, true);
@@ -834,7 +834,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
alloc->setDefaultHandle(allocationInfo[0].hAllocation);
alloc->resourceHandle = openResource.hResource;
alloc->setResourceHandle(openResource.hResource);
auto resourceInfo = const_cast<void *>(allocationInfo[0].pPrivateDriverData);
alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmHelper(), static_cast<GMM_RESOURCE_INFO *>(resourceInfo)));
@@ -883,7 +883,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmHelper(), static_cast<GMM_RESOURCE_INFO *>(resourceInfo), hwDeviceId->getUmKmDataTranslator()->enabled()));
alloc->setDefaultHandle(allocationInfo2[0].hAllocation);
alloc->resourceHandle = openResourceFromNtHandle.hResource;
alloc->setResourceHandle(openResourceFromNtHandle.hResource);
return true;
}

View File

@@ -16,9 +16,9 @@ namespace NEO {
struct OsHandleWin : OsHandle {
~OsHandleWin() override = default;
D3DKMT_HANDLE handle = 0;
D3DGPU_VIRTUAL_ADDRESS gpuPtr = 0;
Gmm *gmm = nullptr;
D3DKMT_HANDLE handle = 0;
};
constexpr size_t trimListUnusedPosition = std::numeric_limits<size_t>::max();
@@ -36,7 +36,7 @@ class WddmAllocation : public GraphicsAllocation {
WddmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, uint64_t canonizedAddress, size_t sizeIn,
void *reservedAddr, MemoryPool pool, uint32_t shareable, size_t maxOsContextCount)
: GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, canonizedAddress, 0llu, sizeIn, pool, maxOsContextCount),
shareable(shareable), trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) {
trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition), shareable(shareable) {
reservedAddressRangeInfo.addressPtr = reservedAddr;
reservedAddressRangeInfo.rangeSize = sizeIn;
handles.resize(gmms.size());
@@ -105,18 +105,29 @@ class WddmAllocation : public GraphicsAllocation {
std::string getAllocationInfoString() const override;
std::string getPatIndexInfoString() const override;
uint64_t &getGpuAddressToModify() { return gpuAddress; }
bool needsMakeResidentBeforeLock() const { return makeResidentBeforeLockRequired; }
void setMakeResidentBeforeLockRequired(bool makeResidentBeforeLockRequired) { this->makeResidentBeforeLockRequired = makeResidentBeforeLockRequired; }
bool isAllocInFrontWindowPool() const { return allocInFrontWindowPool; }
void setAllocInFrontWindowPool(bool allocInFrontWindowPool) { this->allocInFrontWindowPool = allocInFrontWindowPool; }
bool isPhysicalMemoryReservation() const { return physicalMemoryReservation; }
void setPhysicalMemoryReservation(bool physicalMemoryReservation) { this->physicalMemoryReservation = physicalMemoryReservation; }
bool isMappedPhysicalMemoryReservation() const { return mappedPhysicalMemoryReservation; }
void setMappedPhysicalMemoryReservation(bool mappedPhysicalMemoryReservation) { this->mappedPhysicalMemoryReservation = mappedPhysicalMemoryReservation; }
// OS assigned fields
D3DKMT_HANDLE resourceHandle = 0u; // used by shared resources
bool needsMakeResidentBeforeLock = false;
D3DGPU_VIRTUAL_ADDRESS reservedGpuVirtualAddress = 0u;
uint64_t reservedSizeForGpuVirtualAddress = 0u;
uint32_t shareable = 0u;
bool allocInFrontWindowPool = false;
bool physicalMemoryReservation = false;
bool mappedPhysicalMemoryReservation = false;
D3DGPU_VIRTUAL_ADDRESS getReservedGpuVirtualAddress() const { return reservedGpuVirtualAddress; }
D3DGPU_VIRTUAL_ADDRESS &getReservedGpuVirtualAddressToModify() { return reservedGpuVirtualAddress; }
void setReservedGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS reservedGpuVirtualAddress) { this->reservedGpuVirtualAddress = reservedGpuVirtualAddress; }
uint64_t getReservedSizeForGpuVirtualAddress() const { return reservedSizeForGpuVirtualAddress; }
void setReservedSizeForGpuVirtualAddress(uint64_t reservedSizeForGpuVirtualAddress) { this->reservedSizeForGpuVirtualAddress = reservedSizeForGpuVirtualAddress; }
D3DKMT_HANDLE getResourceHandle() const { return resourceHandle; }
D3DKMT_HANDLE &getResourceHandleToModify() { return resourceHandle; }
void setResourceHandle(D3DKMT_HANDLE resourceHandle) { this->resourceHandle = resourceHandle; }
protected:
// OS assigned fields
D3DGPU_VIRTUAL_ADDRESS reservedGpuVirtualAddress = 0u;
uint64_t reservedSizeForGpuVirtualAddress = 0u;
uint64_t ntSecureHandle = 0u;
std::string getHandleInfoString() const {
std::stringstream ss;
@@ -127,5 +138,11 @@ class WddmAllocation : public GraphicsAllocation {
}
std::vector<size_t> trimCandidateListPositions;
StackVec<D3DKMT_HANDLE, EngineLimits::maxHandleCount> handles;
D3DKMT_HANDLE resourceHandle = 0u; // used by shared resources
uint32_t shareable = 0u;
bool allocInFrontWindowPool = false;
bool physicalMemoryReservation = false;
bool mappedPhysicalMemoryReservation = false;
bool makeResidentBeforeLockRequired = false;
};
} // namespace NEO

View File

@@ -98,16 +98,16 @@ void WddmMemoryManager::unMapPhysicalToVirtualMemory(GraphicsAllocation *physica
physicalAllocation->setCpuPtrAndGpuAddress(nullptr, 0u);
physicalAllocation->setReservedAddressRange(nullptr, 0u);
WddmAllocation *wddmAllocation = reinterpret_cast<WddmAllocation *>(physicalAllocation);
wddmAllocation->mappedPhysicalMemoryReservation = false;
wddmAllocation->setMappedPhysicalMemoryReservation(false);
}
bool WddmMemoryManager::mapPhysicalToVirtualMemory(GraphicsAllocation *physicalAllocation, uint64_t gpuRange, size_t bufferSize) {
WddmAllocation *wddmAllocation = reinterpret_cast<WddmAllocation *>(physicalAllocation);
auto decanonizedAddress = getGmmHelper(physicalAllocation->getRootDeviceIndex())->decanonize(gpuRange);
wddmAllocation->mappedPhysicalMemoryReservation = mapGpuVirtualAddress(wddmAllocation, reinterpret_cast<void *>(decanonizedAddress));
wddmAllocation->setMappedPhysicalMemoryReservation(mapGpuVirtualAddress(wddmAllocation, reinterpret_cast<void *>(decanonizedAddress)));
physicalAllocation->setCpuPtrAndGpuAddress(nullptr, gpuRange);
physicalAllocation->setReservedAddressRange(reinterpret_cast<void *>(gpuRange), bufferSize);
return wddmAllocation->mappedPhysicalMemoryReservation;
return wddmAllocation->isMappedPhysicalMemoryReservation();
}
GraphicsAllocation *WddmMemoryManager::allocatePhysicalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) {
@@ -239,7 +239,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryUsingKmdAndMapItToC
return nullptr;
}
auto cpuPtr = gmm->isCompressionEnabled ? nullptr : lockResource(wddmAllocation.get());
auto cpuPtr = gmm->isCompressionEnabled() ? nullptr : lockResource(wddmAllocation.get());
[[maybe_unused]] auto status = true;
@@ -541,7 +541,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
wddmAllocation->setDriverAllocatedCpuPtr(pSysMem);
wddmAllocation->set32BitAllocation(true);
wddmAllocation->setAllocationOffset(offset);
wddmAllocation->allocInFrontWindowPool = allocationData.flags.use32BitFrontWindow;
wddmAllocation->setAllocInFrontWindowPool(allocationData.flags.use32BitFrontWindow);
auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper<ProductHelper>();
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
@@ -668,19 +668,19 @@ void WddmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *g
void *WddmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation) {
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
return getWddm(graphicsAllocation.getRootDeviceIndex()).lockResource(wddmAllocation.getDefaultHandle(), this->peekExecutionEnvironment().rootDeviceEnvironments[wddmAllocation.getRootDeviceIndex()]->getHelper<GfxCoreHelper>().makeResidentBeforeLockNeeded(wddmAllocation.needsMakeResidentBeforeLock), wddmAllocation.getAlignedSize());
return getWddm(graphicsAllocation.getRootDeviceIndex()).lockResource(wddmAllocation.getDefaultHandle(), this->peekExecutionEnvironment().rootDeviceEnvironments[wddmAllocation.getRootDeviceIndex()]->getHelper<GfxCoreHelper>().makeResidentBeforeLockNeeded(wddmAllocation.needsMakeResidentBeforeLock()), wddmAllocation.getAlignedSize());
}
void WddmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocation) {
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
getWddm(graphicsAllocation.getRootDeviceIndex()).unlockResource(wddmAllocation.getDefaultHandle());
if (wddmAllocation.needsMakeResidentBeforeLock) {
if (wddmAllocation.needsMakeResidentBeforeLock()) {
[[maybe_unused]] auto evictionStatus = getWddm(graphicsAllocation.getRootDeviceIndex()).getTemporaryResourcesContainer()->evictResource(wddmAllocation.getDefaultHandle());
DEBUG_BREAK_IF(evictionStatus == MemoryOperationsStatus::failed);
}
}
void WddmMemoryManager::freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) {
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
if (wddmAllocation.needsMakeResidentBeforeLock) {
if (wddmAllocation.needsMakeResidentBeforeLock()) {
for (auto i = 0u; i < wddmAllocation.getNumGmms(); i++) {
getWddm(graphicsAllocation.getRootDeviceIndex()).getTemporaryResourcesContainer()->removeResource(wddmAllocation.getHandles()[i]);
}
@@ -747,8 +747,8 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
input->fragmentsStorage.fragmentCount > 0) {
cleanGraphicsMemoryCreatedFromHostPtr(gfxAllocation);
} else {
if (input->resourceHandle != 0) {
[[maybe_unused]] auto status = tryDeferDeletions(nullptr, 0, input->resourceHandle, gfxAllocation->getRootDeviceIndex());
if (input->getResourceHandle() != 0) {
[[maybe_unused]] auto status = tryDeferDeletions(nullptr, 0, input->getResourceHandle(), gfxAllocation->getRootDeviceIndex());
DEBUG_BREAK_IF(!status);
} else {
for (auto handle : input->getHandles()) {
@@ -762,12 +762,12 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
if (input->getReservedAddressPtr()) {
releaseReservedCpuAddressRange(input->getReservedAddressPtr(), input->getReservedAddressSize(), gfxAllocation->getRootDeviceIndex());
}
if (input->reservedGpuVirtualAddress) {
getWddm(gfxAllocation->getRootDeviceIndex()).freeGpuVirtualAddress(input->reservedGpuVirtualAddress, input->reservedSizeForGpuVirtualAddress);
if (input->getReservedGpuVirtualAddress()) {
getWddm(gfxAllocation->getRootDeviceIndex()).freeGpuVirtualAddress(input->getReservedGpuVirtualAddressToModify(), input->getReservedSizeForGpuVirtualAddress());
}
if (input->allocInFrontWindowPool) {
auto heapIndex = selectHeap(input, false, is32bit || executionEnvironment.rootDeviceEnvironments[input->getRootDeviceIndex()]->isFullRangeSvm(), input->allocInFrontWindowPool);
if (input->isAllocInFrontWindowPool()) {
auto heapIndex = selectHeap(input, false, is32bit || executionEnvironment.rootDeviceEnvironments[input->getRootDeviceIndex()]->isFullRangeSvm(), input->isAllocInFrontWindowPool());
auto alignedSize = input->getAlignedSize();
auto gfxPartition = getGfxPartition(input->getRootDeviceIndex());
gfxPartition->heapFree(heapIndex, input->getGpuAddress(), alignedSize);
@@ -811,7 +811,7 @@ bool WddmMemoryManager::isMemoryBudgetExhausted() const {
bool WddmMemoryManager::validateAllocation(WddmAllocation *alloc) {
if (alloc == nullptr)
return false;
if (alloc->physicalMemoryReservation && !alloc->mappedPhysicalMemoryReservation) {
if (alloc->isPhysicalMemoryReservation() && !alloc->isMappedPhysicalMemoryReservation()) {
return true;
}
if (alloc->getGpuAddress() == 0u || (alloc->getDefaultHandle() == 0 && alloc->fragmentsStorage.fragmentCount == 0))
@@ -942,7 +942,7 @@ bool WddmMemoryManager::createPhysicalAllocation(WddmAllocation *allocation) {
if (!status) {
return false;
}
allocation->physicalMemoryReservation = true;
allocation->setPhysicalMemoryReservation(true);
return true;
}
@@ -995,15 +995,15 @@ void WddmMemoryManager::freeGpuAddress(AddressRange addressRange, uint32_t rootD
bool WddmMemoryManager::mapGpuVaForOneHandleAllocation(WddmAllocation *allocation, const void *preferredGpuVirtualAddress) {
D3DGPU_VIRTUAL_ADDRESS addressToMap = castToUint64(preferredGpuVirtualAddress);
auto heapIndex = selectHeap(allocation, preferredGpuVirtualAddress != nullptr, is32bit || executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm(), allocation->allocInFrontWindowPool);
auto heapIndex = selectHeap(allocation, preferredGpuVirtualAddress != nullptr, is32bit || executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm(), allocation->isAllocInFrontWindowPool());
if (!executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm() && !is32bit) {
addressToMap = 0u;
}
if (allocation->reservedGpuVirtualAddress) {
addressToMap = allocation->reservedGpuVirtualAddress;
if (allocation->getReservedGpuVirtualAddress()) {
addressToMap = allocation->getReservedGpuVirtualAddress();
}
auto gfxPartition = getGfxPartition(allocation->getRootDeviceIndex());
if (allocation->allocInFrontWindowPool) {
if (allocation->isAllocInFrontWindowPool()) {
auto alignedSize = allocation->getAlignedSize();
addressToMap = gfxPartition->heapAllocate(heapIndex, alignedSize);
}
@@ -1017,10 +1017,10 @@ bool WddmMemoryManager::mapGpuVaForOneHandleAllocation(WddmAllocation *allocatio
status = getWddm(allocation->getRootDeviceIndex()).mapGpuVirtualAddress(allocation->getDefaultGmm(), allocation->getDefaultHandle(), minimumAddress, maximumAddress, addressToMap, allocation->getGpuAddressToModify());
}
if (!status) {
if (allocation->reservedGpuVirtualAddress) {
getWddm(allocation->getRootDeviceIndex()).freeGpuVirtualAddress(allocation->reservedGpuVirtualAddress, allocation->reservedSizeForGpuVirtualAddress);
if (allocation->getReservedGpuVirtualAddress()) {
getWddm(allocation->getRootDeviceIndex()).freeGpuVirtualAddress(allocation->getReservedGpuVirtualAddressToModify(), allocation->getReservedSizeForGpuVirtualAddress());
}
getWddm(allocation->getRootDeviceIndex()).destroyAllocations(&allocation->getHandles()[0], allocation->getNumGmms(), allocation->resourceHandle);
getWddm(allocation->getRootDeviceIndex()).destroyAllocations(&allocation->getHandles()[0], allocation->getNumGmms(), allocation->getResourceHandle());
return false;
}
@@ -1044,13 +1044,13 @@ bool WddmMemoryManager::mapMultiHandleAllocationWithRetry(WddmAllocation *alloca
addressToMap = castToUint64(preferredGpuVirtualAddress);
allocation->getGpuAddressToModify() = addressToMap;
} else {
allocation->reservedSizeForGpuVirtualAddress = alignUp(alignedSize, MemoryConstants::pageSize64k);
allocation->setReservedSizeForGpuVirtualAddress(alignUp(alignedSize, MemoryConstants::pageSize64k));
auto status = wddm.reserveGpuVirtualAddress(0ull, gfxPartition->getHeapMinimalAddress(heapIndex), gfxPartition->getHeapLimit(heapIndex),
allocation->reservedSizeForGpuVirtualAddress, &allocation->reservedGpuVirtualAddress);
allocation->getReservedSizeForGpuVirtualAddress(), &allocation->getReservedGpuVirtualAddressToModify());
UNRECOVERABLE_IF(status != STATUS_SUCCESS);
auto gmmHelper = getGmmHelper(allocation->getRootDeviceIndex());
allocation->getGpuAddressToModify() = gmmHelper->canonize(allocation->reservedGpuVirtualAddress);
addressToMap = allocation->reservedGpuVirtualAddress;
allocation->getGpuAddressToModify() = gmmHelper->canonize(allocation->getReservedGpuVirtualAddress());
addressToMap = allocation->getReservedGpuVirtualAddress();
}
for (auto currentHandle = 0u; currentHandle < allocation->getNumGmms(); currentHandle++) {
@@ -1064,10 +1064,10 @@ bool WddmMemoryManager::mapMultiHandleAllocationWithRetry(WddmAllocation *alloca
gfxPartition->getHeapMinimalAddress(heapIndex), gfxPartition->getHeapLimit(heapIndex), addressToMap, gpuAddress);
}
if (!status) {
if (allocation->reservedGpuVirtualAddress) {
wddm.freeGpuVirtualAddress(allocation->reservedGpuVirtualAddress, allocation->reservedSizeForGpuVirtualAddress);
if (allocation->getReservedGpuVirtualAddress()) {
wddm.freeGpuVirtualAddress(allocation->getReservedGpuVirtualAddressToModify(), allocation->getReservedSizeForGpuVirtualAddress());
}
wddm.destroyAllocations(&allocation->getHandles()[0], allocation->getNumGmms(), allocation->resourceHandle);
wddm.destroyAllocations(&allocation->getHandles()[0], allocation->getNumGmms(), allocation->getResourceHandle());
return false;
}
gpuAddress = getGmmHelper(allocation->getRootDeviceIndex())->decanonize(gpuAddress);
@@ -1080,13 +1080,13 @@ bool WddmMemoryManager::mapMultiHandleAllocationWithRetry(WddmAllocation *alloca
bool WddmMemoryManager::createGpuAllocationsWithRetry(WddmAllocation *allocation) {
for (auto handleId = 0u; handleId < allocation->getNumGmms(); handleId++) {
auto gmm = allocation->getGmm(handleId);
auto status = getWddm(allocation->getRootDeviceIndex()).createAllocation(gmm->gmmResourceInfo->getSystemMemPointer(), gmm, allocation->getHandleToModify(handleId), allocation->resourceHandle, allocation->getSharedHandleToModify());
auto status = getWddm(allocation->getRootDeviceIndex()).createAllocation(gmm->gmmResourceInfo->getSystemMemPointer(), gmm, allocation->getHandleToModify(handleId), allocation->getResourceHandleToModify(), allocation->getSharedHandleToModify());
if (status == STATUS_GRAPHICS_NO_VIDEO_MEMORY && deferredDeleter) {
deferredDeleter->drain(true);
status = getWddm(allocation->getRootDeviceIndex()).createAllocation(gmm->gmmResourceInfo->getSystemMemPointer(), gmm, allocation->getHandleToModify(handleId), allocation->resourceHandle, allocation->getSharedHandleToModify());
status = getWddm(allocation->getRootDeviceIndex()).createAllocation(gmm->gmmResourceInfo->getSystemMemPointer(), gmm, allocation->getHandleToModify(handleId), allocation->getResourceHandleToModify(), allocation->getSharedHandleToModify());
}
if (status != STATUS_SUCCESS) {
getWddm(allocation->getRootDeviceIndex()).destroyAllocations(&allocation->getHandles()[0], handleId, allocation->resourceHandle);
getWddm(allocation->getRootDeviceIndex()).destroyAllocations(&allocation->getHandles()[0], handleId, allocation->getResourceHandle());
return false;
}
}
@@ -1197,7 +1197,7 @@ bool WddmMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphics
if (!handleMask.test(handleId)) {
continue;
}
auto ptr = wddm.lockResource(wddmAllocation->getHandles()[handleId], wddmAllocation->needsMakeResidentBeforeLock, wddmAllocation->getAlignedSize());
auto ptr = wddm.lockResource(wddmAllocation->getHandles()[handleId], wddmAllocation->needsMakeResidentBeforeLock(), wddmAllocation->getAlignedSize());
if (!ptr) {
return false;
}
@@ -1335,7 +1335,7 @@ GraphicsAllocation *WddmMemoryManager::allocatePhysicalLocalDeviceMemory(const A
}
wddmAllocation->storageInfo = allocationData.storageInfo;
wddmAllocation->setFlushL3Required(allocationData.flags.flushL3);
wddmAllocation->needsMakeResidentBeforeLock = true;
wddmAllocation->setMakeResidentBeforeLockRequired(true);
auto &wddm = getWddm(allocationData.rootDeviceIndex);
@@ -1421,9 +1421,9 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
}
wddmAllocation->storageInfo = allocationData.storageInfo;
wddmAllocation->setFlushL3Required(allocationData.flags.flushL3);
wddmAllocation->needsMakeResidentBeforeLock = true;
wddmAllocation->setMakeResidentBeforeLockRequired(true);
if (heapAssigners[allocationData.rootDeviceIndex]->use32BitHeap(allocationData.type)) {
wddmAllocation->allocInFrontWindowPool = allocationData.flags.use32BitFrontWindow;
wddmAllocation->setAllocInFrontWindowPool(allocationData.flags.use32BitFrontWindow);
}
void *requiredGpuVa = nullptr;
@@ -1468,7 +1468,7 @@ bool WddmMemoryManager::mapGpuVirtualAddress(WddmAllocation *allocation, const v
return mapTileInstancedAllocation(allocation,
requiredPtr,
&getWddm(allocation->getRootDeviceIndex()),
selectHeap(allocation, requiredPtr != nullptr, executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm(), allocation->allocInFrontWindowPool),
selectHeap(allocation, requiredPtr != nullptr, executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm(), allocation->isAllocInFrontWindowPool()),
*getGfxPartition(allocation->getRootDeviceIndex()));
} else if (allocation->storageInfo.multiStorage) {
return mapMultiHandleAllocationWithRetry(allocation, requiredPtr);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -137,7 +137,7 @@ GraphicsAllocation *MockMemoryManager::allocateGraphicsMemory64kb(const Allocati
auto allocation = OsAgnosticMemoryManager::allocateGraphicsMemory64kb(allocationData);
if (allocation) {
allocation->getDefaultGmm()->isCompressionEnabled = preferCompressedFlagPassed;
allocation->getDefaultGmm()->setCompressionEnabled(preferCompressedFlagPassed);
}
return allocation;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -104,7 +104,7 @@ bool WddmMock::freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t si
}
NTSTATUS WddmMock::createAllocation(WddmAllocation *wddmAllocation) {
if (wddmAllocation) {
return createAllocation(wddmAllocation->getAlignedCpuPtr(), wddmAllocation->getDefaultGmm(), wddmAllocation->getHandleToModify(0u), wddmAllocation->resourceHandle, wddmAllocation->getSharedHandleToModify());
return createAllocation(wddmAllocation->getAlignedCpuPtr(), wddmAllocation->getDefaultGmm(), wddmAllocation->getHandleToModify(0u), wddmAllocation->getResourceHandleToModify(), wddmAllocation->getSharedHandleToModify());
}
return false;
}
@@ -150,7 +150,7 @@ bool WddmMock::destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext)
D3DKMT_HANDLE resourceHandle = 0;
void *reserveAddress = alloc->getReservedAddressPtr();
if (alloc->peekSharedHandle()) {
resourceHandle = alloc->resourceHandle;
resourceHandle = alloc->getResourceHandle();
} else {
allocationHandles = &alloc->getHandles()[0];
allocationCount = static_cast<uint32_t>(alloc->getHandles().size());

View File

@@ -826,7 +826,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe
gfxAllocation->setDefaultGmm(gmm);
for (bool compressed : {false, true}) {
gmm->isCompressionEnabled = compressed;
gmm->setCompressionEnabled(compressed);
aubCsr->writeMemory(*gfxAllocation);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Intel Corporation
* Copyright (C) 2021-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -333,7 +333,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenCompressedAllocationWhenCloningPageTa
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
MockGmm gmm(csr->peekGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements);
gmm.isCompressionEnabled = true;
gmm.setCompressionEnabled(true);
int dummy = 1;
GraphicsAllocation graphicsAllocation{0, AllocationType::unknown,
@@ -366,7 +366,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenUncachedAllocationWhenCloningPageTabl
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
MockGmm gmm(csr->peekGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, {}, gmmRequirements);
gmm.isCompressionEnabled = false;
gmm.setCompressionEnabled(false);
int dummy = 1;
GraphicsAllocation graphicsAllocation{0, AllocationType::unknown,
@@ -429,7 +429,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenCompressedTileInstancedAllocationWhen
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
MockGmm gmm(csr->peekGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements);
gmm.isCompressionEnabled = true;
gmm.setCompressionEnabled(true);
int dummy = 1;
GraphicsAllocation graphicsAllocation{0, AllocationType::unknown,
@@ -471,7 +471,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenUncachedTileInstancedAllocationWhenWr
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
MockGmm gmm(csr->peekGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, {}, gmmRequirements);
gmm.isCompressionEnabled = false;
gmm.setCompressionEnabled(false);
int dummy = 1;
GraphicsAllocation graphicsAllocation{0, AllocationType::unknown,

View File

@@ -1073,7 +1073,7 @@ TEST_F(GmmCompressionTests, givenEnabledAndNotPreferredE2ECWhenApplyingForBuffer
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.RenderCompressed);
EXPECT_EQ(0u, gmm->resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(0u, gmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_FALSE(gmm->isCompressionEnabled);
EXPECT_FALSE(gmm->isCompressionEnabled());
}
TEST_F(GmmCompressionTests, givenDisabledAndPreferredE2ECWhenApplyingForBuffersThenDontSetValidFlags) {
@@ -1089,7 +1089,7 @@ TEST_F(GmmCompressionTests, givenDisabledAndPreferredE2ECWhenApplyingForBuffersT
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.RenderCompressed);
EXPECT_EQ(0u, gmm->resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(0u, gmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_FALSE(gmm->isCompressionEnabled);
EXPECT_FALSE(gmm->isCompressionEnabled());
}
HWTEST_F(GmmCompressionTests, givenAllValidInputsWhenQueryingThenSetAppropriateFlags) {
@@ -1108,7 +1108,7 @@ HWTEST_F(GmmCompressionTests, givenAllValidInputsWhenQueryingThenSetAppropriateF
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Gpu.IndirectClearColor);
EXPECT_TRUE(queryGmm->isCompressionEnabled);
EXPECT_TRUE(queryGmm->isCompressionEnabled());
}
TEST_F(GmmCompressionTests, givenAllValidInputsAndNoLocalMemoryRequestWhenQueryingThenRenderCompressionFlagsAreNotSet) {
@@ -1127,7 +1127,7 @@ TEST_F(GmmCompressionTests, givenAllValidInputsAndNoLocalMemoryRequestWhenQueryi
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.IndirectClearColor);
EXPECT_FALSE(queryGmm->isCompressionEnabled);
EXPECT_FALSE(queryGmm->isCompressionEnabled());
}
TEST_F(GmmCompressionTests, givenNotAllowedRenderCompressionWhenQueryingThenSetAppropriateFlags) {
@@ -1139,7 +1139,7 @@ TEST_F(GmmCompressionTests, givenNotAllowedRenderCompressionWhenQueryingThenSetA
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.IndirectClearColor);
EXPECT_FALSE(queryGmm->isCompressionEnabled);
EXPECT_FALSE(queryGmm->isCompressionEnabled());
}
HWTEST_F(GmmCompressionTests, givenNotAllowedCompressionAndEnabledDebugFlagWhenQueryingThenSetAppropriateFlags) {
@@ -1153,7 +1153,7 @@ HWTEST_F(GmmCompressionTests, givenNotAllowedCompressionAndEnabledDebugFlagWhenQ
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Gpu.IndirectClearColor);
EXPECT_TRUE(queryGmm->isCompressionEnabled);
EXPECT_TRUE(queryGmm->isCompressionEnabled());
debugManager.flags.RenderCompressedImagesEnabled.set(0);
localPlatformDevice->capabilityTable.ftrRenderCompressedImages = true;
@@ -1163,13 +1163,13 @@ HWTEST_F(GmmCompressionTests, givenNotAllowedCompressionAndEnabledDebugFlagWhenQ
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.IndirectClearColor);
EXPECT_FALSE(queryGmm->isCompressionEnabled);
EXPECT_FALSE(queryGmm->isCompressionEnabled());
}
TEST_F(GmmCompressionTests, givenNotPreferredCompressionFlagWhenQueryingThenDisallow) {
auto queryGmm = MockGmm::queryImgParams(getGmmHelper(), imgInfo, false);
EXPECT_FALSE(queryGmm->isCompressionEnabled);
EXPECT_FALSE(queryGmm->isCompressionEnabled());
}
TEST_F(GmmCompressionTests, givenPlaneFormatWhenQueryingThenDisallow) {
@@ -1180,7 +1180,7 @@ TEST_F(GmmCompressionTests, givenPlaneFormatWhenQueryingThenDisallow) {
imgInfo.plane = plane;
auto queryGmm = MockGmm::queryImgParams(getGmmHelper(), imgInfo, true);
EXPECT_EQ(queryGmm->isCompressionEnabled,
EXPECT_EQ(queryGmm->isCompressionEnabled(),
plane == GMM_YUV_PLANE::GMM_NO_PLANE);
}
}
@@ -1209,7 +1209,7 @@ TEST_F(GmmCompressionTests, givenMediaCompressedImageApplyAuxFlagsForImageThenSe
gmm.resourceParams.Flags.Info.RenderCompressed = false;
gmm.setupImageResourceParams(imgInfo, true);
EXPECT_TRUE(gmm.isCompressionEnabled);
EXPECT_TRUE(gmm.isCompressionEnabled());
}
TEST_F(GmmCompressionTests, givenRenderCompressedImageApplyAuxFlagsForImageThenSetFlagsToCompressed) {
@@ -1221,7 +1221,7 @@ TEST_F(GmmCompressionTests, givenRenderCompressedImageApplyAuxFlagsForImageThenS
gmm.resourceParams.Flags.Info.RenderCompressed = true;
gmm.setupImageResourceParams(imgInfo, true);
EXPECT_TRUE(gmm.isCompressionEnabled);
EXPECT_TRUE(gmm.isCompressionEnabled());
}
HWTEST_F(GmmCompressionTests, givenEnabledAndPreferredE2ECWhenApplyingForBuffersThenSetValidFlags) {
@@ -1237,7 +1237,7 @@ HWTEST_F(GmmCompressionTests, givenEnabledAndPreferredE2ECWhenApplyingForBuffers
EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.RenderCompressed);
EXPECT_EQ(1u, gmm->resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(1u, gmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_TRUE(gmm->isCompressionEnabled);
EXPECT_TRUE(gmm->isCompressionEnabled());
}
HWTEST_F(GmmCompressionTests, givenDisabledE2ECAndEnabledDebugFlagWhenApplyingForBuffersThenSetValidFlags) {
@@ -1255,10 +1255,10 @@ HWTEST_F(GmmCompressionTests, givenDisabledE2ECAndEnabledDebugFlagWhenApplyingFo
EXPECT_EQ(1u, gmm.resourceParams.Flags.Info.RenderCompressed);
EXPECT_EQ(1u, gmm.resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(1u, gmm.resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_TRUE(gmm.isCompressionEnabled);
EXPECT_TRUE(gmm.isCompressionEnabled());
gmm.resourceParams = {};
gmm.isCompressionEnabled = false;
gmm.setCompressionEnabled(false);
debugManager.flags.RenderCompressedBuffersEnabled.set(0);
localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = true;
@@ -1266,7 +1266,7 @@ HWTEST_F(GmmCompressionTests, givenDisabledE2ECAndEnabledDebugFlagWhenApplyingFo
EXPECT_EQ(0u, gmm.resourceParams.Flags.Info.RenderCompressed);
EXPECT_EQ(0u, gmm.resourceParams.Flags.Gpu.CCS);
EXPECT_EQ(0u, gmm.resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_FALSE(gmm.isCompressionEnabled);
EXPECT_FALSE(gmm.isCompressionEnabled());
}
struct GmmLocalMemoryTests : public ::testing::Test, MockExecutionEnvironmentGmmFixture {
@@ -1395,7 +1395,7 @@ TEST_F(GmmHelperTests, givenCompressionEnabledWhenUsingLocalMemoryAndAllocationI
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = true;
auto gmm = std::make_unique<Gmm>(getGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, storageInfo, gmmRequirements);
EXPECT_TRUE(gmm->isCompressionEnabled);
EXPECT_TRUE(gmm->isCompressionEnabled());
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly);
EXPECT_EQ(defaultHwInfo->featureTable.flags.ftrLocalMemory, gmm->resourceParams.Flags.Info.LocalOnly);
EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.NotLockable);
@@ -1412,7 +1412,7 @@ TEST_F(GmmHelperTests, givenCompressionSupportedWhenAllocationIsLockableThenGmmH
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = true;
auto gmm = std::make_unique<Gmm>(getGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, storageInfo, gmmRequirements);
EXPECT_FALSE(gmm->isCompressionEnabled);
EXPECT_FALSE(gmm->isCompressionEnabled());
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NotLockable);
}

View File

@@ -574,7 +574,7 @@ HWTEST_F(GfxCoreHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCo
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmHelper(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
allocation.getDefaultGmm()->isCompressionEnabled = true;
allocation.getDefaultGmm()->setCompressionEnabled(true);
SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER;
gfxCoreHelper.setRenderSurfaceStateForScratchResource(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, false, false);
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, state->getCoherencyType());
@@ -680,7 +680,7 @@ HWTEST_F(GfxCoreHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCo
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmHelper(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
allocation.getDefaultGmm()->isCompressionEnabled = true;
allocation.getDefaultGmm()->setCompressionEnabled(true);
SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER;
gfxCoreHelper.setRenderSurfaceStateForScratchResource(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, true, false);
EXPECT_EQ(UnitTestHelper<FamilyType>::getCoherencyTypeSupported(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT), state->getCoherencyType());

View File

@@ -56,7 +56,7 @@ HWTEST2_F(BlitTests, givenDeviceWithoutDefaultGmmWhenAppendBlitCommandsForVillBu
HWTEST2_F(BlitTests, givenGmmWithDisabledCompresionWhenAppendBlitCommandsForVillBufferThenDstCompressionDisabled, IsPVC) {
using MEM_SET = typename FamilyType::MEM_SET;
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->isCompressionEnabled = false;
gmm->setCompressionEnabled(false);
uint32_t pattern = 1;
uint32_t streamBuffer[100] = {};
@@ -80,7 +80,7 @@ HWTEST2_F(BlitTests, givenGmmWithDisabledCompresionWhenAppendBlitCommandsForVill
HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionWhenAppendBlitCommandsForVillBufferThenDstCompressionEnabled, IsPVC) {
using MEM_SET = typename FamilyType::MEM_SET;
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->isCompressionEnabled = true;
gmm->setCompressionEnabled(true);
uint32_t pattern = 1;
uint32_t streamBuffer[100] = {};

View File

@@ -61,7 +61,7 @@ HWTEST2_F(BlitTests, givenGmmWithDisabledCompresionWhenAppendBlitCommandsForFill
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
auto blitCmd = FamilyType::cmdInitXyColorBlt;
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->isCompressionEnabled = false;
gmm->setCompressionEnabled(false);
MockGraphicsAllocation mockAllocation(0, AllocationType::internalHostMemory,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
@@ -75,7 +75,7 @@ HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionWhenAppendBlitCommandsForFillB
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
auto blitCmd = FamilyType::cmdInitXyColorBlt;
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->isCompressionEnabled = true;
gmm->setCompressionEnabled(true);
MockGraphicsAllocation mockAllocation(0, AllocationType::internalHostMemory,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
@@ -91,7 +91,7 @@ HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionWhenAppendBlitCommandsForFillB
auto gmmContext = pDevice->getGmmHelper();
auto gmm = std::make_unique<MockGmm>(gmmContext);
gmm->isCompressionEnabled = true;
gmm->setCompressionEnabled(true);
MockGraphicsAllocation mockAllocation(0, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount);
mockAllocation.setGmm(gmm.get(), 0);
@@ -111,7 +111,7 @@ HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionAndDebugFlagSetWhenAppendBlitC
debugManager.flags.ForceBufferCompressionFormat.set(static_cast<int32_t>(newCompressionFormat));
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->isCompressionEnabled = true;
gmm->setCompressionEnabled(true);
MockGraphicsAllocation mockAllocation(0, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount);
mockAllocation.setGmm(gmm.get(), 0);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -18,17 +18,17 @@ extern BOOL systemPowerStatusRetVal;
extern BYTE systemPowerStatusACLineStatusOverride;
} // namespace SysCalls
class MockKmdNotifyHelper : public KmdNotifyHelper {
class PublicKmdNotifyHelper : public KmdNotifyHelper {
public:
using KmdNotifyHelper::acLineConnected;
using KmdNotifyHelper::updateAcLineStatus;
MockKmdNotifyHelper(const KmdNotifyProperties *newProperties) : KmdNotifyHelper(newProperties){};
PublicKmdNotifyHelper(const KmdNotifyProperties *newProperties) : KmdNotifyHelper(newProperties){};
};
TEST(KmdNotifyWindowsTests, whenGetSystemPowerStatusReturnSuccessThenUpdateAcLineStatus) {
auto properties = &(defaultHwInfo->capabilityTable.kmdNotifyProperties);
MockKmdNotifyHelper helper(properties);
PublicKmdNotifyHelper helper(properties);
EXPECT_TRUE(helper.acLineConnected);
VariableBackup<BOOL> systemPowerStatusRetValBkp(&SysCalls::systemPowerStatusRetVal);
@@ -47,7 +47,7 @@ TEST(KmdNotifyWindowsTests, whenGetSystemPowerStatusReturnSuccessThenUpdateAcLin
TEST(KmdNotifyWindowsTests, whenGetSystemPowerStatusReturnErrorThenDontUpdateAcLineStatus) {
auto properties = &(defaultHwInfo->capabilityTable.kmdNotifyProperties);
MockKmdNotifyHelper helper(properties);
PublicKmdNotifyHelper helper(properties);
EXPECT_TRUE(helper.acLineConnected);
VariableBackup<BOOL> systemPowerStatusRetValBkp(&SysCalls::systemPowerStatusRetVal);

View File

@@ -108,7 +108,7 @@ HWTEST_F(ImageSurfaceStateTests, givenGmmWhenSetAuxParamsForCCSThenAuxiliarySurf
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
EncodeSurfaceState<FamilyType>::setImageAuxParamsForCCS(castSurfaceState, mockGmm.get());
mockGmm->isCompressionEnabled = true;
mockGmm->setCompressionEnabled(true);
EXPECT_TRUE(EncodeSurfaceState<FamilyType>::isAuxModeEnabled(castSurfaceState, mockGmm.get()));
}

View File

@@ -337,7 +337,7 @@ TEST(BaseMemoryManagerTest, givenDebugVariableSetWhenCompressedBufferIsCreatedTh
auto allocationBufferCompressed = memoryManager.allocateGraphicsMemoryInPreferredPool(allocPropertiesBufferCompressed, nullptr);
EXPECT_EQ(nullptr, allocationBuffer->getDefaultGmm());
EXPECT_NE(nullptr, allocationBufferCompressed->getDefaultGmm());
EXPECT_TRUE(allocationBufferCompressed->getDefaultGmm()->isCompressionEnabled);
EXPECT_TRUE(allocationBufferCompressed->getDefaultGmm()->isCompressionEnabled());
memoryManager.freeGraphicsMemory(allocationBuffer);
memoryManager.freeGraphicsMemory(allocationBufferCompressed);

View File

@@ -1161,7 +1161,7 @@ TEST(OsAgnosticMemoryManager, givenCompressionEnabledWhenAllocateGraphicsMemoryW
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(MemoryPool::system4KBPages, allocation->getMemoryPool());
EXPECT_NE(nullptr, allocation->getDefaultGmm());
EXPECT_EQ(true, allocation->getDefaultGmm()->isCompressionEnabled);
EXPECT_EQ(true, allocation->getDefaultGmm()->isCompressionEnabled());
EXPECT_EQ(MemoryConstants::pageSize, allocation->getDefaultGmm()->resourceParams.BaseAlignment);
memoryManager.freeGraphicsMemory(allocation);
}
@@ -2833,7 +2833,7 @@ HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenMapAuxGpuVaThenForAllEng
MockGraphicsAllocation allocation(1u, AllocationType::unknown, nullptr, 0, 0, MemoryPool::memoryNull, MemoryManager::maxOsContextCount, 0llu);
MockGmm gmm(executionEnvironment.rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmHelper());
gmm.isCompressionEnabled = true;
gmm.setCompressionEnabled(true);
allocation.setDefaultGmm(&gmm);
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
expectedDdiUpdateAuxTable.BaseGpuVA = allocation.getGpuAddress();
@@ -2877,7 +2877,7 @@ HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenUpdateAuxTableGmmErrorTh
MockGraphicsAllocation allocation(1u, AllocationType::unknown, nullptr, 0, 0, MemoryPool::memoryNull, MemoryManager::maxOsContextCount, 0llu);
MockGmm gmm(executionEnvironment.rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmHelper());
gmm.isCompressionEnabled = true;
gmm.setCompressionEnabled(true);
allocation.setDefaultGmm(&gmm);
bool result = memoryManager->mapAuxGpuVA(&allocation);
@@ -2909,7 +2909,7 @@ HWTEST_F(PageTableManagerTest, givenNullPageTableManagerWhenMapAuxGpuVaThenNoThr
MockGraphicsAllocation allocation(1u, AllocationType::unknown, nullptr, 0, 0, MemoryPool::memoryNull, MemoryManager::maxOsContextCount, 0llu);
MockGmm gmm(executionEnvironment.rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmHelper());
gmm.isCompressionEnabled = true;
gmm.setCompressionEnabled(true);
allocation.setDefaultGmm(&gmm);
EXPECT_NO_THROW(memoryManager->mapAuxGpuVA(&allocation));

View File

@@ -155,7 +155,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnC
auto executionEnvironment = std::unique_ptr<ExecutionEnvironment>(MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u));
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
MockGmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper());
gmm.isCompressionEnabled = true;
gmm.setCompressionEnabled(true);
allocPtr->setDefaultGmm(&gmm);
auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
@@ -179,7 +179,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnU
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
MockGmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, {}, gmmRequirements);
gmm.isCompressionEnabled = false;
gmm.setCompressionEnabled(false);
allocPtr->setDefaultGmm(&gmm);
auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));

View File

@@ -6857,7 +6857,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenCompress
auto gmm = allocation->getDefaultGmm();
{
gmm->isCompressionEnabled = true;
gmm->setCompressionEnabled(true);
gmm->gmmResourceInfo->getResourceFlags()->Info.Cacheable = 1;
mock->getPatIndex(allocation->getDefaultGmm(), allocation->getAllocationType(), CacheRegion::defaultRegion, CachePolicy::writeBack, false, false);
@@ -6867,7 +6867,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenCompress
}
{
gmm->isCompressionEnabled = false;
gmm->setCompressionEnabled(false);
gmm->gmmResourceInfo->getResourceFlags()->Info.Cacheable = 0;
mock->getPatIndex(allocation->getDefaultGmm(), allocation->getAllocationType(), CacheRegion::defaultRegion, CachePolicy::writeBack, false, false);

View File

@@ -524,7 +524,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
ASSERT_NE(nullptr, wddmAllocation);
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->peekSharedHandle());
EXPECT_EQ(RESOURCE_HANDLE, wddmAllocation->resourceHandle);
EXPECT_EQ(RESOURCE_HANDLE, wddmAllocation->getResourceHandle());
EXPECT_NE(0u, wddmAllocation->getDefaultHandle());
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->getDefaultHandle());
EXPECT_NE(0u, wddmAllocation->getGpuAddress());
@@ -568,7 +568,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
ASSERT_NE(nullptr, wddmAllocation);
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->peekSharedHandle());
EXPECT_EQ(RESOURCE_HANDLE, wddmAllocation->resourceHandle);
EXPECT_EQ(RESOURCE_HANDLE, wddmAllocation->getResourceHandle());
EXPECT_NE(0u, wddmAllocation->getDefaultHandle());
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->getDefaultHandle());
EXPECT_EQ(reservedAddress, reinterpret_cast<void *>(wddmAllocation->getGpuAddress()));
@@ -1238,13 +1238,13 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenOtherReso
TEST_F(WddmLockWithMakeResidentTests, whenAlllocationNeedsBlockingMakeResidentBeforeLockThenLockWithBlockingMakeResident) {
WddmMemoryManager memoryManager(*executionEnvironment);
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmHelper());
allocation.needsMakeResidentBeforeLock = false;
allocation.setMakeResidentBeforeLockRequired(false);
memoryManager.lockResource(&allocation);
EXPECT_EQ(1u, wddm->lockResult.called);
EXPECT_EQ(rootDeviceEnvironment->getHelper<GfxCoreHelper>().makeResidentBeforeLockNeeded(false), wddm->lockResult.uint64ParamPassed);
memoryManager.unlockResource(&allocation);
allocation.needsMakeResidentBeforeLock = true;
allocation.setMakeResidentBeforeLockRequired(true);
memoryManager.lockResource(&allocation);
EXPECT_EQ(2u, wddm->lockResult.called);
EXPECT_EQ(1u, wddm->lockResult.uint64ParamPassed);

View File

@@ -1074,7 +1074,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenRenderCompressBufferEn
allocationData.size = 4096u;
allocationData.flags.preferCompressed = true;
auto allocation = memoryManager->allocateMemoryByKMD(allocationData);
EXPECT_TRUE(allocation->getDefaultGmm()->isCompressionEnabled);
EXPECT_TRUE(allocation->getDefaultGmm()->isCompressionEnabled());
memoryManager->freeGraphicsMemory(allocation);
}
@@ -1087,7 +1087,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenRenderCompressBufferEn
allocationData.size = 4096u;
allocationData.flags.preferCompressed = false;
auto allocation = memoryManager->allocateMemoryByKMD(allocationData);
EXPECT_FALSE(allocation->getDefaultGmm()->isCompressionEnabled);
EXPECT_FALSE(allocation->getDefaultGmm()->isCompressionEnabled());
memoryManager->freeGraphicsMemory(allocation);
}
@@ -1331,7 +1331,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingLockedAllocationThatDoesntNeed
debugManager.flags.ForcePreferredAllocationMethod.set(static_cast<int32_t>(GfxMemoryAllocationMethod::useUmdSystemPtr));
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
memoryManager->lockResource(allocation);
EXPECT_FALSE(allocation->needsMakeResidentBeforeLock);
EXPECT_FALSE(allocation->needsMakeResidentBeforeLock());
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(0u, mockTemporaryResources->evictResourceResult.called);
}
@@ -1340,7 +1340,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingNotLockedAllocationThatDoesntN
debugManager.flags.ForcePreferredAllocationMethod.set(static_cast<int32_t>(GfxMemoryAllocationMethod::useUmdSystemPtr));
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
EXPECT_FALSE(allocation->isLocked());
EXPECT_FALSE(allocation->needsMakeResidentBeforeLock);
EXPECT_FALSE(allocation->needsMakeResidentBeforeLock());
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(0u, mockTemporaryResources->evictResourceResult.called);
}
@@ -1348,7 +1348,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingLockedAllocationThatNeedsMakeR
DebugManagerStateRestore restorer;
debugManager.flags.ForcePreferredAllocationMethod.set(static_cast<int32_t>(GfxMemoryAllocationMethod::useUmdSystemPtr));
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
allocation->needsMakeResidentBeforeLock = true;
allocation->setMakeResidentBeforeLockRequired(true);
memoryManager->lockResource(allocation);
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(1u, mockTemporaryResources->removeResourceResult.called);
@@ -1357,7 +1357,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingNotLockedAllocationThatNeedsMa
DebugManagerStateRestore restorer;
debugManager.flags.ForcePreferredAllocationMethod.set(static_cast<int32_t>(GfxMemoryAllocationMethod::useUmdSystemPtr));
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
allocation->needsMakeResidentBeforeLock = true;
allocation->setMakeResidentBeforeLockRequired(true);
EXPECT_FALSE(allocation->isLocked());
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(0u, mockTemporaryResources->evictResourceResult.called);
@@ -1368,8 +1368,8 @@ TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingAllocationWithReservedGpuVirtu
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
uint64_t gpuAddress = 0x123;
uint64_t sizeForFree = 0x1234;
allocation->reservedGpuVirtualAddress = gpuAddress;
allocation->reservedSizeForGpuVirtualAddress = sizeForFree;
allocation->setReservedGpuVirtualAddress(gpuAddress);
allocation->setReservedSizeForGpuVirtualAddress(sizeForFree);
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(1u, wddm->freeGpuVirtualAddressResult.called);
EXPECT_EQ(gpuAddress, wddm->freeGpuVirtualAddressResult.uint64ParamPassed);
@@ -1381,8 +1381,8 @@ TEST_F(WddmMemoryManagerSimpleTest, givenAllocationWithReservedGpuVirtualAddress
allocation.setAllocationType(AllocationType::kernelIsa);
uint64_t gpuAddress = 0x123;
uint64_t sizeForFree = 0x1234;
allocation.reservedGpuVirtualAddress = gpuAddress;
allocation.reservedSizeForGpuVirtualAddress = sizeForFree;
allocation.setReservedGpuVirtualAddress(gpuAddress);
allocation.setReservedSizeForGpuVirtualAddress(sizeForFree);
wddm->callBaseMapGpuVa = false;
wddm->mapGpuVaStatus = false;
@@ -1550,7 +1550,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenIsaTypeAnd32BitFrontWindowWhenFrontWind
EXPECT_LE(size, allocation->getUnderlyingBufferSize());
EXPECT_NE(nullptr, allocation->getUnderlyingBuffer());
EXPECT_TRUE(allocation->allocInFrontWindowPool);
EXPECT_TRUE(allocation->isAllocInFrontWindowPool());
uint64_t gpuAddress = allocation->getGpuAddress();
EXPECT_NE(0ULL, gpuAddress);
@@ -1586,7 +1586,7 @@ HWTEST2_F(WddmMemoryManagerSimpleTest, givenLocalMemoryIsaTypeAnd32BitFrontWindo
ASSERT_NE(nullptr, allocation);
EXPECT_LE(alignUp(size, MemoryConstants::pageSize64k), allocation->getUnderlyingBufferSize());
EXPECT_TRUE(allocation->allocInFrontWindowPool);
EXPECT_TRUE(allocation->isAllocInFrontWindowPool());
uint64_t gpuAddress = allocation->getGpuAddress();
EXPECT_NE(0ULL, gpuAddress);
@@ -2221,7 +2221,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenMemoryIsAllocatedInLocalMemoryThenTheAll
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
EXPECT_EQ(MemoryPool::localMemory, allocation->getMemoryPool());
EXPECT_TRUE(allocation->needsMakeResidentBeforeLock);
EXPECT_TRUE(allocation->needsMakeResidentBeforeLock());
memoryManager->freeGraphicsMemory(allocation);
}
@@ -2611,7 +2611,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, properties, false, false, true, nullptr);
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_EQ(RESOURCE_HANDLE, wddmAlloc->resourceHandle);
EXPECT_EQ(RESOURCE_HANDLE, wddmAlloc->getResourceHandle());
EXPECT_EQ(ALLOCATION_HANDLE, wddmAlloc->getDefaultHandle());
memoryManager->freeGraphicsMemory(gpuAllocation);
@@ -2628,7 +2628,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0, AllocationType::sharedImage);
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->resourceHandle);
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->getResourceHandle());
EXPECT_EQ(NT_ALLOCATION_HANDLE, wddmAlloc->getDefaultHandle());
EXPECT_EQ(AllocationType::sharedImage, wddmAlloc->getAllocationType());
@@ -2659,7 +2659,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0, AllocationType::sharedImage);
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->resourceHandle);
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->getResourceHandle());
EXPECT_EQ(NT_ALLOCATION_HANDLE, wddmAlloc->getDefaultHandle());
EXPECT_EQ(AllocationType::sharedImage, wddmAlloc->getAllocationType());
@@ -2744,7 +2744,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenFreeAllocFromSharedHandl
AllocationProperties properties(0, false, 4096u, AllocationType::sharedBuffer, false, false, 0);
auto gpuAllocation = (WddmAllocation *)memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, properties, false, false, true, nullptr);
EXPECT_NE(nullptr, gpuAllocation);
auto expectedDestroyHandle = gpuAllocation->resourceHandle;
auto expectedDestroyHandle = gpuAllocation->getResourceHandle();
EXPECT_NE(0u, expectedDestroyHandle);
auto lastDestroyed = getMockLastDestroyedResHandleFcn();
@@ -2764,7 +2764,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocFromHostPtrIsCalled
allocationData.hostPtr = hostPtr;
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData));
EXPECT_EQ(0u, allocation->resourceHandle);
EXPECT_EQ(0u, allocation->getResourceHandle());
memoryManager->freeGraphicsMemory(allocation);
}
@@ -2806,7 +2806,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemory
ASSERT_NE(nullptr, allocation);
EXPECT_TRUE(memoryManager->allocationGraphicsMemory64kbCreated);
EXPECT_TRUE(allocation->getDefaultGmm()->isCompressionEnabled);
EXPECT_TRUE(allocation->getDefaultGmm()->isCompressionEnabled());
if ((is32bit && rootDeviceEnvironment->isFullRangeSvm()) &&
allocation->getDefaultGmm()->gmmResourceInfo->is64KBPageSuitable()) {
auto gmmHelper = memoryManager->getGmmHelper(0);
@@ -2867,7 +2867,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemory
ASSERT_NE(nullptr, allocation);
EXPECT_FALSE(memoryManager->allocationGraphicsMemory64kbCreated);
EXPECT_FALSE(allocation->getDefaultGmm()->isCompressionEnabled);
EXPECT_FALSE(allocation->getDefaultGmm()->isCompressionEnabled());
if (is32bit || rootDeviceEnvironment->isFullRangeSvm()) {
auto gmmHelper = memoryManager->getGmmHelper(0);
@@ -3548,7 +3548,7 @@ TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForBufferAndRequest
EXPECT_EQ(4u, wddm->createAllocationResult.called);
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[wddmAlloc->getRootDeviceIndex()]->getGmmHelper();
EXPECT_EQ(wddmAlloc->getGpuAddressToModify(), gmmHelper->canonize(wddmAlloc->reservedGpuVirtualAddress));
EXPECT_EQ(wddmAlloc->getGpuAddressToModify(), gmmHelper->canonize(wddmAlloc->getReservedGpuVirtualAddress()));
memoryManager.freeGraphicsMemory(wddmAlloc);
}
@@ -3586,7 +3586,7 @@ TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForHostBufferAndReq
EXPECT_EQ(4u, wddm->createAllocationResult.called);
auto gmmHelper = memoryManager.getGmmHelper(wddmAlloc->getRootDeviceIndex());
EXPECT_EQ(wddmAlloc->getGpuAddressToModify(), gmmHelper->canonize(wddmAlloc->reservedGpuVirtualAddress));
EXPECT_EQ(wddmAlloc->getGpuAddressToModify(), gmmHelper->canonize(wddmAlloc->getReservedGpuVirtualAddress()));
memoryManager.freeGraphicsMemory(wddmAlloc);
}
@@ -3665,7 +3665,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), reinterpret_cast<void *>(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
gmm->isCompressionEnabled = true;
gmm->setCompressionEnabled(true);
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm(*executionEnvironment.rootDeviceEnvironments[1].get());
wddm.init();
@@ -3702,7 +3702,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), reinterpret_cast<void *>(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
gmm->isCompressionEnabled = true;
gmm->setCompressionEnabled(true);
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm(*executionEnvironment.rootDeviceEnvironments[1].get());
wddm.init();
@@ -3761,7 +3761,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupported
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemoryWithProperties(AllocationProperties(1, MemoryConstants::pageSize, AllocationType::internalHostMemory, mockDeviceBitfield)));
wddmAlloc->setGpuAddress(gpuVa);
wddmAlloc->getDefaultGmm()->isCompressionEnabled = true;
wddmAlloc->getDefaultGmm()->setCompressionEnabled(true);
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
expectedDdiUpdateAuxTable.BaseGpuVA = gpuVa;
@@ -3795,7 +3795,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenReleaseingThen
}
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, MemoryConstants::pageSize}));
wddmAlloc->getDefaultGmm()->isCompressionEnabled = false;
wddmAlloc->getDefaultGmm()->setCompressionEnabled(false);
memoryManager.freeGraphicsMemory(wddmAlloc);
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
@@ -3807,7 +3807,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenMappedGpuVaThe
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), reinterpret_cast<void *>(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
gmm->isCompressionEnabled = false;
gmm->setCompressionEnabled(false);
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm(*rootDeviceEnvironment);
wddm.init();
@@ -3836,7 +3836,7 @@ TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenRetur
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), reinterpret_cast<void *>(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
gmm->isCompressionEnabled = false;
gmm->setCompressionEnabled(false);
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm(*rootDeviceEnvironment);
wddm.init();
@@ -3867,7 +3867,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsUnsetThenD
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
auto myGmm = new Gmm(rootDeviceEnvironment->getGmmHelper(), reinterpret_cast<void *>(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements);
myGmm->isCompressionEnabled = false;
myGmm->setCompressionEnabled(false);
myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1;
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, MemoryConstants::pageSize}));
@@ -3907,7 +3907,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsSetThenU
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
auto myGmm = new Gmm(rootDeviceEnvironment->getGmmHelper(), reinterpret_cast<void *>(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements);
myGmm->isCompressionEnabled = true;
myGmm->setCompressionEnabled(true);
myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1;
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, MemoryConstants::pageSize}));