Module: Mesa Branch: staging/22.3 Commit: 9318af77dccdc4741752c1420cc6270910f25a80 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9318af77dccdc4741752c1420cc6270910f25a80
Author: SoroushIMG <[email protected]> Date: Sun Feb 5 14:18:16 2023 +0000 zink: clear null image surfaces to 0 GL Spec says that imageLoad from incomplete images must return 0. This is not really spec compliant as for proper behavior nullDescriptor and robustImageAccess2 is needed. A workaround for lack of either of these requires a shader variant. Clearing the null surface and hoping the app doesn't write to the image is closer to spec, while avoiding a shader recompile. KHR-GL46.shader_image_load_store.incomplete_textures tests this. cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21135> (cherry picked from commit 22e91af1a77361249b9c71ee609b67ec187e612c) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_context.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 89c60a98678..d55aa3ee2b3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -292,7 +292,7 @@ "description": "zink: clear null image surfaces to 0", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 3360ae9dea5..ba11566675f 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -4685,6 +4685,13 @@ zink_get_dummy_pipe_surface(struct zink_context *ctx, int samples_index) { if (!ctx->dummy_surface[samples_index]) { ctx->dummy_surface[samples_index] = zink_surface_create_null(ctx, PIPE_TEXTURE_2D, 1024, 1024, BITFIELD_BIT(samples_index)); + /* This is possibly used with imageLoad which according to GL spec must return 0 */ + if (!samples_index) { + union pipe_color_union color = {0}; + struct pipe_box box; + u_box_2d(0, 0, 1024, 1024, &box); + ctx->base.clear_texture(&ctx->base, ctx->dummy_surface[samples_index]->texture, 0, &box, &color); + } } return ctx->dummy_surface[samples_index]; }
