radv/meta: Fix a stack use-after-free with sample locations

As soon as the if ends (or possibly before?) the VkSampleLocationsInfoEXT
goes out of scope.  We need it to stay valid until after the
vkCmdPipelineBarrier completes.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18084>
This commit is contained in:
Jason Ekstrand 2022-05-20 18:05:10 -05:00 committed by Marge Bot
parent 297d82763b
commit 4f9dabc1a6

View file

@ -822,6 +822,7 @@ radv_decompress_resolve_src(struct radv_cmd_buffer *cmd_buffer, struct radv_imag
}
};
VkSampleLocationsInfoEXT sample_loc_info;
if (src_image->vk.create_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) {
/* If the depth/stencil image uses different sample
* locations, we need them during HTILE decompressions.
@ -829,13 +830,14 @@ radv_decompress_resolve_src(struct radv_cmd_buffer *cmd_buffer, struct radv_imag
struct radv_sample_locations_state *sample_locs =
radv_get_resolve_sample_locations(cmd_buffer);
barrier.pNext = &(VkSampleLocationsInfoEXT){
sample_loc_info = (VkSampleLocationsInfoEXT){
.sType = VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT,
.sampleLocationsPerPixel = sample_locs->per_pixel,
.sampleLocationGridSize = sample_locs->grid_size,
.sampleLocationsCount = sample_locs->count,
.pSampleLocations = sample_locs->locations,
};
barrier.pNext = &sample_loc_info;
}
VkDependencyInfo dep_info = {