radv/gfx9: do not load VGPR1 when GS uses points or lines
[mesa.git] / src / amd / vulkan / radv_meta_resolve.c
index 80b44c89e97def72cd2f5fc6bba88bc953fef186..49326fe9d10693005a01b7e4909ddce14ca63d64 100644 (file)
@@ -121,6 +121,21 @@ create_pipeline(struct radv_device *device,
                goto cleanup;
        }
 
+       VkPipelineLayoutCreateInfo pl_create_info = {
+               .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
+               .setLayoutCount = 0,
+               .pSetLayouts = NULL,
+               .pushConstantRangeCount = 0,
+               .pPushConstantRanges = NULL,
+       };
+
+       result = radv_CreatePipelineLayout(radv_device_to_handle(device),
+                                          &pl_create_info,
+                                          &device->meta_state.alloc,
+                                          &device->meta_state.resolve.p_layout);
+       if (result != VK_SUCCESS)
+               goto cleanup;
+
        result = radv_graphics_pipeline_create(device_h,
                                               radv_pipeline_cache_to_handle(&device->meta_state.cache),
                                               &(VkGraphicsPipelineCreateInfo) {
@@ -196,6 +211,7 @@ create_pipeline(struct radv_device *device,
                                                                VK_DYNAMIC_STATE_SCISSOR,
                                                        },
                                                },
+                                               .layout = device->meta_state.resolve.p_layout,
                                                                                                                                       .renderPass = device->meta_state.resolve.pass,
                                                                                                                                       .subpass = 0,
                                                                                                                                       },
@@ -219,18 +235,13 @@ void
 radv_device_finish_meta_resolve_state(struct radv_device *device)
 {
        struct radv_meta_state *state = &device->meta_state;
-       VkDevice device_h = radv_device_to_handle(device);
-       VkRenderPass pass_h = device->meta_state.resolve.pass;
-       const VkAllocationCallbacks *alloc = &device->meta_state.alloc;
-
-       if (pass_h)
-               radv_DestroyRenderPass(device_h, pass_h,
-                                            &device->meta_state.alloc);
 
-       VkPipeline pipeline_h = state->resolve.pipeline;
-       if (pipeline_h) {
-               radv_DestroyPipeline(device_h, pipeline_h, alloc);
-       }
+       radv_DestroyRenderPass(radv_device_to_handle(device),
+                              state->resolve.pass, &state->alloc);
+       radv_DestroyPipelineLayout(radv_device_to_handle(device),
+                                  state->resolve.p_layout, &state->alloc);
+       radv_DestroyPipeline(radv_device_to_handle(device),
+                            state->resolve.pipeline, &state->alloc);
 }
 
 VkResult
@@ -275,13 +286,8 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer,
 
        cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_CB;
 
-       VkPipeline pipeline_h = device->meta_state.resolve.pipeline;
-       RADV_FROM_HANDLE(radv_pipeline, pipeline, pipeline_h);
-
-       if (cmd_buffer->state.pipeline != pipeline) {
-               radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
-                                    pipeline_h);
-       }
+       radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
+                            device->meta_state.resolve.pipeline);
 
        radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkViewport) {
                .x = dest_offset->x,
@@ -309,14 +315,18 @@ enum radv_resolve_method {
 
 static void radv_pick_resolve_method_images(struct radv_image *src_image,
                                            struct radv_image *dest_image,
+                                           VkImageLayout dest_image_layout,
+                                           struct radv_cmd_buffer *cmd_buffer,
                                            enum radv_resolve_method *method)
 
 {
-       if (dest_image->surface.micro_tile_mode != src_image->surface.micro_tile_mode) {
-               if (dest_image->surface.num_dcc_levels > 0)
-                       *method = RESOLVE_FRAGMENT;
-               else
-                       *method = RESOLVE_COMPUTE;
+       uint32_t queue_mask = radv_image_queue_family_mask(dest_image,
+                                                          cmd_buffer->queue_family_index,
+                                                          cmd_buffer->queue_family_index);
+       if (radv_layout_dcc_compressed(dest_image, dest_image_layout, queue_mask)) {
+               *method = RESOLVE_FRAGMENT;
+       } else if (dest_image->surface.micro_tile_mode != src_image->surface.micro_tile_mode) {
+               *method = RESOLVE_COMPUTE;
        }
 }
 
@@ -355,6 +365,7 @@ void radv_CmdResolveImage(
                resolve_method = RESOLVE_COMPUTE;
 
        radv_pick_resolve_method_images(src_image, dest_image,
+                                       dest_image_layout, cmd_buffer,
                                        &resolve_method);
 
        if (resolve_method == RESOLVE_FRAGMENT) {
@@ -377,7 +388,8 @@ void radv_CmdResolveImage(
                return;
        }
 
-       radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer);
+       radv_meta_save(&saved_state, cmd_buffer,
+                      RADV_META_SAVE_GRAPHICS_PIPELINE);
 
        assert(src_image->info.samples > 1);
        if (src_image->info.samples <= 1) {
@@ -571,7 +583,7 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer)
                struct radv_image *dst_img = cmd_buffer->state.framebuffer->attachments[dest_att.attachment].attachment->image;
                struct radv_image *src_img = cmd_buffer->state.framebuffer->attachments[src_att.attachment].attachment->image;
 
-               radv_pick_resolve_method_images(dst_img, src_img, &resolve_method);
+               radv_pick_resolve_method_images(dst_img, src_img, dest_att.layout, cmd_buffer, &resolve_method);
                if (resolve_method == RESOLVE_FRAGMENT) {
                        break;
                }
@@ -585,7 +597,8 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer)
                return;
        }
 
-       radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer);
+       radv_meta_save(&saved_state, cmd_buffer,
+                      RADV_META_SAVE_GRAPHICS_PIPELINE);
 
        for (uint32_t i = 0; i < subpass->color_count; ++i) {
                VkAttachmentReference src_att = subpass->color_attachments[i];