Skip to content

Commit 728932e

Browse files
Pass Drm object to OsContext on Linux
Change-Id: I341925eef9bc892f5c321c668736bb6a3aff38f5 Signed-off-by: Dunajski, Bartosz <[email protected]>
1 parent 76efeae commit 728932e

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

runtime/os_interface/linux/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
3232
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
3333
${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp
3434
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.cpp
35+
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.h
3536
${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h
3637
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.cpp
3738
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.h

runtime/os_interface/linux/os_context_linux.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
*/
77

88
#include "runtime/os_interface/os_context.h"
9+
#include "runtime/os_interface/linux/drm_neo.h"
10+
#include "runtime/os_interface/linux/os_context_linux.h"
11+
#include "runtime/os_interface/linux/os_interface.h"
912

1013
namespace OCLRT {
11-
class OsContext::OsContextImpl {};
14+
1215
OsContext::OsContext(OSInterface *osInterface, uint32_t contextId) : contextId(contextId) {
13-
osContextImpl = std::make_unique<OsContext::OsContextImpl>();
16+
if (osInterface) {
17+
osContextImpl = std::make_unique<OsContextLinux>(*osInterface->get()->getDrm());
18+
}
1419
}
1520

1621
OsContext::~OsContext() = default;
22+
23+
OsContextLinux::OsContextImpl(Drm &drm) : drm(drm) {}
1724
} // namespace OCLRT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2018 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "runtime/os_interface/os_context.h"
9+
10+
namespace OCLRT {
11+
class Drm;
12+
using OsContextLinux = OsContext::OsContextImpl;
13+
14+
class OsContext::OsContextImpl {
15+
public:
16+
OsContextImpl(Drm &drm);
17+
18+
protected:
19+
Drm &drm;
20+
};
21+
} // namespace OCLRT

unit_tests/os_interface/linux/os_interface_linux_tests.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
*
66
*/
77

8-
#include "runtime/os_interface/os_context.h"
9-
#include "runtime/os_interface/os_interface.h"
8+
#include "runtime/os_interface/linux/os_context_linux.h"
9+
#include "runtime/os_interface/linux/os_interface.h"
10+
#include "unit_tests/os_interface/linux/drm_mock.h"
1011
#include "gtest/gtest.h"
1112

1213
namespace OCLRT {
@@ -20,8 +21,11 @@ TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenDeviceHandleQueriedthenZeroIsRetu
2021
EXPECT_EQ(0u, osInterface.getDeviceHandle());
2122
}
2223

23-
TEST(OsContextTest, WhenOsContextIsCreatedThenImplIsAvailable) {
24+
TEST(OsContextTest, givenDrmWhenOsContextIsCreatedThenImplIsAvailable) {
25+
DrmMock drmMock;
2426
OSInterface osInterface;
27+
osInterface.get()->setDrm(&drmMock);
28+
2529
auto osContext = std::make_unique<OsContext>(&osInterface, 0u);
2630
EXPECT_NE(nullptr, osContext->get());
2731
}

0 commit comments

Comments
 (0)