glx: Fix drawable refcounting for naked Windows
authorAdam Jackson <ajax@redhat.com>
Mon, 11 Jul 2022 23:30:05 +0000 (19:30 -0400)
committerAdam Jackson <ajax@redhat.com>
Wed, 13 Jul 2022 16:25:30 +0000 (12:25 -0400)
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 <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17479>

21 files changed:
src/broadcom/ci/broadcom-rpi3-fails.txt
src/broadcom/ci/broadcom-rpi3-flakes.txt
src/broadcom/ci/broadcom-rpi4-fails.txt
src/freedreno/ci/freedreno-a307-fails.txt
src/freedreno/ci/freedreno-a420-fails.txt
src/freedreno/ci/freedreno-a530-fails.txt
src/freedreno/ci/freedreno-a630-fails.txt
src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt
src/gallium/drivers/radeonsi/ci/gfx10-navi10-fail.csv
src/gallium/drivers/radeonsi/ci/gfx10_3-navi21-fail.csv
src/gallium/drivers/radeonsi/ci/gfx8-polaris11-fail.csv
src/gallium/drivers/radeonsi/ci/gfx9-raven-fail.csv
src/gallium/drivers/radeonsi/ci/gfx9-vega20-fail.csv
src/gallium/drivers/softpipe/ci/softpipe-fails.txt
src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt
src/gallium/drivers/zink/ci/zink-lvp-flakes.txt
src/gallium/drivers/zink/ci/zink-lvp-skips.txt
src/gallium/drivers/zink/ci/zink-radv-fails.txt
src/glx/dri_common.c
src/intel/ci/iris-kbl-fails.txt
src/panfrost/ci/panfrost-g52-fails.txt

index a73fb13..0a8edae 100644 (file)
@@ -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
index bfb660b..caf706e 100644 (file)
@@ -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
index f5d0d54..fb62358 100644 (file)
@@ -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
index 90218ee..4e957b7 100644 (file)
@@ -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
index 7a9e26d..3d51692 100644 (file)
@@ -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
index 2e02d92..5be4449 100644 (file)
@@ -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
index a5344d0..d21fdb4 100644 (file)
@@ -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
index d165aff..db891e5 100644 (file)
@@ -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
 
index d76031c..d8b584f 100644 (file)
@@ -1,6 +1,4 @@
 # piglit failures
-glx@glx-make-current,Crash
-glx@glx-multi-window-single-context,Fail
 glx@glx-visuals-depth -pixmap,Crash
 glx@glx-visuals-stencil -pixmap,Crash
 glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail
index 95bebb9..baf0e1b 100644 (file)
@@ -1,6 +1,4 @@
 # piglit failures
-glx@glx-make-current,Crash
-glx@glx-multi-window-single-context,Fail
 glx@glx-swap-event_interval,Fail
 glx@glx-visuals-depth -pixmap,Crash
 glx@glx-visuals-stencil -pixmap,Crash
index f9cc7a9..e9a7648 100644 (file)
@@ -1,6 +1,4 @@
 # piglit failures
-glx@glx-make-current,Crash
-glx@glx-multi-window-single-context,Fail
 glx@glx-swap-event_interval,Fail
 glx@glx-visuals-depth -pixmap,Crash
 glx@glx-visuals-stencil -pixmap,Crash
index 1f52c4c..a1f41ba 100644 (file)
@@ -1,6 +1,4 @@
 # piglit failures
-glx@glx-make-current,Crash
-glx@glx-multi-window-single-context,Fail
 glx@glx-visuals-depth -pixmap,Crash
 glx@glx-visuals-stencil -pixmap,Crash
 glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail
index b8048c8..7d5fb82 100644 (file)
@@ -5,8 +5,6 @@ spec@!opengl 1.1@windowoverlap,Fail
 spec@arb_shader_clock@execution@clock,Fail
 spec@egl_chromium_sync_control@conformance,Fail
 spec@egl_chromium_sync_control@conformance@eglGetSyncValuesCHROMIUM_msc_and_sbc_test,Fail
-glx@glx-make-current,Crash
-glx@glx-multi-window-single-context,Fail
 glx@glx-visuals-depth -pixmap,Fail
 glx@glx-visuals-stencil -pixmap,Fail
 glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail
index 95257ca..258b5c5 100644 (file)
@@ -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
 
index e3732a5..78d50b4 100644 (file)
@@ -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
index d47d2f3..21d8420 100644 (file)
@@ -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"
index e6aa12b..3d10830 100644 (file)
@@ -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.*
index 62c4b38..d4d0fba 100644 (file)
@@ -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
index 632506d..16f1613 100644 (file)
@@ -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;
 }
index adbaf54..7b83e9e 100644 (file)
@@ -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
index bfdec49..e23ae08 100644 (file)
@@ -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