radv: move pipeline barrier image transitions after src flushing
authorDave Airlie <airlied@redhat.com>
Tue, 25 Oct 2016 06:23:48 +0000 (07:23 +0100)
committerDave Airlie <airlied@redhat.com>
Wed, 23 Nov 2016 00:16:34 +0000 (10:16 +1000)
This seems like it would conform better with the spec.

noticed while digging into fast clears.

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

index 9517e7a13dab345f3a389cd47c8dda63bbb324cf..824f9d80af8e35a02c1c3677b4f929a3b00cd140 100644 (file)
@@ -2246,19 +2246,11 @@ void radv_CmdPipelineBarrier(
        }
 
        for (uint32_t i = 0; i < imageMemoryBarrierCount; i++) {
-               RADV_FROM_HANDLE(radv_image, image, pImageMemoryBarriers[i].image);
                src_flags |= pImageMemoryBarriers[i].srcAccessMask;
                dst_flags |= pImageMemoryBarriers[i].dstAccessMask;
-
-               radv_handle_image_transition(cmd_buffer, image,
-                                            pImageMemoryBarriers[i].oldLayout,
-                                            pImageMemoryBarriers[i].newLayout,
-                                            pImageMemoryBarriers[i].subresourceRange,
-                                            0);
        }
 
        enum radv_cmd_flush_bits flush_bits = 0;
-
        for_each_bit(b, src_flags) {
                switch ((VkAccessFlagBits)(1 << b)) {
                case VK_ACCESS_SHADER_WRITE_BIT:
@@ -2277,6 +2269,18 @@ void radv_CmdPipelineBarrier(
                        break;
                }
        }
+       cmd_buffer->state.flush_bits |= flush_bits;
+
+       for (uint32_t i = 0; i < imageMemoryBarrierCount; i++) {
+               RADV_FROM_HANDLE(radv_image, image, pImageMemoryBarriers[i].image);
+               radv_handle_image_transition(cmd_buffer, image,
+                                            pImageMemoryBarriers[i].oldLayout,
+                                            pImageMemoryBarriers[i].newLayout,
+                                            pImageMemoryBarriers[i].subresourceRange,
+                                            0);
+       }
+
+       flush_bits = 0;
 
        for_each_bit(b, dst_flags) {
                switch ((VkAccessFlagBits)(1 << b)) {