gfxstream: Add common interfaces in the VirtGpuDevice to query DrmInfo
and PciBusInfo - Advertise the availability of these extensions, fully implemented as guestOnly features Reviewed-By: Gurchetan Singh <gurchetansingh@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33363>
This commit is contained in:
@@ -130,6 +130,23 @@ struct VirtGpuCaps {
|
||||
struct composerCapset composerCapset;
|
||||
};
|
||||
|
||||
struct VirtGpuDrmInfo {
|
||||
bool hasPrimary;
|
||||
bool hasRender;
|
||||
int64_t primaryMajor;
|
||||
int64_t primaryMinor;
|
||||
int64_t renderMajor;
|
||||
int64_t renderMinor;
|
||||
};
|
||||
|
||||
// Note: Fields match equivalent structure for Magma
|
||||
struct VirtGpuPciBusInfo {
|
||||
uint16_t domain;
|
||||
uint8_t bus;
|
||||
uint8_t device;
|
||||
uint8_t function;
|
||||
};
|
||||
|
||||
#define INVALID_DESCRIPTOR -1
|
||||
|
||||
class VirtGpuResourceMapping;
|
||||
@@ -196,6 +213,9 @@ class VirtGpuDevice {
|
||||
|
||||
virtual int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuResource* blob) = 0;
|
||||
|
||||
virtual bool getDrmInfo(VirtGpuDrmInfo* drmInfo) { return false; }
|
||||
virtual bool getPciBusInfo(VirtGpuPciBusInfo* pciBusInfo) { return false; }
|
||||
|
||||
private:
|
||||
enum VirtGpuCapset mCapset;
|
||||
};
|
||||
|
||||
@@ -67,6 +67,9 @@ class LinuxVirtGpuDevice : public VirtGpuDevice {
|
||||
virtual VirtGpuResourcePtr importBlob(const struct VirtGpuExternalHandle& handle);
|
||||
virtual int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuResource* blob);
|
||||
|
||||
virtual bool getDrmInfo(VirtGpuDrmInfo* drmInfo) override;
|
||||
virtual bool getPciBusInfo(VirtGpuPciBusInfo* pciBusInfo) override;
|
||||
|
||||
private:
|
||||
int64_t mDeviceHandle;
|
||||
struct VirtGpuCaps mCaps;
|
||||
|
||||
@@ -356,3 +356,26 @@ int LinuxVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer,
|
||||
VirtGpuDevice* osCreateVirtGpuDevice(enum VirtGpuCapset capset, int32_t descriptor) {
|
||||
return new LinuxVirtGpuDevice(capset, descriptor);
|
||||
}
|
||||
|
||||
bool LinuxVirtGpuDevice::getDrmInfo(VirtGpuDrmInfo* drmInfo) {
|
||||
drmInfo->hasPrimary = mHasPrimary;
|
||||
drmInfo->hasRender = true;
|
||||
drmInfo->primaryMajor = mPrimaryMajor;
|
||||
drmInfo->primaryMinor = mPrimaryMinor;
|
||||
drmInfo->renderMajor = mRenderMajor;
|
||||
drmInfo->renderMinor = mRenderMinor;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LinuxVirtGpuDevice::getPciBusInfo(VirtGpuPciBusInfo* pciBusInfo) {
|
||||
if (mBusType != DRM_BUS_PCI) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pciBusInfo->domain = mPciBusInfo.domain;
|
||||
pciBusInfo->bus = mPciBusInfo.bus;
|
||||
pciBusInfo->device = mPciBusInfo.dev;
|
||||
pciBusInfo->function = mPciBusInfo.func;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2101,6 +2101,42 @@ void ResourceTracker::on_vkGetPhysicalDeviceProperties2(void* context,
|
||||
VkPhysicalDeviceProperties2* pProperties) {
|
||||
if (pProperties) {
|
||||
on_vkGetPhysicalDeviceProperties(context, physicalDevice, &pProperties->properties);
|
||||
|
||||
VkPhysicalDeviceDrmPropertiesEXT* drmProps =
|
||||
vk_find_struct(pProperties, PHYSICAL_DEVICE_DRM_PROPERTIES_EXT);
|
||||
if (drmProps) {
|
||||
VirtGpuDrmInfo drmInfo;
|
||||
if (VirtGpuDevice::getInstance()->getDrmInfo(&drmInfo)) {
|
||||
drmProps->hasPrimary = drmInfo.hasPrimary;
|
||||
drmProps->hasRender = drmInfo.hasRender;
|
||||
drmProps->primaryMajor = drmInfo.primaryMajor;
|
||||
drmProps->primaryMinor = drmInfo.primaryMinor;
|
||||
drmProps->renderMajor = drmInfo.renderMajor;
|
||||
drmProps->renderMinor = drmInfo.renderMinor;
|
||||
} else {
|
||||
mesa_logd(
|
||||
"%s: encountered VkPhysicalDeviceDrmPropertiesEXT in pProperties::pNext chain, "
|
||||
"but failed to query DrmInfo from the VirtGpuDevice",
|
||||
__func__);
|
||||
}
|
||||
}
|
||||
|
||||
VkPhysicalDevicePCIBusInfoPropertiesEXT* pciBusInfoProps =
|
||||
vk_find_struct(pProperties, PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT);
|
||||
if (pciBusInfoProps) {
|
||||
VirtGpuPciBusInfo pciBusInfo;
|
||||
if (VirtGpuDevice::getInstance()->getPciBusInfo(&pciBusInfo)) {
|
||||
pciBusInfoProps->pciDomain = pciBusInfo.domain;
|
||||
pciBusInfoProps->pciBus = pciBusInfo.bus;
|
||||
pciBusInfoProps->pciDevice = pciBusInfo.device;
|
||||
pciBusInfoProps->pciFunction = pciBusInfo.function;
|
||||
} else {
|
||||
mesa_logd(
|
||||
"%s: encountered VkPhysicalDevicePCIBusInfoPropertiesEXT in pProperties::pNext "
|
||||
"chain, but failed to query PciBusInfo from the VirtGpuDevice",
|
||||
__func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user