mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
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>
(cherry picked from commit 2e775b8bdb)
This commit is contained in:
parent
a0ffb41002
commit
d4d1f52284
3 changed files with 11 additions and 5 deletions
|
|
@ -3010,7 +3010,7 @@
|
|||
"description": "anv/hasvk: Clamping Scissor Rect values in a valid range",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3494,11 +3494,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);
|
||||
|
|
|
|||
|
|
@ -3647,11 +3647,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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue