From: Chad Versace Date: Thu, 14 Jan 2016 02:24:18 +0000 (-0800) Subject: anv: Allow override of pipeline color attachment count X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2997b0da4a71fb3019ba9234cc94ec42fa2e5641;p=mesa.git anv: Allow override of pipeline color attachment count 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!) --- diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index 3ddeab1ef2d..57138fbd6a3 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -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, diff --git a/src/vulkan/anv_meta_clear.c b/src/vulkan/anv_meta_clear.c index 5eea02380d8..d225e98033c 100644 --- a/src/vulkan/anv_meta_clear.c +++ b/src/vulkan/anv_meta_clear.c @@ -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, diff --git a/src/vulkan/anv_pipeline.c b/src/vulkan/anv_pipeline.c index 8de889306cc..517fcb0ac3a 100644 --- a/src/vulkan/anv_pipeline.c +++ b/src/vulkan/anv_pipeline.c @@ -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; diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index e9c41e8d5b2..4f208965041 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -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;