Remove redundant calls from Wddm::init()

Resolves: NEO-3331

Change-Id: I91dc2f170b9feecb9f84f447a9694fdb9b3a03b3
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz
2019-07-08 13:30:31 +02:00
committed by sys_ocldev
parent 6ffcd51847
commit 8fca10095e
19 changed files with 134 additions and 139 deletions

View File

@ -7,7 +7,6 @@
#ifdef _WIN32
#include "runtime/command_stream/preemption.h"
#include "runtime/device/device.h"
#include "runtime/helpers/device_helpers.h"
#include "runtime/os_interface/debug_settings_manager.h"
@ -26,8 +25,9 @@ bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executi
numDevices = 0;
auto hardwareInfo = executionEnvironment.getMutableHardwareInfo();
executionEnvironment.initGmm();
std::unique_ptr<Wddm> wddm(Wddm::createWddm());
if (!wddm->enumAdapters(*hardwareInfo)) {
if (!wddm->init(*hardwareInfo)) {
return false;
}
@ -36,19 +36,9 @@ bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executi
executionEnvironment.osInterface.reset(new OSInterface());
executionEnvironment.osInterface->get()->setWddm(wddm.release());
HwInfoConfig *hwConfig = HwInfoConfig::get(hardwareInfo->platform.eProductFamily);
if (hwConfig->configureHwInfo(hardwareInfo, hardwareInfo, nullptr)) {
return false;
}
numDevices = totalDeviceCount;
DeviceFactory::numDevices = numDevices;
executionEnvironment.initGmm();
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*hardwareInfo);
bool success = executionEnvironment.osInterface->get()->getWddm()->init(preemptionMode);
DEBUG_BREAK_IF(!success);
return true;
}

View File

@ -25,8 +25,6 @@ OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, DeviceBitfield device
aub_stream::EngineType engineType, PreemptionMode preemptionMode, bool lowPriority)
: OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority), wddm(wddm), residencyController(wddm, contextId) {
UNRECOVERABLE_IF(!wddm.isInitialized());
auto wddmInterface = wddm.getWddmInterface();
if (!wddm.createContext(*this)) {
return;

View File

@ -8,6 +8,7 @@
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "core/helpers/interlocked_max.h"
#include "runtime/command_stream/preemption.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/gmm_helper/page_table_mngr.h"
@ -58,7 +59,7 @@ Wddm::~Wddm() {
closeAdapter();
}
bool Wddm::enumAdapters(HardwareInfo &outHardwareInfo) {
bool Wddm::init(HardwareInfo &outHardwareInfo) {
if (!gdi->isInitialized()) {
return false;
}
@ -84,9 +85,31 @@ bool Wddm::enumAdapters(HardwareInfo &outHardwareInfo) {
outHardwareInfo.capabilityTable.instrumentationEnabled &= instrumentationEnabled;
HwInfoConfig *hwConfig = HwInfoConfig::get(productFamily);
hwConfig->adjustPlatformForProductFamily(&outHardwareInfo);
return true;
hwConfig->adjustPlatformForProductFamily(&outHardwareInfo);
if (hwConfig->configureHwInfo(&outHardwareInfo, &outHardwareInfo, nullptr)) {
return false;
}
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(outHardwareInfo);
if (featureTable->ftrWddmHwQueues) {
wddmInterface = std::make_unique<WddmInterface23>(*this);
} else {
wddmInterface = std::make_unique<WddmInterface20>(*this);
}
if (!createDevice(preemptionMode)) {
return false;
}
if (!createPagingQueue()) {
return false;
}
if (!gmmMemory) {
gmmMemory.reset(GmmMemory::create());
}
return configureDeviceAddressSpace();
}
bool Wddm::queryAdapterInfo() {
@ -892,37 +915,6 @@ bool Wddm::configureDeviceAddressSpaceImpl() {
return gmmMemory->configureDevice(adapter, device, gdi->escape, svmSize, featureTable->ftrL3IACoherency, gfxPartition, minAddress);
}
bool Wddm::init(PreemptionMode preemptionMode) {
if (gdi != nullptr && gdi->isInitialized() && !initialized) {
if (!openAdapter()) {
return false;
}
if (!queryAdapterInfo()) {
return false;
}
if (!wddmInterface) {
if (featureTable->ftrWddmHwQueues) {
wddmInterface = std::make_unique<WddmInterface23>(*this);
} else {
wddmInterface = std::make_unique<WddmInterface20>(*this);
}
}
if (!createDevice(preemptionMode)) {
return false;
}
if (!createPagingQueue()) {
return false;
}
if (!gmmMemory) {
gmmMemory.reset(GmmMemory::create());
}
initialized = configureDeviceAddressSpace();
}
return initialized;
}
EvictionStatus Wddm::evictAllTemporaryResources() {
decltype(temporaryResources) resourcesToEvict;
auto lock = acquireLock(temporaryResourcesLock);

View File

@ -54,7 +54,7 @@ class Wddm {
virtual ~Wddm();
static Wddm *createWddm();
bool enumAdapters(HardwareInfo &outHardwareInfo);
bool init(HardwareInfo &outHardwareInfo);
MOCKABLE_VIRTUAL bool evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
MOCKABLE_VIRTUAL bool makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim);
@ -92,12 +92,6 @@ class Wddm {
bool configureDeviceAddressSpace();
bool init(PreemptionMode preemptionMode);
bool isInitialized() const {
return initialized;
}
GT_SYSTEM_INFO *getGtSysInfo() const {
DEBUG_BREAK_IF(!gtSystemInfo);
return gtSystemInfo.get();
@ -157,7 +151,6 @@ class Wddm {
}
protected:
bool initialized = false;
std::unique_ptr<Gdi> gdi;
D3DKMT_HANDLE adapter = 0;
D3DKMT_HANDLE device = 0;

View File

@ -23,8 +23,8 @@ TEST_F(MockOSTimeWinTest, DynamicResolution) {
auto wddmMock = std::unique_ptr<WddmMock>(new WddmMock());
auto mDev = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
bool success = wddmMock->init(mDev->getPreemptionMode());
EXPECT_TRUE(success);
auto hwInfo = mDev->getHardwareInfo();
wddmMock->init(hwInfo);
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock.get()));

View File

@ -50,7 +50,8 @@ CommandStreamReceiver *createMockCommandStreamReceiver(bool withAubDump, Executi
if (!executionEnvironment.osInterface) {
executionEnvironment.osInterface = std::make_unique<OSInterface>();
auto wddm = new WddmMock();
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*executionEnvironment.getHardwareInfo()));
auto hwInfo = *executionEnvironment.getHardwareInfo();
wddm->init(hwInfo);
executionEnvironment.osInterface->get()->setWddm(wddm);
}

View File

@ -134,7 +134,8 @@ TEST_F(GlArbSyncEventOsTest, WhenCreateSynchronizationObjectSucceedsThenAllHAndl
};
CreateSyncObjectMock::reset();
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
gdi->createSynchronizationObject.mFunc = CreateSyncObjectMock::createSynchObject;
gdi->createSynchronizationObject2.mFunc = CreateSyncObjectMock::createSynchObject2;
auto ret = setupArbSyncObject(sharing, osInterface, syncInfo);
@ -185,7 +186,8 @@ TEST_F(GlArbSyncEventOsTest, GivenNewGlSyncInfoWhenCreateSynchronizationObjectFa
}
};
CreateSyncObjectMock::reset();
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
gdi->createSynchronizationObject.mFunc = CreateSyncObjectMock::createSynchObject;
gdi->createSynchronizationObject2.mFunc = CreateSyncObjectMock::createSynchObject2;
@ -209,7 +211,8 @@ TEST_F(GlArbSyncEventOsTest, GivenNewGlSyncInfoWhenCreateEventFailsThenSetupArbS
auto wddm = new WddmMock();
auto gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
mockOsInterface.get()->setWddm(wddm);
@ -237,7 +240,8 @@ TEST_F(GlArbSyncEventOsTest, GivenInvalidGlSyncInfoWhenCleanupArbSyncObjectIsCal
auto wddm = new WddmMock();
auto gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
MockOSInterface mockOsInterface;
MockOSInterfaceImpl *mockOsInterfaceImpl = static_cast<MockOSInterfaceImpl *>(mockOsInterface.get());
@ -266,7 +270,8 @@ TEST_F(GlArbSyncEventOsTest, GivenValidGlSyncInfoWhenCleanupArbSyncObjectIsCalle
auto wddm = new WddmMock();
auto gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
MockOSInterface mockOsInterface;
MockOSInterfaceImpl *mockOsInterfaceImpl = static_cast<MockOSInterfaceImpl *>(mockOsInterface.get());
@ -325,7 +330,8 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza
};
FailSignalSyncObjectMock::reset();
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
wddm->init(preemptionMode);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
OsContextWin osContext(*osInterface.get()->getWddm(), 0u, 1, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode, false);
CL_GL_SYNC_INFO syncInfo = {};
@ -384,7 +390,8 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza
};
FailSignalSyncObjectMock::reset();
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
wddm->init(preemptionMode);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
OsContextWin osContext(*osInterface.get()->getWddm(), 0u, 1, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode, false);
CL_GL_SYNC_INFO syncInfo = {};

View File

@ -30,7 +30,7 @@ void HwInfoConfigTestWindows::SetUp() {
osInterface.reset(new OSInterface());
std::unique_ptr<Wddm> wddm(Wddm::createWddm());
wddm->enumAdapters(outHwInfo);
wddm->init(outHwInfo);
}
void HwInfoConfigTestWindows::TearDown() {

View File

@ -21,21 +21,13 @@ TEST_F(OsInterfaceTest, GivenWindowsWhenCreateEentIsCalledThenValidEventHandleIs
EXPECT_EQ(TRUE, ret);
}
TEST(OsContextTest, givenWddmWhenCreateOsContextBeforeInitWddmThenOsContextIsNotInitialized) {
auto wddm = new WddmMock;
OSInterface osInterface;
osInterface.get()->setWddm(wddm);
EXPECT_THROW(OsContextWin(*wddm, 0u, 1, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0],
PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]), false),
std::exception);
}
TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedAndTrimCallbackIsRegistered) {
auto wddm = new WddmMock;
OSInterface osInterface;
osInterface.get()->setWddm(wddm);
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
wddm->init(preemptionMode);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
EXPECT_EQ(0u, wddm->registerTrimCallbackResult.called);
auto osContext = std::make_unique<OsContextWin>(*wddm, 0u, 1, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode, false);
EXPECT_TRUE(osContext->isInitialized());

View File

@ -86,7 +86,6 @@ TEST(OSTimeWinTests, givenNoOSInterfaceWhenGetCpuGpuTimeThenReturnsError) {
TEST(OSTimeWinTests, givenOSInterfaceWhenGetCpuGpuTimeThenReturnsSuccess) {
auto wddm = new WddmMock;
wddm->init(PreemptionHelper::getDefaultPreemptionMode(DEFAULT_TEST_PLATFORM::hwInfo));
TimeStampData CPUGPUTime01 = {0};
TimeStampData CPUGPUTime02 = {0};
std::unique_ptr<OSInterface> osInterface(new OSInterface());

View File

@ -64,11 +64,9 @@ TEST_F(Wddm20Tests, givenMinWindowsAddressWhenWddmIsInitializedThenWddmUseThisAd
TEST_F(Wddm20Tests, doubleCreation) {
EXPECT_EQ(1u, wddm->createContextResult.called);
auto error = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
EXPECT_EQ(1u, wddm->createContextResult.called);
EXPECT_TRUE(error);
EXPECT_TRUE(wddm->isInitialized());
}
TEST_F(Wddm20Tests, givenNullPageTableManagerAndRenderCompressedResourceWhenMappingGpuVaThenDontUpdateAuxTable) {
@ -95,7 +93,7 @@ TEST(Wddm20EnumAdaptersTest, expectTrue) {
hwInfo->capabilityTable.gpuAddressSpace));
std::unique_ptr<Wddm> wddm(Wddm::createWddm());
bool success = wddm->enumAdapters(outHwInfo);
bool success = wddm->init(outHwInfo);
EXPECT_TRUE(success);
@ -111,7 +109,7 @@ TEST(Wddm20EnumAdaptersTest, givenEmptyHardwareInfoWhenEnumAdapterIsCalledThenCa
hwInfo->capabilityTable.gpuAddressSpace));
std::unique_ptr<Wddm> wddm(Wddm::createWddm());
bool success = wddm->enumAdapters(outHwInfo);
bool success = wddm->init(outHwInfo);
EXPECT_TRUE(success);
EXPECT_EQ(outHwInfo.platform.eDisplayCoreFamily, hwInfo->platform.eDisplayCoreFamily);
@ -134,7 +132,7 @@ TEST(Wddm20EnumAdaptersTest, givenUnknownPlatformWhenEnumAdapterIsCalledThenFals
hwInfo.capabilityTable.gpuAddressSpace));
std::unique_ptr<Wddm> wddm(Wddm::createWddm());
auto ret = wddm->enumAdapters(outHwInfo);
auto ret = wddm->init(outHwInfo);
EXPECT_FALSE(ret);
// reset mock gdi
@ -443,9 +441,8 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) {
FtrL3IACoherency))
.Times(1)
.WillRepeatedly(::testing::Return(true));
wddm->init(PreemptionHelper::getDefaultPreemptionMode(hwInfo));
EXPECT_TRUE(wddm->isInitialized());
auto hwInfoMock = *platformDevices[0];
wddm->init(hwInfoMock);
}
TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) {
@ -718,7 +715,8 @@ TEST_F(Wddm20Tests, givenReadOnlyMemoryWhenCreateAllocationFailsWithNoVideoMemor
}
TEST_F(Wddm20Tests, whenContextIsInitializedThenApplyAdditionalContextFlagsIsCalled) {
auto result = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
auto result = wddm->init(hwInfo);
EXPECT_TRUE(result);
EXPECT_EQ(1u, wddm->applyAdditionalContextFlagsResult.called);
}

View File

@ -37,7 +37,10 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture {
void init() {
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
EXPECT_TRUE(wddm->init(preemptionMode));
auto hwInfo = *platformDevices[0];
wddmMockInterface = reinterpret_cast<WddmMockInterface23 *>(wddm->wddmInterface.release());
wddm->init(hwInfo);
wddm->wddmInterface.reset(wddmMockInterface);
osContext = std::make_unique<OsContextWin>(*wddm, 0u, 1, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode, false);
}

View File

@ -59,12 +59,12 @@ TEST(WddmReserveAddressTest, givenWddmWhenFirstIsSuccessfulThenReturnReserveAddr
size_t size = 0x1000;
void *reserve = nullptr;
bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
EXPECT_TRUE(ret);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
wddm->returnGood = 1;
ret = wddm->reserveValidAddressRange(size, reserve);
auto ret = wddm->reserveValidAddressRange(size, reserve);
uintptr_t expectedReserve = wddm->virtualAllocAddress;
EXPECT_TRUE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
@ -76,10 +76,10 @@ TEST(WddmReserveAddressTest, givenWddmWhenFirstIsNullThenReturnNull) {
size_t size = 0x1000;
void *reserve = nullptr;
bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
EXPECT_TRUE(ret);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
uintptr_t expectedReserve = 0;
ret = wddm->reserveValidAddressRange(size, reserve);
auto ret = wddm->reserveValidAddressRange(size, reserve);
EXPECT_FALSE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
}
@ -89,12 +89,12 @@ TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondSuccessfulThenRetu
size_t size = 0x1000;
void *reserve = nullptr;
bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
EXPECT_TRUE(ret);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
wddm->returnInvalidCount = 1;
ret = wddm->reserveValidAddressRange(size, reserve);
auto ret = wddm->reserveValidAddressRange(size, reserve);
uintptr_t expectedReserve = wddm->virtualAllocAddress;
EXPECT_TRUE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
@ -106,12 +106,12 @@ TEST(WddmReserveAddressTest, givenWddmWhenSecondIsInvalidThirdSuccessfulThenRetu
size_t size = 0x1000;
void *reserve = nullptr;
bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
EXPECT_TRUE(ret);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
wddm->returnInvalidCount = 2;
ret = wddm->reserveValidAddressRange(size, reserve);
auto ret = wddm->reserveValidAddressRange(size, reserve);
uintptr_t expectedReserve = wddm->virtualAllocAddress;
EXPECT_TRUE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
@ -123,14 +123,14 @@ TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondNullThenReturnSeco
size_t size = 0x1000;
void *reserve = nullptr;
bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
EXPECT_TRUE(ret);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
wddm->returnInvalidCount = 2;
wddm->returnNullCount = 1;
uintptr_t expectedReserve = 0;
ret = wddm->reserveValidAddressRange(size, reserve);
auto ret = wddm->reserveValidAddressRange(size, reserve);
EXPECT_FALSE(ret);
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
}

View File

@ -32,9 +32,9 @@ struct WddmFixture : ::testing::Test {
gdi = new MockGdi();
wddm->gdi.reset(gdi);
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
wddm->init(preemptionMode);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1u, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode, false);
ASSERT_TRUE(wddm->isInitialized());
}
WddmMock *wddm = nullptr;
@ -57,9 +57,9 @@ struct WddmFixtureWithMockGdiDll : public GdiDllFixture {
void init() {
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
EXPECT_TRUE(wddm->init(preemptionMode));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode, false);
ASSERT_TRUE(wddm->isInitialized());
}
void TearDown() override {

View File

@ -41,7 +41,8 @@ class WddmKmDafListenerTest : public ::testing::Test {
executionEnvironment = platformImpl->peekExecutionEnvironment();
wddmWithKmDafMock.reset(new WddmWithKmDafMock());
wddmWithKmDafMock->gdi.reset(new MockGdi());
wddmWithKmDafMock->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddmWithKmDafMock->init(hwInfo);
wddmWithKmDafMock->featureTable->ftrKmdDaf = true;
}
void TearDown() {

View File

@ -39,7 +39,8 @@ void WddmMemoryManagerFixture::SetUp() {
GMM_TRANSLATIONTABLE_CALLBACKS dummyTTCallbacks = {};
wddm->resetPageTableManager(GmmPageTableMngr::create(0, &dummyTTCallbacks));
}
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
constexpr uint64_t heap32Base = (is32bit) ? 0x1000 : 0x800000000000;
wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1);
@ -1215,7 +1216,8 @@ struct WddmMemoryManagerWithAsyncDeleterTest : public MockWddmMemoryManagerTest
MockWddmMemoryManagerTest::SetUp();
wddm->gdi.reset(new MockGdi());
wddm->callBaseDestroyAllocations = false;
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
deleter = new MockDeferredDeleter;
memoryManager = std::make_unique<MockWddmMemoryManager>(*executionEnvironment);
memoryManager->setDeferredDeleter(deleter);
@ -1295,14 +1297,16 @@ TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForI
auto executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
auto wddm = new WddmMock();
executionEnvironment->osInterface->get()->setWddm(wddm);
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfoMock = *platformDevices[0];
wddm->init(hwInfoMock);
MockWddmMemoryManager memoryManager(*executionEnvironment);
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(internalHeapIndex)].Base;
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress());
}
TEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledWithTripleAllocationThenSuccessIsReturned) {
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
MockWddmMemoryManager memoryManager(*executionEnvironment);
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{false, MemoryConstants::pageSize}, reinterpret_cast<void *>(0x1000)));
@ -1314,7 +1318,8 @@ TEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledW
TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemoryForBufferWithoutHostPtrThen64kbAdressIsAllocated) {
DebugManagerStateRestore dbgRestore;
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
DebugManager.flags.Enable64kbpages.set(true);
MemoryManagerCreate<WddmMemoryManager> memoryManager64k(true, false, *executionEnvironment);
EXPECT_EQ(0, wddm->createAllocationResult.called);
@ -1331,7 +1336,8 @@ TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemor
TEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocationIsCreatedWithSizeSmallerThan64kbThenGraphicsAllocationsHas64kbAlignedUnderlyingSize) {
DebugManagerStateRestore dbgRestore;
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
DebugManager.flags.Enable64kbpages.set(true);
MockWddmMemoryManager memoryManager(true, false, *executionEnvironment);
AllocationData allocationData;
@ -1350,7 +1356,8 @@ TEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocation
TEST_F(MockWddmMemoryManagerTest, givenWddmWhenallocateGraphicsMemory64kbThenLockResultAndmapGpuVirtualAddressIsCalled) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.Enable64kbpages.set(true);
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
MockWddmMemoryManager memoryManager64k(*executionEnvironment);
uint32_t lockCount = wddm->lockResult.called;
uint32_t mapGpuVirtualAddressResult = wddm->mapGpuVirtualAddressResult.called;
@ -1412,7 +1419,8 @@ TEST_F(MockWddmMemoryManagerTest, givenDisabledAsyncDeleterFlagWhenMemoryManager
}
TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThenUseWddmToMap) {
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
WddmMemoryManager memoryManager(*executionEnvironment);
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
@ -1440,7 +1448,8 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa
gmm->isRenderCompressed = true;
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm;
EXPECT_TRUE(wddm.init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm.init(hwInfo);
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
wddm.resetPageTableManager(mockMngr);
@ -1454,8 +1463,8 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(1).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
auto hwInfo = hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily];
ASSERT_NE(nullptr, hwInfo);
auto hwInfoMock = hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily];
ASSERT_NE(nullptr, hwInfoMock);
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
ASSERT_TRUE(result);
@ -1464,7 +1473,8 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa
}
TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenReleaseingThenUnmapAuxVa) {
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
WddmMemoryManager memoryManager(*executionEnvironment);
D3DGPU_VIRTUAL_ADDRESS gpuVa = 123;
@ -1489,7 +1499,8 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenReleaseingT
}
TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleaseingThenDontUnmapAuxVa) {
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
WddmMemoryManager memoryManager(*executionEnvironment);
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
@ -1508,7 +1519,8 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGp
gmm->isRenderCompressed = false;
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm;
EXPECT_TRUE(wddm.init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm.init(hwInfo);
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
wddm.resetPageTableManager(mockMngr);
@ -1524,7 +1536,8 @@ TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenRetur
gmm->isRenderCompressed = false;
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm;
EXPECT_TRUE(wddm.init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm.init(hwInfo);
auto result = wddm.mapGpuVirtualAddress(gmm.get(), 0, 0, 0, 0, gpuVa);
ASSERT_FALSE(result);
@ -1532,7 +1545,8 @@ TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenRetur
TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUnsetThenDontUpdateAuxTable) {
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
WddmMemoryManager memoryManager(*executionEnvironment);
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
@ -1599,7 +1613,8 @@ TEST(WddmMemoryManagerCleanupTest, givenUsedTagAllocationInWddmMemoryManagerWhen
auto csr = createCommandStream(executionEnvironment);
auto wddm = new WddmMock();
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
EXPECT_TRUE(wddm->init(preemptionMode));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setWddm(wddm);

View File

@ -50,7 +50,8 @@ class MockWddmMemoryManagerFixture {
wddm->gdi.reset(gdi);
constexpr uint64_t heap32Base = (is32bit) ? 0x1000 : 0x800000000000;
wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1);
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
executionEnvironment->osInterface.reset(new OSInterface());
executionEnvironment->osInterface->get()->setWddm(wddm);
@ -94,10 +95,10 @@ class WddmMemoryManagerFixtureWithGmockWddm : public ExecutionEnvironmentFixture
executionEnvironment->osInterface = std::make_unique<OSInterface>();
ASSERT_NE(nullptr, wddm);
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
EXPECT_TRUE(wddm->init(preemptionMode));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
executionEnvironment->osInterface->get()->setWddm(wddm);
osInterface = executionEnvironment->osInterface.get();
wddm->init(preemptionMode);
memoryManager = new (std::nothrow) MockWddmMemoryManager(*executionEnvironment);
//assert we have memory manager
ASSERT_NE(nullptr, memoryManager);
@ -146,7 +147,6 @@ class WddmMemoryManagerSimpleTest : public MockWddmMemoryManagerFixture, public
public:
void SetUp() override {
MockWddmMemoryManagerFixture::SetUp();
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
}
void TearDown() override {
MockWddmMemoryManagerFixture::TearDown();

View File

@ -20,6 +20,7 @@ class WddmPreemptionTests : public Test<WddmFixtureWithMockGdiDll> {
const HardwareInfo hwInfo = *platformDevices[0];
memcpy(&hwInfoTest, &hwInfo, sizeof(hwInfoTest));
dbgRestorer = new DebugManagerStateRestore();
wddm->featureTable->ftrGpGpuMidThreadLevelPreempt = true;
}
void TearDown() override {
@ -36,7 +37,7 @@ class WddmPreemptionTests : public Test<WddmFixtureWithMockGdiDll> {
wddm->registryReader.reset(regReader);
regReader->forceRetValue = forceReturnPreemptionRegKeyValue;
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoTest);
wddm->init(preemptionMode);
wddm->init(hwInfoTest);
osContext = std::make_unique<OsContextWin>(*wddm, 0u, 1, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode, false);
}
@ -49,7 +50,6 @@ TEST_F(WddmPreemptionTests, givenDevicePreemptionEnabledDebugFlagDontForceWhenPr
hwInfoTest.capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
unsigned int expectedVal = 1u;
createAndInitWddm(1u);
EXPECT_EQ(expectedVal, getMockCreateDeviceParamsFcn().Flags.DisableGpuTimeout);
EXPECT_EQ(expectedVal, getCreateContextDataFcn()->Flags.DisableGpuTimeout);
}

View File

@ -51,7 +51,8 @@ struct WddmResidencyControllerTest : ::testing::Test {
void SetUp() {
wddm = std::unique_ptr<WddmMock>(static_cast<WddmMock *>(Wddm::createWddm()));
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
residencyController = std::make_unique<MockWddmResidencyController>(*wddm, osContextId);
wddm->getWddmInterface()->createMonitoredFence(*residencyController);
}
@ -67,7 +68,8 @@ struct WddmResidencyControllerWithGdiTest : ::testing::Test {
wddm = std::unique_ptr<WddmMock>(static_cast<WddmMock *>(Wddm::createWddm()));
gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
residencyController = std::make_unique<MockWddmResidencyController>(*wddm, osContextId);
wddm->getWddmInterface()->createMonitoredFence(*residencyController);
@ -86,7 +88,8 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
wddm = new ::testing::NiceMock<GmockWddm>();
wddm->gdi = std::make_unique<MockGdi>();
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
ASSERT_TRUE(wddm->init(preemptionMode));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
@ -114,7 +117,8 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test {
void SetUp() {
wddm = static_cast<WddmMock *>(Wddm::createWddm());
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
gdi = new MockGdi();
wddm->gdi.reset(gdi);
@ -149,7 +153,8 @@ TEST(WddmResidencyController, givenWddmResidencyControllerWhenItIsConstructedThe
auto gdi = new MockGdi();
auto wddm = std::unique_ptr<WddmMock>{static_cast<WddmMock *>(Wddm::createWddm())};
wddm->gdi.reset(gdi);
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
std::memset(&gdi->getRegisterTrimNotificationArg(), 0, sizeof(D3DKMT_REGISTERTRIMNOTIFICATION));
MockWddmResidencyController residencyController{*wddm, 0u};
@ -167,7 +172,8 @@ TEST(WddmResidencyController, givenWddmResidencyControllerWhenRegisterCallbackTh
auto gdi = new MockGdi();
auto wddm = std::unique_ptr<WddmMock>{static_cast<WddmMock *>(Wddm::createWddm())};
wddm->gdi.reset(gdi);
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
std::memset(&gdi->getRegisterTrimNotificationArg(), 0, sizeof(D3DKMT_REGISTERTRIMNOTIFICATION));