[3/n] Wddm Cleanup.

- remove different flavors of Wddm
- rename files for better meaning
- remove unnecessary files
- remove unnecessary methods

Change-Id: I73a35e186a9a99169260bb157958ff795b36e20d
This commit is contained in:
Mrozek, Michal 2018-08-14 11:05:17 +02:00 committed by sys_ocldev
parent 077134faf4
commit 931ed38a57
28 changed files with 60 additions and 238 deletions

View File

@ -45,7 +45,7 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices, Exec
numDevices = 0; numDevices = 0;
while (numDevices < totalDeviceCount) { while (numDevices < totalDeviceCount) {
std::unique_ptr<Wddm> wddm(Wddm ::createWddm(Wddm::pickWddmInterfaceVersion(tempHwInfos[numDevices]))); std::unique_ptr<Wddm> wddm(Wddm ::createWddm());
if (!wddm->enumAdapters(tempHwInfos[numDevices])) { if (!wddm->enumAdapters(tempHwInfos[numDevices])) {
return false; return false;
} }

View File

@ -909,13 +909,4 @@ void Wddm::resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress
monitoredFence.cpuAddress = cpuAddress; monitoredFence.cpuAddress = cpuAddress;
monitoredFence.gpuAddress = gpuAddress; monitoredFence.gpuAddress = gpuAddress;
} }
WddmInterfaceVersion Wddm::pickWddmInterfaceVersion(const HardwareInfo &hwInfo) {
if (hwInfo.pSkuTable && hwInfo.pSkuTable->ftrWddmHwQueues) {
return WddmInterfaceVersion::Wddm23;
}
// Use default version when hwInfo is not yet populated (eg. during enumAdapter call)
return WddmInterfaceVersion::Wddm20;
}
} // namespace OCLRT } // namespace OCLRT

View File

@ -63,8 +63,7 @@ class Wddm {
virtual ~Wddm(); virtual ~Wddm();
static Wddm *createWddm(WddmInterfaceVersion interfaceVersion); static Wddm *createWddm();
static WddmInterfaceVersion pickWddmInterfaceVersion(const HardwareInfo &hwInfo);
bool enumAdapters(HardwareInfo &outHardwareInfo); bool enumAdapters(HardwareInfo &outHardwareInfo);
MOCKABLE_VIRTUAL bool evict(D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim); MOCKABLE_VIRTUAL bool evict(D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
@ -223,7 +222,4 @@ class Wddm {
std::unique_ptr<KmDafListener> kmDafListener; std::unique_ptr<KmDafListener> kmDafListener;
std::unique_ptr<WddmInterface> wddmInterface; std::unique_ptr<WddmInterface> wddmInterface;
}; };
using Wddm20 = Wddm;
} // namespace OCLRT } // namespace OCLRT

View File

@ -1,29 +0,0 @@
/*
* Copyright (c) 2018, Intel Corporation
*
* 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 "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/wddm/wddm23.h"
namespace OCLRT {
Wddm23::Wddm23() : Wddm20() {
}
} // namespace OCLRT

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2018, Intel Corporation
*
* 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.
*/
#pragma once
#include "runtime/os_interface/windows/wddm/wddm.h"
namespace OCLRT {
class Wddm23 : public Wddm20 {
protected:
friend Wddm20;
Wddm23();
~Wddm23() = default;
D3DKMT_HANDLE hwQueueHandle = 0;
};
} // namespace OCLRT

View File

@ -22,18 +22,9 @@
#include "runtime/os_interface/debug_settings_manager.h" #include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/windows/wddm/wddm.h" #include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm23.h"
namespace OCLRT { namespace OCLRT {
Wddm *Wddm::createWddm(WddmInterfaceVersion interfaceVersion) { Wddm *Wddm::createWddm() {
switch (interfaceVersion) { return new Wddm();
case WddmInterfaceVersion::Wddm20:
return new Wddm20();
case WddmInterfaceVersion::Wddm23:
return new Wddm23();
default:
UNRECOVERABLE_IF(true);
return nullptr;
}
} }
} // namespace OCLRT } // namespace OCLRT

View File

@ -52,7 +52,7 @@ WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver(const HardwareIn
: BaseClass(hwInfoIn, executionEnvironment) { : BaseClass(hwInfoIn, executionEnvironment) {
this->wddm = wddm; this->wddm = wddm;
if (this->wddm == nullptr) { if (this->wddm == nullptr) {
this->wddm = Wddm::createWddm(Wddm::pickWddmInterfaceVersion(hwInfoIn)); this->wddm = Wddm::createWddm();
} }
GPUNODE_ORDINAL nodeOrdinal = GPUNODE_3D; GPUNODE_ORDINAL nodeOrdinal = GPUNODE_3D;
UNRECOVERABLE_IF(!WddmEngineMapper<GfxFamily>::engineNodeMap(hwInfoIn.capabilityTable.defaultEngineType, nodeOrdinal)); UNRECOVERABLE_IF(!WddmEngineMapper<GfxFamily>::engineNodeMap(hwInfoIn.capabilityTable.defaultEngineType, nodeOrdinal));

View File

@ -23,7 +23,7 @@
#include "unit_tests/mocks/mock_ostime.h" #include "unit_tests/mocks/mock_ostime.h"
#include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/mocks/mock_ostime_win.h" #include "unit_tests/mocks/mock_ostime_win.h"
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "test.h" #include "test.h"
using namespace OCLRT; using namespace OCLRT;

View File

@ -79,6 +79,9 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/gmm_memory${BRANCH_DIR_SUFFIX}/mock_gmm_memory.h ${CMAKE_CURRENT_SOURCE_DIR}/gmm_memory${BRANCH_DIR_SUFFIX}/mock_gmm_memory.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_interface23.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm.cpp
${IGDRCL_SRC_tests_mock_wddm} ${IGDRCL_SRC_tests_mock_wddm}
) )
else() else()

View File

@ -23,7 +23,7 @@
#include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/aligned_memory.h"
#include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/wddm_allocation.h" #include "runtime/os_interface/windows/wddm_allocation.h"
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/mock_gdi/mock_gdi.h" #include "unit_tests/mock_gdi/mock_gdi.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
@ -237,38 +237,3 @@ bool WddmMock::reserveValidAddressRange(size_t size, void *&reservedMem) {
GmmMemory *WddmMock::getGmmMemory() const { GmmMemory *WddmMock::getGmmMemory() const {
return gmmMemory.get(); return gmmMemory.get();
} }
bool WddmMock::initializeWithoutConfiguringAddressSpace() {
if (gdi != nullptr && gdi->isInitialized() && !initialized) {
if (!openAdapter()) {
return false;
}
if (!queryAdapterInfo()) {
return false;
}
if (featureTable->ftrWddmHwQueues) {
wddmInterface = std::make_unique<WddmInterface23>(*this);
} else {
wddmInterface = std::make_unique<WddmInterface20>(*this);
}
if (!createDevice()) {
return false;
}
if (!createPagingQueue()) {
return false;
}
if (!createContext()) {
return false;
}
if (wddmInterface->hwQueuesSupported() && !wddmInterface->createHwQueue(preemptionMode)) {
return false;
}
if (!wddmInterface->createMonitoredFence()) {
return false;
}
initialized = true;
}
return initialized;
}

View File

@ -47,19 +47,22 @@ struct KmDafLockCall : public CallResult {
}; };
} // namespace WddmMockHelpers } // namespace WddmMockHelpers
class WddmMock : public Wddm20 { class WddmMock : public Wddm {
public: public:
using Wddm::adapter; using Wddm::adapter;
using Wddm::context; using Wddm::context;
using Wddm::currentPagingFenceValue;
using Wddm::device; using Wddm::device;
using Wddm::featureTable;
using Wddm::gdi; using Wddm::gdi;
using Wddm::getSystemInfo; using Wddm::getSystemInfo;
using Wddm::gmmMemory; using Wddm::gmmMemory;
using Wddm::pagingFenceAddress;
using Wddm::pagingQueue; using Wddm::pagingQueue;
using Wddm::preemptionMode; using Wddm::preemptionMode;
using Wddm::wddmInterface; using Wddm::wddmInterface;
WddmMock() : Wddm20(){}; WddmMock() : Wddm(){};
~WddmMock(); ~WddmMock();
bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) override; bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) override;
@ -103,8 +106,6 @@ class WddmMock : public Wddm20 {
} }
} }
bool initializeWithoutConfiguringAddressSpace();
WddmMockHelpers::MakeResidentCall makeResidentResult; WddmMockHelpers::MakeResidentCall makeResidentResult;
WddmMockHelpers::CallResult makeNonResidentResult; WddmMockHelpers::CallResult makeNonResidentResult;
WddmMockHelpers::CallResult mapGpuVirtualAddressResult; WddmMockHelpers::CallResult mapGpuVirtualAddressResult;
@ -133,6 +134,4 @@ class WddmMock : public Wddm20 {
uintptr_t virtualAllocAddress = OCLRT::windowsMinAddress; uintptr_t virtualAllocAddress = OCLRT::windowsMinAddress;
bool kmDafEnabled = false; bool kmDafEnabled = false;
}; };
using WddmMock20 = WddmMock;
} // namespace OCLRT } // namespace OCLRT

View File

@ -22,33 +22,9 @@
#pragma once #pragma once
#include "runtime/os_interface/windows/wddm/wddm23.h" #include "runtime/os_interface/windows/wddm/wddm.h"
namespace OCLRT { namespace OCLRT {
class WddmMock23 : public Wddm23 {
public:
using Wddm::featureTable;
using Wddm::preemptionMode;
using Wddm::wddmInterface;
using Wddm23::context;
using Wddm23::currentPagingFenceValue;
using Wddm23::gdi;
using Wddm23::hwQueueHandle;
using Wddm23::pagingFenceAddress;
using Wddm23::submit;
WddmMock23() : Wddm23(){};
bool waitOnGPU() override {
waitOnGPUCalled++;
return true;
}
uint32_t waitOnGPUCalled = 0;
uint32_t createHwQueueCalled = 0;
bool createHwQueueResult = false;
};
class WddmMockInterface23 : public WddmInterface23 { class WddmMockInterface23 : public WddmInterface23 {
public: public:
using WddmInterface23::WddmInterface23; using WddmInterface23::WddmInterface23;

View File

@ -21,7 +21,7 @@
*/ */
#include "runtime/os_interface/windows/deferrable_deletion_win.h" #include "runtime/os_interface/windows/deferrable_deletion_win.h"
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <type_traits> #include <type_traits>

View File

@ -45,7 +45,7 @@
#include "unit_tests/mocks/mock_graphics_allocation.h" #include "unit_tests/mocks/mock_graphics_allocation.h"
#include "unit_tests/mocks/mock_program.h" #include "unit_tests/mocks/mock_program.h"
#include "unit_tests/mocks/mock_submissions_aggregator.h" #include "unit_tests/mocks/mock_submissions_aggregator.h"
#include "unit_tests/mocks/mock_wddm23.h" #include "unit_tests/mocks/mock_wddm_interface23.h"
#include "unit_tests/os_interface/windows/mock_gdi_interface.h" #include "unit_tests/os_interface/windows/mock_gdi_interface.h"
#include "unit_tests/os_interface/windows/mock_wddm_memory_manager.h" #include "unit_tests/os_interface/windows/mock_wddm_memory_manager.h"
#include "unit_tests/os_interface/windows/wddm_fixture.h" #include "unit_tests/os_interface/windows/wddm_fixture.h"
@ -67,7 +67,7 @@ class WddmCommandStreamFixture {
virtual void SetUp() { virtual void SetUp() {
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
ASSERT_NE(nullptr, device); ASSERT_NE(nullptr, device);
wddm = static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); wddm = static_cast<WddmMock *>(Wddm::createWddm());
ASSERT_NE(wddm, nullptr); ASSERT_NE(wddm, nullptr);
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::ImmediateDispatch)); DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::ImmediateDispatch));
@ -128,7 +128,7 @@ class WddmCommandStreamWithMockGdiFixture {
virtual void SetUp() { virtual void SetUp() {
ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment; ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment;
executionEnvironment->initGmm(*platformDevices); executionEnvironment->initGmm(*platformDevices);
wddm = static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); wddm = static_cast<WddmMock *>(Wddm::createWddm());
gdi = new MockGdi(); gdi = new MockGdi();
wddm->gdi.reset(gdi); wddm->gdi.reset(gdi);
ASSERT_NE(wddm, nullptr); ASSERT_NE(wddm, nullptr);
@ -242,7 +242,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFl
} }
TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOffWhenWorkloadIsSubmittedThenHeaderDoesntHavePreemptionFieldSet) { TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOffWhenWorkloadIsSubmittedThenHeaderDoesntHavePreemptionFieldSet) {
auto wddm = static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); auto wddm = static_cast<WddmMock *>(Wddm::createWddm());
auto localHwInfo = *platformDevices[0]; auto localHwInfo = *platformDevices[0];
localHwInfo.capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled; localHwInfo.capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
ExecutionEnvironment executionEnvironment; ExecutionEnvironment executionEnvironment;
@ -264,7 +264,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf
} }
TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOnWhenWorkloadIsSubmittedThenHeaderDoesHavePreemptionFieldSet) { TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOnWhenWorkloadIsSubmittedThenHeaderDoesHavePreemptionFieldSet) {
auto wddm = static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); auto wddm = static_cast<WddmMock *>(Wddm::createWddm());
auto localHwInfo = *platformDevices[0]; auto localHwInfo = *platformDevices[0];
localHwInfo.capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; localHwInfo.capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
ExecutionEnvironment executionEnvironment; ExecutionEnvironment executionEnvironment;
@ -285,7 +285,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn
} }
TEST(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderContainsPreemptionFieldSet) { TEST(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderContainsPreemptionFieldSet) {
auto wddm = static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); auto wddm = static_cast<WddmMock *>(Wddm::createWddm());
auto localHwInfo = *platformDevices[0]; auto localHwInfo = *platformDevices[0];
localHwInfo.capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; localHwInfo.capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
ExecutionEnvironment executionEnvironment; ExecutionEnvironment executionEnvironment;
@ -296,7 +296,7 @@ TEST(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStream
} }
TEST(WddmPreemptionHeaderTests, givenDevicenotSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderPreemptionFieldIsNotSet) { TEST(WddmPreemptionHeaderTests, givenDevicenotSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderPreemptionFieldIsNotSet) {
auto wddm = static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); auto wddm = static_cast<WddmMock *>(Wddm::createWddm());
auto localHwInfo = *platformDevices[0]; auto localHwInfo = *platformDevices[0];
localHwInfo.capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled; localHwInfo.capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
ExecutionEnvironment executionEnvironment; ExecutionEnvironment executionEnvironment;
@ -780,7 +780,7 @@ using WddmSimpleTest = ::testing::Test;
HWTEST_F(WddmSimpleTest, givenDefaultWddmCsrWhenItIsCreatedThenBatchingIsTurnedOn) { HWTEST_F(WddmSimpleTest, givenDefaultWddmCsrWhenItIsCreatedThenBatchingIsTurnedOn) {
DebugManager.flags.CsrDispatchMode.set(0); DebugManager.flags.CsrDispatchMode.set(0);
ExecutionEnvironment executionEnvironment; ExecutionEnvironment executionEnvironment;
auto wddm = Wddm::createWddm(WddmInterfaceVersion::Wddm20); auto wddm = Wddm::createWddm();
std::unique_ptr<MockWddmCsr<FamilyType>> mockCsr(new MockWddmCsr<FamilyType>(*platformDevices[0], wddm, executionEnvironment)); std::unique_ptr<MockWddmCsr<FamilyType>> mockCsr(new MockWddmCsr<FamilyType>(*platformDevices[0], wddm, executionEnvironment));
EXPECT_EQ(DispatchMode::BatchedDispatch, mockCsr->dispatchMode); EXPECT_EQ(DispatchMode::BatchedDispatch, mockCsr->dispatchMode);
} }
@ -790,21 +790,9 @@ HWTEST_F(WddmDefaultTest, givenFtrWddmHwQueuesFlagWhenCreatingCsrThenPickWddmVer
FeatureTable myFtrTable = *myHwInfo.pSkuTable; FeatureTable myFtrTable = *myHwInfo.pSkuTable;
myHwInfo.pSkuTable = &myFtrTable; myHwInfo.pSkuTable = &myFtrTable;
myFtrTable.ftrWddmHwQueues = false; WddmCommandStreamReceiver<FamilyType> wddmCsr(myHwInfo, nullptr, *device->executionEnvironment);
EXPECT_TRUE(WddmInterfaceVersion::Wddm20 == Wddm::pickWddmInterfaceVersion(myHwInfo)); auto wddm = wddmCsr.peekWddm();
{ EXPECT_EQ(typeid(*wddm), typeid(WddmMock));
WddmCommandStreamReceiver<FamilyType> wddmCsr20(myHwInfo, nullptr, *device->executionEnvironment);
auto wddm20 = wddmCsr20.peekWddm();
EXPECT_EQ(typeid(*wddm20), typeid(WddmMock20));
}
myFtrTable.ftrWddmHwQueues = true;
EXPECT_TRUE(WddmInterfaceVersion::Wddm23 == Wddm::pickWddmInterfaceVersion(myHwInfo));
{
WddmCommandStreamReceiver<FamilyType> wddmCsr23(myHwInfo, nullptr, *device->executionEnvironment);
auto wddm23 = wddmCsr23.peekWddm();
EXPECT_EQ(typeid(*wddm23), typeid(WddmMock23));
}
} }
struct WddmCsrCompressionTests : ::testing::Test { struct WddmCsrCompressionTests : ::testing::Test {
@ -821,7 +809,7 @@ struct WddmCsrCompressionTests : ::testing::Test {
} }
void createMockWddm() { void createMockWddm() {
myMockWddm = static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); myMockWddm = static_cast<WddmMock *>(Wddm::createWddm());
} }
HardwareInfo hwInfo = {}; HardwareInfo hwInfo = {};

View File

@ -27,7 +27,7 @@
#include "runtime/helpers/options.h" #include "runtime/helpers/options.h"
#include "unit_tests/mocks/mock_device.h" #include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_csr.h" #include "unit_tests/mocks/mock_csr.h"
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/libult/create_command_stream.h" #include "unit_tests/libult/create_command_stream.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"

View File

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

View File

@ -21,7 +21,7 @@
*/ */
#include "runtime/os_interface/windows/windows_wrapper.h" #include "runtime/os_interface/windows/windows_wrapper.h"
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "mock_performance_counters_win.h" #include "mock_performance_counters_win.h"
namespace OCLRT { namespace OCLRT {

View File

@ -22,7 +22,7 @@
#include "runtime/helpers/options.h" #include "runtime/helpers/options.h"
#include "runtime/os_interface/windows/windows_wrapper.h" #include "runtime/os_interface/windows/windows_wrapper.h"
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/os_interface/windows/mock_performance_counters_win.h" #include "unit_tests/os_interface/windows/mock_performance_counters_win.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"

View File

@ -102,7 +102,7 @@ TEST(Wddm20EnumAdaptersTest, expectTrue) {
const HardwareInfo hwInfo = *platformDevices[0]; const HardwareInfo hwInfo = *platformDevices[0];
OsLibrary *mockGdiDll = setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo); OsLibrary *mockGdiDll = setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo);
std::unique_ptr<Wddm> wddm(Wddm::createWddm(Wddm::pickWddmInterfaceVersion(outHwInfo))); std::unique_ptr<Wddm> wddm(Wddm::createWddm());
bool success = wddm->enumAdapters(outHwInfo); bool success = wddm->enumAdapters(outHwInfo);
EXPECT_TRUE(success); EXPECT_TRUE(success);
@ -125,7 +125,7 @@ TEST(Wddm20EnumAdaptersTest, givenEmptyHardwareInfoWhenEnumAdapterIsCalledThenCa
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
std::unique_ptr<OsLibrary> mockGdiDll(setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo)); std::unique_ptr<OsLibrary> mockGdiDll(setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo));
std::unique_ptr<Wddm> wddm(Wddm::createWddm(Wddm::pickWddmInterfaceVersion(outHwInfo))); std::unique_ptr<Wddm> wddm(Wddm::createWddm());
bool success = wddm->enumAdapters(outHwInfo); bool success = wddm->enumAdapters(outHwInfo);
EXPECT_TRUE(success); EXPECT_TRUE(success);
@ -167,7 +167,7 @@ TEST(Wddm20EnumAdaptersTest, givenUnknownPlatformWhenEnumAdapterIsCalledThenFals
fSetAdpaterInfo(&platform, hwInfo.pSysInfo); fSetAdpaterInfo(&platform, hwInfo.pSysInfo);
delete ptr; delete ptr;
}); });
std::unique_ptr<Wddm> wddm(Wddm::createWddm(Wddm::pickWddmInterfaceVersion(outHwInfo))); std::unique_ptr<Wddm> wddm(Wddm::createWddm());
auto ret = wddm->enumAdapters(outHwInfo); auto ret = wddm->enumAdapters(outHwInfo);
EXPECT_FALSE(ret); EXPECT_FALSE(ret);
EXPECT_EQ(nullptr, outHwInfo.pPlatform); EXPECT_EQ(nullptr, outHwInfo.pPlatform);

View File

@ -21,10 +21,10 @@
*/ */
#include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/wddm/wddm23.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h" #include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/mocks/mock_wddm23.h" #include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/mocks/mock_wddm_interface23.h"
#include "unit_tests/os_interface/windows/gdi_dll_fixture.h" #include "unit_tests/os_interface/windows/gdi_dll_fixture.h"
#include "test.h" #include "test.h"
@ -35,7 +35,7 @@ struct Wddm23Tests : public ::testing::Test, GdiDllFixture, public GmmEnvironmen
GmmEnvironmentFixture::SetUp(); GmmEnvironmentFixture::SetUp();
GdiDllFixture::SetUp(); GdiDllFixture::SetUp();
wddm.reset(static_cast<WddmMock23 *>(Wddm::createWddm(WddmInterfaceVersion::Wddm23))); wddm.reset(static_cast<WddmMock *>(Wddm::createWddm()));
wddm->featureTable->ftrWddmHwQueues = true; wddm->featureTable->ftrWddmHwQueues = true;
wddmMockInterface = new WddmMockInterface23(*wddm); wddmMockInterface = new WddmMockInterface23(*wddm);
wddm->wddmInterface.reset(wddmMockInterface); wddm->wddmInterface.reset(wddmMockInterface);
@ -47,7 +47,7 @@ struct Wddm23Tests : public ::testing::Test, GdiDllFixture, public GmmEnvironmen
GmmEnvironmentFixture::TearDown(); GmmEnvironmentFixture::TearDown();
} }
std::unique_ptr<WddmMock23> wddm; std::unique_ptr<WddmMock> wddm;
WddmMockInterface23 *wddmMockInterface = nullptr; WddmMockInterface23 *wddmMockInterface = nullptr;
}; };
@ -67,7 +67,7 @@ HWTEST_F(Wddm23Tests, whenCreateContextIsCalledThenEnableHwQueues) {
} }
TEST_F(Wddm23Tests, whenCreateHwQueueIsCalledThenSetAllRequiredFieldsAndMonitoredFence) { TEST_F(Wddm23Tests, whenCreateHwQueueIsCalledThenSetAllRequiredFieldsAndMonitoredFence) {
EXPECT_EQ(0u, wddm->hwQueueHandle); EXPECT_EQ(0u, wddmMockInterface->hwQueueHandle);
wddm->context = 1; wddm->context = 1;
wddm->wddmInterface->createHwQueue(wddm->preemptionMode); wddm->wddmInterface->createHwQueue(wddm->preemptionMode);
@ -145,11 +145,11 @@ HWTEST_F(Wddm23Tests, givenCurrentPendingFenceValueGreaterThanPendingFenceValueW
*wddm->pagingFenceAddress = 1; *wddm->pagingFenceAddress = 1;
wddm->currentPagingFenceValue = 1; wddm->currentPagingFenceValue = 1;
wddm->submit(cmdBufferAddress, cmdSize, &cmdBufferHeader); wddm->submit(cmdBufferAddress, cmdSize, &cmdBufferHeader);
EXPECT_EQ(0u, wddm->waitOnGPUCalled); EXPECT_EQ(0u, wddm->waitOnGPUResult.called);
wddm->currentPagingFenceValue = 2; wddm->currentPagingFenceValue = 2;
wddm->submit(cmdBufferAddress, cmdSize, &cmdBufferHeader); wddm->submit(cmdBufferAddress, cmdSize, &cmdBufferHeader);
EXPECT_EQ(1u, wddm->waitOnGPUCalled); EXPECT_EQ(1u, wddm->waitOnGPUResult.called);
} }
HWTEST_F(Wddm23Tests, whenInitCalledThenInitializeNewGdiDDIsAndCallToCreateHwQueue) { HWTEST_F(Wddm23Tests, whenInitCalledThenInitializeNewGdiDDIsAndCallToCreateHwQueue) {

View File

@ -21,7 +21,7 @@
*/ */
#include "unit_tests/fixtures/gmm_environment_fixture.h" #include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "test.h" #include "test.h"
using namespace OCLRT; using namespace OCLRT;

View File

@ -20,7 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/os_interface/windows/ult_dxgi_factory.h" #include "unit_tests/os_interface/windows/ult_dxgi_factory.h"
namespace OCLRT { namespace OCLRT {

View File

@ -20,18 +20,11 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/mocks/mock_wddm23.h" #include "unit_tests/mocks/mock_wddm_interface23.h"
namespace OCLRT { namespace OCLRT {
Wddm *Wddm::createWddm(WddmInterfaceVersion interfaceVersion) { Wddm *Wddm::createWddm() {
switch (interfaceVersion) { return new WddmMock();
case WddmInterfaceVersion::Wddm20:
return new WddmMock20();
case WddmInterfaceVersion::Wddm23:
return new WddmMock23();
default:
return nullptr;
}
} }
} // namespace OCLRT } // namespace OCLRT

View File

@ -24,7 +24,7 @@
#include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/gdi_interface.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h" #include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/mocks/mock_wddm20.h" #include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/os_interface/windows/mock_gdi_interface.h" #include "unit_tests/os_interface/windows/mock_gdi_interface.h"
#include "unit_tests/os_interface/windows/gdi_dll_fixture.h" #include "unit_tests/os_interface/windows/gdi_dll_fixture.h"
#include "mock_gmm_memory.h" #include "mock_gmm_memory.h"
@ -34,7 +34,7 @@ namespace OCLRT {
struct WddmFixture : public GmmEnvironmentFixture { struct WddmFixture : public GmmEnvironmentFixture {
void SetUp() override { void SetUp() override {
GmmEnvironmentFixture::SetUp(); GmmEnvironmentFixture::SetUp();
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20))); wddm.reset(static_cast<WddmMock *>(Wddm::createWddm()));
gdi = new MockGdi(); gdi = new MockGdi();
wddm->gdi.reset(gdi); wddm->gdi.reset(gdi);
} }
@ -51,7 +51,7 @@ struct WddmFixtureWithMockGdiDll : public GmmEnvironmentFixture, public GdiDllFi
void SetUp() override { void SetUp() override {
GmmEnvironmentFixture::SetUp(); GmmEnvironmentFixture::SetUp();
GdiDllFixture::SetUp(); GdiDllFixture::SetUp();
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20))); wddm.reset(static_cast<WddmMock *>(Wddm::createWddm()));
} }
void TearDown() override { void TearDown() override {
@ -65,7 +65,7 @@ struct WddmFixtureWithMockGdiDll : public GmmEnvironmentFixture, public GdiDllFi
struct WddmInstrumentationGmmFixture : public GmmEnvironmentFixture { struct WddmInstrumentationGmmFixture : public GmmEnvironmentFixture {
void SetUp() override { void SetUp() override {
GmmEnvironmentFixture::SetUp(); GmmEnvironmentFixture::SetUp();
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20))); wddm.reset(static_cast<WddmMock *>(Wddm::createWddm()));
gmmMem = new ::testing::NiceMock<GmockGmmMemory>(); gmmMem = new ::testing::NiceMock<GmockGmmMemory>();
wddm->gmmMemory.reset(gmmMem); wddm->gmmMemory.reset(gmmMem);
} }

View File

@ -38,7 +38,7 @@ using namespace ::testing;
void WddmMemoryManagerFixture::SetUp() { void WddmMemoryManagerFixture::SetUp() {
GmmEnvironmentFixture::SetUp(); GmmEnvironmentFixture::SetUp();
GdiDllFixture::SetUp(); GdiDllFixture::SetUp();
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20))); wddm.reset(static_cast<WddmMock *>(Wddm::createWddm()));
ASSERT_NE(nullptr, wddm); ASSERT_NE(nullptr, wddm);
if (platformDevices[0]->capabilityTable.ftrRenderCompressedBuffers || platformDevices[0]->capabilityTable.ftrRenderCompressedImages) { if (platformDevices[0]->capabilityTable.ftrRenderCompressedBuffers || platformDevices[0]->capabilityTable.ftrRenderCompressedImages) {
GMM_DEVICE_CALLBACKS_INT dummyDeviceCallbacks = {}; GMM_DEVICE_CALLBACKS_INT dummyDeviceCallbacks = {};
@ -58,7 +58,7 @@ TEST(WddmMemoryManager, NonAssignable) {
} }
TEST(WddmMemoryManagerAllocator32BitTest, allocator32BitIsCreatedWithCorrectBase) { TEST(WddmMemoryManagerAllocator32BitTest, allocator32BitIsCreatedWithCorrectBase) {
std::unique_ptr<WddmMock> wddm(static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20))); std::unique_ptr<WddmMock> wddm(static_cast<WddmMock *>(Wddm::createWddm()));
uint64_t base = 0x56000; uint64_t base = 0x56000;
uint64_t size = 0x9000; uint64_t size = 0x9000;
wddm->setHeap32(base, size); wddm->setHeap32(base, size);

View File

@ -70,7 +70,7 @@ class MockWddmMemoryManagerFixture : public GmmEnvironmentFixture {
public: public:
void SetUp() { void SetUp() {
GmmEnvironmentFixture::SetUp(); GmmEnvironmentFixture::SetUp();
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20))); wddm.reset(static_cast<WddmMock *>(Wddm::createWddm()));
gdi = new MockGdi(); gdi = new MockGdi();
wddm->gdi.reset(gdi); wddm->gdi.reset(gdi);
} }
@ -197,7 +197,7 @@ class WddmMemoryManagerSimpleTest : public MockWddmMemoryManagerFixture, public
public: public:
void SetUp() override { void SetUp() override {
MockWddmMemoryManagerFixture::SetUp(); MockWddmMemoryManagerFixture::SetUp();
wddm->initializeWithoutConfiguringAddressSpace(); wddm->init<DEFAULT_TEST_FAMILY_NAME>();
} }
void TearDown() override { void TearDown() override {
MockWddmMemoryManagerFixture::TearDown(); MockWddmMemoryManagerFixture::TearDown();

View File

@ -43,7 +43,7 @@ class WddmPreemptionTests : public Test<WddmFixtureWithMockGdiDll> {
template <typename GfxFamily> template <typename GfxFamily>
void createAndInitWddm(unsigned int forceReturnPreemptionRegKeyValue) { void createAndInitWddm(unsigned int forceReturnPreemptionRegKeyValue) {
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm(WddmInterfaceVersion::Wddm20))); wddm.reset(static_cast<WddmMock *>(Wddm::createWddm()));
auto regReader = new RegistryReaderMock(); auto regReader = new RegistryReaderMock();
wddm->registryReader.reset(regReader); wddm->registryReader.reset(regReader);
regReader->forceRetValue = forceReturnPreemptionRegKeyValue; regReader->forceRetValue = forceReturnPreemptionRegKeyValue;

View File

@ -22,7 +22,6 @@
#include "runtime/helpers/hw_info.h" #include "runtime/helpers/hw_info.h"
#include "runtime/os_interface/windows/wddm/wddm.h" #include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm23.h"
#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/debug_manager_state_restore.h"
#include "test.h" #include "test.h"
@ -31,21 +30,6 @@
using namespace OCLRT; using namespace OCLRT;
TEST(wddmCreateTests, givenInputVersionWhenCreatingThenCreateRequestedObject) { TEST(wddmCreateTests, givenInputVersionWhenCreatingThenCreateRequestedObject) {
std::unique_ptr<Wddm> wddm20(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); std::unique_ptr<Wddm> wddm(Wddm::createWddm());
std::unique_ptr<Wddm> wddm23(Wddm::createWddm(WddmInterfaceVersion::Wddm23)); EXPECT_EQ(typeid(*wddm.get()), typeid(Wddm));
EXPECT_EQ(typeid(*wddm20.get()), typeid(Wddm20));
EXPECT_EQ(typeid(*wddm23.get()), typeid(Wddm23));
}
TEST(wddmCreateTests, givenInvalidInputVersionWhenCreatingThenThrowException) {
EXPECT_THROW(Wddm::createWddm(static_cast<WddmInterfaceVersion>(0)), std::exception);
EXPECT_THROW(Wddm::createWddm(static_cast<WddmInterfaceVersion>(21)), std::exception);
EXPECT_THROW(Wddm::createWddm(static_cast<WddmInterfaceVersion>(22)), std::exception);
EXPECT_THROW(Wddm::createWddm(static_cast<WddmInterfaceVersion>(24)), std::exception);
}
TEST(wddmCreateTests, givenNotPopulatedHwInfoWhenAskingForWddmVersionThenReturn20) {
HardwareInfo hwInfo = {};
EXPECT_TRUE(WddmInterfaceVersion::Wddm20 == Wddm::pickWddmInterfaceVersion(hwInfo));
} }