zink: move 'acquired' flag onto swapchain struct

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17149>
This commit is contained in:
Mike Blumenkrantz
2022-06-21 10:59:55 -04:00
committed by Marge Bot
parent c47378fb0f
commit 92228a6d28
5 changed files with 17 additions and 10 deletions

View File

@@ -469,7 +469,7 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
batch->work_count = 0; batch->work_count = 0;
if (batch->swapchain) { if (batch->swapchain) {
if (batch->swapchain->obj->acquired && !batch->swapchain->obj->present) { if (zink_kopper_acquired(batch->swapchain->obj->dt, batch->swapchain->obj->dt_idx) && !batch->swapchain->obj->present) {
batch->state->present = zink_kopper_present(screen, batch->swapchain); batch->state->present = zink_kopper_present(screen, batch->swapchain);
batch->state->swapchain = batch->swapchain; batch->state->swapchain = batch->swapchain;
} }

View File

@@ -498,7 +498,7 @@ kopper_acquire(struct zink_screen *screen, struct zink_resource *res, uint64_t t
cdt->swapchain->images[res->obj->dt_idx].acquire = res->obj->acquire = acquire; cdt->swapchain->images[res->obj->dt_idx].acquire = res->obj->acquire = acquire;
res->obj->image = cdt->swapchain->images[res->obj->dt_idx].image; res->obj->image = cdt->swapchain->images[res->obj->dt_idx].image;
res->obj->acquired = false; cdt->swapchain->images[res->obj->dt_idx].acquired = false;
if (!cdt->swapchain->images[res->obj->dt_idx].init) { if (!cdt->swapchain->images[res->obj->dt_idx].init) {
/* swapchain images are initially in the UNDEFINED layout */ /* swapchain images are initially in the UNDEFINED layout */
res->layout = VK_IMAGE_LAYOUT_UNDEFINED; res->layout = VK_IMAGE_LAYOUT_UNDEFINED;
@@ -569,10 +569,10 @@ zink_kopper_acquire_submit(struct zink_screen *screen, struct zink_resource *res
{ {
assert(res->obj->dt); assert(res->obj->dt);
struct kopper_displaytarget *cdt = kopper_displaytarget(res->obj->dt); struct kopper_displaytarget *cdt = kopper_displaytarget(res->obj->dt);
if (res->obj->acquired) if (zink_kopper_acquired(res->obj->dt, res->obj->dt_idx))
return VK_NULL_HANDLE; return VK_NULL_HANDLE;
assert(res->obj->acquire); assert(res->obj->acquire);
res->obj->acquired = true; cdt->swapchain->images[res->obj->dt_idx].acquired = true;
/* this is now owned by the batch */ /* this is now owned by the batch */
cdt->swapchain->images[res->obj->dt_idx].acquire = VK_NULL_HANDLE; cdt->swapchain->images[res->obj->dt_idx].acquire = VK_NULL_HANDLE;
cdt->swapchain->dt_has_data = true; cdt->swapchain->dt_has_data = true;
@@ -589,7 +589,7 @@ zink_kopper_present(struct zink_screen *screen, struct zink_resource *res)
NULL, NULL,
0 0
}; };
assert(res->obj->acquired); assert(zink_kopper_acquired(res->obj->dt, res->obj->dt_idx));
VkResult ret = VKSCR(CreateSemaphore)(screen->dev, &sci, NULL, &res->obj->present); VkResult ret = VKSCR(CreateSemaphore)(screen->dev, &sci, NULL, &res->obj->present);
return zink_screen_handle_vkresult(screen, ret) ? res->obj->present : VK_NULL_HANDLE; return zink_screen_handle_vkresult(screen, ret) ? res->obj->present : VK_NULL_HANDLE;
} }
@@ -698,7 +698,7 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res)
{ {
assert(res->obj->dt); assert(res->obj->dt);
struct kopper_displaytarget *cdt = kopper_displaytarget(res->obj->dt); struct kopper_displaytarget *cdt = kopper_displaytarget(res->obj->dt);
assert(res->obj->acquired); assert(zink_kopper_acquired(res->obj->dt, res->obj->dt_idx));
assert(res->obj->present); assert(res->obj->present);
struct kopper_present_info *cpi = malloc(sizeof(struct kopper_present_info)); struct kopper_present_info *cpi = malloc(sizeof(struct kopper_present_info));
cpi->sem = res->obj->present; cpi->sem = res->obj->present;
@@ -723,7 +723,8 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res)
kopper_present(cpi, screen, -1); kopper_present(cpi, screen, -1);
} }
res->obj->acquire = VK_NULL_HANDLE; res->obj->acquire = VK_NULL_HANDLE;
res->obj->indefinite_acquire = res->obj->acquired = false; res->obj->indefinite_acquire = false;
cdt->swapchain->images[res->obj->dt_idx].acquired = false;
res->obj->dt_idx = UINT32_MAX; res->obj->dt_idx = UINT32_MAX;
} }

View File

@@ -31,6 +31,7 @@
struct kopper_swapchain_image { struct kopper_swapchain_image {
bool init; bool init;
bool acquired;
VkImage image; VkImage image;
VkSemaphore acquire; VkSemaphore acquire;
}; };
@@ -97,6 +98,12 @@ zink_kopper_last_present_eq(const struct kopper_displaytarget *cdt, uint32_t idx
return cdt->swapchain->last_present == idx; return cdt->swapchain->last_present == idx;
} }
static inline bool
zink_kopper_acquired(const struct kopper_displaytarget *cdt, uint32_t idx)
{
return idx != UINT32_MAX && cdt->swapchain->images[idx].acquired;
}
struct kopper_displaytarget * struct kopper_displaytarget *
zink_kopper_displaytarget_create(struct zink_screen *screen, unsigned tex_usage, zink_kopper_displaytarget_create(struct zink_screen *screen, unsigned tex_usage,
enum pipe_format format, unsigned width, enum pipe_format format, unsigned width,

View File

@@ -90,7 +90,6 @@ struct zink_resource_object {
uint32_t last_dt_idx; uint32_t last_dt_idx;
VkSemaphore acquire; VkSemaphore acquire;
VkSemaphore present; VkSemaphore present;
bool acquired;
bool new_dt; bool new_dt;
bool dt_has_data; bool dt_has_data;
bool indefinite_acquire; bool indefinite_acquire;

View File

@@ -1422,7 +1422,7 @@ zink_flush_frontbuffer(struct pipe_screen *pscreen,
/* if the surface has never been acquired, there's nothing to present, /* if the surface has never been acquired, there's nothing to present,
* so this is a no-op */ * so this is a no-op */
if (!res->obj->acquired && res->obj->last_dt_idx == UINT32_MAX) if (!zink_kopper_acquired(res->obj->dt, res->obj->dt_idx) && res->obj->last_dt_idx == UINT32_MAX)
return; return;
/* need to get the actual zink_context, not the threaded context */ /* need to get the actual zink_context, not the threaded context */
@@ -1438,7 +1438,7 @@ zink_flush_frontbuffer(struct pipe_screen *pscreen,
} }
} }
if (res->obj->acquired) if (zink_kopper_acquired(res->obj->dt, res->obj->dt_idx))
zink_kopper_present_queue(screen, res); zink_kopper_present_queue(screen, res);
else { else {
assert(res->obj->last_dt_idx != UINT32_MAX); assert(res->obj->last_dt_idx != UINT32_MAX);