Mesa (main): zink: add a util function to create a null surface
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 2 17:14:01 UTC 2021
Module: Mesa
Branch: main
Commit: 83afe211ecea09909e8b2825d8852a0630fc69c3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=83afe211ecea09909e8b2825d8852a0630fc69c3
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Mar 25 15:42:53 2021 -0400
zink: add a util function to create a null surface
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11122>
---
src/gallium/drivers/zink/zink_surface.c | 26 ++++++++++++++++++++++++++
src/gallium/drivers/zink/zink_surface.h | 3 +++
2 files changed, 29 insertions(+)
diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c
index e61ccb2f3dd..b64316a9759 100644
--- a/src/gallium/drivers/zink/zink_surface.c
+++ b/src/gallium/drivers/zink/zink_surface.c
@@ -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)
{
diff --git a/src/gallium/drivers/zink/zink_surface.h b/src/gallium/drivers/zink/zink_surface.h
index 4f29509835e..87d6fc6fa50 100644
--- a/src/gallium/drivers/zink/zink_surface.h
+++ b/src/gallium/drivers/zink/zink_surface.h
@@ -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
More information about the mesa-commit
mailing list