From c41a78a21b1108a6435c8b2e3715c96b2282b267 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Sat, 9 Nov 2024 00:00:44 +0100 Subject: [PATCH] rdpq: add asserts for large surfaces in autoscissoring and scissoring --- include/rdpq.h | 2 ++ src/rdpq/rdpq.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/rdpq.h b/include/rdpq.h index be459571a..3a6c383ff 100644 --- a/include/rdpq.h +++ b/include/rdpq.h @@ -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)); \ diff --git a/src/rdpq/rdpq.c b/src/rdpq/rdpq.c index 075697992..8751b9429 100644 --- a/src/rdpq/rdpq.c +++ b/src/rdpq/rdpq.c @@ -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); }