radv: drop few useless state changes when doing color/depth decompressions
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 22 Nov 2018 18:10:15 +0000 (19:10 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 29 Nov 2018 09:18:55 +0000 (10:18 +0100)
Viewport/scissor don't need to be updated for array textures.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_meta_decompress.c
src/amd/vulkan/radv_meta_fast_clear.c

index b4f568ba2f83704b19ba71c79b86555d3b9552a9..fe8e114e91bf92eb3ea05860770a4a1cac0c7073 100644 (file)
@@ -308,34 +308,6 @@ cleanup:
        return res;
 }
 
-static void
-emit_depth_decomp(struct radv_cmd_buffer *cmd_buffer,
-                 const VkExtent2D *depth_decomp_extent,
-                 VkPipeline pipeline_h)
-{
-       VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
-
-       radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
-                            pipeline_h);
-
-       radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkViewport) {
-               .x = 0,
-               .y = 0,
-               .width = depth_decomp_extent->width,
-               .height = depth_decomp_extent->height,
-               .minDepth = 0.0f,
-               .maxDepth = 1.0f
-       });
-
-       radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkRect2D) {
-               .offset = { 0, 0 },
-               .extent = *depth_decomp_extent,
-       });
-
-       radv_CmdDraw(cmd_buffer_h, 3, 1, 0, 0);
-}
-
-
 enum radv_depth_op {
        DEPTH_DECOMPRESS,
        DEPTH_RESUMMARIZE,
@@ -388,6 +360,23 @@ static void radv_process_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                unreachable("unknown operation");
        }
 
+       radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
+                            pipeline_h);
+
+       radv_CmdSetViewport(cmd_buffer_h, 0, 1, &(VkViewport) {
+               .x = 0,
+               .y = 0,
+               .width = width,
+               .height = height,
+               .minDepth = 0.0f,
+               .maxDepth = 1.0f
+       });
+
+       radv_CmdSetScissor(cmd_buffer_h, 0, 1, &(VkRect2D) {
+               .offset = { 0, 0 },
+               .extent = { width, height },
+       });
+
        for (uint32_t layer = 0; layer < radv_get_layerCount(image, subresourceRange); layer++) {
                struct radv_image_view iview;
 
@@ -442,7 +431,7 @@ static void radv_process_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                           },
                                           VK_SUBPASS_CONTENTS_INLINE);
 
-               emit_depth_decomp(cmd_buffer, &(VkExtent2D){width, height}, pipeline_h);
+               radv_CmdDraw(cmd_buffer_h, 3, 1, 0, 0);
                radv_CmdEndRenderPass(cmd_buffer_h);
 
                radv_DestroyFramebuffer(device_h, fb_h,
index a54b78c2a6c82bec11d0044b6eb0f3a96b8b41d0..f2f68961e2ec2bc28608d3f0cc048044c90bf038 100644 (file)
@@ -549,35 +549,6 @@ radv_device_init_meta_fast_clear_flush_state(struct radv_device *device, bool on
        return radv_device_init_meta_fast_clear_flush_state_internal(device);
 }
 
-static void
-emit_fast_clear_flush(struct radv_cmd_buffer *cmd_buffer,
-                     const VkExtent2D *resolve_extent,
-                     VkPipeline pipeline)
-{
-       VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
-
-       radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
-                            pipeline);
-
-       radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkViewport) {
-                       .x = 0,
-                       .y = 0,
-                       .width = resolve_extent->width,
-                       .height = resolve_extent->height,
-                       .minDepth = 0.0f,
-                       .maxDepth = 1.0f
-               });
-
-               radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkRect2D) {
-                       .offset = (VkOffset2D) { 0, 0 },
-                       .extent = (VkExtent2D) { resolve_extent->width, resolve_extent->height },
-               });
-
-       radv_CmdDraw(cmd_buffer_h, 3, 1, 0, 0);
-       cmd_buffer->state.flush_bits |= (RADV_CMD_FLAG_FLUSH_AND_INV_CB |
-                                        RADV_CMD_FLAG_FLUSH_AND_INV_CB_META);
-}
-
 static void
 radv_emit_set_predication_state_from_image(struct radv_cmd_buffer *cmd_buffer,
                                      struct radv_image *image, bool value)
@@ -635,6 +606,24 @@ radv_emit_color_decompress(struct radv_cmd_buffer *cmd_buffer,
                radv_emit_set_predication_state_from_image(cmd_buffer, image, true);
                cmd_buffer->state.predicating = true;
        }
+
+       radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
+                            pipeline);
+
+       radv_CmdSetViewport(cmd_buffer_h, 0, 1, &(VkViewport) {
+               .x = 0,
+               .y = 0,
+               .width = image->info.width,
+               .height = image->info.height,
+               .minDepth = 0.0f,
+               .maxDepth = 1.0f
+       });
+
+       radv_CmdSetScissor(cmd_buffer_h, 0, 1, &(VkRect2D) {
+               .offset = (VkOffset2D) { 0, 0 },
+               .extent = (VkExtent2D) { image->info.width, image->info.height },
+       });
+
        for (uint32_t layer = 0; layer < layer_count; ++layer) {
                struct radv_image_view iview;
 
@@ -688,9 +677,11 @@ radv_emit_color_decompress(struct radv_cmd_buffer *cmd_buffer,
                                     },
                                     VK_SUBPASS_CONTENTS_INLINE);
 
-               emit_fast_clear_flush(cmd_buffer,
-                                     &(VkExtent2D) { image->info.width, image->info.height },
-                                     pipeline);
+               radv_CmdDraw(cmd_buffer_h, 3, 1, 0, 0);
+
+               cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_CB |
+                                               RADV_CMD_FLAG_FLUSH_AND_INV_CB_META;
+
                radv_CmdEndRenderPass(cmd_buffer_h);
 
                radv_DestroyFramebuffer(device_h, fb_h,