kopper: fix bufferage/swapinterval handling for non-window swapchains

if swapchain creation fails (e.g., insane cts swapchain configs), the
swapchain gets demoted to a non-window image that is still accessed by
the frontend. this image should not ever hit corresponding zink entrypoints
for swapchain-only images, which requires a flag to test swapchain-edness

cc: mesa-stable

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28904>
(cherry picked from commit a50c17802a)
This commit is contained in:
Mike Blumenkrantz 2024-04-24 12:42:11 -04:00 committed by Eric Engestrom
parent 235d807e93
commit 56a8bde81d
3 changed files with 10 additions and 1 deletions

View file

@ -264,7 +264,7 @@
"description": "kopper: fix bufferage/swapinterval handling for non-window swapchains",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -91,6 +91,7 @@ struct dri_drawable
struct kopper_loader_info info;
__DRIimage *image; //texture_from_pixmap
bool is_window;
bool window_valid;
bool has_modifiers;
/* hooks filled in by dri2 & drisw */

View file

@ -555,6 +555,7 @@ XXX do this once swapinterval is hooked up
assert(data);
drawable->textures[statts[i]] =
screen->base.screen->resource_create_drawable(screen->base.screen, &templ, data);
drawable->window_valid = !!drawable->textures[statts[i]];
}
#ifdef VK_USE_PLATFORM_XCB_KHR
else if (is_pixmap && statts[i] == ST_ATTACHMENT_FRONT_LEFT && !screen->is_sw) {
@ -904,6 +905,9 @@ kopperSetSwapInterval(__DRIdrawable *dPriv, int interval)
drawable->textures[ST_ATTACHMENT_BACK_LEFT] :
drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
/* can't set swap interval on non-windows */
if (!drawable->window_valid)
return;
/* the conditional is because we can be called before buffer allocation. If
* we're before allocation, then the initial_swap_interval will be used when
* the swapchain is eventually created.
@ -922,6 +926,10 @@ kopperQueryBufferAge(__DRIdrawable *dPriv)
drawable->textures[ST_ATTACHMENT_BACK_LEFT] :
drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
/* can't get buffer age from non-window swapchain */
if (!drawable->window_valid)
return 0;
/* Wait for glthread to finish because we can't use pipe_context from
* multiple threads.
*/