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

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 "x11_standalone_glx_context_attribute_builder.h"
0010 #include <epoxy/glx.h>
0011 
0012 #ifndef GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV
0013 #define GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7
0014 #endif
0015 
0016 namespace KWin
0017 {
0018 
0019 std::vector<int> GlxContextAttributeBuilder::build() const
0020 {
0021     std::vector<int> attribs;
0022     if (isVersionRequested()) {
0023         attribs.emplace_back(GLX_CONTEXT_MAJOR_VERSION_ARB);
0024         attribs.emplace_back(majorVersion());
0025         attribs.emplace_back(GLX_CONTEXT_MINOR_VERSION_ARB);
0026         attribs.emplace_back(minorVersion());
0027     }
0028     if (isRobust()) {
0029         attribs.emplace_back(GLX_CONTEXT_FLAGS_ARB);
0030         attribs.emplace_back(GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB);
0031         attribs.emplace_back(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB);
0032         attribs.emplace_back(GLX_LOSE_CONTEXT_ON_RESET_ARB);
0033         if (isResetOnVideoMemoryPurge()) {
0034             attribs.emplace_back(GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV);
0035             attribs.emplace_back(GL_TRUE);
0036         }
0037     }
0038     attribs.emplace_back(0);
0039     return attribs;
0040 }
0041 
0042 }