Add support for reserveGpuVirtualAddress.

Change-Id: I068df0dd3b2064cdb93be1c4408eeb86ff264d2f
This commit is contained in:
Mrozek, Michal
2019-02-26 08:28:41 +01:00
committed by sys_ocldev
parent 0a49afc7e8
commit ce77425428
7 changed files with 51 additions and 3 deletions

View File

@@ -75,6 +75,7 @@ SetMockCreateDeviceParams
getMockAllocation
getAdapterInfoAddress
getLastCallMapGpuVaArg
getLastCallReserveGpuVaArg
setMapGpuVaFailConfig
getCreateContextData
getCreateHwQueueData

View File

@@ -11,6 +11,7 @@
ADAPTER_INFO gAdapterInfo = {0};
D3DDDI_MAPGPUVIRTUALADDRESS gLastCallMapGpuVaArg = {0};
D3DDDI_RESERVEGPUVIRTUALADDRESS gLastCallReserveGpuVaArg = {0};
uint32_t gMapGpuVaFailConfigCount = 0;
uint32_t gMapGpuVaFailConfigMax = 0;
@@ -262,6 +263,12 @@ NTSTATUS __stdcall D3DKMTMapGpuVirtualAddress(IN OUT D3DDDI_MAPGPUVIRTUALADDRESS
return STATUS_PENDING;
}
NTSTATUS __stdcall D3DKMTReserveGpuVirtualAddress(IN OUT D3DDDI_RESERVEGPUVIRTUALADDRESS *reserveGpuVirtualAddress) {
gLastCallReserveGpuVaArg = *reserveGpuVirtualAddress;
reserveGpuVirtualAddress->VirtualAddress = reserveGpuVirtualAddress->MinimumAddress;
return STATUS_SUCCESS;
}
NTSTATUS __stdcall D3DKMTQueryAdapterInfo(IN CONST D3DKMT_QUERYADAPTERINFO *queryAdapterInfo) {
if (queryAdapterInfo == nullptr || queryAdapterInfo->hAdapter != ADAPTER_HANDLE) {
return STATUS_INVALID_PARAMETER;
@@ -454,6 +461,10 @@ D3DDDI_MAPGPUVIRTUALADDRESS *getLastCallMapGpuVaArg() {
return &gLastCallMapGpuVaArg;
}
D3DDDI_RESERVEGPUVIRTUALADDRESS *getLastCallReserveGpuVaArg() {
return &gLastCallReserveGpuVaArg;
}
void setMapGpuVaFailConfig(uint32_t count, uint32_t max) {
gMapGpuVaFailConfigCount = count;
gMapGpuVaFailConfigMax = max;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -26,7 +26,6 @@
FUNCTION(SignalSynchronizationObjectFromCpu, IN CONST D3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMCPU *) \
FUNCTION(WaitForSynchronizationObjectFromGpu, IN CONST D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMGPU *) \
FUNCTION(SignalSynchronizationObjectFromGpu, IN CONST D3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMGPU *) \
FUNCTION(ReserveGpuVirtualAddress, IN OUT D3DDDI_RESERVEGPUVIRTUALADDRESS *) \
FUNCTION(FreeGpuVirtualAddress, IN CONST D3DKMT_FREEGPUVIRTUALADDRESS *) \
FUNCTION(UpdateGpuVirtualAddress, IN CONST D3DKMT_UPDATEGPUVIRTUALADDRESS *) \
FUNCTION(SubmitCommand, IN CONST D3DKMT_SUBMITCOMMAND *) \
@@ -66,6 +65,7 @@ void SetMockCreateDeviceParams(D3DKMT_CREATEDEVICE params);
D3DKMT_CREATEALLOCATION *getMockAllocation();
ADAPTER_INFO *getAdapterInfoAddress();
D3DDDI_MAPGPUVIRTUALADDRESS *getLastCallMapGpuVaArg();
D3DDDI_RESERVEGPUVIRTUALADDRESS *getLastCallReserveGpuVaArg();
void setMapGpuVaFailConfig(uint32_t count, uint32_t max);
D3DKMT_CREATECONTEXTVIRTUAL *getCreateContextData();
D3DKMT_CREATEHWQUEUE *getCreateHwQueueData();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -33,6 +33,7 @@ struct GdiDllFixture {
getMockAllocationFcn = reinterpret_cast<decltype(&getMockAllocation)>(mockGdiDll->getProcAddress("getMockAllocation"));
getAdapterInfoAddressFcn = reinterpret_cast<decltype(&getAdapterInfoAddress)>(mockGdiDll->getProcAddress("getAdapterInfoAddress"));
getLastCallMapGpuVaArgFcn = reinterpret_cast<decltype(&getLastCallMapGpuVaArg)>(mockGdiDll->getProcAddress("getLastCallMapGpuVaArg"));
getLastCallReserveGpuVaArgFcn = reinterpret_cast<decltype(&getLastCallReserveGpuVaArg)>(mockGdiDll->getProcAddress("getLastCallReserveGpuVaArg"));
setMapGpuVaFailConfigFcn = reinterpret_cast<decltype(&setMapGpuVaFailConfig)>(mockGdiDll->getProcAddress("setMapGpuVaFailConfig"));
setMapGpuVaFailConfigFcn(0, 0);
getCreateContextDataFcn = reinterpret_cast<decltype(&getCreateContextData)>(mockGdiDll->getProcAddress("getCreateContextData"));
@@ -61,6 +62,7 @@ struct GdiDllFixture {
decltype(&getMockAllocation) getMockAllocationFcn = nullptr;
decltype(&getAdapterInfoAddress) getAdapterInfoAddressFcn = nullptr;
decltype(&getLastCallMapGpuVaArg) getLastCallMapGpuVaArgFcn = nullptr;
decltype(&getLastCallReserveGpuVaArg) getLastCallReserveGpuVaArgFcn = nullptr;
decltype(&setMapGpuVaFailConfig) setMapGpuVaFailConfigFcn = nullptr;
decltype(&getCreateContextData) getCreateContextDataFcn = nullptr;
decltype(&getCreateHwQueueData) getCreateHwQueueDataFcn = nullptr;

View File

@@ -213,6 +213,24 @@ TEST_F(Wddm20WithMockGdiDllTests, givenAllocationSmallerUnderlyingThanAlignedSiz
delete gmm;
}
TEST_F(Wddm20WithMockGdiDllTests, givenReserveCallWhenItIsCalledWithProperParamtersThenAddressInRangeIsReturend) {
auto sizeAlignedTo64Kb = 64 * KB;
auto reservationAddress = wddm->reserveGpuVirtualAddress(wddm->getGfxPartition().Heap32[0].Base,
wddm->getGfxPartition().Heap32[0].Limit,
sizeAlignedTo64Kb);
EXPECT_GE(reservationAddress, wddm->getGfxPartition().Heap32[0].Base);
auto programmedReserved = getLastCallReserveGpuVaArgFcn();
EXPECT_EQ(0llu, programmedReserved->BaseAddress);
EXPECT_EQ(wddm->getGfxPartition().Heap32[0].Base, programmedReserved->MinimumAddress);
EXPECT_EQ(wddm->getGfxPartition().Heap32[0].Limit, programmedReserved->MaximumAddress);
EXPECT_EQ(sizeAlignedTo64Kb, programmedReserved->Size);
auto pagingQueue = wddm->getPagingQueue();
EXPECT_NE(0llu, pagingQueue);
EXPECT_EQ(pagingQueue, programmedReserved->hPagingQueue);
}
TEST_F(Wddm20WithMockGdiDllTests, givenWddmAllocationWhenMappingGpuVaThenUseGmmSize) {
void *fakePtr = reinterpret_cast<void *>(0x123);