From: Axel Davy Date: Sat, 27 Apr 2019 13:25:35 +0000 (+0200) Subject: st/nine: Throttle rendering similarly for thread_submit X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b71c300c70fa33705ddd795998e0fe25452cb2af;p=mesa.git st/nine: Throttle rendering similarly for thread_submit thread_submit's throttling depending on the number of internal back buffers, and wasn't affected by the driver requested throttling value. Now it is. Signed-off-by: Axel Davy --- 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 diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c index d6453bec131..b0b9bb12f2c 100644 --- a/src/gallium/targets/d3dadapter9/drm.c +++ b/src/gallium/targets/d3dadapter9/drm.c @@ -269,13 +269,6 @@ drm_create_adapter( int fd, else ctx->base.thread_submit = different_device; - if (ctx->base.thread_submit && (throttling_value_user == -2 || throttling_value_user == 0)) { - ctx->base.throttling_value = 0; - } else if (ctx->base.thread_submit) { - DBG("You have set a non standard throttling value in combination with thread_submit." - "We advise to use a throttling value of -2/0"); - } - if (driCheckOption(&userInitOptions, "override_vendorid", DRI_INT)) { override_vendorid = driQueryOptioni(&userInitOptions, "override_vendorid"); }