radv: stop setting redundant viewport/scissor for internal operations
Only emit them when it's needed. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18567>
This commit is contained in:
committed by
Marge Bot
parent
4031c9428f
commit
9ebaa62a34
@@ -241,8 +241,7 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
|
||||
struct radv_image_view *src_iview, VkImageLayout src_image_layout,
|
||||
float src_offset_0[3], float src_offset_1[3], struct radv_image *dest_image,
|
||||
struct radv_image_view *dest_iview, VkImageLayout dest_image_layout,
|
||||
VkOffset2D dest_offset_0, VkOffset2D dest_offset_1, VkRect2D dest_box,
|
||||
VkSampler sampler)
|
||||
VkRect2D dest_box, VkSampler sampler)
|
||||
{
|
||||
struct radv_device *device = cmd_buffer->device;
|
||||
uint32_t src_width = radv_minify(src_iview->image->info.width, src_iview->vk.base_mip_level);
|
||||
@@ -357,22 +356,6 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
|
||||
},
|
||||
}}});
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = dest_offset_0.x,
|
||||
.y = dest_offset_0.y,
|
||||
.width = dest_offset_1.x - dest_offset_0.x,
|
||||
.height = dest_offset_1.y - dest_offset_0.y,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkRect2D){
|
||||
.offset = (VkOffset2D){MIN2(dest_offset_0.x, dest_offset_1.x),
|
||||
MIN2(dest_offset_0.y, dest_offset_1.y)},
|
||||
.extent = (VkExtent2D){abs(dest_offset_1.x - dest_offset_0.x),
|
||||
abs(dest_offset_1.y - dest_offset_0.y)},
|
||||
});
|
||||
|
||||
VkRenderingInfo rendering_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
|
||||
.renderArea = {
|
||||
@@ -543,19 +526,35 @@ blit_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
|
||||
dst_box.extent.width = dst_x1 - dst_x0;
|
||||
dst_box.extent.height = dst_y1 - dst_y0;
|
||||
|
||||
const VkOffset2D dst_offset_0 = {
|
||||
.x = dst_x0,
|
||||
.y = dst_y0,
|
||||
};
|
||||
const VkOffset2D dst_offset_1 = {
|
||||
.x = dst_x1,
|
||||
.y = dst_y1,
|
||||
};
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = dst_offset_0.x,
|
||||
.y = dst_offset_0.y,
|
||||
.width = dst_offset_1.x - dst_offset_0.x,
|
||||
.height = dst_offset_1.y - dst_offset_0.y,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkRect2D){
|
||||
.offset = (VkOffset2D){MIN2(dst_offset_0.x, dst_offset_1.x),
|
||||
MIN2(dst_offset_0.y, dst_offset_1.y)},
|
||||
.extent = (VkExtent2D){abs(dst_offset_1.x - dst_offset_0.x),
|
||||
abs(dst_offset_1.y - dst_offset_0.y)},
|
||||
});
|
||||
|
||||
const unsigned num_layers = dst_end - dst_start;
|
||||
for (unsigned i = 0; i < num_layers; i++) {
|
||||
struct radv_image_view dst_iview, src_iview;
|
||||
|
||||
const VkOffset2D dst_offset_0 = {
|
||||
.x = dst_x0,
|
||||
.y = dst_y0,
|
||||
};
|
||||
const VkOffset2D dst_offset_1 = {
|
||||
.x = dst_x1,
|
||||
.y = dst_y1,
|
||||
};
|
||||
|
||||
float src_offset_0[3] = {
|
||||
src_x0,
|
||||
src_y0,
|
||||
@@ -598,8 +597,7 @@ blit_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
|
||||
},
|
||||
0, NULL);
|
||||
meta_emit_blit(cmd_buffer, src_image, &src_iview, src_image_layout, src_offset_0,
|
||||
src_offset_1, dst_image, &dst_iview, dst_image_layout, dst_offset_0,
|
||||
dst_offset_1, dst_box, sampler);
|
||||
src_offset_1, dst_image, &dst_iview, dst_image_layout, dst_box, sampler);
|
||||
|
||||
radv_image_view_finish(&dst_iview);
|
||||
radv_image_view_finish(&src_iview);
|
||||
|
||||
@@ -204,6 +204,20 @@ radv_meta_blit2d_normal_dst(struct radv_cmd_buffer *cmd_buffer,
|
||||
struct radv_device *device = cmd_buffer->device;
|
||||
|
||||
for (unsigned r = 0; r < num_rects; ++r) {
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = rects[r].dst_x,
|
||||
.y = rects[r].dst_y,
|
||||
.width = rects[r].width,
|
||||
.height = rects[r].height,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkRect2D){
|
||||
.offset = (VkOffset2D){rects[r].dst_x, rects[r].dst_y},
|
||||
.extent = (VkExtent2D){rects[r].width, rects[r].height},
|
||||
});
|
||||
|
||||
u_foreach_bit(i, dst->aspect_mask)
|
||||
{
|
||||
unsigned aspect_mask = 1u << i;
|
||||
@@ -342,20 +356,6 @@ radv_meta_blit2d_normal_dst(struct radv_cmd_buffer *cmd_buffer,
|
||||
} else
|
||||
unreachable("Processing blit2d with multiple aspects.");
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = rects[r].dst_x,
|
||||
.y = rects[r].dst_y,
|
||||
.width = rects[r].width,
|
||||
.height = rects[r].height,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkRect2D){
|
||||
.offset = (VkOffset2D){rects[r].dst_x, rects[r].dst_y},
|
||||
.extent = (VkExtent2D){rects[r].width, rects[r].height},
|
||||
});
|
||||
|
||||
radv_CmdDraw(radv_cmd_buffer_to_handle(cmd_buffer), 3, 1, 0, 0);
|
||||
|
||||
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
|
||||
|
||||
@@ -231,7 +231,7 @@ cleanup:
|
||||
|
||||
static void
|
||||
emit_resolve(struct radv_cmd_buffer *cmd_buffer, const struct radv_image *src_image,
|
||||
const struct radv_image *dst_image, VkFormat vk_format, const VkRect2D *resolve_area)
|
||||
const struct radv_image *dst_image, VkFormat vk_format)
|
||||
{
|
||||
struct radv_device *device = cmd_buffer->device;
|
||||
VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
|
||||
@@ -245,16 +245,6 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer, const struct radv_image *src_im
|
||||
radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
device->meta_state.resolve.pipeline[fs_key]);
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = resolve_area->offset.x,
|
||||
.y = resolve_area->offset.y,
|
||||
.width = resolve_area->extent.width,
|
||||
.height = resolve_area->extent.height,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, resolve_area);
|
||||
|
||||
radv_CmdDraw(cmd_buffer_h, 3, 1, 0, 0);
|
||||
cmd_buffer->state.flush_bits |=
|
||||
radv_src_access_flush(cmd_buffer, VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, dst_image);
|
||||
@@ -411,6 +401,21 @@ radv_meta_resolve_hardware_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
||||
cmd_buffer->state.flush_bits |= radv_init_dcc(cmd_buffer, dst_image, &range, 0xffffffff);
|
||||
}
|
||||
|
||||
VkRect2D resolve_area = {
|
||||
.offset = { dstOffset.x, dstOffset.y },
|
||||
.extent = { extent.width, extent.height },
|
||||
};
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = resolve_area.offset.x,
|
||||
.y = resolve_area.offset.y,
|
||||
.width = resolve_area.extent.width,
|
||||
.height = resolve_area.extent.height,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &resolve_area);
|
||||
|
||||
for (uint32_t layer = 0; layer < region->srcSubresource.layerCount; ++layer) {
|
||||
|
||||
VkResult ret = build_resolve_pipeline(device, fs_key);
|
||||
@@ -474,10 +479,7 @@ radv_meta_resolve_hardware_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
||||
|
||||
const VkRenderingInfo rendering_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
|
||||
.renderArea = {
|
||||
.offset = { dstOffset.x, dstOffset.y },
|
||||
.extent = { extent.width, extent.height },
|
||||
},
|
||||
.renderArea = resolve_area,
|
||||
.layerCount = 1,
|
||||
.colorAttachmentCount = 2,
|
||||
.pColorAttachments = color_atts,
|
||||
@@ -485,8 +487,7 @@ radv_meta_resolve_hardware_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
||||
|
||||
radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
|
||||
|
||||
emit_resolve(cmd_buffer, src_image, dst_image, dst_iview.vk.format,
|
||||
&rendering_info.renderArea);
|
||||
emit_resolve(cmd_buffer, src_image, dst_image, dst_iview.vk.format);
|
||||
|
||||
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
|
||||
|
||||
@@ -570,6 +571,18 @@ radv_cmd_buffer_resolve_rendering_hw(struct radv_cmd_buffer *cmd_buffer)
|
||||
radv_meta_save(&saved_state, cmd_buffer,
|
||||
RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_RENDER);
|
||||
|
||||
VkRect2D *resolve_area = &saved_state.render.area;
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = resolve_area->offset.x,
|
||||
.y = resolve_area->offset.y,
|
||||
.width = resolve_area->extent.width,
|
||||
.height = resolve_area->extent.height,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, resolve_area);
|
||||
|
||||
for (uint32_t i = 0; i < saved_state.render.color_att_count; ++i) {
|
||||
if (saved_state.render.color_att[i].resolve_iview == NULL)
|
||||
continue;
|
||||
@@ -633,7 +646,7 @@ radv_cmd_buffer_resolve_rendering_hw(struct radv_cmd_buffer *cmd_buffer)
|
||||
continue;
|
||||
}
|
||||
|
||||
emit_resolve(cmd_buffer, src_img, dst_img, dst_iview->vk.format, &saved_state.render.area);
|
||||
emit_resolve(cmd_buffer, src_img, dst_img, dst_iview->vk.format);
|
||||
|
||||
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ radv_get_resolve_pipeline(struct radv_cmd_buffer *cmd_buffer, struct radv_image_
|
||||
static void
|
||||
emit_resolve(struct radv_cmd_buffer *cmd_buffer, struct radv_image_view *src_iview,
|
||||
struct radv_image_view *dest_iview, const VkOffset2D *src_offset,
|
||||
const VkOffset2D *dest_offset, const VkExtent2D *resolve_extent)
|
||||
const VkOffset2D *dest_offset)
|
||||
{
|
||||
struct radv_device *device = cmd_buffer->device;
|
||||
VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
|
||||
@@ -678,20 +678,6 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer, struct radv_image_view *src_ivi
|
||||
|
||||
radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline);
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = dest_offset->x,
|
||||
.y = dest_offset->y,
|
||||
.width = resolve_extent->width,
|
||||
.height = resolve_extent->height,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkRect2D){
|
||||
.offset = *dest_offset,
|
||||
.extent = *resolve_extent,
|
||||
});
|
||||
|
||||
radv_CmdDraw(cmd_buffer_h, 3, 1, 0, 0);
|
||||
cmd_buffer->state.flush_bits |=
|
||||
radv_src_access_flush(cmd_buffer, VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, dest_iview->image);
|
||||
@@ -815,6 +801,21 @@ radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
||||
const struct VkOffset3D srcOffset = vk_image_sanitize_offset(&src_image->vk, region->srcOffset);
|
||||
const struct VkOffset3D dstOffset = vk_image_sanitize_offset(&dest_image->vk, region->dstOffset);
|
||||
|
||||
VkRect2D resolve_area = {
|
||||
.offset = { dstOffset.x, dstOffset.y },
|
||||
.extent = { extent.width, extent.height },
|
||||
};
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = resolve_area.offset.x,
|
||||
.y = resolve_area.offset.y,
|
||||
.width = resolve_area.extent.width,
|
||||
.height = resolve_area.extent.height,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &resolve_area);
|
||||
|
||||
for (uint32_t layer = 0; layer < region->srcSubresource.layerCount; ++layer) {
|
||||
|
||||
struct radv_image_view src_iview;
|
||||
@@ -863,10 +864,7 @@ radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
||||
|
||||
const VkRenderingInfo rendering_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
|
||||
.renderArea = {
|
||||
.offset = { dstOffset.x, dstOffset.y },
|
||||
.extent = { extent.width, extent.height }
|
||||
},
|
||||
.renderArea = resolve_area,
|
||||
.layerCount = 1,
|
||||
.colorAttachmentCount = 1,
|
||||
.pColorAttachments = &color_att,
|
||||
@@ -875,8 +873,7 @@ radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
||||
radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
|
||||
|
||||
emit_resolve(cmd_buffer, &src_iview, &dest_iview, &(VkOffset2D){srcOffset.x, srcOffset.y},
|
||||
&(VkOffset2D){dstOffset.x, dstOffset.y},
|
||||
&(VkExtent2D){extent.width, extent.height});
|
||||
&(VkOffset2D){dstOffset.x, dstOffset.y});
|
||||
|
||||
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
|
||||
|
||||
@@ -909,6 +906,18 @@ radv_cmd_buffer_resolve_rendering_fs(struct radv_cmd_buffer *cmd_buffer)
|
||||
RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_CONSTANTS | RADV_META_SAVE_DESCRIPTORS |
|
||||
RADV_META_SAVE_RENDER);
|
||||
|
||||
VkRect2D *resolve_area = &saved_state.render.area;
|
||||
|
||||
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
|
||||
&(VkViewport){.x = resolve_area->offset.x,
|
||||
.y = resolve_area->offset.y,
|
||||
.width = resolve_area->extent.width,
|
||||
.height = resolve_area->extent.height,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f});
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, resolve_area);
|
||||
|
||||
for (uint32_t i = 0; i < saved_state.render.color_att_count; ++i) {
|
||||
if (saved_state.render.color_att[i].resolve_iview == NULL)
|
||||
continue;
|
||||
@@ -936,7 +945,7 @@ radv_cmd_buffer_resolve_rendering_fs(struct radv_cmd_buffer *cmd_buffer)
|
||||
radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
|
||||
|
||||
emit_resolve(cmd_buffer, src_iview, dst_iview, &saved_state.render.area.offset,
|
||||
&saved_state.render.area.offset, &saved_state.render.area.extent);
|
||||
&saved_state.render.area.offset);
|
||||
|
||||
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user