zink: split surface creation more to allow disabling caching
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14541>
This commit is contained in:
parent
e37f33cc8d
commit
820077acdb
|
@ -122,7 +122,8 @@ static struct zink_surface *
|
|||
create_surface(struct pipe_context *pctx,
|
||||
struct pipe_resource *pres,
|
||||
const struct pipe_surface *templ,
|
||||
VkImageViewCreateInfo *ivci)
|
||||
VkImageViewCreateInfo *ivci,
|
||||
bool actually)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(pctx->screen);
|
||||
struct zink_resource *res = zink_resource(pres);
|
||||
|
@ -163,6 +164,9 @@ create_surface(struct pipe_context *pctx,
|
|||
|
||||
init_surface_info(surface, res, ivci);
|
||||
|
||||
if (!actually)
|
||||
return surface;
|
||||
assert(ivci->image);
|
||||
if (VKSCR(CreateImageView)(screen->dev, ivci, NULL,
|
||||
&surface->image_view) != VK_SUCCESS) {
|
||||
mesa_loge("ZINK: vkCreateImageView failed");
|
||||
|
@ -179,6 +183,17 @@ hash_ivci(const void *key)
|
|||
return _mesa_hash_data((char*)key + offsetof(VkImageViewCreateInfo, flags), sizeof(VkImageViewCreateInfo) - offsetof(VkImageViewCreateInfo, flags));
|
||||
}
|
||||
|
||||
static struct zink_surface *
|
||||
do_create_surface(struct pipe_context *pctx, struct pipe_resource *pres, const struct pipe_surface *templ, VkImageViewCreateInfo *ivci, uint32_t hash, bool actually)
|
||||
{
|
||||
/* create a new surface */
|
||||
struct zink_surface *surface = create_surface(pctx, pres, templ, ivci, actually);
|
||||
surface->base.nr_samples = 0;
|
||||
surface->hash = hash;
|
||||
surface->ivci = *ivci;
|
||||
return surface;
|
||||
}
|
||||
|
||||
struct pipe_surface *
|
||||
zink_get_surface(struct zink_context *ctx,
|
||||
struct pipe_resource *pres,
|
||||
|
@ -194,10 +209,7 @@ zink_get_surface(struct zink_context *ctx,
|
|||
|
||||
if (!entry) {
|
||||
/* create a new surface */
|
||||
surface = create_surface(&ctx->base, pres, templ, ivci);
|
||||
surface->base.nr_samples = 0;
|
||||
surface->hash = hash;
|
||||
surface->ivci = *ivci;
|
||||
surface = do_create_surface(&ctx->base, pres, templ, ivci, hash, true);
|
||||
entry = _mesa_hash_table_insert_pre_hashed(&res->surface_cache, hash, &surface->ivci, surface);
|
||||
if (!entry) {
|
||||
simple_mtx_unlock(&res->surface_mtx);
|
||||
|
@ -252,7 +264,7 @@ zink_create_surface(struct pipe_context *pctx,
|
|||
if (!transient)
|
||||
return NULL;
|
||||
ivci.image = transient->obj->image;
|
||||
csurf->transient = (struct zink_ctx_surface*)wrap_surface(pctx, (struct pipe_surface*)create_surface(pctx, &transient->base.b, templ, &ivci));
|
||||
csurf->transient = (struct zink_ctx_surface*)wrap_surface(pctx, (struct pipe_surface*)create_surface(pctx, &transient->base.b, templ, &ivci, true));
|
||||
if (!csurf->transient) {
|
||||
pipe_resource_reference((struct pipe_resource**)&transient, NULL);
|
||||
pipe_surface_release(pctx, &psurf);
|
||||
|
|
Loading…
Reference in New Issue