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,
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);