[Mesa-dev] [PATCH 3/8] radv: allow the depth decompress pass to emit dynamic sample locations

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu May 30 14:05:16 UTC 2019


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_cmd_buffer.c      |  3 ++-
 src/amd/vulkan/radv_meta.h            |  6 ++++--
 src/amd/vulkan/radv_meta_decompress.c | 29 +++++++++++++++++++++++----
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 5338a8b9fe2..8db4fcdbdc1 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -4679,7 +4679,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;
diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h
index 66c8df6b9e9..59b9121cf39 100644
--- a/src/amd/vulkan/radv_meta.h
+++ b/src/amd/vulkan/radv_meta.h
@@ -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);
diff --git a/src/amd/vulkan/radv_meta_decompress.c b/src/amd/vulkan/radv_meta_decompress.c
index c51beb0c32d..578a287d07b 100644
--- a/src/amd/vulkan/radv_meta_decompress.c
+++ b/src/amd/vulkan/radv_meta_decompress.c
@@ -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);
 }
-- 
2.21.0



More information about the mesa-dev mailing list