From 768238fdc06eed3dce36da3baf811cb70db42b5c Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 11 Jul 2022 19:30:05 -0400 Subject: [PATCH] glx: Fix drawable refcounting for naked Windows driFetchDrawable is only ever called from the MakeCurrent path, which means it has to handle the case of pre-GLX-1.3 Windows being named as the drawable. When it finds the drawable in the hash, it increments its refcount before returning it, so for a GLXWindow it would be 2 on first return, one from glXCreateWindow and one from glXMakeCurrent. But when it does not find the drawable and creates one for the naked Window, the reference count on first return would only be 1. As a result, if this context was then ever bound to a different drawable, the old Window's DRI drawable state (like the back buffer) would be destroyed. Fixes piglit's glx-multi-window-single-context and glx-make-current for a variety of drivers. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6713 Reviewed-by: Emma Anholt Part-of: --- src/broadcom/ci/broadcom-rpi3-fails.txt | 1 - src/broadcom/ci/broadcom-rpi3-flakes.txt | 1 - src/broadcom/ci/broadcom-rpi4-fails.txt | 2 -- src/freedreno/ci/freedreno-a307-fails.txt | 2 -- src/freedreno/ci/freedreno-a420-fails.txt | 2 -- src/freedreno/ci/freedreno-a530-fails.txt | 2 -- src/freedreno/ci/freedreno-a630-fails.txt | 2 -- src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt | 7 ------- src/gallium/drivers/radeonsi/ci/gfx10-navi10-fail.csv | 2 -- src/gallium/drivers/radeonsi/ci/gfx10_3-navi21-fail.csv | 2 -- src/gallium/drivers/radeonsi/ci/gfx8-polaris11-fail.csv | 2 -- src/gallium/drivers/radeonsi/ci/gfx9-raven-fail.csv | 2 -- src/gallium/drivers/radeonsi/ci/gfx9-vega20-fail.csv | 2 -- src/gallium/drivers/softpipe/ci/softpipe-fails.txt | 6 ------ src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt | 2 -- src/gallium/drivers/zink/ci/zink-lvp-flakes.txt | 1 - src/gallium/drivers/zink/ci/zink-lvp-skips.txt | 1 - src/gallium/drivers/zink/ci/zink-radv-fails.txt | 2 -- src/glx/dri_common.c | 9 ++++++++- src/intel/ci/iris-kbl-fails.txt | 9 --------- src/panfrost/ci/panfrost-g52-fails.txt | 2 -- 21 files changed, 8 insertions(+), 53 deletions(-) diff --git a/src/broadcom/ci/broadcom-rpi3-fails.txt b/src/broadcom/ci/broadcom-rpi3-fails.txt index a73fb13fd0f9..0a8edaeb1908 100644 --- a/src/broadcom/ci/broadcom-rpi3-fails.txt +++ b/src/broadcom/ci/broadcom-rpi3-fails.txt @@ -102,7 +102,6 @@ spec@glsl-1.20@execution@tex-miplevel-selection gl2:textureproj 3d,Fail spec@glsl-1.20@execution@tex-miplevel-selection gl2:textureproj(bias) 3d,Fail spec@khr_texture_compression_astc@basic-gl,Fail -glx@glx-make-current,Crash glx@glx-multithread-buffer,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth -pixmap,Fail diff --git a/src/broadcom/ci/broadcom-rpi3-flakes.txt b/src/broadcom/ci/broadcom-rpi3-flakes.txt index bfb660b52f4f..caf706ea0221 100644 --- a/src/broadcom/ci/broadcom-rpi3-flakes.txt +++ b/src/broadcom/ci/broadcom-rpi3-flakes.txt @@ -5,7 +5,6 @@ dEQP-GLES2.functional.clipping.triangle_vertex.clip_three.clip_pos_x_and_neg_x_n dEQP-GLES2.functional.draw.random.51 dEQP-GLES2.functional.texture.size.cube.256x256_rgb888 -glx@glx-multi-window-single-context shaders@glsl-vs-loop shaders@glsl-vs-loop-nested spec@arb_framebuffer_srgb@blit renderbuffer srgb single_sampled enabled clear diff --git a/src/broadcom/ci/broadcom-rpi4-fails.txt b/src/broadcom/ci/broadcom-rpi4-fails.txt index f5d0d54eb84e..fb623584ba2f 100644 --- a/src/broadcom/ci/broadcom-rpi4-fails.txt +++ b/src/broadcom/ci/broadcom-rpi4-fails.txt @@ -1,5 +1,3 @@ -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-multithread-buffer,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth -pixmap,Crash diff --git a/src/freedreno/ci/freedreno-a307-fails.txt b/src/freedreno/ci/freedreno-a307-fails.txt index 90218ee89eff..4e957b749bd8 100644 --- a/src/freedreno/ci/freedreno-a307-fails.txt +++ b/src/freedreno/ci/freedreno-a307-fails.txt @@ -156,8 +156,6 @@ spec@glsl-1.30@execution@interpolation@interpolation-noperspective-gl_frontsecon spec@glsl-1.30@execution@interpolation@interpolation-noperspective-other-flat-fixed,Fail spec@glsl-1.30@execution@interpolation@interpolation-noperspective-other-smooth-fixed,Fail -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth -pixmap,Crash glx@glx-visuals-stencil -pixmap,Crash diff --git a/src/freedreno/ci/freedreno-a420-fails.txt b/src/freedreno/ci/freedreno-a420-fails.txt index 7a9e26daf5e0..3d5169297c4f 100644 --- a/src/freedreno/ci/freedreno-a420-fails.txt +++ b/src/freedreno/ci/freedreno-a420-fails.txt @@ -291,8 +291,6 @@ spec@!opengl 2.1@polygon-stipple-fs,Fail spec@ext_packed_float@query-rgba-signed-components,Fail # Uncategorized piglit failures -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-query-drawable-glx_fbconfig_id-window,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth -pixmap,Crash diff --git a/src/freedreno/ci/freedreno-a530-fails.txt b/src/freedreno/ci/freedreno-a530-fails.txt index 2e02d92b9906..5be444966b58 100644 --- a/src/freedreno/ci/freedreno-a530-fails.txt +++ b/src/freedreno/ci/freedreno-a530-fails.txt @@ -596,8 +596,6 @@ KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_2_mirrored_repeat,Fail KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_2_repeat,Fail glx@glx-multithread-buffer,Fail -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-tfp,Fail glx@glx-visuals-depth -pixmap,Crash diff --git a/src/freedreno/ci/freedreno-a630-fails.txt b/src/freedreno/ci/freedreno-a630-fails.txt index a5344d0b9dbf..d21fdb48fa23 100644 --- a/src/freedreno/ci/freedreno-a630-fails.txt +++ b/src/freedreno/ci/freedreno-a630-fails.txt @@ -47,8 +47,6 @@ glx@glx_ext_import_context@imported context has same context id,Fail glx@glx_ext_import_context@make current- multi process,Fail glx@glx_ext_import_context@make current- single process,Fail glx@glx_ext_import_context@query context info,Fail -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth -pixmap,Crash glx@glx-visuals-stencil -pixmap,Crash diff --git a/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt b/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt index d165affe0ef9..db891e55930c 100644 --- a/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt +++ b/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt @@ -29,13 +29,6 @@ spec@oes_shader_io_blocks@compiler@layout-location-aliasing.vert,Fail glx@glx-copy-sub-buffer,Fail glx@glx-copy-sub-buffer samples=2,Fail glx@glx-copy-sub-buffer samples=4,Fail - -# X Error of failed request: BadMatch (invalid parameter attributes) -# Major opcode of failed request: 150 (GLX) -# Minor opcode of failed request: 11 (X_GLXSwapBuffers) -glx@glx-make-current,Crash - -glx@glx-multi-window-single-context,Fail glx@glx-swap-copy,Fail glx@glx-swap-pixmap-bad,Fail diff --git a/src/gallium/drivers/softpipe/ci/softpipe-fails.txt b/src/gallium/drivers/softpipe/ci/softpipe-fails.txt index 95257ca3113a..258b5c5601b4 100644 --- a/src/gallium/drivers/softpipe/ci/softpipe-fails.txt +++ b/src/gallium/drivers/softpipe/ci/softpipe-fails.txt @@ -908,14 +908,8 @@ KHR-GLES31.core.texture_storage_multisample.GLCoverage.gl_tex_parameter_handlers fast_color_clear@fcc-front-buffer-distraction,Fail -# X Error of failed request: BadMatch (invalid parameter attributes) -# Major opcode of failed request: 150 (GLX) -# Minor opcode of failed request: 11 (X_GLXSwapBuffers) -glx@glx-make-current,Crash - glx@glx-multi-context-front,Fail -glx@glx-multi-window-single-context,Fail glx@glx-swap-copy,Fail glx@glx-swap-pixmap-bad,Fail diff --git a/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt b/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt index e3732a59883c..78d50b466aa8 100644 --- a/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt +++ b/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt @@ -72,8 +72,6 @@ KHR-GL43.transform_feedback_overflow_query_ARB.basic-single-stream-separate-attr KHR-GL43.transform_feedback_overflow_query_ARB.multiple-streams-multiple-buffers-per-stream,Fail KHR-GL43.transform_feedback_overflow_query_ARB.multiple-streams-one-buffer-per-stream,Fail -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-multithread-clearbuffer,Crash glx@glx-multithread-texture,Crash glx@glx-swap-copy,Fail diff --git a/src/gallium/drivers/zink/ci/zink-lvp-flakes.txt b/src/gallium/drivers/zink/ci/zink-lvp-flakes.txt index d47d2f3ba1b0..21d8420a7469 100644 --- a/src/gallium/drivers/zink/ci/zink-lvp-flakes.txt +++ b/src/gallium/drivers/zink/ci/zink-lvp-flakes.txt @@ -1,6 +1,5 @@ dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_mirror_l8_pot spec@khr_debug@push-pop-group_gl.* -glx@glx-multi-window-single-context # "Pending expose event- rerunning." # exit status: signal: 11" diff --git a/src/gallium/drivers/zink/ci/zink-lvp-skips.txt b/src/gallium/drivers/zink/ci/zink-lvp-skips.txt index e6aa12bc0c0e..3d10830dea18 100644 --- a/src/gallium/drivers/zink/ci/zink-lvp-skips.txt +++ b/src/gallium/drivers/zink/ci/zink-lvp-skips.txt @@ -6,7 +6,6 @@ KHR-GL32.texture_size_promotion.functional # ignores copied from the old runner script spec@arb_map_buffer_alignment@arb_map_buffer_alignment-map-invalidate-range -glx@glx-make-current spec@arb_timer_query.* spec@arb_sample_shading@builtin-gl-sample-mask spec@glsl-1.30@execution@tex-miplevel-selection.* diff --git a/src/gallium/drivers/zink/ci/zink-radv-fails.txt b/src/gallium/drivers/zink/ci/zink-radv-fails.txt index 62c4b383a6be..d4d0fbad54fb 100644 --- a/src/gallium/drivers/zink/ci/zink-radv-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-radv-fails.txt @@ -7,7 +7,6 @@ dEQP-GLES3.functional.shaders.texture_functions.textureprojlodoffset.sampler2dsh dEQP-GLES3.functional.shaders.texture_functions.textureprojoffset.sampler2dshadow_vertex,Fail # kopper -glx@glx-multi-window-single-context,Crash spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export-tex,Crash spec@egl_chromium_sync_control@conformance@eglGetSyncValuesCHROMIUM_ust_test,Fail @@ -36,7 +35,6 @@ glx@glx_ext_import_context@imported context has same context id,Fail glx@glx_ext_import_context@make current- multi process,Fail glx@glx_ext_import_context@make current- single process,Fail glx@glx_ext_import_context@query context info,Fail -glx@glx-make-current,Crash glx@glx-swap-copy,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth,Crash diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index 632506dabbd5..16f1613013ea 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -417,7 +417,14 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable) (*pdraw->destroyDrawable) (pdraw); return NULL; } - pdraw->refcount = 1; + /* This sure does look suspicious, doesn't it? We're on this path because + * this is a naked Window. GLX 1.3 drawables have an explicit creation + * step (setting refcount to 1), and those we would have found in the + * hash lookup above, bumped their refcount for the bind_context we're + * being called for, and then returned. But since we just created the + * internal naked-Window state, we need to account for both here. + */ + pdraw->refcount = 2; return pdraw; } diff --git a/src/intel/ci/iris-kbl-fails.txt b/src/intel/ci/iris-kbl-fails.txt index adbaf54618af..7b83e9e70ae0 100644 --- a/src/intel/ci/iris-kbl-fails.txt +++ b/src/intel/ci/iris-kbl-fails.txt @@ -13,15 +13,6 @@ dEQP-GLES3.functional.texture.compressed.astc.void_extent_ldr.8x5,Fail dEQP-GLES3.functional.texture.compressed.astc.void_extent_ldr.8x6,Fail dEQP-GLES3.functional.texture.compressed.astc.void_extent_ldr.8x8,Fail -# X Error of failed request: BadMatch (invalid parameter attributes) -# Major opcode of failed request: 151 (GLX) -# Minor opcode of failed request: 11 (X_GLXSwapBuffers) -# Serial number of failed request: 79 -# Current serial number in output stream: 80 -glx@glx-make-current,Crash - -glx@glx-multi-window-single-context,Fail - glx@glx-swap-pixmap-bad,Fail # failed to create drawable diff --git a/src/panfrost/ci/panfrost-g52-fails.txt b/src/panfrost/ci/panfrost-g52-fails.txt index bfdec49b2107..e23ae08030f1 100644 --- a/src/panfrost/ci/panfrost-g52-fails.txt +++ b/src/panfrost/ci/panfrost-g52-fails.txt @@ -10,9 +10,7 @@ glx@glx_ext_import_context@imported context has same context id,Fail glx@glx_ext_import_context@make current- multi process,Fail glx@glx_ext_import_context@make current- single process,Fail glx@glx_ext_import_context@query context info,Fail -glx@glx-make-current,Crash glx@glx-multithread-clearbuffer,Crash -glx@glx-multi-window-single-context,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth -pixmap,Crash glx@glx-visuals-stencil -pixmap,Crash -- GitLab