radv/meta: consolidate the depth stencil clear renderpasses
authorDave Airlie <airlied@redhat.com>
Mon, 16 Jan 2017 20:37:36 +0000 (06:37 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 16 Jan 2017 20:51:25 +0000 (06:51 +1000)
We only need one per samples (maybe not even that), reduce
all the unneeded ones.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_meta_clear.c
src/amd/vulkan/radv_private.h

index 4cee75e6f0a41af37884eebd5c37cc4a87f6ef63..601c3de4ebaaa9104c510417a5e8c5ec8ea8ba5b 100644 (file)
@@ -346,12 +346,10 @@ radv_device_finish_meta_clear_state(struct radv_device *device)
 
                for (uint32_t j = 0; j < NUM_DEPTH_CLEAR_PIPELINES; j++) {
                        destroy_pipeline(device, state->clear[i].depth_only_pipeline[j]);
-                       destroy_render_pass(device, state->clear[i].depth_only_rp[j]);
                        destroy_pipeline(device, state->clear[i].stencil_only_pipeline[j]);
-                       destroy_render_pass(device, state->clear[i].stencil_only_rp[j]);
                        destroy_pipeline(device, state->clear[i].depthstencil_pipeline[j]);
-                       destroy_render_pass(device, state->clear[i].depthstencil_rp[j]);
                }
+               destroy_render_pass(device, state->clear[i].depthstencil_rp);
        }
 
 }
@@ -478,13 +476,48 @@ build_depthstencil_shader(struct nir_shader **out_vs, struct nir_shader **out_fs
        *out_fs = fs_b.shader;
 }
 
+static VkResult
+create_depthstencil_renderpass(struct radv_device *device,
+                              uint32_t samples,
+                              VkRenderPass *render_pass)
+{
+       return radv_CreateRenderPass(radv_device_to_handle(device),
+                                      &(VkRenderPassCreateInfo) {
+                                              .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
+                                                      .attachmentCount = 1,
+                                                      .pAttachments = &(VkAttachmentDescription) {
+                                                      .format = VK_FORMAT_UNDEFINED,
+                                                      .samples = samples,
+                                                      .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
+                                                      .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
+                                                      .initialLayout = VK_IMAGE_LAYOUT_GENERAL,
+                                                      .finalLayout = VK_IMAGE_LAYOUT_GENERAL,
+                                              },
+                                                      .subpassCount = 1,
+                                                               .pSubpasses = &(VkSubpassDescription) {
+                                                      .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
+                                                      .inputAttachmentCount = 0,
+                                                      .colorAttachmentCount = 0,
+                                                      .pColorAttachments = NULL,
+                                                      .pResolveAttachments = NULL,
+                                                      .pDepthStencilAttachment = &(VkAttachmentReference) {
+                                                              .attachment = 0,
+                                                              .layout = VK_IMAGE_LAYOUT_GENERAL,
+                                                      },
+                                                      .preserveAttachmentCount = 1,
+                                                      .pPreserveAttachments = (uint32_t[]) { 0 },
+                                              },
+                                                               .dependencyCount = 0,
+                                                                        }, &device->meta_state.alloc, render_pass);
+}
+
 static VkResult
 create_depthstencil_pipeline(struct radv_device *device,
                              VkImageAspectFlags aspects,
                             uint32_t samples,
                             int index,
                              struct radv_pipeline **pipeline,
-                            VkRenderPass *render_pass)
+                            VkRenderPass render_pass)
 {
        struct nir_shader *vs_nir, *fs_nir;
        VkResult result;
@@ -535,36 +568,6 @@ create_depthstencil_pipeline(struct radv_device *device,
                .pAttachments = NULL,
        };
 
-       result = radv_CreateRenderPass(radv_device_to_handle(device),
-                                      &(VkRenderPassCreateInfo) {
-                                              .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
-                                                      .attachmentCount = 1,
-                                                      .pAttachments = &(VkAttachmentDescription) {
-                                                      .format = VK_FORMAT_UNDEFINED,
-                                                      .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
-                                                      .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
-                                                      .initialLayout = VK_IMAGE_LAYOUT_GENERAL,
-                                                      .finalLayout = VK_IMAGE_LAYOUT_GENERAL,
-                                              },
-                                                      .subpassCount = 1,
-                                                               .pSubpasses = &(VkSubpassDescription) {
-                                                      .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
-                                                      .inputAttachmentCount = 0,
-                                                      .colorAttachmentCount = 0,
-                                                      .pColorAttachments = NULL,
-                                                      .pResolveAttachments = NULL,
-                                                      .pDepthStencilAttachment = &(VkAttachmentReference) {
-                                                              .attachment = 0,
-                                                              .layout = VK_IMAGE_LAYOUT_GENERAL,
-                                                      },
-                                                      .preserveAttachmentCount = 1,
-                                                      .pPreserveAttachments = (uint32_t[]) { 0 },
-                                              },
-                                                               .dependencyCount = 0,
-                                                                        }, &device->meta_state.alloc, render_pass);
-       if (result != VK_SUCCESS)
-               return result;
-
        struct radv_graphics_pipeline_create_info extra = {
                .use_rectlist = true,
        };
@@ -577,7 +580,7 @@ create_depthstencil_pipeline(struct radv_device *device,
                extra.db_stencil_clear = index == DEPTH_CLEAR_SLOW ? false : true;
                extra.db_stencil_disable_expclear = index == DEPTH_CLEAR_FAST_NO_EXPCLEAR ? true : false;
        }
-       result = create_pipeline(device, radv_render_pass_from_handle(*render_pass),
+       result = create_pipeline(device, radv_render_pass_from_handle(render_pass),
                                 samples, vs_nir, fs_nir, &vi_state, &ds_state, &cb_state,
                                 &extra, &device->meta_state.alloc, pipeline);
        return result;
@@ -747,13 +750,19 @@ radv_device_init_meta_clear_state(struct radv_device *device)
 
                }
 
+               res = create_depthstencil_renderpass(device,
+                                                    samples,
+                                                    &state->clear[i].depthstencil_rp);
+               if (res != VK_SUCCESS)
+                       goto fail;
+
                for (uint32_t j = 0; j < NUM_DEPTH_CLEAR_PIPELINES; j++) {
                        res = create_depthstencil_pipeline(device,
                                                           VK_IMAGE_ASPECT_DEPTH_BIT,
                                                           samples,
                                                           j,
                                                           &state->clear[i].depth_only_pipeline[j],
-                                                          &state->clear[i].depth_only_rp[j]);
+                                                          state->clear[i].depthstencil_rp);
                        if (res != VK_SUCCESS)
                                goto fail;
 
@@ -762,7 +771,7 @@ radv_device_init_meta_clear_state(struct radv_device *device)
                                                           samples,
                                                           j,
                                                           &state->clear[i].stencil_only_pipeline[j],
-                                                          &state->clear[i].stencil_only_rp[j]);
+                                                          state->clear[i].depthstencil_rp);
                        if (res != VK_SUCCESS)
                                goto fail;
 
@@ -772,7 +781,7 @@ radv_device_init_meta_clear_state(struct radv_device *device)
                                                           samples,
                                                           j,
                                                           &state->clear[i].depthstencil_pipeline[j],
-                                                          &state->clear[i].depthstencil_rp[j]);
+                                                          state->clear[i].depthstencil_rp);
                        if (res != VK_SUCCESS)
                                goto fail;
                }
index b095e3f39a66f8784757b25d4369b716d5719170..6b80b20487583fd46654d6130dfddeeabf5caa52 100644 (file)
@@ -348,11 +348,9 @@ struct radv_meta_state {
                VkRenderPass render_pass[NUM_META_FS_KEYS];
                struct radv_pipeline *color_pipelines[NUM_META_FS_KEYS];
 
-               VkRenderPass depth_only_rp[NUM_DEPTH_CLEAR_PIPELINES];
+               VkRenderPass depthstencil_rp;
                struct radv_pipeline *depth_only_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
-               VkRenderPass stencil_only_rp[NUM_DEPTH_CLEAR_PIPELINES];
                struct radv_pipeline *stencil_only_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
-               VkRenderPass depthstencil_rp[NUM_DEPTH_CLEAR_PIPELINES];
                struct radv_pipeline *depthstencil_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
        } clear[1 + MAX_SAMPLES_LOG2];