[Piglit] [PATCH] st/wgl: fix handling of minimized windows

Brian Paul brianp at vmware.com
Wed Mar 27 16:16:12 PDT 2013


If a window is redrawn while minimized we were emitting an invalid
size when doing SwapBuffers.  With the VMware SVGA driver it meant we
were emitting invalid dimensions for the SurfaceCopy command.

--

I've been running with this patch for a few days and haven't seen
any regressions.  Tested in WinXP and Win7.

Fixes http://bugzilla.eng.vmware.com/show_bug.cgi?id=996695
---
 src/gallium/state_trackers/wgl/stw_framebuffer.c |   26 +++----
 src/gallium/state_trackers/wgl/stw_st.c          |   86 +++++++++++-----------
 2 files changed, 54 insertions(+), 58 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c
index 32d3a2c..7d9c6c9 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c
@@ -122,33 +122,29 @@ stw_framebuffer_get_size( struct stw_framebuffer *fb )
     */
 
    assert(fb->hWnd);
-   assert(fb->width && fb->height);
    assert(fb->client_rect.right  == fb->client_rect.left + fb->width);
    assert(fb->client_rect.bottom == fb->client_rect.top  + fb->height);
 
    /*
-    * Get the client area size.
+    * Get the client area size.  Note: we might get a size of 0 x 0 if
+    * the window is minimized.
     */
-
    if (!GetClientRect(fb->hWnd, &client_rect)) {
       return;
    }
 
+   if (0)
+      debug_printf("GetClientRect l %u  r %u  t %u  b %u\n",
+                   (unsigned) client_rect.left,
+                   (unsigned) client_rect.right,
+                   (unsigned) client_rect.top,
+                   (unsigned) client_rect.bottom);
+
    assert(client_rect.left == 0);
    assert(client_rect.top == 0);
    width  = client_rect.right  - client_rect.left;
    height = client_rect.bottom - client_rect.top;
 
-   if (width <= 0 || height <= 0) {
-      /*
-       * When the window is minimized GetClientRect will return zeros.  Simply
-       * preserve the current window size, until the window is restored or
-       * maximized again.
-       */
-
-      return;
-   }
-
    if (width != fb->width || height != fb->height) {
       fb->must_resize = TRUE;
       fb->width = width; 
@@ -337,9 +333,7 @@ stw_framebuffer_update(
    struct stw_framebuffer *fb)
 {
    assert(fb->stfb);
-   assert(fb->height);
-   assert(fb->width);
-   
+
    /* XXX: It would be nice to avoid checking the size again -- in theory  
     * stw_call_window_proc would have cought the resize and stored the right 
     * size already, but unfortunately threads created before the DllMain is 
diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c
index dcf9587..96b322d 100644
--- a/src/gallium/state_trackers/wgl/stw_st.c
+++ b/src/gallium/state_trackers/wgl/stw_st.c
@@ -70,48 +70,50 @@ stw_st_framebuffer_validate_locked(struct st_framebuffer_iface *stfb,
          pipe_resource_reference(&stwfb->textures[i], NULL);
    }
 
-   memset(&templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
-   templ.width0 = width;
-   templ.height0 = height;
-   templ.depth0 = 1;
-   templ.array_size = 1;
-   templ.last_level = 0;
-
-   for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
-      enum pipe_format format;
-      unsigned bind;
-
-      /* the texture already exists or not requested */
-      if (stwfb->textures[i] || !(mask & (1 << i))) {
-         /* remember the texture */
-         if (stwfb->textures[i])
-            mask |= (1 << i);
-         continue;
-      }
-
-      switch (i) {
-      case ST_ATTACHMENT_FRONT_LEFT:
-      case ST_ATTACHMENT_BACK_LEFT:
-         format = stwfb->stvis.color_format;
-         bind = PIPE_BIND_DISPLAY_TARGET |
-                PIPE_BIND_RENDER_TARGET;
-         break;
-      case ST_ATTACHMENT_DEPTH_STENCIL:
-         format = stwfb->stvis.depth_stencil_format;
-         bind = PIPE_BIND_DEPTH_STENCIL;
-         break;
-      default:
-         format = PIPE_FORMAT_NONE;
-         break;
-      }
-
-      if (format != PIPE_FORMAT_NONE) {
-         templ.format = format;
-         templ.bind = bind;
-
-         stwfb->textures[i] =
-            stw_dev->screen->resource_create(stw_dev->screen, &templ);
+   if (width > 0 && height > 0) {
+      memset(&templ, 0, sizeof(templ));
+      templ.target = PIPE_TEXTURE_2D;
+      templ.width0 = width;
+      templ.height0 = height;
+      templ.depth0 = 1;
+      templ.array_size = 1;
+      templ.last_level = 0;
+
+      for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+         enum pipe_format format;
+         unsigned bind;
+
+         /* the texture already exists or not requested */
+         if (stwfb->textures[i] || !(mask & (1 << i))) {
+            /* remember the texture */
+            if (stwfb->textures[i])
+               mask |= (1 << i);
+            continue;
+         }
+
+         switch (i) {
+         case ST_ATTACHMENT_FRONT_LEFT:
+         case ST_ATTACHMENT_BACK_LEFT:
+            format = stwfb->stvis.color_format;
+            bind = PIPE_BIND_DISPLAY_TARGET |
+                   PIPE_BIND_RENDER_TARGET;
+            break;
+         case ST_ATTACHMENT_DEPTH_STENCIL:
+            format = stwfb->stvis.depth_stencil_format;
+            bind = PIPE_BIND_DEPTH_STENCIL;
+            break;
+         default:
+            format = PIPE_FORMAT_NONE;
+            break;
+         }
+
+         if (format != PIPE_FORMAT_NONE) {
+            templ.format = format;
+            templ.bind = bind;
+
+            stwfb->textures[i] =
+               stw_dev->screen->resource_create(stw_dev->screen, &templ);
+         }
       }
    }
 
-- 
1.7.3.4



More information about the Piglit mailing list