mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-09 07:58:16 +02:00
zink: break out VkImageViewUsageCreateInfo applying for reuse
no functional changes cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22713>
This commit is contained in:
parent
c39a2d67ea
commit
792c2956ac
1 changed files with 24 additions and 18 deletions
|
|
@ -141,6 +141,29 @@ init_pipe_surface_info(struct pipe_context *pctx, struct pipe_surface *psurf, co
|
|||
psurf->u.tex.last_layer = templ->u.tex.last_layer;
|
||||
}
|
||||
|
||||
static void
|
||||
apply_view_usage_for_format(struct zink_screen *screen, struct zink_resource *res, struct zink_surface *surface, enum pipe_format format, VkImageViewCreateInfo *ivci)
|
||||
{
|
||||
VkFormatFeatureFlags feats = res->linear ?
|
||||
screen->format_props[format].linearTilingFeatures :
|
||||
screen->format_props[format].optimalTilingFeatures;
|
||||
VkImageUsageFlags attachment = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
|
||||
surface->usage_info.usage = res->obj->vkusage & ~attachment;
|
||||
if (res->obj->modifier_aspect) {
|
||||
feats = res->obj->vkfeats;
|
||||
/* intersect format features for current modifier */
|
||||
for (unsigned i = 0; i < screen->modifier_props[format].drmFormatModifierCount; i++) {
|
||||
if (res->obj->modifier == screen->modifier_props[format].pDrmFormatModifierProperties[i].drmFormatModifier)
|
||||
feats &= screen->modifier_props[format].pDrmFormatModifierProperties[i].drmFormatModifierTilingFeatures;
|
||||
}
|
||||
}
|
||||
/* if the format features don't support framebuffer attachment, use VkImageViewUsageCreateInfo to remove it */
|
||||
if ((res->obj->vkusage & attachment) &&
|
||||
!(feats & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))) {
|
||||
ivci->pNext = &surface->usage_info;
|
||||
}
|
||||
}
|
||||
|
||||
static struct zink_surface *
|
||||
create_surface(struct pipe_context *pctx,
|
||||
struct pipe_resource *pres,
|
||||
|
|
@ -157,24 +180,7 @@ create_surface(struct pipe_context *pctx,
|
|||
|
||||
surface->usage_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO;
|
||||
surface->usage_info.pNext = NULL;
|
||||
VkFormatFeatureFlags feats = res->linear ?
|
||||
screen->format_props[templ->format].linearTilingFeatures :
|
||||
screen->format_props[templ->format].optimalTilingFeatures;
|
||||
VkImageUsageFlags attachment = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
|
||||
surface->usage_info.usage = res->obj->vkusage & ~attachment;
|
||||
if (res->obj->modifier_aspect) {
|
||||
feats = res->obj->vkfeats;
|
||||
/* intersect format features for current modifier */
|
||||
for (unsigned i = 0; i < screen->modifier_props[templ->format].drmFormatModifierCount; i++) {
|
||||
if (res->obj->modifier == screen->modifier_props[templ->format].pDrmFormatModifierProperties[i].drmFormatModifier)
|
||||
feats &= screen->modifier_props[templ->format].pDrmFormatModifierProperties[i].drmFormatModifierTilingFeatures;
|
||||
}
|
||||
}
|
||||
/* if the format features don't support framebuffer attachment, use VkImageViewUsageCreateInfo to remove it */
|
||||
if ((res->obj->vkusage & attachment) &&
|
||||
!(feats & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))) {
|
||||
ivci->pNext = &surface->usage_info;
|
||||
}
|
||||
apply_view_usage_for_format(screen, res, surface, templ->format, ivci);
|
||||
|
||||
pipe_resource_reference(&surface->base.texture, pres);
|
||||
pipe_reference_init(&surface->base.reference, 1);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue