mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 07:10:15 +01:00
llvmpipe: clamp scissors to be between 0 and max
We need to clamp to make sure invalid shader doesn't crash our driver. The spec says to return 0-th index for everything that's out of bounds. Signed-off-by: Zack Rusin <zackr@vmware.com> Reviewed-by: José Fonseca<jfonseca@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
d7d676252d
commit
c88ce3480c
5 changed files with 13 additions and 3 deletions
|
|
@ -154,4 +154,10 @@ void
|
|||
lp_setup_end_query(struct lp_setup_context *setup,
|
||||
struct llvmpipe_query *pq);
|
||||
|
||||
static INLINE unsigned
|
||||
lp_clamp_scissor_idx(int idx)
|
||||
{
|
||||
return (PIPE_MAX_VIEWPORTS > idx && idx >= 0) ? idx : 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ try_setup_line( struct lp_setup_context *setup,
|
|||
nr_planes = 8;
|
||||
if (setup->viewport_index_slot > 0) {
|
||||
unsigned *udata = (unsigned*)v1[setup->viewport_index_slot];
|
||||
scissor_index = *udata;
|
||||
scissor_index = lp_clamp_scissor_idx(*udata);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ try_setup_point( struct lp_setup_context *setup,
|
|||
|
||||
if (setup->viewport_index_slot > 0) {
|
||||
unsigned *udata = (unsigned*)v0[setup->viewport_index_slot];
|
||||
scissor_index = *udata;
|
||||
scissor_index = lp_clamp_scissor_idx(*udata);
|
||||
}
|
||||
/* Bounding rectangle (in pixels) */
|
||||
{
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ do_triangle_ccw(struct lp_setup_context *setup,
|
|||
nr_planes = 7;
|
||||
if (setup->viewport_index_slot > 0) {
|
||||
unsigned *udata = (unsigned*)v0[setup->viewport_index_slot];
|
||||
scissor_index = *udata;
|
||||
scissor_index = lp_clamp_scissor_idx(*udata);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -71,8 +71,12 @@ llvmpipe_set_scissor_states(struct pipe_context *pipe,
|
|||
|
||||
draw_flush(llvmpipe->draw);
|
||||
|
||||
debug_assert(start_slot < PIPE_MAX_VIEWPORTS);
|
||||
debug_assert((start_slot + num_scissors) <= PIPE_MAX_VIEWPORTS);
|
||||
|
||||
memcpy(llvmpipe->scissors + start_slot, scissors,
|
||||
sizeof(struct pipe_scissor_state) * num_scissors);
|
||||
|
||||
llvmpipe->dirty |= LP_NEW_SCISSOR;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue