[3/n] Add VulkanQueueSubmitWithCommands feature to guest
Bug: 177241396
+ Also make sure rcEncoder() is active for each Vulkan thread. It looks
like we don't always ensure that, which allows leaking of render threads
on host after guest process shutdown, since the host needs the process
id info for each guest thread.
Change-Id: I121be5fc144699493a96f034bd2de697f1770a6d
diff --git a/system/OpenglSystemCommon/Android.mk b/system/OpenglSystemCommon/Android.mk
index b4c5eae..c53e1ea 100644
--- a/system/OpenglSystemCommon/Android.mk
+++ b/system/OpenglSystemCommon/Android.mk
@@ -17,6 +17,7 @@
HostConnection.cpp \
QemuPipeStream.cpp \
ProcessPipe.cpp \
+ ThreadInfo.cpp \
ifeq (true,$(GFXSTREAM))
$(call emugl-import,libvulkan_enc)
@@ -29,9 +30,6 @@
ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
-LOCAL_SRC_FILES += \
- ThreadInfo_host.cpp \
-
else
ifeq (true,$(GFXSTREAM))
@@ -48,9 +46,6 @@
endif
-LOCAL_SRC_FILES += \
- ThreadInfo.cpp \
-
endif
ifdef IS_AT_LEAST_OPD1
diff --git a/system/OpenglSystemCommon/CMakeLists.txt b/system/OpenglSystemCommon/CMakeLists.txt
index 3786200..f02eacb 100644
--- a/system/OpenglSystemCommon/CMakeLists.txt
+++ b/system/OpenglSystemCommon/CMakeLists.txt
@@ -1,9 +1,9 @@
# This is an autogenerated file! Do not edit!
# instead run make from .../device/generic/goldfish-opengl
# which will re-generate this file.
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/Android.mk" "1beb394a90c7b8fe0bcd0087fc7e4f8b0990f6dcc02ba43264cd13d070823b06")
-set(OpenglSystemCommon_src FormatConversions.cpp HostConnection.cpp QemuPipeStream.cpp ProcessPipe.cpp AddressSpaceStream.cpp ThreadInfo_host.cpp)
-android_add_library(TARGET OpenglSystemCommon SHARED LICENSE Apache-2.0 SRC FormatConversions.cpp HostConnection.cpp QemuPipeStream.cpp ProcessPipe.cpp AddressSpaceStream.cpp ThreadInfo_host.cpp)
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/Android.mk" "b9cff4065e53bf36a805c6d9d035083efc2c03dd3216982ff5b63094fb99c7f6")
+set(OpenglSystemCommon_src FormatConversions.cpp HostConnection.cpp QemuPipeStream.cpp ProcessPipe.cpp ThreadInfo.cpp AddressSpaceStream.cpp)
+android_add_library(TARGET OpenglSystemCommon SHARED LICENSE Apache-2.0 SRC FormatConversions.cpp HostConnection.cpp QemuPipeStream.cpp ProcessPipe.cpp ThreadInfo.cpp AddressSpaceStream.cpp)
target_include_directories(OpenglSystemCommon PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
target_compile_definitions(OpenglSystemCommon PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGFXSTREAM")
target_compile_options(OpenglSystemCommon PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-unused-variable" "-fno-emulated-tls")
diff --git a/system/OpenglSystemCommon/EmulatorFeatureInfo.h b/system/OpenglSystemCommon/EmulatorFeatureInfo.h
index c47966e..70161a2 100644
--- a/system/OpenglSystemCommon/EmulatorFeatureInfo.h
+++ b/system/OpenglSystemCommon/EmulatorFeatureInfo.h
@@ -123,6 +123,9 @@
// Make current async
static const char kAsyncFrameCommands[] = "ANDROID_EMU_async_frame_commands";
+// Queue submit with commands
+static const char kVulkanQueueSubmitWithCommands[] = "ANDROID_EMU_vulkan_queue_submit_with_commands";
+
// Struct describing available emulator features
struct EmulatorFeatureInfo {
@@ -146,7 +149,8 @@
hasVulkanShaderFloat16Int8(false),
hasVulkanAsyncQueueSubmit(false),
hasHostSideTracing(false),
- hasAsyncFrameCommands(false)
+ hasAsyncFrameCommands(false),
+ hasVulkanQueueSubmitWithCommands(false)
{ }
SyncImpl syncImpl;
@@ -169,6 +173,7 @@
bool hasVulkanAsyncQueueSubmit;
bool hasHostSideTracing;
bool hasAsyncFrameCommands;
+ bool hasVulkanQueueSubmitWithCommands;
};
enum HostConnectionType {
diff --git a/system/OpenglSystemCommon/HostConnection.cpp b/system/OpenglSystemCommon/HostConnection.cpp
index 0e5b6c7..c1dcb9b 100644
--- a/system/OpenglSystemCommon/HostConnection.cpp
+++ b/system/OpenglSystemCommon/HostConnection.cpp
@@ -634,6 +634,7 @@
VkEncoder *HostConnection::vkEncoder()
{
+ rcEncoder();
if (!m_vkEnc) {
m_vkEnc = new VkEncoder(m_stream);
}
@@ -669,6 +670,7 @@
queryAndSetVulkanAsyncQueueSubmitSupport(rcEnc);
queryAndSetHostSideTracingSupport(rcEnc);
queryAndSetAsyncFrameCommands(rcEnc);
+ queryAndSetVulkanQueueSubmitWithCommandsSupport(rcEnc);
if (m_processPipe) {
m_processPipe->processPipeInit(m_connectionType, rcEnc);
}
@@ -945,3 +947,11 @@
rcEnc->featureInfo()->hasAsyncFrameCommands = true;
}
}
+
+void HostConnection::queryAndSetVulkanQueueSubmitWithCommandsSupport(ExtendedRCEncoderContext* rcEnc) {
+ std::string glExtensions = queryGLExtensions(rcEnc);
+ if (glExtensions.find(kVulkanQueueSubmitWithCommands) != std::string::npos) {
+ rcEnc->featureInfo()->hasVulkanQueueSubmitWithCommands = true;
+ }
+}
+
diff --git a/system/OpenglSystemCommon/HostConnection.h b/system/OpenglSystemCommon/HostConnection.h
index 9d0ad8e..2f81963 100644
--- a/system/OpenglSystemCommon/HostConnection.h
+++ b/system/OpenglSystemCommon/HostConnection.h
@@ -237,6 +237,7 @@
void queryAndSetVulkanAsyncQueueSubmitSupport(ExtendedRCEncoderContext *rcEnc);
void queryAndSetHostSideTracingSupport(ExtendedRCEncoderContext *rcEnc);
void queryAndSetAsyncFrameCommands(ExtendedRCEncoderContext *rcEnc);
+ void queryAndSetVulkanQueueSubmitWithCommandsSupport(ExtendedRCEncoderContext *rcEnc);
private:
HostConnectionType m_connectionType;
diff --git a/system/OpenglSystemCommon/ThreadInfo.cpp b/system/OpenglSystemCommon/ThreadInfo.cpp
index 6096352..5f7372f 100644
--- a/system/OpenglSystemCommon/ThreadInfo.cpp
+++ b/system/OpenglSystemCommon/ThreadInfo.cpp
@@ -15,11 +15,16 @@
*/
#include "ThreadInfo.h"
+
+#ifdef HOST_BUILD
+#include "android/base/threads/AndroidThread.h"
+#else
#include "cutils/threads.h"
+#endif
#include <pthread.h>
-#ifdef GFXSTREAM
+#if defined(HOST_BUILD) || defined(GFXSTREAM)
static thread_local EGLThreadInfo sEglThreadInfoThreadLocal;
@@ -33,7 +38,11 @@
}
int32_t getCurrentThreadId() {
+#ifdef HOST_BUILD
+ return (int32_t)android::base::guest::getCurrentThreadId();
+#else
return (int32_t)gettid();
+#endif
}
void setTlsDestructor(tlsDtorCallback func) {