Skip to content

Commit ee40174

Browse files
jmacnakrmuthiah
authored andcommitted
Enable multi queue emulation when needed for hwui on skiavk
HWUI's vulkan setup requires 2 queues which may not always be supported by the hosts vulkan driver. Gfxstream has a mode to emulate this support. This change updates the launcher to try to detect when this is needed and enable the feature if so. Bug: b/537569893 Test: bazel run //cuttlefish/package:cvd -- create
1 parent c761459 commit ee40174

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

base/cvd/cuttlefish/host/commands/assemble_cvd/graphics_flags.cc

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,28 @@ std::string GetGfxstreamRendererFeaturesString(
731731
return absl::StrJoin(parts, ",");
732732
}
733733

734+
CF_UNUSED_ON_MACOS
735+
bool HasMultipleGraphicsQueues(
736+
const gfxstream::proto::GraphicsAvailability& availability) {
737+
if (!availability.has_vulkan()) {
738+
return false;
739+
}
740+
const gfxstream::proto::VulkanAvailability& vulkan_availability =
741+
availability.vulkan();
742+
if (vulkan_availability.physical_devices().empty()) {
743+
return false;
744+
}
745+
const auto& physical_device = vulkan_availability.physical_devices(0);
746+
for (const auto& queue_family : physical_device.queue_families()) {
747+
if (!queue_family.has_supports_graphics()) continue;
748+
if (!queue_family.supports_graphics()) continue;
749+
750+
// HWUI seems to only check the first queue family supporting graphics:
751+
return queue_family.has_queue_count() && queue_family.queue_count() >= 2;
752+
}
753+
return false;
754+
}
755+
734756
CF_UNUSED_ON_MACOS
735757
Result<void> SetGfxstreamFlags(
736758
const GpuMode gpu_mode, const GuestHwuiRenderer hwui_renderer,
@@ -758,11 +780,21 @@ Result<void> SetGfxstreamFlags(
758780
features["GlProgramBinaryLinkStatus"] = true;
759781
}
760782

761-
// SwiftShader currently only supports a single queue. SkiaVK requests
762-
// a second queue used for transfers.
763-
if (gpu_mode == GpuMode::GfxstreamGuestAngleHostSwiftshader &&
764-
hwui_renderer == GuestHwuiRenderer::kSkiaVk) {
765-
features["VulkanVirtualQueue"] = true;
783+
if (hwui_renderer == GuestHwuiRenderer::kSkiaVk) {
784+
// SkiaVK requires a second graphics queue for AHB transfers.
785+
const bool needs_multi_queue_emulation =
786+
(gpu_mode == GpuMode::GfxstreamGuestAngleHostSwiftshader)
787+
?
788+
// The SwiftShader driver packaged with the Cuttlefish host tools
789+
// does not appear in `availability` and does not have multiple
790+
// queues.
791+
true
792+
: !HasMultipleGraphicsQueues(availability);
793+
;
794+
795+
if (needs_multi_queue_emulation) {
796+
features["VulkanVirtualQueue"] = true;
797+
}
766798
}
767799

768800
// Apply feature overrides from --gpu_renderer_features.

0 commit comments

Comments
 (0)