Skip to content

Commit aafbbf5

Browse files
Add member for handling additional adapterInfo fields
Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
1 parent 9743e37 commit aafbbf5

File tree

10 files changed

+79
-18
lines changed

10 files changed

+79
-18
lines changed

opencl/source/sharings/d3d/enable_d3d.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -104,11 +104,11 @@ std::string D3DSharingBuilderFactory<D3DTypesHelper::D3D9>::getExtensions(Driver
104104
}
105105

106106
std::string D3DSharingBuilderFactory<D3DTypesHelper::D3D10>::getExtensions(DriverInfo *driverInfo) {
107-
return "cl_khr_d3d10_sharing ";
107+
return extensionEnabled ? "cl_khr_d3d10_sharing " : "";
108108
}
109109

110110
std::string D3DSharingBuilderFactory<D3DTypesHelper::D3D11>::getExtensions(DriverInfo *driverInfo) {
111-
return "cl_khr_d3d11_sharing cl_intel_d3d11_nv12_media_sharing ";
111+
return extensionEnabled ? "cl_khr_d3d11_sharing cl_intel_d3d11_nv12_media_sharing " : "";
112112
}
113113

114114
void D3DSharingBuilderFactory<D3DTypesHelper::D3D9>::fillGlobalDispatchTable() {
@@ -169,9 +169,13 @@ void D3DSharingBuilderFactory<D3DTypesHelper::D3D9>::setExtensionEnabled(DriverI
169169
extensionEnabled = driverInfo->getMediaSharingSupport();
170170
}
171171

172-
void D3DSharingBuilderFactory<D3DTypesHelper::D3D10>::setExtensionEnabled(DriverInfo *driverInfo) {}
172+
void D3DSharingBuilderFactory<D3DTypesHelper::D3D10>::setExtensionEnabled(DriverInfo *driverInfo) {
173+
extensionEnabled = driverInfo->getMediaSharingSupport();
174+
}
173175

174-
void D3DSharingBuilderFactory<D3DTypesHelper::D3D11>::setExtensionEnabled(DriverInfo *driverInfo) {}
176+
void D3DSharingBuilderFactory<D3DTypesHelper::D3D11>::setExtensionEnabled(DriverInfo *driverInfo) {
177+
extensionEnabled = driverInfo->getMediaSharingSupport();
178+
}
175179

176180
static SharingFactory::RegisterSharing<D3DSharingBuilderFactory<D3DTypesHelper::D3D9>, D3DSharingFunctions<D3DTypesHelper::D3D9>> D3D9Sharing;
177181
static SharingFactory::RegisterSharing<D3DSharingBuilderFactory<D3DTypesHelper::D3D10>, D3DSharingFunctions<D3DTypesHelper::D3D10>> D3D10Sharing;

opencl/test/unit_test/d3d_sharing/d3d_tests_part1.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,12 +850,25 @@ TEST(D3D10, givenD3D10BuilderWhenGettingExtensionsThenCorrectExtensionsListIsRet
850850
EXPECT_TRUE(hasSubstr(builderFactory->getExtensions(nullptr), std::string("cl_khr_d3d10_sharing")));
851851
}
852852

853+
TEST(D3D10, givenD3D10BuilderAndExtensionEnableFalseWhenGettingExtensionsThenCorrectExtensionsListIsReturned) {
854+
auto builderFactory = std::make_unique<D3DSharingBuilderFactory<D3DTypesHelper::D3D10>>();
855+
builderFactory->extensionEnabled = false;
856+
EXPECT_FALSE(hasSubstr(builderFactory->getExtensions(nullptr), std::string("cl_khr_d3d10_sharing")));
857+
}
858+
853859
TEST(D3D11, givenD3D11BuilderWhenGettingExtensionsThenCorrectExtensionsListIsReturned) {
854860
auto builderFactory = std::make_unique<D3DSharingBuilderFactory<D3DTypesHelper::D3D11>>();
855861
EXPECT_TRUE(hasSubstr(builderFactory->getExtensions(nullptr), std::string("cl_khr_d3d11_sharing")));
856862
EXPECT_TRUE(hasSubstr(builderFactory->getExtensions(nullptr), std::string("cl_intel_d3d11_nv12_media_sharing")));
857863
}
858864

865+
TEST(D3D11, givenD3D11BuilderAndExtensionEnableFalseWhenGettingExtensionsThenCorrectExtensionsListIsReturned) {
866+
auto builderFactory = std::make_unique<D3DSharingBuilderFactory<D3DTypesHelper::D3D11>>();
867+
builderFactory->extensionEnabled = false;
868+
EXPECT_FALSE(hasSubstr(builderFactory->getExtensions(nullptr), std::string("cl_khr_d3d11_sharing")));
869+
EXPECT_FALSE(hasSubstr(builderFactory->getExtensions(nullptr), std::string("cl_intel_d3d11_nv12_media_sharing")));
870+
}
871+
859872
TEST(D3DSharingFactory, givenEnabledFormatQueryAndFactoryWithD3DSharingsWhenGettingExtensionFunctionAddressThenFormatQueryFunctionsAreReturned) {
860873
DebugManagerStateRestore restorer;
861874
DebugManager.flags.EnableFormatQuery.set(true);

shared/source/os_interface/windows/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
1515
${CMAKE_CURRENT_SOURCE_DIR}/debug_registry_reader.cpp
1616
${CMAKE_CURRENT_SOURCE_DIR}/debug_registry_reader.h
1717
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream.inl
18+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}driver_info_windows_impl.cpp
1819
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_windows.cpp
1920
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_windows.h
2021
${CMAKE_CURRENT_SOURCE_DIR}/environment_variables.h
@@ -83,6 +84,7 @@ set(NEO_CORE_OS_INTERFACE_WDDM
8384
${CMAKE_CURRENT_SOURCE_DIR}/wddm/adapter_factory.h
8485
${CMAKE_CURRENT_SOURCE_DIR}/wddm/adapter_factory_dxcore.cpp
8586
${CMAKE_CURRENT_SOURCE_DIR}/wddm/adapter_factory_dxcore.h
87+
${CMAKE_CURRENT_SOURCE_DIR}/wddm${BRANCH_DIR_SUFFIX}wddm_additional_adapter_info_options.cpp
8688
${CMAKE_CURRENT_SOURCE_DIR}/wddm/configure_device_address_space_${DRIVER_MODEL}.cpp
8789
${CMAKE_CURRENT_SOURCE_DIR}/wddm/set_gmm_input_args_${DRIVER_MODEL}.cpp
8890
${CMAKE_CURRENT_SOURCE_DIR}/wddm/max_mem_alloc_size_${DRIVER_MODEL}.cpp

shared/source/os_interface/windows/driver_info_windows.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ std::string getCurrentLibraryPath() {
3333
}
3434

3535
namespace NEO {
36-
37-
DriverInfo *DriverInfo::create(const HardwareInfo *hwInfo, const OSInterface *osInterface) {
38-
if (osInterface == nullptr) {
39-
return nullptr;
40-
}
41-
42-
auto wddm = osInterface->getDriverModel()->as<Wddm>();
43-
UNRECOVERABLE_IF(wddm == nullptr);
44-
45-
return new DriverInfoWindows(wddm->getDeviceRegistryPath(), wddm->getPciBusInfo());
46-
};
47-
4836
DriverInfoWindows::DriverInfoWindows(const std::string &fullPath, const PhysicalDevicePciBusInfo &pciBusInfo)
4937
: path(DriverInfoWindows::trimRegistryKey(fullPath)), registryReader(createRegistryReaderFunc(path)) {
5038
this->pciBusInfo = pciBusInfo;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/os_interface/windows/driver_info_windows.h"
9+
#include "shared/source/os_interface/windows/wddm/wddm.h"
10+
11+
namespace NEO {
12+
13+
DriverInfo *DriverInfo::create(const HardwareInfo *hwInfo, const OSInterface *osInterface) {
14+
if (osInterface == nullptr) {
15+
return nullptr;
16+
}
17+
18+
auto wddm = osInterface->getDriverModel()->as<Wddm>();
19+
UNRECOVERABLE_IF(wddm == nullptr);
20+
21+
return new DriverInfoWindows(wddm->getDeviceRegistryPath(), wddm->getPciBusInfo());
22+
};
23+
24+
} // namespace NEO

shared/source/os_interface/windows/wddm/wddm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ bool Wddm::queryAdapterInfo() {
188188
maxRenderFrequency = adapterInfo.MaxRenderFreq;
189189
timestampFrequency = adapterInfo.GfxTimeStampFreq;
190190
instrumentationEnabled = adapterInfo.Caps.InstrumentationIsEnabled != 0;
191+
192+
populateAdditionalAdapterInfoOptions(adapterInfo);
191193
}
192194

193195
return status == STATUS_SUCCESS;

shared/source/os_interface/windows/wddm/wddm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ class Wddm : public DriverModel {
207207

208208
PhyicalDevicePciSpeedInfo getPciSpeedInfo() const override;
209209

210+
uint32_t getAdditionalAdapterInfoOptions() {
211+
return additionalAdapterInfoOptions;
212+
}
213+
210214
protected:
211215
Wddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
212216
MOCKABLE_VIRTUAL bool waitOnGPU(D3DKMT_HANDLE context);
@@ -224,6 +228,7 @@ class Wddm : public DriverModel {
224228
return evictNeeded;
225229
}
226230
void setPlatformSupportEvictWhenNecessaryFlag(const HwInfoConfig &hwInfoConfig);
231+
void populateAdditionalAdapterInfoOptions(const ADAPTER_INFO_KMD &adapterInfo);
227232

228233
GMM_GFX_PARTITIONING gfxPartition{};
229234
ADAPTER_BDF adapterBDF{};
@@ -265,6 +270,7 @@ class Wddm : public DriverModel {
265270

266271
uint32_t maxRenderFrequency = 0;
267272
uint32_t timestampFrequency = 0u;
273+
uint32_t additionalAdapterInfoOptions = 0u;
268274

269275
unsigned int enablePreemptionRegValue = 1;
270276

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/os_interface/windows/wddm/wddm.h"
9+
10+
namespace NEO {
11+
12+
void Wddm::populateAdditionalAdapterInfoOptions(const ADAPTER_INFO_KMD &adapterInfo) {
13+
}
14+
15+
} // namespace NEO

shared/test/common/mocks/mock_wddm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ constexpr auto virtualAllocAddress = is64bit ? 0x7FFFF0000000 : 0xFF000000;
2828
class WddmMock : public Wddm {
2929
public:
3030
using Wddm::adapterBDF;
31+
using Wddm::additionalAdapterInfoOptions;
3132
using Wddm::adjustEvictNeededParameter;
3233
using Wddm::createPagingFenceLogger;
3334
using Wddm::currentPagingFenceValue;
@@ -44,6 +45,7 @@ class WddmMock : public Wddm {
4445
using Wddm::pagingFenceAddress;
4546
using Wddm::pagingQueue;
4647
using Wddm::platformSupportsEvictWhenNecessary;
48+
using Wddm::populateAdditionalAdapterInfoOptions;
4749
using Wddm::residencyLogger;
4850
using Wddm::rootDeviceEnvironment;
4951
using Wddm::setPlatformSupportEvictWhenNecessaryFlag;
@@ -102,7 +104,7 @@ class WddmMock : public Wddm {
102104

103105
bool configureDeviceAddressSpace() {
104106
configureDeviceAddressSpaceResult.called++;
105-
//create context cant be called before configureDeviceAddressSpace
107+
// create context cant be called before configureDeviceAddressSpace
106108
if (createContextResult.called > 0) {
107109
return configureDeviceAddressSpaceResult.success = false;
108110
} else {

shared/test/unit_test/os_interface/windows/wddm_tests.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ TEST_F(WddmTests, GivenPlatformSupportsEvictWhenNecessaryWhenAdjustingEvictNeede
149149
EXPECT_TRUE(value);
150150
}
151151

152+
TEST_F(WddmTests, GivenWddmWhenAdditionalAdapterInfoOptionIsSetThenCorrectValueIsReturned) {
153+
wddm->additionalAdapterInfoOptions = 13u;
154+
EXPECT_EQ(13u, wddm->getAdditionalAdapterInfoOptions());
155+
}
156+
152157
TEST_F(WddmTests, GivenPlatformNotSupportEvictWhenNecessaryWhenAdjustingEvictNeededTrueThenExpectTrue) {
153158
wddm->platformSupportsEvictWhenNecessary = false;
154159
bool value = wddm->adjustEvictNeededParameter(true);

0 commit comments

Comments
 (0)