Blame SOURCES/0001-cogl-add-new-UNSTABLE_TEXTURES-feature.patch

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