// // Copyright 2020 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //
[[maybe_unused]] const std::string WrapICDEnvironment(constchar *icdEnvironment)
{ // The libraries are bundled into the module directory
std::string ret = ConcatenatePath(angle::GetModuleDirectory(), icdEnvironment); return ret;
}
// If we're loading the validation layers, we could be running from any random directory. // Change to the executable directory so we can find the layers, then change back to the // previous directory to be safe we don't disrupt the application.
ScopedVkLoaderEnvironment::ScopedVkLoaderEnvironment(bool enableValidationLayers, vk::ICD icd)
: mEnableValidationLayers(enableValidationLayers),
mICD(icd),
mChangedCWD(false),
mChangedICDEnv(false),
mChangedNoDeviceSelect(false)
{ // Changing CWD and setting environment variables makes no sense on Android, // since this code is a part of Java application there. // Android Vulkan loader doesn't need this either. #if !defined(ANGLE_PLATFORM_ANDROID) && !defined(ANGLE_PLATFORM_GGP) if (icd == vk::ICD::Mock)
{ if (!setICDEnvironment(WrapICDEnvironment(ANGLE_VK_MOCK_ICD_JSON).c_str()))
{
ERR() << "Error setting environment for Mock/Null Driver.";
}
} # ifdefined(ANGLE_VK_SWIFTSHADER_ICD_JSON) elseif (icd == vk::ICD::SwiftShader)
{ if (!setICDEnvironment(WrapICDEnvironment(ANGLE_VK_SWIFTSHADER_ICD_JSON).c_str()))
{
ERR() << "Error setting environment for SwiftShader.";
}
} # endif // defined(ANGLE_VK_SWIFTSHADER_ICD_JSON)
if (mChangedNoDeviceSelect)
{
ResetEnvironmentVar(kNoDeviceSelect, mPreviousNoDeviceSelectEnv);
}
}
bool ScopedVkLoaderEnvironment::setICDEnvironment(constchar *icd)
{ // Override environment variable to use built Mock ICD // ANGLE_VK_ICD_JSON gets set to the built mock ICD in BUILD.gn
mPreviousICDEnv = angle::GetEnvironmentVar(kLoaderICDFilenamesEnv);
mChangedICDEnv = angle::SetEnvironmentVar(kLoaderICDFilenamesEnv, icd);
if (!mChangedICDEnv)
{
mICD = vk::ICD::Default;
} return mChangedICDEnv;
}
for (const VkPhysicalDevice &physicalDevice : physicalDevices)
{
pGetPhysicalDeviceProperties(physicalDevice, physicalDevicePropertiesOut); if (filter(*physicalDevicePropertiesOut))
{
*physicalDeviceOut = physicalDevice; return;
}
if (shouldChooseByID)
{ // NOTE: If the system has multiple GPUs with the same vendor and // device IDs, this will arbitrarily select one of them. bool matchVendorID = true; bool matchDeviceID = true;
Optional<VkPhysicalDevice> integratedDevice;
VkPhysicalDeviceProperties integratedDeviceProperties; for (const VkPhysicalDevice &physicalDevice : physicalDevices)
{
pGetPhysicalDeviceProperties(physicalDevice, physicalDevicePropertiesOut); // If discrete GPU exists, uses it by default. if (physicalDevicePropertiesOut->deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
{
*physicalDeviceOut = physicalDevice; return;
} if (physicalDevicePropertiesOut->deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU &&
!integratedDevice.valid())
{
integratedDevice = physicalDevice;
integratedDeviceProperties = *physicalDevicePropertiesOut; continue;
}
}
// If only integrated GPU exists, use it by default. if (integratedDevice.valid())
{
*physicalDeviceOut = integratedDevice.value();
*physicalDevicePropertiesOut = integratedDeviceProperties; return;
}
WARN() << "Preferred device ICD not found. Using default physicalDevice instead."; // Fallback to the first device.
*physicalDeviceOut = physicalDevices[0];
pGetPhysicalDeviceProperties(*physicalDeviceOut, physicalDevicePropertiesOut);
}
} // namespace vk
} // namespace angle
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.