zink: create dummy surface/bufferview for null descriptor use

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11122>
This commit is contained in:
Mike Blumenkrantz 2021-03-25 15:55:33 -04:00 committed by Marge Bot
parent b897012054
commit 7ed9919e95
2 changed files with 12 additions and 1 deletions

View file

@ -95,6 +95,9 @@ zink_context_destroy(struct pipe_context *pctx)
pipe_resource_reference(&ctx->dummy_vertex_buffer, NULL);
pipe_resource_reference(&ctx->dummy_xfb_buffer, NULL);
zink_surface_reference(screen, (struct zink_surface**)&ctx->dummy_surface, NULL);
zink_buffer_view_reference(screen, &ctx->dummy_bufferview, NULL);
if (ctx->tc)
util_queue_destroy(&ctx->batch.flush_queue);
@ -3364,13 +3367,19 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
const uint8_t data[] = { 0 };
ctx->dummy_vertex_buffer = pipe_buffer_create_with_data(&ctx->base,
PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_IMMUTABLE, sizeof(data), data);
PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_SHADER_IMAGE, PIPE_USAGE_IMMUTABLE, sizeof(data), data);
if (!ctx->dummy_vertex_buffer)
goto fail;
ctx->dummy_xfb_buffer = pipe_buffer_create_with_data(&ctx->base,
PIPE_BIND_STREAM_OUTPUT, PIPE_USAGE_DEFAULT, sizeof(data), data);
if (!ctx->dummy_xfb_buffer)
goto fail;
ctx->dummy_surface = zink_surface_create_null(ctx, PIPE_TEXTURE_2D, 1, 1, 1);
if (!ctx->dummy_surface)
goto fail;
ctx->dummy_bufferview = get_buffer_view(ctx, zink_resource(ctx->dummy_vertex_buffer), PIPE_FORMAT_R8_UNORM, 0, sizeof(data));
if (!ctx->dummy_bufferview)
goto fail;
if (!zink_descriptor_layouts_init(ctx))
goto fail;

View file

@ -231,6 +231,8 @@ struct zink_context {
struct pipe_resource *dummy_vertex_buffer;
struct pipe_resource *dummy_xfb_buffer;
struct pipe_surface *dummy_surface;
struct zink_buffer_view *dummy_bufferview;
struct {
/* descriptor info */