update vulkan.h for multi-pass command buffers (V131, #14075)

Minimal changes to keep everything building and functioning.

TODO: Need to port draw_state to use new VkAttachmentView structure.
diff --git a/icd/intel/cmd_meta.c b/icd/intel/cmd_meta.c
index 32490b7..bb76e42 100644
--- a/icd/intel/cmd_meta.c
+++ b/icd/intel/cmd_meta.c
@@ -254,19 +254,19 @@
                                      uint32_t lod, uint32_t layer,
                                      struct intel_cmd_meta *meta)
 {
-    VkColorAttachmentViewCreateInfo info;
+    VkAttachmentViewCreateInfo info;
     struct intel_att_view *view;
     VkResult ret;
 
     memset(&info, 0, sizeof(info));
-    info.sType = VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO;
+    info.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO;
     info.image = (VkImage) img;
     info.format = format;
     info.mipLevel = lod;
     info.baseArraySlice = layer;
     info.arraySize = 1;
 
-    ret = intel_att_view_create_for_color(cmd->dev, &info, &view);
+    ret = intel_att_view_create(cmd->dev, &info, &view);
     if (ret != VK_SUCCESS) {
         cmd_fail(cmd, ret);
         return;
@@ -322,18 +322,18 @@
                                  uint32_t lod, uint32_t layer,
                                  struct intel_cmd_meta *meta)
 {
-    VkDepthStencilViewCreateInfo info;
+    VkAttachmentViewCreateInfo info;
     struct intel_att_view *view;
     VkResult ret;
 
     memset(&info, 0, sizeof(info));
-    info.sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO;
+    info.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO;
     info.image = (VkImage) img;
     info.mipLevel = lod;
     info.baseArraySlice = layer;
     info.arraySize = 1;
 
-    ret = intel_att_view_create_for_ds(cmd->dev, &info, &view);
+    ret = intel_att_view_create(cmd->dev, &info, &view);
     if (ret != VK_SUCCESS) {
         cmd_fail(cmd, ret);
         return;
diff --git a/icd/intel/cmd_pipeline.c b/icd/intel/cmd_pipeline.c
index 0bcca0f..6474f8d 100644
--- a/icd/intel/cmd_pipeline.c
+++ b/icd/intel/cmd_pipeline.c
@@ -2017,16 +2017,13 @@
 
 static void emit_msaa(struct intel_cmd *cmd)
 {
-    const struct intel_fb *fb = cmd->bind.fb;
+    const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
 
     if (!cmd->bind.render_pass_changed)
         return;
 
-    if (fb->sample_count != cmd->bind.pipeline.graphics->sample_count)
-        cmd->result = VK_ERROR_UNKNOWN;
-
     cmd_wa_gen6_pre_multisample_depth_flush(cmd);
-    gen6_3DSTATE_MULTISAMPLE(cmd, fb->sample_count);
+    gen6_3DSTATE_MULTISAMPLE(cmd, pipeline->sample_count);
 }
 
 static void emit_rt(struct intel_cmd *cmd)
@@ -3623,8 +3620,9 @@
 }
 
 ICD_EXPORT void VKAPI vkCmdBeginRenderPass(
-    VkCmdBuffer                              cmdBuffer,
-    const VkRenderPassBegin*                pRenderPassBegin)
+    VkCmdBuffer                                 cmdBuffer,
+    const VkRenderPassBeginInfo*                pRenderPassBegin,
+    VkRenderPassContents                        contents)
 {
     struct intel_cmd *cmd = intel_cmd(cmdBuffer);
     const struct intel_render_pass *rp =
@@ -3638,10 +3636,12 @@
         return;
     }
 
-    cmd_begin_render_pass(cmd, rp, fb, pRenderPassBegin->contents);
+    cmd_begin_render_pass(cmd, rp, fb, contents);
 
     for (i = 0; i < rp->attachment_count; i++) {
         const struct intel_render_pass_attachment *att = &rp->attachments[i];
+        const VkClearValue *clear_val =
+            &pRenderPassBegin->pAttachmentClearValues[i];
         VkImageSubresourceRange range;
 
         if (!att->clear_on_load)
@@ -3657,13 +3657,13 @@
             range.aspect = VK_IMAGE_ASPECT_COLOR;
 
             cmd_meta_clear_color_image(cmdBuffer, (VkImage) view->img,
-                    att->initial_layout, &att->clear_val.color, 1, &range);
+                    att->initial_layout, &clear_val->color, 1, &range);
         } else {
             range.aspect = VK_IMAGE_ASPECT_DEPTH;
 
             cmd_meta_clear_depth_stencil_image(cmdBuffer,
                     (VkImage) view->img, att->initial_layout,
-                    att->clear_val.ds.depth, att->clear_val.ds.stencil,
+                    clear_val->ds.depth, clear_val->ds.stencil,
                     1, &range);
 
             if (att->stencil_clear_on_load) {
@@ -3671,13 +3671,31 @@
 
                 cmd_meta_clear_depth_stencil_image(cmdBuffer,
                         (VkImage) view->img, att->initial_layout,
-                        att->clear_val.ds.depth, att->clear_val.ds.stencil,
+                        clear_val->ds.depth, clear_val->ds.stencil,
                         1, &range);
             }
         }
     }
 }
 
+ICD_EXPORT void VKAPI vkCmdNextSubpass(
+    VkCmdBuffer                                 cmdBuffer,
+    VkRenderPassContents                        contents)
+{
+    struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+    const struct intel_render_pass *rp = cmd->bind.render_pass;
+
+   if (cmd->bind.render_pass_subpass >= rp->subpasses +
+           rp->subpass_count - 1) {
+       cmd->result = VK_ERROR_UNKNOWN;
+       return;
+   }
+
+   cmd->bind.render_pass_changed = true;
+   cmd->bind.render_pass_subpass++;
+   cmd->bind.render_pass_contents = contents;
+}
+
 ICD_EXPORT void VKAPI vkCmdEndRenderPass(
     VkCmdBuffer                              cmdBuffer)
 {
diff --git a/icd/intel/fb.c b/icd/intel/fb.c
index 0b0f934..51eece5 100644
--- a/icd/intel/fb.c
+++ b/icd/intel/fb.c
@@ -37,24 +37,18 @@
 }
 
 VkResult intel_fb_create(struct intel_dev *dev,
-                           const VkFramebufferCreateInfo *info,
-                           struct intel_fb **fb_ret)
+                         const VkFramebufferCreateInfo *info,
+                         struct intel_fb **fb_ret)
 {
     struct intel_fb *fb;
     uint32_t width, height, array_size, i;
 
-    if (info->colorAttachmentCount > INTEL_MAX_RENDER_TARGETS)
-        return VK_ERROR_INVALID_VALUE;
-
     fb = (struct intel_fb *) intel_base_create(&dev->base.handle,
             sizeof(*fb), dev->base.dbg, VK_OBJECT_TYPE_FRAMEBUFFER, info, 0);
     if (!fb)
         return VK_ERROR_OUT_OF_HOST_MEMORY;
 
-    fb->view_count = info->colorAttachmentCount;
-    if (info->pDepthStencilAttachment)
-        fb->view_count++;
-
+    fb->view_count = info->attachmentCount;
     fb->views = intel_alloc(fb, sizeof(fb->views[0]) * fb->view_count, 0,
             VK_SYSTEM_ALLOC_TYPE_INTERNAL);
     if (!fb->views) {
@@ -66,10 +60,9 @@
     height = info->height;
     array_size = info->layers;
 
-    for (i = 0; i < info->colorAttachmentCount; i++) {
-        const VkColorAttachmentBindInfo *att = &info->pColorAttachments[i];
-        const struct intel_att_view *view =
-            intel_att_view_from_color(att->view);
+    for (i = 0; i < info->attachmentCount; i++) {
+        const VkAttachmentBindInfo *att = &info->pAttachments[i];
+        const struct intel_att_view *view = intel_att_view(att->view);
         const struct intel_layout *layout = &view->img->layout;
 
         if (width > layout->width0)
@@ -79,41 +72,13 @@
         if (array_size > view->array_size)
             array_size = view->array_size;
 
-        if (view->img->samples != info->sampleCount) {
-            intel_fb_destroy(fb);
-            return VK_ERROR_INVALID_VALUE;
-        }
-
         fb->views[i] = view;
     }
 
-    if (info->pDepthStencilAttachment) {
-        const VkDepthStencilBindInfo *att = info->pDepthStencilAttachment;
-        const struct intel_att_view *view = intel_att_view_from_ds(att->view);
-        const struct intel_layout *layout = &view->img->layout;
-
-        if (width > layout->width0)
-            width = layout->width0;
-        if (height > layout->height0)
-            height = layout->height0;
-        if (array_size > view->array_size)
-            array_size = view->array_size;
-
-        if (view->img->samples != info->sampleCount) {
-            intel_fb_destroy(fb);
-            return VK_ERROR_INVALID_VALUE;
-        }
-
-        fb->views[info->colorAttachmentCount] = view;
-    }
-
     fb->width = width;
     fb->height = height;
     fb->array_size = array_size;
 
-    /* This information must match pipeline state */
-    fb->sample_count = info->sampleCount;
-
     fb->obj.destroy = fb_destroy;
 
     *fb_ret = fb;
@@ -142,16 +107,17 @@
     struct intel_render_pass *rp;
     uint32_t i;
 
+    /* TODO */
+    if (info->dependencyCount)
+	    return VK_ERROR_UNKNOWN;
+
     rp = (struct intel_render_pass *) intel_base_create(&dev->base.handle,
             sizeof(*rp), dev->base.dbg, VK_OBJECT_TYPE_RENDER_PASS, info, 0);
     if (!rp)
         return VK_ERROR_OUT_OF_HOST_MEMORY;
 
-    rp->attachment_count = info->colorAttachmentCount;
-    if (info->depthStencilFormat != VK_FORMAT_UNDEFINED)
-        rp->attachment_count++;
-
-    rp->subpass_count = 1;
+    rp->attachment_count = info->attachmentCount;
+    rp->subpass_count = info->subpassCount;
 
     rp->attachments = intel_alloc(rp,
             sizeof(rp->attachments[0]) * rp->attachment_count +
@@ -167,66 +133,55 @@
 
     rp->obj.destroy = render_pass_destroy;
 
-    for (i = 0; i < info->colorAttachmentCount; i++) {
+    for (i = 0; i < info->attachmentCount; i++) {
         struct intel_render_pass_attachment *att = &rp->attachments[i];
 
-        att->format = info->pColorFormats[i];
-        att->sample_count = info->sampleCount;
-        att->initial_layout = info->pColorLayouts[i];
-        att->final_layout = info->pColorLayouts[i];
+        att->format = info->pAttachments[i].format;
+        att->sample_count = info->pAttachments[i].samples;
+        att->initial_layout = info->pAttachments[i].initialLayout;
+        att->final_layout = info->pAttachments[i].finalLayout;
 
-        att->clear_on_load =
-            (info->pColorLoadOps[i] == VK_ATTACHMENT_LOAD_OP_CLEAR);
-        att->disable_store =
-            (info->pColorStoreOps[i] == VK_ATTACHMENT_STORE_OP_DONT_CARE);
+        att->clear_on_load = (info->pAttachments[i].loadOp ==
+                VK_ATTACHMENT_LOAD_OP_CLEAR);
+        att->disable_store = (info->pAttachments[i].storeOp ==
+                VK_ATTACHMENT_STORE_OP_DONT_CARE);
 
-        att->stencil_clear_on_load = false;
-        att->stencil_disable_store = true;
-
-        att->clear_val.color = info->pColorLoadClearValues[i];
-    }
-
-    if (info->depthStencilFormat != VK_FORMAT_UNDEFINED) {
-        struct intel_render_pass_attachment *att =
-            &rp->attachments[info->colorAttachmentCount];
-
-        att->format = info->depthStencilFormat;
-        att->sample_count = info->sampleCount;
-        att->initial_layout = info->depthStencilLayout;
-        att->final_layout = info->depthStencilLayout;
-
-        att->clear_on_load =
-            (info->depthLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR);
-        att->disable_store =
-            (info->depthStoreOp == VK_ATTACHMENT_STORE_OP_DONT_CARE);
-
-        att->stencil_clear_on_load =
-            (info->stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR);
-        att->stencil_disable_store =
-            (info->stencilStoreOp == VK_ATTACHMENT_STORE_OP_DONT_CARE);
-
-        att->clear_val.ds.depth = info->depthLoadClearValue;
-        att->clear_val.ds.stencil = info->stencilLoadClearValue;
+        att->stencil_clear_on_load = (info->pAttachments[i].stencilLoadOp ==
+                VK_ATTACHMENT_LOAD_OP_CLEAR);
+        att->stencil_disable_store = (info->pAttachments[i].stencilStoreOp ==
+                VK_ATTACHMENT_STORE_OP_DONT_CARE);
     }
 
     for (i = 0; i < rp->subpass_count; i++) {
+        const VkSubpassDescription *subpass_info = &info->pSubpasses[i];
         struct intel_render_pass_subpass *subpass = &rp->subpasses[i];
         uint32_t j;
 
-        for (j = 0; j < info->colorAttachmentCount; j++) {
-            subpass->color_indices[j] = j;
-            subpass->resolve_indices[j] = 0xffffffffu;
-            subpass->color_layouts[j] = info->pColorLayouts[j];
+	/* missing SPIR support? */
+	if (subpass_info->inputCount) {
+		intel_render_pass_destroy(rp);
+		return VK_ERROR_UNKNOWN;
+	}
+
+        for (j = 0; j < subpass_info->colorCount; j++) {
+            const VkAttachmentReference *color_ref =
+                &subpass_info->colorAttachments[j];
+            const VkAttachmentReference *resolve_ref =
+                (subpass_info->resolveAttachments) ?
+                &subpass_info->resolveAttachments[j] : NULL;
+
+            subpass->color_indices[j] = color_ref->attachment;
+            subpass->resolve_indices[j] = (resolve_ref) ?
+                resolve_ref->attachment : VK_ATTACHMENT_UNUSED;
+            subpass->color_layouts[j] = color_ref->layout;
         }
 
-        subpass->color_count = info->colorAttachmentCount;
+        subpass->color_count = subpass_info->colorCount;
 
-        subpass->ds_index =
-            (info->depthStencilFormat != VK_FORMAT_UNDEFINED) ?
-            info->colorAttachmentCount : 0xffffffffu;
-        subpass->ds_layout = info->depthStencilLayout;
+        subpass->ds_index = subpass_info->depthStencilAttachment.attachment;
+        subpass->ds_layout = subpass_info->depthStencilAttachment.layout;
 
-        switch (info->depthStencilLayout) {
+        switch (subpass->ds_layout) {
         case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
         case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
             subpass->ds_optimal = true;
diff --git a/icd/intel/fb.h b/icd/intel/fb.h
index 3fc18bf..d786eb7 100644
--- a/icd/intel/fb.h
+++ b/icd/intel/fb.h
@@ -35,7 +35,6 @@
     const struct intel_att_view **views;
     uint32_t view_count;
 
-    uint32_t sample_count;
     uint32_t width;
     uint32_t height;
     uint32_t array_size;
@@ -53,14 +52,6 @@
 
     bool stencil_clear_on_load;
     bool stencil_disable_store;
-
-    union {
-        VkClearColorValue color;
-        struct {
-            float depth;
-            uint32_t stencil;
-        } ds;
-    } clear_val;
 };
 
 struct intel_render_pass_subpass {
diff --git a/icd/intel/obj.c b/icd/intel/obj.c
index fc70a30..c67c4f7 100644
--- a/icd/intel/obj.c
+++ b/icd/intel/obj.c
@@ -90,13 +90,9 @@
         assert(info.header->struct_type == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);
         shallow_copy = sizeof(VkImageViewCreateInfo);
         break;
-    case VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW:
-        assert(info.header->struct_type == VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO);
-        shallow_copy = sizeof(VkColorAttachmentViewCreateInfo);
-        break;
-    case VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW:
-        assert(info.header->struct_type == VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO);
-        shallow_copy = sizeof(VkDepthStencilViewCreateInfo);
+    case VK_OBJECT_TYPE_ATTACHMENT_VIEW:
+        assert(info.header->struct_type == VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO);
+        shallow_copy = sizeof(VkAttachmentViewCreateInfo);
         break;
     case VK_OBJECT_TYPE_SAMPLER:
         assert(info.header->struct_type == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
diff --git a/icd/intel/view.c b/icd/intel/view.c
index b0b1fba..278c328 100644
--- a/icd/intel/view.c
+++ b/icd/intel/view.c
@@ -1299,16 +1299,16 @@
     intel_att_view_destroy(view);
 }
 
-VkResult intel_att_view_create_for_color(struct intel_dev *dev,
-                                         const VkColorAttachmentViewCreateInfo *info,
-                                         struct intel_att_view **view_ret)
+VkResult intel_att_view_create(struct intel_dev *dev,
+                               const VkAttachmentViewCreateInfo *info,
+                               struct intel_att_view **view_ret)
 {
     struct intel_img *img = intel_img(info->image);
     struct intel_att_view *view;
     VkImageViewType view_type;
 
     view = (struct intel_att_view *) intel_base_create(&dev->base.handle,
-            sizeof(*view), dev->base.dbg, VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW,
+            sizeof(*view), dev->base.dbg, VK_OBJECT_TYPE_ATTACHMENT_VIEW,
             info, 0);
     if (!view)
         return VK_ERROR_OUT_OF_HOST_MEMORY;
@@ -1326,8 +1326,14 @@
 
     att_view_init_for_input(view, dev->gpu, img, view_type, info->format,
             info->mipLevel, info->baseArraySlice, info->arraySize);
-    att_view_init_for_rt(view, dev->gpu, img, view_type, info->format,
-            info->mipLevel, info->baseArraySlice, info->arraySize);
+
+    if (img->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_BIT) {
+        att_view_init_for_ds(view, dev->gpu, img, view_type, img->layout.format,
+                info->mipLevel, info->baseArraySlice, info->arraySize);
+    } else {
+        att_view_init_for_rt(view, dev->gpu, img, view_type, info->format,
+                info->mipLevel, info->baseArraySlice, info->arraySize);
+    }
 
     *view_ret = view;
 
@@ -1339,43 +1345,6 @@
     intel_base_destroy(&view->obj.base);
 }
 
-VkResult intel_att_view_create_for_ds(struct intel_dev *dev,
-                                      const VkDepthStencilViewCreateInfo *info,
-                                      struct intel_att_view **view_ret)
-{
-    struct intel_img *img = intel_img(info->image);
-    struct intel_att_view *view;
-    VkImageViewType view_type;
-
-    view = (struct intel_att_view *) intel_base_create(&dev->base.handle,
-            sizeof(*view), dev->base.dbg, VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW,
-            info, 0);
-    if (!view)
-        return VK_ERROR_OUT_OF_HOST_MEMORY;
-
-    view->obj.destroy = att_view_destroy;
-
-    view->img = img;
-
-    view->mipLevel = info->mipLevel;
-    view->baseArraySlice = info->baseArraySlice;
-    view->array_size = info->arraySize;
-
-    view_type = img_type_to_view_type(img->type,
-            info->baseArraySlice, info->arraySize);
-
-    /* translate D/S formats to R/G? ones? */
-    att_view_init_for_input(view, dev->gpu, img, view_type, img->layout.format,
-            info->mipLevel, info->baseArraySlice, info->arraySize);
-
-    att_view_init_for_ds(view, dev->gpu, img, view_type, img->layout.format,
-            info->mipLevel, info->baseArraySlice, info->arraySize);
-
-    *view_ret = view;
-
-    return VK_SUCCESS;
-}
-
 ICD_EXPORT VkResult VKAPI vkCreateBufferView(
     VkDevice                                  device,
     const VkBufferViewCreateInfo*          pCreateInfo,
@@ -1398,24 +1367,13 @@
             (struct intel_img_view **) pView);
 }
 
-ICD_EXPORT VkResult VKAPI vkCreateColorAttachmentView(
-    VkDevice                                  device,
-    const VkColorAttachmentViewCreateInfo* pCreateInfo,
-    VkColorAttachmentView*                  pView)
+ICD_EXPORT VkResult VKAPI vkCreateAttachmentView(
+    VkDevice                                    device,
+    const VkAttachmentViewCreateInfo*           pCreateInfo,
+    VkAttachmentView*                           pView)
 {
     struct intel_dev *dev = intel_dev(device);
 
-    return intel_att_view_create_for_color(dev, pCreateInfo,
-            (struct intel_att_view **) pView);
-}
-
-ICD_EXPORT VkResult VKAPI vkCreateDepthStencilView(
-    VkDevice                                  device,
-    const VkDepthStencilViewCreateInfo*   pCreateInfo,
-    VkDepthStencilView*                     pView)
-{
-    struct intel_dev *dev = intel_dev(device);
-
-    return intel_att_view_create_for_ds(dev, pCreateInfo,
+    return intel_att_view_create(dev, pCreateInfo,
             (struct intel_att_view **) pView);
 }
diff --git a/icd/intel/view.h b/icd/intel/view.h
index 1fc4da6..dda9d3d 100644
--- a/icd/intel/view.h
+++ b/icd/intel/view.h
@@ -111,12 +111,7 @@
     return (struct intel_img_view *) obj;
 }
 
-static inline struct intel_att_view *intel_att_view_from_color(VkColorAttachmentView view)
-{
-    return (struct intel_att_view *) view;
-}
-
-static inline struct intel_att_view *intel_att_view_from_ds(VkDepthStencilView view)
+static inline struct intel_att_view *intel_att_view(VkAttachmentView view)
 {
     return (struct intel_att_view *) view;
 }
@@ -140,12 +135,9 @@
                                  struct intel_img_view **view_ret);
 void intel_img_view_destroy(struct intel_img_view *view);
 
-VkResult intel_att_view_create_for_color(struct intel_dev *dev,
-                                         const VkColorAttachmentViewCreateInfo *info,
-                                         struct intel_att_view **view_ret);
-VkResult intel_att_view_create_for_ds(struct intel_dev *dev,
-                                      const VkDepthStencilViewCreateInfo *info,
-                                      struct intel_att_view **view_ret);
+VkResult intel_att_view_create(struct intel_dev *dev,
+                               const VkAttachmentViewCreateInfo *info,
+                               struct intel_att_view **view_ret);
 void intel_att_view_destroy(struct intel_att_view *view);
 
 #endif /* VIEW_H */