+ int i;
+ uint32_t num_atts = num_color_atts + 1;
+ bool has_layout = depth_att->props.in_layout !=
+ VK_IMAGE_LAYOUT_UNDEFINED;
+
+ att_dsc = malloc(num_atts * sizeof att_dsc[0]);
+ att_rfc = malloc(num_atts * sizeof att_rfc[0]);
+
+ memset(att_dsc, 0, num_atts * sizeof att_dsc[0]);
+ memset(att_rfc, 0, num_atts * sizeof att_rfc[0]);
+
+ /* color attachments description (we can have many) */
+ for (i = 0; i < num_color_atts; i++) {
+ att_dsc[i].samples = get_num_samples(color_atts[i].props.num_samples);
+ att_dsc[i].initialLayout = color_atts[i].props.in_layout;
+ att_dsc[i].finalLayout = color_atts[i].props.end_layout;
+ att_dsc[i].format = color_atts[i].props.format;
+
+ att_dsc[i].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
+ att_dsc[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+ att_dsc[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
+ att_dsc[i].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
+
+ att_rfc[i].attachment = i;
+ att_rfc[i].layout = color_atts[i].props.tiling != VK_IMAGE_TILING_OPTIMAL ?
+ VK_IMAGE_LAYOUT_GENERAL :
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+
+ }
+
+ /* depth attachment description (we can have only one) */
+ att_dsc[num_color_atts].samples = get_num_samples(depth_att->props.num_samples);
+ att_dsc[num_color_atts].initialLayout = depth_att->props.in_layout;
+ att_dsc[num_color_atts].finalLayout = depth_att->props.end_layout;
+ att_dsc[num_color_atts].format = depth_att->props.format;
+ /* we might want to reuse the depth buffer when it's filled */
+ att_dsc[num_color_atts].loadOp = has_layout ?
+ VK_ATTACHMENT_LOAD_OP_LOAD :
+ VK_ATTACHMENT_LOAD_OP_CLEAR;
+ att_dsc[num_color_atts].stencilLoadOp = has_layout ?
+ VK_ATTACHMENT_LOAD_OP_LOAD :
+ VK_ATTACHMENT_LOAD_OP_CLEAR;
+ att_dsc[num_color_atts].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
+ att_rfc[num_color_atts].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ att_rfc[num_color_atts].attachment = num_color_atts;