2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-01-22 23:43:26 +08:00
|
|
|
* Copyright (c) 2017 - 2018, Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "unit_tests/os_interface/windows/wddm_fixture.h"
|
|
|
|
|
|
|
|
#include "runtime/helpers/hw_info.h"
|
|
|
|
#include "runtime/helpers/options.h"
|
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
|
|
|
#include "runtime/os_interface/windows/os_interface.h"
|
|
|
|
#include "runtime/os_interface/os_library.h"
|
|
|
|
#include "runtime/os_interface/windows/wddm_allocation.h"
|
|
|
|
#include "runtime/os_interface/windows/wddm_memory_manager.h"
|
|
|
|
|
|
|
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
2018-05-08 02:42:00 +08:00
|
|
|
#include "unit_tests/mocks/mock_gmm_resource_info.h"
|
2018-02-28 23:52:08 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "runtime/os_interface/os_time.h"
|
|
|
|
|
2018-02-28 23:52:08 +08:00
|
|
|
#include <memory>
|
|
|
|
#include <functional>
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
using namespace OCLRT;
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
namespace GmmHelperFunctions {
|
|
|
|
Gmm *getGmm(void *ptr, size_t size) {
|
|
|
|
size_t alignedSize = alignSizeWholePage(ptr, size);
|
|
|
|
void *alignedPtr = alignUp(ptr, 4096);
|
|
|
|
Gmm *gmm = new Gmm;
|
|
|
|
|
|
|
|
gmm->resourceParams.Type = RESOURCE_BUFFER;
|
|
|
|
gmm->resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
|
|
|
|
gmm->resourceParams.BaseWidth = (uint32_t)alignedSize;
|
|
|
|
gmm->resourceParams.BaseHeight = 1;
|
|
|
|
gmm->resourceParams.Depth = 1;
|
|
|
|
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
|
|
|
|
|
|
|
|
gmm->resourceParams.pExistingSysMem = reinterpret_cast<GMM_VOIDPTR64>(alignedPtr);
|
|
|
|
gmm->resourceParams.ExistingSysMemSize = alignedSize;
|
|
|
|
gmm->resourceParams.BaseAlignment = 0;
|
|
|
|
|
|
|
|
gmm->resourceParams.Flags.Info.ExistingSysMem = 1;
|
|
|
|
gmm->resourceParams.Flags.Info.Linear = 1;
|
|
|
|
gmm->resourceParams.Flags.Info.Cacheable = 1;
|
|
|
|
gmm->resourceParams.Flags.Gpu.Texture = 1;
|
|
|
|
|
|
|
|
gmm->create();
|
|
|
|
|
|
|
|
EXPECT_NE(gmm->gmmResourceInfo.get(), nullptr);
|
|
|
|
|
|
|
|
return gmm;
|
|
|
|
}
|
|
|
|
} // namespace GmmHelperFunctions
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, givenMinWindowsAddressWhenWddmIsInitializedThenWddmUseThisAddress) {
|
2018-02-09 05:52:58 +08:00
|
|
|
uintptr_t expectedAddress = 0x200000;
|
2018-02-12 23:53:20 +08:00
|
|
|
EXPECT_EQ(expectedAddress, OCLRT::windowsMinAddress);
|
|
|
|
|
|
|
|
bool status = wddm->init<FamilyType>();
|
|
|
|
EXPECT_TRUE(status);
|
|
|
|
EXPECT_TRUE(wddm->isInitialized());
|
|
|
|
EXPECT_EQ(expectedAddress, wddm->getWddmMinAddress());
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, creation) {
|
2017-12-21 07:45:38 +08:00
|
|
|
bool error = wddm->init<FamilyType>();
|
|
|
|
EXPECT_TRUE(error);
|
|
|
|
EXPECT_TRUE(wddm->isInitialized());
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, doubleCreation) {
|
2018-05-08 02:42:00 +08:00
|
|
|
bool error = wddm->init<FamilyType>();
|
|
|
|
EXPECT_EQ(1u, wddm->createContextResult.called);
|
|
|
|
error |= wddm->init<FamilyType>();
|
|
|
|
EXPECT_EQ(1u, wddm->createContextResult.called);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(error);
|
2018-05-08 02:42:00 +08:00
|
|
|
EXPECT_TRUE(wddm->isInitialized());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-01-25 22:10:07 +08:00
|
|
|
TEST_F(WddmTest, givenNullPageTableManagerWhenUpdateAuxTableCalledThenReturnFalse) {
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->resetPageTableManager(nullptr);
|
|
|
|
EXPECT_EQ(nullptr, wddm->getPageTableManager());
|
2018-01-25 22:10:07 +08:00
|
|
|
|
|
|
|
auto gmm = std::unique_ptr<Gmm>(Gmm::create(nullptr, 1, false));
|
|
|
|
auto mockGmmRes = reinterpret_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
|
|
|
|
mockGmmRes->setUnifiedAuxTranslationCapable();
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
EXPECT_FALSE(wddm->updateAuxTable(1234u, gmm.get(), true));
|
2018-01-25 22:10:07 +08:00
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
TEST(WddmTestEnumAdapters, expectTrue) {
|
2018-02-28 23:52:08 +08:00
|
|
|
HardwareInfo outHwInfo;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
const HardwareInfo hwInfo = *platformDevices[0];
|
2018-03-02 04:50:09 +08:00
|
|
|
OsLibrary *mockGdiDll = setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-02-28 23:52:08 +08:00
|
|
|
bool success = Wddm::enumAdapters(0, outHwInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(success);
|
|
|
|
|
|
|
|
const HardwareInfo *hwinfo = *platformDevices;
|
|
|
|
|
2018-02-28 23:52:08 +08:00
|
|
|
ASSERT_NE(nullptr, outHwInfo.pPlatform);
|
|
|
|
EXPECT_EQ(outHwInfo.pPlatform->eDisplayCoreFamily, hwinfo->pPlatform->eDisplayCoreFamily);
|
2017-12-21 07:45:38 +08:00
|
|
|
delete mockGdiDll;
|
2018-02-28 23:52:08 +08:00
|
|
|
|
|
|
|
delete outHwInfo.pPlatform;
|
|
|
|
delete outHwInfo.pSkuTable;
|
|
|
|
delete outHwInfo.pSysInfo;
|
|
|
|
delete outHwInfo.pWaTable;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-02-28 23:52:08 +08:00
|
|
|
TEST(WddmTestEnumAdapters, givenEmptyHardwareInfoWhenEnumAdapterIsCalledThenCapabilityTableIsSet) {
|
2018-03-21 17:00:49 +08:00
|
|
|
HardwareInfo outHwInfo = {};
|
2018-02-28 23:52:08 +08:00
|
|
|
|
|
|
|
auto hwInfo = *platformDevices[0];
|
|
|
|
std::unique_ptr<OsLibrary> mockGdiDll(setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo));
|
|
|
|
|
|
|
|
bool success = Wddm::enumAdapters(0, outHwInfo);
|
|
|
|
EXPECT_TRUE(success);
|
|
|
|
|
|
|
|
const HardwareInfo *hwinfo = *platformDevices;
|
|
|
|
|
|
|
|
ASSERT_NE(nullptr, outHwInfo.pPlatform);
|
|
|
|
EXPECT_EQ(outHwInfo.pPlatform->eDisplayCoreFamily, hwinfo->pPlatform->eDisplayCoreFamily);
|
|
|
|
|
|
|
|
EXPECT_EQ(outHwInfo.capabilityTable.defaultProfilingTimerResolution, hwInfo.capabilityTable.defaultProfilingTimerResolution);
|
|
|
|
EXPECT_EQ(outHwInfo.capabilityTable.clVersionSupport, hwInfo.capabilityTable.clVersionSupport);
|
2018-03-21 17:00:49 +08:00
|
|
|
EXPECT_EQ(outHwInfo.capabilityTable.kmdNotifyProperties.enableKmdNotify, hwInfo.capabilityTable.kmdNotifyProperties.enableKmdNotify);
|
|
|
|
EXPECT_EQ(outHwInfo.capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, hwInfo.capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);
|
|
|
|
EXPECT_EQ(outHwInfo.capabilityTable.kmdNotifyProperties.enableQuickKmdSleep, hwInfo.capabilityTable.kmdNotifyProperties.enableQuickKmdSleep);
|
|
|
|
EXPECT_EQ(outHwInfo.capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds, hwInfo.capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds);
|
2018-02-28 23:52:08 +08:00
|
|
|
|
|
|
|
delete outHwInfo.pPlatform;
|
|
|
|
delete outHwInfo.pSkuTable;
|
|
|
|
delete outHwInfo.pSysInfo;
|
|
|
|
delete outHwInfo.pWaTable;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-02-28 23:52:08 +08:00
|
|
|
TEST(WddmTestEnumAdapters, givenUnknownPlatformWhenEnumAdapterIsCalledThenFalseIsReturnedAndOutputIsEmpty) {
|
|
|
|
HardwareInfo outHwInfo;
|
|
|
|
|
|
|
|
memset(&outHwInfo, 0, sizeof(outHwInfo));
|
|
|
|
|
|
|
|
HardwareInfo hwInfo = *platformDevices[0];
|
|
|
|
auto bkp = hwInfo.pPlatform->eProductFamily;
|
|
|
|
PLATFORM platform = *(hwInfo.pPlatform);
|
|
|
|
platform.eProductFamily = IGFX_UNKNOWN;
|
|
|
|
|
|
|
|
std::unique_ptr<OsLibrary, std::function<void(OsLibrary *)>> mockGdiDll(
|
|
|
|
setAdapterInfo(&platform, hwInfo.pSysInfo),
|
|
|
|
[&](OsLibrary *ptr) {
|
|
|
|
platform.eProductFamily = bkp;
|
|
|
|
typedef void(__stdcall * pfSetAdapterInfo)(const void *, const void *);
|
|
|
|
pfSetAdapterInfo fSetAdpaterInfo = reinterpret_cast<pfSetAdapterInfo>(ptr->getProcAddress("MockSetAdapterInfo"));
|
|
|
|
|
|
|
|
fSetAdpaterInfo(&platform, hwInfo.pSysInfo);
|
|
|
|
delete ptr;
|
|
|
|
});
|
|
|
|
bool ret = Wddm::enumAdapters(0, outHwInfo);
|
|
|
|
EXPECT_FALSE(ret);
|
|
|
|
EXPECT_EQ(nullptr, outHwInfo.pPlatform);
|
|
|
|
EXPECT_EQ(nullptr, outHwInfo.pSkuTable);
|
|
|
|
EXPECT_EQ(nullptr, outHwInfo.pSysInfo);
|
|
|
|
EXPECT_EQ(nullptr, outHwInfo.pWaTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(WddmTestEnumAdapters, devIdExpectFalse) {
|
|
|
|
HardwareInfo tempHwInfos;
|
|
|
|
|
|
|
|
bool success = Wddm::enumAdapters(1, tempHwInfos);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_FALSE(success);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, context) {
|
2018-05-02 18:00:28 +08:00
|
|
|
EXPECT_TRUE(wddm->getOsDeviceContext() == static_cast<D3DKMT_HANDLE>(0));
|
2017-12-21 07:45:38 +08:00
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
2018-05-02 18:00:28 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(wddm->createContext());
|
|
|
|
|
|
|
|
auto context = wddm->getOsDeviceContext();
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(context != static_cast<D3DKMT_HANDLE>(0));
|
2018-05-02 18:00:28 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(wddm->destroyContext(context));
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, allocation) {
|
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
|
|
|
OsAgnosticMemoryManager mm(false);
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation(mm.allocateSystemMemory(100, 0), 100, nullptr);
|
2018-05-08 02:42:00 +08:00
|
|
|
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
allocation.gmm = gmm;
|
2018-01-08 23:31:29 +08:00
|
|
|
auto status = wddm->createAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-08 23:31:29 +08:00
|
|
|
EXPECT_EQ(STATUS_SUCCESS, status);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(allocation.handle != 0);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
auto error = wddm->destroyAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(error);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
delete gmm;
|
2017-12-21 07:45:38 +08:00
|
|
|
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTestWithMockGdiDll, givenAllocationSmallerUnderlyingThanAlignedSizeWhenCreatedThenWddmUseAligned) {
|
2018-02-02 00:16:36 +08:00
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
void *ptr = reinterpret_cast<void *>(wddm->virtualAllocAddress + 0x1000);
|
2018-02-02 00:16:36 +08:00
|
|
|
size_t underlyingSize = 0x2100;
|
|
|
|
size_t alignedSize = 0x3000;
|
|
|
|
|
|
|
|
size_t underlyingPages = underlyingSize / MemoryConstants::pageSize;
|
|
|
|
size_t alignedPages = alignedSize / MemoryConstants::pageSize;
|
|
|
|
|
|
|
|
WddmAllocation allocation(ptr, 0x2100, ptr, 0x3000, nullptr);
|
2018-05-08 02:42:00 +08:00
|
|
|
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getAlignedCpuPtr(), allocation.getAlignedSize());
|
2018-02-02 00:16:36 +08:00
|
|
|
|
|
|
|
allocation.gmm = gmm;
|
|
|
|
auto status = wddm->createAllocation(&allocation);
|
|
|
|
|
|
|
|
EXPECT_EQ(STATUS_SUCCESS, status);
|
|
|
|
EXPECT_NE(0, allocation.handle);
|
|
|
|
|
2018-02-27 18:08:22 +08:00
|
|
|
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.getAlignedSize(), allocation.is32BitAllocation, false, false);
|
2018-02-07 05:43:38 +08:00
|
|
|
EXPECT_TRUE(ret);
|
|
|
|
|
2018-02-02 00:16:36 +08:00
|
|
|
EXPECT_EQ(alignedPages, getLastCallMapGpuVaArgFcn()->SizeInPages);
|
|
|
|
EXPECT_NE(underlyingPages, getLastCallMapGpuVaArgFcn()->SizeInPages);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
ret = wddm->destroyAllocation(&allocation);
|
2018-02-02 00:16:36 +08:00
|
|
|
EXPECT_TRUE(ret);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
delete gmm;
|
2018-02-02 00:16:36 +08:00
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
HWTEST_F(WddmTest, createAllocation32bit) {
|
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
|
|
|
|
|
|
|
uint64_t heap32baseAddress = 0x40000;
|
|
|
|
uint64_t heap32Size = 0x40000;
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->setHeap32(heap32baseAddress, heap32Size);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
void *alignedPtr = (void *)0x12000;
|
|
|
|
size_t alignedSize = 0x2000;
|
|
|
|
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation(alignedPtr, alignedSize, nullptr);
|
2018-05-08 02:42:00 +08:00
|
|
|
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
allocation.gmm = gmm;
|
|
|
|
allocation.is32BitAllocation = true; // mark 32 bit allocation
|
|
|
|
|
2018-01-08 23:31:29 +08:00
|
|
|
auto status = wddm->createAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-08 23:31:29 +08:00
|
|
|
EXPECT_EQ(STATUS_SUCCESS, status);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(allocation.handle != 0);
|
|
|
|
|
2018-02-27 18:08:22 +08:00
|
|
|
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.getAlignedSize(), allocation.is32BitAllocation, false, false);
|
2018-02-07 05:43:38 +08:00
|
|
|
EXPECT_TRUE(ret);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
EXPECT_EQ(1u, wddm->mapGpuVirtualAddressResult.called);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_LE(heap32baseAddress, allocation.gpuPtr);
|
|
|
|
EXPECT_GT(heap32baseAddress + heap32Size, allocation.gpuPtr);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
auto success = wddm->destroyAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(success);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
delete gmm;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-02-28 15:31:38 +08:00
|
|
|
HWTEST_F(WddmTest, givenGraphicsAllocationWhenItIsMappedInHeap1ThenItHasGpuAddressWithingHeap1Limits) {
|
|
|
|
wddm->init<FamilyType>();
|
|
|
|
void *alignedPtr = (void *)0x12000;
|
|
|
|
size_t alignedSize = 0x2000;
|
|
|
|
WddmAllocation allocation(alignedPtr, alignedSize, nullptr);
|
|
|
|
|
|
|
|
allocation.handle = ALLOCATION_HANDLE;
|
2018-05-08 02:42:00 +08:00
|
|
|
allocation.gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
2018-02-28 15:31:38 +08:00
|
|
|
|
|
|
|
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.getAlignedSize(), false, false, true);
|
|
|
|
EXPECT_TRUE(ret);
|
|
|
|
|
2018-03-03 04:43:37 +08:00
|
|
|
auto cannonizedHeapBase = Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Base);
|
|
|
|
auto cannonizedHeapEnd = Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Limit);
|
2018-02-28 15:31:38 +08:00
|
|
|
|
|
|
|
EXPECT_GE(allocation.gpuPtr, cannonizedHeapBase);
|
|
|
|
EXPECT_LE(allocation.gpuPtr, cannonizedHeapEnd);
|
2018-05-08 02:42:00 +08:00
|
|
|
delete allocation.gmm;
|
2018-02-28 15:31:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTestWithMockGdiDll, GivenThreeOsHandlesWhenAskedForDestroyAllocationsThenAllMarkedAllocationsAreDestroyed) {
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(wddm->init<FamilyType>());
|
|
|
|
OsHandleStorage storage;
|
|
|
|
OsHandle osHandle1 = {0};
|
|
|
|
OsHandle osHandle2 = {0};
|
|
|
|
OsHandle osHandle3 = {0};
|
|
|
|
|
|
|
|
osHandle1.handle = ALLOCATION_HANDLE;
|
|
|
|
osHandle2.handle = ALLOCATION_HANDLE;
|
|
|
|
osHandle3.handle = ALLOCATION_HANDLE;
|
|
|
|
|
|
|
|
storage.fragmentStorageData[0].osHandleStorage = &osHandle1;
|
|
|
|
storage.fragmentStorageData[0].freeTheFragment = true;
|
|
|
|
|
|
|
|
storage.fragmentStorageData[1].osHandleStorage = &osHandle2;
|
|
|
|
storage.fragmentStorageData[1].freeTheFragment = false;
|
|
|
|
|
|
|
|
storage.fragmentStorageData[2].osHandleStorage = &osHandle3;
|
|
|
|
storage.fragmentStorageData[2].freeTheFragment = true;
|
|
|
|
|
|
|
|
D3DKMT_HANDLE handles[3] = {ALLOCATION_HANDLE, ALLOCATION_HANDLE, ALLOCATION_HANDLE};
|
|
|
|
bool retVal = wddm->destroyAllocations(handles, 3, 0, 0);
|
|
|
|
EXPECT_TRUE(retVal);
|
|
|
|
|
|
|
|
auto destroyWithResourceHandleCalled = 0u;
|
|
|
|
D3DKMT_DESTROYALLOCATION2 *ptrToDestroyAlloc2 = nullptr;
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
getSizesFcn(destroyWithResourceHandleCalled, ptrToDestroyAlloc2);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(0u, ptrToDestroyAlloc2->Flags.SynchronousDestroy);
|
|
|
|
EXPECT_EQ(1u, ptrToDestroyAlloc2->Flags.AssumeNotInUse);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, mapAndFreeGpuVa) {
|
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
|
|
|
|
|
|
|
OsAgnosticMemoryManager mm(false);
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation(mm.allocateSystemMemory(100, 0), 100, nullptr);
|
2018-05-08 02:42:00 +08:00
|
|
|
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
allocation.gmm = gmm;
|
2018-01-08 23:31:29 +08:00
|
|
|
auto status = wddm->createAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-08 23:31:29 +08:00
|
|
|
EXPECT_EQ(STATUS_SUCCESS, status);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(allocation.handle != 0);
|
|
|
|
|
2018-02-27 18:08:22 +08:00
|
|
|
auto error = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.getUnderlyingBufferSize(), false, false, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(error);
|
|
|
|
EXPECT_TRUE(allocation.gpuPtr != 0);
|
|
|
|
|
|
|
|
error = wddm->freeGpuVirtualAddres(allocation.gpuPtr, allocation.getUnderlyingBufferSize());
|
|
|
|
EXPECT_TRUE(error);
|
|
|
|
EXPECT_TRUE(allocation.gpuPtr == 0);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
error = wddm->destroyAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(error);
|
2018-05-08 02:42:00 +08:00
|
|
|
delete gmm;
|
2017-12-21 07:45:38 +08:00
|
|
|
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, givenNullAllocationWhenCreateThenAllocateAndMap) {
|
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
|
|
|
OsAgnosticMemoryManager mm(false);
|
|
|
|
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation(nullptr, 100, nullptr);
|
2018-05-08 02:42:00 +08:00
|
|
|
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
allocation.gmm = gmm;
|
2018-01-08 23:31:29 +08:00
|
|
|
auto status = wddm->createAllocation(&allocation);
|
|
|
|
EXPECT_EQ(STATUS_SUCCESS, status);
|
2018-02-07 05:43:38 +08:00
|
|
|
|
2018-02-27 18:08:22 +08:00
|
|
|
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.getAlignedSize(), allocation.is32BitAllocation, false, false);
|
2018-02-07 05:43:38 +08:00
|
|
|
EXPECT_TRUE(ret);
|
|
|
|
|
|
|
|
EXPECT_NE(0u, allocation.gpuPtr);
|
|
|
|
EXPECT_EQ(allocation.gpuPtr, Gmm::canonize(allocation.gpuPtr));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
delete gmm;
|
2017-12-21 07:45:38 +08:00
|
|
|
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, makeResidentNonResident) {
|
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
|
|
|
|
|
|
|
OsAgnosticMemoryManager mm(false);
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation(mm.allocateSystemMemory(100, 0), 100, nullptr);
|
2018-05-08 02:42:00 +08:00
|
|
|
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
allocation.gmm = gmm;
|
2018-01-08 23:31:29 +08:00
|
|
|
auto status = wddm->createAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-08 23:31:29 +08:00
|
|
|
EXPECT_EQ(STATUS_SUCCESS, status);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(allocation.handle != 0);
|
|
|
|
|
2018-02-27 18:08:22 +08:00
|
|
|
auto error = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.getUnderlyingBufferSize(), false, false, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE(error);
|
|
|
|
EXPECT_TRUE(allocation.gpuPtr != 0);
|
|
|
|
|
|
|
|
error = wddm->makeResident(&allocation.handle, 1, false, nullptr);
|
|
|
|
EXPECT_TRUE(error);
|
|
|
|
|
|
|
|
uint64_t sizeToTrim;
|
|
|
|
error = wddm->evict(&allocation.handle, 1, sizeToTrim);
|
|
|
|
EXPECT_TRUE(error);
|
|
|
|
|
|
|
|
auto monitoredFence = wddm->getMonitoredFence();
|
|
|
|
UINT64 fenceValue = 100;
|
|
|
|
monitoredFence.cpuAddress = &fenceValue;
|
|
|
|
monitoredFence.currentFenceValue = 101;
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
error = wddm->destroyAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(error);
|
2018-05-08 02:42:00 +08:00
|
|
|
delete gmm;
|
2017-12-21 07:45:38 +08:00
|
|
|
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(WddmTest, GetCpuTime) {
|
|
|
|
uint64_t time = 0;
|
|
|
|
std::unique_ptr<OSTime> osTime(OSTime::create(nullptr).release());
|
|
|
|
auto error = osTime->getCpuTime(&time);
|
|
|
|
EXPECT_TRUE(error);
|
|
|
|
EXPECT_NE(0, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(WddmTest, GivenNoOSInterfaceGetCpuGpuTimeReturnsError) {
|
|
|
|
TimeStampData CPUGPUTime = {0};
|
|
|
|
std::unique_ptr<OSTime> osTime(OSTime::create(nullptr).release());
|
|
|
|
auto success = osTime->getCpuGpuTime(&CPUGPUTime);
|
|
|
|
EXPECT_FALSE(success);
|
|
|
|
EXPECT_EQ(0, CPUGPUTime.CPUTimeinNS);
|
|
|
|
EXPECT_EQ(0, CPUGPUTime.GPUTimeStamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(WddmTest, GetCpuGpuTime) {
|
|
|
|
TimeStampData CPUGPUTime01 = {0};
|
|
|
|
TimeStampData CPUGPUTime02 = {0};
|
|
|
|
std::unique_ptr<OSInterface> osInterface(new OSInterface());
|
2018-05-08 02:42:00 +08:00
|
|
|
osInterface->get()->setWddm(wddm.get());
|
2017-12-21 07:45:38 +08:00
|
|
|
std::unique_ptr<OSTime> osTime(OSTime::create(osInterface.get()).release());
|
|
|
|
auto success = osTime->getCpuGpuTime(&CPUGPUTime01);
|
|
|
|
EXPECT_TRUE(success);
|
|
|
|
EXPECT_NE(0, CPUGPUTime01.CPUTimeinNS);
|
|
|
|
EXPECT_NE(0, CPUGPUTime01.GPUTimeStamp);
|
|
|
|
success = osTime->getCpuGpuTime(&CPUGPUTime02);
|
|
|
|
EXPECT_TRUE(success);
|
|
|
|
EXPECT_NE(0, CPUGPUTime02.CPUTimeinNS);
|
|
|
|
EXPECT_NE(0, CPUGPUTime02.GPUTimeStamp);
|
|
|
|
EXPECT_GT(CPUGPUTime02.GPUTimeStamp, CPUGPUTime01.GPUTimeStamp);
|
|
|
|
EXPECT_GT(CPUGPUTime02.CPUTimeinNS, CPUGPUTime01.CPUTimeinNS);
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTestWithMockGdiDll, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenGraphicsAllocationWithSharedPropertiesIsCreated) {
|
2017-12-21 07:45:38 +08:00
|
|
|
void *pSysMem = (void *)0x1000;
|
2018-01-05 00:48:46 +08:00
|
|
|
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
|
2018-05-08 02:42:00 +08:00
|
|
|
auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(0u, status);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->init<FamilyType>();
|
|
|
|
WddmMemoryManager mm(false, wddm.release());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, false);
|
|
|
|
auto wddmAllocation = (WddmAllocation *)graphicsAllocation;
|
|
|
|
ASSERT_NE(nullptr, wddmAllocation);
|
|
|
|
|
|
|
|
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->peekSharedHandle());
|
|
|
|
EXPECT_EQ(RESOURCE_HANDLE, wddmAllocation->resourceHandle);
|
|
|
|
EXPECT_NE(0u, wddmAllocation->handle);
|
|
|
|
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->handle);
|
|
|
|
EXPECT_NE(0u, wddmAllocation->getGpuAddress());
|
|
|
|
EXPECT_EQ(wddmAllocation->gpuPtr, wddmAllocation->getGpuAddress());
|
|
|
|
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
|
|
|
|
EXPECT_EQ(nullptr, wddmAllocation->getAlignedCpuPtr());
|
|
|
|
EXPECT_NE(nullptr, wddmAllocation->gmm);
|
|
|
|
|
|
|
|
EXPECT_EQ(4096u, wddmAllocation->gmm->gmmResourceInfo->getSizeAllocation());
|
|
|
|
|
|
|
|
mm.freeGraphicsMemory(graphicsAllocation);
|
|
|
|
auto destroyWithResourceHandleCalled = 0u;
|
|
|
|
D3DKMT_DESTROYALLOCATION2 *ptrToDestroyAlloc2 = nullptr;
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
status = getSizesFcn(destroyWithResourceHandleCalled, ptrToDestroyAlloc2);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(0u, ptrToDestroyAlloc2->Flags.SynchronousDestroy);
|
|
|
|
EXPECT_EQ(1u, ptrToDestroyAlloc2->Flags.AssumeNotInUse);
|
|
|
|
|
|
|
|
EXPECT_EQ(0u, status);
|
|
|
|
EXPECT_EQ(1u, destroyWithResourceHandleCalled);
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTestWithMockGdiDll, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenMapGpuVaWithCpuPtrDepensOnBitness) {
|
2017-12-21 07:45:38 +08:00
|
|
|
void *pSysMem = (void *)0x1000;
|
2018-01-05 00:48:46 +08:00
|
|
|
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
|
2018-05-08 02:42:00 +08:00
|
|
|
auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(0u, status);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
auto mockWddm = wddm.release();
|
2017-12-21 07:45:38 +08:00
|
|
|
mockWddm->init<FamilyType>();
|
|
|
|
WddmMemoryManager mm(false, mockWddm);
|
|
|
|
|
|
|
|
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, false);
|
|
|
|
auto wddmAllocation = (WddmAllocation *)graphicsAllocation;
|
|
|
|
ASSERT_NE(nullptr, wddmAllocation);
|
|
|
|
|
|
|
|
if (is32bit) {
|
|
|
|
EXPECT_NE(mockWddm->mapGpuVirtualAddressResult.cpuPtrPassed, nullptr);
|
|
|
|
} else {
|
|
|
|
EXPECT_EQ(mockWddm->mapGpuVirtualAddressResult.cpuPtrPassed, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
mm.freeGraphicsMemory(graphicsAllocation);
|
|
|
|
}
|
|
|
|
|
2018-01-22 23:43:26 +08:00
|
|
|
HWTEST_F(WddmTest, givenWddmCreatedWhenNotInitedThenMinAddressZero) {
|
|
|
|
uintptr_t expected = 0;
|
|
|
|
uintptr_t actual = wddm->getWddmMinAddress();
|
|
|
|
EXPECT_EQ(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, givenWddmCreatedWhenInitedThenMinAddressValid) {
|
|
|
|
bool ret = wddm->init<FamilyType>();
|
|
|
|
EXPECT_TRUE(ret);
|
|
|
|
|
|
|
|
uintptr_t expected = windowsMinAddress;
|
|
|
|
uintptr_t actual = wddm->getWddmMinAddress();
|
|
|
|
EXPECT_EQ(expected, actual);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
HWTEST_F(WddmInstrumentationTest, configureDeviceAddressSpaceOnInit) {
|
|
|
|
SYSTEM_INFO sysInfo = {};
|
|
|
|
WddmMock::getSystemInfo(&sysInfo);
|
|
|
|
uintptr_t maxAddr = reinterpret_cast<uintptr_t>(sysInfo.lpMaximumApplicationAddress) + 1;
|
|
|
|
|
|
|
|
D3DKMT_HANDLE adapterHandle = ADAPTER_HANDLE;
|
|
|
|
D3DKMT_HANDLE deviceHandle = DEVICE_HANDLE;
|
|
|
|
const HardwareInfo hwInfo = *platformDevices[0];
|
|
|
|
BOOLEAN FtrL3IACoherency = hwInfo.pSkuTable->ftrL3IACoherency ? 1 : 0;
|
|
|
|
|
|
|
|
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(adapterHandle,
|
|
|
|
deviceHandle,
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->gdi->escape.mFunc,
|
2017-12-21 07:45:38 +08:00
|
|
|
maxAddr,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
FtrL3IACoherency,
|
|
|
|
0,
|
|
|
|
0))
|
|
|
|
.Times(1)
|
|
|
|
.WillRepeatedly(::testing::Return(true));
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->init<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
EXPECT_TRUE(wddm->isInitialized());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmInstrumentationTest, configureDeviceAddressSpaceNoAdapter) {
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->adapter = static_cast<D3DKMT_HANDLE>(0);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(static_cast<D3DKMT_HANDLE>(0),
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_))
|
|
|
|
.Times(1)
|
|
|
|
.WillRepeatedly(::testing::Return(false));
|
2018-05-08 02:42:00 +08:00
|
|
|
auto ret = wddm->configureDeviceAddressSpace<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_FALSE(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmInstrumentationTest, configureDeviceAddressSpaceNoDevice) {
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->device = static_cast<D3DKMT_HANDLE>(0);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_,
|
|
|
|
static_cast<D3DKMT_HANDLE>(0),
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_))
|
|
|
|
.Times(1)
|
|
|
|
.WillRepeatedly(::testing::Return(false));
|
2018-05-08 02:42:00 +08:00
|
|
|
auto ret = wddm->configureDeviceAddressSpace<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_FALSE(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmInstrumentationTest, configureDeviceAddressSpaceNoEscFunc) {
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->gdi->escape = static_cast<PFND3DKMT_ESCAPE>(nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
static_cast<PFND3DKMT_ESCAPE>(nullptr),
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_,
|
|
|
|
::testing::_))
|
|
|
|
.Times(1)
|
|
|
|
.WillRepeatedly(::testing::Return(false));
|
2018-05-08 02:42:00 +08:00
|
|
|
auto ret = wddm->configureDeviceAddressSpace<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_FALSE(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, getMaxApplicationAddress) {
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->init<FamilyType>();
|
|
|
|
EXPECT_TRUE(wddm->isInitialized());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
uint64_t maxAddr = wddm->getMaxApplicationAddress();
|
2017-12-21 07:45:38 +08:00
|
|
|
if (is32bit) {
|
|
|
|
EXPECT_EQ(maxAddr, MemoryConstants::max32BitAppAddress);
|
|
|
|
} else {
|
|
|
|
EXPECT_EQ(maxAddr, MemoryConstants::max64BitAppAddress);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTest, dontCallCreateContextBeforeConfigureDeviceAddressSpace) {
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->createContext();
|
|
|
|
EXPECT_EQ(1u, wddm->createContextResult.called); // dont care about the result
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->configureDeviceAddressSpace<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
EXPECT_EQ(1u, wddm->configureDeviceAddressSpaceResult.called);
|
|
|
|
EXPECT_FALSE(wddm->configureDeviceAddressSpaceResult.success);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTestWithMockGdiDll, givenUseNoRingFlushesKmdModeDebugFlagToFalseWhenCreateContextIsCalledThenNoRingFlushesKmdModeIsSetToFalse) {
|
2018-02-16 16:07:49 +08:00
|
|
|
DebugManagerStateRestore dbgRestore;
|
|
|
|
DebugManager.flags.UseNoRingFlushesKmdMode.set(false);
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->init<FamilyType>();
|
2018-02-16 16:07:49 +08:00
|
|
|
auto createContextParams = this->getCreateContextDataFcn();
|
|
|
|
auto privateData = (CREATECONTEXT_PVTDATA *)createContextParams->pPrivateDriverData;
|
|
|
|
EXPECT_FALSE(!!privateData->NoRingFlushes);
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTestWithMockGdiDll, givenUseNoRingFlushesKmdModeDebugFlagToTrueWhenCreateContextIsCalledThenNoRingFlushesKmdModeIsSetToTrue) {
|
2018-02-16 16:07:49 +08:00
|
|
|
DebugManagerStateRestore dbgRestore;
|
|
|
|
DebugManager.flags.UseNoRingFlushesKmdMode.set(true);
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->init<FamilyType>();
|
2018-02-16 16:07:49 +08:00
|
|
|
auto createContextParams = this->getCreateContextDataFcn();
|
|
|
|
auto privateData = (CREATECONTEXT_PVTDATA *)createContextParams->pPrivateDriverData;
|
|
|
|
EXPECT_TRUE(!!privateData->NoRingFlushes);
|
|
|
|
}
|
|
|
|
|
2018-05-15 20:07:37 +08:00
|
|
|
HWTEST_F(WddmTestWithMockGdiDll, givenHwQueueSupportEnabledWhenCreateContextIsCalledThenSetAppropriateFlag) {
|
|
|
|
DebugManagerStateRestore dbgRestore;
|
|
|
|
DebugManager.flags.HwQueueSupported.set(true);
|
|
|
|
|
|
|
|
wddm->init<FamilyType>();
|
|
|
|
EXPECT_EQ(1u, getCreateContextDataFcn()->Flags.HwQueueSupported);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(WddmTestWithMockGdiDll, givenHwQueueSupportDisabledWhenCreateContextIsCalledThenSetAppropriateFlag) {
|
|
|
|
DebugManagerStateRestore dbgRestore;
|
|
|
|
DebugManager.flags.HwQueueSupported.set(false);
|
|
|
|
|
|
|
|
wddm->init<FamilyType>();
|
|
|
|
EXPECT_EQ(0u, getCreateContextDataFcn()->Flags.HwQueueSupported);
|
|
|
|
}
|
|
|
|
|
2018-03-01 21:44:09 +08:00
|
|
|
HWTEST_F(WddmTest, givenDebugManagerWhenGetForUseNoRingFlushesKmdModeIsCalledThenTrueIsReturned) {
|
|
|
|
EXPECT_TRUE(DebugManager.flags.UseNoRingFlushesKmdMode.get());
|
|
|
|
}
|
|
|
|
|
2018-05-15 20:07:37 +08:00
|
|
|
HWTEST_F(WddmTest, givenDebugManagerWhenGetForHwQueueSupportedIsCalledThenFalseIsReturned) {
|
|
|
|
EXPECT_FALSE(DebugManager.flags.HwQueueSupported.get());
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, makeResidentMultipleHandles) {
|
2017-12-21 07:45:38 +08:00
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
|
|
|
|
|
|
|
OsAgnosticMemoryManager mm(false);
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation(mm.allocateSystemMemory(100, 0), 100, nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
allocation.handle = ALLOCATION_HANDLE;
|
|
|
|
|
|
|
|
D3DKMT_HANDLE handles[2] = {0};
|
|
|
|
|
|
|
|
handles[0] = allocation.handle;
|
|
|
|
handles[1] = allocation.handle;
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getMakeResidentArg().NumAllocations = 0;
|
|
|
|
gdi->getMakeResidentArg().AllocationList = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
bool error = wddm->makeResident(handles, 2, false, nullptr);
|
|
|
|
EXPECT_TRUE(error);
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_EQ(2u, gdi->getMakeResidentArg().NumAllocations);
|
|
|
|
EXPECT_EQ(handles, gdi->getMakeResidentArg().AllocationList);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, makeResidentMultipleHandlesWithReturnBytesToTrim) {
|
2017-12-21 07:45:38 +08:00
|
|
|
wddm->init<FamilyType>();
|
|
|
|
ASSERT_TRUE(wddm->isInitialized());
|
|
|
|
|
|
|
|
OsAgnosticMemoryManager mm(false);
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation(mm.allocateSystemMemory(100, 0), 100, nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
allocation.handle = ALLOCATION_HANDLE;
|
|
|
|
|
|
|
|
D3DKMT_HANDLE handles[2] = {0};
|
|
|
|
|
|
|
|
handles[0] = allocation.handle;
|
|
|
|
handles[1] = allocation.handle;
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getMakeResidentArg().NumAllocations = 0;
|
|
|
|
gdi->getMakeResidentArg().AllocationList = nullptr;
|
|
|
|
gdi->getMakeResidentArg().NumBytesToTrim = 30;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
uint64_t bytesToTrim = 0;
|
|
|
|
bool success = wddm->makeResident(handles, 2, false, &bytesToTrim);
|
|
|
|
EXPECT_TRUE(success);
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_EQ(gdi->getMakeResidentArg().NumBytesToTrim, bytesToTrim);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, makeNonResidentCallsEvict) {
|
|
|
|
wddm->init<FamilyType>();
|
2018-01-31 18:22:13 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
D3DKMT_HANDLE handle = (D3DKMT_HANDLE)0x1234;
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getEvictArg().AllocationList = nullptr;
|
|
|
|
gdi->getEvictArg().Flags.Value = 0;
|
|
|
|
gdi->getEvictArg().hDevice = 0;
|
|
|
|
gdi->getEvictArg().NumAllocations = 0;
|
|
|
|
gdi->getEvictArg().NumBytesToTrim = 20;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
uint64_t sizeToTrim = 10;
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->evict(&handle, 1, sizeToTrim);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_EQ(1u, gdi->getEvictArg().NumAllocations);
|
|
|
|
EXPECT_EQ(&handle, gdi->getEvictArg().AllocationList);
|
|
|
|
EXPECT_EQ(wddm->getDevice(), gdi->getEvictArg().hDevice);
|
|
|
|
EXPECT_EQ(0u, gdi->getEvictArg().NumBytesToTrim);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, destroyAllocationWithLastFenceValueGreaterThanCurrentValueCallsWaitFromCpu) {
|
|
|
|
wddm->init<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation((void *)0x23000, 0x1000, nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
allocation.getResidencyData().lastFence = 20;
|
|
|
|
allocation.handle = ALLOCATION_HANDLE;
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
*wddm->getMonitoredFence().cpuAddress = 10;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
D3DKMT_HANDLE handle = (D3DKMT_HANDLE)0x1234;
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getWaitFromCpuArg().FenceValueArray = nullptr;
|
|
|
|
gdi->getWaitFromCpuArg().Flags.Value = 0;
|
|
|
|
gdi->getWaitFromCpuArg().hDevice = (D3DKMT_HANDLE)0;
|
|
|
|
gdi->getWaitFromCpuArg().ObjectCount = 0;
|
|
|
|
gdi->getWaitFromCpuArg().ObjectHandleArray = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getDestroyArg().AllocationCount = 0;
|
|
|
|
gdi->getDestroyArg().Flags.Value = 0;
|
|
|
|
gdi->getDestroyArg().hDevice = (D3DKMT_HANDLE)0;
|
|
|
|
gdi->getDestroyArg().hResource = (D3DKMT_HANDLE)0;
|
|
|
|
gdi->getDestroyArg().phAllocationList = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->destroyAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_NE(nullptr, gdi->getWaitFromCpuArg().FenceValueArray);
|
|
|
|
EXPECT_EQ(wddm->getDevice(), gdi->getWaitFromCpuArg().hDevice);
|
|
|
|
EXPECT_EQ(1u, gdi->getWaitFromCpuArg().ObjectCount);
|
|
|
|
EXPECT_EQ(&wddm->getMonitoredFence().fenceHandle, gdi->getWaitFromCpuArg().ObjectHandleArray);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_EQ(wddm->getDevice(), gdi->getDestroyArg().hDevice);
|
|
|
|
EXPECT_EQ(1u, gdi->getDestroyArg().AllocationCount);
|
|
|
|
EXPECT_NE(nullptr, gdi->getDestroyArg().phAllocationList);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, destroyAllocationWithLastFenceValueLessEqualToCurrentValueDoesNotCallWaitFromCpu) {
|
|
|
|
wddm->init<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation((void *)0x23000, 0x1000, nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
allocation.getResidencyData().lastFence = 10;
|
|
|
|
allocation.handle = ALLOCATION_HANDLE;
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
*wddm->getMonitoredFence().cpuAddress = 10;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
D3DKMT_HANDLE handle = (D3DKMT_HANDLE)0x1234;
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getWaitFromCpuArg().FenceValueArray = nullptr;
|
|
|
|
gdi->getWaitFromCpuArg().Flags.Value = 0;
|
|
|
|
gdi->getWaitFromCpuArg().hDevice = (D3DKMT_HANDLE)0;
|
|
|
|
gdi->getWaitFromCpuArg().ObjectCount = 0;
|
|
|
|
gdi->getWaitFromCpuArg().ObjectHandleArray = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getDestroyArg().AllocationCount = 0;
|
|
|
|
gdi->getDestroyArg().Flags.Value = 0;
|
|
|
|
gdi->getDestroyArg().hDevice = (D3DKMT_HANDLE)0;
|
|
|
|
gdi->getDestroyArg().hResource = (D3DKMT_HANDLE)0;
|
|
|
|
gdi->getDestroyArg().phAllocationList = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->destroyAllocation(&allocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_EQ(nullptr, gdi->getWaitFromCpuArg().FenceValueArray);
|
|
|
|
EXPECT_EQ((D3DKMT_HANDLE)0, gdi->getWaitFromCpuArg().hDevice);
|
|
|
|
EXPECT_EQ(0u, gdi->getWaitFromCpuArg().ObjectCount);
|
|
|
|
EXPECT_EQ(nullptr, gdi->getWaitFromCpuArg().ObjectHandleArray);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_EQ(wddm->getDevice(), gdi->getDestroyArg().hDevice);
|
|
|
|
EXPECT_EQ(1u, gdi->getDestroyArg().AllocationCount);
|
|
|
|
EXPECT_NE(nullptr, gdi->getDestroyArg().phAllocationList);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, WhenLastFenceLessEqualThanMonitoredThenWaitFromCpuIsNotCalled) {
|
|
|
|
wddm->init<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation((void *)0x23000, 0x1000, nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
allocation.getResidencyData().lastFence = 10;
|
|
|
|
allocation.handle = ALLOCATION_HANDLE;
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
*wddm->getMonitoredFence().cpuAddress = 10;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getWaitFromCpuArg().FenceValueArray = nullptr;
|
|
|
|
gdi->getWaitFromCpuArg().Flags.Value = 0;
|
|
|
|
gdi->getWaitFromCpuArg().hDevice = (D3DKMT_HANDLE)0;
|
|
|
|
gdi->getWaitFromCpuArg().ObjectCount = 0;
|
|
|
|
gdi->getWaitFromCpuArg().ObjectHandleArray = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
auto status = wddm->waitFromCpu(10);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(status);
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_EQ(nullptr, gdi->getWaitFromCpuArg().FenceValueArray);
|
|
|
|
EXPECT_EQ((D3DKMT_HANDLE)0, gdi->getWaitFromCpuArg().hDevice);
|
|
|
|
EXPECT_EQ(0u, gdi->getWaitFromCpuArg().ObjectCount);
|
|
|
|
EXPECT_EQ(nullptr, gdi->getWaitFromCpuArg().ObjectHandleArray);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, WhenLastFenceGreaterThanMonitoredThenWaitFromCpuIsCalled) {
|
|
|
|
wddm->init<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-30 22:07:58 +08:00
|
|
|
WddmAllocation allocation((void *)0x23000, 0x1000, nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
allocation.getResidencyData().lastFence = 10;
|
|
|
|
allocation.handle = ALLOCATION_HANDLE;
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
*wddm->getMonitoredFence().cpuAddress = 10;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getWaitFromCpuArg().FenceValueArray = nullptr;
|
|
|
|
gdi->getWaitFromCpuArg().Flags.Value = 0;
|
|
|
|
gdi->getWaitFromCpuArg().hDevice = (D3DKMT_HANDLE)0;
|
|
|
|
gdi->getWaitFromCpuArg().ObjectCount = 0;
|
|
|
|
gdi->getWaitFromCpuArg().ObjectHandleArray = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
auto status = wddm->waitFromCpu(20);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(status);
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_NE(nullptr, gdi->getWaitFromCpuArg().FenceValueArray);
|
|
|
|
EXPECT_EQ((D3DKMT_HANDLE)wddm->getDevice(), gdi->getWaitFromCpuArg().hDevice);
|
|
|
|
EXPECT_EQ(1u, gdi->getWaitFromCpuArg().ObjectCount);
|
|
|
|
EXPECT_NE(nullptr, gdi->getWaitFromCpuArg().ObjectHandleArray);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, createMonitoredFenceIsInitializedWithFenceValueZeroAndCurrentFenceValueIsSetToOne) {
|
|
|
|
wddm->init<FamilyType>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->createSynchronizationObject2 = gdi->createSynchronizationObject2Mock;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->getCreateSynchronizationObject2Arg().Info.MonitoredFence.InitialFenceValue = 300;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->createMonitoredFence();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
EXPECT_EQ(0u, gdi->getCreateSynchronizationObject2Arg().Info.MonitoredFence.InitialFenceValue);
|
2018-05-08 02:42:00 +08:00
|
|
|
EXPECT_EQ(1u, wddm->getMonitoredFence().currentFenceValue);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2017-12-22 00:28:17 +08:00
|
|
|
|
2018-01-09 00:35:09 +08:00
|
|
|
NTSTATUS APIENTRY queryResourceInfoMock(D3DKMT_QUERYRESOURCEINFO *pData) {
|
2017-12-22 00:28:17 +08:00
|
|
|
pData->NumAllocations = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, givenOpenSharedHandleWhenZeroAllocationsThenReturnNull) {
|
|
|
|
wddm->init<FamilyType>();
|
2017-12-22 00:28:17 +08:00
|
|
|
|
|
|
|
D3DKMT_HANDLE handle = 0;
|
|
|
|
WddmAllocation *alloc = nullptr;
|
|
|
|
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->queryResourceInfo = reinterpret_cast<PFND3DKMT_QUERYRESOURCEINFO>(queryResourceInfoMock);
|
2018-05-08 02:42:00 +08:00
|
|
|
auto ret = wddm->openSharedHandle(handle, alloc);
|
2017-12-22 00:28:17 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(false, ret);
|
|
|
|
}
|
2018-01-30 22:07:58 +08:00
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
HWTEST_F(WddmTest, givenReadOnlyMemoryWhenCreateAllocationFailsWithNoVideoMemoryThenCorrectStatusIsReturned) {
|
2018-03-23 17:07:31 +08:00
|
|
|
class MockCreateAllocation {
|
|
|
|
public:
|
|
|
|
static NTSTATUS APIENTRY mockCreateAllocation(D3DKMT_CREATEALLOCATION *param) {
|
|
|
|
return STATUS_GRAPHICS_NO_VIDEO_MEMORY;
|
|
|
|
};
|
|
|
|
};
|
2018-05-10 17:42:41 +08:00
|
|
|
gdi->createAllocation = MockCreateAllocation::mockCreateAllocation;
|
2018-03-23 17:07:31 +08:00
|
|
|
wddm->init<FamilyType>();
|
|
|
|
|
|
|
|
OsHandleStorage handleStorage;
|
|
|
|
OsHandle handle = {0};
|
|
|
|
ResidencyData residency;
|
|
|
|
|
|
|
|
handleStorage.fragmentCount = 1;
|
|
|
|
handleStorage.fragmentStorageData[0].cpuPtr = (void *)0x1000;
|
|
|
|
handleStorage.fragmentStorageData[0].fragmentSize = 0x1000;
|
|
|
|
handleStorage.fragmentStorageData[0].freeTheFragment = false;
|
|
|
|
handleStorage.fragmentStorageData[0].osHandleStorage = &handle;
|
|
|
|
handleStorage.fragmentStorageData[0].residency = &residency;
|
2018-05-08 02:42:00 +08:00
|
|
|
handleStorage.fragmentStorageData[0].osHandleStorage->gmm = GmmHelperFunctions::getGmm(nullptr, 0);
|
2018-03-23 17:07:31 +08:00
|
|
|
|
|
|
|
NTSTATUS result = wddm->createAllocationsAndMapGpuVa(handleStorage);
|
|
|
|
|
|
|
|
EXPECT_EQ(STATUS_GRAPHICS_NO_VIDEO_MEMORY, result);
|
|
|
|
|
2018-05-08 02:42:00 +08:00
|
|
|
delete handleStorage.fragmentStorageData[0].osHandleStorage->gmm;
|
2018-03-23 17:07:31 +08:00
|
|
|
}
|
2018-03-23 22:55:13 +08:00
|
|
|
|
|
|
|
HWTEST_F(WddmTest, whenGetOsDeviceContextIsCalledThenWddmOsDeviceContextIsReturned) {
|
|
|
|
D3DKMT_HANDLE ctx = 0xc1;
|
2018-05-08 02:42:00 +08:00
|
|
|
wddm->context = ctx;
|
|
|
|
EXPECT_EQ(ctx, wddm->getOsDeviceContext());
|
2018-03-23 22:55:13 +08:00
|
|
|
}
|