aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2020-05-09 13:17:17 +0200
committerMarge Bot <[email protected]>2020-05-15 15:43:57 +0000
commit1c474dde282aa7b02513097b58435a470eee23f9 (patch)
treebeef8deab28ab9147b68584afc94512142f2ab6c
parentffed34113b652a59e6d6a9d9e212a3eac72dd216 (diff)
st/nine: Improve pDestRect handling
pSourceRect and pDestRect allows to: A) display a crop of the backbuffer B) display the content in a subregion (after an offset) C) resize the content before displaying Before this patch, only features A and B were supported. This patch adds C, but breaks A, which current support relied on C not being implemented. I think C is more important than A, and A can be added later. Signed-off-by: Axel Davy <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5015>
-rw-r--r--src/gallium/frontends/nine/swapchain9.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/gallium/frontends/nine/swapchain9.c b/src/gallium/frontends/nine/swapchain9.c
index 8fb20082f91..b9578b54600 100644
--- a/src/gallium/frontends/nine/swapchain9.c
+++ b/src/gallium/frontends/nine/swapchain9.c
@@ -724,6 +724,8 @@ present( struct NineSwapChain9 *This,
HRESULT hr;
struct pipe_blit_info blit;
int target_width, target_height, target_depth, i;
+ RECT source_rect;
+ RECT dest_rect;
DBG("present: This=%p pSourceRect=%p pDestRect=%p "
"pDirtyRegion=%p hDestWindowOverride=%p"
@@ -731,14 +733,18 @@ present( struct NineSwapChain9 *This,
This, pSourceRect, pDestRect, pDirtyRegion,
hDestWindowOverride, (int)dwFlags, This->buffers[0]->base.resource);
- if (pSourceRect)
+ if (pSourceRect) {
DBG("pSourceRect = (%u..%u)x(%u..%u)\n",
pSourceRect->left, pSourceRect->right,
pSourceRect->top, pSourceRect->bottom);
- if (pDestRect)
+ source_rect = *pSourceRect;
+ }
+ if (pDestRect) {
DBG("pDestRect = (%u..%u)x(%u..%u)\n",
pDestRect->left, pDestRect->right,
pDestRect->top, pDestRect->bottom);
+ 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.
@@ -771,6 +777,15 @@ present( struct NineSwapChain9 *This,
target_height = resource->height0;
}
+ if (pDestRect) {
+ dest_rect.top = MAX2(0, dest_rect.top);
+ dest_rect.left = MAX2(0, dest_rect.left);
+ dest_rect.bottom = MIN2(target_height, dest_rect.bottom);
+ dest_rect.right = MIN2(target_width, dest_rect.right);
+ target_height = dest_rect.bottom - dest_rect.top;
+ target_width = dest_rect.right - dest_rect.left;
+ }
+
/* Switch to using presentation buffers on window resize.
* Note: Most apps should resize the d3d back buffers when
* a window resize is detected, which will result in a call to
@@ -906,7 +921,7 @@ bypass_rendering:
if (!This->enable_threadpool) {
This->tasks[0]=NULL;
- hr = ID3DPresent_PresentBuffer(This->present, This->present_handles[0], hDestWindowOverride, pSourceRect, pDestRect, pDirtyRegion, dwFlags);
+ hr = ID3DPresent_PresentBuffer(This->present, This->present_handles[0], hDestWindowOverride, pSourceRect, pDestRect ? &dest_rect : NULL, pDirtyRegion, dwFlags);
if (FAILED(hr)) { UNTESTED(3);return hr; }
}