From ae369e9f6d4f2c826f1f2a748c32a14f9d5f1f54 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 26 Apr 2022 11:07:23 -0400 Subject: [PATCH] zink: fix null buffer/surface formats 4-component formats are needed here in order to return the correct alpha value in invalid load scenarios cc: mesa-stable fixes: spec@arb_shader_image_load_store@invalid Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/ci/zink-lvp-fails.txt | 4 ---- src/gallium/drivers/zink/zink_context.c | 6 +++--- src/gallium/drivers/zink/zink_surface.c | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/zink/ci/zink-lvp-fails.txt b/src/gallium/drivers/zink/ci/zink-lvp-fails.txt index 0f83c789215..5f8fa812874 100644 --- a/src/gallium/drivers/zink/ci/zink-lvp-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-lvp-fails.txt @@ -343,9 +343,6 @@ spec@arb_shader_image_load_store@early-z@occlusion query test/early-z pass,Fail spec@arb_shader_image_load_store@execution@image-array-out-of-bounds-access-load,Crash spec@arb_shader_image_load_store@execution@image-array-out-of-bounds-access-store,Crash -spec@arb_shader_image_load_store@invalid,Fail -spec@arb_shader_image_load_store@invalid@imageLoad/incompatible format test/imageBuffer,Fail - spec@arb_tessellation_shader@execution@tcs-tes-levels-out-of-bounds-read,Crash spec@arb_tessellation_shader@execution@tcs-tes-levels-out-of-bounds-write,Crash @@ -354,7 +351,6 @@ spec@khr_texture_compression_astc@array-gles@12x12 Block Dim,Fail spec@khr_texture_compression_astc@array-gles@5x5 Block Dim,Fail spec@oes_egl_image_external_essl3@oes_egl_image_external_essl3,Fail spec@oes_egl_image_external_essl3@oes_egl_image_external_essl3@oes_egl_image_external_essl3_imageLoad,Fail -spec@oes_egl_image_external_essl3@oes_egl_image_external_essl3@oes_egl_image_external_essl3_imageStore,Fail #literally no driver can pass these diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 1364a77f019..0e1fd2af5c7 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -2034,7 +2034,7 @@ get_render_pass(struct zink_context *ctx) state.msaa_expand_mask |= BITFIELD_BIT(i); } } else { - state.rts[i].format = VK_FORMAT_R8_UINT; + state.rts[i].format = VK_FORMAT_R8G8B8A8_UNORM; state.rts[i].samples = fb->samples; } state.num_rts++; @@ -4321,7 +4321,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) if (!ctx->render_pass_cache) goto fail; - const uint8_t data[] = {0}; + const uint32_t data[] = {0}; ctx->dummy_vertex_buffer = pipe_buffer_create(&screen->base, PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_SHADER_IMAGE, PIPE_USAGE_IMMUTABLE, sizeof(data)); if (!ctx->dummy_vertex_buffer) @@ -4337,7 +4337,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) if (!ctx->dummy_surface[i]) goto fail; } - VkBufferViewCreateInfo bvci = create_bvci(ctx, zink_resource(ctx->dummy_vertex_buffer), PIPE_FORMAT_R8_UNORM, 0, sizeof(data)); + VkBufferViewCreateInfo bvci = create_bvci(ctx, zink_resource(ctx->dummy_vertex_buffer), PIPE_FORMAT_R8G8B8A8_UNORM, 0, sizeof(data)); ctx->dummy_bufferview = get_buffer_view(ctx, zink_resource(ctx->dummy_vertex_buffer), &bvci); if (!ctx->dummy_bufferview) goto fail; diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c index daddb0c9242..c7491dcc622 100644 --- a/src/gallium/drivers/zink/zink_surface.c +++ b/src/gallium/drivers/zink/zink_surface.c @@ -394,7 +394,7 @@ zink_surface_create_null(struct zink_context *ctx, enum pipe_texture_target targ templ.width0 = width; templ.height0 = height; templ.depth0 = 1; - templ.format = PIPE_FORMAT_R8_UINT; + templ.format = PIPE_FORMAT_R8G8B8A8_UNORM; templ.target = target; templ.bind = PIPE_BIND_RENDER_TARGET; templ.nr_samples = samples; @@ -403,7 +403,7 @@ zink_surface_create_null(struct zink_context *ctx, enum pipe_texture_target targ if (!pres) return NULL; - surf_templ.format = PIPE_FORMAT_R8_UINT; + surf_templ.format = PIPE_FORMAT_R8G8B8A8_UNORM; surf_templ.nr_samples = 0; struct pipe_surface *psurf = ctx->base.create_surface(&ctx->base, pres, &surf_templ); pipe_resource_reference(&pres, NULL);