mutter/SOURCES/0001-cogl-add-new-UNSTABLE_TEXTURES-feature.patch
2021-10-08 13:54:48 +00:00

137 lines
5.0 KiB
Diff

From 78bb1fff1155462638b0d6037ccddf1328482842 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 15 Jan 2019 11:01:38 -0500
Subject: [PATCH 1/9] cogl: add new UNSTABLE_TEXTURES feature
The proprietary nvidia driver garbles texture memory on suspend.
Before we can address that, we need to be able to detect it.
This commit adds a new UNSTABLE_TEXTURES feature that gets set if
the proprietary nvidia driver is in use.
---
cogl/cogl/cogl-context.h | 1 +
cogl/cogl/cogl-types.h | 5 ++++-
cogl/cogl/winsys/cogl-winsys-egl.c | 11 +++++++++++
cogl/cogl/winsys/cogl-winsys-glx.c | 13 +++++++++++--
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h
index d4104625e..a20c54549 100644
--- a/cogl/cogl/cogl-context.h
+++ b/cogl/cogl/cogl-context.h
@@ -261,6 +261,7 @@ typedef enum _CoglFeatureID
COGL_FEATURE_ID_TEXTURE_RG,
COGL_FEATURE_ID_BUFFER_AGE,
COGL_FEATURE_ID_TEXTURE_EGL_IMAGE_EXTERNAL,
+ COGL_FEATURE_ID_UNSTABLE_TEXTURES,
/*< private >*/
_COGL_N_FEATURE_IDS /*< skip >*/
diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h
index 690daa16a..5b980a43c 100644
--- a/cogl/cogl/cogl-types.h
+++ b/cogl/cogl/cogl-types.h
@@ -354,6 +354,8 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
* supported with CoglBufferAccess including write support.
* @COGL_FEATURE_DEPTH_TEXTURE: Whether #CoglFramebuffer support rendering the
* depth buffer to a texture.
+ * @COGL_FEATURE_UNSTABLE_TEXTURES: Whether textures require redrawing on
+ * resume or not.
*
* Flags for the supported features.
*
@@ -383,7 +385,8 @@ typedef enum
COGL_FEATURE_MAP_BUFFER_FOR_READ = (1 << 21),
COGL_FEATURE_MAP_BUFFER_FOR_WRITE = (1 << 22),
COGL_FEATURE_ONSCREEN_MULTIPLE = (1 << 23),
- COGL_FEATURE_DEPTH_TEXTURE = (1 << 24)
+ COGL_FEATURE_DEPTH_TEXTURE = (1 << 24),
+ COGL_FEATURE_UNSTABLE_TEXTURES = (1 << 25)
} CoglFeatureFlags;
/**
diff --git a/cogl/cogl/winsys/cogl-winsys-egl.c b/cogl/cogl/winsys/cogl-winsys-egl.c
index 903c6492d..dd450d4f3 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/cogl/winsys/cogl-winsys-egl.c
@@ -499,6 +499,7 @@ _cogl_winsys_context_init (CoglContext *context, CoglError **error)
CoglRenderer *renderer = context->display->renderer;
CoglDisplayEGL *egl_display = context->display->winsys;
CoglRendererEGL *egl_renderer = renderer->winsys;
+ CoglGpuInfo *info;
context->winsys = g_new0 (CoglContextEGL, 1);
@@ -511,6 +512,16 @@ _cogl_winsys_context_init (CoglContext *context, CoglError **error)
if (!_cogl_context_update_features (context, error))
return FALSE;
+ info = &context->gpu;
+
+ if (info->vendor == COGL_GPU_INFO_VENDOR_NVIDIA)
+ {
+ context->feature_flags |= COGL_FEATURE_UNSTABLE_TEXTURES;
+ COGL_FLAGS_SET (context->features,
+ COGL_FEATURE_ID_UNSTABLE_TEXTURES,
+ TRUE);
+ }
+
if (egl_renderer->private_features & COGL_EGL_WINSYS_FEATURE_SWAP_REGION)
{
COGL_FLAGS_SET (context->winsys_features,
diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c
index 235cfe81f..7e87dc15f 100644
--- a/cogl/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/cogl/winsys/cogl-winsys-glx.c
@@ -830,12 +830,15 @@ update_winsys_features (CoglContext *context, CoglError **error)
{
CoglGLXDisplay *glx_display = context->display->winsys;
CoglGLXRenderer *glx_renderer = context->display->renderer->winsys;
+ CoglGpuInfo *info;
_COGL_RETURN_VAL_IF_FAIL (glx_display->glx_context, FALSE);
if (!_cogl_context_update_features (context, error))
return FALSE;
+ info = &context->gpu;
+
memcpy (context->winsys_features,
glx_renderer->base_winsys_features,
sizeof (context->winsys_features));
@@ -848,7 +851,6 @@ update_winsys_features (CoglContext *context, CoglError **error)
if (glx_renderer->glXCopySubBuffer || context->glBlitFramebuffer)
{
- CoglGpuInfo *info = &context->gpu;
CoglGpuInfoArchitecture arch = info->architecture;
COGL_FLAGS_SET (context->winsys_features, COGL_WINSYS_FEATURE_SWAP_REGION, TRUE);
@@ -897,7 +899,6 @@ update_winsys_features (CoglContext *context, CoglError **error)
}
else
{
- CoglGpuInfo *info = &context->gpu;
if (glx_display->have_vblank_counter &&
context->display->renderer->xlib_enable_threaded_swap_wait &&
info->vendor == COGL_GPU_INFO_VENDOR_NVIDIA)
@@ -919,6 +920,14 @@ update_winsys_features (CoglContext *context, CoglError **error)
}
}
+ if (info->vendor == COGL_GPU_INFO_VENDOR_NVIDIA)
+ {
+ context->feature_flags |= COGL_FEATURE_UNSTABLE_TEXTURES;
+ COGL_FLAGS_SET (context->features,
+ COGL_FEATURE_ID_UNSTABLE_TEXTURES,
+ TRUE);
+ }
+
/* We'll manually handle queueing dirty events in response to
* Expose events from X */
COGL_FLAGS_SET (context->private_features,
--
2.21.0