mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Test prelim buffer object ext
Signed-off-by: Daniel Chabrowski daniel.chabrowski@intel.com Related-To: NEO-6591
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
3e8a6680e2
commit
10e7b9d5be
@@ -38,6 +38,15 @@ set(IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/self_lib_lin.cpp
|
||||
)
|
||||
|
||||
if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_fixture_context.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_fixture_context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_fixture_prelim.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object_tests_prelim.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NEO__LIBVA_FOUND)
|
||||
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_va_sharing_tests.cpp
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_context.h"
|
||||
|
||||
#include "third_party/uapi/prelim/drm/i915_drm.h"
|
||||
|
||||
int DrmMockCustomPrelimContext::ioctlExtra(unsigned long request, void *arg) {
|
||||
switch (request) {
|
||||
case PRELIM_DRM_IOCTL_I915_GEM_CREATE_EXT: {
|
||||
auto createExtParams = reinterpret_cast<prelim_drm_i915_gem_create_ext *>(arg);
|
||||
createExtSize = createExtParams->size;
|
||||
createExtHandle = createExtParams->handle;
|
||||
createExtExtensions = createExtParams->extensions;
|
||||
} break;
|
||||
case PRELIM_DRM_IOCTL_I915_GEM_VM_BIND: {
|
||||
} break;
|
||||
case PRELIM_DRM_IOCTL_I915_GEM_VM_UNBIND: {
|
||||
} break;
|
||||
case PRELIM_DRM_IOCTL_I915_GEM_WAIT_USER_FENCE: {
|
||||
const auto wait = reinterpret_cast<prelim_drm_i915_gem_wait_user_fence *>(arg);
|
||||
receivedGemWaitUserFence = WaitUserFence{
|
||||
wait->extensions,
|
||||
wait->addr,
|
||||
wait->ctx_id,
|
||||
wait->op,
|
||||
wait->flags,
|
||||
wait->value,
|
||||
wait->mask,
|
||||
wait->timeout,
|
||||
};
|
||||
gemWaitUserFenceCalled++;
|
||||
} break;
|
||||
default: {
|
||||
std::cout << std::hex << DRM_IOCTL_I915_GEM_WAIT << std::endl;
|
||||
std::cout << "unexpected IOCTL: " << std::hex << request << std::endl;
|
||||
UNRECOVERABLE_IF(true);
|
||||
} break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DrmMockCustomPrelimContext::execBufferExtensions(void *arg) {
|
||||
const auto execbuf = reinterpret_cast<drm_i915_gem_execbuffer2 *>(arg);
|
||||
if ((execbuf->flags | I915_EXEC_USE_EXTENSIONS) &&
|
||||
(execbuf->cliprects_ptr != 0)) {
|
||||
i915_user_extension *base = reinterpret_cast<i915_user_extension *>(execbuf->cliprects_ptr);
|
||||
if (base->name == PRELIM_DRM_I915_GEM_EXECBUFFER_EXT_USER_FENCE) {
|
||||
prelim_drm_i915_gem_execbuffer_ext_user_fence *userFenceExt =
|
||||
reinterpret_cast<prelim_drm_i915_gem_execbuffer_ext_user_fence *>(execbuf->cliprects_ptr);
|
||||
this->completionAddress = userFenceExt->addr;
|
||||
this->completionValue = userFenceExt->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/test/common/libult/linux/drm_mock_prelim_context.h"
|
||||
|
||||
struct DrmMockCustomPrelimContext {
|
||||
//PRELIM_DRM_IOCTL_I915_GEM_CREATE_EXT
|
||||
uint64_t createExtSize = 0;
|
||||
uint32_t createExtHandle = 0;
|
||||
uint64_t createExtExtensions = 0;
|
||||
|
||||
//PRELIM_DRM_IOCTL_I915_GEM_WAIT_USER_FENCE
|
||||
WaitUserFence receivedGemWaitUserFence{};
|
||||
uint32_t gemWaitUserFenceCalled = 0;
|
||||
|
||||
//PRELIM_DRM_I915_GEM_EXECBUFFER_EXT_USER_FENCE
|
||||
uint64_t completionAddress = 0;
|
||||
uint64_t completionValue = 0;
|
||||
|
||||
int ioctlExtra(unsigned long request, void *arg);
|
||||
void execBufferExtensions(void *arg);
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_context.h"
|
||||
|
||||
class DrmMockCustomPrelim : public DrmMockCustom {
|
||||
public:
|
||||
using Drm::cacheInfo;
|
||||
using Drm::ioctlHelper;
|
||||
using Drm::memoryInfo;
|
||||
|
||||
DrmMockCustomPrelim(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockCustom(rootDeviceEnvironment) {
|
||||
setupIoctlHelper(IGFX_UNKNOWN);
|
||||
}
|
||||
|
||||
void getPrelimVersion(std::string &prelimVersion) override {
|
||||
prelimVersion = "2.0";
|
||||
}
|
||||
|
||||
int ioctlExtra(unsigned long request, void *arg) override {
|
||||
return context.ioctlExtra(request, arg);
|
||||
}
|
||||
|
||||
void execBufferExtensions(void *arg) override {
|
||||
return context.execBufferExtensions(arg);
|
||||
}
|
||||
|
||||
DrmMockCustomPrelimContext context{};
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock.h"
|
||||
#include "shared/test/common/os_interface/linux/drm_buffer_object_fixture.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_prelim.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using DrmBufferObjectPrelimFixture = DrmBufferObjectFixture<DrmMockCustomPrelim>;
|
||||
using DrmBufferObjectPrelimTest = Test<DrmBufferObjectPrelimFixture>;
|
||||
|
||||
TEST_F(DrmBufferObjectPrelimTest, GivenCompletionAddressWhenCallingExecThenReturnIsCorrect) {
|
||||
mock->ioctl_expected.total = 1;
|
||||
mock->ioctl_res = 0;
|
||||
|
||||
constexpr uint64_t completionAddress = 0x1230;
|
||||
constexpr uint32_t completionValue = 33;
|
||||
constexpr uint64_t expectedCompletionValue = completionValue;
|
||||
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
auto ret = bo->exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, completionAddress, completionValue);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(completionAddress, mock->context.completionAddress);
|
||||
EXPECT_EQ(expectedCompletionValue, mock->context.completionValue);
|
||||
}
|
||||
Reference in New Issue
Block a user