st/nine: Handle full pSourceRect better
authorAxel Davy <davyaxel0@gmail.com>
Sat, 9 May 2020 11:31:25 +0000 (13:31 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 15 May 2020 15:43:57 +0000 (15:43 +0000)
Some apps do set pSourceRect to the full area even if not needed.

Filtering out this case is helpful, as we currently do not handle
properly resizing (pDestRect or window size not of the size of the resource)
when pSourceRect is set. Indeed in this case pSourceRect needs to be modified
before being passed to the presentation backend.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5015>

src/gallium/frontends/nine/swapchain9.c

index dab6ba6aa291b1cd0fa7ca6b5da0e607b6402222..39784738895dac6f06fb864e979531844ba8863a 100644 (file)
@@ -737,11 +737,23 @@ present( struct NineSwapChain9 *This,
      * to update everything. Let's ignore */
     (void) pDirtyRegion;
 
+    resource = This->buffers[0]->base.resource;
+
     if (pSourceRect) {
         DBG("pSourceRect = (%u..%u)x(%u..%u)\n",
             pSourceRect->left, pSourceRect->right,
             pSourceRect->top, pSourceRect->bottom);
         source_rect = *pSourceRect;
+        if (source_rect.top == 0 &&
+            source_rect.left == 0 &&
+            source_rect.bottom == resource->height0 &&
+            source_rect.right == resource->width0)
+            pSourceRect = NULL;
+        /* TODO: Handle more of pSourceRect.
+         * Currently we should support:
+         * . When there is no pSourceRect
+         * . When pSourceRect is the full buffer.
+         */
     }
     if (pDestRect) {
         DBG("pDestRect = (%u..%u)x(%u..%u)\n",
@@ -750,21 +762,9 @@ present( struct NineSwapChain9 *This,
         dest_rect = *pDestRect;
     }
 
-    /* TODO: in the case the source and destination rect have different size:
-     * We need to allocate a new buffer, and do a blit to it to resize.
-     * We can't use the present_buffer for that since when we created it,
-     * we couldn't guess which size would have been needed.
-     * If pDestRect or pSourceRect is null, we have to check the sizes
-     * from the source size, and the destination window size.
-     * In this case, either resize rngdata, or pass NULL instead
-     */
-    /* Note: This->buffers[0]->level should always be 0 */
-
     if (This->rendering_done)
         goto bypass_rendering;
 
-    resource = This->buffers[0]->base.resource;
-
     if (This->params.SwapEffect == D3DSWAPEFFECT_DISCARD)
         handle_draw_cursor_and_hud(This, resource);
 
@@ -830,7 +830,7 @@ present( struct NineSwapChain9 *This,
     if (This->present_buffers[0]) {
         memset(&blit, 0, sizeof(blit));
         blit.src.resource = resource;
-        blit.src.level = 0;
+        blit.src.level = 0; /* Note: This->buffers[0]->level should always be 0 */
         blit.src.format = resource->format;
         blit.src.box.z = 0;
         blit.src.box.depth = 1;