.travis.yml | 15 Makefile.am | 1 VERSION | 2 bin/.cherry-ignore | 12 configure.ac | 13 docs/relnotes/17.2.1.html | 3 docs/relnotes/17.2.2.html | 202 ++++++++ scons/llvm.py | 21 src/amd/addrlib/core/addrobject.cpp | 8 src/amd/common/ac_llvm_build.c | 53 ++ src/amd/common/ac_llvm_build.h | 14 src/amd/common/ac_nir_to_llvm.c | 11 src/amd/common/ac_surface.c | 11 src/amd/vulkan/radv_cmd_buffer.c | 5 src/amd/vulkan/radv_pipeline.c | 1 src/amd/vulkan/radv_query.c | 4 src/compiler/glsl/linker.cpp | 23 src/egl/drivers/dri2/egl_dri2.c | 12 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 9 src/egl/drivers/dri2/platform_x11.c | 1 src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 2 src/gallium/drivers/radeonsi/si_shader.c | 20 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 136 +++++ src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 2 src/gallium/drivers/radeonsi/si_state.c | 2 src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py | 8 src/gallium/drivers/vc4/vc4_bufmgr.c | 10 src/gallium/drivers/vc4/vc4_context.h | 7 src/gallium/drivers/vc4/vc4_draw.c | 65 +- src/gallium/drivers/vc4/vc4_job.c | 9 src/gallium/drivers/vc4/vc4_program.c | 21 src/gallium/drivers/vc4/vc4_resource.c | 15 src/gallium/drivers/vc4/vc4_resource.h | 14 src/gallium/drivers/vc4/vc4_state.c | 34 - src/gallium/drivers/vc4/vc4_uniforms.c | 2 src/gallium/state_trackers/va/postproc.c | 14 src/intel/compiler/brw_vec4_nir.cpp | 12 src/intel/compiler/brw_vec4_surface_builder.cpp | 13 src/intel/vulkan/anv_descriptor_set.c | 2 src/intel/vulkan/gen8_cmd_buffer.c | 4 src/mesa/drivers/dri/i965/brw_blorp.c | 6 src/mesa/drivers/dri/nouveau/nouveau_gldefs.h | 19 src/mesa/drivers/dri/nouveau/nv20_state_tex.c | 16 src/mesa/main/context.c | 2 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 src/util/Makefile.am | 4 src/util/u_atomic.c | 14 src/vulkan/wsi/wsi_common_wayland.c | 249 +++++----- 48 files changed, 864 insertions(+), 275 deletions(-)
New commits: commit bc12538a8e79113b733381ffdc0f6c89d59d0a50 Author: Juan A. Suarez Romero <jasua...@igalia.com> Date: Mon Oct 2 17:26:10 2017 +0200 docs: add release notes for 17.2.2 Signed-off-by: Juan A. Suarez Romero <jasua...@igalia.com> diff --git a/docs/relnotes/17.2.2.html b/docs/relnotes/17.2.2.html new file mode 100644 index 0000000..90f972a --- /dev/null +++ b/docs/relnotes/17.2.2.html @@ -0,0 +1,202 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <title>Mesa Release Notes</title> + <link rel="stylesheet" type="text/css" href="../mesa.css"> +</head> +<body> + +<div class="header"> + <h1>The Mesa 3D Graphics Library</h1> +</div> + +<iframe src="../contents.html"></iframe> +<div class="content"> + +<h1>Mesa 17.2.2 Release Notes / October 2, 2017</h1> + +<p> +Mesa 17.2.2 is a bug fix release which fixes bugs found since the 17.2.1 release. +</p> +<p> +Mesa 17.2.2 implements the OpenGL 4.5 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 4.5. OpenGL +4.5 is <strong>only</strong> available if requested at context creation +because compatibility contexts are not supported. +</p> + + +<h2>SHA256 checksums</h2> +<pre> +TBD +</pre> + + +<h2>New features</h2> +<p>None</p> + + +<h2>Bug fixes</h2> + +<ul> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=102573">Bug 102573</a> - fails to build on armel</li> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=102844">Bug 102844</a> - memory leak with glDeleteProgram for shader program type GL_COMPUTE_SHADER</li> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=102847">Bug 102847</a> - swr fail to build with llvm-5.0.0</li> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=102904">Bug 102904</a> - piglit and gl45 cts linker tests regressed</li> + +</ul> + + +<h2>Changes</h2> + +<p>Alexandru-Liviu Prodea (1):</p> +<ul> + <li>Scons: Add LLVM 5.0 support</li> +</ul> + +<p>Bas Nieuwenhuizen (1):</p> +<ul> + <li>radv: Check for GFX9 for 1D arrays in image_size intrinsic.</li> +</ul> + +<p>Boris Brezillon (1):</p> +<ul> + <li>broadcom/vc4: Fix infinite retry in vc4_bo_alloc()</li> +</ul> + +<p>Dave Airlie (3):</p> +<ul> + <li>radv/nir: call opt_remove_phis after trivial continues.</li> + <li>ac/surface: handle S8 on gfx9</li> + <li>st/glsl->tgsi: fix u64 to bool comparisons.</li> +</ul> + +<p>David Airlie (1):</p> +<ul> + <li>radv: add gfx9 scissor workaround</li> +</ul> + +<p>Emil Velikov (2):</p> +<ul> + <li>docs: add sha256 checksums for 17.2.1</li> + <li>automake: enable libunwind in `make distcheck'</li> +</ul> + +<p>Eric Anholt (4):</p> +<ul> + <li>broadcom/vc4: Fix use-after-free for flushing when writing to a texture.</li> + <li>broadcom/vc4: Fix use-after-free trying to mix a quad and tile clear.</li> + <li>broadcom/vc4: Fix use-after-free when deleting a program.</li> + <li>broadcom/vc4: Keep pipe_sampler_view->texture matching the original texture.</li> +</ul> + +<p>Gert Wollny (2):</p> +<ul> + <li>travis: force llvm-3.3 for "make Gallium ST Other"</li> + <li>travis: Add libunwind-dev to gallium/make builds</li> +</ul> + +<p>Grazvydas Ignotas (1):</p> +<ul> + <li>configure: check if -latomic is needed for __atomic_*</li> +</ul> + +<p>Ian Romanick (1):</p> +<ul> + <li>nv20: Fix GL_CLAMP</li> +</ul> + +<p>Jason Ekstrand (6):</p> +<ul> + <li>i965/blorp: Set r8stencil_needs_update when writing stencil</li> + <li>vulkan/wsi/wayland: Stop printing out the DRM device</li> + <li>vulkan/wsi/wayland: Refactor wsi_wl_display code</li> + <li>vulkan/wsi/wayland: Stop caching Wayland displays</li> + <li>vulkan/wsi/wayland: Copy wl_proxy objects from oldSwapchain if available</li> + <li>vulkan/wsi/wayland: Return better error messages</li> +</ul> + +<p>Juan A. Suarez Romero (4):</p> +<ul> + <li>cherry-ignore: add "radeonsi/gfx9: proper workaround for LS/HS VGPR initialization bug"</li> + <li>cherry-ignore: add "radv: Check for GFX9 for 1D arrays in image_size intrinsic."</li> + <li>cherry-ignore: add "radv: copy the number of viewports/scissors at pipeline bind time"</li> + <li>Update version to 17.2.2</li> +</ul> + +<p>Józef Kucia (1):</p> +<ul> + <li>anv: Fix descriptors copying</li> +</ul> + +<p>Kenneth Graunke (2):</p> +<ul> + <li>i965/vec4: Actually handle atomic op intrinsics.</li> + <li>i965/vec4: Fix swizzles on atomic sources.</li> +</ul> + +<p>Leo Liu (1):</p> +<ul> + <li>st/va/postproc: use video original size for postprocessing</li> +</ul> + +<p>Lucas Stach (1):</p> +<ul> + <li>etnaviv: fix 16bpp clears</li> +</ul> + +<p>Matt Turner (2):</p> +<ul> + <li>util: Link libmesautil into u_atomic_test</li> + <li>util/u_atomic: Add implementation of __sync_val_compare_and_swap_8</li> +</ul> + +<p>Nicolai Hähnle (9):</p> +<ul> + <li>radeonsi: workaround for gather4 on integer cube maps</li> + <li>amd/common: round cube array slice in ac_prepare_cube_coords</li> + <li>amd/common: add workaround for cube map array layer clamping</li> + <li>glsl/linker: fix output variable overlap check</li> + <li>radeonsi: fix array textures layer coordinate</li> + <li>radeonsi: set MIP_POINT_PRECLAMP to 0</li> + <li>amd/addrlib: fix missing va_end() after va_copy()</li> + <li>amd/common: move ac_build_phi from radeonsi</li> + <li>radeonsi: fix a regression in integer cube map handling</li> +</ul> + +<p>Samuel Iglesias Gonsálvez (1):</p> +<ul> + <li>anv: fix viewport transformation for z component</li> +</ul> + +<p>Samuel Pitoiset (1):</p> +<ul> + <li>radv: fix saved compute state when doing statistics/occlusion queries</li> +</ul> + +<p>Tapani Pälli (1):</p> +<ul> + <li>mesa: free current ComputeProgram state in _mesa_free_context_data</li> +</ul> + +<p>Tim Rowley (1):</p> +<ul> + <li>swr/rast: remove llvm fence/atomics from generated files</li> +</ul> + +<p>Tomasz Figa (1):</p> +<ul> + <li>egl/dri2: Implement swapInterval fallback in a conformant way</li> +</ul> + + +</div> +</body> +</html> commit 98dce315c84eda2ccedc945a1f94dd1814fc7042 Author: Juan A. Suarez Romero <jasua...@igalia.com> Date: Mon Oct 2 17:15:02 2017 +0200 Update version to 17.2.2 Signed-off-by: Juan A. Suarez Romero <jasua...@igalia.com> diff --git a/VERSION b/VERSION index 7c95a07..d3b2c4f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -17.2.1 +17.2.2 commit 1535e8a5d49312595505450ae3e0e2921750102d Author: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl> Date: Sun Oct 1 10:07:29 2017 +0200 radv: Check for GFX9 for 1D arrays in image_size intrinsic. Only on GFX9 we implement them as 2D images. This fixes: dEQP-VK.image.image_size.1d_array.readonly_12x34 dEQP-VK.image.image_size.1d_array.readonly_1x1 dEQP-VK.image.image_size.1d_array.readonly_32x32 dEQP-VK.image.image_size.1d_array.readonly_7x1 dEQP-VK.image.image_size.1d_array.readonly_writeonly_12x34 dEQP-VK.image.image_size.1d_array.readonly_writeonly_1x1 dEQP-VK.image.image_size.1d_array.readonly_writeonly_32x32 dEQP-VK.image.image_size.1d_array.readonly_writeonly_7x1 dEQP-VK.image.image_size.1d_array.writeonly_12x34 dEQP-VK.image.image_size.1d_array.writeonly_1x1 dEQP-VK.image.image_size.1d_array.writeonly_32x32 dEQP-VK.image.image_size.1d_array.writeonly_7x1 Fixes: 1bcb953e166 "radv: handle GFX9 1D textures" Reviewed-by: Dave Airlie <airl...@redhat.com> (cherry picked from commit 979978ee06867a531b8d56cee252f5c83920a339) diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 94e457d..95cc8e5 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -3609,7 +3609,8 @@ static LLVMValueRef visit_image_size(struct nir_to_llvm_context *ctx, z = LLVMBuildSDiv(ctx->builder, z, six, ""); res = LLVMBuildInsertElement(ctx->builder, res, z, two, ""); } - if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_1D && + if (ctx->options->chip_class >= GFX9 && + glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_1D && glsl_sampler_type_is_array(type)) { LLVMValueRef layers = LLVMBuildExtractElement(ctx->builder, res, two, ""); res = LLVMBuildInsertElement(ctx->builder, res, layers, commit a66a70480f1b8dfaec611d1d75f65a04e579f184 Author: Nicolai Hähnle <nicolai.haeh...@amd.com> Date: Fri Sep 29 11:21:01 2017 +0200 radeonsi: fix a regression in integer cube map handling A recent commit fixed the case of 8888 integer cube maps, which need the workaround of replacing the data format with USCALED/SSCALED. However, this broke the case of non-8888 integer cube maps; those still need the fix of shifting the texture coordinates. Fixes KHR-GL45.texture_gather.plain-gather-int-cube-array and similar. Fixes: 6fb0c1013b35 ("radeonsi: workaround for gather4 on integer cube maps") Reviewed-by: Marek Olšák <marek.ol...@amd.com> (cherry picked from commit 6d23f7c65d6a3e6117b7b383bc811f01dd5b5c40) diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c index c9051bf..dd5b648 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c @@ -1701,6 +1701,7 @@ si_lower_gather4_integer(struct si_shader_context *ctx, enum tgsi_return_type return_type) { LLVMBuilderRef builder = ctx->gallivm.builder; + LLVMValueRef wa_8888 = NULL; LLVMValueRef coord = args->addr; LLVMValueRef half_texel[2]; /* Texture coordinates start after: @@ -1718,7 +1719,6 @@ si_lower_gather4_integer(struct si_shader_context *ctx, LLVMValueRef formats; LLVMValueRef data_format; LLVMValueRef wa_formats; - LLVMValueRef wa; formats = LLVMBuildExtractElement(builder, args->resource, ctx->i32_1, ""); @@ -1726,9 +1726,10 @@ si_lower_gather4_integer(struct si_shader_context *ctx, LLVMConstInt(ctx->i32, 20, false), ""); data_format = LLVMBuildAnd(builder, data_format, LLVMConstInt(ctx->i32, (1u << 6) - 1, false), ""); - wa = LLVMBuildICmp(builder, LLVMIntEQ, data_format, - LLVMConstInt(ctx->i32, V_008F14_IMG_DATA_FORMAT_8_8_8_8, false), - ""); + wa_8888 = LLVMBuildICmp( + builder, LLVMIntEQ, data_format, + LLVMConstInt(ctx->i32, V_008F14_IMG_DATA_FORMAT_8_8_8_8, false), + ""); uint32_t wa_num_format = return_type == TGSI_RETURN_TYPE_UINT ? @@ -1740,19 +1741,24 @@ si_lower_gather4_integer(struct si_shader_context *ctx, wa_formats = LLVMBuildOr(builder, wa_formats, LLVMConstInt(ctx->i32, wa_num_format, false), ""); - formats = LLVMBuildSelect(builder, wa, wa_formats, formats, ""); + formats = LLVMBuildSelect(builder, wa_8888, wa_formats, formats, ""); args->resource = LLVMBuildInsertElement( builder, args->resource, formats, ctx->i32_1, ""); - - return wa; } if (target == TGSI_TEXTURE_RECT || target == TGSI_TEXTURE_SHADOWRECT) { + assert(!wa_8888); half_texel[0] = half_texel[1] = LLVMConstReal(ctx->f32, -0.5); } else { struct tgsi_full_instruction txq_inst = {}; struct lp_build_emit_data txq_emit_data = {}; + struct lp_build_if_state if_ctx; + + if (wa_8888) { + /* Skip the texture size query entirely if we don't need it. */ + lp_build_if(&if_ctx, &ctx->gallivm, LLVMBuildNot(builder, wa_8888, "")); + } /* Query the texture size. */ txq_inst.Texture.Texture = target; @@ -1775,6 +1781,18 @@ si_lower_gather4_integer(struct si_shader_context *ctx, half_texel[c] = LLVMBuildFMul(builder, half_texel[c], LLVMConstReal(ctx->f32, -0.5), ""); } + + if (wa_8888) { + lp_build_endif(&if_ctx); + + LLVMBasicBlockRef bb[2] = { if_ctx.true_block, if_ctx.entry_block }; + + for (c = 0; c < 2; c++) { + LLVMValueRef values[2] = { half_texel[c], ctx->ac.f32_0 }; + half_texel[c] = ac_build_phi(&ctx->ac, ctx->f32, 2, + values, bb); + } + } } for (c = 0; c < 2; c++) { @@ -1790,7 +1808,7 @@ si_lower_gather4_integer(struct si_shader_context *ctx, args->addr = coord; - return NULL; + return wa_8888; } /* The second half of the cube texture 8_8_8_8 integer workaround: adjust the commit bd522741c4e87354ae828592116fa36bf0acc4e4 Author: Nicolai Hähnle <nicolai.haeh...@amd.com> Date: Fri Sep 29 11:17:03 2017 +0200 amd/common: move ac_build_phi from radeonsi Reviewed-by: Marek Olšák <marek.ol...@amd.com> (cherry picked from commit 052b974fed3586f3b2f61d2d2c050c1807ec43c5) [Juan A. Suarez: resolve trivial conflicts] Signed-off-by: Juan A. Suarez Romero <jasua...@igalia.com> Conflicts: src/amd/common/ac_llvm_build.c src/amd/common/ac_llvm_build.h diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 58dac72..6d9ec8b 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -179,6 +179,20 @@ void ac_build_type_name_for_intr(LLVMTypeRef type, char *buf, unsigned bufsize) } } +/** + * Helper function that builds an LLVM IR PHI node and immediately adds + * incoming edges. + */ +LLVMValueRef +ac_build_phi(struct ac_llvm_context *ctx, LLVMTypeRef type, + unsigned count_incoming, LLVMValueRef *values, + LLVMBasicBlockRef *blocks) +{ + LLVMValueRef phi = LLVMBuildPhi(ctx->builder, type, ""); + LLVMAddIncoming(phi, values, blocks, count_incoming); + return phi; +} + LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMValueRef *values, diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 0cfc9c6..f4f485d 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -79,6 +79,11 @@ ac_build_intrinsic(struct ac_llvm_context *ctx, const char *name, void ac_build_type_name_for_intr(LLVMTypeRef type, char *buf, unsigned bufsize); LLVMValueRef +ac_build_phi(struct ac_llvm_context *ctx, LLVMTypeRef type, + unsigned count_incoming, LLVMValueRef *values, + LLVMBasicBlockRef *blocks); + +LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMValueRef *values, unsigned value_count, diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 2bec7ff..68a9515 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -175,20 +175,6 @@ unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index) } /** - * Helper function that builds an LLVM IR PHI node and immediately adds - * incoming edges. - */ -static LLVMValueRef -build_phi(struct ac_llvm_context *ctx, LLVMTypeRef type, - unsigned count_incoming, LLVMValueRef *values, - LLVMBasicBlockRef *blocks) -{ - LLVMValueRef phi = LLVMBuildPhi(ctx->builder, type, ""); - LLVMAddIncoming(phi, values, blocks, count_incoming); - return phi; -} - -/** * Get the value of a shader input parameter and extract a bitfield. */ static LLVMValueRef unpack_param(struct si_shader_context *ctx, @@ -2732,15 +2718,15 @@ static void si_llvm_emit_tcs_epilogue(struct lp_build_tgsi_context *bld_base) values[0] = rel_patch_id; values[1] = LLVMGetUndef(ctx->i32); - rel_patch_id = build_phi(&ctx->ac, ctx->i32, 2, values, blocks); + rel_patch_id = ac_build_phi(&ctx->ac, ctx->i32, 2, values, blocks); values[0] = tf_lds_offset; values[1] = LLVMGetUndef(ctx->i32); - tf_lds_offset = build_phi(&ctx->ac, ctx->i32, 2, values, blocks); + tf_lds_offset = ac_build_phi(&ctx->ac, ctx->i32, 2, values, blocks); values[0] = invocation_id; values[1] = ctx->i32_1; /* cause the epilog to skip threads */ - invocation_id = build_phi(&ctx->ac, ctx->i32, 2, values, blocks); + invocation_id = ac_build_phi(&ctx->ac, ctx->i32, 2, values, blocks); } /* Return epilog parameters from this function. */ commit b78c664115b592d36f3f6b9cd13d300c40c3e451 Author: Jason Ekstrand <jason.ekstr...@intel.com> Date: Tue Sep 26 09:42:56 2017 -0700 vulkan/wsi/wayland: Return better error messages Reviewed-by: Daniel Stone <dani...@collabora.com> Cc: mesa-sta...@lists.freedesktop.org (cherry picked from commit 4fe3913b9699ac929715b16ecbf5b93fe87ce4ee) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 15dc84c..4c94cd6 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -263,59 +263,72 @@ wsi_wl_display_finish(struct wsi_wl_display *display) wl_event_queue_destroy(display->queue); } -static int +static VkResult wsi_wl_display_init(struct wsi_wayland *wsi_wl, struct wsi_wl_display *display, struct wl_display *wl_display, bool get_format_list) { + VkResult result = VK_SUCCESS; memset(display, 0, sizeof(*display)); display->wsi_wl = wsi_wl; display->wl_display = wl_display; if (get_format_list) { - if (!u_vector_init(&display->formats, sizeof(VkFormat), 8)) + if (!u_vector_init(&display->formats, sizeof(VkFormat), 8)) { + result = VK_ERROR_OUT_OF_HOST_MEMORY; goto fail; + } } display->queue = wl_display_create_queue(wl_display); - if (!display->queue) + if (!display->queue) { + result = VK_ERROR_OUT_OF_HOST_MEMORY; goto fail; + } display->wl_display_wrapper = wl_proxy_create_wrapper(wl_display); - if (!display->wl_display_wrapper) + if (!display->wl_display_wrapper) { + result = VK_ERROR_OUT_OF_HOST_MEMORY; goto fail; + } wl_proxy_set_queue((struct wl_proxy *) display->wl_display_wrapper, display->queue); struct wl_registry *registry = wl_display_get_registry(display->wl_display_wrapper); - if (!registry) + if (!registry) { + result = VK_ERROR_OUT_OF_HOST_MEMORY; goto fail; + } wl_registry_add_listener(registry, ®istry_listener, display); /* Round-trip to get the wl_drm global */ wl_display_roundtrip_queue(display->wl_display, display->queue); - if (!display->drm) + if (!display->drm) { + result = VK_ERROR_SURFACE_LOST_KHR; goto fail_registry; + } /* Round-trip to get wl_drm formats and capabilities */ wl_display_roundtrip_queue(display->wl_display, display->queue); /* We need prime support */ - if (!(display->capabilities & WL_DRM_CAPABILITY_PRIME)) + if (!(display->capabilities & WL_DRM_CAPABILITY_PRIME)) { + result = VK_ERROR_SURFACE_LOST_KHR; goto fail_registry; + } /* We don't need this anymore */ wl_registry_destroy(registry); display->refcount = 0; - return 0; + return VK_SUCCESS; fail_registry: if (registry) @@ -323,26 +336,29 @@ fail_registry: fail: wsi_wl_display_finish(display); - return -1; + return result; } -static struct wsi_wl_display * -wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display) +static VkResult +wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display, + struct wsi_wl_display **display_out) { struct wsi_wl_display *display = vk_alloc(wsi->alloc, sizeof(*display), 8, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (!display) - return NULL; + return VK_ERROR_OUT_OF_HOST_MEMORY; - if (wsi_wl_display_init(wsi, display, wl_display, true)) { + VkResult result = wsi_wl_display_init(wsi, display, wl_display, true); + if (result != VK_SUCCESS) { vk_free(wsi->alloc, display); - return NULL; + return result; } display->refcount++; + *display_out = display; - return display; + return result; } static struct wsi_wl_display * @@ -841,16 +857,15 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, struct wsi_wl_swapchain *old_chain = (void *)pCreateInfo->oldSwapchain; chain->display = wsi_wl_display_ref(old_chain->display); } else { - chain->display = wsi_wl_display_create(wsi, surface->display); - if (!chain->display) { - result = VK_ERROR_INITIALIZATION_FAILED; + chain->display = NULL; + result = wsi_wl_display_create(wsi, surface->display, &chain->display); + if (result != VK_SUCCESS) goto fail; - } } chain->surface = wl_proxy_create_wrapper(surface->surface); if (!chain->surface) { - result = VK_ERROR_INITIALIZATION_FAILED; + result = VK_ERROR_OUT_OF_HOST_MEMORY; goto fail; } wl_proxy_set_queue((struct wl_proxy *) chain->surface, @@ -859,7 +874,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, chain->drm_wrapper = wl_proxy_create_wrapper(chain->display->drm); if (!chain->drm_wrapper) { - result = VK_ERROR_INITIALIZATION_FAILED; + result = VK_ERROR_OUT_OF_HOST_MEMORY; goto fail; } wl_proxy_set_queue((struct wl_proxy *) chain->drm_wrapper, commit 2467b50e458b0731d2f71ae384be5f2db567ac13 Author: Jason Ekstrand <jason.ekstr...@intel.com> Date: Tue Sep 26 09:20:47 2017 -0700 vulkan/wsi/wayland: Copy wl_proxy objects from oldSwapchain if available This should save us some round trips while resizing. Reviewed-by: Daniel Stone <dani...@collabora.com> Cc: mesa-sta...@lists.freedesktop.org (cherry picked from commit 537b9bc3e4773f68c426b99a1860622db5ce6f0e) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 214a4e3..15dc84c 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -58,6 +58,9 @@ struct wsi_wl_display { struct u_vector formats; uint32_t capabilities; + + /* Only used for displays created by wsi_wl_display_create */ + uint32_t refcount; }; struct wsi_wayland { @@ -249,6 +252,8 @@ static const struct wl_registry_listener registry_listener = { static void wsi_wl_display_finish(struct wsi_wl_display *display) { + assert(display->refcount == 0); + u_vector_finish(&display->formats); if (display->drm) wl_drm_destroy(display->drm); @@ -308,6 +313,8 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl, /* We don't need this anymore */ wl_registry_destroy(registry); + display->refcount = 0; + return 0; fail_registry: @@ -333,12 +340,24 @@ wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display) return NULL; } + display->refcount++; + + return display; +} + +static struct wsi_wl_display * +wsi_wl_display_ref(struct wsi_wl_display *display) +{ + display->refcount++; return display; } static void -wsi_wl_display_destroy(struct wsi_wl_display *display) +wsi_wl_display_unref(struct wsi_wl_display *display) { + if (display->refcount-- > 1) + return; + struct wsi_wayland *wsi = display->wsi_wl; wsi_wl_display_finish(display); vk_free(wsi->alloc, display); @@ -757,7 +776,7 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain, wl_proxy_wrapper_destroy(chain->drm_wrapper); if (chain->display) - wsi_wl_display_destroy(chain->display); + wsi_wl_display_unref(chain->display); vk_free(pAllocator, chain); @@ -815,10 +834,18 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, chain->vk_format = pCreateInfo->imageFormat; chain->drm_format = wl_drm_format_for_vk_format(chain->vk_format, alpha); - chain->display = wsi_wl_display_create(wsi, surface->display); - if (!chain->display) { - result = VK_ERROR_INITIALIZATION_FAILED; - goto fail; + if (pCreateInfo->oldSwapchain) { + /* If we have an oldSwapchain parameter, copy the display struct over + * from the old one so we don't have to fully re-initialize it. + */ + struct wsi_wl_swapchain *old_chain = (void *)pCreateInfo->oldSwapchain; + chain->display = wsi_wl_display_ref(old_chain->display); + } else { + chain->display = wsi_wl_display_create(wsi, surface->display); + if (!chain->display) { + result = VK_ERROR_INITIALIZATION_FAILED; + goto fail; + } } chain->surface = wl_proxy_create_wrapper(surface->surface); commit b5a70210af8ceb7fe9f64101273c5d9d707338ea Author: Jason Ekstrand <jason.ekstr...@intel.com> Date: Tue Sep 26 08:30:22 2017 -0700 vulkan/wsi/wayland: Stop caching Wayland displays We originally implemented caching to avoid unneeded round-trips to the compositor when querying surface capabilities etc. to set up the swapchain. Unfortunately, this doesn't work if vkDestroyInstance is called after the Wayland connection has been dropped. In this case, we end up trying to clean up already destroyed wl_proxy objects which leads to crashes. In particular most of dEQP-VK.wsi.wayland is crashing thanks to this problem. This commit gets rid of the cache and simply embeds the wsi_wl_display struct in the swapchain. While we're at it, we can get rid of the wl_event_queue that we were storing in the swapchain because we can just use the one in the embedded wsi_wl_display. Reviewed-by: Daniel Stone <dani...@collabora.com> Bugzilla: https://bugs.freedesktop.org/102578 Cc: mesa-sta...@lists.freedesktop.org (cherry picked from commit 43691024982b3ea734ad001bd53cc7b563ccce5a) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 62fc97c..214a4e3 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -66,10 +66,6 @@ struct wsi_wayland { const VkAllocationCallbacks *alloc; VkPhysicalDevice physical_device; - pthread_mutex_t mutex; - /* Hash table of wl_display -> wsi_wl_display mappings */ - struct hash_table * displays; - const struct wsi_callbacks *cbs; }; @@ -148,6 +144,8 @@ static void drm_handle_format(void *data, struct wl_drm *drm, uint32_t wl_format) { struct wsi_wl_display *display = data; + if (display->formats.element_size == 0) + return; switch (wl_format) { #if 0 @@ -263,15 +261,18 @@ wsi_wl_display_finish(struct wsi_wl_display *display) static int wsi_wl_display_init(struct wsi_wayland *wsi_wl, struct wsi_wl_display *display, - struct wl_display *wl_display) + struct wl_display *wl_display, + bool get_format_list) { memset(display, 0, sizeof(*display)); display->wsi_wl = wsi_wl; display->wl_display = wl_display; - if (!u_vector_init(&display->formats, sizeof(VkFormat), 8)) - goto fail; + if (get_format_list) { + if (!u_vector_init(&display->formats, sizeof(VkFormat), 8)) + goto fail; + } display->queue = wl_display_create_queue(wl_display); if (!display->queue) @@ -327,7 +328,7 @@ wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display) if (!display) return NULL; - if (wsi_wl_display_init(wsi, display, wl_display)) { + if (wsi_wl_display_init(wsi, display, wl_display, true)) { vk_free(wsi->alloc, display); return NULL; } @@ -336,54 +337,25 @@ wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display) } static void -wsi_wl_display_destroy(struct wsi_wayland *wsi, struct wsi_wl_display *display) +wsi_wl_display_destroy(struct wsi_wl_display *display) { + struct wsi_wayland *wsi = display->wsi_wl; wsi_wl_display_finish(display); vk_free(wsi->alloc, display); } -static struct wsi_wl_display * -wsi_wl_get_display(struct wsi_device *wsi_device, - struct wl_display *wl_display) +VkBool32 +wsi_wl_get_presentation_support(struct wsi_device *wsi_device, + struct wl_display *wl_display) { struct wsi_wayland *wsi = (struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND]; - pthread_mutex_lock(&wsi->mutex); - - struct hash_entry *entry = _mesa_hash_table_search(wsi->displays, - wl_display); - if (!entry) { - /* We're about to make a bunch of blocking calls. Let's drop the - * mutex for now so we don't block up too badly. - */ - pthread_mutex_unlock(&wsi->mutex); - - struct wsi_wl_display *display = wsi_wl_display_create(wsi, wl_display); - if (!display) - return NULL; - - pthread_mutex_lock(&wsi->mutex); - - entry = _mesa_hash_table_search(wsi->displays, wl_display); - if (entry) { - /* Oops, someone raced us to it */ - wsi_wl_display_destroy(wsi, display); - } else { - entry = _mesa_hash_table_insert(wsi->displays, wl_display, display); - } - } - - pthread_mutex_unlock(&wsi->mutex); - - return entry->data; -} + struct wsi_wl_display display; + int ret = wsi_wl_display_init(wsi, &display, wl_display, false); + wsi_wl_display_finish(&display); -VkBool32 -wsi_wl_get_presentation_support(struct wsi_device *wsi_device, - struct wl_display *wl_display) -{ - return wsi_wl_get_display(wsi_device, wl_display) != NULL; + return ret == 0; } static VkResult @@ -457,21 +429,25 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface, VkSurfaceFormatKHR* pSurfaceFormats) { VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface; - struct wsi_wl_display *display = - wsi_wl_get_display(wsi_device, surface->display); - if (!display) - return VK_ERROR_OUT_OF_HOST_MEMORY; + struct wsi_wayland *wsi = + (struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND]; + + struct wsi_wl_display display; + if (wsi_wl_display_init(wsi, &display, surface->display, true)) + return VK_ERROR_SURFACE_LOST_KHR; VK_OUTARRAY_MAKE(out, pSurfaceFormats, pSurfaceFormatCount); VkFormat *disp_fmt; - u_vector_foreach(disp_fmt, &display->formats) { + u_vector_foreach(disp_fmt, &display.formats) { vk_outarray_append(&out, out_fmt) { out_fmt->format = *disp_fmt; out_fmt->colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; } } + wsi_wl_display_finish(&display); + return vk_outarray_status(&out); } @@ -483,21 +459,25 @@ wsi_wl_surface_get_formats2(VkIcdSurfaceBase *icd_surface, VkSurfaceFormat2KHR* pSurfaceFormats) { VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface; - struct wsi_wl_display *display = - wsi_wl_get_display(wsi_device, surface->display); - if (!display) - return VK_ERROR_OUT_OF_HOST_MEMORY; + struct wsi_wayland *wsi = + (struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND]; + + struct wsi_wl_display display; + if (wsi_wl_display_init(wsi, &display, surface->display, true)) + return VK_ERROR_SURFACE_LOST_KHR; VK_OUTARRAY_MAKE(out, pSurfaceFormats, pSurfaceFormatCount); VkFormat *disp_fmt; - u_vector_foreach(disp_fmt, &display->formats) { + u_vector_foreach(disp_fmt, &display.formats) { vk_outarray_append(&out, out_fmt) { out_fmt->surfaceFormat.format = *disp_fmt; out_fmt->surfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; } }