2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2017-06-26 04:56:55 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
|
2017-06-26 04:56:55 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2022-01-13 14:02:41 +00:00
|
|
|
#include "utils/abstract_opengl_context_attribute_builder.h"
|
|
|
|
#include "utils/egl_context_attribute_builder.h"
|
2018-06-05 10:52:57 +00:00
|
|
|
#include <QtTest>
|
2017-06-26 04:56:55 +00:00
|
|
|
#include <epoxy/egl.h>
|
|
|
|
|
2023-03-25 15:33:13 +00:00
|
|
|
#include "libkwineffects/kwinconfig.h"
|
2023-04-26 19:51:31 +00:00
|
|
|
#if HAVE_GLX
|
2022-07-22 16:59:22 +00:00
|
|
|
#include "../src/backends/x11/standalone/x11_standalone_glx_context_attribute_builder.h"
|
2017-06-27 19:08:19 +00:00
|
|
|
#include <epoxy/glx.h>
|
|
|
|
|
|
|
|
#ifndef GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV
|
|
|
|
#define GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2017-06-26 04:56:55 +00:00
|
|
|
using namespace KWin;
|
|
|
|
|
|
|
|
class OpenGLContextAttributeBuilderTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void testCtor();
|
|
|
|
void testRobust();
|
2017-07-16 15:31:09 +00:00
|
|
|
void testForwardCompatible();
|
|
|
|
void testProfile();
|
2017-06-27 19:08:19 +00:00
|
|
|
void testResetOnVideoMemoryPurge();
|
2017-06-26 04:56:55 +00:00
|
|
|
void testVersionMajor();
|
|
|
|
void testVersionMajorAndMinor();
|
2018-03-22 09:20:37 +00:00
|
|
|
void testHighPriority();
|
2017-06-26 04:56:55 +00:00
|
|
|
void testEgl_data();
|
|
|
|
void testEgl();
|
|
|
|
void testGles_data();
|
|
|
|
void testGles();
|
2017-06-27 19:08:19 +00:00
|
|
|
void testGlx_data();
|
|
|
|
void testGlx();
|
2017-06-26 04:56:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MockOpenGLContextAttributeBuilder : public AbstractOpenGLContextAttributeBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::vector<int> build() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<int> MockOpenGLContextAttributeBuilder::build() const
|
|
|
|
{
|
|
|
|
return std::vector<int>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testCtor()
|
|
|
|
{
|
|
|
|
MockOpenGLContextAttributeBuilder builder;
|
|
|
|
QCOMPARE(builder.isVersionRequested(), false);
|
|
|
|
QCOMPARE(builder.majorVersion(), 0);
|
|
|
|
QCOMPARE(builder.minorVersion(), 0);
|
|
|
|
QCOMPARE(builder.isRobust(), false);
|
2017-07-16 15:31:09 +00:00
|
|
|
QCOMPARE(builder.isForwardCompatible(), false);
|
|
|
|
QCOMPARE(builder.isCoreProfile(), false);
|
|
|
|
QCOMPARE(builder.isCompatibilityProfile(), false);
|
2017-06-27 19:08:19 +00:00
|
|
|
QCOMPARE(builder.isResetOnVideoMemoryPurge(), false);
|
2018-03-22 09:20:37 +00:00
|
|
|
QCOMPARE(builder.isHighPriority(), false);
|
2017-06-26 04:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testRobust()
|
|
|
|
{
|
|
|
|
MockOpenGLContextAttributeBuilder builder;
|
|
|
|
QCOMPARE(builder.isRobust(), false);
|
|
|
|
builder.setRobust(true);
|
|
|
|
QCOMPARE(builder.isRobust(), true);
|
|
|
|
builder.setRobust(false);
|
|
|
|
QCOMPARE(builder.isRobust(), false);
|
|
|
|
}
|
|
|
|
|
2017-07-16 15:31:09 +00:00
|
|
|
void OpenGLContextAttributeBuilderTest::testForwardCompatible()
|
|
|
|
{
|
|
|
|
MockOpenGLContextAttributeBuilder builder;
|
|
|
|
QCOMPARE(builder.isForwardCompatible(), false);
|
|
|
|
builder.setForwardCompatible(true);
|
|
|
|
QCOMPARE(builder.isForwardCompatible(), true);
|
|
|
|
builder.setForwardCompatible(false);
|
|
|
|
QCOMPARE(builder.isForwardCompatible(), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testProfile()
|
|
|
|
{
|
|
|
|
MockOpenGLContextAttributeBuilder builder;
|
|
|
|
QCOMPARE(builder.isCoreProfile(), false);
|
|
|
|
QCOMPARE(builder.isCompatibilityProfile(), false);
|
|
|
|
builder.setCoreProfile(true);
|
|
|
|
QCOMPARE(builder.isCoreProfile(), true);
|
|
|
|
QCOMPARE(builder.isCompatibilityProfile(), false);
|
|
|
|
builder.setCompatibilityProfile(true);
|
|
|
|
QCOMPARE(builder.isCoreProfile(), false);
|
|
|
|
QCOMPARE(builder.isCompatibilityProfile(), true);
|
|
|
|
builder.setCoreProfile(true);
|
|
|
|
QCOMPARE(builder.isCoreProfile(), true);
|
|
|
|
QCOMPARE(builder.isCompatibilityProfile(), false);
|
|
|
|
}
|
|
|
|
|
2017-06-27 19:08:19 +00:00
|
|
|
void OpenGLContextAttributeBuilderTest::testResetOnVideoMemoryPurge()
|
|
|
|
{
|
|
|
|
MockOpenGLContextAttributeBuilder builder;
|
|
|
|
QCOMPARE(builder.isResetOnVideoMemoryPurge(), false);
|
|
|
|
builder.setResetOnVideoMemoryPurge(true);
|
|
|
|
QCOMPARE(builder.isResetOnVideoMemoryPurge(), true);
|
|
|
|
builder.setResetOnVideoMemoryPurge(false);
|
|
|
|
QCOMPARE(builder.isResetOnVideoMemoryPurge(), false);
|
|
|
|
}
|
|
|
|
|
2018-03-22 09:20:37 +00:00
|
|
|
void OpenGLContextAttributeBuilderTest::testHighPriority()
|
|
|
|
{
|
|
|
|
MockOpenGLContextAttributeBuilder builder;
|
|
|
|
QCOMPARE(builder.isHighPriority(), false);
|
|
|
|
builder.setHighPriority(true);
|
|
|
|
QCOMPARE(builder.isHighPriority(), true);
|
|
|
|
builder.setHighPriority(false);
|
|
|
|
QCOMPARE(builder.isHighPriority(), false);
|
|
|
|
}
|
|
|
|
|
2017-06-26 04:56:55 +00:00
|
|
|
void OpenGLContextAttributeBuilderTest::testVersionMajor()
|
|
|
|
{
|
|
|
|
MockOpenGLContextAttributeBuilder builder;
|
|
|
|
builder.setVersion(2);
|
|
|
|
QCOMPARE(builder.isVersionRequested(), true);
|
|
|
|
QCOMPARE(builder.majorVersion(), 2);
|
|
|
|
QCOMPARE(builder.minorVersion(), 0);
|
|
|
|
builder.setVersion(3);
|
|
|
|
QCOMPARE(builder.isVersionRequested(), true);
|
|
|
|
QCOMPARE(builder.majorVersion(), 3);
|
|
|
|
QCOMPARE(builder.minorVersion(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testVersionMajorAndMinor()
|
|
|
|
{
|
|
|
|
MockOpenGLContextAttributeBuilder builder;
|
|
|
|
builder.setVersion(2, 1);
|
|
|
|
QCOMPARE(builder.isVersionRequested(), true);
|
|
|
|
QCOMPARE(builder.majorVersion(), 2);
|
|
|
|
QCOMPARE(builder.minorVersion(), 1);
|
|
|
|
builder.setVersion(3, 2);
|
|
|
|
QCOMPARE(builder.isVersionRequested(), true);
|
|
|
|
QCOMPARE(builder.majorVersion(), 3);
|
|
|
|
QCOMPARE(builder.minorVersion(), 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testEgl_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("requestVersion");
|
|
|
|
QTest::addColumn<int>("major");
|
|
|
|
QTest::addColumn<int>("minor");
|
|
|
|
QTest::addColumn<bool>("robust");
|
2017-07-16 15:31:09 +00:00
|
|
|
QTest::addColumn<bool>("forwardCompatible");
|
|
|
|
QTest::addColumn<bool>("coreProfile");
|
|
|
|
QTest::addColumn<bool>("compatibilityProfile");
|
2018-03-22 09:20:37 +00:00
|
|
|
QTest::addColumn<bool>("highPriority");
|
2017-06-26 04:56:55 +00:00
|
|
|
QTest::addColumn<std::vector<int>>("expectedAttribs");
|
|
|
|
|
2018-03-22 09:20:37 +00:00
|
|
|
QTest::newRow("fallback") << false << 0 << 0 << false << false << false << false << false << std::vector<int>{EGL_NONE};
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("legacy/robust")
|
|
|
|
<< false << 0 << 0 << true << false << false << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("legacy/robust/high priority")
|
|
|
|
<< false << 0 << 0 << true << false << false << false << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core")
|
|
|
|
<< true << 3 << 1 << false << false << false << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core/high priority")
|
|
|
|
<< true << 3 << 1 << false << false << false << false << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core/robust")
|
|
|
|
<< true << 3 << 1 << true << false << false << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core/robust/high priority")
|
|
|
|
<< true << 3 << 1 << true << false << false << false << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core/robust/forward compatible")
|
|
|
|
<< true << 3 << 1 << true << true << false << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core/robust/forward compatible/high priority")
|
|
|
|
<< true << 3 << 1 << true << true << false << false << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core/forward compatible")
|
|
|
|
<< true << 3 << 1 << false << true << false << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core/forward compatible/high priority")
|
|
|
|
<< true << 3 << 1 << false << true << false << false << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core profile/forward compatible")
|
|
|
|
<< true << 3 << 2 << false << true << true << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core profile/forward compatible/high priority")
|
|
|
|
<< true << 3 << 2 << false << true << true << false << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("compatibility profile/forward compatible")
|
|
|
|
<< true << 3 << 2 << false << true << false << true << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("compatibility profile/forward compatible/high priority")
|
|
|
|
<< true << 3 << 2 << false << true << false << true << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core profile/robust/forward compatible")
|
|
|
|
<< true << 3 << 2 << true << true << true << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("core profile/robust/forward compatible/high priority")
|
|
|
|
<< true << 3 << 2 << true << true << true << false << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("compatibility profile/robust/forward compatible")
|
|
|
|
<< true << 3 << 2 << true << true << false << true << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("compatibility profile/robust/forward compatible/high priority")
|
|
|
|
<< true << 3 << 2 << true << true << false << true << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
|
|
|
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
|
|
|
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
2017-06-26 04:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testEgl()
|
|
|
|
{
|
|
|
|
QFETCH(bool, requestVersion);
|
|
|
|
QFETCH(int, major);
|
|
|
|
QFETCH(int, minor);
|
|
|
|
QFETCH(bool, robust);
|
2017-07-16 15:31:09 +00:00
|
|
|
QFETCH(bool, forwardCompatible);
|
|
|
|
QFETCH(bool, coreProfile);
|
|
|
|
QFETCH(bool, compatibilityProfile);
|
2018-03-22 09:20:37 +00:00
|
|
|
QFETCH(bool, highPriority);
|
2017-06-26 04:56:55 +00:00
|
|
|
|
|
|
|
EglContextAttributeBuilder builder;
|
|
|
|
if (requestVersion) {
|
|
|
|
builder.setVersion(major, minor);
|
|
|
|
}
|
|
|
|
builder.setRobust(robust);
|
2017-07-16 15:31:09 +00:00
|
|
|
builder.setForwardCompatible(forwardCompatible);
|
|
|
|
builder.setCoreProfile(coreProfile);
|
|
|
|
builder.setCompatibilityProfile(compatibilityProfile);
|
2018-03-22 09:20:37 +00:00
|
|
|
builder.setHighPriority(highPriority);
|
2017-06-26 04:56:55 +00:00
|
|
|
|
|
|
|
auto attribs = builder.build();
|
|
|
|
QTEST(attribs, "expectedAttribs");
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testGles_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("robust");
|
2018-03-22 09:20:37 +00:00
|
|
|
QTest::addColumn<bool>("highPriority");
|
2017-06-26 04:56:55 +00:00
|
|
|
QTest::addColumn<std::vector<int>>("expectedAttribs");
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("robust")
|
|
|
|
<< true << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
|
|
EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("robust/high priority")
|
|
|
|
<< true << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
|
|
EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE,
|
|
|
|
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("normal")
|
|
|
|
<< false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
|
|
EGL_NONE};
|
|
|
|
QTest::newRow("normal/high priority")
|
|
|
|
<< false << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
EGL_NONE};
|
2017-06-26 04:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testGles()
|
|
|
|
{
|
|
|
|
QFETCH(bool, robust);
|
2018-03-22 09:20:37 +00:00
|
|
|
QFETCH(bool, highPriority);
|
2017-06-26 04:56:55 +00:00
|
|
|
|
|
|
|
EglOpenGLESContextAttributeBuilder builder;
|
|
|
|
builder.setVersion(2);
|
|
|
|
builder.setRobust(robust);
|
2018-03-22 09:20:37 +00:00
|
|
|
builder.setHighPriority(highPriority);
|
2017-06-26 04:56:55 +00:00
|
|
|
|
|
|
|
auto attribs = builder.build();
|
|
|
|
QTEST(attribs, "expectedAttribs");
|
|
|
|
}
|
|
|
|
|
2017-06-27 19:08:19 +00:00
|
|
|
void OpenGLContextAttributeBuilderTest::testGlx_data()
|
|
|
|
{
|
2023-04-26 19:51:31 +00:00
|
|
|
#if HAVE_GLX
|
2017-06-27 19:08:19 +00:00
|
|
|
QTest::addColumn<bool>("requestVersion");
|
|
|
|
QTest::addColumn<int>("major");
|
|
|
|
QTest::addColumn<int>("minor");
|
|
|
|
QTest::addColumn<bool>("robust");
|
|
|
|
QTest::addColumn<bool>("videoPurge");
|
|
|
|
QTest::addColumn<std::vector<int>>("expectedAttribs");
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("fallback")
|
|
|
|
<< true << 2 << 1 << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
|
|
|
|
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
|
|
|
|
0};
|
|
|
|
QTest::newRow("legacy/robust")
|
|
|
|
<< false << 0 << 0 << true << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
|
|
|
|
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
|
|
|
|
0};
|
|
|
|
QTest::newRow("legacy/robust/videoPurge")
|
|
|
|
<< false << 0 << 0 << true << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
|
|
|
|
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
|
|
|
|
GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE,
|
|
|
|
0};
|
|
|
|
QTest::newRow("core")
|
|
|
|
<< true << 3 << 1 << false << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
|
|
|
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
|
|
|
|
0};
|
|
|
|
QTest::newRow("core/robust")
|
|
|
|
<< true << 3 << 1 << true << false
|
|
|
|
<< std::vector<int>{
|
|
|
|
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
|
|
|
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
|
|
|
|
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
|
|
|
|
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
|
|
|
|
0};
|
|
|
|
QTest::newRow("core/robust/videoPurge")
|
|
|
|
<< true << 3 << 1 << true << true
|
|
|
|
<< std::vector<int>{
|
|
|
|
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
|
|
|
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
|
|
|
|
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
|
|
|
|
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
|
|
|
|
GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE,
|
|
|
|
0};
|
2017-06-27 19:08:19 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLContextAttributeBuilderTest::testGlx()
|
|
|
|
{
|
2023-04-26 19:51:31 +00:00
|
|
|
#if HAVE_GLX
|
2017-06-27 19:08:19 +00:00
|
|
|
QFETCH(bool, requestVersion);
|
|
|
|
QFETCH(int, major);
|
|
|
|
QFETCH(int, minor);
|
|
|
|
QFETCH(bool, robust);
|
|
|
|
QFETCH(bool, videoPurge);
|
|
|
|
|
|
|
|
GlxContextAttributeBuilder builder;
|
|
|
|
if (requestVersion) {
|
|
|
|
builder.setVersion(major, minor);
|
|
|
|
}
|
|
|
|
builder.setRobust(robust);
|
|
|
|
builder.setResetOnVideoMemoryPurge(videoPurge);
|
|
|
|
|
|
|
|
auto attribs = builder.build();
|
|
|
|
QTEST(attribs, "expectedAttribs");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-06-26 04:56:55 +00:00
|
|
|
QTEST_GUILESS_MAIN(OpenGLContextAttributeBuilderTest)
|
|
|
|
#include "opengl_context_attribute_builder_test.moc"
|