anv: Allow override of pipeline color attachment count
authorChad Versace <chad.versace@intel.com>
Thu, 14 Jan 2016 02:24:18 +0000 (18:24 -0800)
committerChad Versace <chad.versace@intel.com>
Fri, 15 Jan 2016 06:53:05 +0000 (22:53 -0800)
Add anv_graphics_pipeline_create_info::color_attachment_count. If
non-negative, then it overrides the color attachment count in the
pipeline's subpass. Useful for meta. (All the hacks for meta!)

src/vulkan/anv_meta.c
src/vulkan/anv_meta_clear.c
src/vulkan/anv_pipeline.c
src/vulkan/anv_private.h

index 3ddeab1ef2dbacc88273b847832ad77f8e13aa53..57138fbd6a33dde22bcc26c9935b837b56bfac26 100644 (file)
@@ -392,6 +392,7 @@ anv_device_init_meta_blit_state(struct anv_device *device)
    };
 
    const struct anv_graphics_pipeline_create_info anv_pipeline_info = {
+      .color_attachment_count = -1,
       .use_repclear = false,
       .disable_viewport = true,
       .disable_scissor = true,
index 5eea02380d8ef0c8cb72e928ca34ba08cafbf911..d225e98033c8159af9ba621210c9218c29af264c 100644 (file)
@@ -207,6 +207,7 @@ create_pipeline(struct anv_device *device,
          .subpass = 0,
       },
       &(struct anv_graphics_pipeline_create_info) {
+         .color_attachment_count = MAX_RTS,
          .use_repclear = true,
          .disable_viewport = true,
          .disable_vs = true,
index 8de889306ccdfbfd29da0b7cc951528a5ee7a568..517fcb0ac3aaccf834b63f7e58d56184f67561e6 100644 (file)
@@ -341,6 +341,7 @@ populate_gs_prog_key(const struct brw_device_info *devinfo,
 static void
 populate_wm_prog_key(const struct brw_device_info *devinfo,
                      const VkGraphicsPipelineCreateInfo *info,
+                     const struct anv_graphics_pipeline_create_info *extra,
                      struct brw_wm_prog_key *key)
 {
    ANV_FROM_HANDLE(anv_render_pass, render_pass, info->renderPass);
@@ -361,7 +362,12 @@ populate_wm_prog_key(const struct brw_device_info *devinfo,
    key->drawable_height = 0;
    key->render_to_fbo = false;
 
-   key->nr_color_regions = render_pass->subpasses[info->subpass].color_count;
+   if (extra && extra->color_attachment_count >= 0) {
+      key->nr_color_regions = extra->color_attachment_count;
+   } else {
+      key->nr_color_regions =
+         render_pass->subpasses[info->subpass].color_count;
+   }
 
    key->replicate_alpha = key->nr_color_regions > 1 &&
                           info->pMultisampleState &&
@@ -633,6 +639,7 @@ static VkResult
 anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
                         struct anv_pipeline_cache *cache,
                         const VkGraphicsPipelineCreateInfo *info,
+                        const struct anv_graphics_pipeline_create_info *extra,
                         struct anv_shader_module *module,
                         const char *entrypoint,
                         const VkSpecializationInfo *spec_info)
@@ -642,7 +649,7 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
    struct brw_wm_prog_data *prog_data = &pipeline->wm_prog_data;
    struct brw_wm_prog_key key;
 
-   populate_wm_prog_key(&pipeline->device->info, info, &key);
+   populate_wm_prog_key(&pipeline->device->info, info, extra, &key);
 
    if (pipeline->use_repclear)
       key.nr_color_regions = 1;
@@ -1098,7 +1105,7 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
                                  pCreateInfo->pStages[i].pSpecializationInfo);
          break;
       case VK_SHADER_STAGE_FRAGMENT_BIT:
-         anv_pipeline_compile_fs(pipeline, cache, pCreateInfo, module,
+         anv_pipeline_compile_fs(pipeline, cache, pCreateInfo, extra, module,
                                  pCreateInfo->pStages[i].pName,
                                  pCreateInfo->pStages[i].pSpecializationInfo);
          break;
index e9c41e8d5b2c830e13eb3ce8f3f6b95efa5fdfd7..4f208965041b6446f8f0fe9e9c1f870fcf377d54 100644 (file)
@@ -1368,6 +1368,12 @@ struct anv_pipeline {
 };
 
 struct anv_graphics_pipeline_create_info {
+   /**
+    * If non-negative, overrides the color attachment count of the pipeline's
+    * subpass.
+    */
+   int8_t color_attachment_count;
+
    bool                                         use_repclear;
    bool                                         disable_viewport;
    bool                                         disable_scissor;