gfxstream: gfxstreamCapset --> vulkanCapset

We couple everything as one giant gfxstream capset, and also have
a renderControl path for versioning.

Long term, it makes sense to nuke renderControl path (which controls
many legacy GLES bits) and rely on a virtgpu-style versioning scheme
[each context type gets it's one capset].

Some capability sets are experimental.  For example, GFXSTREAM_COMPOSER.
However, Fuchsia for example does rip out parts of HostConnection
and use in it's display controller.  Probably have a cross-platform
API that performs that functions would a long-term clean solution.

Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
Gurchetan Singh
2023-09-08 15:05:12 -07:00
committed by Marge Bot
parent a5c7ce4dda
commit a4ff4b058d
5 changed files with 28 additions and 32 deletions
@@ -59,8 +59,8 @@ AddressSpaceStream* createVirtioGpuAddressSpaceStream(HealthMonitor<>* healthMon
blobCreate.blobId = 0;
blobCreate.blobMem = kBlobMemHost3d;
blobCreate.flags = kBlobFlagMappable;
blobCreate.size = ALIGN(caps.gfxstreamCapset.ringSize + caps.gfxstreamCapset.bufferSize,
caps.gfxstreamCapset.blobAlignment);
blobCreate.size = ALIGN(caps.vulkanCapset.ringSize + caps.vulkanCapset.bufferSize,
caps.vulkanCapset.blobAlignment);
blob = instance->createBlob(blobCreate);
if (!blob)
return nullptr;
@@ -89,7 +89,7 @@ AddressSpaceStream* createVirtioGpuAddressSpaceStream(HealthMonitor<>* healthMon
bufferPtr = blobAddr + sizeof(struct asg_ring_storage);
struct asg_context context =
asg_context_create(blobAddr, bufferPtr, caps.gfxstreamCapset.bufferSize);
asg_context_create(blobAddr, bufferPtr, caps.vulkanCapset.bufferSize);
context.ring_config->transfer_mode = 1;
context.ring_config->host_consumed_pos = 0;
@@ -107,4 +107,4 @@ AddressSpaceStream* createVirtioGpuAddressSpaceStream(HealthMonitor<>* healthMon
res->setMapping(blobMapping);
res->setResourceId(contextCreate.resourceId);
return res;
}
}
@@ -106,7 +106,7 @@ struct VirtGpuCreateBlob {
struct VirtGpuCaps {
uint64_t params[kParamMax];
struct gfxstreamCapset gfxstreamCapset;
struct vulkanCapset vulkanCapset;
};
class VirtGpuBlobMapping;
@@ -76,7 +76,7 @@ struct gfxstreamPlaceholderCommandVk {
uint32_t padding;
};
struct gfxstreamCapset {
struct vulkanCapset {
uint32_t protocolVersion;
// ASG Ring Parameters
@@ -80,8 +80,8 @@ LinuxVirtGpuDevice::LinuxVirtGpuDevice(enum VirtGpuCapset capset, int fd) {
get_caps.cap_set_id = static_cast<uint32_t>(capset);
if (capset == kCapsetGfxStreamVulkan) {
get_caps.size = sizeof(struct gfxstreamCapset);
get_caps.addr = (unsigned long long)&mCaps.gfxstreamCapset;
get_caps.size = sizeof(struct vulkanCapset);
get_caps.addr = (unsigned long long)&mCaps.vulkanCapset;
}
ret = drmIoctl(mDeviceHandle, DRM_IOCTL_VIRTGPU_GET_CAPS, &get_caps);
@@ -92,8 +92,8 @@ LinuxVirtGpuDevice::LinuxVirtGpuDevice(enum VirtGpuCapset capset, int fd) {
}
// We always need an ASG blob in some cases, so always define blobAlignment
if (!mCaps.gfxstreamCapset.blobAlignment) {
mCaps.gfxstreamCapset.blobAlignment = 4096;
if (!mCaps.vulkanCapset.blobAlignment) {
mCaps.vulkanCapset.blobAlignment = 4096;
}
ctx_set_params[0].param = VIRTGPU_CONTEXT_PARAM_NUM_RINGS;
@@ -924,8 +924,8 @@ public:
mCaps = instance->getCaps();
// Delete once goldfish Linux drivers are gone
if (mCaps.gfxstreamCapset.protocolVersion == 0) {
mCaps.gfxstreamCapset.colorBufferMemoryIndex = 0xFFFFFFFF;
if (mCaps.vulkanCapset.protocolVersion == 0) {
mCaps.vulkanCapset.colorBufferMemoryIndex = 0xFFFFFFFF;
}
}
@@ -1722,13 +1722,12 @@ public:
ResourceTracker::threadingCallbacks.hostConnectionGetFunc()->grallocHelper();
// Delete once goldfish Linux drivers are gone
if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
mCaps.gfxstreamCapset.colorBufferMemoryIndex =
getColorBufferMemoryIndex(context, device);
if (mCaps.vulkanCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
mCaps.vulkanCapset.colorBufferMemoryIndex = getColorBufferMemoryIndex(context, device);
}
updateMemoryTypeBits(&pProperties->memoryTypeBits,
mCaps.gfxstreamCapset.colorBufferMemoryIndex);
mCaps.vulkanCapset.colorBufferMemoryIndex);
return getAndroidHardwareBufferPropertiesANDROID(
grallocHelper, buffer, pProperties);
@@ -3057,15 +3056,15 @@ public:
bool dedicated = deviceAddressMemoryAllocation;
if (mCaps.gfxstreamCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle])
if (mCaps.vulkanCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle])
dedicated = true;
VkMemoryAllocateInfo hostAllocationInfo = vk_make_orphan_copy(*pAllocateInfo);
vk_struct_chain_iterator structChainIter = vk_make_chain_iterator(&hostAllocationInfo);
if (mCaps.gfxstreamCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle]) {
if (mCaps.vulkanCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle]) {
hostAllocationInfo.allocationSize =
ALIGN(pAllocateInfo->allocationSize, mCaps.gfxstreamCapset.blobAlignment);
ALIGN(pAllocateInfo->allocationSize, mCaps.vulkanCapset.blobAlignment);
} else if (dedicated) {
// Over-aligning to kLargestSize to some Windows drivers (b:152769369). Can likely
// have host report the desired alignment.
@@ -3125,7 +3124,7 @@ public:
}
guestBlob->wait();
} else if (mCaps.gfxstreamCapset.deferredMapping) {
} else if (mCaps.vulkanCapset.deferredMapping) {
createBlobInfo.blobId = ++mBlobId;
createBlobInfo.blobMem = kBlobMemHost3d;
vk_append_struct(&structChainIter, &createBlobInfo);
@@ -3141,7 +3140,7 @@ public:
}
struct VkDeviceMemory_Info info;
if (mCaps.gfxstreamCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle]) {
if (mCaps.vulkanCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle]) {
info.allocationSize = pAllocateInfo->allocationSize;
info.blobId = createBlobInfo.blobId;
}
@@ -3173,7 +3172,7 @@ public:
info_VkDeviceMemory[mem] = info;
}
if (mCaps.gfxstreamCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle]) {
if (mCaps.vulkanCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle]) {
*pMemory = mem;
return host_res;
}
@@ -3210,7 +3209,7 @@ public:
((allocFlagsInfoPtr->flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) ||
(allocFlagsInfoPtr->flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT));
if (mCaps.gfxstreamCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle])
if (mCaps.vulkanCapset.deferredMapping || mCaps.params[kParamCreateGuestHandle])
dedicated = true;
CoherentMemoryPtr coherentMemory = nullptr;
@@ -4323,15 +4322,14 @@ public:
// Delete `protocolVersion` check goldfish drivers are gone.
#ifdef VK_USE_PLATFORM_ANDROID_KHR
if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
mCaps.gfxstreamCapset.colorBufferMemoryIndex =
getColorBufferMemoryIndex(context, device);
if (mCaps.vulkanCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
mCaps.vulkanCapset.colorBufferMemoryIndex = getColorBufferMemoryIndex(context, device);
}
if (extImgCiPtr &&
(extImgCiPtr->handleTypes &
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)) {
updateMemoryTypeBits(&memReqs.memoryTypeBits,
mCaps.gfxstreamCapset.colorBufferMemoryIndex);
mCaps.vulkanCapset.colorBufferMemoryIndex);
}
#endif
@@ -5380,17 +5378,15 @@ public:
if (res != VK_SUCCESS) return res;
// Delete `protocolVersion` check goldfish drivers are gone.
#ifdef VK_USE_PLATFORM_ANDROID_KHR
if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
mCaps.gfxstreamCapset.colorBufferMemoryIndex =
getColorBufferMemoryIndex(context, device);
if (mCaps.vulkanCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
mCaps.vulkanCapset.colorBufferMemoryIndex = getColorBufferMemoryIndex(context, device);
}
if (extBufCiPtr &&
(extBufCiPtr->handleTypes &
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)) {
updateMemoryTypeBits(&memReqs.memoryTypeBits,
mCaps.gfxstreamCapset.colorBufferMemoryIndex);
mCaps.vulkanCapset.colorBufferMemoryIndex);
}
#endif