hw/display/ati: Include vga state in the blit context
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 <balaton@eik.bme.hu> Reviewed-by: Chad Jablonski <chad@jablonski.xyz> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Message-ID: <20260619140408.6CF98596948@zero.eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
BALATON Zoltan committed
Jun 19, 2026 at 16:04 UTC
5ccef75fa239201905dd7bb7627d5966a2c777da
1 file changed
+18
-20
hw/display/ati_2d.c
+18
-20
@@ -45,6 +45,7 @@ static int ati_bpp_from_datatype(const ATIVGAState *s)
45
}
46
47
typedef struct {
48
+ VGACommonState *vga;
49
int bpp;
50
uint32_t rop3;
51
bool host_data_active;
@@ -52,8 +53,6 @@ typedef struct {
53
bool top_to_bottom;
54
bool need_swap;
55
uint32_t frgd_clr;
55
- const uint8_t *palette;
56
- const uint8_t *vram_end;
56
QemuRect scissor;
57
58
QemuRect dst;
@@ -66,8 +65,9 @@ typedef struct {
65
const uint8_t *src_bits;
66
} ATI2DCtx;
67
69
-static void ati_set_dirty(VGACommonState *vga, const ATI2DCtx *ctx)
68
+static void ati_set_dirty(const ATI2DCtx *ctx)
69
{
70
+ VGACommonState *vga = ctx->vga;
71
DisplaySurface *ds = qemu_console_surface(vga->con);
72
unsigned int bypp = ctx->bpp / 8;
73
hwaddr dirty_start = ctx->dst_offset + ctx->dst.x * bypp +
@@ -94,8 +94,9 @@ static void ati_set_dirty(VGACommonState *vga, const ATI2DCtx *ctx)
94
}
95
}
96
97
-static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
97
+static void setup_2d_blt_ctx(ATIVGAState *s, ATI2DCtx *ctx)
98
{
99
+ ctx->vga = &s->vga;
100
ctx->bpp = ati_bpp_from_datatype(s);
101
ctx->rop3 = s->regs.dp_mix & GMC_ROP3_MASK;
102
ctx->host_data_active = s->host_data.active;
@@ -103,9 +104,7 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
104
ctx->top_to_bottom = s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM;
105
ctx->need_swap = (HOST_BIG_ENDIAN != s->vga.big_endian_fb);
106
ctx->frgd_clr = s->regs.dp_brush_frgd_clr;
106
- ctx->palette = s->vga.palette;
107
ctx->dst_offset = s->regs.dst_offset;
108
- ctx->vram_end = s->vga.vram_ptr + s->vga.vram_size;
108
109
ctx->scissor.width = s->regs.sc_right - s->regs.sc_left + 1;
110
ctx->scissor.height = s->regs.sc_bottom - s->regs.sc_top + 1;
@@ -153,10 +152,11 @@ static uint32_t make_filler(int bpp, uint32_t color)
152
return color;
153
}
154
156
-static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)
155
+static bool ati_2d_do_blt(const ATI2DCtx *ctx, uint8_t use_pixman)
156
{
157
QemuRect vis_src, vis_dst;
158
unsigned int x, y, i, j, bypp = ctx->bpp / 8;
159
+ const uint8_t *vram_end = ctx->vga->vram_ptr + ctx->vga->vram_size;
160
161
if (!ctx->bpp) {
162
qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n");
@@ -167,9 +167,8 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)
167
return false;
168
}
169
if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff ||
170
- ctx->dst_bits >= ctx->vram_end - bypp ||
171
- ctx->dst_bits + ctx->dst.x * bypp + (ctx->dst.y + ctx->dst.height) *
172
- ctx->dst_stride >= ctx->vram_end - bypp) {
170
+ ctx->dst_bits >= vram_end - bypp || ctx->dst_bits + ctx->dst.x * bypp +
171
+ (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >= vram_end - bypp) {
172
qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n");
173
return false;
174
}
@@ -206,9 +205,9 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)
205
}
206
if (!ctx->host_data_active &&
207
(vis_src.x > 0x3fff || vis_src.y > 0x3fff ||
209
- ctx->src_bits >= ctx->vram_end - bypp ||
208
+ ctx->src_bits >= vram_end - bypp ||
209
ctx->src_bits + vis_src.x * bypp + (vis_src.y + vis_dst.height) *
211
- ctx->src_stride >= ctx->vram_end - bypp)) {
210
+ ctx->src_stride >= vram_end - bypp)) {
211
qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n");
212
return false;
213
}
@@ -275,6 +274,7 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)
274
case ROP3_BLACKNESS:
275
case ROP3_WHITENESS:
276
{
277
+ const uint8_t *palette = ctx->vga->palette;
278
uint32_t filler = 0;
279
280
if (ctx->bpp == 24) {
@@ -286,14 +286,12 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)
286
filler = make_filler(ctx->bpp, ctx->frgd_clr);
287
break;
288
case ROP3_BLACKNESS:
289
- filler = 0xffUL << 24 | rgb_to_pixel32(ctx->palette[0],
290
- ctx->palette[1],
291
- ctx->palette[2]);
289
+ filler = 0xffUL << 24 | rgb_to_pixel32(palette[0], palette[1],
290
+ palette[2]);
291
break;
292
case ROP3_WHITENESS:
294
- filler = 0xffUL << 24 | rgb_to_pixel32(ctx->palette[3],
295
- ctx->palette[4],
296
- ctx->palette[5]);
293
+ filler = 0xffUL << 24 | rgb_to_pixel32(palette[3], palette[4],
294
+ palette[5]);
295
break;
296
}
297
DPRINTF("pixman_fill(%p, %ld, %d, %d, %d, %d, %d, %x)\n",
@@ -347,7 +345,7 @@ void ati_2d_blt(ATIVGAState *s)
345
}
346
setup_2d_blt_ctx(s, &ctx);
347
if (ati_2d_do_blt(&ctx, s->use_pixman)) {
350
- ati_set_dirty(&s->vga, &ctx);
348
+ ati_set_dirty(&ctx);
349
}
350
}
351
@@ -446,7 +444,7 @@ bool ati_host_data_flush(ATIVGAState *s)
444
DPRINTF("blt %dpx span @ row: %d, col: %d to dst (%d,%d)\n",
445
pix_in_scanline, row, col, chunk.dst.x, chunk.dst.y);
446
if (ati_2d_do_blt(&chunk, s->use_pixman)) {
449
- ati_set_dirty(&s->vga, &chunk);
447
+ ati_set_dirty(&chunk);
448
}
449
idx += pix_in_scanline;
450
col += pix_in_scanline;