mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 18:25:05 +08:00
Change-Id: If965c79d70392db26597aea4c2f3b7ae2820fe96 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
69 lines
2.2 KiB
C++
69 lines
2.2 KiB
C++
/*
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/kernel/kernel.h"
|
|
#include "runtime/mem_obj/buffer.h"
|
|
#include "runtime/sharings/gl/gl_buffer.h"
|
|
#include "test.h"
|
|
#include "unit_tests/fixtures/context_fixture.h"
|
|
#include "unit_tests/fixtures/device_fixture.h"
|
|
#include "unit_tests/fixtures/memory_management_fixture.h"
|
|
#include "unit_tests/kernel/kernel_arg_buffer_fixture.h"
|
|
#include "unit_tests/mocks/gl/mock_gl_sharing.h"
|
|
#include "unit_tests/mocks/mock_buffer.h"
|
|
#include "unit_tests/mocks/mock_context.h"
|
|
#include "unit_tests/mocks/mock_kernel.h"
|
|
#include "unit_tests/mocks/mock_program.h"
|
|
|
|
#include "CL/cl.h"
|
|
#include "config.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <memory>
|
|
|
|
using namespace NEO;
|
|
|
|
typedef Test<KernelArgBufferFixture> KernelArgBufferTest;
|
|
|
|
TEST_F(KernelArgBufferTest, givenSharedBufferWhenSetArgIsCalledThenReportSharedObjUsage) {
|
|
MockGlSharing glSharing;
|
|
glSharing.uploadDataToBufferInfo(1, 0);
|
|
pContext->setSharingFunctions(new GlSharingFunctionsMock());
|
|
auto sharedBuffer = GlBuffer::createSharedGlBuffer(pContext, CL_MEM_READ_WRITE, 1);
|
|
auto nonSharedBuffer = new MockBuffer;
|
|
|
|
auto sharedMem = static_cast<cl_mem>(sharedBuffer);
|
|
auto nonSharedMem = static_cast<cl_mem>(nonSharedBuffer);
|
|
|
|
EXPECT_FALSE(pKernel->isUsingSharedObjArgs());
|
|
this->pKernel->setArg(0, sizeof(cl_mem *), &nonSharedMem);
|
|
EXPECT_FALSE(pKernel->isUsingSharedObjArgs());
|
|
|
|
this->pKernel->setArg(0, sizeof(cl_mem *), &sharedMem);
|
|
EXPECT_TRUE(pKernel->isUsingSharedObjArgs());
|
|
|
|
delete nonSharedBuffer;
|
|
delete sharedBuffer;
|
|
}
|
|
|
|
HWTEST_F(KernelArgBufferTest, givenSharedBufferWhenSetArgStatefulIsCalledThenBufferSurfaceShouldBeUsed) {
|
|
MockGlSharing glSharing;
|
|
glSharing.uploadDataToBufferInfo(1, 0);
|
|
pContext->setSharingFunctions(new GlSharingFunctionsMock());
|
|
auto sharedBuffer = GlBuffer::createSharedGlBuffer(pContext, CL_MEM_READ_WRITE, 1);
|
|
|
|
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
|
RENDER_SURFACE_STATE surfaceState = {};
|
|
|
|
sharedBuffer->setArgStateful(&surfaceState);
|
|
|
|
auto surfType = surfaceState.getSurfaceType();
|
|
EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER, surfType);
|
|
|
|
delete sharedBuffer;
|
|
}
|