zink: lock buffer age when chundering swapchain for readback
this sequence doesn't count as SwapBuffers calls, so age cannot be modified
Fixes: c123ab2137 ("kopper: Implement {EGL,GLX}_EXT_buffer_age")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27553>
(cherry picked from commit c3a2e2f9f2e4be1e11792c01f3b9a2748dce6acb)
This commit is contained in:
parent
850c9dbdc9
commit
cf0ed80d3a
3 changed files with 17 additions and 6 deletions
|
|
@ -194,7 +194,7 @@
|
||||||
"description": "zink: lock buffer age when chundering swapchain for readback",
|
"description": "zink: lock buffer age when chundering swapchain for readback",
|
||||||
"nominated": true,
|
"nominated": true,
|
||||||
"nomination_type": 1,
|
"nomination_type": 1,
|
||||||
"resolution": 0,
|
"resolution": 1,
|
||||||
"main_sha": null,
|
"main_sha": null,
|
||||||
"because_sha": "c123ab213797c1d0d2a34e57c503428261324cc6",
|
"because_sha": "c123ab213797c1d0d2a34e57c503428261324cc6",
|
||||||
"notes": null
|
"notes": null
|
||||||
|
|
|
||||||
|
|
@ -812,11 +812,13 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res)
|
||||||
* * Any other color buffers' ages are incremented by 1 if
|
* * Any other color buffers' ages are incremented by 1 if
|
||||||
* their age was previously greater than 0.
|
* their age was previously greater than 0.
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < cdt->swapchain->num_images; i++) {
|
if (!cdt->age_locked) {
|
||||||
if (i == res->obj->dt_idx)
|
for (int i = 0; i < cdt->swapchain->num_images; i++) {
|
||||||
cdt->swapchain->images[i].age = 1;
|
if (i == res->obj->dt_idx)
|
||||||
else if (cdt->swapchain->images[i].age > 0)
|
cdt->swapchain->images[i].age = 1;
|
||||||
cdt->swapchain->images[i].age += 1;
|
else if (cdt->swapchain->images[i].age > 0)
|
||||||
|
cdt->swapchain->images[i].age += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (util_queue_is_initialized(&screen->flush_queue)) {
|
if (util_queue_is_initialized(&screen->flush_queue)) {
|
||||||
p_atomic_inc(&cpi->swapchain->async_presents);
|
p_atomic_inc(&cpi->swapchain->async_presents);
|
||||||
|
|
@ -873,14 +875,17 @@ zink_kopper_acquire_readback(struct zink_context *ctx, struct zink_resource *res
|
||||||
if (++cdt->readback_counter >= ZINK_READBACK_THRESHOLD)
|
if (++cdt->readback_counter >= ZINK_READBACK_THRESHOLD)
|
||||||
kopper_ensure_readback(screen, res);
|
kopper_ensure_readback(screen, res);
|
||||||
while (res->obj->dt_idx != last_dt_idx) {
|
while (res->obj->dt_idx != last_dt_idx) {
|
||||||
|
cdt->age_locked = true;
|
||||||
if (res->obj->dt_idx != UINT32_MAX && !zink_kopper_present_readback(ctx, res))
|
if (res->obj->dt_idx != UINT32_MAX && !zink_kopper_present_readback(ctx, res))
|
||||||
break;
|
break;
|
||||||
|
cdt->age_locked = true;
|
||||||
do {
|
do {
|
||||||
ret = kopper_acquire(screen, res, 0);
|
ret = kopper_acquire(screen, res, 0);
|
||||||
} while (!is_swapchain_kill(ret) && (ret == VK_NOT_READY || ret == VK_TIMEOUT));
|
} while (!is_swapchain_kill(ret) && (ret == VK_NOT_READY || ret == VK_TIMEOUT));
|
||||||
if (is_swapchain_kill(ret)) {
|
if (is_swapchain_kill(ret)) {
|
||||||
kill_swapchain(ctx, res);
|
kill_swapchain(ctx, res);
|
||||||
*readback = NULL;
|
*readback = NULL;
|
||||||
|
cdt->age_locked = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -936,6 +941,10 @@ zink_kopper_present_readback(struct zink_context *ctx, struct zink_resource *res
|
||||||
simple_mtx_lock(&screen->semaphores_lock);
|
simple_mtx_lock(&screen->semaphores_lock);
|
||||||
util_dynarray_append(&screen->semaphores, VkSemaphore, acquire);
|
util_dynarray_append(&screen->semaphores, VkSemaphore, acquire);
|
||||||
simple_mtx_unlock(&screen->semaphores_lock);
|
simple_mtx_unlock(&screen->semaphores_lock);
|
||||||
|
|
||||||
|
struct kopper_displaytarget *cdt = res->obj->dt;
|
||||||
|
cdt->age_locked = false;
|
||||||
|
|
||||||
return zink_screen_handle_vkresult(screen, error);
|
return zink_screen_handle_vkresult(screen, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,8 @@ struct kopper_displaytarget
|
||||||
bool is_kill;
|
bool is_kill;
|
||||||
VkPresentModeKHR present_mode;
|
VkPresentModeKHR present_mode;
|
||||||
unsigned readback_counter;
|
unsigned readback_counter;
|
||||||
|
|
||||||
|
bool age_locked; //disables buffer age during readback
|
||||||
};
|
};
|
||||||
|
|
||||||
struct zink_context;
|
struct zink_context;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue