On Fri, 30 Jan 2026, Chad Jablonski wrote:
Previously all state derived from registers was moved to locals. Now we
can mechanically replace those locals with fields on the new ATI2DCtx
struct.
Signed-off-by: Chad Jablonski <[email protected]>
---
vram_end feels a little out of place to me in the ATI2DCtx struct but moving
it into the ctx allows us to eventually remove ATIVGAState entirely. I
also considered moving the dst validation that requires it outside of
ati_2d_blt and making it the responsibility of the caller but that has its
own downsides (forgetting to validate). In the end I left it in the ctx.
---
hw/display/ati_2d.c | 216 +++++++++++++++++++++++++-------------------
1 file changed, 122 insertions(+), 94 deletions(-)
diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c
index a368950182..bc41ad37f6 100644
--- a/hw/display/ati_2d.c
+++ b/hw/display/ati_2d.c
@@ -13,6 +13,7 @@
#include "qemu/log.h"
#include "ui/pixel_ops.h"
#include "ui/console.h"
+#include "ui/rect.h"
/*
* NOTE:
@@ -43,6 +44,26 @@ static int ati_bpp_from_datatype(ATIVGAState *s)
}
}
+typedef struct {
+ int bpp;
+ uint32_t rop3;
+ bool left_to_right;
+ bool top_to_bottom;
+ uint32_t frgd_clr;
+ const uint8_t *palette;
+ const uint8_t *vram_end;
+
+ /* dst */
+ QemuRect dst;
+ int dst_stride;
+ uint8_t *dst_bits;
+
+ /* src */
Since these are already prefixed with src_ and dst_ I'm not sure the
comments add much.
+ QemuRect src;
+ int src_stride;
+ const uint8_t *src_bits;
+} ATI2DCtx;
+
void ati_2d_blt(ATIVGAState *s)
{
/* FIXME it is probably more complex than this and may need to be */
@@ -50,105 +71,111 @@ void ati_2d_blt(ATIVGAState *s)
DisplaySurface *ds = qemu_console_surface(s->vga.con);
bool use_pixman_fill = s->use_pixman & BIT(0);
bool use_pixman_blt = s->use_pixman & BIT(1);
- int rop3 = s->regs.dp_mix & GMC_ROP3_MASK;
- bool left_to_right = s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT;
- bool top_to_bottom = s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM;
- uint32_t frgd_clr = s->regs.dp_brush_frgd_clr;
- uint8_t *palette = s->vga.palette;
+ ATI2DCtx ctx;
To reduce churn later maybe doing the pointer here as you had in the
previous version could help just not with _name but name_ or similar. Now
next patches convert these from ctx.something to ctx->something so this
patch does note help that much.
Regards,
BALATON Zoltan