Cleanup Wddm interface 2/n
don't pass the entire WddmAllocation to createAllocation methods Change-Id: Ibd4c684a362edbe3b2c520b73b71246fed5a9399 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
fe07ede28d
commit
4605a48170
|
@ -402,20 +402,16 @@ bool Wddm::freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size)
|
|||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS Wddm::createAllocation(WddmAllocation *alloc) {
|
||||
NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
D3DDDI_ALLOCATIONINFO AllocationInfo = {0};
|
||||
D3DKMT_CREATEALLOCATION CreateAllocation = {0};
|
||||
size_t size;
|
||||
|
||||
if (alloc == nullptr)
|
||||
return false;
|
||||
size = alloc->getAlignedSize();
|
||||
if (size == 0)
|
||||
if (gmm == nullptr)
|
||||
return false;
|
||||
|
||||
AllocationInfo.pSystemMem = alloc->getAlignedCpuPtr();
|
||||
AllocationInfo.pPrivateDriverData = alloc->gmm->gmmResourceInfo->peekHandle();
|
||||
AllocationInfo.pSystemMem = alignedCpuPtr;
|
||||
AllocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();
|
||||
AllocationInfo.PrivateDriverDataSize = static_cast<unsigned int>(sizeof(GMM_RESOURCE_INFO));
|
||||
AllocationInfo.Flags.Primary = 0;
|
||||
|
||||
|
@ -429,7 +425,7 @@ NTSTATUS Wddm::createAllocation(WddmAllocation *alloc) {
|
|||
CreateAllocation.Flags.NonSecure = FALSE;
|
||||
CreateAllocation.Flags.CreateShared = FALSE;
|
||||
CreateAllocation.Flags.RestrictSharedAccess = FALSE;
|
||||
CreateAllocation.Flags.CreateResource = alloc->getAlignedCpuPtr() == 0 ? TRUE : FALSE;
|
||||
CreateAllocation.Flags.CreateResource = alignedCpuPtr ? TRUE : FALSE;
|
||||
CreateAllocation.pAllocationInfo = &AllocationInfo;
|
||||
CreateAllocation.hDevice = device;
|
||||
|
||||
|
@ -439,19 +435,19 @@ NTSTATUS Wddm::createAllocation(WddmAllocation *alloc) {
|
|||
return status;
|
||||
}
|
||||
|
||||
alloc->handle = AllocationInfo.hAllocation;
|
||||
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, alloc->handle, gdi->escape);
|
||||
outHandle = AllocationInfo.hAllocation;
|
||||
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, outHandle, gdi->escape);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Wddm::createAllocation64k(WddmAllocation *alloc) {
|
||||
bool Wddm::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DDDI_ALLOCATIONINFO AllocationInfo = {0};
|
||||
D3DKMT_CREATEALLOCATION CreateAllocation = {0};
|
||||
|
||||
AllocationInfo.pSystemMem = 0;
|
||||
AllocationInfo.pPrivateDriverData = alloc->gmm->gmmResourceInfo->peekHandle();
|
||||
AllocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();
|
||||
AllocationInfo.PrivateDriverDataSize = static_cast<unsigned int>(sizeof(GMM_RESOURCE_INFO));
|
||||
AllocationInfo.Flags.Primary = 0;
|
||||
|
||||
|
@ -469,9 +465,9 @@ bool Wddm::createAllocation64k(WddmAllocation *alloc) {
|
|||
return false;
|
||||
}
|
||||
|
||||
alloc->handle = AllocationInfo.hAllocation;
|
||||
outHandle = AllocationInfo.hAllocation;
|
||||
|
||||
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, alloc->handle, gdi->escape);
|
||||
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, outHandle, gdi->escape);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ class Wddm {
|
|||
MOCKABLE_VIRTUAL bool createContext(OsContextWin &osContext);
|
||||
MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext);
|
||||
MOCKABLE_VIRTUAL bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
|
||||
MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool createAllocation64k(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL NTSTATUS createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKMT_HANDLE &outHandle);
|
||||
MOCKABLE_VIRTUAL bool createAllocation64k(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 openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc);
|
||||
|
|
|
@ -67,7 +67,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const Allocati
|
|||
auto gmm = new Gmm(nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true, {});
|
||||
wddmAllocation->gmm = gmm;
|
||||
|
||||
if (!wddm->createAllocation64k(wddmAllocation.get())) {
|
||||
if (!wddm->createAllocation64k(gmm, wddmAllocation->handle)) {
|
||||
delete gmm;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -459,10 +459,10 @@ AlignedMallocRestrictions *WddmMemoryManager::getAlignedMallocRestrictions() {
|
|||
}
|
||||
|
||||
bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation) {
|
||||
auto wddmSuccess = wddm->createAllocation(allocation);
|
||||
auto wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->gmm, allocation->handle);
|
||||
if (wddmSuccess == STATUS_GRAPHICS_NO_VIDEO_MEMORY && deferredDeleter) {
|
||||
deferredDeleter->drain(true);
|
||||
wddmSuccess = wddm->createAllocation(allocation);
|
||||
wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->gmm, allocation->handle);
|
||||
}
|
||||
|
||||
if (wddmSuccess == STATUS_SUCCESS) {
|
||||
|
|
|
@ -50,23 +50,34 @@ bool WddmMock::freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t si
|
|||
freeGpuVirtualAddressResult.called++;
|
||||
return freeGpuVirtualAddressResult.success = Wddm::freeGpuVirtualAddress(gpuPtr, size);
|
||||
}
|
||||
|
||||
NTSTATUS WddmMock::createAllocation(WddmAllocation *alloc) {
|
||||
NTSTATUS WddmMock::createAllocation(WddmAllocation *wddmAllocation) {
|
||||
if (wddmAllocation) {
|
||||
return createAllocation(wddmAllocation->getAlignedCpuPtr(), wddmAllocation->gmm, wddmAllocation->handle);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
NTSTATUS WddmMock::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
|
||||
createAllocationResult.called++;
|
||||
if (callBaseDestroyAllocations) {
|
||||
createAllocationStatus = Wddm::createAllocation(alloc);
|
||||
createAllocationStatus = Wddm::createAllocation(alignedCpuPtr, gmm, outHandle);
|
||||
createAllocationResult.success = createAllocationStatus == STATUS_SUCCESS;
|
||||
} else {
|
||||
createAllocationResult.success = true;
|
||||
alloc->handle = ALLOCATION_HANDLE;
|
||||
outHandle = ALLOCATION_HANDLE;
|
||||
return createAllocationStatus;
|
||||
}
|
||||
return createAllocationStatus;
|
||||
}
|
||||
|
||||
bool WddmMock::createAllocation64k(WddmAllocation *alloc) {
|
||||
bool WddmMock::createAllocation64k(WddmAllocation *wddmAllocation) {
|
||||
if (wddmAllocation) {
|
||||
return createAllocation64k(wddmAllocation->gmm, wddmAllocation->handle);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool WddmMock::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
|
||||
createAllocationResult.called++;
|
||||
return createAllocationResult.success = Wddm::createAllocation64k(alloc);
|
||||
return createAllocationResult.success = Wddm::createAllocation64k(gmm, outHandle);
|
||||
}
|
||||
|
||||
bool WddmMock::destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {
|
||||
|
|
|
@ -62,9 +62,12 @@ class WddmMock : public Wddm {
|
|||
bool evict(const D3DKMT_HANDLE *handles, uint32_t num, uint64_t &sizeToTrim) override;
|
||||
bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, HeapIndex heapIndex) override;
|
||||
bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) override;
|
||||
NTSTATUS createAllocation(WddmAllocation *alloc) override;
|
||||
bool createAllocation64k(WddmAllocation *alloc) override;
|
||||
NTSTATUS createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKMT_HANDLE &outHandle) override;
|
||||
bool createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) override;
|
||||
bool destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) override;
|
||||
|
||||
NTSTATUS createAllocation(WddmAllocation *wddmAllocation);
|
||||
bool createAllocation64k(WddmAllocation *wddmAllocation);
|
||||
bool destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext);
|
||||
bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) override;
|
||||
bool createContext(OsContextWin &osContext) override;
|
||||
|
|
|
@ -142,7 +142,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafList
|
|||
auto gmm = std::unique_ptr<Gmm>(new Gmm(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
|
||||
wddmWithKmDafMock->createAllocation(&allocation);
|
||||
wddmWithKmDafMock->createAllocation(allocation.getAlignedCpuPtr(), gmm.get(), allocation.handle);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);
|
||||
|
@ -156,7 +156,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafLi
|
|||
auto gmm = std::unique_ptr<Gmm>(new Gmm(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
|
||||
wddmWithKmDafMock->createAllocation64k(&allocation);
|
||||
wddmWithKmDafMock->createAllocation64k(gmm.get(), allocation.handle);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);
|
||||
|
|
Loading…
Reference in New Issue