Debian Codegraph @

opencl/test/unit_test/sharings/va/va_base_object_tests.cpp

raw
1 /*
2 * Copyright (C) 2018-2024 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "opencl/source/accelerators/intel_accelerator.h"
9 #include "opencl/source/helpers/base_object.h"
10 #include "opencl/source/sharings/sharing_factory.h"
11 #include "opencl/test/unit_test/mocks/mock_command_queue.h"
12 #include "opencl/test/unit_test/mocks/mock_platform.h"
13
14 #include "gtest/gtest.h"
15
16 namespace NEO {
17
18 template <typename TypeParam>
19 struct VABaseObjectTests : public ::testing::Test {
20 void SetUp() override {
21 }
22
23 void TearDown() override {
24 }
25 };
26
27 typedef ::testing::Types<
28 MockPlatform,
29 IntelAccelerator,
30 MockCommandQueue>
31 BaseObjectTypes;
32
33 TYPED_TEST_SUITE(VABaseObjectTests, BaseObjectTypes);
34
35 TYPED_TEST(VABaseObjectTests, GivenCommonRuntimeThenDispatchTableAtFirstPointerInObject) {
36 TypeParam objectDrv;
37
38 // Automatic downcasting to _cl_type *.
39 typename TypeParam::BaseType *objectCL = &objectDrv;
40 sharingFactory.fillGlobalDispatchTable();
41
42 // Common runtime casts to generic type assuming
43 // the dispatch table is the first ptr in the structure
44 auto genericObject = reinterpret_cast<ClDispatch *>(objectCL);
45 EXPECT_EQ(reinterpret_cast<void *>(clCreateFromVA_APIMediaSurfaceINTEL),
46 genericObject->dispatch.crtDispatch->clCreateFromVA_APIMediaSurfaceINTEL);
47
48 EXPECT_EQ(reinterpret_cast<void *>(clEnqueueAcquireVA_APIMediaSurfacesINTEL),
49 genericObject->dispatch.crtDispatch->clEnqueueAcquireVA_APIMediaSurfacesINTEL);
50
51 EXPECT_EQ(reinterpret_cast<void *>(clEnqueueReleaseVA_APIMediaSurfacesINTEL),
52 genericObject->dispatch.crtDispatch->clEnqueueReleaseVA_APIMediaSurfacesINTEL);
53
54 EXPECT_EQ(reinterpret_cast<void *>(clGetDeviceIDsFromVA_APIMediaAdapterINTEL),
55 genericObject->dispatch.crtDispatch->clGetDeviceIDsFromVA_APIMediaAdapterINTEL);
56 }
57 } // namespace NEO