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 <davyaxel0@gmail.com>
This commit is contained in:
Axel Davy 2018-09-16 17:43:56 +02:00
parent e50d374b61
commit 2318ca68bb
1 changed files with 30 additions and 1 deletions

View File

@ -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;