anv/hasvk: Clamping Scissor Rect values in a valid range
On cmd_buffer_emit_scissor(), if VkViewport height or width are set to a value lower than 1.0, y_max or x_max can be attributed negative values, causing an overflow. That leads to ScissorRectangleYMax or ScissorRectangleXMax to be set to values on an unsupported range. Clamping x_max and y_max in the valid range solves the problem. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7471 Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20200>
This commit is contained in:
@@ -3509,11 +3509,14 @@ cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer)
|
||||
|
||||
uint32_t y_min = MAX2(s->offset.y, MIN2(vp->y, vp->y + vp->height));
|
||||
uint32_t x_min = MAX2(s->offset.x, vp->x);
|
||||
uint32_t y_max = MIN2(s->offset.y + s->extent.height - 1,
|
||||
int64_t y_max = MIN2(s->offset.y + s->extent.height - 1,
|
||||
MAX2(vp->y, vp->y + vp->height) - 1);
|
||||
uint32_t x_max = MIN2(s->offset.x + s->extent.width - 1,
|
||||
int64_t x_max = MIN2(s->offset.x + s->extent.width - 1,
|
||||
vp->x + vp->width - 1);
|
||||
|
||||
y_max = clamp_int64(y_max, 0, INT16_MAX >> 1);
|
||||
x_max = clamp_int64(x_max, 0, INT16_MAX >> 1);
|
||||
|
||||
/* Do this math using int64_t so overflow gets clamped correctly. */
|
||||
if (cmd_buffer->vk.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) {
|
||||
y_min = clamp_int64((uint64_t) y_min, gfx->render_area.offset.y, max);
|
||||
|
||||
@@ -3094,11 +3094,14 @@ cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer)
|
||||
|
||||
uint32_t y_min = MAX2(s->offset.y, MIN2(vp->y, vp->y + vp->height));
|
||||
uint32_t x_min = MAX2(s->offset.x, vp->x);
|
||||
uint32_t y_max = MIN2(s->offset.y + s->extent.height - 1,
|
||||
int64_t y_max = MIN2(s->offset.y + s->extent.height - 1,
|
||||
MAX2(vp->y, vp->y + vp->height) - 1);
|
||||
uint32_t x_max = MIN2(s->offset.x + s->extent.width - 1,
|
||||
int64_t x_max = MIN2(s->offset.x + s->extent.width - 1,
|
||||
vp->x + vp->width - 1);
|
||||
|
||||
y_max = clamp_int64(y_max, 0, INT16_MAX >> 1);
|
||||
x_max = clamp_int64(x_max, 0, INT16_MAX >> 1);
|
||||
|
||||
/* Do this math using int64_t so overflow gets clamped correctly. */
|
||||
if (cmd_buffer->vk.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) {
|
||||
y_min = clamp_int64((uint64_t) y_min, gfx->render_area.offset.y, max);
|
||||
|
||||
Reference in New Issue
Block a user