From nobody Sun Jul 26 12:38:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781877911142319.45270841107174; Fri, 19 Jun 2026 07:05:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1waZpU-00021b-1N; Fri, 19 Jun 2026 10:04:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waZpR-00020t-Le for qemu-devel@nongnu.org; Fri, 19 Jun 2026 10:04:18 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waZpP-0000x7-Be for qemu-devel@nongnu.org; Fri, 19 Jun 2026 10:04:17 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id AB52A59694F; Fri, 19 Jun 2026 16:04:10 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id p0kbqH-Joi5e; Fri, 19 Jun 2026 16:04:08 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 6CF98596948; Fri, 19 Jun 2026 16:04:08 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu From: BALATON Zoltan Subject: [PATCH] ati-vga: Include vga state in the blit context To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , marcandre.lureau@redhat.com, Chad Jablonski Message-Id: <20260619140408.6CF98596948@zero.eik.bme.hu> Date: Fri, 19 Jun 2026 16:04:08 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1781877916804158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The vga state is needed by several functions using the blit context so just include it in the context instead of passing it separately. Signed-off-by: BALATON Zoltan Reviewed-by: Chad Jablonski Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/display/ati_2d.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 48498677c7..ce62b470ab 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -45,6 +45,7 @@ static int ati_bpp_from_datatype(const ATIVGAState *s) } =20 typedef struct { + VGACommonState *vga; int bpp; uint32_t rop3; bool host_data_active; @@ -52,8 +53,6 @@ typedef struct { bool top_to_bottom; bool need_swap; uint32_t frgd_clr; - const uint8_t *palette; - const uint8_t *vram_end; QemuRect scissor; =20 QemuRect dst; @@ -66,8 +65,9 @@ typedef struct { const uint8_t *src_bits; } ATI2DCtx; =20 -static void ati_set_dirty(VGACommonState *vga, const ATI2DCtx *ctx) +static void ati_set_dirty(const ATI2DCtx *ctx) { + VGACommonState *vga =3D ctx->vga; DisplaySurface *ds =3D qemu_console_surface(vga->con); unsigned int bypp =3D ctx->bpp / 8; hwaddr dirty_start =3D ctx->dst_offset + ctx->dst.x * bypp + @@ -94,8 +94,9 @@ static void ati_set_dirty(VGACommonState *vga, const ATI2= DCtx *ctx) } } =20 -static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx) +static void setup_2d_blt_ctx(ATIVGAState *s, ATI2DCtx *ctx) { + ctx->vga =3D &s->vga; ctx->bpp =3D ati_bpp_from_datatype(s); ctx->rop3 =3D s->regs.dp_mix & GMC_ROP3_MASK; ctx->host_data_active =3D s->host_data.active; @@ -103,9 +104,7 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2= DCtx *ctx) ctx->top_to_bottom =3D s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM; ctx->need_swap =3D (HOST_BIG_ENDIAN !=3D s->vga.big_endian_fb); ctx->frgd_clr =3D s->regs.dp_brush_frgd_clr; - ctx->palette =3D s->vga.palette; ctx->dst_offset =3D s->regs.dst_offset; - ctx->vram_end =3D s->vga.vram_ptr + s->vga.vram_size; =20 ctx->scissor.width =3D s->regs.sc_right - s->regs.sc_left + 1; ctx->scissor.height =3D s->regs.sc_bottom - s->regs.sc_top + 1; @@ -153,10 +152,11 @@ static uint32_t make_filler(int bpp, uint32_t color) return color; } =20 -static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman) +static bool ati_2d_do_blt(const ATI2DCtx *ctx, uint8_t use_pixman) { QemuRect vis_src, vis_dst; unsigned int x, y, i, j, bypp =3D ctx->bpp / 8; + const uint8_t *vram_end =3D ctx->vga->vram_ptr + ctx->vga->vram_size; =20 if (!ctx->bpp) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); @@ -167,9 +167,8 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pi= xman) return false; } if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff || - ctx->dst_bits >=3D ctx->vram_end - bypp || - ctx->dst_bits + ctx->dst.x * bypp + (ctx->dst.y + ctx->dst.height)= * - ctx->dst_stride >=3D ctx->vram_end - bypp) { + ctx->dst_bits >=3D vram_end - bypp || ctx->dst_bits + ctx->dst.x *= bypp + + (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >=3D vram_end - b= ypp) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return false; } @@ -206,9 +205,9 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pi= xman) } if (!ctx->host_data_active && (vis_src.x > 0x3fff || vis_src.y > 0x3fff || - ctx->src_bits >=3D ctx->vram_end - bypp || + ctx->src_bits >=3D vram_end - bypp || ctx->src_bits + vis_src.x * bypp + (vis_src.y + vis_dst.height= ) * - ctx->src_stride >=3D ctx->vram_end - bypp)) { + ctx->src_stride >=3D vram_end - bypp)) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return false; } @@ -275,6 +274,7 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pi= xman) case ROP3_BLACKNESS: case ROP3_WHITENESS: { + const uint8_t *palette =3D ctx->vga->palette; uint32_t filler =3D 0; =20 if (ctx->bpp =3D=3D 24) { @@ -286,14 +286,12 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_= pixman) filler =3D make_filler(ctx->bpp, ctx->frgd_clr); break; case ROP3_BLACKNESS: - filler =3D 0xffUL << 24 | rgb_to_pixel32(ctx->palette[0], - ctx->palette[1], - ctx->palette[2]); + filler =3D 0xffUL << 24 | rgb_to_pixel32(palette[0], palette[1= ], + palette[2]); break; case ROP3_WHITENESS: - filler =3D 0xffUL << 24 | rgb_to_pixel32(ctx->palette[3], - ctx->palette[4], - ctx->palette[5]); + filler =3D 0xffUL << 24 | rgb_to_pixel32(palette[3], palette[4= ], + palette[5]); break; } DPRINTF("pixman_fill(%p, %ld, %d, %d, %d, %d, %d, %x)\n", @@ -347,7 +345,7 @@ void ati_2d_blt(ATIVGAState *s) } setup_2d_blt_ctx(s, &ctx); if (ati_2d_do_blt(&ctx, s->use_pixman)) { - ati_set_dirty(&s->vga, &ctx); + ati_set_dirty(&ctx); } } =20 @@ -441,7 +439,7 @@ bool ati_host_data_flush(ATIVGAState *s) DPRINTF("blt %dpx span @ row: %d, col: %d to dst (%d,%d)\n", pix_in_scanline, row, col, chunk.dst.x, chunk.dst.y); if (ati_2d_do_blt(&chunk, s->use_pixman)) { - ati_set_dirty(&s->vga, &chunk); + ati_set_dirty(&chunk); } idx +=3D pix_in_scanline; col +=3D pix_in_scanline; --=20 2.41.3