From c562276bd9b9b7664b588a4f6eafc2f0e24ca19b Mon Sep 17 00:00:00 2001 From: Xinyue Date: Thu, 21 Dec 2023 17:31:13 +0800 Subject: [PATCH] avoid checking Vulkan version with a separate hgi instance --- pxr/imaging/hgi/hgi.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pxr/imaging/hgi/hgi.cpp b/pxr/imaging/hgi/hgi.cpp index 46e2e056b3..b309ae423a 100644 --- a/pxr/imaging/hgi/hgi.cpp +++ b/pxr/imaging/hgi/hgi.cpp @@ -112,7 +112,14 @@ _MakeNewPlatformDefaultHgi() return nullptr; } +#ifdef __ANDROID__ + if (instance->IsBackendSupported()) + return instance; + else + return nullptr; +#else return instance; +#endif } static Hgi* @@ -173,7 +180,14 @@ _MakeHgiOfChoice(const TfToken& type) return nullptr; } +#ifdef __ANDROID__ + if (instance->IsBackendSupported()) + return instance; + else + return nullptr; +#else return instance; +#endif } Hgi* @@ -200,6 +214,11 @@ Hgi::CreateHgiOfChoice(const TfToken& token) bool Hgi::IsSupported() { +#ifdef __ANDROID__ + // Generating a separate instance only for checking supports makes trouble for Android. + // Android does the check at the first time the instance is generated. + return true; +#endif if (HgiUniquePtr const instance = CreatePlatformDefaultHgi()) { return instance->IsBackendSupported(); }