Skip to content

Commit

Permalink
rdpq: add asserts for large surfaces in autoscissoring and scissoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Nov 8, 2024
1 parent 34f8c33 commit c41a78a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/rdpq.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ inline void rdpq_set_yuv_parms(uint16_t k0, uint16_t k1, uint16_t k2, uint16_t k
assertf(y0fx <= y1fx, "y1 must be greater or equal to y0"); \
assertf(x0fx >= 0, "x0 must be positive"); \
assertf(y0fx >= 0, "y0 must be positive"); \
assertf(x1fx <= 0xFFF, "x1 must be less than 1024"); \
assertf(y1fx <= 0xFFF, "y1 must be less than 1024"); \
__rdpq_set_scissor( \
_carg(x0fx, 0xFFF, 12) | _carg(y0fx, 0xFFF, 0), \
_carg(x1fx, 0xFFF, 12) | _carg(y1fx, 0xFFF, 0)); \
Expand Down
8 changes: 8 additions & 0 deletions src/rdpq/rdpq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,14 @@ void rdpq_set_color_image(const surface_t *surface)
}
assertf((PhysicalAddr(surface->buffer) & 63) == 0,
"buffer pointer is not aligned to 64 bytes, so it cannot be used as RDP color image");
if (rdpq_config & RDPQ_CFG_AUTOSCISSOR) {
// Max horizontal scissor value is 1023, and that allows for a 1023-pixel
// surface in standard mode, and 1024-pixel surface in copy/fill mode.
// Here, for simplicity, we just allow only up to 1023.
// Height is always exclusive, so the maximum height is always 1023.
assertf(surface->width <= 1023, "surface width is too large for auto-scissoring (max: 1023)");
assertf(surface->height <= 1023, "surface height is too large for auto-scissoring (max: 1023)");
}
rdpq_set_color_image_raw(0, PhysicalAddr(surface->buffer),
surface_get_format(surface), surface->width, surface->height, surface->stride);
}
Expand Down

0 comments on commit c41a78a

Please sign in to comment.