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 a9140ec2f7
commit 4a04c47a5f
4 changed files with 10 additions and 5 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

@ -96,10 +96,6 @@ glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail
glx@glx_arb_create_context_no_error@no error,Fail
glx@glx_arb_create_context_robustness@invalid reset notification strategy,Fail
# See also the EGL buffer age failures
glx@glx-buffer-age,Fail
glx@glx-buffer-age vblank_mode=0,Fail
glx@glx-swap-pixmap-bad,Fail
# ../src/gallium/drivers/zink/zink_kopper.c:859: zink_kopper_update: Assertion `pres->bind & PIPE_BIND_DISPLAY_TARGET' failed.

View file

@ -88,6 +88,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

@ -606,6 +606,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) {
@ -928,6 +929,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.
@ -946,6 +950,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.
*/