radv: allow the depth decompress pass to emit dynamic sample locations
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 30 May 2019 10:20:12 +0000 (12:20 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 7 Jun 2019 11:11:00 +0000 (13:11 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-By: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_meta.h
src/amd/vulkan/radv_meta_decompress.c

index b570bda35aedb4b9ec52292abf0ab817626080b8..6a6dc38b6517d9b298e25b3a995e6bdc2e51dc8e 100644 (file)
@@ -4678,7 +4678,8 @@ static void radv_handle_depth_image_transition(struct radv_cmd_buffer *cmd_buffe
                cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_DB |
                                                RADV_CMD_FLAG_FLUSH_AND_INV_DB_META;
 
-               radv_decompress_depth_image_inplace(cmd_buffer, image, &local_range);
+               radv_decompress_depth_image_inplace(cmd_buffer, image,
+                                                   &local_range, NULL);
 
                cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_DB |
                                                RADV_CMD_FLAG_FLUSH_AND_INV_DB_META;
index 66c8df6b9e9cc6f26e78492de351e08ead5d9331..59b9121cf39289bae6f5490f5973b3110f743daf 100644 (file)
@@ -169,10 +169,12 @@ void radv_meta_clear_image_cs(struct radv_cmd_buffer *cmd_buffer,
 
 void radv_decompress_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                         struct radv_image *image,
-                                        VkImageSubresourceRange *subresourceRange);
+                                        VkImageSubresourceRange *subresourceRange,
+                                        struct radv_sample_locations_state *sample_locs);
 void radv_resummarize_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                          struct radv_image *image,
-                                         VkImageSubresourceRange *subresourceRange);
+                                         VkImageSubresourceRange *subresourceRange,
+                                         struct radv_sample_locations_state *sample_locs);
 void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                         struct radv_image *image,
                                         const VkImageSubresourceRange *subresourceRange);
index c51beb0c32d308a6ae7a10853a0bcb25cee4fc59..578a287d07b689ceb954ab13e7f99f2a3c07d7a4 100644 (file)
@@ -323,6 +323,7 @@ enum radv_depth_op {
 static void radv_process_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                             struct radv_image *image,
                                             VkImageSubresourceRange *subresourceRange,
+                                            struct radv_sample_locations_state *sample_locs,
                                             enum radv_depth_op op)
 {
        struct radv_meta_saved_state saved_state;
@@ -354,6 +355,7 @@ static void radv_process_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
 
        radv_meta_save(&saved_state, cmd_buffer,
                       RADV_META_SAVE_GRAPHICS_PIPELINE |
+                      RADV_META_SAVE_SAMPLE_LOCATIONS |
                       RADV_META_SAVE_PASS);
 
        switch (op) {
@@ -384,6 +386,21 @@ static void radv_process_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                .extent = { width, height },
        });
 
+       if (sample_locs) {
+               assert(image->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT);
+
+               /* Set the sample locations specified during explicit or
+                * automatic layout transitions, otherwise the depth decompress
+                * pass uses the default HW locations.
+                */
+               radv_CmdSetSampleLocationsEXT(cmd_buffer_h, &(VkSampleLocationsInfoEXT) {
+                       .sampleLocationsPerPixel = sample_locs->per_pixel,
+                       .sampleLocationGridSize = sample_locs->grid_size,
+                       .sampleLocationsCount = sample_locs->count,
+                       .pSampleLocations = sample_locs->locations,
+               });
+       }
+
        for (uint32_t layer = 0; layer < radv_get_layerCount(image, subresourceRange); layer++) {
                struct radv_image_view iview;
 
@@ -449,16 +466,20 @@ static void radv_process_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
 
 void radv_decompress_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                         struct radv_image *image,
-                                        VkImageSubresourceRange *subresourceRange)
+                                        VkImageSubresourceRange *subresourceRange,
+                                        struct radv_sample_locations_state *sample_locs)
 {
        assert(cmd_buffer->queue_family_index == RADV_QUEUE_GENERAL);
-       radv_process_depth_image_inplace(cmd_buffer, image, subresourceRange, DEPTH_DECOMPRESS);
+       radv_process_depth_image_inplace(cmd_buffer, image, subresourceRange,
+                                        sample_locs, DEPTH_DECOMPRESS);
 }
 
 void radv_resummarize_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                         struct radv_image *image,
-                                        VkImageSubresourceRange *subresourceRange)
+                                        VkImageSubresourceRange *subresourceRange,
+                                        struct radv_sample_locations_state *sample_locs)
 {
        assert(cmd_buffer->queue_family_index == RADV_QUEUE_GENERAL);
-       radv_process_depth_image_inplace(cmd_buffer, image, subresourceRange, DEPTH_RESUMMARIZE);
+       radv_process_depth_image_inplace(cmd_buffer, image, subresourceRange,
+                                        sample_locs, DEPTH_RESUMMARIZE);
 }