File indexing completed on 2024-11-10 04:56:23

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "opengl/abstract_opengl_context_attribute_builder.h"
0010 #include "opengl/egl_context_attribute_builder.h"
0011 #include <QTest>
0012 #include <epoxy/egl.h>
0013 
0014 #include "config-kwin.h"
0015 #if HAVE_GLX
0016 #include "../src/backends/x11/standalone/x11_standalone_glx_context_attribute_builder.h"
0017 #include <epoxy/glx.h>
0018 
0019 #ifndef GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV
0020 #define GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7
0021 #endif
0022 #endif
0023 
0024 using namespace KWin;
0025 
0026 class OpenGLContextAttributeBuilderTest : public QObject
0027 {
0028     Q_OBJECT
0029 private Q_SLOTS:
0030     void testCtor();
0031     void testRobust();
0032     void testForwardCompatible();
0033     void testProfile();
0034     void testResetOnVideoMemoryPurge();
0035     void testVersionMajor();
0036     void testVersionMajorAndMinor();
0037     void testHighPriority();
0038     void testEgl_data();
0039     void testEgl();
0040     void testGles_data();
0041     void testGles();
0042     void testGlx_data();
0043     void testGlx();
0044 };
0045 
0046 class MockOpenGLContextAttributeBuilder : public AbstractOpenGLContextAttributeBuilder
0047 {
0048 public:
0049     std::vector<int> build() const override;
0050 };
0051 
0052 std::vector<int> MockOpenGLContextAttributeBuilder::build() const
0053 {
0054     return std::vector<int>();
0055 }
0056 
0057 void OpenGLContextAttributeBuilderTest::testCtor()
0058 {
0059     MockOpenGLContextAttributeBuilder builder;
0060     QCOMPARE(builder.isVersionRequested(), false);
0061     QCOMPARE(builder.majorVersion(), 0);
0062     QCOMPARE(builder.minorVersion(), 0);
0063     QCOMPARE(builder.isRobust(), false);
0064     QCOMPARE(builder.isForwardCompatible(), false);
0065     QCOMPARE(builder.isCoreProfile(), false);
0066     QCOMPARE(builder.isCompatibilityProfile(), false);
0067     QCOMPARE(builder.isResetOnVideoMemoryPurge(), false);
0068     QCOMPARE(builder.isHighPriority(), false);
0069 }
0070 
0071 void OpenGLContextAttributeBuilderTest::testRobust()
0072 {
0073     MockOpenGLContextAttributeBuilder builder;
0074     QCOMPARE(builder.isRobust(), false);
0075     builder.setRobust(true);
0076     QCOMPARE(builder.isRobust(), true);
0077     builder.setRobust(false);
0078     QCOMPARE(builder.isRobust(), false);
0079 }
0080 
0081 void OpenGLContextAttributeBuilderTest::testForwardCompatible()
0082 {
0083     MockOpenGLContextAttributeBuilder builder;
0084     QCOMPARE(builder.isForwardCompatible(), false);
0085     builder.setForwardCompatible(true);
0086     QCOMPARE(builder.isForwardCompatible(), true);
0087     builder.setForwardCompatible(false);
0088     QCOMPARE(builder.isForwardCompatible(), false);
0089 }
0090 
0091 void OpenGLContextAttributeBuilderTest::testProfile()
0092 {
0093     MockOpenGLContextAttributeBuilder builder;
0094     QCOMPARE(builder.isCoreProfile(), false);
0095     QCOMPARE(builder.isCompatibilityProfile(), false);
0096     builder.setCoreProfile(true);
0097     QCOMPARE(builder.isCoreProfile(), true);
0098     QCOMPARE(builder.isCompatibilityProfile(), false);
0099     builder.setCompatibilityProfile(true);
0100     QCOMPARE(builder.isCoreProfile(), false);
0101     QCOMPARE(builder.isCompatibilityProfile(), true);
0102     builder.setCoreProfile(true);
0103     QCOMPARE(builder.isCoreProfile(), true);
0104     QCOMPARE(builder.isCompatibilityProfile(), false);
0105 }
0106 
0107 void OpenGLContextAttributeBuilderTest::testResetOnVideoMemoryPurge()
0108 {
0109     MockOpenGLContextAttributeBuilder builder;
0110     QCOMPARE(builder.isResetOnVideoMemoryPurge(), false);
0111     builder.setResetOnVideoMemoryPurge(true);
0112     QCOMPARE(builder.isResetOnVideoMemoryPurge(), true);
0113     builder.setResetOnVideoMemoryPurge(false);
0114     QCOMPARE(builder.isResetOnVideoMemoryPurge(), false);
0115 }
0116 
0117 void OpenGLContextAttributeBuilderTest::testHighPriority()
0118 {
0119     MockOpenGLContextAttributeBuilder builder;
0120     QCOMPARE(builder.isHighPriority(), false);
0121     builder.setHighPriority(true);
0122     QCOMPARE(builder.isHighPriority(), true);
0123     builder.setHighPriority(false);
0124     QCOMPARE(builder.isHighPriority(), false);
0125 }
0126 
0127 void OpenGLContextAttributeBuilderTest::testVersionMajor()
0128 {
0129     MockOpenGLContextAttributeBuilder builder;
0130     builder.setVersion(2);
0131     QCOMPARE(builder.isVersionRequested(), true);
0132     QCOMPARE(builder.majorVersion(), 2);
0133     QCOMPARE(builder.minorVersion(), 0);
0134     builder.setVersion(3);
0135     QCOMPARE(builder.isVersionRequested(), true);
0136     QCOMPARE(builder.majorVersion(), 3);
0137     QCOMPARE(builder.minorVersion(), 0);
0138 }
0139 
0140 void OpenGLContextAttributeBuilderTest::testVersionMajorAndMinor()
0141 {
0142     MockOpenGLContextAttributeBuilder builder;
0143     builder.setVersion(2, 1);
0144     QCOMPARE(builder.isVersionRequested(), true);
0145     QCOMPARE(builder.majorVersion(), 2);
0146     QCOMPARE(builder.minorVersion(), 1);
0147     builder.setVersion(3, 2);
0148     QCOMPARE(builder.isVersionRequested(), true);
0149     QCOMPARE(builder.majorVersion(), 3);
0150     QCOMPARE(builder.minorVersion(), 2);
0151 }
0152 
0153 void OpenGLContextAttributeBuilderTest::testEgl_data()
0154 {
0155     QTest::addColumn<bool>("requestVersion");
0156     QTest::addColumn<int>("major");
0157     QTest::addColumn<int>("minor");
0158     QTest::addColumn<bool>("robust");
0159     QTest::addColumn<bool>("forwardCompatible");
0160     QTest::addColumn<bool>("coreProfile");
0161     QTest::addColumn<bool>("compatibilityProfile");
0162     QTest::addColumn<bool>("highPriority");
0163     QTest::addColumn<std::vector<int>>("expectedAttribs");
0164 
0165     QTest::newRow("fallback") << false << 0 << 0 << false << false << false << false << false << std::vector<int>{EGL_NONE};
0166     QTest::newRow("legacy/robust")
0167         << false << 0 << 0 << true << false << false << false << false
0168         << std::vector<int>{
0169                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0170                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
0171                EGL_NONE};
0172     QTest::newRow("legacy/robust/high priority")
0173         << false << 0 << 0 << true << false << false << false << true
0174         << std::vector<int>{
0175                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0176                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
0177                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0178                EGL_NONE};
0179     QTest::newRow("core")
0180         << true << 3 << 1 << false << false << false << false << false
0181         << std::vector<int>{
0182                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0183                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
0184                EGL_NONE};
0185     QTest::newRow("core/high priority")
0186         << true << 3 << 1 << false << false << false << false << true
0187         << std::vector<int>{
0188                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0189                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
0190                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0191                EGL_NONE};
0192     QTest::newRow("core/robust")
0193         << true << 3 << 1 << true << false << false << false << false
0194         << std::vector<int>{
0195                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0196                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
0197                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0198                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
0199                EGL_NONE};
0200     QTest::newRow("core/robust/high priority")
0201         << true << 3 << 1 << true << false << false << false << true
0202         << std::vector<int>{
0203                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0204                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
0205                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0206                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
0207                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0208                EGL_NONE};
0209     QTest::newRow("core/robust/forward compatible")
0210         << true << 3 << 1 << true << true << false << false << false
0211         << std::vector<int>{
0212                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0213                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
0214                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0215                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0216                EGL_NONE};
0217     QTest::newRow("core/robust/forward compatible/high priority")
0218         << true << 3 << 1 << true << true << false << false << true
0219         << std::vector<int>{
0220                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0221                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
0222                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0223                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0224                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0225                EGL_NONE};
0226     QTest::newRow("core/forward compatible")
0227         << true << 3 << 1 << false << true << false << false << false
0228         << std::vector<int>{
0229                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0230                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
0231                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0232                EGL_NONE};
0233     QTest::newRow("core/forward compatible/high priority")
0234         << true << 3 << 1 << false << true << false << false << true
0235         << std::vector<int>{
0236                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0237                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
0238                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0239                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0240                EGL_NONE};
0241     QTest::newRow("core profile/forward compatible")
0242         << true << 3 << 2 << false << true << true << false << false
0243         << std::vector<int>{
0244                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0245                EGL_CONTEXT_MINOR_VERSION_KHR, 2,
0246                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0247                EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
0248                EGL_NONE};
0249     QTest::newRow("core profile/forward compatible/high priority")
0250         << true << 3 << 2 << false << true << true << false << true
0251         << std::vector<int>{
0252                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0253                EGL_CONTEXT_MINOR_VERSION_KHR, 2,
0254                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0255                EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
0256                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0257                EGL_NONE};
0258     QTest::newRow("compatibility profile/forward compatible")
0259         << true << 3 << 2 << false << true << false << true << false
0260         << std::vector<int>{
0261                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0262                EGL_CONTEXT_MINOR_VERSION_KHR, 2,
0263                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0264                EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
0265                EGL_NONE};
0266     QTest::newRow("compatibility profile/forward compatible/high priority")
0267         << true << 3 << 2 << false << true << false << true << true
0268         << std::vector<int>{
0269                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0270                EGL_CONTEXT_MINOR_VERSION_KHR, 2,
0271                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0272                EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
0273                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0274                EGL_NONE};
0275     QTest::newRow("core profile/robust/forward compatible")
0276         << true << 3 << 2 << true << true << true << false << false
0277         << std::vector<int>{
0278                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0279                EGL_CONTEXT_MINOR_VERSION_KHR, 2,
0280                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0281                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0282                EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
0283                EGL_NONE};
0284     QTest::newRow("core profile/robust/forward compatible/high priority")
0285         << true << 3 << 2 << true << true << true << false << true
0286         << std::vector<int>{
0287                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0288                EGL_CONTEXT_MINOR_VERSION_KHR, 2,
0289                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0290                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0291                EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
0292                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0293                EGL_NONE};
0294     QTest::newRow("compatibility profile/robust/forward compatible")
0295         << true << 3 << 2 << true << true << false << true << false
0296         << std::vector<int>{
0297                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0298                EGL_CONTEXT_MINOR_VERSION_KHR, 2,
0299                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0300                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0301                EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
0302                EGL_NONE};
0303     QTest::newRow("compatibility profile/robust/forward compatible/high priority")
0304         << true << 3 << 2 << true << true << false << true << true
0305         << std::vector<int>{
0306                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
0307                EGL_CONTEXT_MINOR_VERSION_KHR, 2,
0308                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
0309                EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
0310                EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
0311                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0312                EGL_NONE};
0313 }
0314 
0315 void OpenGLContextAttributeBuilderTest::testEgl()
0316 {
0317     QFETCH(bool, requestVersion);
0318     QFETCH(int, major);
0319     QFETCH(int, minor);
0320     QFETCH(bool, robust);
0321     QFETCH(bool, forwardCompatible);
0322     QFETCH(bool, coreProfile);
0323     QFETCH(bool, compatibilityProfile);
0324     QFETCH(bool, highPriority);
0325 
0326     EglContextAttributeBuilder builder;
0327     if (requestVersion) {
0328         builder.setVersion(major, minor);
0329     }
0330     builder.setRobust(robust);
0331     builder.setForwardCompatible(forwardCompatible);
0332     builder.setCoreProfile(coreProfile);
0333     builder.setCompatibilityProfile(compatibilityProfile);
0334     builder.setHighPriority(highPriority);
0335 
0336     auto attribs = builder.build();
0337     QTEST(attribs, "expectedAttribs");
0338 }
0339 
0340 void OpenGLContextAttributeBuilderTest::testGles_data()
0341 {
0342     QTest::addColumn<bool>("robust");
0343     QTest::addColumn<bool>("highPriority");
0344     QTest::addColumn<std::vector<int>>("expectedAttribs");
0345 
0346     QTest::newRow("robust")
0347         << true << false
0348         << std::vector<int>{
0349                EGL_CONTEXT_CLIENT_VERSION, 2,
0350                EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE,
0351                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT,
0352                EGL_NONE};
0353     QTest::newRow("robust/high priority")
0354         << true << true
0355         << std::vector<int>{
0356                EGL_CONTEXT_CLIENT_VERSION, 2,
0357                EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE,
0358                EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT,
0359                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0360                EGL_NONE};
0361     QTest::newRow("normal")
0362         << false << false
0363         << std::vector<int>{
0364                EGL_CONTEXT_CLIENT_VERSION, 2,
0365                EGL_NONE};
0366     QTest::newRow("normal/high priority")
0367         << false << true
0368         << std::vector<int>{
0369                EGL_CONTEXT_CLIENT_VERSION, 2,
0370                EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
0371                EGL_NONE};
0372 }
0373 
0374 void OpenGLContextAttributeBuilderTest::testGles()
0375 {
0376     QFETCH(bool, robust);
0377     QFETCH(bool, highPriority);
0378 
0379     EglOpenGLESContextAttributeBuilder builder;
0380     builder.setVersion(2);
0381     builder.setRobust(robust);
0382     builder.setHighPriority(highPriority);
0383 
0384     auto attribs = builder.build();
0385     QTEST(attribs, "expectedAttribs");
0386 }
0387 
0388 void OpenGLContextAttributeBuilderTest::testGlx_data()
0389 {
0390 #if HAVE_GLX
0391     QTest::addColumn<bool>("requestVersion");
0392     QTest::addColumn<int>("major");
0393     QTest::addColumn<int>("minor");
0394     QTest::addColumn<bool>("robust");
0395     QTest::addColumn<bool>("videoPurge");
0396     QTest::addColumn<std::vector<int>>("expectedAttribs");
0397 
0398     QTest::newRow("fallback")
0399         << true << 2 << 1 << false << false
0400         << std::vector<int>{
0401                GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
0402                GLX_CONTEXT_MINOR_VERSION_ARB, 1,
0403                0};
0404     QTest::newRow("legacy/robust")
0405         << false << 0 << 0 << true << false
0406         << std::vector<int>{
0407                GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
0408                GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
0409                0};
0410     QTest::newRow("legacy/robust/videoPurge")
0411         << false << 0 << 0 << true << true
0412         << std::vector<int>{
0413                GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
0414                GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
0415                GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE,
0416                0};
0417     QTest::newRow("core")
0418         << true << 3 << 1 << false << false
0419         << std::vector<int>{
0420                GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
0421                GLX_CONTEXT_MINOR_VERSION_ARB, 1,
0422                0};
0423     QTest::newRow("core/robust")
0424         << true << 3 << 1 << true << false
0425         << std::vector<int>{
0426                GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
0427                GLX_CONTEXT_MINOR_VERSION_ARB, 1,
0428                GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
0429                GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
0430                0};
0431     QTest::newRow("core/robust/videoPurge")
0432         << true << 3 << 1 << true << true
0433         << std::vector<int>{
0434                GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
0435                GLX_CONTEXT_MINOR_VERSION_ARB, 1,
0436                GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
0437                GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
0438                GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE,
0439                0};
0440 #endif
0441 }
0442 
0443 void OpenGLContextAttributeBuilderTest::testGlx()
0444 {
0445 #if HAVE_GLX
0446     QFETCH(bool, requestVersion);
0447     QFETCH(int, major);
0448     QFETCH(int, minor);
0449     QFETCH(bool, robust);
0450     QFETCH(bool, videoPurge);
0451 
0452     GlxContextAttributeBuilder builder;
0453     if (requestVersion) {
0454         builder.setVersion(major, minor);
0455     }
0456     builder.setRobust(robust);
0457     builder.setResetOnVideoMemoryPurge(videoPurge);
0458 
0459     auto attribs = builder.build();
0460     QTEST(attribs, "expectedAttribs");
0461 #endif
0462 }
0463 
0464 QTEST_GUILESS_MAIN(OpenGLContextAttributeBuilderTest)
0465 #include "opengl_context_attribute_builder_test.moc"