Mitigation for WDDM_LINUX allocation size limits

Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
Jaroslaw Chodor 2021-07-14 16:51:47 +02:00 committed by Compute-Runtime-Automation
parent 058c30c9a8
commit 78499ca48d
15 changed files with 120 additions and 67 deletions

View File

@ -734,6 +734,49 @@ TEST_F(GmmTests, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapability
EXPECT_FALSE(gmm->unifiedAuxTranslationCapable()); // RenderCompressed == 0
}
TEST_F(GmmTests, whenLargePagesAreImplicitlyAllowedThenEnableOptimizationPadding) {
size_t allocationSize = 128;
Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, false);
EXPECT_FALSE(gmm.resourceParams.Flags.Info.NoOptimizationPadding);
}
TEST_F(GmmTests, whenLargePagesAreExplicitlyAllowedAndUserPtrIsNullThenAllowOptimizationPadding) {
size_t allocationSize = 128;
bool allowLargePages = true;
Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, false, false, false, {}, allowLargePages);
EXPECT_FALSE(gmm.resourceParams.Flags.Info.NoOptimizationPadding);
}
TEST_F(GmmTests, whenLargePagesAreExplicitlyDisallowedButUserPtrIsNotNullThenAllowOptimizationPadding) {
const void *dummyPtr = reinterpret_cast<void *>(0x123);
size_t allocationSize = 128;
bool allowLargePages = false;
Gmm gmm(getGmmClientContext(), dummyPtr, allocationSize, 0, false, false, false, {}, allowLargePages);
EXPECT_FALSE(gmm.resourceParams.Flags.Info.NoOptimizationPadding);
}
TEST_F(GmmTests, whenLargePagesAreExplicitlyDisallowedAndUserPtrIsNullThenDisableOptimizationPadding) {
size_t allocationSize = 128;
bool allowLargePages = false;
Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, false, false, false, {}, allowLargePages);
EXPECT_TRUE(gmm.resourceParams.Flags.Info.NoOptimizationPadding);
}
TEST_F(GmmTests, givenSizeIsMisallignedTo64kbWhenForceDisablingLargePagesThenSizeIsPreserved) {
const void *dummyPtr = reinterpret_cast<void *>(0x123);
size_t allocationSize = 256U;
bool allowLargePages = false;
Gmm gmm(getGmmClientContext(), dummyPtr, allocationSize, 0, false, false, false, {}, allowLargePages);
EXPECT_EQ(allocationSize, gmm.resourceParams.BaseWidth64);
}
TEST_F(GmmTests, givenSizeIsAllignedTo64kbWhenForceDisablingLargePagesThenSizeIsAlteredToBreak64kbAlignment) {
size_t allocationSize = MemoryConstants::pageSize64k;
bool allowLargePages = false;
Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, false, false, false, {}, allowLargePages);
EXPECT_EQ(allocationSize + MemoryConstants::pageSize, gmm.resourceParams.BaseWidth64);
}
TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedThenSetThisHwInfoToGmmHelper) {
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_EQ(&device->getHardwareInfo(), device->getGmmHelper()->getHardwareInfo());

View File

@ -44,8 +44,8 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
return BaseClass::allocateGraphicsMemoryInDevicePool(allocationData, status);
}
size_t hugeGfxMemoryChunkSize = BaseClass::getHugeGfxMemoryChunkSize();
size_t getHugeGfxMemoryChunkSize() const override { return hugeGfxMemoryChunkSize; }
size_t hugeGfxMemoryChunkSize = BaseClass::getHugeGfxMemoryChunkSize(preferredAllocationMethod);
size_t getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod allocationMethod) const override { return hugeGfxMemoryChunkSize; }
MockWddmMemoryManager(ExecutionEnvironment &executionEnvironment) : MemoryManagerCreate(false, false, executionEnvironment) {
hostPtrManager.reset(new MockHostPtrManager);

View File

@ -155,7 +155,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafLi
auto gmm = std::make_unique<Gmm>(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, false);
auto handle = 0u;
wddmWithKmDafMock->createAllocation64k(gmm.get(), handle);
wddmWithKmDafMock->createAllocation(gmm.get(), handle);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);

View File

@ -1548,10 +1548,10 @@ TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemor
if (memoryManager64k.isLimitedGPU(0)) {
GTEST_SKIP();
}
EXPECT_EQ(0, wddm->createAllocationResult.called);
EXPECT_EQ(0U, wddm->createAllocationResult.called);
GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemoryWithProperties({rootDeviceIndex, MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, mockDeviceBitfield});
EXPECT_EQ(1, wddm->createAllocationResult.called);
EXPECT_NE(0U, wddm->createAllocationResult.called);
EXPECT_NE(nullptr, galloc);
EXPECT_EQ(true, galloc->isLocked());
EXPECT_NE(nullptr, galloc->getUnderlyingBuffer());
@ -1629,7 +1629,8 @@ TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForBufferAndRequest
TEST_F(MockWddmMemoryManagerTest, givenDefaultMemoryManagerWhenItIsCreatedThenCorrectHugeGfxMemoryChunkIsSet) {
MockWddmMemoryManager memoryManager(*executionEnvironment);
EXPECT_EQ(memoryManager.getHugeGfxMemoryChunkSize(), 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k);
EXPECT_EQ(memoryManager.getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::AllocateByKmd), 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k);
EXPECT_EQ(memoryManager.getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::UseUmdSystemPtr), 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k);
}
TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForHostBufferAndRequestedSizeIsHugeThenResultAllocationIsSplitted) {

View File

@ -20,13 +20,23 @@
namespace NEO {
Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable) : Gmm(clientContext, alignedPtr, alignedSize, alignment, uncacheable, false, true, {}) {}
Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo) : clientContext(clientContext) {
Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo)
: Gmm(clientContext, alignedPtr, alignedSize, alignment, uncacheable, preferRenderCompressed, systemMemoryPool, storageInfo, true) {
}
Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo, bool allowLargePages) : clientContext(clientContext) {
resourceParams.Type = RESOURCE_BUFFER;
resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
resourceParams.BaseWidth64 = static_cast<uint64_t>(alignedSize);
resourceParams.BaseHeight = 1;
resourceParams.Depth = 1;
resourceParams.BaseAlignment = static_cast<uint32_t>(alignment);
if ((nullptr == alignedPtr) && (false == allowLargePages)) {
resourceParams.Flags.Info.NoOptimizationPadding = true;
if ((resourceParams.BaseWidth64 & MemoryConstants::page64kMask) == 0) {
resourceParams.BaseWidth64 += MemoryConstants::pageSize;
}
}
if (!uncacheable) {
resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
} else {

View File

@ -27,6 +27,7 @@ class Gmm {
Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo);
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable);
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo);
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo, bool allowLargePages);
Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm);
void queryImageParams(ImageInfo &inputOutputImgInfo);

View File

@ -9,8 +9,14 @@
namespace NEO {
size_t WddmMemoryManager::getHugeGfxMemoryChunkSize() const {
return 31 * MemoryConstants::megaByte;
const GfxMemoryAllocationMethod preferredAllocationMethod = GfxMemoryAllocationMethod::AllocateByKmd;
size_t WddmMemoryManager::getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod allocationMethod) const {
if (GfxMemoryAllocationMethod::AllocateByKmd == allocationMethod) {
return 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k;
} else {
return 31 * MemoryConstants::megaByte;
}
}
} // namespace NEO

View File

@ -9,7 +9,9 @@
namespace NEO {
size_t WddmMemoryManager::getHugeGfxMemoryChunkSize() const {
const GfxMemoryAllocationMethod preferredAllocationMethod = GfxMemoryAllocationMethod::UseUmdSystemPtr;
size_t WddmMemoryManager::getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod allocationMethod) const {
return 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k;
}

View File

@ -498,18 +498,8 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
AllocationInfo.pSystemMem = alignedCpuPtr;
AllocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();
AllocationInfo.PrivateDriverDataSize = static_cast<uint32_t>(gmm->gmmResourceInfo->peekHandleSize());
AllocationInfo.Flags.Primary = 0;
CreateAllocation.hGlobalShare = 0;
CreateAllocation.PrivateRuntimeDataSize = 0;
CreateAllocation.PrivateDriverDataSize = 0;
CreateAllocation.Flags.Reserved = 0;
CreateAllocation.NumAllocations = 1;
CreateAllocation.pPrivateRuntimeData = nullptr;
CreateAllocation.pPrivateDriverData = nullptr;
CreateAllocation.Flags.NonSecure = FALSE;
CreateAllocation.Flags.CreateShared = outSharedHandle ? TRUE : FALSE;
CreateAllocation.Flags.RestrictSharedAccess = FALSE;
CreateAllocation.Flags.CreateResource = outSharedHandle || alignedCpuPtr ? TRUE : FALSE;
CreateAllocation.pAllocationInfo2 = &AllocationInfo;
CreateAllocation.hDevice = device;
@ -530,6 +520,13 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
return status;
}
bool Wddm::createAllocation(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
D3DKMT_HANDLE outResourceHandle = NULL_HANDLE;
D3DKMT_HANDLE *outSharedHandle = nullptr;
auto result = this->createAllocation(nullptr, gmm, outHandle, outResourceHandle, outSharedHandle);
return STATUS_SUCCESS == result;
}
bool Wddm::setAllocationPriority(const D3DKMT_HANDLE *handles, uint32_t allocationCount, uint32_t priority) {
D3DKMT_SETALLOCATIONPRIORITY setAllocationPriority = {};
@ -553,36 +550,6 @@ bool Wddm::setAllocationPriority(const D3DKMT_HANDLE *handles, uint32_t allocati
return STATUS_SUCCESS == status;
}
bool Wddm::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
NTSTATUS status = STATUS_SUCCESS;
D3DDDI_ALLOCATIONINFO2 AllocationInfo = {};
D3DKMT_CREATEALLOCATION CreateAllocation = {};
AllocationInfo.pSystemMem = 0;
AllocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();
AllocationInfo.PrivateDriverDataSize = static_cast<uint32_t>(gmm->gmmResourceInfo->peekHandleSize());
AllocationInfo.Flags.Primary = 0;
CreateAllocation.NumAllocations = 1;
CreateAllocation.pPrivateRuntimeData = nullptr;
CreateAllocation.pPrivateDriverData = nullptr;
CreateAllocation.Flags.CreateResource = FALSE;
CreateAllocation.pAllocationInfo2 = &AllocationInfo;
CreateAllocation.hDevice = device;
status = getGdi()->createAllocation2(&CreateAllocation);
if (status != STATUS_SUCCESS) {
DEBUG_BREAK_IF(true);
return false;
}
outHandle = AllocationInfo.hAllocation;
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, getAdapter(), device, outHandle, getGdi()->escape);
return true;
}
NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DDDI_ALLOCATIONINFO2 AllocationInfo[maxFragmentsCount] = {};

View File

@ -77,7 +77,7 @@ class Wddm : public DriverModel {
MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext, const HardwareInfo &hwInfo);
MOCKABLE_VIRTUAL bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
MOCKABLE_VIRTUAL NTSTATUS createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKMT_HANDLE &outHandle, D3DKMT_HANDLE &outResourceHandle, D3DKMT_HANDLE *outSharedHandle);
MOCKABLE_VIRTUAL bool createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle);
MOCKABLE_VIRTUAL bool createAllocation(const Gmm *gmm, D3DKMT_HANDLE &outHandle);
MOCKABLE_VIRTUAL NTSTATUS createAllocationsAndMapGpuVa(OsHandleStorage &osHandles);
MOCKABLE_VIRTUAL bool destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
MOCKABLE_VIRTUAL bool verifySharedHandle(D3DKMT_HANDLE osHandle);

View File

@ -95,15 +95,19 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImageImpl(const
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const AllocationData &allocationData) {
size_t sizeAligned = alignUp(allocationData.size, MemoryConstants::pageSize64k);
if (sizeAligned > getHugeGfxMemoryChunkSize()) {
return allocateGraphicsMemoryUsingKmdAndMapItToCpuVA(allocationData, true);
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryUsingKmdAndMapItToCpuVA(const AllocationData &allocationData, bool allowLargePages) {
size_t sizeAligned = alignUp(allocationData.size, allowLargePages ? MemoryConstants::pageSize64k : MemoryConstants::pageSize);
if (sizeAligned > getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::AllocateByKmd)) {
return allocateHugeGraphicsMemory(allocationData, false);
}
auto wddmAllocation = std::make_unique<WddmAllocation>(allocationData.rootDeviceIndex,
1u, // numGmms
allocationData.type, nullptr,
sizeAligned, nullptr, MemoryPool::System64KBPages,
sizeAligned, nullptr, allowLargePages ? MemoryPool::System64KBPages : MemoryPool::System4KBPages,
0u, // shareable
maxOsContextCount);
@ -111,12 +115,13 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const Allocati
sizeAligned, 0u,
allocationData.flags.uncacheable,
allocationData.flags.preferRenderCompressed, true,
allocationData.storageInfo);
allocationData.storageInfo,
allowLargePages);
wddmAllocation->setDefaultGmm(gmm);
wddmAllocation->setFlushL3Required(allocationData.flags.flushL3);
wddmAllocation->storageInfo = allocationData.storageInfo;
if (!getWddm(allocationData.rootDeviceIndex).createAllocation64k(gmm, wddmAllocation->getHandleToModify(0u))) {
if (!getWddm(allocationData.rootDeviceIndex).createAllocation(gmm, wddmAllocation->getHandleToModify(0u))) {
delete gmm;
return nullptr;
}
@ -149,7 +154,7 @@ GraphicsAllocation *WddmMemoryManager::allocateHugeGraphicsMemory(const Allocati
}
}
auto chunkSize = getHugeGfxMemoryChunkSize();
auto chunkSize = getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::UseUmdSystemPtr);
auto numGmms = (alignedSize + chunkSize - 1) / chunkSize;
auto wddmAllocation = std::make_unique<WddmAllocation>(allocationData.rootDeviceIndex, numGmms,
allocationData.type, hostPtr, allocationData.size,
@ -191,9 +196,17 @@ GraphicsAllocation *WddmMemoryManager::allocateUSMHostGraphicsMemory(const Alloc
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) {
if (preferredAllocationMethod == GfxMemoryAllocationMethod::UseUmdSystemPtr) {
return allocateSystemMemoryAndCreateGraphicsAllocationFromIt(allocationData);
} else {
return allocateGraphicsMemoryUsingKmdAndMapItToCpuVA(allocationData, NEO::OSInterface::osEnabled64kbPages);
}
}
GraphicsAllocation *WddmMemoryManager::allocateSystemMemoryAndCreateGraphicsAllocationFromIt(const AllocationData &allocationData) {
size_t newAlignment = allocationData.alignment ? alignUp(allocationData.alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize;
size_t sizeAligned = allocationData.size ? alignUp(allocationData.size, MemoryConstants::pageSize) : MemoryConstants::pageSize;
if (sizeAligned > getHugeGfxMemoryChunkSize()) {
if (sizeAligned > getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::UseUmdSystemPtr)) {
return allocateHugeGraphicsMemory(allocationData, true);
}
void *pSysMem = allocateSystemMemory(sizeAligned, newAlignment);
@ -240,7 +253,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) {
auto alignedSize = alignSizeWholePage(allocationData.hostPtr, allocationData.size);
if (alignedSize > getHugeGfxMemoryChunkSize()) {
if (alignedSize > getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::UseUmdSystemPtr)) {
return allocateHugeGraphicsMemory(allocationData, false);
}
@ -268,7 +281,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData) {
if (allocationData.size > getHugeGfxMemoryChunkSize()) {
if (allocationData.size > getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::UseUmdSystemPtr)) {
return allocateHugeGraphicsMemory(allocationData, false);
}

View File

@ -23,6 +23,13 @@ class Gmm;
class OsContextWin;
class Wddm;
enum class GfxMemoryAllocationMethod : uint32_t {
UseUmdSystemPtr,
AllocateByKmd
};
extern const GfxMemoryAllocationMethod preferredAllocationMethod;
class WddmMemoryManager : public MemoryManager {
public:
using MemoryManager::allocateGraphicsMemoryWithProperties;
@ -68,7 +75,6 @@ class WddmMemoryManager : public MemoryManager {
protected:
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) override;
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) override;
GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override;
GraphicsAllocation *allocateUSMHostGraphicsMemory(const AllocationData &allocationData) override;
GraphicsAllocation *allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData) override;
GraphicsAllocation *allocateGraphicsMemory64kb(const AllocationData &allocationData) override;
@ -76,13 +82,17 @@ class WddmMemoryManager : public MemoryManager {
GraphicsAllocation *allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm) override;
GraphicsAllocation *allocateGraphicsMemoryWithGpuVa(const AllocationData &allocationData) override { return nullptr; }
GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override;
GraphicsAllocation *allocateSystemMemoryAndCreateGraphicsAllocationFromIt(const AllocationData &allocationData);
GraphicsAllocation *allocateGraphicsMemoryUsingKmdAndMapItToCpuVA(const AllocationData &allocationData, bool allowLargePages);
void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
void freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) override;
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override;
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
MOCKABLE_VIRTUAL size_t getHugeGfxMemoryChunkSize() const;
MOCKABLE_VIRTUAL size_t getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod allocationMethod) const;
GraphicsAllocation *allocateHugeGraphicsMemory(const AllocationData &allocationData, bool sharedVirtualAddress);
GraphicsAllocation *createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex);

View File

@ -104,13 +104,13 @@ NTSTATUS WddmMock::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D
bool WddmMock::createAllocation64k(WddmAllocation *wddmAllocation) {
if (wddmAllocation) {
return createAllocation64k(wddmAllocation->getDefaultGmm(), wddmAllocation->getHandleToModify(0u));
return createAllocation(wddmAllocation->getDefaultGmm(), wddmAllocation->getHandleToModify(0u));
}
return false;
}
bool WddmMock::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
bool WddmMock::createAllocation(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
createAllocationResult.called++;
return createAllocationResult.success = Wddm::createAllocation64k(gmm, outHandle);
return createAllocationResult.success = Wddm::createAllocation(gmm, outHandle);
}
bool WddmMock::destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {

View File

@ -58,7 +58,7 @@ class WddmMock : public Wddm {
bool mapGpuVirtualAddress(WddmAllocation *allocation);
bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) override;
NTSTATUS createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKMT_HANDLE &outHandle, D3DKMT_HANDLE &outResource, D3DKMT_HANDLE *outSharedHandle) override;
bool createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) override;
bool createAllocation(const Gmm *gmm, D3DKMT_HANDLE &outHandle) override;
bool destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) override;
NTSTATUS createAllocation(WddmAllocation *wddmAllocation);

View File

@ -20,7 +20,7 @@ TEST_F(WddmTests, whenCreatingAllocation64kThenDoNotCreateResource) {
D3DKMT_HANDLE handle;
Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 20, 0, false, true, true, {});
EXPECT_TRUE(wddm->createAllocation64k(&gmm, handle));
EXPECT_TRUE(wddm->createAllocation(&gmm, handle));
auto gdiParam = getMockAllocationFcn();
EXPECT_EQ(FALSE, gdiParam->Flags.CreateResource);
}