summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2018-09-16 17:43:56 +0200
committerAxel Davy <[email protected]>2018-10-26 22:16:16 +0200
commit2318ca68bbeb4fa6e21a4d8c650cec3f64246596 (patch)
tree9b258fe7a7bcb27623f37ecd7b264843e2023035 /src/gallium
parente50d374b6140a610e61fa0da9d5d69f7cb9ef914 (diff)
st/nine: Handle window resize when a presentation buffer is used
Usually when a window is resized, the app calls d3d to resize the back buffer to the window size. In some cases, it is not done, and it expects the output resizes to the window size, even if the back buffer size is unchanged. This patch introduces the behaviour when a presentation buffer is used. ID3DPresent_GetWindowInfo is a function available with D3DPresent v1.0, and thus we don't need to check if the function is available. The function had been introduced to implement this very feature. Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/nine/swapchain9.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index aa485a6268b..cd77081e915 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -662,6 +662,7 @@ present( struct NineSwapChain9 *This,
struct pipe_fence_handle *fence;
HRESULT hr;
struct pipe_blit_info blit;
+ int target_width, target_height, target_depth;
DBG("present: This=%p pSourceRect=%p pDestRect=%p "
"pDirtyRegion=%p hDestWindowOverride=%p"
@@ -696,6 +697,9 @@ present( struct NineSwapChain9 *This,
if (This->params.SwapEffect == D3DSWAPEFFECT_DISCARD)
handle_draw_cursor_and_hud(This, resource);
+ ID3DPresent_GetWindowInfo(This->present, hDestWindowOverride, &target_width, &target_height, &target_depth);
+ (void)target_depth;
+
pipe = NineDevice9_GetPipe(This->base.device);
if (This->present_buffers[0]) {
@@ -710,6 +714,29 @@ present( struct NineSwapChain9 *This,
blit.src.box.width = resource->width0;
blit.src.box.height = resource->height0;
+ /* Reallocate a new presentation buffer if the target window
+ * size has changed */
+ if (target_width != This->present_buffers[0]->width0 ||
+ target_height != This->present_buffers[0]->height0) {
+ struct pipe_resource *new_resource;
+ D3DWindowBuffer *new_handle;
+
+ create_present_buffer(This, target_width, target_height, &new_resource, &new_handle);
+ /* Switch to the new buffer */
+ if (new_handle) {
+ /* WaitBufferReleased also waits the presentation feedback,
+ * while IsBufferReleased doesn't. DestroyD3DWindowBuffer unfortunately
+ * checks it to release immediately all data, else the release
+ * is postponed for This->present release. To avoid leaks (we may handle
+ * a lot of resize), call WaitBufferReleased. */
+ ID3DPresent_WaitBufferReleased(This->present, This->present_handles[0]);
+ ID3DPresent_DestroyD3DWindowBuffer(This->present, This->present_handles[0]);
+ This->present_handles[0] = new_handle;
+ pipe_resource_reference(&This->present_buffers[0], new_resource);
+ pipe_resource_reference(&new_resource, NULL);
+ }
+ }
+
resource = This->present_buffers[0];
blit.dst.resource = resource;
@@ -723,7 +750,9 @@ present( struct NineSwapChain9 *This,
blit.dst.box.height = resource->height0;
blit.mask = PIPE_MASK_RGBA;
- blit.filter = PIPE_TEX_FILTER_NEAREST;
+ blit.filter = (blit.dst.box.width == blit.src.box.width &&
+ blit.dst.box.height == blit.src.box.height) ?
+ PIPE_TEX_FILTER_NEAREST : PIPE_TEX_FILTER_LINEAR;
blit.scissor_enable = FALSE;
blit.alpha_blend = FALSE;