| 1 |
/* |
| 2 |
* Copyright (C) 2018-2023 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "shared/test/common/mocks/mock_device.h" |
| 9 |
#include "shared/test/common/test_macros/test.h" |
| 10 |
|
| 11 |
#include "opencl/source/sharings/va/va_surface.h" |
| 12 |
#include "opencl/test/unit_test/fixtures/kernel_arg_fixture.h" |
| 13 |
#include "opencl/test/unit_test/mocks/mock_kernel.h" |
| 14 |
#include "opencl/test/unit_test/mocks/mock_program.h" |
| 15 |
#include "opencl/test/unit_test/sharings/va/mock_va_sharing.h" |
| 16 |
|
| 17 |
#include "gtest/gtest.h" |
| 18 |
|
| 19 |
using namespace NEO; |
| 20 |
|
| 21 |
TEST_F(KernelImageArgTest, givenSharedImageWhenSetArgIsCalledThenReportSharedObjUsage) { |
| 22 |
MockVaSharing vaSharing; |
| 23 |
VASurfaceID vaSurfaceId = 0u; |
| 24 |
vaSharing.updateAcquiredHandle(1u); |
| 25 |
std::unique_ptr<Image> sharedImage(VASurface::createSharedVaSurface(context.get(), &vaSharing.sharingFunctions, |
| 26 |
CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr)); |
| 27 |
|
| 28 |
auto sharedMem = static_cast<cl_mem>(sharedImage.get()); |
| 29 |
auto nonSharedMem = static_cast<cl_mem>(image.get()); |
| 30 |
|
| 31 |
EXPECT_FALSE(pKernel->isUsingSharedObjArgs()); |
| 32 |
this->pKernel->setArg(0, sizeof(cl_mem *), &nonSharedMem); |
| 33 |
EXPECT_FALSE(pKernel->isUsingSharedObjArgs()); |
| 34 |
|
| 35 |
this->pKernel->setArg(0, sizeof(cl_mem *), &sharedMem); |
| 36 |
EXPECT_TRUE(pKernel->isUsingSharedObjArgs()); |
| 37 |
} |