From 9c26a6b3bbd300024580184be39ff725c02395b6 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: --- src/intel/vulkan/genX_cmd_buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 7faf29d..6586da6 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -2889,10 +2889,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); } @@ -2912,9 +2912,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 -- 2.7.4