zink: add a util function to create a null surface

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:42:53 -04:00
committed by Marge Bot
parent b090ad574d
commit 83afe211ec
2 changed files with 29 additions and 0 deletions
+26
View File
@@ -282,6 +282,32 @@ zink_rebind_surface(struct zink_context *ctx, struct pipe_surface **psurface)
return true;
}
struct pipe_surface *
zink_surface_create_null(struct zink_context *ctx, enum pipe_texture_target target, unsigned width, unsigned height, unsigned samples)
{
struct pipe_surface surf_templ = {};
struct pipe_resource *pres;
struct pipe_resource templ = {};
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
templ.format = PIPE_FORMAT_R8_UINT;
templ.target = target;
templ.bind = PIPE_BIND_RENDER_TARGET;
templ.nr_samples = samples;
pres = ctx->base.screen->resource_create(ctx->base.screen, &templ);
if (!pres)
return NULL;
surf_templ.format = PIPE_FORMAT_R8_UINT;
surf_templ.nr_samples = samples;
struct pipe_surface *psurf = ctx->base.create_surface(&ctx->base, pres, &surf_templ);
pipe_resource_reference(&pres, NULL);
return psurf;
}
void
zink_context_surface_init(struct pipe_context *context)
{
+3
View File
@@ -99,4 +99,7 @@ zink_surface_clamp_viewtype(VkImageViewType viewType, unsigned first_layer, unsi
bool
zink_rebind_surface(struct zink_context *ctx, struct pipe_surface **psurface);
struct pipe_surface *
zink_surface_create_null(struct zink_context *ctx, enum pipe_texture_target target, unsigned width, unsigned height, unsigned samples);
#endif