From a8253221790c89d52e72b219e6fa17c7c293ed63 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 18 May 2023 15:40:11 -0700 Subject: [PATCH] anv: Fix calculation of guardband clipping region. The existing guardband region calculation was mixing up x/y_min with x/y_max in cmd_buffer_emit_viewport(), causing the calculated viewport area to always be an empty region. Luckily intel_calculate_guardband_size() returns a non-empty but bogus guardband region in that case, so this doesn't seem to have led to conformance regressions, but the off-center guardbands could potentially impact performance in geometry-heavy rendering. Fixes: 893fa30afed10394f ("anv: Include scissors in viewport calculations") Reviewed-by: Lionel Landwerlin Reviewed-by: Kenneth Graunke Part-of: (cherry picked from commit 9c26a6b3bbd300024580184be39ff725c02395b6) --- .pick_status.json | 2 +- src/intel/vulkan/genX_cmd_buffer.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 01a0c7e5c6b..4e277a987a0 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2101,7 +2101,7 @@ "description": "anv: Fix calculation of guardband clipping region.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "893fa30afed10394fdee266e0dc772ddd36dfde8" }, diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index f864996c795..f10f2622bdd 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -3036,10 +3036,10 @@ cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer) if (gfx->render_area.extent.width > 0 && gfx->render_area.extent.height > 0) { x_min = MAX2(x_min, gfx->render_area.offset.x); - x_max = MIN2(x_min, gfx->render_area.offset.x + + x_max = MIN2(x_max, gfx->render_area.offset.x + gfx->render_area.extent.width); y_min = MAX2(y_min, gfx->render_area.offset.y); - y_max = MIN2(y_min, gfx->render_area.offset.y + + y_max = MIN2(y_max, gfx->render_area.offset.y + gfx->render_area.extent.height); } @@ -3059,9 +3059,9 @@ cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer) if (i < dyn->vp.scissor_count) { const VkRect2D *scissor = &dyn->vp.scissors[i]; x_min = MAX2(x_min, scissor->offset.x); - x_max = MIN2(x_min, scissor->offset.x + scissor->extent.width); + x_max = MIN2(x_max, scissor->offset.x + scissor->extent.width); y_min = MAX2(y_min, scissor->offset.y); - y_max = MIN2(y_min, scissor->offset.y + scissor->extent.height); + y_max = MIN2(y_max, scissor->offset.y + scissor->extent.height); } /* Only bother calculating the guardband if our known render area is