- VkFormat depth_format = 0;
- if (dst->aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT)
- depth_format = vk_format_stencil_only(dst->image->vk_format);
- else if (dst->aspect_mask == VK_IMAGE_ASPECT_DEPTH_BIT)
- depth_format = vk_format_depth_only(dst->image->vk_format);
- struct blit2d_src_temps src_temps;
- blit2d_bind_src(cmd_buffer, src_img, src_buf, &src_temps, src_type, depth_format);
-
- struct blit2d_dst_temps dst_temps;
- blit2d_bind_dst(cmd_buffer, dst, rects[r].dst_x + rects[r].width,
- rects[r].dst_y + rects[r].height, depth_format, &dst_temps);
-
- float vertex_push_constants[4] = {
- rects[r].src_x,
- rects[r].src_y,
- rects[r].src_x + rects[r].width,
- rects[r].src_y + rects[r].height,
- };
+ unsigned i;
+ for_each_bit(i, dst->aspect_mask) {
+ unsigned aspect_mask = 1u << i;
+ VkFormat depth_format = 0;
+ if (aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT)
+ depth_format = vk_format_stencil_only(dst->image->vk_format);
+ else if (aspect_mask == VK_IMAGE_ASPECT_DEPTH_BIT)
+ depth_format = vk_format_depth_only(dst->image->vk_format);
+ struct blit2d_src_temps src_temps;
+ blit2d_bind_src(cmd_buffer, src_img, src_buf, &src_temps, src_type, depth_format, aspect_mask);
+
+ struct blit2d_dst_temps dst_temps;
+ blit2d_bind_dst(cmd_buffer, dst, rects[r].dst_x + rects[r].width,
+ rects[r].dst_y + rects[r].height, depth_format, &dst_temps, aspect_mask);
+
+ float vertex_push_constants[4] = {
+ rects[r].src_x,
+ rects[r].src_y,
+ rects[r].src_x + rects[r].width,
+ rects[r].src_y + rects[r].height,
+ };
+
+ radv_CmdPushConstants(radv_cmd_buffer_to_handle(cmd_buffer),
+ device->meta_state.blit2d.p_layouts[src_type],
+ VK_SHADER_STAGE_VERTEX_BIT, 0, 16,
+ vertex_push_constants);
+
+ if (aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT) {
+ unsigned fs_key = radv_format_meta_fs_key(dst_temps.iview.vk_format);
+
+ radv_CmdBeginRenderPass(radv_cmd_buffer_to_handle(cmd_buffer),
+ &(VkRenderPassBeginInfo) {
+ .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
+ .renderPass = device->meta_state.blit2d.render_passes[fs_key],
+ .framebuffer = dst_temps.fb,
+ .renderArea = {
+ .offset = { rects[r].dst_x, rects[r].dst_y, },
+ .extent = { rects[r].width, rects[r].height },
+ },
+ .clearValueCount = 0,
+ .pClearValues = NULL,
+ }, VK_SUBPASS_CONTENTS_INLINE);
+
+
+ bind_pipeline(cmd_buffer, src_type, fs_key);
+ } else if (aspect_mask == VK_IMAGE_ASPECT_DEPTH_BIT) {
+ enum radv_blit_ds_layout ds_layout = radv_meta_blit_ds_to_type(dst->current_layout);
+ radv_CmdBeginRenderPass(radv_cmd_buffer_to_handle(cmd_buffer),
+ &(VkRenderPassBeginInfo) {
+ .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
+ .renderPass = device->meta_state.blit2d.depth_only_rp[ds_layout],
+ .framebuffer = dst_temps.fb,
+ .renderArea = {
+ .offset = { rects[r].dst_x, rects[r].dst_y, },
+ .extent = { rects[r].width, rects[r].height },
+ },
+ .clearValueCount = 0,
+ .pClearValues = NULL,
+ }, VK_SUBPASS_CONTENTS_INLINE);
+
+
+ bind_depth_pipeline(cmd_buffer, src_type);
+
+ } else if (aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT) {
+ enum radv_blit_ds_layout ds_layout = radv_meta_blit_ds_to_type(dst->current_layout);
+ radv_CmdBeginRenderPass(radv_cmd_buffer_to_handle(cmd_buffer),
+ &(VkRenderPassBeginInfo) {
+ .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
+ .renderPass = device->meta_state.blit2d.stencil_only_rp[ds_layout],
+ .framebuffer = dst_temps.fb,
+ .renderArea = {
+ .offset = { rects[r].dst_x, rects[r].dst_y, },
+ .extent = { rects[r].width, rects[r].height },
+ },
+ .clearValueCount = 0,
+ .pClearValues = NULL,
+ }, VK_SUBPASS_CONTENTS_INLINE);