Commit 52035a97 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Use NV_robustness_video_memory_purge

Tested by hand on gLapstation with GLX and ANGLE backends. GLX works as
intended. ANGLE tickles a driver bug that causes a GL_OUT_OF_MEMORY error and
followed by a driver crash on glDrawElements. This forces a redraw of
everything so is a better user experience than just showing corrupted
textures.

Bug: 1113040
Change-Id: I404441e1c39541aa925931c15364b4d1ee6761b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2456190
Commit-Queue: Jonathan Backer <backer@chromium.org>
Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819367}
parent cbb38ec3
......@@ -69,6 +69,11 @@
#define EGL_HIGH_POWER_ANGLE 0x0002
#endif /* EGL_ANGLE_power_preference */
#ifndef EGL_NV_robustness_video_memory_purge
#define EGL_NV_robustness_video_memory_purge 1
#define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C
#endif /*EGL_NV_robustness_video_memory_purge */
using ui::GetLastEGLErrorString;
namespace gl {
......@@ -137,6 +142,12 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface,
context_attributes.push_back(
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
context_attributes.push_back(EGL_LOSE_CONTEXT_ON_RESET_EXT);
if (GLSurfaceEGL::IsRobustnessVideoMemoryPurgeSupported()) {
context_attributes.push_back(
EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV);
context_attributes.push_back(EGL_TRUE);
}
}
} else {
// At some point we should require the presence of the robustness
......
......@@ -17,6 +17,11 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_glx.h"
#ifndef GLX_NV_robustness_video_memory_purge
#define GLX_NV_robustness_video_memory_purge 1
#define GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7
#endif /* GLX_NV_robustness_video_memory_purge */
namespace gl {
namespace {
......@@ -33,6 +38,11 @@ GLXContext CreateContextAttribs(x11::Connection* connection,
if (GLSurfaceGLX::IsCreateContextRobustnessSupported()) {
attribs.push_back(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB);
attribs.push_back(GLX_LOSE_CONTEXT_ON_RESET_ARB);
if (GLSurfaceGLX::IsRobustnessVideoMemoryPurgeSupported()) {
attribs.push_back(GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV);
attribs.push_back(GL_TRUE);
}
}
if (version.first != 0 || version.second != 0) {
......
......@@ -183,6 +183,7 @@ EGLDisplayPlatform g_native_display(EGL_DEFAULT_DISPLAY);
const char* g_egl_extensions = nullptr;
bool g_egl_create_context_robustness_supported = false;
bool g_egl_robustness_video_memory_purge_supported = false;
bool g_egl_create_context_bind_generates_resource_supported = false;
bool g_egl_create_context_webgl_compatability_supported = false;
bool g_egl_sync_control_supported = false;
......@@ -955,6 +956,8 @@ bool GLSurfaceEGL::InitializeOneOffCommon() {
g_egl_create_context_robustness_supported =
HasEGLExtension("EGL_EXT_create_context_robustness");
g_egl_robustness_video_memory_purge_supported =
HasEGLExtension("EGL_NV_robustness_video_memory_purge");
g_egl_create_context_bind_generates_resource_supported =
HasEGLExtension("EGL_CHROMIUM_create_context_bind_generates_resource");
g_egl_create_context_webgl_compatability_supported =
......@@ -1095,6 +1098,7 @@ void GLSurfaceEGL::ShutdownOneOff() {
g_egl_extensions = nullptr;
g_egl_create_context_robustness_supported = false;
g_egl_robustness_video_memory_purge_supported = false;
g_egl_create_context_bind_generates_resource_supported = false;
g_egl_create_context_webgl_compatability_supported = false;
g_egl_sync_control_supported = false;
......@@ -1135,6 +1139,11 @@ bool GLSurfaceEGL::IsCreateContextRobustnessSupported() {
return g_egl_create_context_robustness_supported;
}
// static
bool GLSurfaceEGL::IsRobustnessVideoMemoryPurgeSupported() {
return g_egl_robustness_video_memory_purge_supported;
}
bool GLSurfaceEGL::IsCreateContextBindGeneratesResourceSupported() {
return g_egl_create_context_bind_generates_resource_supported;
}
......
......@@ -109,6 +109,7 @@ class GL_EXPORT GLSurfaceEGL : public GLSurface {
static const char* GetEGLExtensions();
static bool HasEGLExtension(const char* name);
static bool IsCreateContextRobustnessSupported();
static bool IsRobustnessVideoMemoryPurgeSupported();
static bool IsCreateContextBindGeneratesResourceSupported();
static bool IsCreateContextWebGLCompatabilitySupported();
static bool IsEGLSurfacelessContextSupported();
......
......@@ -49,6 +49,7 @@ namespace {
bool g_glx_context_create = false;
bool g_glx_create_context_robustness_supported = false;
bool g_glx_robustness_video_memory_purge_supported = false;
bool g_glx_create_context_profile_supported = false;
bool g_glx_create_context_profile_es2_supported = false;
bool g_glx_texture_from_pixmap_supported = false;
......@@ -518,6 +519,8 @@ bool GLSurfaceGLX::InitializeExtensionSettingsOneOff() {
g_glx_context_create = HasGLXExtension("GLX_ARB_create_context");
g_glx_create_context_robustness_supported =
HasGLXExtension("GLX_ARB_create_context_robustness");
g_glx_robustness_video_memory_purge_supported =
HasGLXExtension("GLX_NV_robustness_video_memory_purge");
g_glx_create_context_profile_supported =
HasGLXExtension("GLX_ARB_create_context_profile");
g_glx_create_context_profile_es2_supported =
......@@ -542,6 +545,7 @@ void GLSurfaceGLX::ShutdownOneOff() {
initialized_ = false;
g_glx_context_create = false;
g_glx_create_context_robustness_supported = false;
g_glx_robustness_video_memory_purge_supported = false;
g_glx_create_context_profile_supported = false;
g_glx_create_context_profile_es2_supported = false;
g_glx_texture_from_pixmap_supported = false;
......@@ -592,6 +596,11 @@ bool GLSurfaceGLX::IsCreateContextRobustnessSupported() {
return g_glx_create_context_robustness_supported;
}
// static
bool GLSurfaceGLX::IsRobustnessVideoMemoryPurgeSupported() {
return g_glx_robustness_video_memory_purge_supported;
}
// static
bool GLSurfaceGLX::IsCreateContextProfileSupported() {
return g_glx_create_context_profile_supported;
......
......@@ -44,6 +44,7 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface {
static bool HasGLXExtension(const char* name);
static bool IsCreateContextSupported();
static bool IsCreateContextRobustnessSupported();
static bool IsRobustnessVideoMemoryPurgeSupported();
static bool IsCreateContextProfileSupported();
static bool IsCreateContextES2ProfileSupported();
static bool IsTextureFromPixmapSupported();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment