add support for Lima, V3D, VC4 (based on https://github.com/OpenMandrivaAssociation/kwin/blob/master/kwin-5.21.4-add-support-for-panfrost-driver.patch made by Bernhard Rosenkraenzer) and update list of supported devices for Panfrost

This commit is contained in:
Tomasz Paweł Gajc 2022-12-02 19:45:29 +01:00 committed by Tomasz Gajc
parent c2fb99d126
commit 88cf83554f
8 changed files with 217 additions and 12 deletions

View file

@ -0,0 +1,17 @@
[Driver]
Vendor=Broadcom VideoCore 3D
Renderer=V3D 4.2
Version=2.1 Mesa 19.1
[Settings]
LooseBinding=true
GLSL=false
TextureNPOT=false
Mesa=true
V3D=true
GLVersion=2,1
MesaVersion=19,1
DriverVersion=19,1
Driver=21
ChipClass=7000
Compositor=4

View file

@ -0,0 +1,17 @@
[Driver]
Vendor=Broadcom VideoCore IV
Renderer=VC4 V3D 2.1
Version=2.1 Mesa 19.1
[Settings]
LooseBinding=true
GLSL=false
TextureNPOT=false
Mesa=true
VC4=true
GLVersion=2,1
MesaVersion=19,1
DriverVersion=19,1
Driver=20
ChipClass=6000
Compositor=4

View file

@ -0,0 +1,19 @@
[Driver]
Vendor=Mali (Lima)
Renderer=Mali 400 (Lima)
Version=3.0 Mesa 19.1
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=false
TextureNPOT=true
Mesa=true
Lima=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=19,1
DriverVersion=19,1
Driver=19
ChipClass=5000
Compositor=1

View file

@ -69,6 +69,9 @@ void GLPlatformTest::testDriverToString_data()
QTest::newRow("Qualcomm") << Driver_Qualcomm << QStringLiteral("Qualcomm");
QTest::newRow("Virgl") << Driver_Virgl << QStringLiteral("Virgl (virtio-gpu, Qemu/KVM guest)");
QTest::newRow("Panfrost") << Driver_Panfrost << QStringLiteral("Panfrost");
QTest::newRow("Lima") << Driver_Lima << QStringLiteral("Mali (Lima)");
QTest::newRow("VC4") << Driver_VC4 << QStringLiteral("VideoCore IV");
QTest::newRow("V3D") << Driver_V3D << QStringLiteral("VideoCore 3D");
QTest::newRow("Unknown") << Driver_Unknown << QStringLiteral("Unknown");
}
@ -121,7 +124,15 @@ void GLPlatformTest::testChipClassToString_data()
QTest::newRow("MaliT7XX") << MaliT7XX << QStringLiteral("Mali T7xx series");
QTest::newRow("MaliT8XX") << MaliT8XX << QStringLiteral("Mali T8xx series");
QTest::newRow("MaliGXX") << MaliGXX << QStringLiteral("Mali Gxx series");
QTest::newRow("UnknownPanfrost") << UnknownAdreno << QStringLiteral("Unknown");
QTest::newRow("UnknownPanfrost") << UnknownPanfrost << QStringLiteral("Unknown");
QTest::newRow("Mali400") << Mali400 << QStringLiteral("Mali 400 series");
QTest::newRow("Mali450") << Mali450 << QStringLiteral("Mali 450 series");
QTest::newRow("Mali470") << Mali470 << QStringLiteral("Mali 470 series");
QTest::newRow("UnknownLima") << UnknownLima << QStringLiteral("Unknown");
QTest::newRow("VC4_2_1") << VC4_2_1 << QStringLiteral("VideoCore IV");
QTest::newRow("UnknownVideoCore4") << UnknownVideoCore4 << QStringLiteral("Unknown");
QTest::newRow("V3D_4_2") << V3D_4_2 << QStringLiteral("VideoCore 3D");
QTest::newRow("UnknownVideoCore3D") << UnknownVideoCore3D << QStringLiteral("Unknown");
QTest::newRow("UnknownChipClass") << UnknownChipClass << QStringLiteral("Unknown");
}
@ -158,6 +169,10 @@ void GLPlatformTest::testPriorDetect()
QCOMPARE(gl->isNvidia(), false);
QCOMPARE(gl->isIntel(), false);
QCOMPARE(gl->isPanfrost(), false);
QCOMPARE(gl->isLima(), false);
QCOMPARE(gl->isVideoCore4(), false);
QCOMPARE(gl->isVideoCore3D(), false);
QCOMPARE(gl->isVirtualBox(), false);
QCOMPARE(gl->isVMware(), false);
@ -259,6 +274,9 @@ void GLPlatformTest::testDetect()
QCOMPARE(gl->isVMware(), settingsGroup.readEntry("VMware", false));
QCOMPARE(gl->isAdreno(), settingsGroup.readEntry("Adreno", false));
QCOMPARE(gl->isPanfrost(), settingsGroup.readEntry("Panfrost", false));
QCOMPARE(gl->isLima(), settingsGroup.readEntry("Lima", false));
QCOMPARE(gl->isVideoCore4(), settingsGroup.readEntry("VC4", false));
QCOMPARE(gl->isVideoCore3D(), settingsGroup.readEntry("V3D", false));
QCOMPARE(gl->isVirgl(), settingsGroup.readEntry("Virgl", false));
QCOMPARE(gl->isSoftwareEmulation(), settingsGroup.readEntry("SoftwareEmulation", false));

View file

@ -265,6 +265,9 @@ bool ContrastEffect::enabledByDefault()
if (gl->isPanfrost() && gl->chipClass() <= MaliT8XX) {
return false;
}
if (gl->isLima() || gl->isVideoCore4() || gl->isVideoCore3D()) {
return false;
}
if (gl->isSoftwareEmulation()) {
return false;
}

View file

@ -395,6 +395,10 @@ bool BlurEffect::enabledByDefault()
if (gl->isPanfrost() && gl->chipClass() <= MaliT8XX) {
return false;
}
// The blur effect works, but is painfully slow (FPS < 5) on Mali and VideoCore
if (gl->isLima() || gl->isVideoCore4() || gl->isVideoCore3D()) {
return false;
}
if (gl->isSoftwareEmulation()) {
return false;
}

View file

@ -520,17 +520,13 @@ static ChipClass detectQualcommClass(const QByteArray &chipClass)
if (ok) {
if (value >= 100 && value < 200) {
return Adreno1XX;
}
if (value >= 200 && value < 300) {
} else if (value >= 200 && value < 300) {
return Adreno2XX;
}
if (value >= 300 && value < 400) {
} else if (value >= 300 && value < 400) {
return Adreno3XX;
}
if (value >= 400 && value < 500) {
} else if (value >= 400 && value < 500) {
return Adreno4XX;
}
if (value >= 500 && value < 600) {
} else if (value >= 500 && value < 600) {
return Adreno5XX;
}
}
@ -539,22 +535,53 @@ static ChipClass detectQualcommClass(const QByteArray &chipClass)
static ChipClass detectPanfrostClass(const QByteArray &chipClass)
{
// Keep the list of supported Mali chipset up to date with https://docs.mesa3d.org/drivers/panfrost.html
if (chipClass.contains("T720") || chipClass.contains("T760")) {
return MaliT7XX;
}
if (chipClass.contains("T820") || chipClass.contains("T860")) {
if (chipClass.contains("T820") || chipClass.contains("T830") || chipClass.contains("T860") || chipClass.contains("T880")) {
return MaliT8XX;
}
if (chipClass.contains("G31") || chipClass.contains("G52") || chipClass.contains("G72")) {
if (chipClass.contains("G31") || chipClass.contains("G51") || chipClass.contains("G52") || chipClass.contains("G57") || chipClass.contains("G72") || chipClass.contains("G76")) {
return MaliGXX;
}
return UnknownPanfrost;
}
static ChipClass detectLimaClass(const QByteArray &chipClass)
{
if (chipClass.contains("400")) {
return Mali400;
} else if (chipClass.contains("450")) {
return Mali450;
} else if (chipClass.contains("470")) {
return Mali470;
}
return UnknownLima;
}
static ChipClass detectVC4Class(const QByteArray &chipClass)
{
if (chipClass.contains("2.1")) {
return VC4_2_1;
}
return UnknownVideoCore4;
}
static ChipClass detectV3DClass(const QByteArray &chipClass)
{
if (chipClass.contains("4.2")) {
return V3D_4_2;
}
return UnknownVideoCore3D;
}
QString GLPlatform::versionToString(qint64 version)
{
return QString::fromLatin1(versionToString8(version));
@ -618,6 +645,12 @@ QByteArray GLPlatform::driverToString8(Driver driver)
return QByteArrayLiteral("Virgl (virtio-gpu, Qemu/KVM guest)");
case Driver_Panfrost:
return QByteArrayLiteral("Panfrost");
case Driver_Lima:
return QByteArrayLiteral("Mali (Lima)");
case Driver_VC4:
return QByteArrayLiteral("VideoCore IV");
case Driver_V3D:
return QByteArrayLiteral("VideoCore 3D");
default:
return QByteArrayLiteral("Unknown");
@ -725,6 +758,13 @@ QByteArray GLPlatform::chipClassToString8(ChipClass chipClass)
case Adreno5XX:
return QByteArrayLiteral("Adreno 5xx series");
case Mali400:
return QByteArrayLiteral("Mali 400 series");
case Mali450:
return QByteArrayLiteral("Mali 450 series");
case Mali470:
return QByteArrayLiteral("Mali 470 series");
case MaliT7XX:
return QByteArrayLiteral("Mali T7xx series");
case MaliT8XX:
@ -732,6 +772,11 @@ QByteArray GLPlatform::chipClassToString8(ChipClass chipClass)
case MaliGXX:
return QByteArrayLiteral("Mali Gxx series");
case VC4_2_1:
return QByteArrayLiteral("VideoCore IV");
case V3D_4_2:
return QByteArrayLiteral("VideoCore 3D");
default:
return QByteArrayLiteral("Unknown");
}
@ -921,6 +966,21 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
m_chipClass = detectPanfrostClass(m_renderer);
}
else if (m_renderer.contains("Mali")) {
m_driver = Driver_Lima;
m_chipClass = detectLimaClass(m_renderer);
}
else if (m_renderer.startsWith("VC4 ")) {
m_driver = Driver_VC4;
m_chipClass = detectVC4Class(m_renderer);
}
else if(m_renderer.startsWith("V3D ")) {
m_driver = Driver_V3D;
m_chipClass = detectV3DClass(m_renderer);
}
else if (m_renderer == "Software Rasterizer") {
m_driver = Driver_Swrast;
}
@ -1076,6 +1136,22 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
m_recommendedCompositor = OpenGLCompositing;
}
if (isLima()) {
m_recommendedCompositor = OpenGLCompositing;
// GLSL works but causes dramatic FPS drop on this GPU
m_supportsGLSL = false;
}
if (isVideoCore4()) {
// OpenGL works, but is much slower than QPainter
m_recommendedCompositor = QPainterCompositing;
}
if (isVideoCore3D()) {
// OpenGL works, but is much slower than QPainter
m_recommendedCompositor = QPainterCompositing;
}
if (isMesaDriver() && platformInterface == EglPlatformInterface) {
// According to the reference implementation in
// mesa/demos/src/egl/opengles1/texture_from_pixmap
@ -1310,6 +1386,21 @@ bool GLPlatform::isPanfrost() const
return m_chipClass >= MaliT7XX && m_chipClass <= UnknownPanfrost;
}
bool GLPlatform::isLima() const
{
return m_chipClass >= Mali400 && m_chipClass <= UnknownLima;
}
bool GLPlatform::isVideoCore4() const
{
return m_chipClass >= VC4_2_1 && m_chipClass <= UnknownVideoCore4;
}
bool GLPlatform::isVideoCore3D() const
{
return m_chipClass >= V3D_4_2 && m_chipClass <= UnknownVideoCore3D;
}
const QByteArray &GLPlatform::glRendererString() const
{
return m_renderer;

View file

@ -99,6 +99,9 @@ enum Driver {
Driver_RadeonSI,
Driver_Virgl,
Driver_Panfrost,
Driver_Lima,
Driver_VC4,
Driver_V3D,
Driver_Unknown,
};
@ -169,6 +172,21 @@ enum ChipClass {
MaliGXX, // GLES3.0
UnknownPanfrost = 4999,
// Lima Mali
// from https://docs.mesa3d.org/drivers/lima.html
Mali400 = 5000,
Mali450,
Mali470,
UnknownLima = 5999,
// Broadcom VideoCore IV (e.g. Raspberry Pi 0 to 3), GLES 2.0/2.1 with caveats
VC4_2_1 = 6000, // Found in Raspberry Pi 3B+
UnknownVideoCore4 = 6999,
// Broadcom VideoCore 3D (e.g. Raspberry Pi 4, Raspberry Pi 400)
V3D_4_2 = 7000, // Found in Raspberry Pi 400
UnknownVideoCore3D = 7999,
UnknownChipClass = 99999,
};
// clang-format on
@ -319,6 +337,24 @@ public:
**/
bool isPanfrost() const;
/**
* @returns @c true if the GPU is a Mali GPU supported by the Lima driver (Mali 400, 450)
* @since 5.27.1
**/
bool isLima() const;
/**
* @returns @c true if the GPU is a Broadcom VideoCore IV (e.g. Raspberry Pi 0 to 3)
* @since 5.27.1
**/
bool isVideoCore4() const;
/**
* @returns @c true if the GPU is a Broadcom VideoCore 3D (e.g. Raspberry Pi 4, 400)
* @since 5.27.1
**/
bool isVideoCore3D() const;
/**
* @returns the GL_VERSION string as provided by the driver.
* @since 4.9