aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-06-22 00:04:37 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-06-22 00:04:37 +0000
commite106d9eeab3c96db145bc5b59188283acdba3df8 (patch)
tree74d29fef3c198b69a99d28192ebe765207e54b9c
parenta21d97f945d430b8b25223a41a38ae616d502829 (diff)
parentdddebf8ef49a61aa18edf37bd60f08753c226ca9 (diff)
downloadqemu-emu-30-release.tar.gz
Merge "Merge cherrypicks of [1742256, 1742257, 1742258, 1742259] into emu-30-release" into emu-30-releaseemu-30-release
-rw-r--r--android/android-emu/android/skin/qt/extended-pages/google-play-page.cpp106
-rw-r--r--android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp6
-rw-r--r--android/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp62
-rw-r--r--android/android-emugl/host/libs/libOpenglRender/FrameBuffer.h9
-rw-r--r--android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.cpp59
-rw-r--r--android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.h4
-rw-r--r--android/android-emugl/host/libs/libOpenglRender/vulkan/VkDecoderGlobalState.cpp123
-rw-r--r--mac.source.properties2
-rw-r--r--source.properties2
-rw-r--r--win.source.properties2
10 files changed, 293 insertions, 82 deletions
diff --git a/android/android-emu/android/skin/qt/extended-pages/google-play-page.cpp b/android/android-emu/android/skin/qt/extended-pages/google-play-page.cpp
index 3c82031438..7e6592d0c7 100644
--- a/android/android-emu/android/skin/qt/extended-pages/google-play-page.cpp
+++ b/android/android-emu/android/skin/qt/extended-pages/google-play-page.cpp
@@ -11,6 +11,8 @@
#include "android/skin/qt/extended-pages/google-play-page.h"
+#include "android/skin/qt/emulator-qt-window.h" // for EmulatorQtWindow
+
#include <qapplication.h> // for QApplication (ptr only), qApp
#include <QApplication> // for QApplication
#include <QObject> // for QObject
@@ -90,19 +92,21 @@ void GooglePlayPage::queryPlayVersions() {
void GooglePlayPage::bootCompletionPropertyDone(
GooglePlayServices::Result result,
StringView outString) {
- if (result == GooglePlayServices::Result::Success && !outString.empty() &&
- outString[0] == '1') {
- // TODO: remove this once we have android properties to wait on.
- mTimer.disconnect();
- QObject::connect(&mTimer, &QTimer::timeout, this,
- &GooglePlayPage::queryPlayVersions);
- mTimer.setSingleShot(false);
- mTimer.setInterval(10000); // 10 sec
- mTimer.start();
- } else {
- // Continue to wait until it is finished booting.
- mTimer.start();
- }
+ EmulatorQtWindow::getInstance()->runOnUiThread([this, result, outString] {
+ if (result == GooglePlayServices::Result::Success && !outString.empty() &&
+ outString[0] == '1') {
+ // TODO: remove this once we have android properties to wait on.
+ mTimer.disconnect();
+ QObject::connect(&mTimer, &QTimer::timeout, this,
+ &GooglePlayPage::queryPlayVersions);
+ mTimer.setSingleShot(false);
+ mTimer.setInterval(10000); // 10 sec
+ mTimer.start();
+ } else {
+ // Continue to wait until it is finished booting.
+ mTimer.start();
+ }
+ });
}
QString GooglePlayPage::getPlayPageDescription(PlayPages page) {
@@ -140,16 +144,18 @@ void GooglePlayPage::showPlayServicesPage() {
void GooglePlayPage::playPageDone(GooglePlayServices::Result result,
PlayPages page) {
- QString msg;
- switch (result) {
- case GooglePlayServices::Result::Success:
- case GooglePlayServices::Result::OperationInProgress:
- return;
- default:
- msg = tr("There was an unknown error while opening %1.")
- .arg(getPlayPageDescription(page));
- }
- showErrorDialog(msg, getPlayPageDescription(page));
+ EmulatorQtWindow::getInstance()->runOnUiThread([this, result, page] {
+ QString msg;
+ switch (result) {
+ case GooglePlayServices::Result::Success:
+ case GooglePlayServices::Result::OperationInProgress:
+ return;
+ default:
+ msg = tr("There was an unknown error while opening %1.")
+ .arg(getPlayPageDescription(page));
+ }
+ showErrorDialog(msg, getPlayPageDescription(page));
+ });
}
void GooglePlayPage::getPlayServicesVersion() {
@@ -163,32 +169,34 @@ void GooglePlayPage::getPlayServicesVersion() {
void GooglePlayPage::playVersionDone(GooglePlayServices::Result result,
PlayApps app,
StringView outString) {
- QString msg;
- QPlainTextEdit* textEdit = nullptr;
-
- switch (app) {
- case PlayApps::PlayServices:
- textEdit = mUi->goog_playServicesVersionBox;
- break;
- default:
- return;
- }
-
- switch (result) {
- case GooglePlayServices::Result::Success:
- textEdit->setPlainText(QString::fromUtf8(outString.data(),
- outString.size()));
- return;
-
- case GooglePlayServices::Result::AppNotInstalled:
- textEdit->setPlainText(tr("Not Installed"));
- break;
- case GooglePlayServices::Result::OperationInProgress:
- textEdit->setPlainText(tr("Loading..."));
- break;
- default:
- textEdit->setPlainText(tr("Unknown Error"));
- }
+ EmulatorQtWindow::getInstance()->runOnUiThread([this, result, app, outString] {
+ QString msg;
+ QPlainTextEdit* textEdit = nullptr;
+
+ switch (app) {
+ case PlayApps::PlayServices:
+ textEdit = mUi->goog_playServicesVersionBox;
+ break;
+ default:
+ return;
+ }
+
+ switch (result) {
+ case GooglePlayServices::Result::Success:
+ textEdit->setPlainText(QString::fromUtf8(outString.data(),
+ outString.size()));
+ return;
+
+ case GooglePlayServices::Result::AppNotInstalled:
+ textEdit->setPlainText(tr("Not Installed"));
+ break;
+ case GooglePlayServices::Result::OperationInProgress:
+ textEdit->setPlainText(tr("Loading..."));
+ break;
+ default:
+ textEdit->setPlainText(tr("Unknown Error"));
+ }
+ });
}
void GooglePlayPage::on_goog_updateServicesButton_clicked() {
diff --git a/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 9ac032b784..09198c9762 100644
--- a/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -4391,11 +4391,17 @@ fprintf(stderr, "%s: begin count %d\n", __func__, count);
// Common between GL_EXT_memory_object and GL_EXT_semaphore
GL_APICALL void GL_APIENTRY glGetUnsignedBytevEXT(GLenum pname, GLubyte* data) {
GET_CTX_V2();
+ if (!ctx->dispatcher().glGetUnsignedBytevEXT) {
+ return;
+ }
ctx->dispatcher().glGetUnsignedBytevEXT(pname, data);
}
GL_APICALL void GL_APIENTRY glGetUnsignedBytei_vEXT(GLenum target, GLuint index, GLubyte* data) {
GET_CTX_V2();
+ if (!ctx->dispatcher().glGetUnsignedBytei_vEXT) {
+ return;
+ }
ctx->dispatcher().glGetUnsignedBytei_vEXT(target, index, data);
}
diff --git a/android/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp b/android/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp
index 4b94c421d1..3283154e93 100644
--- a/android/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp
+++ b/android/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp
@@ -355,15 +355,22 @@ bool FrameBuffer::initialize(int width, int height, bool useSubWindow,
// used by underlying EGL driver might become invalid,
// preventing new contexts from being created that share
// against those contexts.
+ goldfish_vk::VkEmulation* vkEmu = nullptr;
if (emugl::emugl_feature_is_enabled(android::featurecontrol::Vulkan)) {
auto dispatch = emugl::vkDispatch(false /* not for testing */);
- auto emu = goldfish_vk::createOrGetGlobalVkEmulation(dispatch);
+ vkEmu = goldfish_vk::createOrGetGlobalVkEmulation(dispatch);
bool useDeferredCommands =
android::base::System::get()->envGet("ANDROID_EMU_VK_DISABLE_DEFERRED_COMMANDS").empty();
bool useCreateResourcesWithRequirements =
android::base::System::get()->envGet("ANDROID_EMU_VK_DISABLE_USE_CREATE_RESOURCES_WITH_REQUIREMENTS").empty();
- goldfish_vk::setUseDeferredCommands(emu, useDeferredCommands);
- goldfish_vk::setUseCreateResourcesWithRequirements(emu, useCreateResourcesWithRequirements);
+ goldfish_vk::setUseDeferredCommands(vkEmu, useDeferredCommands);
+ goldfish_vk::setUseCreateResourcesWithRequirements(vkEmu, useCreateResourcesWithRequirements);
+ if (vkEmu->deviceInfo.supportsIdProperties) {
+ GL_LOG("Supports id properties, got a vulkan device UUID");
+ memcpy(fb->m_vulkanUUID, vkEmu->deviceInfo.idProps.deviceUUID, 16);
+ } else {
+ GL_LOG("Doesn't support id properties, no vulkan device UUID");
+ }
}
if (s_egl.eglUseOsEglApi)
@@ -622,6 +629,50 @@ bool FrameBuffer::initialize(int width, int height, bool useSubWindow,
fb->m_glRenderer = std::string((const char*)s_gles2.glGetString(GL_RENDERER));
fb->m_glVersion = std::string((const char*)s_gles2.glGetString(GL_VERSION));
+ // Attempt to get the device UUID of the gles and match with Vulkan. If
+ // they match, interop is possible. If they don't, then don't trust the
+ // result of interop query to egl and fall back to CPU copy, as we might
+ // have initialized Vulkan devices and GLES contexts from different
+ // physical devices.
+
+ bool vkglesUuidsGood = true;
+
+ // First, if the VkEmulation instance doesn't support ext memory capabilities,
+ // it won't support uuids.
+ if (!vkEmu || !vkEmu->instanceSupportsExternalMemoryCapabilities) {
+ vkglesUuidsGood = false;
+ }
+
+ s_gles2.glGetError();
+
+ GLint numDeviceUuids = 0;
+ s_gles2.glGetIntegerv(GL_NUM_DEVICE_UUIDS_EXT, &numDeviceUuids);
+
+ // If underlying gles doesn't support UUID query, we definitely don't
+ // support interop and should not proceed further.
+
+ if (!numDeviceUuids) {
+ vkglesUuidsGood = false;
+ }
+
+ // If numDeviceUuids != 1 it's unclear what gles we're using (SLI? Xinerama?)
+ // and we shouldn't try to interop.
+ if (1 != numDeviceUuids) {
+ vkglesUuidsGood = false;
+ }
+
+ if (vkglesUuidsGood && 1 == numDeviceUuids) {
+ s_gles2.glGetUnsignedBytei_vEXT(GL_DEVICE_UUID_EXT, 0, fb->m_glesUUID);
+ if (0 == memcmp(fb->m_vulkanUUID, fb->m_glesUUID, 16)) {
+ GL_LOG("vk/gles UUIDs match");
+ } else {
+ GL_LOG("vk/gles UUIDs don't match");
+ vkglesUuidsGood = false;
+ }
+ }
+
+ s_gles2.glGetError();
+
DBG("GL Vendor %s\n", fb->m_glVendor.c_str());
DBG("GL Renderer %s\n", fb->m_glRenderer.c_str());
DBG("GL Extensions %s\n", fb->m_glVersion.c_str());
@@ -639,6 +690,9 @@ bool FrameBuffer::initialize(int width, int height, bool useSubWindow,
if (s_egl.eglQueryVulkanInteropSupportANDROID) {
fb->m_vulkanInteropSupported =
s_egl.eglQueryVulkanInteropSupportANDROID();
+ if (!vkglesUuidsGood) {
+ fb->m_vulkanInteropSupported = false;
+ }
}
// TODO: 0-copy gl interop on swiftshader vk
@@ -758,6 +812,8 @@ FrameBuffer::FrameBuffer(int p_width, int p_height, bool useSubWindow)
setDisplayPose(displayId, 0, 0, getWidth(), getHeight(), 0);
m_perfThread->start();
+ memset(m_vulkanUUID, 0x0, VK_UUID_SIZE);
+ memset(m_glesUUID, 0x0, GL_UUID_SIZE_EXT);
}
FrameBuffer::~FrameBuffer() {
diff --git a/android/android-emugl/host/libs/libOpenglRender/FrameBuffer.h b/android/android-emugl/host/libs/libOpenglRender/FrameBuffer.h
index 971fa6eefc..af5d9c6159 100644
--- a/android/android-emugl/host/libs/libOpenglRender/FrameBuffer.h
+++ b/android/android-emugl/host/libs/libOpenglRender/FrameBuffer.h
@@ -38,6 +38,9 @@
#include "OpenglRender/Renderer.h"
#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <vulkan/vulkan.h>
#include <functional>
#include <map>
@@ -874,5 +877,11 @@ private:
android::base::MessageChannel<HandleType, 1024>
mOutstandingColorBufferDestroys;
+
+ // UUIDs of physical devices for Vulkan and GLES, respectively. In most
+ // cases, this determines whether we can support zero-copy interop.
+ uint8_t m_vulkanUUID[VK_UUID_SIZE];
+ uint8_t m_glesUUID[GL_UUID_SIZE_EXT];
+ static_assert(VK_UUID_SIZE == GL_UUID_SIZE_EXT);
};
#endif
diff --git a/android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.cpp b/android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.cpp
index 5767865320..54db6365a6 100644
--- a/android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.cpp
+++ b/android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.cpp
@@ -594,6 +594,18 @@ VkEmulation* createOrGetGlobalVkEmulation(VulkanDispatch* vk) {
ivk->vkGetInstanceProcAddr(
sVkEmulation->instance,
"vkGetPhysicalDeviceImageFormatProperties2KHR"));
+ sVkEmulation->getPhysicalDeviceProperties2Func = reinterpret_cast<
+ PFN_vkGetPhysicalDeviceProperties2KHR>(
+ ivk->vkGetInstanceProcAddr(
+ sVkEmulation->instance,
+ "vkGetPhysicalDeviceProperties2KHR"));
+ if (!sVkEmulation->getPhysicalDeviceProperties2Func) {
+ sVkEmulation->getPhysicalDeviceProperties2Func = reinterpret_cast<
+ PFN_vkGetPhysicalDeviceProperties2KHR>(
+ ivk->vkGetInstanceProcAddr(
+ sVkEmulation->instance,
+ "vkGetPhysicalDeviceProperties2"));
+ }
}
if (sVkEmulation->instanceSupportsMoltenVK) {
@@ -651,6 +663,25 @@ VkEmulation* createOrGetGlobalVkEmulation(VulkanDispatch* vk) {
if (sVkEmulation->instanceSupportsExternalMemoryCapabilities) {
deviceInfos[i].supportsExternalMemory = extensionsSupported(
deviceExts, externalMemoryDeviceExtNames);
+ deviceInfos[i].supportsIdProperties =
+ sVkEmulation->getPhysicalDeviceProperties2Func != nullptr;
+ if (!sVkEmulation->getPhysicalDeviceProperties2Func) {
+ fprintf(stderr, "%s: warning: device claims to support ID properties "
+ "but vkGetPhysicalDeviceProperties2 could not be found\n", __func__);
+ }
+ }
+
+ if (deviceInfos[i].supportsIdProperties) {
+ VkPhysicalDeviceIDPropertiesKHR idProps = {
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR, nullptr,
+ };
+ VkPhysicalDeviceProperties2KHR propsWithId = {
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR, &idProps,
+ };
+ sVkEmulation->getPhysicalDeviceProperties2Func(
+ physdevs[i],
+ &propsWithId);
+ deviceInfos[i].idProps = idProps;
}
uint32_t queueFamilyCount = 0;
@@ -715,19 +746,33 @@ VkEmulation* createOrGetGlobalVkEmulation(VulkanDispatch* vk) {
for (uint32_t i = 0; i < physdevCount; ++i) {
uint32_t deviceScore = 0;
- if (deviceInfos[i].hasGraphicsQueueFamily) deviceScore += 100;
- if (deviceInfos[i].supportsExternalMemory) deviceScore += 10;
- if (deviceInfos[i].hasComputeQueueFamily) deviceScore += 1;
+ if (deviceInfos[i].hasGraphicsQueueFamily) deviceScore += 10000;
+ if (deviceInfos[i].supportsExternalMemory) deviceScore += 1000;
+ if (deviceInfos[i].physdevProps.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU ||
+ deviceInfos[i].physdevProps.deviceType == VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) {
+ deviceScore += 100;
+ }
+ if (deviceInfos[i].physdevProps.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) {
+ deviceScore += 50;
+ }
deviceScores[i] = deviceScore;
}
uint32_t maxScoringIndex = 0;
uint32_t maxScore = 0;
- for (uint32_t i = 0; i < physdevCount; ++i) {
- if (deviceScores[i] > maxScore) {
- maxScoringIndex = i;
- maxScore = deviceScores[i];
+ // If we don't support physical devce ID properties,
+ // just pick the first physical device.
+ if (!sVkEmulation->instanceSupportsExternalMemoryCapabilities) {
+ fprintf(stderr, "%s: warning: instance doesn't support "
+ "external memory capabilities, picking first physical device\n", __func__);
+ maxScoringIndex = 0;
+ } else {
+ for (uint32_t i = 0; i < physdevCount; ++i) {
+ if (deviceScores[i] > maxScore) {
+ maxScoringIndex = i;
+ maxScore = deviceScores[i];
+ }
}
}
diff --git a/android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.h b/android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.h
index 4792a47fcb..af90d03db7 100644
--- a/android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.h
+++ b/android/android-emugl/host/libs/libOpenglRender/vulkan/VkCommonOperations.h
@@ -83,6 +83,8 @@ struct VkEmulation {
bool instanceSupportsExternalMemoryCapabilities = false;
PFN_vkGetPhysicalDeviceImageFormatProperties2KHR
getImageFormatProperties2Func = nullptr;
+ PFN_vkGetPhysicalDeviceProperties2KHR
+ getPhysicalDeviceProperties2Func = nullptr;
bool instanceSupportsMoltenVK = false;
PFN_vkSetMTLTextureMVK setMTLTextureFunc = nullptr;
@@ -125,6 +127,7 @@ struct VkEmulation {
bool hasGraphicsQueueFamily = false;
bool hasComputeQueueFamily = false;
bool supportsExternalMemory = false;
+ bool supportsIdProperties = false;
bool glInteropSupported = false;
std::vector<uint32_t> graphicsQueueFamilyIndices;
@@ -132,6 +135,7 @@ struct VkEmulation {
VkPhysicalDeviceProperties physdevProps;
VkPhysicalDeviceMemoryProperties memProps;
+ VkPhysicalDeviceIDPropertiesKHR idProps;
PFN_vkGetImageMemoryRequirements2KHR getImageMemoryRequirements2Func = nullptr;
PFN_vkGetBufferMemoryRequirements2KHR getBufferMemoryRequirements2Func = nullptr;
diff --git a/android/android-emugl/host/libs/libOpenglRender/vulkan/VkDecoderGlobalState.cpp b/android/android-emugl/host/libs/libOpenglRender/vulkan/VkDecoderGlobalState.cpp
index 2758345c7d..b97107469d 100644
--- a/android/android-emugl/host/libs/libOpenglRender/vulkan/VkDecoderGlobalState.cpp
+++ b/android/android-emugl/host/libs/libOpenglRender/vulkan/VkDecoderGlobalState.cpp
@@ -546,56 +546,139 @@ public:
fb->unregisterProcessCleanupCallback(instance);
}
- VkResult on_vkEnumeratePhysicalDevices(
- android::base::BumpPool* pool,
- VkInstance boxed_instance,
- uint32_t* physicalDeviceCount,
- VkPhysicalDevice* physicalDevices) {
-
+ VkResult on_vkEnumeratePhysicalDevices(android::base::BumpPool* pool,
+ VkInstance boxed_instance,
+ uint32_t* physicalDeviceCount,
+ VkPhysicalDevice* physicalDevices) {
auto instance = unbox_VkInstance(boxed_instance);
auto vk = dispatch_VkInstance(boxed_instance);
- auto res = vk->vkEnumeratePhysicalDevices(instance, physicalDeviceCount, physicalDevices);
+ uint32_t physicalDevicesSize = 0;
+ if (physicalDeviceCount) {
+ physicalDevicesSize = *physicalDeviceCount;
+ }
+ uint32_t actualPhysicalDeviceCount;
+ auto res = vk->vkEnumeratePhysicalDevices(
+ instance, &actualPhysicalDeviceCount, nullptr);
+ if (res != VK_SUCCESS) {
+ return res;
+ }
+ std::vector<VkPhysicalDevice> validPhysicalDevices(
+ actualPhysicalDeviceCount);
+ res = vk->vkEnumeratePhysicalDevices(
+ instance, &actualPhysicalDeviceCount, validPhysicalDevices.data());
if (res != VK_SUCCESS) return res;
AutoLock lock(mLock);
+ if (m_emu->instanceSupportsExternalMemoryCapabilities) {
+ PFN_vkGetPhysicalDeviceProperties2KHR getPhysdevProps2Func =
+ (PFN_vkGetPhysicalDeviceProperties2KHR)(vk->vkGetInstanceProcAddr(
+ instance, "vkGetPhysicalDeviceProperties2KHR"));
+
+ if (!getPhysdevProps2Func) {
+ getPhysdevProps2Func =
+ (PFN_vkGetPhysicalDeviceProperties2KHR)(vk->vkGetInstanceProcAddr(
+ instance, "vkGetPhysicalDeviceProperties2"));
+ }
+
+ if (!getPhysdevProps2Func) {
+ PFN_vkGetPhysicalDeviceProperties2KHR khrFunc =
+ vk->vkGetPhysicalDeviceProperties2KHR;
+ PFN_vkGetPhysicalDeviceProperties2KHR coreFunc =
+ vk->vkGetPhysicalDeviceProperties2;
+
+ if (coreFunc) getPhysdevProps2Func = coreFunc;
+ if (!getPhysdevProps2Func && khrFunc)
+ getPhysdevProps2Func = khrFunc;
+ }
+
+ if (getPhysdevProps2Func) {
+ validPhysicalDevices.erase(std::remove_if(
+ validPhysicalDevices.begin(), validPhysicalDevices.end(),
+ [getPhysdevProps2Func,
+ this](VkPhysicalDevice physicalDevice) {
+ // We can get the device UUID.
+ VkPhysicalDeviceIDPropertiesKHR idProps = {
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR,
+ nullptr,
+ };
+ VkPhysicalDeviceProperties2KHR propsWithId = {
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR,
+ &idProps,
+ };
+ getPhysdevProps2Func(physicalDevice, &propsWithId);
+
+ // Remove those devices whose UUIDs don't match the one
+ // in VkCommonOperations.
+ return memcmp(m_emu->deviceInfo.idProps.deviceUUID,
+ idProps.deviceUUID, VK_UUID_SIZE) != 0;
+ }), validPhysicalDevices.end());
+ } else {
+ fprintf(stderr,
+ "%s: warning: failed to "
+ "vkGetPhysicalDeviceProperties2KHR\n",
+ __func__);
+ }
+ } else {
+ // If we don't support ID properties then just advertise only the
+ // first physical device.
+ fprintf(stderr,
+ "%s: device id properties not supported, using first "
+ "physical device\n",
+ __func__);
+ }
+ if (!validPhysicalDevices.empty()) {
+ validPhysicalDevices.erase(std::next(validPhysicalDevices.begin()),
+ validPhysicalDevices.end());
+ }
+
+ if (physicalDeviceCount) {
+ *physicalDeviceCount = validPhysicalDevices.size();
+ }
+
+ auto emu = getGlobalVkEmulation();
+
if (physicalDeviceCount && physicalDevices) {
// Box them up
- for (uint32_t i = 0; i < *physicalDeviceCount; ++i) {
- mPhysicalDeviceToInstance[physicalDevices[i]] = instance;
-
- auto& physdevInfo = mPhysdevInfo[physicalDevices[i]];
+ for (uint32_t i = 0;
+ i < std::min(*physicalDeviceCount, physicalDevicesSize); ++i) {
+ mPhysicalDeviceToInstance[validPhysicalDevices[i]] = instance;
+ auto& physdevInfo = mPhysdevInfo[validPhysicalDevices[i]];
- physdevInfo.boxed =
- new_boxed_VkPhysicalDevice(physicalDevices[i], vk, false /* does not own dispatch */);
+ physdevInfo.boxed = new_boxed_VkPhysicalDevice(
+ validPhysicalDevices[i], vk,
+ false /* does not own dispatch */);
- vk->vkGetPhysicalDeviceProperties(physicalDevices[i],
- &physdevInfo.props);
+ vk->vkGetPhysicalDeviceProperties(validPhysicalDevices[i],
+ &physdevInfo.props);
if (physdevInfo.props.apiVersion > kMaxSafeVersion) {
physdevInfo.props.apiVersion = kMaxSafeVersion;
}
vk->vkGetPhysicalDeviceMemoryProperties(
- physicalDevices[i], &physdevInfo.memoryProperties);
+ validPhysicalDevices[i], &physdevInfo.memoryProperties);
uint32_t queueFamilyPropCount = 0;
vk->vkGetPhysicalDeviceQueueFamilyProperties(
- physicalDevices[i], &queueFamilyPropCount, nullptr);
+ validPhysicalDevices[i], &queueFamilyPropCount, nullptr);
physdevInfo.queueFamilyProperties.resize(
- (size_t)queueFamilyPropCount);
+ (size_t)queueFamilyPropCount);
vk->vkGetPhysicalDeviceQueueFamilyProperties(
- physicalDevices[i], &queueFamilyPropCount,
- physdevInfo.queueFamilyProperties.data());
+ validPhysicalDevices[i], &queueFamilyPropCount,
+ physdevInfo.queueFamilyProperties.data());
physicalDevices[i] = (VkPhysicalDevice)physdevInfo.boxed;
}
+ if (physicalDevicesSize < *physicalDeviceCount) {
+ res = VK_INCOMPLETE;
+ }
}
return res;
diff --git a/mac.source.properties b/mac.source.properties
index aec4fd945a..808753b764 100644
--- a/mac.source.properties
+++ b/mac.source.properties
@@ -1,5 +1,5 @@
Pkg.UserSrc=false
-Pkg.Revision=30.7.4
+Pkg.Revision=30.7.5
Pkg.Path=emulator
Pkg.Desc=Android Emulator
diff --git a/source.properties b/source.properties
index a611361a23..a45a87acd9 100644
--- a/source.properties
+++ b/source.properties
@@ -1,4 +1,4 @@
Pkg.UserSrc=false
-Pkg.Revision=30.7.4
+Pkg.Revision=30.7.5
Pkg.Path=emulator
Pkg.Desc=Android Emulator
diff --git a/win.source.properties b/win.source.properties
index a611361a23..a45a87acd9 100644
--- a/win.source.properties
+++ b/win.source.properties
@@ -1,4 +1,4 @@
Pkg.UserSrc=false
-Pkg.Revision=30.7.4
+Pkg.Revision=30.7.5
Pkg.Path=emulator
Pkg.Desc=Android Emulator