[mutter/wip/texture-purge-on-nvidia: 1/9] cogl: add new UNSTABLE_TEXTURES feature



commit a566c6677cd63cd1b200e815eda3a6661602db46
Author: Ray Strode <rstrode redhat com>
Date:   Tue Jan 15 11:01:38 2019 -0500

    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 add575b49..985ce336d 100644
--- a/cogl/cogl/cogl-context.h
+++ b/cogl/cogl/cogl-context.h
@@ -263,6 +263,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 f67895dd9..8338e284d 100644
--- a/cogl/cogl/cogl-types.h
+++ b/cogl/cogl/cogl-types.h
@@ -398,6 +398,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.
  *
@@ -428,7 +430,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 73648f663..66c2661b3 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/cogl/winsys/cogl-winsys-egl.c
@@ -502,6 +502,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);
 
@@ -514,6 +515,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 74b0895d1..4a033c0c6 100644
--- a/cogl/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/cogl/winsys/cogl-winsys-glx.c
@@ -832,12 +832,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));
@@ -850,7 +853,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);
@@ -899,7 +901,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)
@@ -921,6 +922,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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]