[Libreoffice-commits] core.git: vcl/inc vcl/skia vcl/source

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 19 11:44:16 UTC 2020


 vcl/inc/driverblocklist.hxx           |   23 +++++++++++++----------
 vcl/inc/skia/utils.hxx                |    8 ++++++++
 vcl/skia/SkiaHelper.cxx               |   18 ++++++++++++------
 vcl/skia/gdiimpl.cxx                  |    7 +++++++
 vcl/source/helper/driverblocklist.cxx |   17 +++++++++++++++++
 5 files changed, 57 insertions(+), 16 deletions(-)

New commits:
commit 1127a8dea95488c7c9add42244a79bb20e7c6d95
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Feb 18 15:55:46 2020 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Wed Feb 19 12:43:42 2020 +0100

    work around a driver/card(?) problem with Skia and AA-ed polygons
    
    See description in SkiaSalGraphicsImpl::drawPolyPolygon().
    
    Change-Id: I4b2626e26cac6d145b417426fc2575845386db57
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88941
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/inc/driverblocklist.hxx b/vcl/inc/driverblocklist.hxx
index 6a0180386a9a..c9b83b3f365e 100644
--- a/vcl/inc/driverblocklist.hxx
+++ b/vcl/inc/driverblocklist.hxx
@@ -23,6 +23,19 @@ VCL_DLLPUBLIC bool IsDeviceBlocked(const OUString& blocklistURL, const OUString&
 VCL_DLLPUBLIC int32_t GetWindowsVersion();
 #endif
 
+enum DeviceVendor
+{
+    VendorAll,
+    VendorIntel,
+    VendorNVIDIA,
+    VendorAMD,
+    VendorMicrosoft,
+};
+const int DeviceVendorMax = VendorMicrosoft + 1;
+
+/// Returns vendor for the given vendor ID, or VendorAll if not known.
+VCL_DLLPUBLIC DeviceVendor GetVendorFromId(uint32_t id);
+
 // The rest should be private (only for the unittest).
 
 struct InvalidFileException
@@ -59,16 +72,6 @@ enum VersionComparisonOp
     DRIVER_COMPARISON_IGNORED
 };
 
-enum DeviceVendor
-{
-    VendorAll,
-    VendorIntel,
-    VendorNVIDIA,
-    VendorAMD,
-    VendorMicrosoft,
-};
-const int DeviceVendorMax = VendorMicrosoft + 1;
-
 struct DriverInfo
 {
     DriverInfo(OperatingSystem os, const OUString& vendor, VersionComparisonOp op,
diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx
index af81ca99f2dd..cd6732a57a44 100644
--- a/vcl/inc/skia/utils.hxx
+++ b/vcl/inc/skia/utils.hxx
@@ -23,6 +23,7 @@
 #include <vcl/skia/SkiaHelper.hxx>
 
 #include <tools/gen.hxx>
+#include <driverblocklist.hxx>
 
 #include <tools/sk_app/VulkanWindowContext.h>
 
@@ -53,6 +54,13 @@ VCL_DLLPUBLIC void dump(const sk_sp<SkImage>& image, const char* file);
 VCL_DLLPUBLIC void dump(const sk_sp<SkSurface>& surface, const char* file);
 #endif
 
+extern uint32_t vendorId;
+
+inline DriverBlocklist::DeviceVendor getVendor()
+{
+    return DriverBlocklist::GetVendorFromId(vendorId);
+}
+
 } // namespace
 
 #endif // INCLUDED_VCL_INC_SKIA_UTILS_H
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index c0972ab2e0a0..50402cccf47c 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -38,6 +38,8 @@ bool isVCLSkiaEnabled() { return false; }
 
 namespace SkiaHelper
 {
+uint32_t vendorId = 0;
+
 static OUString getBlacklistFile()
 {
     OUString url("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER);
@@ -53,19 +55,21 @@ static bool isVulkanBlacklisted(const VkPhysicalDeviceProperties& props)
     OUString driverVersion = OUString::number(props.driverVersion >> 22) + "."
                              + OUString::number((props.driverVersion >> 12) & 0x3ff) + "."
                              + OUString::number(props.driverVersion & 0xfff);
-    OUString vendorId = "0x" + OUString::number(props.vendorID, 16);
-    OUString deviceId = "0x" + OUString::number(props.deviceID, 16);
+    vendorId = props.vendorID;
+    OUString vendorIdStr = "0x" + OUString::number(props.vendorID, 16);
+    OUString deviceIdStr = "0x" + OUString::number(props.deviceID, 16);
     SAL_INFO("vcl.skia",
              "Vulkan API version: "
                  << (props.apiVersion >> 22) << "." << ((props.apiVersion >> 12) & 0x3ff) << "."
                  << (props.apiVersion & 0xfff) << ", driver version: " << driverVersion
-                 << ", vendor: " << vendorId << ", device: " << deviceId << ", type: "
+                 << ", vendor: " << vendorIdStr << ", device: " << deviceIdStr << ", type: "
                  << types[std::min<unsigned>(props.deviceType, SAL_N_ELEMENTS(types) - 1)]
                  << ", name: " << props.deviceName);
-    return DriverBlocklist::IsDeviceBlocked(getBlacklistFile(), driverVersion, vendorId, deviceId);
+    return DriverBlocklist::IsDeviceBlocked(getBlacklistFile(), driverVersion, vendorIdStr,
+                                            deviceIdStr);
 }
 
-static void checkDeviceBlacklisted()
+static void checkDeviceBlacklisted(bool blockDisable = false)
 {
     static bool done = false;
     if (!done)
@@ -86,7 +90,7 @@ static void checkDeviceBlacklisted()
                 }
                 else
                     SAL_INFO("vcl.skia", "Vulkan could not be initialized");
-                if (blacklisted)
+                if (blacklisted && !blockDisable)
                     disableRenderMethod(RenderVulkan);
                 break;
             }
@@ -135,6 +139,8 @@ bool isVCLSkiaEnabled()
     if (bForceSkia)
     {
         bRet = true;
+        // don't actually block if blacklisted, but log it if enabled, and also get the vendor id
+        checkDeviceBlacklisted(true);
     }
     else if (getenv("SAL_FORCEGL"))
     {
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 12265418c617..a704ef9c5312 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -690,6 +690,13 @@ bool SkiaSalGraphicsImpl::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectTo
     if (mXorMode) // limit xor area update
         mXorExtents = aPath.getBounds();
     postDraw();
+#if defined LINUX
+    // WORKAROUND: The logo in the about dialog has drawing errors. This seems to happen
+    // only on Linux (not Windows on the same machine), with both AMDGPU and Mesa,
+    // and only when antialiasing is enabled. Flushing seems to avoid the problem.
+    if (mParent.getAntiAliasB2DDraw() && SkiaHelper::getVendor() == DriverBlocklist::VendorAMD)
+        mSurface->flush();
+#endif
     return true;
 }
 
diff --git a/vcl/source/helper/driverblocklist.cxx b/vcl/source/helper/driverblocklist.cxx
index de1c81992789..1fe134eafed2 100644
--- a/vcl/source/helper/driverblocklist.cxx
+++ b/vcl/source/helper/driverblocklist.cxx
@@ -140,6 +140,23 @@ OUString GetVendorId(DeviceVendor id)
     abort();
 }
 
+DeviceVendor GetVendorFromId(uint32_t id)
+{
+    switch (id)
+    {
+        case 0x8086:
+            return VendorIntel;
+        case 0x10de:
+            return VendorNVIDIA;
+        case 0x1002:
+            return VendorAMD;
+        case 0x1414:
+            return VendorMicrosoft;
+        default:
+            return VendorAll;
+    }
+}
+
 Parser::Parser(const OUString& rURL, std::vector<DriverInfo>& rDriverList)
     : meBlockType(BlockType::UNKNOWN)
     , mrDriverList(rDriverList)


More information about the Libreoffice-commits mailing list