summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-04-09 15:47:34 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-04-10 21:15:33 +0200
commite3f5e49ac3aff3db9491b57e001579729f21bd56 (patch)
tree7a2134ccba8a6ff37b52550c37ab82fcfc93aaa3
parentad65fa305cc73ae0bbed44e140c11ad5638ce440 (diff)
dump info about Skia and Vulkan drivers to a log file
Apparently it's hard for users to find out the actual Vulkan driver version (as compared to the marketing version), which is needed for blacklisting. And raster performance is noticeably better if Skia is compiled using Clang. So just dump the info to <cachedir>/skia.log (where on Windows the <cachedir> should be AppData\Roaming\LibreOffice\4\cache). Change-Id: Iafbc32637579b831275c60554f064479a326b917 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91980 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--vcl/inc/driverblocklist.hxx2
-rw-r--r--vcl/skia/SkiaHelper.cxx103
-rw-r--r--vcl/source/helper/driverblocklist.cxx17
3 files changed, 109 insertions, 13 deletions
diff --git a/vcl/inc/driverblocklist.hxx b/vcl/inc/driverblocklist.hxx
index c9b83b3f365e..8c1747be472f 100644
--- a/vcl/inc/driverblocklist.hxx
+++ b/vcl/inc/driverblocklist.hxx
@@ -36,6 +36,8 @@ const int DeviceVendorMax = VendorMicrosoft + 1;
/// Returns vendor for the given vendor ID, or VendorAll if not known.
VCL_DLLPUBLIC DeviceVendor GetVendorFromId(uint32_t id);
+VCL_DLLPUBLIC OUStringLiteral GetVendorNameFromId(uint32_t id);
+
// The rest should be private (only for the unittest).
struct InvalidFileException
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 356570706f59..f0d2559d376f 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -29,6 +29,8 @@ bool isVCLSkiaEnabled() { return false; }
#include <driverblocklist.hxx>
#include <skia/utils.hxx>
#include <config_folders.h>
+#include <osl/file.hxx>
+#include <tools/stream.hxx>
#include <SkCanvas.h>
#include <SkPaint.h>
@@ -40,8 +42,6 @@ bool isVCLSkiaEnabled() { return false; }
namespace SkiaHelper
{
-uint32_t vendorId = 0;
-
static OUString getBlacklistFile()
{
OUString url("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER);
@@ -50,25 +50,98 @@ static OUString getBlacklistFile()
return url + "/skia/skia_blacklist_vulkan.xml";
}
+static uint32_t driverVersion = 0;
+uint32_t vendorId = 0;
+
+static OUString versionAsString(uint32_t version)
+{
+ return OUString::number(version >> 22) + "." + OUString::number((version >> 12) & 0x3ff) + "."
+ + OUString::number(version & 0xfff);
+}
+
+static OUStringLiteral vendorAsString(uint32_t vendor)
+{
+ return DriverBlocklist::GetVendorNameFromId(vendor);
+}
+
+static OUString getCacheFolder()
+{
+ OUString url("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
+ "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/cache/");
+ rtl::Bootstrap::expandMacros(url);
+ osl::Directory::create(url);
+ return url;
+}
+
+static void writeToLog(SvStream& stream, const char* key, const char* value)
+{
+ stream.WriteCharPtr(key);
+ stream.WriteCharPtr(": ");
+ stream.WriteCharPtr(value);
+ stream.WriteChar('\n');
+}
+
+static void writeToLog(SvStream& stream, const char* key, const OUString& value)
+{
+ writeToLog(stream, key, OUStringToOString(value, RTL_TEXTENCODING_UTF8).getStr());
+}
+
+// Note that this function also logs system information about Vulkan.
static bool isVulkanBlacklisted(const VkPhysicalDeviceProperties& props)
{
static const char* const types[]
= { "other", "integrated", "discrete", "virtual", "cpu", "??" }; // VkPhysicalDeviceType
- OUString driverVersion = OUString::number(props.driverVersion >> 22) + "."
- + OUString::number((props.driverVersion >> 12) & 0x3ff) + "."
- + OUString::number(props.driverVersion & 0xfff);
+ driverVersion = props.driverVersion;
vendorId = props.vendorID;
OUString vendorIdStr = "0x" + OUString::number(props.vendorID, 16);
OUString deviceIdStr = "0x" + OUString::number(props.deviceID, 16);
+ OUString driverVersionString = versionAsString(driverVersion);
+ OUString apiVersion = versionAsString(props.apiVersion);
+ const char* deviceType = types[std::min<unsigned>(props.deviceType, SAL_N_ELEMENTS(types) - 1)];
+
+ CrashReporter::addKeyValue("VulkanVendor", vendorIdStr, CrashReporter::AddItem);
+ CrashReporter::addKeyValue("VulkanDevice", deviceIdStr, CrashReporter::AddItem);
+ CrashReporter::addKeyValue("VulkanAPI", apiVersion, CrashReporter::AddItem);
+ CrashReporter::addKeyValue("VulkanDriver", driverVersionString, CrashReporter::AddItem);
+ CrashReporter::addKeyValue("VulkanDeviceType", OUString::createFromAscii(deviceType),
+ CrashReporter::AddItem);
+ CrashReporter::addKeyValue("VulkanDeviceName", OUString::createFromAscii(props.deviceName),
+ CrashReporter::Write);
+
+ SvFileStream logFile(getCacheFolder() + "/skia.log", StreamMode::WRITE);
+ writeToLog(logFile, "RenderMethod", "vulkan");
+ writeToLog(logFile, "Vendor", vendorIdStr);
+ writeToLog(logFile, "Device", deviceIdStr);
+ writeToLog(logFile, "API", apiVersion);
+ writeToLog(logFile, "Driver", driverVersionString);
+ writeToLog(logFile, "DeviceType", deviceType);
+ writeToLog(logFile, "DeviceName", props.deviceName);
+
SAL_INFO("vcl.skia",
- "Vulkan API version: "
- << (props.apiVersion >> 22) << "." << ((props.apiVersion >> 12) & 0x3ff) << "."
- << (props.apiVersion & 0xfff) << ", driver version: " << driverVersion
- << ", vendor: " << vendorIdStr << ", device: " << deviceIdStr << ", type: "
- << types[std::min<unsigned>(props.deviceType, SAL_N_ELEMENTS(types) - 1)]
- << ", name: " << props.deviceName);
- return DriverBlocklist::IsDeviceBlocked(getBlacklistFile(), driverVersion, vendorIdStr,
- deviceIdStr);
+ "Vulkan API version: " << apiVersion << ", driver version: " << driverVersionString
+ << ", vendor: " << vendorIdStr << " ("
+ << vendorAsString(vendorId) << "), device: " << deviceIdStr
+ << ", type: " << deviceType << ", name: " << props.deviceName);
+ bool blacklisted = DriverBlocklist::IsDeviceBlocked(getBlacklistFile(), driverVersionString,
+ vendorIdStr, deviceIdStr);
+ writeToLog(logFile, "Blacklisted", blacklisted ? "yes" : "no");
+ return blacklisted;
+}
+
+static void writeSkiaRasterInfo()
+{
+ SvFileStream logFile(getCacheFolder() + "/skia.log", StreamMode::WRITE);
+ writeToLog(logFile, "RenderMethod", "raster");
+ // Log compiler, Skia works best when compiled with Clang.
+#if defined __clang__
+ writeToLog(logFile, "Compiler", "Clang");
+#elif defined __GNUC__
+ writeToLog(logFile, "Compiler", "GCC");
+#elif defined _MSC_VER
+ writeToLog(logFile, "Compiler", "MSVC");
+#else
+ writeToLog(logFile, "Compiler", "?");
+#endif
}
static sk_app::VulkanWindowContext::SharedGrContext getTemporaryGrContext();
@@ -109,11 +182,15 @@ static void checkDeviceBlacklisted(bool blockDisable = false)
else
SAL_INFO("vcl.skia", "Vulkan could not be initialized");
if (blacklisted && !blockDisable)
+ {
disableRenderMethod(RenderVulkan);
+ writeSkiaRasterInfo();
+ }
break;
}
case RenderRaster:
SAL_INFO("vcl.skia", "Using Skia raster mode");
+ writeSkiaRasterInfo();
return; // software, never blacklisted
}
done = true;
diff --git a/vcl/source/helper/driverblocklist.cxx b/vcl/source/helper/driverblocklist.cxx
index 1fe134eafed2..556eb7172fed 100644
--- a/vcl/source/helper/driverblocklist.cxx
+++ b/vcl/source/helper/driverblocklist.cxx
@@ -157,6 +157,23 @@ DeviceVendor GetVendorFromId(uint32_t id)
}
}
+OUStringLiteral GetVendorNameFromId(uint32_t id)
+{
+ switch (id)
+ {
+ case 0x8086:
+ return "Intel";
+ case 0x10de:
+ return "Nvidia";
+ case 0x1002:
+ return "AMD";
+ case 0x1414:
+ return "Microsoft";
+ default:
+ return "?";
+ }
+}
+
Parser::Parser(const OUString& rURL, std::vector<DriverInfo>& rDriverList)
: meBlockType(BlockType::UNKNOWN)
, mrDriverList(rDriverList)