mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
gfxstream: Rename platform/linux to platform/drm
... And rename LinuxVirtGpu* -> DrmVirtGpu* The characteristic of this virtgpu implementation is that it works through the DRI from Linux. Yes, this is traditionally "Linux" specific, but some platforms such as QNX, have started to incorporate parts of the "DRM framework", on a platform that otherwise still is not "Linux". This is just a more generally applicable naming to this implementation. Reviewed-by: Gurchetan Singh <gurchetansingh@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36229>
This commit is contained in:
parent
0dc9108f7a
commit
4f227dc00c
10 changed files with 85 additions and 85 deletions
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "LinuxSync.h"
|
||||
#include "DrmSync.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
|
||||
namespace gfxstream {
|
||||
|
||||
LinuxSyncHelper::LinuxSyncHelper() {}
|
||||
DrmSyncHelper::DrmSyncHelper() {}
|
||||
|
||||
int LinuxSyncHelper::wait(int syncFd, int timeoutMilliseconds) {
|
||||
int DrmSyncHelper::wait(int syncFd, int timeoutMilliseconds) {
|
||||
return sync_wait(syncFd, timeoutMilliseconds);
|
||||
}
|
||||
|
||||
void LinuxSyncHelper::debugPrint(int syncFd) {
|
||||
void DrmSyncHelper::debugPrint(int syncFd) {
|
||||
struct sync_file_info* info = sync_file_info(syncFd);
|
||||
if (!info) {
|
||||
mesa_loge("failed to get sync file info");
|
||||
|
|
@ -38,10 +38,10 @@ void LinuxSyncHelper::debugPrint(int syncFd) {
|
|||
free(info);
|
||||
}
|
||||
|
||||
int LinuxSyncHelper::dup(int syncFd) { return ::dup(syncFd); }
|
||||
int DrmSyncHelper::dup(int syncFd) { return ::dup(syncFd); }
|
||||
|
||||
int LinuxSyncHelper::close(int syncFd) { return ::close(syncFd); }
|
||||
int DrmSyncHelper::close(int syncFd) { return ::close(syncFd); }
|
||||
|
||||
SyncHelper* osCreateSyncHelper() { return new LinuxSyncHelper(); }
|
||||
SyncHelper* osCreateSyncHelper() { return new DrmSyncHelper(); }
|
||||
|
||||
} // namespace gfxstream
|
||||
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
namespace gfxstream {
|
||||
|
||||
class LinuxSyncHelper : public SyncHelper {
|
||||
class DrmSyncHelper : public SyncHelper {
|
||||
public:
|
||||
LinuxSyncHelper();
|
||||
DrmSyncHelper();
|
||||
|
||||
int wait(int syncFd, int timeoutMilliseconds) override;
|
||||
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
#include "VirtGpu.h"
|
||||
#include <xf86drm.h>
|
||||
|
||||
class LinuxVirtGpuResource : public std::enable_shared_from_this<LinuxVirtGpuResource>,
|
||||
class DrmVirtGpuResource : public std::enable_shared_from_this<DrmVirtGpuResource>,
|
||||
public VirtGpuResource {
|
||||
public:
|
||||
LinuxVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle,
|
||||
DrmVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle,
|
||||
uint64_t size);
|
||||
~LinuxVirtGpuResource();
|
||||
~DrmVirtGpuResource();
|
||||
|
||||
void intoRaw() override;
|
||||
uint32_t getResourceHandle() const override;
|
||||
|
|
@ -37,10 +37,10 @@ class LinuxVirtGpuResource : public std::enable_shared_from_this<LinuxVirtGpuRes
|
|||
uint64_t mSize;
|
||||
};
|
||||
|
||||
class LinuxVirtGpuResourceMapping : public VirtGpuResourceMapping {
|
||||
class DrmVirtGpuResourceMapping : public VirtGpuResourceMapping {
|
||||
public:
|
||||
LinuxVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr, uint64_t size);
|
||||
~LinuxVirtGpuResourceMapping(void);
|
||||
DrmVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr, uint64_t size);
|
||||
~DrmVirtGpuResourceMapping(void);
|
||||
|
||||
uint8_t* asRawPtr(void) override;
|
||||
|
||||
|
|
@ -50,12 +50,12 @@ class LinuxVirtGpuResourceMapping : public VirtGpuResourceMapping {
|
|||
uint64_t mSize;
|
||||
};
|
||||
|
||||
class LinuxVirtGpuDevice : public VirtGpuDevice {
|
||||
class DrmVirtGpuDevice : public VirtGpuDevice {
|
||||
public:
|
||||
LinuxVirtGpuDevice(enum VirtGpuCapset capset);
|
||||
DrmVirtGpuDevice(enum VirtGpuCapset capset);
|
||||
int32_t init(int32_t descriptor);
|
||||
|
||||
virtual ~LinuxVirtGpuDevice();
|
||||
virtual ~DrmVirtGpuDevice();
|
||||
|
||||
virtual int64_t getDeviceHandle(void);
|
||||
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "LinuxVirtGpu.h"
|
||||
#include "DrmVirtGpu.h"
|
||||
#include "drm-uapi/virtgpu_drm.h"
|
||||
#include "util/log.h"
|
||||
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
static std::mutex sDrmObjectRefMutex;
|
||||
static std::unordered_map<uint32_t, int> sDrmObjectRefMap;
|
||||
|
||||
LinuxVirtGpuResource::LinuxVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle,
|
||||
DrmVirtGpuResource::DrmVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle,
|
||||
uint32_t resourceHandle, uint64_t size)
|
||||
: mDeviceHandle(deviceHandle),
|
||||
mBlobHandle(blobHandle),
|
||||
|
|
@ -42,7 +42,7 @@ LinuxVirtGpuResource::LinuxVirtGpuResource(int64_t deviceHandle, uint32_t blobHa
|
|||
}
|
||||
}
|
||||
|
||||
LinuxVirtGpuResource::~LinuxVirtGpuResource() {
|
||||
DrmVirtGpuResource::~DrmVirtGpuResource() {
|
||||
if (mBlobHandle == INVALID_DESCRIPTOR) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ LinuxVirtGpuResource::~LinuxVirtGpuResource() {
|
|||
auto refMapIt = sDrmObjectRefMap.find(mBlobHandle);
|
||||
if (refMapIt == sDrmObjectRefMap.end()) {
|
||||
mesa_logw(
|
||||
"LinuxVirtGpuResource::~LinuxVirtGpuResource() could not find the blobHandle: %d in "
|
||||
"DrmVirtGpuResource::~DrmVirtGpuResource() could not find the blobHandle: %d in "
|
||||
"internal map",
|
||||
mBlobHandle);
|
||||
return;
|
||||
|
|
@ -73,18 +73,18 @@ LinuxVirtGpuResource::~LinuxVirtGpuResource() {
|
|||
}
|
||||
}
|
||||
|
||||
void LinuxVirtGpuResource::intoRaw() {
|
||||
void DrmVirtGpuResource::intoRaw() {
|
||||
mBlobHandle = INVALID_DESCRIPTOR;
|
||||
mResourceHandle = INVALID_DESCRIPTOR;
|
||||
}
|
||||
|
||||
uint32_t LinuxVirtGpuResource::getBlobHandle() const { return mBlobHandle; }
|
||||
uint32_t DrmVirtGpuResource::getBlobHandle() const { return mBlobHandle; }
|
||||
|
||||
uint32_t LinuxVirtGpuResource::getResourceHandle() const { return mResourceHandle; }
|
||||
uint32_t DrmVirtGpuResource::getResourceHandle() const { return mResourceHandle; }
|
||||
|
||||
uint64_t LinuxVirtGpuResource::getSize() const { return mSize; }
|
||||
uint64_t DrmVirtGpuResource::getSize() const { return mSize; }
|
||||
|
||||
VirtGpuResourceMappingPtr LinuxVirtGpuResource::createMapping() {
|
||||
VirtGpuResourceMappingPtr DrmVirtGpuResource::createMapping() {
|
||||
int ret;
|
||||
struct drm_virtgpu_map map {
|
||||
.handle = mBlobHandle, .pad = 0,
|
||||
|
|
@ -104,10 +104,10 @@ VirtGpuResourceMappingPtr LinuxVirtGpuResource::createMapping() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<LinuxVirtGpuResourceMapping>(shared_from_this(), ptr, mSize);
|
||||
return std::make_shared<DrmVirtGpuResourceMapping>(shared_from_this(), ptr, mSize);
|
||||
}
|
||||
|
||||
int LinuxVirtGpuResource::exportBlob(struct VirtGpuExternalHandle& handle) {
|
||||
int DrmVirtGpuResource::exportBlob(struct VirtGpuExternalHandle& handle) {
|
||||
int ret, fd;
|
||||
|
||||
uint32_t flags = DRM_CLOEXEC;
|
||||
|
|
@ -122,7 +122,7 @@ int LinuxVirtGpuResource::exportBlob(struct VirtGpuExternalHandle& handle) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LinuxVirtGpuResource::wait() {
|
||||
int DrmVirtGpuResource::wait() {
|
||||
int ret;
|
||||
struct drm_virtgpu_3d_wait wait_3d = {0};
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ int LinuxVirtGpuResource::wait() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LinuxVirtGpuResource::transferToHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
int DrmVirtGpuResource::transferToHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
int ret;
|
||||
struct drm_virtgpu_3d_transfer_to_host xfer = {0};
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ int LinuxVirtGpuResource::transferToHost(uint32_t x, uint32_t y, uint32_t w, uin
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LinuxVirtGpuResource::transferFromHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
int DrmVirtGpuResource::transferFromHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
int ret;
|
||||
struct drm_virtgpu_3d_transfer_from_host xfer = {0};
|
||||
|
||||
17
src/gfxstream/guest/platform/drm/DrmVirtGpuBlobMapping.cpp
Normal file
17
src/gfxstream/guest/platform/drm/DrmVirtGpuBlobMapping.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright 2022 Google
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "DrmVirtGpu.h"
|
||||
#include "drm-uapi/virtgpu_drm.h"
|
||||
|
||||
DrmVirtGpuResourceMapping::DrmVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr,
|
||||
uint64_t size)
|
||||
: mBlob(blob), mPtr(ptr), mSize(size) {}
|
||||
|
||||
DrmVirtGpuResourceMapping::~DrmVirtGpuResourceMapping(void) { munmap(mPtr, mSize); }
|
||||
|
||||
uint8_t* DrmVirtGpuResourceMapping::asRawPtr(void) { return mPtr; }
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include "LinuxVirtGpu.h"
|
||||
#include "DrmVirtGpu.h"
|
||||
#include "drm-uapi/virtgpu_drm.h"
|
||||
#include "util/detect_os.h"
|
||||
#include "util/log.h"
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
static inline uint32_t align_up(uint32_t n, uint32_t a) { return ((n + a - 1) / a) * a; }
|
||||
|
||||
int32_t LinuxVirtGpuDevice::openDevice() {
|
||||
int32_t DrmVirtGpuDevice::openDevice() {
|
||||
drmDevicePtr devs[8];
|
||||
int32_t ret = -EINVAL;
|
||||
int count = drmGetDevices2(0, devs, ARRAY_SIZE(devs));
|
||||
|
|
@ -139,9 +139,9 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
LinuxVirtGpuDevice::LinuxVirtGpuDevice(enum VirtGpuCapset capset) : VirtGpuDevice(capset) {}
|
||||
DrmVirtGpuDevice::DrmVirtGpuDevice(enum VirtGpuCapset capset) : VirtGpuDevice(capset) {}
|
||||
|
||||
int32_t LinuxVirtGpuDevice::init(int32_t descriptor) {
|
||||
int32_t DrmVirtGpuDevice::init(int32_t descriptor) {
|
||||
struct VirtGpuParam params[] = {
|
||||
PARAM(VIRTGPU_PARAM_3D_FEATURES), PARAM(VIRTGPU_PARAM_CAPSET_QUERY_FIX),
|
||||
PARAM(VIRTGPU_PARAM_RESOURCE_BLOB), PARAM(VIRTGPU_PARAM_HOST_VISIBLE),
|
||||
|
|
@ -269,13 +269,13 @@ int32_t LinuxVirtGpuDevice::init(int32_t descriptor) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
LinuxVirtGpuDevice::~LinuxVirtGpuDevice() { close(mDeviceHandle); }
|
||||
DrmVirtGpuDevice::~DrmVirtGpuDevice() { close(mDeviceHandle); }
|
||||
|
||||
struct VirtGpuCaps LinuxVirtGpuDevice::getCaps(void) { return mCaps; }
|
||||
struct VirtGpuCaps DrmVirtGpuDevice::getCaps(void) { return mCaps; }
|
||||
|
||||
int64_t LinuxVirtGpuDevice::getDeviceHandle(void) { return mDeviceHandle; }
|
||||
int64_t DrmVirtGpuDevice::getDeviceHandle(void) { return mDeviceHandle; }
|
||||
|
||||
VirtGpuResourcePtr LinuxVirtGpuDevice::createResource(uint32_t width, uint32_t height,
|
||||
VirtGpuResourcePtr DrmVirtGpuDevice::createResource(uint32_t width, uint32_t height,
|
||||
uint32_t stride, uint32_t size,
|
||||
uint32_t virglFormat, uint32_t target,
|
||||
uint32_t bind) {
|
||||
|
|
@ -299,11 +299,11 @@ VirtGpuResourcePtr LinuxVirtGpuDevice::createResource(uint32_t width, uint32_t h
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<LinuxVirtGpuResource>(
|
||||
return std::make_shared<DrmVirtGpuResource>(
|
||||
mDeviceHandle, create.bo_handle, create.res_handle, static_cast<uint64_t>(create.size));
|
||||
}
|
||||
|
||||
VirtGpuResourcePtr LinuxVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& blobCreate) {
|
||||
VirtGpuResourcePtr DrmVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& blobCreate) {
|
||||
int ret;
|
||||
struct drm_virtgpu_resource_create_blob create = {0};
|
||||
|
||||
|
|
@ -320,11 +320,11 @@ VirtGpuResourcePtr LinuxVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<LinuxVirtGpuResource>(mDeviceHandle, create.bo_handle,
|
||||
return std::make_shared<DrmVirtGpuResource>(mDeviceHandle, create.bo_handle,
|
||||
create.res_handle, blobCreate.size);
|
||||
}
|
||||
|
||||
VirtGpuResourcePtr LinuxVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle& handle) {
|
||||
VirtGpuResourcePtr DrmVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle& handle) {
|
||||
struct drm_virtgpu_resource_info info = {0};
|
||||
uint32_t blobHandle;
|
||||
int ret;
|
||||
|
|
@ -343,11 +343,11 @@ VirtGpuResourcePtr LinuxVirtGpuDevice::importBlob(const struct VirtGpuExternalHa
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<LinuxVirtGpuResource>(mDeviceHandle, blobHandle, info.res_handle,
|
||||
return std::make_shared<DrmVirtGpuResource>(mDeviceHandle, blobHandle, info.res_handle,
|
||||
static_cast<uint64_t>(info.size));
|
||||
}
|
||||
|
||||
int LinuxVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer,
|
||||
int DrmVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer,
|
||||
const VirtGpuResource* blob) {
|
||||
int ret;
|
||||
struct drm_virtgpu_execbuffer exec = {0};
|
||||
|
|
@ -380,7 +380,7 @@ int LinuxVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer,
|
|||
}
|
||||
|
||||
VirtGpuDevice* osCreateVirtGpuDevice(enum VirtGpuCapset capset, int32_t descriptor) {
|
||||
auto device = new LinuxVirtGpuDevice(capset);
|
||||
auto device = new DrmVirtGpuDevice(capset);
|
||||
int32_t ret = device->init(descriptor);
|
||||
if (ret) {
|
||||
delete device;
|
||||
|
|
@ -390,7 +390,7 @@ VirtGpuDevice* osCreateVirtGpuDevice(enum VirtGpuCapset capset, int32_t descript
|
|||
return device;
|
||||
}
|
||||
|
||||
bool LinuxVirtGpuDevice::getDrmInfo(VirtGpuDrmInfo* drmInfo) {
|
||||
bool DrmVirtGpuDevice::getDrmInfo(VirtGpuDrmInfo* drmInfo) {
|
||||
drmInfo->hasPrimary = mHasPrimary;
|
||||
drmInfo->hasRender = true;
|
||||
drmInfo->primaryMajor = mPrimaryMajor;
|
||||
|
|
@ -400,7 +400,7 @@ bool LinuxVirtGpuDevice::getDrmInfo(VirtGpuDrmInfo* drmInfo) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool LinuxVirtGpuDevice::getPciBusInfo(VirtGpuPciBusInfo* pciBusInfo) {
|
||||
bool DrmVirtGpuDevice::getPciBusInfo(VirtGpuPciBusInfo* pciBusInfo) {
|
||||
if (mBusType != DRM_BUS_PCI) {
|
||||
return false;
|
||||
}
|
||||
17
src/gfxstream/guest/platform/drm/meson.build
Normal file
17
src/gfxstream/guest/platform/drm/meson.build
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Copyright 2022 Google
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
files_libplatform_virtgpu_drm = files(
|
||||
'DrmVirtGpuDevice.cpp',
|
||||
'DrmVirtGpuBlobMapping.cpp',
|
||||
'DrmVirtGpuBlob.cpp',
|
||||
'DrmSync.cpp',
|
||||
)
|
||||
|
||||
libplatform_virtgpu_drm = static_library(
|
||||
'platform_virtgpu_drm',
|
||||
files_libplatform_virtgpu_drm,
|
||||
cpp_args: gfxstream_guest_args,
|
||||
include_directories: [inc_platform_virtgpu, inc_src, inc_include],
|
||||
dependencies: dep_libdrm,
|
||||
)
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Copyright 2022 Google
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "LinuxVirtGpu.h"
|
||||
#include "drm-uapi/virtgpu_drm.h"
|
||||
|
||||
LinuxVirtGpuResourceMapping::LinuxVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr,
|
||||
uint64_t size)
|
||||
: mBlob(blob), mPtr(ptr), mSize(size) {}
|
||||
|
||||
LinuxVirtGpuResourceMapping::~LinuxVirtGpuResourceMapping(void) { munmap(mPtr, mSize); }
|
||||
|
||||
uint8_t* LinuxVirtGpuResourceMapping::asRawPtr(void) { return mPtr; }
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
# Copyright 2022 Google
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
files_libplatform_virtgpu_linux = files(
|
||||
'LinuxVirtGpuDevice.cpp',
|
||||
'LinuxVirtGpuBlobMapping.cpp',
|
||||
'LinuxVirtGpuBlob.cpp',
|
||||
'LinuxSync.cpp',
|
||||
)
|
||||
|
||||
libplatform_virtgpu_linux = static_library(
|
||||
'platform_virtgpu_linux',
|
||||
files_libplatform_virtgpu_linux,
|
||||
cpp_args: gfxstream_guest_args,
|
||||
include_directories: [inc_platform_virtgpu, inc_src, inc_include],
|
||||
dependencies: dep_libdrm,
|
||||
)
|
||||
|
|
@ -8,8 +8,8 @@ subdir('kumquat')
|
|||
libplatform_virtgpu = [libplatform_virtgpu_kumquat]
|
||||
|
||||
if system_has_kms_drm
|
||||
subdir('linux')
|
||||
libplatform_virtgpu += libplatform_virtgpu_linux
|
||||
subdir('drm')
|
||||
libplatform_virtgpu += libplatform_virtgpu_drm
|
||||
elif host_machine.system() == 'windows'
|
||||
subdir('windows')
|
||||
libplatform_virtgpu += libplatform_virtgpu_windows
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue