mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Move drm wrappers to a separate file
Related-To: NEO-6852 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
9e7b2a77ea
commit
de465b1e6c
@ -12,6 +12,7 @@
|
||||
#include "shared/source/os_interface/linux/drm_allocation.h"
|
||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/utilities/wait_util.h"
|
||||
|
||||
|
@ -41,6 +41,8 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_create_multi_host_allocation.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_wrappers.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_wrappers.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_drm.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/linux/os_time_linux.h"
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "shared/source/memory_manager/residency.h"
|
||||
#include "shared/source/os_interface/linux/allocator_helper.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/source/os_interface/linux/device_time_drm.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
|
48
shared/source/os_interface/linux/drm_wrappers.cpp
Normal file
48
shared/source/os_interface/linux/drm_wrappers.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
static_assert(sizeof(GemCreate) == sizeof(drm_i915_gem_create));
|
||||
static_assert(offsetof(GemCreate, size) == offsetof(drm_i915_gem_create, size));
|
||||
static_assert(offsetof(GemCreate, handle) == offsetof(drm_i915_gem_create, handle));
|
||||
|
||||
static_assert(sizeof(GemUserPtr) == sizeof(drm_i915_gem_userptr));
|
||||
static_assert(offsetof(GemUserPtr, userPtr) == offsetof(drm_i915_gem_userptr, user_ptr));
|
||||
static_assert(offsetof(GemUserPtr, userSize) == offsetof(drm_i915_gem_userptr, user_size));
|
||||
static_assert(offsetof(GemUserPtr, flags) == offsetof(drm_i915_gem_userptr, flags));
|
||||
static_assert(offsetof(GemUserPtr, handle) == offsetof(drm_i915_gem_userptr, handle));
|
||||
|
||||
static_assert(sizeof(RegisterRead) == sizeof(drm_i915_reg_read));
|
||||
static_assert(offsetof(RegisterRead, offset) == offsetof(drm_i915_reg_read, offset));
|
||||
static_assert(offsetof(RegisterRead, value) == offsetof(drm_i915_reg_read, val));
|
||||
|
||||
static_assert(sizeof(GemSetTiling) == sizeof(drm_i915_gem_set_tiling));
|
||||
static_assert(offsetof(GemSetTiling, handle) == offsetof(drm_i915_gem_set_tiling, handle));
|
||||
static_assert(offsetof(GemSetTiling, tilingMode) == offsetof(drm_i915_gem_set_tiling, tiling_mode));
|
||||
static_assert(offsetof(GemSetTiling, stride) == offsetof(drm_i915_gem_set_tiling, stride));
|
||||
static_assert(offsetof(GemSetTiling, swizzleMode) == offsetof(drm_i915_gem_set_tiling, swizzle_mode));
|
||||
|
||||
static_assert(sizeof(GemGetTiling) == sizeof(drm_i915_gem_get_tiling));
|
||||
static_assert(offsetof(GemGetTiling, handle) == offsetof(drm_i915_gem_get_tiling, handle));
|
||||
static_assert(offsetof(GemGetTiling, tilingMode) == offsetof(drm_i915_gem_get_tiling, tiling_mode));
|
||||
static_assert(offsetof(GemGetTiling, swizzleMode) == offsetof(drm_i915_gem_get_tiling, swizzle_mode));
|
||||
static_assert(offsetof(GemGetTiling, physSwizzleMode) == offsetof(drm_i915_gem_get_tiling, phys_swizzle_mode));
|
||||
|
||||
bool GemGetTiling::isTilingDisabled() const { return I915_TILING_NONE == tilingMode; }
|
||||
|
||||
static_assert(sizeof(ExecObject) == sizeof(drm_i915_gem_exec_object2));
|
||||
|
||||
static_assert(sizeof(ExecBuffer) == sizeof(drm_i915_gem_execbuffer2));
|
||||
|
||||
} // namespace NEO
|
52
shared/source/os_interface/linux/drm_wrappers.h
Normal file
52
shared/source/os_interface/linux/drm_wrappers.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
namespace NEO {
|
||||
|
||||
struct RegisterRead {
|
||||
uint64_t offset;
|
||||
uint64_t value;
|
||||
};
|
||||
|
||||
struct ExecObject {
|
||||
uint8_t data[56];
|
||||
};
|
||||
|
||||
struct ExecBuffer {
|
||||
uint8_t data[64];
|
||||
};
|
||||
|
||||
struct GemCreate {
|
||||
uint64_t size;
|
||||
uint32_t handle;
|
||||
};
|
||||
|
||||
struct GemUserPtr {
|
||||
uint64_t userPtr;
|
||||
uint64_t userSize;
|
||||
uint32_t flags;
|
||||
uint32_t handle;
|
||||
};
|
||||
|
||||
struct GemSetTiling {
|
||||
uint32_t handle;
|
||||
uint32_t tilingMode;
|
||||
uint32_t stride;
|
||||
uint32_t swizzleMode;
|
||||
};
|
||||
|
||||
struct GemGetTiling {
|
||||
bool isTilingDisabled() const;
|
||||
|
||||
uint32_t handle;
|
||||
uint32_t tilingMode;
|
||||
uint32_t swizzleMode;
|
||||
uint32_t physSwizzleMode;
|
||||
};
|
||||
} // namespace NEO
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
@ -18,36 +19,6 @@ uint32_t IoctlHelper::ioctl(Drm *drm, unsigned long request, void *arg) {
|
||||
return drm->ioctl(request, arg);
|
||||
}
|
||||
|
||||
static_assert(sizeof(GemCreate) == sizeof(drm_i915_gem_create));
|
||||
static_assert(offsetof(GemCreate, size) == offsetof(drm_i915_gem_create, size));
|
||||
static_assert(offsetof(GemCreate, handle) == offsetof(drm_i915_gem_create, handle));
|
||||
|
||||
static_assert(sizeof(GemUserPtr) == sizeof(drm_i915_gem_userptr));
|
||||
static_assert(offsetof(GemUserPtr, userPtr) == offsetof(drm_i915_gem_userptr, user_ptr));
|
||||
static_assert(offsetof(GemUserPtr, userSize) == offsetof(drm_i915_gem_userptr, user_size));
|
||||
static_assert(offsetof(GemUserPtr, flags) == offsetof(drm_i915_gem_userptr, flags));
|
||||
static_assert(offsetof(GemUserPtr, handle) == offsetof(drm_i915_gem_userptr, handle));
|
||||
|
||||
static_assert(sizeof(RegisterRead) == sizeof(drm_i915_reg_read));
|
||||
static_assert(offsetof(RegisterRead, offset) == offsetof(drm_i915_reg_read, offset));
|
||||
static_assert(offsetof(RegisterRead, value) == offsetof(drm_i915_reg_read, val));
|
||||
|
||||
static_assert(sizeof(GemSetTiling) == sizeof(drm_i915_gem_set_tiling));
|
||||
static_assert(offsetof(GemSetTiling, handle) == offsetof(drm_i915_gem_set_tiling, handle));
|
||||
static_assert(offsetof(GemSetTiling, tilingMode) == offsetof(drm_i915_gem_set_tiling, tiling_mode));
|
||||
static_assert(offsetof(GemSetTiling, stride) == offsetof(drm_i915_gem_set_tiling, stride));
|
||||
static_assert(offsetof(GemSetTiling, swizzleMode) == offsetof(drm_i915_gem_set_tiling, swizzle_mode));
|
||||
|
||||
static_assert(sizeof(GemGetTiling) == sizeof(drm_i915_gem_get_tiling));
|
||||
static_assert(offsetof(GemGetTiling, handle) == offsetof(drm_i915_gem_get_tiling, handle));
|
||||
static_assert(offsetof(GemGetTiling, tilingMode) == offsetof(drm_i915_gem_get_tiling, tiling_mode));
|
||||
static_assert(offsetof(GemGetTiling, swizzleMode) == offsetof(drm_i915_gem_get_tiling, swizzle_mode));
|
||||
static_assert(offsetof(GemGetTiling, physSwizzleMode) == offsetof(drm_i915_gem_get_tiling, phys_swizzle_mode));
|
||||
|
||||
bool GemGetTiling::isTilingDisabled() const { return I915_TILING_NONE == tilingMode; }
|
||||
|
||||
static_assert(sizeof(ExecObject) == sizeof(drm_i915_gem_exec_object2));
|
||||
|
||||
void IoctlHelper::fillExecObject(ExecObject &execObject, uint32_t handle, uint64_t gpuAddress, uint32_t drmContextId, bool bindInfo, bool isMarkedForCapture) {
|
||||
|
||||
auto &drmExecObject = *reinterpret_cast<drm_i915_gem_exec_object2 *>(execObject.data);
|
||||
@ -82,8 +53,6 @@ void IoctlHelper::logExecObject(const ExecObject &execObject, std::stringstream
|
||||
<< ", size: " << size << " }\n";
|
||||
}
|
||||
|
||||
static_assert(sizeof(ExecBuffer) == sizeof(drm_i915_gem_execbuffer2));
|
||||
|
||||
void IoctlHelper::fillExecBuffer(ExecBuffer &execBuffer, uintptr_t buffersPtr, uint32_t bufferCount, uint32_t startOffset, uint32_t size, uint64_t flags, uint32_t drmContextId) {
|
||||
auto &drmExecBuffer = *reinterpret_cast<drm_i915_gem_execbuffer2 *>(execBuffer.data);
|
||||
drmExecBuffer.buffers_ptr = buffersPtr;
|
||||
|
@ -25,6 +25,8 @@ class Drm;
|
||||
class IoctlHelper;
|
||||
enum class CacheRegion : uint16_t;
|
||||
struct HardwareInfo;
|
||||
struct ExecBuffer;
|
||||
struct ExecObject;
|
||||
|
||||
extern IoctlHelper *ioctlHelperFactory[IGFX_MAX_PRODUCT];
|
||||
|
||||
@ -70,51 +72,10 @@ struct UuidRegisterResult {
|
||||
uint32_t handle;
|
||||
};
|
||||
|
||||
struct RegisterRead {
|
||||
uint64_t offset;
|
||||
uint64_t value;
|
||||
};
|
||||
|
||||
using MemRegionsVec = StackVec<MemoryClassInstance, 5>;
|
||||
using VmBindExtSetPatT = uint8_t[40];
|
||||
using VmBindExtUserFenceT = uint8_t[56];
|
||||
|
||||
struct ExecObject {
|
||||
uint8_t data[56];
|
||||
};
|
||||
|
||||
struct ExecBuffer {
|
||||
uint8_t data[64];
|
||||
};
|
||||
|
||||
struct GemCreate {
|
||||
uint64_t size;
|
||||
uint32_t handle;
|
||||
};
|
||||
|
||||
struct GemUserPtr {
|
||||
uint64_t userPtr;
|
||||
uint64_t userSize;
|
||||
uint32_t flags;
|
||||
uint32_t handle;
|
||||
};
|
||||
|
||||
struct GemSetTiling {
|
||||
uint32_t handle;
|
||||
uint32_t tilingMode;
|
||||
uint32_t stride;
|
||||
uint32_t swizzleMode;
|
||||
};
|
||||
|
||||
struct GemGetTiling {
|
||||
bool isTilingDisabled() const;
|
||||
|
||||
uint32_t handle;
|
||||
uint32_t tilingMode;
|
||||
uint32_t swizzleMode;
|
||||
uint32_t physSwizzleMode;
|
||||
};
|
||||
|
||||
class IoctlHelper {
|
||||
public:
|
||||
virtual ~IoctlHelper() {}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/linux/cache_info.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
|
||||
#include "third_party/uapi/prelim/drm/i915_drm.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
Reference in New Issue
Block a user