anv/meta: Remove unneeded resolve pipeline
authorChad Versace <chad.versace@intel.com>
Thu, 28 Jan 2016 18:20:10 +0000 (10:20 -0800)
committerChad Versace <chad.versace@intel.com>
Thu, 28 Jan 2016 18:45:11 +0000 (10:45 -0800)
Vulkan does not allow resolving a single-sample image. So remove that
pipeline from anv_meta_state::resolve::pipelines.

src/vulkan/anv_meta_resolve.c
src/vulkan/anv_private.h

index 06324c9a0bec40de67a45a524fdecb5471016eb4..9969a0e5d883556a2ad1dab2b7c460f9254d3095 100644 (file)
@@ -56,6 +56,17 @@ meta_resolve_restore(struct anv_meta_saved_state *saved_state,
    anv_meta_restore(saved_state, cmd_buffer);
 }
 
+static VkPipeline *                                                                                          
+get_pipeline_h(struct anv_device *device, uint32_t samples)
+{                                                                                                            
+   uint32_t i = ffs(samples) - 2; /* log2(samples) - 1 */                                                        
+
+   assert(samples >= 2);
+   assert(i < ARRAY_SIZE(device->meta_state.resolve.pipelines));                                             
+
+   return &device->meta_state.resolve.pipelines[i];
+}                                                                                                            
+
 static nir_shader *
 build_nir_vs(void)
 {
@@ -213,7 +224,6 @@ create_pipeline(struct anv_device *device,
 {
    VkResult result;
    VkDevice device_h = anv_device_to_handle(device);
-   uint32_t samples_log2 = ffs(num_samples) - 1;
 
    struct anv_shader_module fs_module = {
       .nir = build_nir_fs(num_samples),
@@ -339,7 +349,7 @@ create_pipeline(struct anv_device *device,
          .use_rectlist = true
       },
       &device->meta_state.alloc,
-      &device->meta_state.resolve.pipelines[samples_log2]);
+      get_pipeline_h(device, num_samples));
    if (result != VK_SUCCESS)
       goto cleanup;
 
@@ -437,8 +447,8 @@ anv_device_init_meta_resolve_state(struct anv_device *device)
 
    for (uint32_t i = 0;
         i < ARRAY_SIZE(device->meta_state.resolve.pipelines); ++i) {
-      uint32_t sample_count = 1 << i;
 
+      uint32_t sample_count = 1 << (1 + i);
       if (!(sample_count_mask & sample_count))
          continue;
 
@@ -472,7 +482,6 @@ emit_resolve(struct anv_cmd_buffer *cmd_buffer,
    const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
    const struct anv_image *src_image = src_iview->image;
    VkDescriptorPool dummy_desc_pool_h = (VkDescriptorPool) 1;
-   uint32_t samples_log2 = ffs(src_image->samples) - 1;
 
    const struct vertex_attrs vertex_data[3] = {
       {
@@ -609,7 +618,7 @@ emit_resolve(struct anv_cmd_buffer *cmd_buffer,
          },
       });
 
-   VkPipeline pipeline_h = device->meta_state.resolve.pipelines[samples_log2];
+   VkPipeline pipeline_h = *get_pipeline_h(device, src_image->samples);
    ANV_FROM_HANDLE(anv_pipeline, pipeline, pipeline_h);
 
    if (cmd_buffer->state.pipeline != pipeline) {
index 835a5e81e1eb66a98590bec66b6f9e18a122dc2e..6a670190ab9998283fffd7d93cde98de113f74ec 100644 (file)
@@ -601,10 +601,8 @@ struct anv_meta_state {
    } blit;
 
    struct {
-      /**
-       * Use pipeline `i` for images with `2^i` samples.
-       */
-      VkPipeline                                pipelines[1 + MAX_SAMPLES_LOG2];
+      /** Pipeline [i] resolves an image with 2^(i+1) samples.  */
+      VkPipeline                                pipelines[MAX_SAMPLES_LOG2];
 
       VkRenderPass                              pass;
       VkPipelineLayout                          pipeline_layout;