diff options
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/nine/swapchain9.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c index 8026ee16b7a..d299f62399f 100644 --- a/src/gallium/state_trackers/nine/swapchain9.c +++ b/src/gallium/state_trackers/nine/swapchain9.c @@ -693,12 +693,13 @@ static void work_present(void *data) } static void pend_present(struct NineSwapChain9 *This, + struct pipe_fence_handle *fence, HWND hDestWindowOverride) { struct end_present_struct *work = calloc(1, sizeof(struct end_present_struct)); work->screen = This->screen; - work->fence_to_wait = swap_fences_pop_front(This); + This->screen->fence_reference(This->screen, &work->fence_to_wait, fence); work->present = This->present; work->present_handle = This->present_handles[0]; work->hDestWindowOverride = hDestWindowOverride; @@ -867,6 +868,12 @@ present( struct NineSwapChain9 *This, fence = NULL; pipe->flush(pipe, &fence, PIPE_FLUSH_END_OF_FRAME); + + /* Present now for thread_submit, because we have the fence. + * It's possible we return WASSTILLDRAWING and still Present, + * but it should be fine. */ + if (This->enable_threadpool) + pend_present(This, fence, hDestWindowOverride); if (fence) { swap_fences_push_back(This, fence); This->screen->fence_reference(This->screen, &fence, NULL); @@ -887,21 +894,22 @@ bypass_rendering: return D3DERR_WASSTILLDRAWING; } + /* Throttle rendering if needed */ + fence = swap_fences_pop_front(This); + if (fence) { + (void) This->screen->fence_finish(This->screen, NULL, fence, PIPE_TIMEOUT_INFINITE); + This->screen->fence_reference(This->screen, &fence, NULL); + } + + This->rendering_done = FALSE; + if (!This->enable_threadpool) { This->tasks[0]=NULL; - fence = swap_fences_pop_front(This); - if (fence) { - (void) This->screen->fence_finish(This->screen, NULL, fence, PIPE_TIMEOUT_INFINITE); - This->screen->fence_reference(This->screen, &fence, NULL); - } hr = ID3DPresent_PresentBuffer(This->present, This->present_handles[0], hDestWindowOverride, pSourceRect, pDestRect, pDirtyRegion, dwFlags); if (FAILED(hr)) { UNTESTED(3);return hr; } - } else { - pend_present(This, hDestWindowOverride); } - This->rendering_done = FALSE; return D3D_OK; } @@ -1262,12 +1270,11 @@ NineSwapChain9_GetBackBufferCountForParams( struct NineSwapChain9 *This, /* With DISCARD, as there is no guarantee about the buffer contents, we can use * an arbitrary number of buffers */ if (pParams->SwapEffect == D3DSWAPEFFECT_DISCARD) { - /* thread_submit has a throttling equivalent to the throttling - * with throttling_value set to count-1. Most drivers use - * 2 for throttling_value. For performance use count of at least 3 - * for thread_submit. */ - if (This->actx->thread_submit && count < 3) - count = 3; + /* thread_submit's can have maximum count or This->actx->throttling_value + 1 + * frames in flight being rendered and not shown. + * Do not let count decrease that number */ + if (This->actx->thread_submit && count < This->desired_fences) + count = This->desired_fences; /* When we enable AllowDISCARDDelayedRelease, we must ensure * to have at least 4 buffers to meet INTERVAL_IMMEDIATE, * since the display server/compositor can hold 3 buffers |