From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224871; cv=none; d=zohomail.com; s=zohoarc; b=XPjVPUiqtgz+/py4WfpXo0/RwSf2omvLLQdFgfz5wz4b9pG+2BkaznIGwIABi2Z9uFGlsyPSGI8apuUqmZvJ6dD90KzTUWiw+pmf1PCGj+Q/iaX95ZPLbejGfrGbM02UZJqYApBuu9nKw6g6fAn8rA7oTY7Hm6BzT6l6RmfBax4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224871; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=laB0U4bo8HCPOWBM9uXAA+xB62yuJOctU/qX8DNsXjM=; b=X12NvdSgp7ZxsicsxOs3ZjaHO/2qGwFJaayXLw2/SurCZ4kHbTY0rObUXJWMFIdMN+lNeiI2Z8CA1qoVKUhR4Co/asVJnaZ90u41VXi/hHanw37SskeTcmDYQglfmZE2bDWQe8PKVZUb0Nc3vGrSXt77Fxqd2qYA7bFNkckYpKA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224871120249.06798480823056; Fri, 27 Feb 2026 12:41:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e2-0001Z6-HU; Fri, 27 Feb 2026 15:41:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dx-0001Lo-Hf for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:02 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dv-0007Ok-A6 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:01 -0500 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3076514001D8; Fri, 27 Feb 2026 15:40:58 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 27 Feb 2026 15:40:58 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:40:57 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 10ff023b; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224858; x= 1772311258; bh=laB0U4bo8HCPOWBM9uXAA+xB62yuJOctU/qX8DNsXjM=; b=L gTz5wMcgKVaVRu144xBtSqBr0/P4+3BVHsyWbx3PhSj6+nDddjTN7NqDQzIR6uEF 5Jajs85EfE7pwGizyhIR/YNjUIPBHp/D9WQfGTJn1oat3T0KHo1ExJ6GdSJJrWrr VjyG/eioIK4Amhd9ZCO+Jm9XNkzhKJEgzarLXyHzGhQxC/mhpHTRXpjhDpwVS3L9 c1vnMwVeL8kRJDt0VGxpUjOMylcHGDmydD//4RtFKOG6JLvX0YMAv42cbdlIv6Tb CVptkn9F5/1HHXVetvMrtHVy5QcE2tQ8NEASZ/0akODHK1QGleHtZzaqiER5phaV 2LuQ4oxdiJaZtAskVStrw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224858; x=1772311258; bh=l aB0U4bo8HCPOWBM9uXAA+xB62yuJOctU/qX8DNsXjM=; b=iv1u06VzLB9m5Vxg4 d/8rub181c4l9ZJCppss9YrbA6wj1IQuCqaJ3pzFECcf3WBJyaimy0HkoYcGHdxg t4nf+X62/9tA570LJH371IXau1M//hDUD2xZM7uCyK8hTb+VsiDzn/7/YdIJZb8x V98Pg1sEcd0ulOXM4FCCzv2D0IZtUh2i7oft4SMkJqew07g65x5fQzqurqCXCga9 y5tBlq8H6+xLImnMpWPsrnnAU/NzAu6X39Nj7oYycUw9Te86MoL1G8NNiyVJqDZp QIn6w7kpXcKgTUU+K2XZStFL3zi34brKman8xOfP+zkT8V5DfinaogCVApY7K5x+ b2v4A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthhgrugesjh grsghlohhnshhkihdrgiihiidprhgtphhtthhopehmrghrtggrnhgurhgvrdhluhhrvggr uhesrhgvughhrghtrdgtohhmpdhrtghpthhtohepkhhrrgigvghlsehrvgguhhgrthdrtg homhdprhgtphhtthhopegsrghlrghtohhnsegvihhkrdgsmhgvrdhhuhdprhgtphhtthho pehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhg X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 01/18] ati-vga: Fix framebuffer mapping by using hardware-correct aperture sizes Date: Fri, 27 Feb 2026 15:39:27 -0500 Message-ID: <20260227203944.746471-2-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224873771158500 Content-Type: text/plain; charset="utf-8" Rage 128 cards always request 64MB for their linear (framebuffer) aperture and R100 cards always request 128MB. This is regardless of the amount of physical VRAM on the board. The following are results from real hardware tests: Card VRAM PCI BAR0 CONFIG_MEMSIZE CONFIG= _APER_SIZE AGP_APER_OFFSET Reviewed-by: BALATON Zoltan ----------------------- ---- -------- -------------- ------= ---------- --------------- Rage 128 Pro Ultra TF 32MB 64MB 0x02000000 0x020= 00000 0x02000000 Rage 128 RF/SG AGP 16MB 64MB 0x01000000 0x020= 00000 0x02000000 Radeon R100 QD [Radeon 7200] 64MB 128MB 0x04000000 0x040= 00000 N/A Radeon RV100 QY [Radeon 7000/VE] 32MB 128MB 0x02000000 0x040= 00000 N/A Previously the linear aperture (BAR0) would match the VRAM size. This discrepancy caused issues with the X.org and XFree86 r128 drivers. These drivers apply a mask of 0xfc000000 (2^26 =3D 64MB) to the linear aperture address. If that address is not on a 64MB boundary the framebuffer points to an incorrect memory location. Testing shows that the Radeon R100 also has a BAR0 larger than VRAM (128MB in this case) and the X.org radeon driver also masks to 64MB. For Rage 128, CONFIG_APER_SIZE also differs from the previous value and the behavior stated in the documentation. The Rage 128 register guide states that it should contain the size of the VRAM + AGP memory. The cards tested above show that this isn't the case. These tests also included enabling/disabling AGP with 8MB of memory. It didn't change the contents of CONFIG_APER_SIZE. For both Rage 128 and R100 the CONFIG_APER_SIZE is half of the PCI BAR0 siz= e. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati.c | 16 ++++++++++++++-- hw/display/ati_int.h | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index e9c3ad2cd1..8438a77de0 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -361,7 +361,7 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, = unsigned int size) PCI_BASE_ADDRESS_0, size) & 0xffffff= f0; break; case CONFIG_APER_SIZE: - val =3D s->vga.vram_size / 2; + val =3D memory_region_size(&s->linear_aper) / 2; break; case CONFIG_REG_1_BASE: val =3D pci_default_read_config(&s->dev, @@ -952,6 +952,7 @@ static void ati_vga_realize(PCIDevice *dev, Error **err= p) { ATIVGAState *s =3D ATI_VGA(dev); VGACommonState *vga =3D &s->vga; + uint64_t aper_size; =20 #ifndef CONFIG_PIXMAN if (s->use_pixman !=3D 0) { @@ -1011,7 +1012,18 @@ static void ati_vga_realize(PCIDevice *dev, Error **= errp) /* io space is alias to beginning of mmregs */ memory_region_init_alias(&s->io, OBJECT(s), "ati.io", &s->mm, 0, 0x100= ); =20 - pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &vga->vram); + /* + * The framebuffer is at the beginning of the linear aperture. For + * Rage128 the upper half of the aperture is reserved for an AGP + * window (which we do not emulate.) + */ + aper_size =3D s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF ? + ATI_RAGE128_LINEAR_APER_SIZE : ATI_R100_LINEAR_APER_SIZE; + memory_region_init(&s->linear_aper, OBJECT(dev), "ati-linear-aperture0= ", + aper_size); + memory_region_add_subregion(&s->linear_aper, 0, &vga->vram); + + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->linear_ape= r); pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io); pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mm); =20 diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index f5a47b82b0..708cc1dd3a 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -10,6 +10,7 @@ #define ATI_INT_H =20 #include "qemu/timer.h" +#include "qemu/units.h" #include "hw/pci/pci_device.h" #include "hw/i2c/bitbang_i2c.h" #include "vga_int.h" @@ -29,6 +30,9 @@ /* Radeon RV100 (VE) */ #define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159 =20 +#define ATI_RAGE128_LINEAR_APER_SIZE (64 * MiB) +#define ATI_R100_LINEAR_APER_SIZE (128 * MiB) + #define TYPE_ATI_VGA "ati-vga" OBJECT_DECLARE_SIMPLE_TYPE(ATIVGAState, ATI_VGA) =20 @@ -97,6 +101,7 @@ struct ATIVGAState { QEMUCursor *cursor; QEMUTimer vblank_timer; bitbang_i2c_interface bbi2c; + MemoryRegion linear_aper; MemoryRegion io; MemoryRegion mm; ATIVGARegs regs; --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224935; cv=none; d=zohomail.com; s=zohoarc; b=ja6cAIzfCaqND+Y5FNyh1t8t+VcMoooqmAokQjhRj3ogsLWYsq14X4cmVr3GeODVaAP7Hgcr2CINZaflFA32vr/3kNPbXoP5eBYhFOlPNw1+0zG3RAmnjsaUxXLUr91Exw1nkIlnLiQnOD/qkBLFMKT7RjdNTMYqtXZPMK/dthg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224935; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ABtiVlaCZkrAUapG4ZkghRtl4BtewIcQLfaOOoKZZwo=; b=n5qIbccQWc6vPeT1FHu+T2BqnE+kRCH6Ycc6BgSMlm+J/hYSaoKiX0cO0REOLBAPjoi1kGlUs8mpwKPhbaock0OtFmMQaoEgI2m/zzukxaqVBx9vQAoqi0J0CvEzaSPGyy6rh4zXPXkqH5lCxiQMOGLtnHlqNvKJKXf0Gq1l/Qs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224935721924.6922020413625; Fri, 27 Feb 2026 12:42:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eA-0002UB-TG; Fri, 27 Feb 2026 15:41:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0001Pl-Q5 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dw-0007Ou-00 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:02 -0500 Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id B5DDAEC0633; Fri, 27 Feb 2026 15:40:58 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 27 Feb 2026 15:40:58 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:40:58 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 7c776d26; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224858; x= 1772311258; bh=ABtiVlaCZkrAUapG4ZkghRtl4BtewIcQLfaOOoKZZwo=; b=g hTsCywnugsCpoiwV+587HAeQThacyykacXsfbWifdCwPKV2b2MoL6DLfjefA4X2b n1ZTZBwduZ7DlffMvzYKLnU7jlf5Y0EizHQovImMz+bQCKmkfp1igKGyFTZb3YlD 25E8MyR40Ch9E9WBHF91J4gGCJgt+UeEQOckdi9Lj+myOQhI0fS3e5aRDmbH/twQ bGMrcYstRtHuYiBOels5/huUvVXbeFVoVMDCI/57o3/DIVlXw3stKHv4dzMgqHra OY2/AdkYXuYrUXncCqd0sVaI7WwA74H5f4wsICoyucMpI3lhuuy+YM8iUuTYe13z 0NN022ddm9QwKWn8xgqkw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224858; x=1772311258; bh=A BtiVlaCZkrAUapG4ZkghRtl4BtewIcQLfaOOoKZZwo=; b=VtIFlPbntc+XuBDGA HgyIG+rk2l22vRdCTUdAONUZh0k7rPcIbmQ0A2OBdI15mViEUKGsQ8zLNLR0/x8+ gdJZxZoEZZALon1RVPUcRFFSm+YOfo8h2qtWiGQo5I4QkMyj8Qjlq6Se5gQpp3RQ gDtZWbg9lxo9nztI1bGdePwi2bNwJjrgJEExB627U8l6NYcKnNl2TNdYMV97gX+v htFg33TSaegKspuUwQqNLZktn52yuSFHiXjLP4MMx0s5jiGLJPLAUhMFJPTBUXms JAEOLW/QX6HuaMkpeHHPO197wHN/L5uFRN9yz/JZOMAexUDlfVzVBv9RXU2NVWDF 7BDjQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehqvghmuhdqug gvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtghpthhtohepmhgrrhgtrghnughrvgdrlhhu rhgvrghusehrvgguhhgrthdrtghomhdprhgtphhtthhopegthhgrugesjhgrsghlohhnsh hkihdrgiihiidprhgtphhtthhopehkrhgrgigvlhesrhgvughhrghtrdgtohhmpdhrtghp thhtohepsggrlhgrthhonhesvghikhdrsghmvgdrhhhu X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 02/18] ati-vga: Fix DST_PITCH and SRC_PITCH reads Date: Fri, 27 Feb 2026 15:39:28 -0500 Message-ID: <20260227203944.746471-3-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.144; envelope-from=chad@jablonski.xyz; helo=fout-a1-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224937654158500 Content-Type: text/plain; charset="utf-8" Reading DST_PITCH and SRC_PITCH on the Rage 128 is broken. The read handlers attempt to construct the value from pitch and tile bits in the register state but mistakenly AND them instead of ORing them. This means the pitch is always zero on read. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 8438a77de0..777a6b0a2e 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -438,7 +438,7 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, = unsigned int size) case DST_PITCH: val =3D s->regs.dst_pitch; if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { - val &=3D s->regs.dst_tile << 16; + val |=3D s->regs.dst_tile << 16; } break; case DST_WIDTH: @@ -468,7 +468,7 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, = unsigned int size) case SRC_PITCH: val =3D s->regs.src_pitch; if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { - val &=3D s->regs.src_tile << 16; + val |=3D s->regs.src_tile << 16; } break; case DP_BRUSH_BKGD_CLR: --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224936; cv=none; d=zohomail.com; s=zohoarc; b=I9b+expRDrqMdDrH/hC6MqfQwTqFD06qvoB7vrY5zauCJkLj+S4OrjrYaI6QxMP40otN8Vu+GzuL/t2eP0ugvOAXEbnkL+pEvdfHYENuaQzOgTs07/c4+jXhZ/DLPYxQQ9jGc2DoGN0KK2U+Dn2MW77EiN0Gz3G+HksFIkKpWXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224936; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UFSgWoKS6dct4PEaVxUuYg6ee7pN7SwnivHZWSj1kps=; b=ZDTliixMN9x7wneU4oLUeU9hNsYhEydgLHoMXx3j6l1NelgBKNrgzbnqt8q79b+WsX6WC8j2B+DXFZP9NUnwF0GxakGQYa/Wfqt1W8gik+j+a/GlSXNxeu9pWpdBxOMM1ZxiZLz8IQcI8CQyLVRTUwuyH05VrZrcjcFFodAkVH4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224936618489.30350042878615; Fri, 27 Feb 2026 12:42:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eU-0002uY-An; Fri, 27 Feb 2026 15:41:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0001Pq-LA for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dw-0007Ov-0H for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:02 -0500 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id C8BE714001EC; Fri, 27 Feb 2026 15:40:58 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 27 Feb 2026 15:40:58 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:40:58 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 88c8ec3a; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224858; x= 1772311258; bh=UFSgWoKS6dct4PEaVxUuYg6ee7pN7SwnivHZWSj1kps=; b=A 7fHA9QWR/MeLLExJbPT/RI86AxwIsb6mkyrF4JEMsXA+AebPc8yGZM1SJzfQa7i5 sBFIvl63NfjTtxKxmPJFJMgBNbmFJ0fCvrv40nr8Gbsj/uOWBA1/dxNEXfPAoVKU MY3j4weJCqoUq56txIZxRSNEYu66MsbvLMCZ9FHBLIqSoo6rB5NUoEJATxAb+rwX 4Sp8O03uBkqgP3mqHL7q7FVAsaaoHT6FkzX6zjKXxFOHMJdQGSzWH9Oj8o0wNC5d 2O8ouxOl3QM1d53CkrgI6zA8c2I3rEghhirx5+0aM7HmP1g1gPxLB7zNVEvM2O3/ ysiqrHrjN2HSbma4TKZgg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224858; x=1772311258; bh=U FSgWoKS6dct4PEaVxUuYg6ee7pN7SwnivHZWSj1kps=; b=Uc7b+bvqfvPiXmgct 1J6hQA4359UnHg46V8Em7h6rdvWkANW2t2zVElDUG7kNarJN0rlYoMJlf8a02yD2 XyGMH2MOSWYIeER4FozBSl7BWTs6+AK5ak37IOpzmPJnnpu9GeczoaSbLjNK0AsR WS6lbRT4pGrFySC10vwp90CRWy+wHzHIqq8uMYgBLQezoCdABE0irTkRdt/eC/jR JsoC+3++uKbGJuCvINVfs7qJt3PIR4tCTMpFTmAUJPWWmG3XKAPRY/SwaasarfpX CDv+uokRt0F77ZfnJtkyn+Y+g2YcaYEdHmykrwKcVYUJj9Nah9/4BBgOJFl+daHG fC1EQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthhgrugesjh grsghlohhnshhkihdrgiihiidprhgtphhtthhopehmrghrtggrnhgurhgvrdhluhhrvggr uhesrhgvughhrghtrdgtohhmpdhrtghpthhtohepkhhrrgigvghlsehrvgguhhgrthdrtg homhdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtghp thhtohepsggrlhgrthhonhesvghikhdrsghmvgdrhhhu X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 03/18] ati-vga: Read aliased values from DP_GUI_MASTER_CNTL Date: Fri, 27 Feb 2026 15:39:29 -0500 Message-ID: <20260227203944.746471-4-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224937666158500 Content-Type: text/plain; charset="utf-8" DP_GUI_MASTER_CNTL aliases several fields from DP_DATATYPE and DP_MIX. These were being written correctly but not returned on a read of DP_GUI_MASTER_CNTL. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati.c | 8 +++++++- hw/display/ati_regs.h | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 777a6b0a2e..028efd13e1 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -460,7 +460,13 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr,= unsigned int size) val =3D s->regs.dst_y; break; case DP_GUI_MASTER_CNTL: - val =3D s->regs.dp_gui_master_cntl; + /* DP_GUI_MASTER_CNTL aliases fields from DP_MIX and DP_DATATYPE */ + val =3D s->regs.dp_gui_master_cntl | + ((s->regs.dp_datatype & DP_BRUSH_DATATYPE) >> 4) | + ((s->regs.dp_datatype & DP_DST_DATATYPE) << 8) | + ((s->regs.dp_datatype & DP_SRC_DATATYPE) >> 4) | + (s->regs.dp_mix & DP_ROP3) | + ((s->regs.dp_mix & DP_SRC_SOURCE) << 16); break; case SRC_OFFSET: val =3D s->regs.src_offset; diff --git a/hw/display/ati_regs.h b/hw/display/ati_regs.h index d7127748ff..0a0825db04 100644 --- a/hw/display/ati_regs.h +++ b/hw/display/ati_regs.h @@ -386,6 +386,9 @@ #define DST_16BPP 0x00000004 #define DST_24BPP 0x00000005 #define DST_32BPP 0x00000006 +#define DP_DST_DATATYPE 0x0000000f +#define DP_BRUSH_DATATYPE 0x00000f00 +#define DP_SRC_DATATYPE 0x00030000 =20 #define BRUSH_SOLIDCOLOR 0x00000d00 =20 @@ -437,6 +440,8 @@ #define DP_SRC_RECT 0x00000200 #define DP_SRC_HOST 0x00000300 #define DP_SRC_HOST_BYTEALIGN 0x00000400 +#define DP_SRC_SOURCE 0x00000700 +#define DP_ROP3 0x00ff0000 =20 /* LVDS_GEN_CNTL constants */ #define LVDS_BL_MOD_LEVEL_MASK 0x0000ff00 --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224929; cv=none; d=zohomail.com; s=zohoarc; b=WbENUo1b/3aCQ7SM+5FGMU0bOFyPFNhfxcUr5FqxQ//ZWcy2dsOzhvpFCpK2otoXt89L3NqZs02DhVKY1Tfiw9OTGbFwVgpXWD6siSuR0gQoNjiLnupqHZNfzdi4Ns3WkWaH+85m7BvA4AKbMAbuEEdsVXAjigqZGzyrnoS0cvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224929; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iZFopa7BN2v/Wniu8RWnxAcgO5JG4vm8jdapubVGmHM=; b=CuS3FboujuHT1xotWDrqsNpPyMLRo0kXLWCajgyVA5C+CclBEBuIbD3+5TL9CXI4h9QQgJEWtkhmXC65itf/H06+e2jhp4HRzfFfA6cQWglh8a/+Gt41PeQwnW3R8da6kEncLjSFBVZ19mNMRuihooUPyu2PHAI7sCCbMPF8RVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224929972870.7964355434611; Fri, 27 Feb 2026 12:42:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e3-0001h9-N7; Fri, 27 Feb 2026 15:41:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0001Pp-KZ for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dw-0007PQ-La for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:02 -0500 Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id 7274CEC0637; Fri, 27 Feb 2026 15:40:59 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 27 Feb 2026 15:40:59 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:40:58 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 6b0b3d11; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224859; x= 1772311259; bh=iZFopa7BN2v/Wniu8RWnxAcgO5JG4vm8jdapubVGmHM=; b=c BQmNHlZDAA/XOguGHmz2F4JtcS33Lf8yW/Gyhhb78enDASfexAco8aF89svJpdSW WTDASqon2+U5hOZcrU+a+VZe8azm1eZ3v//tdame0KIM7l06aZau6Qfs5KDl7v9m 1YwpjwcnVQP+c7UU71v0txVhArqPZ1BMBkzpucrxMaR6uOKcj0eN7rMez16bdicz Ra2BvkoHjp37byySEBR5bF631TmqFbT2LRZAFv0NfrXcNqAUJCQeDp4XxhboXN48 gAHfQSdGIFDTPpPMXrmHelJvx0aag8nRjqus9uEyKk4Q3AAo9DkGkmwLdlswBL0T EBejeKqYJCiLp504CHJyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224859; x=1772311259; bh=i ZFopa7BN2v/Wniu8RWnxAcgO5JG4vm8jdapubVGmHM=; b=oaREIXSrRvE38Aihh DXxE27dHeHP0AmS72fw6v0/ExAERHWqDF/yJqNT+26R6oxChBCxt/QpdaTwRFVEo gO/sYbrmHUUt1ow6lL5kn2cDVStKsV4mHnT8OcgIbC0PYF/h5Xu6xeEmFjwg6T3C ZeLPt4b+pttp6m4ve6D4IDydNUTyTaM9s41ghos9Vu8GmBhC+tJk5FSNOy//lnab peEihGz0pYCBJ2DQynikHcWD5Vpc0BdjqFGPUjiqvPM3si27B3zqX6WSF2dV6Jfq wecuIcsgiWBIs2jC9HsbkOn8RQiNGmelZUc7w/o/Q1q/JgcEg9Qr7Rum8ATENB1B n91cQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsrghlrghtoh hnsegvihhkrdgsmhgvrdhhuhdprhgtphhtthhopehmrghrtggrnhgurhgvrdhluhhrvggr uhesrhgvughhrghtrdgtohhmpdhrtghpthhtoheptghhrggusehjrggslhhonhhskhhird ighiiipdhrtghpthhtohepkhhrrgigvghlsehrvgguhhgrthdrtghomhdprhgtphhtthho pehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhg X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 04/18] ati-vga: Latch src and dst pitch and offset on master_cntl default Date: Fri, 27 Feb 2026 15:39:30 -0500 Message-ID: <20260227203944.746471-5-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.144; envelope-from=chad@jablonski.xyz; helo=fout-a1-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224931718158500 Content-Type: text/plain; charset="utf-8" Hardware testing on the Rage 128 confirms that (SRC/DST)_OFFSET, and (SRC/DST)_PITCH are latched when (SRC/DST)_PITCH_OFFSET_CNTL bits in DP_GUI_MASTER_CNTL are set to "default". The earlier approach looked at the state of the (SRC/DST)_PITCH_OFFSET_CNTL bits when offset and pitch registers were used. This meant that when (SRC/DST)_PITCH_OFFSET_CNTL was reset to "leave alone" the old values stored in the registers would return. This is not how the real hardware works. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati.c | 9 +++++++++ hw/display/ati_2d.c | 13 ++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 028efd13e1..ce23e5e48b 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -868,6 +868,15 @@ static void ati_mm_write(void *opaque, hwaddr addr, s->regs.dp_datatype =3D (data & 0x0f00) >> 8 | (data & 0x30f0) << = 4 | (data & 0x4000) << 16; s->regs.dp_mix =3D (data & GMC_ROP3_MASK) | (data & 0x7000000) >> = 16; + + if (!(data & GMC_SRC_PITCH_OFFSET_CNTL)) { + s->regs.src_offset =3D s->regs.default_offset; + s->regs.src_pitch =3D s->regs.default_pitch; + } + if (!(data & GMC_DST_PITCH_OFFSET_CNTL)) { + s->regs.dst_offset =3D s->regs.default_offset; + s->regs.dst_pitch =3D s->regs.default_pitch; + } break; case DST_WIDTH_X: s->regs.dst_x =3D data & 0x3fff; diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 309bb5ccb6..a8c4c534b9 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -43,8 +43,6 @@ static int ati_bpp_from_datatype(ATIVGAState *s) } } =20 -#define DEFAULT_CNTL (s->regs.dp_gui_master_cntl & GMC_DST_PITCH_OFFSET_CN= TL) - void ati_2d_blt(ATIVGAState *s) { /* FIXME it is probably more complex than this and may need to be */ @@ -63,13 +61,12 @@ void ati_2d_blt(ATIVGAState *s) qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); return; } - int dst_stride =3D DEFAULT_CNTL ? s->regs.dst_pitch : s->regs.default_= pitch; + int dst_stride =3D s->regs.dst_pitch; if (!dst_stride) { qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n"); return; } - uint8_t *dst_bits =3D s->vga.vram_ptr + (DEFAULT_CNTL ? - s->regs.dst_offset : s->regs.default_offset); + uint8_t *dst_bits =3D s->vga.vram_ptr + s->regs.dst_offset; =20 if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { dst_bits +=3D s->regs.crtc_offset & 0x07ffffff; @@ -97,14 +94,12 @@ void ati_2d_blt(ATIVGAState *s) s->regs.src_x : s->regs.src_x + 1 - s->regs.dst_wid= th); unsigned src_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? s->regs.src_y : s->regs.src_y + 1 - s->regs.dst_hei= ght); - int src_stride =3D DEFAULT_CNTL ? - s->regs.src_pitch : s->regs.default_pitch; + int src_stride =3D s->regs.src_pitch; if (!src_stride) { qemu_log_mask(LOG_GUEST_ERROR, "Zero source pitch\n"); return; } - uint8_t *src_bits =3D s->vga.vram_ptr + (DEFAULT_CNTL ? - s->regs.src_offset : s->regs.default_offset); + uint8_t *src_bits =3D s->vga.vram_ptr + s->regs.src_offset; =20 if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { src_bits +=3D s->regs.crtc_offset & 0x07ffffff; --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224898; cv=none; d=zohomail.com; s=zohoarc; b=JhKRBfljUBqDLvlB1L/JTqcuA1c0nNAJf6svU71g7MRSKvbDL5p0Y2RHDhDDEwVALhsDzywksHuXYvZQkG05LpQc5JQlg87ZIKZF6pL9ARYU048s9cw7ObgxNkK5H/cXaZL4XeP/b/87Gd/blLNqeVnlfZHxaUOF5lDSbOCd6Ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224898; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t09fhcpWk+aZIQ1AgyqKwCgGRfq7HEmlcpbHugFS7Os=; b=Nf4Uwdqv3AB31Iu1xZkCKOdBaItzMjF/8O4kl6Ad8tT66Zbs2YFMqlgqPvwQ8TIrrIHXWWL4ZfglHMPbRz39j7OlypAnRER2rnumOe512HS9x+Uzg+ykSSEGpi1+Oq7YbG71AJRqeAqnDhRnrBhRN1I2AHVydqPCI6XcBUmKW5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224898368299.1106982922786; Fri, 27 Feb 2026 12:41:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e2-0001Zg-Na; Fri, 27 Feb 2026 15:41:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0001Po-P0 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dw-0007PP-Ls for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:02 -0500 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 614AE14001ED; Fri, 27 Feb 2026 15:40:59 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 27 Feb 2026 15:40:59 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:40:58 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 8727a4bb; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224859; x= 1772311259; bh=t09fhcpWk+aZIQ1AgyqKwCgGRfq7HEmlcpbHugFS7Os=; b=g 1NVmxTRbPNKcP4fYMC2oIceBW921zYpqMcbmRI0Dot19PB7B67Zj2U7mNCdDU5OC Z9ecCFyRxrI7VyA+8VyWtiak7wRbRgTk3IIt6kEADaWlVTJr24wzgECT2SIl+eI8 B+XbSTiO6yrQivH/mTTPsl4pqj6tmtIUxsXvmRJGGuiL7lZzu5IjOierCiUuC2sD fgV6/H0UlgbzwQwH6KiRe5q0R497/try2vaWt/I0oQBd1LbssnGG6mzVddpfLw/G XdzFr0ECP3M5qefx4+fObkQ0/nOcJnX/Rf0jMHafPHoXMNvP4WEB6uF+tHUFSInT heNu3wBjSUQbXuwHnMxnQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224859; x=1772311259; bh=t 09fhcpWk+aZIQ1AgyqKwCgGRfq7HEmlcpbHugFS7Os=; b=Ihqn3CvarevGfwiY6 5yQbxEydXPYCLOT7j9vyuCdao/J8P3g5E1yhP0CXnk3tcyStEAZoDmZy9SqS1+Zm bMFYePPWcQTGVLpIEkiwW6xOE/gdRplEecIiqOFdsm9c9DC9w7YnWI5Rp52nZJkE TCYNL7nBjIBQL1QiEzs5bfwiPocuwaWDhQfmEeVKH6JzziTY0GXlu/TKwl7KmLRr ntlC7MJcmJ8k3ThqQbGlfhEmSjJUzwU3fbuRfOH3fb67Bc3Jh+SdXtlwiCD+gIi5 N+t+FvDdCo/5WTGB40EnEjmPAVgGv+dOVjponmqbQFvTVhJP4Og6BAjQWUXiQZ5/ 2InIg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehqvghmuhdqug gvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtghpthhtohepmhgrrhgtrghnughrvgdrlhhu rhgvrghusehrvgguhhgrthdrtghomhdprhgtphhtthhopehkrhgrgigvlhesrhgvughhrg htrdgtohhmpdhrtghpthhtoheptghhrggusehjrggslhhonhhskhhirdighiiipdhrtghp thhtohepsggrlhgrthhonhesvghikhdrsghmvgdrhhhu X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 05/18] ati-vga: Implement foreground and background color register writes Date: Fri, 27 Feb 2026 15:39:31 -0500 Message-ID: <20260227203944.746471-6-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224899486158500 Content-Type: text/plain; charset="utf-8" These are straightforward 32-bit register write handlers. They're necessary for a future patch which will use them for color expansion from monochrome host data transfers. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/display/ati.c b/hw/display/ati.c index ce23e5e48b..26fc74b19b 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -924,6 +924,12 @@ static void ati_mm_write(void *opaque, hwaddr addr, case DP_CNTL: s->regs.dp_cntl =3D data; break; + case DP_SRC_FRGD_CLR: + s->regs.dp_src_frgd_clr =3D data; + break; + case DP_SRC_BKGD_CLR: + s->regs.dp_src_bkgd_clr =3D data; + break; case DP_DATATYPE: s->regs.dp_datatype =3D data & 0xe0070f0f; break; --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224932; cv=none; d=zohomail.com; s=zohoarc; b=RxTJeiQ75eAldhmHCinKnWHa8Q4Kk2EIoyhs7T61V4hFL5cXswEBPpdspFt+fCehlBXTLaLEZ2waDjp17MyKcy1I+AMwmZs0z7ZJ34l1jSgPDb+kguPfajQwEg6uhvLjZ9dImKJdURYV4JH2o17uRLm3CG+0KsobsvLboew787I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224932; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t0OpkvKmgs3r3p5IFcwqLrOzfIoWRJB1S+bWvMool0c=; b=Il2eW93/zKIA2dYh6m1QGcYXXjFBJafipgvI3EoMGdgrsYIxyKdlYOPLkX1jxzqAwH0a0SJH49arTPVqFPX/CWZkZENahBjpIWyBhTYRJ+mw90oV4eh2nEk4aMeKAc/hCNTeYKLMFLI9bcaV+sdGUy9ZCw0J9zINmrxgMu469jY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224932794161.46784191897586; Fri, 27 Feb 2026 12:42:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e5-0001tj-N4; Fri, 27 Feb 2026 15:41:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e1-0001Sp-Gr for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dx-0007Pc-5c for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:04 -0500 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id E67C2EC063D; Fri, 27 Feb 2026 15:40:59 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 27 Feb 2026 15:40:59 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:40:59 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id c45cbb91; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224859; x= 1772311259; bh=t0OpkvKmgs3r3p5IFcwqLrOzfIoWRJB1S+bWvMool0c=; b=C eV/gHxuXv9p570wMLN3NRTeP4GeuYVUefZBeSNKTtF4GjOSvd6erlvNv4o8i3Xd2 fY5dwkrCDiHZuqYRiJBCPDTVdHmHz65XO5+LRnKjuiH0KLGTNQffIWksnMb/6+E4 sYQBVxIVLSpyou729dN+H/5vMGQPnSP8/uZoClgUE7bHQL+S2aTA00kZ2vpDvtoQ /vbJ0wada2Zlj7UXGmj8+wO0wMm4eBdzL5a0cUo32ntSHn8Mezu6soX9QozivqPE qNs6JDZbpKDDobk4Z1CkdHBu0aiZ93TsETJtjMQuDUzdrLSYPeZy7x4z3Lsku6+3 uS5iUNkONLYW4escleKyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224859; x=1772311259; bh=t 0OpkvKmgs3r3p5IFcwqLrOzfIoWRJB1S+bWvMool0c=; b=lrW2RDvhN/U0CmhI7 JYRDPzLYkPEl4mFHBduQihFTI+/LTOoz/xZcvokejgCZxagQW7W1U8wf8b4iflAZ MK3f7egIcNY7trRZGMhtTs7exH7RLDPoXmNu2bgvZz0CzFdp2Q1IwOf1Ynb7FjOo HABuRFGMLNGOAwF+LEnbKqxk5GqSpZcsNfW+lUsLpy/10/m/jKEesuWNibqoikBY A7wzIxBgO/3RqoU+q0BnShUBjxVNpU+HpxjvAdRoSRxNGSgRBqgOQBR6lhtPD+0z V2x4COxKzIHRE5zH4xmEeHnhRyQi5XbtzP1uDJDEe87TwHdXjovA3KXCPQP0Mkcj R0DFg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthhgrugesjh grsghlohhnshhkihdrgiihiidprhgtphhtthhopegsrghlrghtohhnsegvihhkrdgsmhgv rdhhuhdprhgtphhtthhopehmrghrtggrnhgurhgvrdhluhhrvggruhesrhgvughhrghtrd gtohhmpdhrtghpthhtohepkhhrrgigvghlsehrvgguhhgrthdrtghomhdprhgtphhtthho pehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhg X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 06/18] ati-vga: Add scissor clipping register support Date: Fri, 27 Feb 2026 15:39:32 -0500 Message-ID: <20260227203944.746471-7-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.144; envelope-from=chad@jablonski.xyz; helo=fout-a1-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224933712158500 Content-Type: text/plain; charset="utf-8" Implement read and write operations on SC_TOP_LEFT, SC_BOTTOM_RIGHT, and SRC_SC_BOTTOM_RIGHT registers. These registers are also updated when the src and/or dst clipping fields on DP_GUI_MASTER_CNTL are set to default clipping. Scissor clipping is used when rendering text in X.org. The r128 driver sends host data much wider than is necessary to draw a glyph and cuts it down to size using clipping before rendering. The actual clipping implementation follows in a future patch. This also includes a very minor refactor of the combined default_sc_bottom_right field in the registers struct to default_sc_bottom and default_sc_right. This was done to stay consistent with the other scissor registers and prevent repeated masking and extraction. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- v5: Removed unused default_sc_bottom_right field --- hw/display/ati.c | 70 +++++++++++++++++++++++++++++++++++++++++-- hw/display/ati_int.h | 9 +++++- hw/display/ati_regs.h | 2 ++ 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 26fc74b19b..6cf243bcf9 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -514,7 +514,32 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr,= unsigned int size) val |=3D s->regs.default_tile << 16; break; case DEFAULT_SC_BOTTOM_RIGHT: - val =3D s->regs.default_sc_bottom_right; + val =3D (s->regs.default_sc_bottom << 16) | + s->regs.default_sc_right; + break; + case SC_TOP: + val =3D s->regs.sc_top; + break; + case SC_LEFT: + val =3D s->regs.sc_left; + break; + case SC_BOTTOM: + val =3D s->regs.sc_bottom; + break; + case SC_RIGHT: + val =3D s->regs.sc_right; + break; + case SRC_SC_BOTTOM: + val =3D s->regs.src_sc_bottom; + break; + case SRC_SC_RIGHT: + val =3D s->regs.src_sc_right; + break; + case SC_TOP_LEFT: + case SC_BOTTOM_RIGHT: + case SRC_SC_BOTTOM_RIGHT: + qemu_log_mask(LOG_GUEST_ERROR, + "Read from write-only register 0x%x\n", (unsigned)ad= dr); break; default: break; @@ -877,6 +902,16 @@ static void ati_mm_write(void *opaque, hwaddr addr, s->regs.dst_offset =3D s->regs.default_offset; s->regs.dst_pitch =3D s->regs.default_pitch; } + if (!(data & GMC_SRC_CLIPPING)) { + s->regs.src_sc_right =3D s->regs.default_sc_right; + s->regs.src_sc_bottom =3D s->regs.default_sc_bottom; + } + if (!(data & GMC_DST_CLIPPING)) { + s->regs.sc_top =3D 0; + s->regs.sc_left =3D 0; + s->regs.sc_right =3D s->regs.default_sc_right; + s->regs.sc_bottom =3D s->regs.default_sc_bottom; + } break; case DST_WIDTH_X: s->regs.dst_x =3D data & 0x3fff; @@ -956,7 +991,38 @@ static void ati_mm_write(void *opaque, hwaddr addr, } break; case DEFAULT_SC_BOTTOM_RIGHT: - s->regs.default_sc_bottom_right =3D data & 0x3fff3fff; + s->regs.default_sc_right =3D data & 0x3fff; + s->regs.default_sc_bottom =3D (data >> 16) & 0x3fff; + break; + case SC_TOP_LEFT: + s->regs.sc_left =3D data & 0x3fff; + s->regs.sc_top =3D (data >> 16) & 0x3fff; + break; + case SC_LEFT: + s->regs.sc_left =3D data & 0x3fff; + break; + case SC_TOP: + s->regs.sc_top =3D data & 0x3fff; + break; + case SC_BOTTOM_RIGHT: + s->regs.sc_right =3D data & 0x3fff; + s->regs.sc_bottom =3D (data >> 16) & 0x3fff; + break; + case SC_RIGHT: + s->regs.sc_right =3D data & 0x3fff; + break; + case SC_BOTTOM: + s->regs.sc_bottom =3D data & 0x3fff; + break; + case SRC_SC_BOTTOM_RIGHT: + s->regs.src_sc_right =3D data & 0x3fff; + s->regs.src_sc_bottom =3D (data >> 16) & 0x3fff; + break; + case SRC_SC_RIGHT: + s->regs.src_sc_right =3D data & 0x3fff; + break; + case SRC_SC_BOTTOM: + s->regs.src_sc_bottom =3D data & 0x3fff; break; default: break; diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index 708cc1dd3a..98f57ca5fa 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -78,14 +78,21 @@ typedef struct ATIVGARegs { uint32_t dp_brush_frgd_clr; uint32_t dp_src_frgd_clr; uint32_t dp_src_bkgd_clr; + uint16_t sc_top; + uint16_t sc_left; + uint16_t sc_bottom; + uint16_t sc_right; + uint16_t src_sc_bottom; + uint16_t src_sc_right; uint32_t dp_cntl; uint32_t dp_datatype; uint32_t dp_mix; uint32_t dp_write_mask; uint32_t default_offset; uint32_t default_pitch; + uint16_t default_sc_bottom; + uint16_t default_sc_right; uint32_t default_tile; - uint32_t default_sc_bottom_right; } ATIVGARegs; =20 struct ATIVGAState { diff --git a/hw/display/ati_regs.h b/hw/display/ati_regs.h index 0a0825db04..3999edb9b7 100644 --- a/hw/display/ati_regs.h +++ b/hw/display/ati_regs.h @@ -397,6 +397,8 @@ #define GMC_DST_PITCH_OFFSET_CNTL 0x00000002 #define GMC_SRC_CLIP_DEFAULT 0x00000000 #define GMC_DST_CLIP_DEFAULT 0x00000000 +#define GMC_SRC_CLIPPING 0x00000004 +#define GMC_DST_CLIPPING 0x00000008 #define GMC_BRUSH_SOLIDCOLOR 0x000000d0 #define GMC_SRC_DSTCOLOR 0x00003000 #define GMC_BYTE_ORDER_MSB_TO_LSB 0x00000000 --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224916; cv=none; d=zohomail.com; s=zohoarc; b=XB7k4XrqHw1ESUQj3MzfWEYsd7oUyt3j3T2HXELhEeVs6iLS1QvvGbWneMDjBRoDPkIvEdzeP2bdI1txgNHj3CJMbILzyaUjqQI5K81iyJGkNiXG4YuvJmo0niEfXfVBikjDJ7IwD93rwTLLGuE6Yw/OmcxkB0RFuwyOXliapzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224916; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jEmCW2CJeKwiBoliiD/nWnWhBy0/mPCAScNKxecv+dg=; b=GDDLUyeNHQbvIdOeLXGKUCJtIovF3H2YrJgFam/+4KzMCMsm7WyxCNM0N7qywez0K1DohN/YRKABAkEBtVL26QFDbWWTeAMLmQ3n6/gWn7JVjFKXW5P7megg4HqfPOwd8QlxOJYaYHum9JmQ8kl8Mvv2bFXb8PzkJiT03su/laY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224916833967.4949399235043; Fri, 27 Feb 2026 12:41:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e4-0001jU-0O; Fri, 27 Feb 2026 15:41:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e0-0001Pt-0T for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dx-0007Ph-6R for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:03 -0500 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 128C214001DD; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Fri, 27 Feb 2026 15:41:00 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:40:59 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id aea6f75c; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224860; x= 1772311260; bh=jEmCW2CJeKwiBoliiD/nWnWhBy0/mPCAScNKxecv+dg=; b=e hH6Eu9NRpui14eWRqkGPxAiwRSsh61OvB1I9VsR3GUKhSJ1KzG491pItRoPOTchG RMXm2tEcOEwr999kA2celFK2SvxQz6T2UGzYHJydBL/wBDvJ5VdiakCb5g207R+c 8qucVwGjgVClO6sa5GJnYiWTKAJVoimSnvreXs5Pq61CbpfWvGkLccOeq30Cz9sr 3UM3BYKXZugrGlB529eMnVV4g8VAaCKPXW4tWUQR7nmZNpH02v5FZKDUHbkZwUw6 c7ZIWg3AZeJJWlHyy95yKJaLeQQME3OULG9Ml6iI0QgG10hb/bjKSQkUK6Ic421w LAJ1dNPkV+lScaLq7Ysjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224860; x=1772311260; bh=j EmCW2CJeKwiBoliiD/nWnWhBy0/mPCAScNKxecv+dg=; b=M9NwLFpERbG4qyNIQ pviZNFw7pgGEMarIHzcyg0hBSK36E5o9BAnmADUthysO76DSTzKV82Fw59HCZDkT IN0t5JEWL5qDwApEKfK7HwpJCTxgFhi8Djs1z2zkwuCj/ZiJRcDZurr3lvpcUoQX l/rGjoux+2omOvtpBzL9zm6e0QDU2l2Ot1T05qPcEEmyRJVphD0MfbxWMaoMODJi LZIc30HmAK6XdGdAg95PJLFVHiEIV2ZOFL8+h64zV5VENEwaFwvfzS+4nyNGeZKx ocqeZQ8pCEEQ6YFISTTQG5v8Bre6gGyfaoWUEZ9kO5u6nE+T0Z06VlhjfZF9qceD iOkKw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehkrhgrgigvlh esrhgvughhrghtrdgtohhmpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhn uhdrohhrghdprhgtphhtthhopegsrghlrghtohhnsegvihhkrdgsmhgvrdhhuhdprhgtph htthhopegthhgrugesjhgrsghlohhnshhkihdrgiihiidprhgtphhtthhopehmrghrtggr nhgurhgvrdhluhhrvggruhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 07/18] ati-vga: Remove dst_x/y updates after blit Date: Fri, 27 Feb 2026 15:39:33 -0500 Message-ID: <20260227203944.746471-8-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224917560158500 Content-Type: text/plain; charset="utf-8" The Mobility M6 register reference (DST_HEIGHT_WIDTH) states that dst_y is updated after a blit but this appears to not be the case. Hardware testing revealed that both the R128 and R100 do not update dst_x or dst_y after a blit, regardless of the source. This removes the update. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati_2d.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index a8c4c534b9..cfc7bf9789 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -174,10 +174,6 @@ void ati_2d_blt(ATIVGAState *s) dst_y * surface_stride(ds), s->regs.dst_height * surface_stride(ds= )); } - s->regs.dst_x =3D (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? - dst_x + s->regs.dst_width : dst_x); - s->regs.dst_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? - dst_y + s->regs.dst_height : dst_y); break; } case ROP3_PATCOPY: @@ -228,8 +224,6 @@ void ati_2d_blt(ATIVGAState *s) dst_y * surface_stride(ds), s->regs.dst_height * surface_stride(ds= )); } - s->regs.dst_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? - dst_y + s->regs.dst_height : dst_y); break; } default: --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224914; cv=none; d=zohomail.com; s=zohoarc; b=NyxZ5PlivIrQF6Rhy/EQ0qqAMXV7RMsHD2+CrVLi12OdPo5+iyhiTZLAPiCeMA8ZDIZlGqKl8zLMaE/xygl1HmdNdagPXMD0M9HLCUAEoagnaGbaw0um+7zAo+AQW+lTotlloNOwi20XaCtviw/SFFIYBRTvH4xmOSrSyfRavgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224914; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/8gQrPLmCC6i3JQzdW1xashObqgDvg5nx94NGxDJ1P0=; b=gIyTZe/WJOsm2vp+mEOIXhGioOTEliHYTtiF5/dzd4mC7AhQgLvdFiKnzBVHRQcnL9QLjAHmPHbATqcnLIhKF+PjlMSj3XRA5v6DS/MUDy9OGkO17TkWcrEpOk6lcBRQRSpj+Fy2IfQ9MT/Klbjol/coqzoWyCHT3nfsa5n7Gxk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224914491358.2420349377152; Fri, 27 Feb 2026 12:41:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e8-0002Gf-Uw; Fri, 27 Feb 2026 15:41:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0001Pm-Ne for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dx-0007Ps-5t for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:02 -0500 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 71647140017B; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 27 Feb 2026 15:41:00 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:40:59 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id d22ddc48; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224860; x= 1772311260; bh=/8gQrPLmCC6i3JQzdW1xashObqgDvg5nx94NGxDJ1P0=; b=A r/gR8Lj8PrPN00T2xdEAlaSy59+oDNDlxggVgAkI7xkmRS1E8rPhhWQnb+M7Tge+ 8ZwVcUUjAlfPhJprhd55oEwI8wzr53WuheC2fbre7Zo6S9jhIqFYZcc08z8eqPdy M8xMGajGRv4rRnyJCz6HqNcgutFIa0vqN4fTA1s+hHHJ2xcnTDlUURr7uL6hkxmL VQedMNL0eK3KdVsf+CvYbdHSINtnsazcEy1vmFTka7QfgG3kPgl9CsJiNgTtEiWU QNfBlj/ipK9osvlT4lfgxu5fMXo/SV6FkMvvHHURua7vgHVtyljgojZKRrOLyWf+ DnFbo3mo7aokqzLhIHRUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224860; x=1772311260; bh=/ 8gQrPLmCC6i3JQzdW1xashObqgDvg5nx94NGxDJ1P0=; b=tVNabtkYqU4CoZMP9 qu9YJLZUiFIn//NdXjRZo7FnVpJSqOnNMUCUYLpOD7QK+u55iyyFSA+nanCl7e1Z HRU5EFtaGMK5TlqG1fKNYf38stMZLzkvTVIOcP8iZcKGiZ9zuKPiODbFuVDVScm/ JzBpvBj3M9VwxC2WF5N16IU2l89cusnN/PuNwMtB3J+CZBpegS/ALyX452UYQG8Q WLT7aVAeficmZ1xhcUbjnTnJCpWFmLuMWUs6SJc9h7fsDqwYfbSmaKk/IDe6Kmky NKVRbOBLkL63jFh0QxWLwj42URDQjcofDt53DqcS0JSFB4svZ1dvI/vRqAvzAeuN H8/TA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsrghlrghtoh hnsegvihhkrdgsmhgvrdhhuhdprhgtphhtthhopegthhgrugesjhgrsghlohhnshhkihdr giihiidprhgtphhtthhopehmrghrtggrnhgurhgvrdhluhhrvggruhesrhgvughhrghtrd gtohhmpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghdprhgt phhtthhopehkrhgrgigvlhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 08/18] ati-vga: Consolidate dirty region tracking in ati_2d_blt Date: Fri, 27 Feb 2026 15:39:34 -0500 Message-ID: <20260227203944.746471-9-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224915574158500 Content-Type: text/plain; charset="utf-8" Both supported ROPs follow the same memory set dirty logic. This consolidates that logic to remove the duplication. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati_2d.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index cfc7bf9789..980cdd6ac0 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -43,15 +43,28 @@ static int ati_bpp_from_datatype(ATIVGAState *s) } } =20 +static void ati_set_dirty(ATIVGAState *s, + const uint8_t *dst_bits, unsigned dst_y) +{ + VGACommonState *vga =3D &s->vga; + DisplaySurface *ds =3D qemu_console_surface(vga->con); + + DPRINTF("%p %u ds: %p %d %d rop: %x\n", vga->vram_ptr, vga->vbe_start_= addr, + surface_data(ds), surface_stride(ds), surface_bits_per_pixel(d= s), + (s->regs.dp_mix & GMC_ROP3_MASK) >> 16); + if (dst_bits >=3D vga->vram_ptr + vga->vbe_start_addr && + dst_bits < vga->vram_ptr + vga->vbe_start_addr + + vga->vbe_regs[VBE_DISPI_INDEX_YRES] * vga->vbe_line_offset) { + memory_region_set_dirty(&vga->vram, vga->vbe_start_addr + + s->regs.dst_offset + dst_y * surface_strid= e(ds), + s->regs.dst_height * surface_stride(ds)); + } +} + void ati_2d_blt(ATIVGAState *s) { /* FIXME it is probably more complex than this and may need to be */ /* rewritten but for now as a start just to get some output: */ - DisplaySurface *ds =3D qemu_console_surface(s->vga.con); - DPRINTF("%p %u ds: %p %d %d rop: %x\n", s->vga.vram_ptr, - s->vga.vbe_start_addr, surface_data(ds), surface_stride(ds), - surface_bits_per_pixel(ds), - (s->regs.dp_mix & GMC_ROP3_MASK) >> 16); unsigned dst_x =3D (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? s->regs.dst_x : s->regs.dst_x + 1 - s->regs.dst_widt= h); unsigned dst_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? @@ -166,14 +179,6 @@ void ati_2d_blt(ATIVGAState *s) memmove(&dst_bits[i], &src_bits[j], s->regs.dst_width * by= pp); } } - if (dst_bits >=3D s->vga.vram_ptr + s->vga.vbe_start_addr && - dst_bits < s->vga.vram_ptr + s->vga.vbe_start_addr + - s->vga.vbe_regs[VBE_DISPI_INDEX_YRES] * s->vga.vbe_line_offset= ) { - memory_region_set_dirty(&s->vga.vram, s->vga.vbe_start_addr + - s->regs.dst_offset + - dst_y * surface_stride(ds), - s->regs.dst_height * surface_stride(ds= )); - } break; } case ROP3_PATCOPY: @@ -216,18 +221,13 @@ void ati_2d_blt(ATIVGAState *s) } } } - if (dst_bits >=3D s->vga.vram_ptr + s->vga.vbe_start_addr && - dst_bits < s->vga.vram_ptr + s->vga.vbe_start_addr + - s->vga.vbe_regs[VBE_DISPI_INDEX_YRES] * s->vga.vbe_line_offset= ) { - memory_region_set_dirty(&s->vga.vram, s->vga.vbe_start_addr + - s->regs.dst_offset + - dst_y * surface_stride(ds), - s->regs.dst_height * surface_stride(ds= )); - } break; } default: qemu_log_mask(LOG_UNIMP, "Unimplemented ati_2d blt op %x\n", (s->regs.dp_mix & GMC_ROP3_MASK) >> 16); + return; } + + ati_set_dirty(s, dst_bits, dst_y); } --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224937; cv=none; d=zohomail.com; s=zohoarc; b=n1D5VWXmEG/Qymxa6skF83GfCpxWIbk5iXM0ajfQT+zueC7NC80VFj1Ui5ZiulOy+YNsSrOhytDN9oQL3x7nnbiKKO+UnjWnVw/svZL+Rqqb1vNu9F1eaRL+qUUmFcMSXR6YFveM3Ypgq28cNEmsp3f7xkcR3XXhCq8SL1/abqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224937; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lCg0ydTcvECcQMK7tczPRmb81G6yDxSx9iHuTCxaTpc=; b=kpcz8lIc0siqMbtKK8NU2AOJzNs8iMQA5TH6yxnJU9Ka9o19KsdcsvvX17ac/jMUN8LSM+K+Upb0+PRwCCzLXsjXBLPoHe/vW/lHvr6iADnm1y41FGVlc53g/vU3aIRNU9jzsasuxHxJXmlk/EPMzIBDzc+sTWJ02TkWZcHyaZA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224937792471.83042684881264; Fri, 27 Feb 2026 12:42:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e5-0001pR-0e; Fri, 27 Feb 2026 15:41:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e1-0001TG-IH for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dy-0007Q7-7H for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:04 -0500 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8993514001F0; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Fri, 27 Feb 2026 15:41:00 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 4b8c2ff7; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224860; x= 1772311260; bh=lCg0ydTcvECcQMK7tczPRmb81G6yDxSx9iHuTCxaTpc=; b=M 0mgbY1k/EVWUWXYAXVOXoQ1XuTkMoaKNRJZ9CAjq7znhfLhnZnFK0Jelzqf8nQii 7baclHwpKIP4I1fU4mcJ/W6XcaiENbG5QkO4aGwqjWoa+YXeXhQpNpH7USig6P1Q aFzKyoYiqwECRcySYi3R5/dhhvOj1ItBSgzMTEcPlMRXLK6YC7hM+2U5ll55oWRn GZGR0rZCLuEsHfevmU5YHXVQw1ZxA0MYRxQp+ZUncG1aWiONMYgAoGuGPnv2RXuk 9orVwExs0mHwZ1XZOie8LXnYg3rmmT+xpOKv6irbdmKF1MTX43bqzsQD9pAsAgxi K46MFA6zXpo9RkjnN+8EA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224860; x=1772311260; bh=l Cg0ydTcvECcQMK7tczPRmb81G6yDxSx9iHuTCxaTpc=; b=OeLgFTiOr4QnftgqY IEYg4wuT8ieRnC3K9LooU9J64OzaqW0Ezvv8aJOQEpCKa2pANq4Tk7Q5FN6xazvc 49xnc8xNDRr10mgxQ9T2Ly8Nme6++ZnH7+bhtUdeZ9tP4PuRy63fEfylUogLMUBo kXnfghZzgP9TVJNPK/TpdIUslqiGqub8cSu3F/WPY0O+0B/opoN1V0vYUmNyErgv Kx11HH5hcfbt9nwBrPhftOR7JpSK2uBU0lr7zyPv6hK23nf3mJ1YhOfa0kKmibQW k+fst2EpqSz73ZuYDrjnfp7FpZVRcw8Qy6S8BdUBw+wBli7qtl6ltYyrB/Y+gm9Z pq3xw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsrghlrghtoh hnsegvihhkrdgsmhgvrdhhuhdprhgtphhtthhopehmrghrtggrnhgurhgvrdhluhhrvggr uhesrhgvughhrghtrdgtohhmpdhrtghpthhtoheptghhrggusehjrggslhhonhhskhhird ighiiipdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghdprhgt phhtthhopehkrhgrgigvlhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 09/18] ati-vga: Remove src and dst stride mutation in ati_2d_blt Date: Fri, 27 Feb 2026 15:39:35 -0500 Message-ID: <20260227203944.746471-10-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224939723158500 Content-Type: text/plain; charset="utf-8" Pixman requires stride in words. So over the course of the ati_2d_blt function both src and dst stride were mutated before being passed to pixman and then back afterwards. This creates local variables holding src and dst stride in words avoiding the potentially confusing mutation. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati_2d.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 980cdd6ac0..e366774835 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -85,6 +85,7 @@ void ati_2d_blt(ATIVGAState *s) dst_bits +=3D s->regs.crtc_offset & 0x07ffffff; dst_stride *=3D bpp; } + int dst_stride_words =3D dst_stride / sizeof(uint32_t); uint8_t *end =3D s->vga.vram_ptr + s->vga.vram_size; if (dst_x > 0x3fff || dst_y > 0x3fff || dst_bits >=3D end || dst_bits + dst_x @@ -118,6 +119,7 @@ void ati_2d_blt(ATIVGAState *s) src_bits +=3D s->regs.crtc_offset & 0x07ffffff; src_stride *=3D bpp; } + int src_stride_words =3D src_stride / sizeof(uint32_t); if (src_x > 0x3fff || src_y > 0x3fff || src_bits >=3D end || src_bits + src_x + (src_y + s->regs.dst_height) * src_stride >=3D end) { @@ -125,34 +127,32 @@ void ati_2d_blt(ATIVGAState *s) return; } =20 - src_stride /=3D sizeof(uint32_t); - dst_stride /=3D sizeof(uint32_t); DPRINTF("pixman_blt(%p, %p, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d= )\n", - src_bits, dst_bits, src_stride, dst_stride, bpp, bpp, - src_x, src_y, dst_x, dst_y, + src_bits, dst_bits, src_stride_words, dst_stride_words, + bpp, bpp, src_x, src_y, dst_x, dst_y, s->regs.dst_width, s->regs.dst_height); #ifdef CONFIG_PIXMAN if ((s->use_pixman & BIT(1)) && s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT && s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) { fallback =3D !pixman_blt((uint32_t *)src_bits, (uint32_t *)dst= _bits, - src_stride, dst_stride, bpp, bpp, + src_stride_words, dst_stride_words, bpp= , bpp, src_x, src_y, dst_x, dst_y, s->regs.dst_width, s->regs.dst_height); } else if (s->use_pixman & BIT(1)) { /* FIXME: We only really need a temporary if src and dst overl= ap */ int llb =3D s->regs.dst_width * (bpp / 8); - int tmp_stride =3D DIV_ROUND_UP(llb, sizeof(uint32_t)); - uint32_t *tmp =3D g_malloc(tmp_stride * sizeof(uint32_t) * + int tmp_stride_words =3D DIV_ROUND_UP(llb, sizeof(uint32_t)); + uint32_t *tmp =3D g_malloc(tmp_stride_words * sizeof(uint32_t)= * s->regs.dst_height); fallback =3D !pixman_blt((uint32_t *)src_bits, tmp, - src_stride, tmp_stride, bpp, bpp, + src_stride_words, tmp_stride_words, bpp= , bpp, src_x, src_y, 0, 0, s->regs.dst_width, s->regs.dst_height); if (!fallback) { fallback =3D !pixman_blt(tmp, (uint32_t *)dst_bits, - tmp_stride, dst_stride, bpp, bpp, - 0, 0, dst_x, dst_y, + tmp_stride_words, dst_stride_words, + bpp, bpp, 0, 0, dst_x, dst_y, s->regs.dst_width, s->regs.dst_heig= ht); } g_free(tmp); @@ -163,18 +163,15 @@ void ati_2d_blt(ATIVGAState *s) } if (fallback) { unsigned int y, i, j, bypp =3D bpp / 8; - unsigned int src_pitch =3D src_stride * sizeof(uint32_t); - unsigned int dst_pitch =3D dst_stride * sizeof(uint32_t); - for (y =3D 0; y < s->regs.dst_height; y++) { i =3D dst_x * bypp; j =3D src_x * bypp; if (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) { - i +=3D (dst_y + y) * dst_pitch; - j +=3D (src_y + y) * src_pitch; + i +=3D (dst_y + y) * dst_stride; + j +=3D (src_y + y) * src_stride; } else { - i +=3D (dst_y + s->regs.dst_height - 1 - y) * dst_pitc= h; - j +=3D (src_y + s->regs.dst_height - 1 - y) * src_pitc= h; + i +=3D (dst_y + s->regs.dst_height - 1 - y) * dst_stri= de; + j +=3D (src_y + s->regs.dst_height - 1 - y) * src_stri= de; } memmove(&dst_bits[i], &src_bits[j], s->regs.dst_width * by= pp); } @@ -201,21 +198,19 @@ void ati_2d_blt(ATIVGAState *s) break; } =20 - dst_stride /=3D sizeof(uint32_t); DPRINTF("pixman_fill(%p, %d, %d, %d, %d, %d, %d, %x)\n", - dst_bits, dst_stride, bpp, dst_x, dst_y, + dst_bits, dst_stride_words, bpp, dst_x, dst_y, s->regs.dst_width, s->regs.dst_height, filler); #ifdef CONFIG_PIXMAN if (!(s->use_pixman & BIT(0)) || - !pixman_fill((uint32_t *)dst_bits, dst_stride, bpp, dst_x, dst= _y, - s->regs.dst_width, s->regs.dst_height, filler)) + !pixman_fill((uint32_t *)dst_bits, dst_stride_words, bpp, dst_= x, + dst_y, s->regs.dst_width, s->regs.dst_height, fil= ler)) #endif { /* fallback when pixman failed or we don't want to call it */ unsigned int x, y, i, bypp =3D bpp / 8; - unsigned int dst_pitch =3D dst_stride * sizeof(uint32_t); for (y =3D 0; y < s->regs.dst_height; y++) { - i =3D dst_x * bypp + (dst_y + y) * dst_pitch; + i =3D dst_x * bypp + (dst_y + y) * dst_stride; for (x =3D 0; x < s->regs.dst_width; x++, i +=3D bypp) { stn_he_p(&dst_bits[i], bypp, filler); } --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224906; cv=none; d=zohomail.com; s=zohoarc; b=LHhws9rXMIjWooSqBEveRH2B0eLigsr2gSimfo2nfB0yVcZUN//LL1Gj0Gcd/WBo958kUn1U6Qg7jZZViVTwc8+hWjMokFzdz3/Zdlyjcu3uieZo/QygHZ1ox76h/CG2iyeDlW5WOEAse/1rBvAFwZe/eDYqQnngcz0yHIcG+cU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224906; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=u1D2gj1k8+504f+ZE233OXp2oE6ZzFIewogKeoLNcOA=; b=Exc91d6e7iARO0M5awMAX/flF4h+yAcdHNEFsVgzW7Uf4O7o/RQRSKIZmCj3oJnwkPevKsYN8wOfePT9geQkLORRA/d6sE8rDKyXrdO60m0+6yvVcOCr+KBxTbP5iZzSHdW91/KyZ6ERW1JefHsbd5QkjYtC0kyeU3OyGftx9Ys= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224906401126.25116595190218; Fri, 27 Feb 2026 12:41:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eD-0002bm-61; Fri, 27 Feb 2026 15:41:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e1-0001T9-Hl for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dy-0007Pz-79 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:04 -0500 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id EC98FEC0636; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 27 Feb 2026 15:41:00 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id bf826384; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224860; x= 1772311260; bh=u1D2gj1k8+504f+ZE233OXp2oE6ZzFIewogKeoLNcOA=; b=s lRkq5OD032aqH27fu+CEjB/nvqKFpLdabMVk8QK1RSZQC4Nf1fZ5LEXpdWhc80+N LqtgD4ooqr6JeFJgB7/Z5MdvuhnHcJ2j7Y/XgH0Z7Zm24LTDrEJ4s+jbZHdum/VR 73/rgzWb8BLtze1cyiNyZE9Um3WaEGqqSn/QJSWUx9NWmviN79mFRavTmlDVZDQ+ a4I50k6RH4ho9s7lO1WxEvz7jZY0vBB8OJ24poEHJmD9u4p4MAJ5VTXIqzX2h4Pz QBLPNzE6jvrjCyYejUnxO4ne1vpVnrCBkELsuVWeHSpTKAb7K5MWFXsQmKdDnleK tleaRBDfWwwBV6vMl1O8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224860; x=1772311260; bh=u 1D2gj1k8+504f+ZE233OXp2oE6ZzFIewogKeoLNcOA=; b=RSgkc2iifZdFmOoRW zi2zSJhzugcHzPKgChA+D3RGHEpDPqhDkijCFaVAsJ5JtdMEff0L0gnUFA842hJ6 91yurKM82L7p68B9IhMiG8e0IVNdebNvYNMjFXlM43mHfDSGCqyRH49usdMTef9M 0VtHDkCF/feYblMP/WMsPP8jZcmSDAK/p7i4h2esIiMiczwkexflKj+xIQcxRMO/ itSusuWmylRnZC3Wn/LKH6JpXY4b+pZ/MkpEV2hhNKuixSQ0KR4wFL6yziT9UXxI chMVd3MK0BrvvaK8MldMRFP6fgBOc8NKiZg8y/PevaajbFsI8m0ExRd9GNwfUSc2 GGclA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthhgrugesjh grsghlohhnshhkihdrgiihiidprhgtphhtthhopegsrghlrghtohhnsegvihhkrdgsmhgv rdhhuhdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtg hpthhtohepmhgrrhgtrghnughrvgdrlhhurhgvrghusehrvgguhhgrthdrtghomhdprhgt phhtthhopehkrhgrgigvlhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 10/18] ati-vga: Use local variables for register values in ati_2d_blt Date: Fri, 27 Feb 2026 15:39:36 -0500 Message-ID: <20260227203944.746471-11-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.144; envelope-from=chad@jablonski.xyz; helo=fout-a1-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224907813158500 Content-Type: text/plain; charset="utf-8" ati_2d_blt uses a mixture of locals and direct register access of needed state. This assigns all values derived from register state to local variables. It prepares the function for a larger refactor that removes the dependency on the full device and direct register access entirely. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati_2d.c | 97 ++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index e366774835..689b07b4d0 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -65,10 +65,20 @@ void ati_2d_blt(ATIVGAState *s) { /* FIXME it is probably more complex than this and may need to be */ /* rewritten but for now as a start just to get some output: */ - unsigned dst_x =3D (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? - s->regs.dst_x : s->regs.dst_x + 1 - s->regs.dst_widt= h); - unsigned dst_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? - s->regs.dst_y : s->regs.dst_y + 1 - s->regs.dst_heig= ht); + bool use_pixman_fill =3D s->use_pixman & BIT(0); + bool use_pixman_blt =3D s->use_pixman & BIT(1); + uint32_t rop3 =3D s->regs.dp_mix & GMC_ROP3_MASK; + bool left_to_right =3D s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT; + bool top_to_bottom =3D s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM; + uint32_t frgd_clr =3D s->regs.dp_brush_frgd_clr; + uint8_t *palette =3D s->vga.palette; + unsigned dst_offset =3D s->regs.dst_offset; + unsigned dst_width =3D s->regs.dst_width; + unsigned dst_height =3D s->regs.dst_height; + unsigned dst_x =3D (left_to_right ? + s->regs.dst_x : s->regs.dst_x + 1 - dst_width); + unsigned dst_y =3D (top_to_bottom ? + s->regs.dst_y : s->regs.dst_y + 1 - dst_height); int bpp =3D ati_bpp_from_datatype(s); if (!bpp) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); @@ -79,7 +89,7 @@ void ati_2d_blt(ATIVGAState *s) qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n"); return; } - uint8_t *dst_bits =3D s->vga.vram_ptr + s->regs.dst_offset; + uint8_t *dst_bits =3D s->vga.vram_ptr + dst_offset; =20 if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { dst_bits +=3D s->regs.crtc_offset & 0x07ffffff; @@ -88,26 +98,25 @@ void ati_2d_blt(ATIVGAState *s) int dst_stride_words =3D dst_stride / sizeof(uint32_t); uint8_t *end =3D s->vga.vram_ptr + s->vga.vram_size; if (dst_x > 0x3fff || dst_y > 0x3fff || dst_bits >=3D end - || dst_bits + dst_x - + (dst_y + s->regs.dst_height) * dst_stride >=3D end) { + || dst_bits + dst_x + (dst_y + dst_height) * dst_stride >=3D end) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } DPRINTF("%d %d %d, %d %d %d, (%d,%d) -> (%d,%d) %dx%d %c %c\n", - s->regs.src_offset, s->regs.dst_offset, s->regs.default_offset, - s->regs.src_pitch, s->regs.dst_pitch, s->regs.default_pitch, + s->regs.src_offset, dst_offset, s->regs.default_offset, + s->regs.src_pitch, dst_stride, s->regs.default_pitch, s->regs.src_x, s->regs.src_y, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height, - (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? '>' : '<'), - (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? 'v' : '^')); - switch (s->regs.dp_mix & GMC_ROP3_MASK) { + dst_width, dst_height, + (left_to_right ? '>' : '<'), + (top_to_bottom ? 'v' : '^')); + switch (rop3) { case ROP3_SRCCOPY: { bool fallback =3D false; - unsigned src_x =3D (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? - s->regs.src_x : s->regs.src_x + 1 - s->regs.dst_wid= th); - unsigned src_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? - s->regs.src_y : s->regs.src_y + 1 - s->regs.dst_hei= ght); + unsigned src_x =3D (left_to_right ? + s->regs.src_x : s->regs.src_x + 1 - dst_width); + unsigned src_y =3D (top_to_bottom ? + s->regs.src_y : s->regs.src_y + 1 - dst_height); int src_stride =3D s->regs.src_pitch; if (!src_stride) { qemu_log_mask(LOG_GUEST_ERROR, "Zero source pitch\n"); @@ -122,7 +131,7 @@ void ati_2d_blt(ATIVGAState *s) int src_stride_words =3D src_stride / sizeof(uint32_t); if (src_x > 0x3fff || src_y > 0x3fff || src_bits >=3D end || src_bits + src_x - + (src_y + s->regs.dst_height) * src_stride >=3D end) { + + (src_y + dst_height) * src_stride >=3D end) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } @@ -130,30 +139,28 @@ void ati_2d_blt(ATIVGAState *s) DPRINTF("pixman_blt(%p, %p, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d= )\n", src_bits, dst_bits, src_stride_words, dst_stride_words, bpp, bpp, src_x, src_y, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height); + dst_width, dst_height); #ifdef CONFIG_PIXMAN - if ((s->use_pixman & BIT(1)) && - s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT && - s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) { + if (use_pixman_blt && left_to_right && top_to_bottom) { fallback =3D !pixman_blt((uint32_t *)src_bits, (uint32_t *)dst= _bits, src_stride_words, dst_stride_words, bpp= , bpp, src_x, src_y, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height); - } else if (s->use_pixman & BIT(1)) { + dst_width, dst_height); + } else if (use_pixman_blt) { /* FIXME: We only really need a temporary if src and dst overl= ap */ - int llb =3D s->regs.dst_width * (bpp / 8); + int llb =3D dst_width * (bpp / 8); int tmp_stride_words =3D DIV_ROUND_UP(llb, sizeof(uint32_t)); uint32_t *tmp =3D g_malloc(tmp_stride_words * sizeof(uint32_t)= * - s->regs.dst_height); + dst_height); fallback =3D !pixman_blt((uint32_t *)src_bits, tmp, src_stride_words, tmp_stride_words, bpp= , bpp, src_x, src_y, 0, 0, - s->regs.dst_width, s->regs.dst_height); + dst_width, dst_height); if (!fallback) { fallback =3D !pixman_blt(tmp, (uint32_t *)dst_bits, tmp_stride_words, dst_stride_words, bpp, bpp, 0, 0, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_heig= ht); + dst_width, dst_height); } g_free(tmp); } else @@ -163,17 +170,17 @@ void ati_2d_blt(ATIVGAState *s) } if (fallback) { unsigned int y, i, j, bypp =3D bpp / 8; - for (y =3D 0; y < s->regs.dst_height; y++) { + for (y =3D 0; y < dst_height; y++) { i =3D dst_x * bypp; j =3D src_x * bypp; - if (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) { + if (top_to_bottom) { i +=3D (dst_y + y) * dst_stride; j +=3D (src_y + y) * src_stride; } else { - i +=3D (dst_y + s->regs.dst_height - 1 - y) * dst_stri= de; - j +=3D (src_y + s->regs.dst_height - 1 - y) * src_stri= de; + i +=3D (dst_y + dst_height - 1 - y) * dst_stride; + j +=3D (src_y + dst_height - 1 - y) * src_stride; } - memmove(&dst_bits[i], &src_bits[j], s->regs.dst_width * by= pp); + memmove(&dst_bits[i], &src_bits[j], dst_width * bypp); } } break; @@ -184,34 +191,34 @@ void ati_2d_blt(ATIVGAState *s) { uint32_t filler =3D 0; =20 - switch (s->regs.dp_mix & GMC_ROP3_MASK) { + switch (rop3) { case ROP3_PATCOPY: - filler =3D s->regs.dp_brush_frgd_clr; + filler =3D frgd_clr; break; case ROP3_BLACKNESS: - filler =3D 0xffUL << 24 | rgb_to_pixel32(s->vga.palette[0], - s->vga.palette[1], s->vga.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(s->vga.palette[3], - s->vga.palette[4], s->vga.palette[5]); + filler =3D 0xffUL << 24 | rgb_to_pixel32(palette[3], palette[4= ], + palette[5]); break; } =20 DPRINTF("pixman_fill(%p, %d, %d, %d, %d, %d, %d, %x)\n", dst_bits, dst_stride_words, bpp, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height, filler); + dst_width, dst_height, filler); #ifdef CONFIG_PIXMAN - if (!(s->use_pixman & BIT(0)) || + if (!use_pixman_fill || !pixman_fill((uint32_t *)dst_bits, dst_stride_words, bpp, dst_= x, - dst_y, s->regs.dst_width, s->regs.dst_height, fil= ler)) + dst_y, dst_width, dst_height, filler)) #endif { /* fallback when pixman failed or we don't want to call it */ unsigned int x, y, i, bypp =3D bpp / 8; - for (y =3D 0; y < s->regs.dst_height; y++) { + for (y =3D 0; y < dst_height; y++) { i =3D dst_x * bypp + (dst_y + y) * dst_stride; - for (x =3D 0; x < s->regs.dst_width; x++, i +=3D bypp) { + for (x =3D 0; x < dst_width; x++, i +=3D bypp) { stn_he_p(&dst_bits[i], bypp, filler); } } @@ -220,7 +227,7 @@ void ati_2d_blt(ATIVGAState *s) } default: qemu_log_mask(LOG_UNIMP, "Unimplemented ati_2d blt op %x\n", - (s->regs.dp_mix & GMC_ROP3_MASK) >> 16); + rop3 >> 16); return; } =20 --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224916; cv=none; d=zohomail.com; s=zohoarc; b=iX46OBJrN+FbRct4RjBO5yakNdemfudCmNXXEJqf3RDWlnO+E3av0g3Z//H5vZlvBi8nNL6FSaLSy4GMRjFouPnHn4obnN/97rfZ6cB7AAop53UyTFcqNxjmAvxxRKKlvmBVL05IbKdH8q2xQPd2M3UzOGbbKaJ8/DamIGW5LcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224916; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WU6cZD7VMvAe2lt4ksMZ8qKTpaE4lnZg2DgkHNwr9uU=; b=Y8d41VBXR+WUaJ9vr4TtmWD6A5fYGmoi4IPMuu8+92uHtQcu5jYaHxLdGjUvoekKJuISHgbJsDVtHWtRaMpXbqxtqvZteecKpjE8pXYUw+UT2Z2KyK3Z79cP7UUnod/F8JXVwWxR9QTguKfEyWfxcTinl3HTO9zan3MY/w806m8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224916048588.9245879770712; Fri, 27 Feb 2026 12:41:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eD-0002bX-6U; Fri, 27 Feb 2026 15:41:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e2-0001Vz-3Q for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:06 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0007Q8-5B for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 0C23F14001F7; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Fri, 27 Feb 2026 15:41:01 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 77aaef6b; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224861; x= 1772311261; bh=WU6cZD7VMvAe2lt4ksMZ8qKTpaE4lnZg2DgkHNwr9uU=; b=m AMoqQWaqKShJ9Wjw7CSXCbUPwUuM64EeFH/Z3k/BimYZYGxRzHtxE00mLOO3xplg qzBfF14EeZaeNNK1amcl4xXA7lGglwx+M9PGTfZZrveDRZ5PIsQ31wHbipJgq84F NORZ6xaXbWAe7W+btGwyQFWcC0ByHBTtKhxBWNm/omM+oRt9LjUV1CaCoM/BFDWh vTIjnNxCeg1Ctz4z7xUvHgqq+KLpYUvcKDDcCwZmU2zfiV3ngsrB1XU0DZkhwvo/ +6BhmfC521RK/4F4AbUkYeuiW2iIfwa70AFSxZOTRjMrFLUF68BLm22RsaNXyLko NuL8mn41ejmh8VsvSHpKw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224861; x=1772311261; bh=W U6cZD7VMvAe2lt4ksMZ8qKTpaE4lnZg2DgkHNwr9uU=; b=SJTcPqn9Vhr/Qjosf +t8h4cjvx9xCaX1wPhz/ukNbUvtJekqEwAAPHAepgoXIA+WYemcozz5IiwWtM6dQ fEj0nGdbxKArLG4/7Elj7hu8F8XoLAimbBOliar6rH0pbHrFNR59NZTiHXFXwlsu YRIS6+Pxq2p/GMef6IiRBMj1G5zMmYNfv8DRVj3zy4w5iBr0iqECEKPe60Vo+VfT dJiLF6hxcLkLyEp3LnJ/nGJU6j4ic2Bvl/2qacBiaJI8o3Jev2OKTpnVIx9eiJm/ lTHkXXpuR2QkxPKjsRQj9Rf0ic+uinV53a5PMxmgnnuYTaUCXjh3zHMLpPyjUedu h0Xdw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehkrhgrgigvlh esrhgvughhrghtrdgtohhmpdhrtghpthhtohepsggrlhgrthhonhesvghikhdrsghmvgdr hhhupdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghdprhgtph htthhopehmrghrtggrnhgurhgvrdhluhhrvggruhesrhgvughhrghtrdgtohhmpdhrtghp thhtoheptghhrggusehjrggslhhonhhskhhirdighiii X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 11/18] ati-vga: Introduce ATI2DCtx struct for 2D blit context Date: Fri, 27 Feb 2026 15:39:37 -0500 Message-ID: <20260227203944.746471-12-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224917658158501 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: BALATON Zoltan --- hw/display/ati_2d.c | 221 +++++++++++++++++++++++++------------------- 1 file changed, 126 insertions(+), 95 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 689b07b4d0..d43268ba5f 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" =20 /* * NOTE: @@ -43,21 +44,39 @@ static int ati_bpp_from_datatype(ATIVGAState *s) } } =20 -static void ati_set_dirty(ATIVGAState *s, - const uint8_t *dst_bits, unsigned dst_y) +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; + + QemuRect dst; + int dst_stride; + uint8_t *dst_bits; + uint32_t dst_offset; + + QemuRect src; + int src_stride; + const uint8_t *src_bits; +} ATI2DCtx; + +static void ati_set_dirty(VGACommonState *vga, const ATI2DCtx *ctx) { - VGACommonState *vga =3D &s->vga; DisplaySurface *ds =3D qemu_console_surface(vga->con); =20 DPRINTF("%p %u ds: %p %d %d rop: %x\n", vga->vram_ptr, vga->vbe_start_= addr, surface_data(ds), surface_stride(ds), surface_bits_per_pixel(d= s), - (s->regs.dp_mix & GMC_ROP3_MASK) >> 16); - if (dst_bits >=3D vga->vram_ptr + vga->vbe_start_addr && - dst_bits < vga->vram_ptr + vga->vbe_start_addr + + ctx->rop3 >> 16); + if (ctx->dst_bits >=3D vga->vram_ptr + vga->vbe_start_addr && + ctx->dst_bits < vga->vram_ptr + vga->vbe_start_addr + vga->vbe_regs[VBE_DISPI_INDEX_YRES] * vga->vbe_line_offset) { memory_region_set_dirty(&vga->vram, vga->vbe_start_addr + - s->regs.dst_offset + dst_y * surface_strid= e(ds), - s->regs.dst_height * surface_stride(ds)); + ctx->dst_offset + ctx->dst.y + * surface_stride(ds), + ctx->dst.height * surface_stride(ds)); } } =20 @@ -67,100 +86,106 @@ void ati_2d_blt(ATIVGAState *s) /* rewritten but for now as a start just to get some output: */ bool use_pixman_fill =3D s->use_pixman & BIT(0); bool use_pixman_blt =3D s->use_pixman & BIT(1); - uint32_t rop3 =3D s->regs.dp_mix & GMC_ROP3_MASK; - bool left_to_right =3D s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT; - bool top_to_bottom =3D s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM; - uint32_t frgd_clr =3D s->regs.dp_brush_frgd_clr; - uint8_t *palette =3D s->vga.palette; - unsigned dst_offset =3D s->regs.dst_offset; - unsigned dst_width =3D s->regs.dst_width; - unsigned dst_height =3D s->regs.dst_height; - unsigned dst_x =3D (left_to_right ? - s->regs.dst_x : s->regs.dst_x + 1 - dst_width); - unsigned dst_y =3D (top_to_bottom ? - s->regs.dst_y : s->regs.dst_y + 1 - dst_height); - int bpp =3D ati_bpp_from_datatype(s); - if (!bpp) { + ATI2DCtx ctx_; + ATI2DCtx *ctx =3D &ctx_; + ctx->rop3 =3D s->regs.dp_mix & GMC_ROP3_MASK; + ctx->left_to_right =3D s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT; + ctx->top_to_bottom =3D s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM; + 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->dst.width =3D s->regs.dst_width; + ctx->dst.height =3D s->regs.dst_height; + ctx->dst.x =3D (ctx->left_to_right ? + s->regs.dst_x : s->regs.dst_x + 1 - ctx->dst.width); + ctx->dst.y =3D (ctx->top_to_bottom ? + s->regs.dst_y : s->regs.dst_y + 1 - ctx->dst.height); + ctx->bpp =3D ati_bpp_from_datatype(s); + if (!ctx->bpp) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); return; } - int dst_stride =3D s->regs.dst_pitch; - if (!dst_stride) { + ctx->dst_stride =3D s->regs.dst_pitch; + if (!ctx->dst_stride) { qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n"); return; } - uint8_t *dst_bits =3D s->vga.vram_ptr + dst_offset; + ctx->dst_bits =3D s->vga.vram_ptr + ctx->dst_offset; =20 if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { - dst_bits +=3D s->regs.crtc_offset & 0x07ffffff; - dst_stride *=3D bpp; + ctx->dst_bits +=3D s->regs.crtc_offset & 0x07ffffff; + ctx->dst_stride *=3D ctx->bpp; } - int dst_stride_words =3D dst_stride / sizeof(uint32_t); - uint8_t *end =3D s->vga.vram_ptr + s->vga.vram_size; - if (dst_x > 0x3fff || dst_y > 0x3fff || dst_bits >=3D end - || dst_bits + dst_x + (dst_y + dst_height) * dst_stride >=3D end) { + int dst_stride_words =3D ctx->dst_stride / sizeof(uint32_t); + ctx->vram_end =3D s->vga.vram_ptr + s->vga.vram_size; + if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff + || ctx->dst_bits >=3D ctx->vram_end || ctx->dst_bits + ctx->dst.x + + (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >=3D ctx->vram= _end) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } DPRINTF("%d %d %d, %d %d %d, (%d,%d) -> (%d,%d) %dx%d %c %c\n", - s->regs.src_offset, dst_offset, s->regs.default_offset, - s->regs.src_pitch, dst_stride, s->regs.default_pitch, - s->regs.src_x, s->regs.src_y, dst_x, dst_y, - dst_width, dst_height, - (left_to_right ? '>' : '<'), - (top_to_bottom ? 'v' : '^')); - switch (rop3) { + s->regs.src_offset, ctx->dst_offset, s->regs.default_offset, + ctx->src_stride, ctx->dst_stride, s->regs.default_pitch, + ctx->src.x, ctx->src.y, ctx->dst.x, ctx->dst.y, + ctx->dst.width, ctx->dst.height, + (ctx->left_to_right ? '>' : '<'), + (ctx->top_to_bottom ? 'v' : '^')); + switch (ctx->rop3) { case ROP3_SRCCOPY: { bool fallback =3D false; - unsigned src_x =3D (left_to_right ? - s->regs.src_x : s->regs.src_x + 1 - dst_width); - unsigned src_y =3D (top_to_bottom ? - s->regs.src_y : s->regs.src_y + 1 - dst_height); - int src_stride =3D s->regs.src_pitch; - if (!src_stride) { + ctx->src.x =3D (ctx->left_to_right ? + s->regs.src_x : s->regs.src_x + 1 - ctx->dst.width); + ctx->src.y =3D (ctx->top_to_bottom ? + s->regs.src_y : s->regs.src_y + 1 - ctx->dst.height); + ctx->src_stride =3D s->regs.src_pitch; + if (!ctx->src_stride) { qemu_log_mask(LOG_GUEST_ERROR, "Zero source pitch\n"); return; } - uint8_t *src_bits =3D s->vga.vram_ptr + s->regs.src_offset; + ctx->src_bits =3D s->vga.vram_ptr + s->regs.src_offset; =20 if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { - src_bits +=3D s->regs.crtc_offset & 0x07ffffff; - src_stride *=3D bpp; + ctx->src_bits +=3D s->regs.crtc_offset & 0x07ffffff; + ctx->src_stride *=3D ctx->bpp; } - int src_stride_words =3D src_stride / sizeof(uint32_t); - if (src_x > 0x3fff || src_y > 0x3fff || src_bits >=3D end - || src_bits + src_x - + (src_y + dst_height) * src_stride >=3D end) { + int src_stride_words =3D ctx->src_stride / sizeof(uint32_t); + if (ctx->src.x > 0x3fff || ctx->src.y > 0x3fff + || ctx->src_bits >=3D ctx->vram_end + || ctx->src_bits + ctx->src.x + (ctx->src.y + ctx->dst.height) + * ctx->src_stride >=3D ctx->vram_end) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } =20 DPRINTF("pixman_blt(%p, %p, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d= )\n", - src_bits, dst_bits, src_stride_words, dst_stride_words, - bpp, bpp, src_x, src_y, dst_x, dst_y, - dst_width, dst_height); + ctx->src_bits, ctx->dst_bits, src_stride_words, + dst_stride_words, ctx->bpp, ctx->bpp, ctx->src.x, ctx->src= .y, + ctx->dst.x, ctx->dst.y, ctx->dst.width, ctx->dst.height); #ifdef CONFIG_PIXMAN - if (use_pixman_blt && left_to_right && top_to_bottom) { - fallback =3D !pixman_blt((uint32_t *)src_bits, (uint32_t *)dst= _bits, - src_stride_words, dst_stride_words, bpp= , bpp, - src_x, src_y, dst_x, dst_y, - dst_width, dst_height); + if (use_pixman_blt && ctx->left_to_right && ctx->top_to_bottom) { + fallback =3D !pixman_blt((uint32_t *)ctx->src_bits, + (uint32_t *)ctx->dst_bits, src_stride_w= ords, + dst_stride_words, ctx->bpp, ctx->bpp, + ctx->src.x, ctx->src.y, ctx->dst.x, + ctx->dst.y, ctx->dst.width, ctx->dst.he= ight); } else if (use_pixman_blt) { /* FIXME: We only really need a temporary if src and dst overl= ap */ - int llb =3D dst_width * (bpp / 8); + int llb =3D ctx->dst.width * (ctx->bpp / 8); int tmp_stride_words =3D DIV_ROUND_UP(llb, sizeof(uint32_t)); uint32_t *tmp =3D g_malloc(tmp_stride_words * sizeof(uint32_t)= * - dst_height); - fallback =3D !pixman_blt((uint32_t *)src_bits, tmp, - src_stride_words, tmp_stride_words, bpp= , bpp, - src_x, src_y, 0, 0, - dst_width, dst_height); + ctx->dst.height); + fallback =3D !pixman_blt((uint32_t *)ctx->src_bits, tmp, + src_stride_words, tmp_stride_words, ctx= ->bpp, + ctx->bpp, ctx->src.x, ctx->src.y, 0, 0, + ctx->dst.width, ctx->dst.height); if (!fallback) { - fallback =3D !pixman_blt(tmp, (uint32_t *)dst_bits, + fallback =3D !pixman_blt(tmp, (uint32_t *)ctx->dst_bits, tmp_stride_words, dst_stride_words, - bpp, bpp, 0, 0, dst_x, dst_y, - dst_width, dst_height); + ctx->bpp, ctx->bpp, 0, 0, + ctx->dst.x, ctx->dst.y, + ctx->dst.width, ctx->dst.height); } g_free(tmp); } else @@ -169,18 +194,21 @@ void ati_2d_blt(ATIVGAState *s) fallback =3D true; } if (fallback) { - unsigned int y, i, j, bypp =3D bpp / 8; - for (y =3D 0; y < dst_height; y++) { - i =3D dst_x * bypp; - j =3D src_x * bypp; - if (top_to_bottom) { - i +=3D (dst_y + y) * dst_stride; - j +=3D (src_y + y) * src_stride; + unsigned int y, i, j, bypp =3D ctx->bpp / 8; + for (y =3D 0; y < ctx->dst.height; y++) { + i =3D ctx->dst.x * bypp; + j =3D ctx->src.x * bypp; + if (ctx->top_to_bottom) { + i +=3D (ctx->dst.y + y) * ctx->dst_stride; + j +=3D (ctx->src.y + y) * ctx->src_stride; } else { - i +=3D (dst_y + dst_height - 1 - y) * dst_stride; - j +=3D (src_y + dst_height - 1 - y) * src_stride; + i +=3D (ctx->dst.y + ctx->dst.height - 1 - y) + * ctx->dst_stride; + j +=3D (ctx->src.y + ctx->dst.height - 1 - y) + * ctx->src_stride; } - memmove(&dst_bits[i], &src_bits[j], dst_width * bypp); + memmove(&ctx->dst_bits[i], &ctx->src_bits[j], + ctx->dst.width * bypp); } } break; @@ -191,35 +219,38 @@ void ati_2d_blt(ATIVGAState *s) { uint32_t filler =3D 0; =20 - switch (rop3) { + switch (ctx->rop3) { case ROP3_PATCOPY: - filler =3D frgd_clr; + filler =3D ctx->frgd_clr; break; case ROP3_BLACKNESS: - filler =3D 0xffUL << 24 | rgb_to_pixel32(palette[0], palette[1= ], - palette[2]); + filler =3D 0xffUL << 24 | rgb_to_pixel32(ctx->palette[0], + ctx->palette[1], + ctx->palette[2]); break; case ROP3_WHITENESS: - filler =3D 0xffUL << 24 | rgb_to_pixel32(palette[3], palette[4= ], - palette[5]); + filler =3D 0xffUL << 24 | rgb_to_pixel32(ctx->palette[3], + ctx->palette[4], + ctx->palette[5]); break; } =20 DPRINTF("pixman_fill(%p, %d, %d, %d, %d, %d, %d, %x)\n", - dst_bits, dst_stride_words, bpp, dst_x, dst_y, - dst_width, dst_height, filler); + ctx->dst_bits, dst_stride_words, ctx->bpp, ctx->dst.x, + ctx->dst.y, ctx->dst.width, ctx->dst.height, filler); #ifdef CONFIG_PIXMAN if (!use_pixman_fill || - !pixman_fill((uint32_t *)dst_bits, dst_stride_words, bpp, dst_= x, - dst_y, dst_width, dst_height, filler)) + !pixman_fill((uint32_t *)ctx->dst_bits, dst_stride_words, ctx-= >bpp, + ctx->dst.x, ctx->dst.y, + ctx->dst.width, ctx->dst.height, filler)) #endif { /* fallback when pixman failed or we don't want to call it */ - unsigned int x, y, i, bypp =3D bpp / 8; - for (y =3D 0; y < dst_height; y++) { - i =3D dst_x * bypp + (dst_y + y) * dst_stride; - for (x =3D 0; x < dst_width; x++, i +=3D bypp) { - stn_he_p(&dst_bits[i], bypp, filler); + unsigned int x, y, i, bypp =3D ctx->bpp / 8; + for (y =3D 0; y < ctx->dst.height; y++) { + i =3D ctx->dst.x * bypp + (ctx->dst.y + y) * ctx->dst_stri= de; + for (x =3D 0; x < ctx->dst.width; x++, i +=3D bypp) { + stn_he_p(&ctx->dst_bits[i], bypp, filler); } } } @@ -227,9 +258,9 @@ void ati_2d_blt(ATIVGAState *s) } default: qemu_log_mask(LOG_UNIMP, "Unimplemented ati_2d blt op %x\n", - rop3 >> 16); + ctx->rop3 >> 16); return; } =20 - ati_set_dirty(s, dst_bits, dst_y); + ati_set_dirty(&s->vga, ctx); } --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224898; cv=none; d=zohomail.com; s=zohoarc; b=XDYys0JUxxDiwJdO3PjgwP2dKeZ4IMeXLQbzo3HDMpLSEMpC/nqLr0nzFL1U9Wna4bjb8tnjecO3oc/izLCT6kOtVRMLEuTPHwoYEYzWn4yzyH9tZ7ovkN7t3i1jsRuDLRO7/CQup/Cu+bjkawonXRPQ5dPr54biFi/CJHAg4ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224898; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XKA7BDVAEuSkI7Cyv+HPSD9abD9gVHJAjeSHHpT4T3E=; b=Ijd0oGs++0ruYKaUFr/NvlNcVza3o90iKai9Qv8lldo4m6Bsl/W77Qo0KgnH1YUSAhx/E/eA4LhExM/V6s4eR7Higl6wseJUDeokpsuIDVG7CYEoDVqv7oibxdy52o9QxzJNkK+hE87ahAsr64+zqMLsiifVoA7DZLoKya5lplo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224898968713.7065144736777; Fri, 27 Feb 2026 12:41:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e6-00025l-Pj; Fri, 27 Feb 2026 15:41:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e2-0001Vq-2i for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:06 -0500 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0007QJ-7g for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id 1AFA8EC0642; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 27 Feb 2026 15:41:01 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 811b5076; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224861; x= 1772311261; bh=XKA7BDVAEuSkI7Cyv+HPSD9abD9gVHJAjeSHHpT4T3E=; b=V 9/xn5cExtFqmIzwe71UGAc+7Cvb+NH9tEMKcJhBgrqARsjumwtQJFyFi+IaamsgN RKpE20k9uLq7Y3L+kibhtUYvCqyfqqAe9Fb3plckcFwKzSDIDf0+wr5Wh5sHP+9V WGk75+4FuHiUlfT+dq2Gvuet0XogWmqYJilHoNp0XBImn7HGI5/ifi5NAMs8eDrv yTH+1N6SOtcXs/FFgC2D2cEwiQGI+/MwtcHddNW1l8JG2pTeAenRWQ870O7APi/a Z6MFr8YFBrK7UPBO/pZnGZB8YPGfMDgLMD+Co+DKYpyE6w3K6OMSu591ROhe6mKH NppzZmx+j1+4wfKLtwIyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224861; x=1772311261; bh=X KA7BDVAEuSkI7Cyv+HPSD9abD9gVHJAjeSHHpT4T3E=; b=RgEkePhmkpJcw7xwB H/wjJkjP0VgVEfrfte2JbsmT/OAHUiR5oHVWIxQp3qfa2cxaPYJakavYmkB7T+pe Uv7mbZ8wt4etjlFNhw9wO0lNlBrzSmt8LmmJTnjD86qwhgfn7p7S6jOY2AKl7BNU DwPfN4Dg2NJcQG8RHQBC071bMICh3//4utNt6h4JEhtmlLGvKyawf1j+jXitAl75 GkXJBN8W/FfbraVYCgLR8v9z/L754a0Tvf73UnpvUbPNNzBYi6xU0HPE0m/SXE+Y cyXK3xCL7LGb9GbFOlvzUvapIaeSi5u9g3+o5hp8gPh75/DaeUE3c8MD7tfKViHK Ocuwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthhgrugesjh grsghlohhnshhkihdrgiihiidprhgtphhtthhopehmrghrtggrnhgurhgvrdhluhhrvggr uhesrhgvughhrghtrdgtohhmpdhrtghpthhtohepsggrlhgrthhonhesvghikhdrsghmvg drhhhupdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghdprhgt phhtthhopehkrhgrgigvlhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 12/18] ati-vga: Extract setup_2d_blt_ctx from ati_2d_blt Date: Fri, 27 Feb 2026 15:39:38 -0500 Message-ID: <20260227203944.746471-13-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.144; envelope-from=chad@jablonski.xyz; helo=fout-a1-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224899570158500 Content-Type: text/plain; charset="utf-8" setup_2d_blt_ctx is responsible for knowing how to retrieve the state needed by ati_2d_blt from the registers and assigning it to the ATI2DCtx. This will be useful in a future patch when HOST_DATA needs to make small modifications to the ctx. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati_2d.c | 75 ++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index d43268ba5f..ebcec07334 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -25,7 +25,7 @@ * possible. */ =20 -static int ati_bpp_from_datatype(ATIVGAState *s) +static int ati_bpp_from_datatype(const ATIVGAState *s) { switch (s->regs.dp_datatype & 0xf) { case 2: @@ -80,76 +80,81 @@ static void ati_set_dirty(VGACommonState *vga, const AT= I2DCtx *ctx) } } =20 -void ati_2d_blt(ATIVGAState *s) +static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx) { - /* FIXME it is probably more complex than this and may need to be */ - /* rewritten but for now as a start just to get some output: */ - bool use_pixman_fill =3D s->use_pixman & BIT(0); - bool use_pixman_blt =3D s->use_pixman & BIT(1); - ATI2DCtx ctx_; - ATI2DCtx *ctx =3D &ctx_; + ctx->bpp =3D ati_bpp_from_datatype(s); ctx->rop3 =3D s->regs.dp_mix & GMC_ROP3_MASK; ctx->left_to_right =3D s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT; ctx->top_to_bottom =3D s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM; 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; + ctx->dst.width =3D s->regs.dst_width; ctx->dst.height =3D s->regs.dst_height; ctx->dst.x =3D (ctx->left_to_right ? s->regs.dst_x : s->regs.dst_x + 1 - ctx->dst.width); ctx->dst.y =3D (ctx->top_to_bottom ? s->regs.dst_y : s->regs.dst_y + 1 - ctx->dst.height); - ctx->bpp =3D ati_bpp_from_datatype(s); + ctx->dst_stride =3D s->regs.dst_pitch; + ctx->dst_bits =3D s->vga.vram_ptr + s->regs.dst_offset; + if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { + ctx->dst_bits +=3D s->regs.crtc_offset & 0x07ffffff; + ctx->dst_stride *=3D ctx->bpp; + } + + ctx->src.x =3D (ctx->left_to_right ? + s->regs.src_x : s->regs.src_x + 1 - ctx->dst.width); + ctx->src.y =3D (ctx->top_to_bottom ? + s->regs.src_y : s->regs.src_y + 1 - ctx->dst.height); + ctx->src_stride =3D s->regs.src_pitch; + ctx->src_bits =3D s->vga.vram_ptr + s->regs.src_offset; + if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { + ctx->src_bits +=3D s->regs.crtc_offset & 0x07ffffff; + ctx->src_stride *=3D ctx->bpp; + } + DPRINTF("%d %d %d, %d %d %d, (%d,%d) -> (%d,%d) %dx%d %c %c\n", + s->regs.src_offset, s->regs.dst_offset, s->regs.default_offset, + ctx->src_stride, ctx->dst_stride, s->regs.default_pitch, + ctx->src.x, ctx->src.y, ctx->dst.x, ctx->dst.y, + ctx->dst.width, ctx->dst.height, + (ctx->left_to_right ? '>' : '<'), + (ctx->top_to_bottom ? 'v' : '^')); +} + +void ati_2d_blt(ATIVGAState *s) +{ + /* FIXME it is probably more complex than this and may need to be */ + /* rewritten but for now as a start just to get some output: */ + bool use_pixman_fill =3D s->use_pixman & BIT(0); + bool use_pixman_blt =3D s->use_pixman & BIT(1); + ATI2DCtx ctx_; + ATI2DCtx *ctx =3D &ctx_; + setup_2d_blt_ctx(s, ctx); if (!ctx->bpp) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); return; } - ctx->dst_stride =3D s->regs.dst_pitch; if (!ctx->dst_stride) { qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n"); return; } - ctx->dst_bits =3D s->vga.vram_ptr + ctx->dst_offset; - - if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { - ctx->dst_bits +=3D s->regs.crtc_offset & 0x07ffffff; - ctx->dst_stride *=3D ctx->bpp; - } int dst_stride_words =3D ctx->dst_stride / sizeof(uint32_t); - ctx->vram_end =3D s->vga.vram_ptr + s->vga.vram_size; if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff || ctx->dst_bits >=3D ctx->vram_end || ctx->dst_bits + ctx->dst.x + (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >=3D ctx->vram= _end) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } - DPRINTF("%d %d %d, %d %d %d, (%d,%d) -> (%d,%d) %dx%d %c %c\n", - s->regs.src_offset, ctx->dst_offset, s->regs.default_offset, - ctx->src_stride, ctx->dst_stride, s->regs.default_pitch, - ctx->src.x, ctx->src.y, ctx->dst.x, ctx->dst.y, - ctx->dst.width, ctx->dst.height, - (ctx->left_to_right ? '>' : '<'), - (ctx->top_to_bottom ? 'v' : '^')); switch (ctx->rop3) { case ROP3_SRCCOPY: { bool fallback =3D false; - ctx->src.x =3D (ctx->left_to_right ? - s->regs.src_x : s->regs.src_x + 1 - ctx->dst.width); - ctx->src.y =3D (ctx->top_to_bottom ? - s->regs.src_y : s->regs.src_y + 1 - ctx->dst.height); - ctx->src_stride =3D s->regs.src_pitch; if (!ctx->src_stride) { qemu_log_mask(LOG_GUEST_ERROR, "Zero source pitch\n"); return; } - ctx->src_bits =3D s->vga.vram_ptr + s->regs.src_offset; - - if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { - ctx->src_bits +=3D s->regs.crtc_offset & 0x07ffffff; - ctx->src_stride *=3D ctx->bpp; - } int src_stride_words =3D ctx->src_stride / sizeof(uint32_t); if (ctx->src.x > 0x3fff || ctx->src.y > 0x3fff || ctx->src_bits >=3D ctx->vram_end --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224914; cv=none; d=zohomail.com; s=zohoarc; b=Ziy3ASZ31eaCmf+hEjkQ20EsKdzKsBjf8aM4nq7q0viJc7DFIykj6P6CZR2tUIdj3ppMA0c1nZg35qaYDrt10CVgFA6K9ZDYg4ys6Zzmc9fbdfg6NCY7IRPjYLi3nedmIGB7U3RNM1p9F2EeKtR7KdtnS4QSkM7h6mnJiMWrKOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224914; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bem76XaBuWb9Xot1enKa+abtbFpjdjVizWhFW+ejJlI=; b=kw17H9t8Q4gmMSIwDgE6c4oUSmWCTv19GeP19lpU5ewbL+98diGpBoadzqrZ0xD1ITBYenaNuDOwq5ovgHJ01O2tnalLW7rr5GkdkScS6fG9MLEZOfxIpC97FlQZ+QOWEJQrs2yI5crkA+6lWpy/0/VK056EV+Ix4FNqX5ptCHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224914380839.2860634577034; Fri, 27 Feb 2026 12:41:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eF-0002gb-12; Fri, 27 Feb 2026 15:41:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e1-0001TH-I0 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0007QL-3g for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:05 -0500 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 67F0EEC0644; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 27 Feb 2026 15:41:01 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:00 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id ab8e299d; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224861; x= 1772311261; bh=Bem76XaBuWb9Xot1enKa+abtbFpjdjVizWhFW+ejJlI=; b=H CcfibrYFtnKh5Eb3htuLO4IlpckUwW+YcQZOFYyK3y3oV2QHlowGRmTT57Jwm5Tz i1LhfknP+vsgw8MzmWr7pIjgcSod2tV3LMKLPFSfUEG9SDrpy7/GqkF2WIglQ71g z4UTvEtrRixpt8U0lqQaLuoAU51GPFrKnAlvLpd4sB1BOVztQym152cjcD8IENQQ lAkAt1mycljn7zTfM8L4jm0ICl8bqypHVloXmrF2fufPFa8pprFuOdxW9Fv2Yhwx +V6CnCoWcwneTVgOSsxouRRSL6+k7vpe7jK3u5WTOqP3Le9jyCiD8ud+vDzXVQqd pdIBuW4J8WwM2M7Yxwvxw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224861; x=1772311261; bh=B em76XaBuWb9Xot1enKa+abtbFpjdjVizWhFW+ejJlI=; b=ZjjHhiWkPVUwnTXse Ne4PMvx8weZ7gf3gxsLhBY5GVYkVinaNqW2FZY8/wZCie15K/S5pp8wDWPBsADp+ IDVUcq6+eUOlUIcxD5qyP1vN1qOojJI7j6Y+87OCANyFSSGp8ZPIwFOdYzJDXByk UI/wXDUd76zPk9JOUQB+Pq2prJIF6uL8RB2zZs8s4qNiOOifZ6+8zcZrc33MP1ax 0GY20Ta0krgwRa1hp6E+20BFrx4pAlAynopKl41gObwUq56mzzN6rsRcG2WeN/4C xtR118S/fjW6J/c1UXgxJlLJ9fRw/GbHhQcVsPoGFtmWVAmZdy8HM3nmdwqBnW+5 PjOdA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehkrhgrgigvlh esrhgvughhrghtrdgtohhmpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhn uhdrohhrghdprhgtphhtthhopegsrghlrghtohhnsegvihhkrdgsmhgvrdhhuhdprhgtph htthhopegthhgrugesjhgrsghlohhnshhkihdrgiihiidprhgtphhtthhopehmrghrtggr nhgurhgvrdhluhhrvggruhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 13/18] ati-vga: Split ati_2d_do_blt from ati_2d_blt Date: Fri, 27 Feb 2026 15:39:39 -0500 Message-ID: <20260227203944.746471-14-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.144; envelope-from=chad@jablonski.xyz; helo=fout-a1-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224915557158500 Content-Type: text/plain; charset="utf-8" ati_2d_blt remains the public interface to the blitter but the bulk of the implementation is moved down into ati_2d_do_blt which is passed an ATI2DCtx. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati_2d.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index ebcec07334..a93a267465 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -123,15 +123,12 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, AT= I2DCtx *ctx) (ctx->top_to_bottom ? 'v' : '^')); } =20 -void ati_2d_blt(ATIVGAState *s) +static void ati_2d_do_blt(ATIVGAState *s, ATI2DCtx *ctx) { /* FIXME it is probably more complex than this and may need to be */ /* rewritten but for now as a start just to get some output: */ bool use_pixman_fill =3D s->use_pixman & BIT(0); bool use_pixman_blt =3D s->use_pixman & BIT(1); - ATI2DCtx ctx_; - ATI2DCtx *ctx =3D &ctx_; - setup_2d_blt_ctx(s, ctx); if (!ctx->bpp) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); return; @@ -264,8 +261,13 @@ void ati_2d_blt(ATIVGAState *s) default: qemu_log_mask(LOG_UNIMP, "Unimplemented ati_2d blt op %x\n", ctx->rop3 >> 16); - return; } +} =20 - ati_set_dirty(&s->vga, ctx); +void ati_2d_blt(ATIVGAState *s) +{ + ATI2DCtx ctx; + setup_2d_blt_ctx(s, &ctx); + ati_2d_do_blt(s, &ctx); + ati_set_dirty(&s->vga, &ctx); } --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224909; cv=none; d=zohomail.com; s=zohoarc; b=AXXKr6ZKPKCZOLpmVSA7tTgAD+HPYQmVrceZK9CS0ceIG9QqhWKQQN94mi3F8ggNtSNsmn/D54+wwscD5kbdbj2G9JdY25gj58Q5Z4HiMR9tFvu9hHWp80pEKyx8yeFmtr9OZviqBSIdVG84ZpQjVQ6/20t42UzvxB0IOBFU/fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224909; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RONghVL5qfFab4fHWCH3aq+qD8Ikth6my46Lk/Xt2dI=; b=jJDXH19oHd6PmjrmAdV3dOKJZ1glZ9hAdqvz4TlK1t+f78ti/h6P9pG6lSb0v2u7ky0V6c8TJ2p6eZxnyr+q7Vmwv1V1VC+OoF2Lj8IO0C3MHUHSn1oUIw2pveVF/UT64ifS1AkxLFoj8Vi+sybTeLFhqtqtw/r9304jwnDPFEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224909467563.2166632023107; Fri, 27 Feb 2026 12:41:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eW-00035B-8V; Fri, 27 Feb 2026 15:41:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e2-0001be-Q8 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:06 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0007Qi-S1 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:06 -0500 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 9D04914001D1; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Fri, 27 Feb 2026 15:41:01 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 07c0fadb; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224861; x= 1772311261; bh=RONghVL5qfFab4fHWCH3aq+qD8Ikth6my46Lk/Xt2dI=; b=E /l0l9jENmMJ9E9t9u5VnJo5eD1IYYRU0G6PUkiNGntlt7sbPcSXT6oz/+r5NfVVI OLBwlR2CmqBmqt9nPkhE7QGITrDR+H62Hz6IcJDsIbUo8oHN4IIhjuZ3lzqddUou XskTkFiRv+GoDyIpLBh7o76lrCOi/n8GrfcA6vJq+guD75PW0ZX3USg9TTjzFx50 kWkhttX5RYN0lGkqBl3LdQrWIMIqwz9wjimf+YeZTAcvxYtWl8qs1KDOXg9lkJc3 Sxx+BfgGsREVmHcj1jZrEzQxAcjoPO2QVWdnemkCTto9l+o/rRdTKx9lf/ulVBj0 H6TL4na75pgqrfrY5H6+A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224861; x=1772311261; bh=R ONghVL5qfFab4fHWCH3aq+qD8Ikth6my46Lk/Xt2dI=; b=CXdfBL256Qd4GkHH6 bHED6V183lx4YgZfMQX+KNs9/4h+SPdSlnNuai9c1QqAeItkcol2SOmSzMNnsydM QTONZiLsJlTrgZ0v6+p+LCNLYlRkCpavLZwdpY37Ock0vpk2bsIrxkBHWWtYO3QT cda6NMTtjIy1eQIx/njkKfKRs1I39ft/XWq6xZPlg48QPvVbig7RaGvu8L7BUZZj SqHQUpu59bf5/A+YfTcPsGABMqdLRkOvPKFCZhZbgsnIijy8dOkz3Vf1ddO2i+hv VvCvLrHJNukhLCpWXNi4eBOFLPrkK3jjftLFs756CkSc25CT3jNzxF6FRrIHLInZ Io29A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthhgrugesjh grsghlohhnshhkihdrgiihiidprhgtphhtthhopegsrghlrghtohhnsegvihhkrdgsmhgv rdhhuhdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtg hpthhtohepmhgrrhgtrghnughrvgdrlhhurhgvrghusehrvgguhhgrthdrtghomhdprhgt phhtthhopehkrhgrgigvlhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 14/18] ati-vga: Remove ATIVGAState param from ati_2d_do_blt Date: Fri, 27 Feb 2026 15:39:40 -0500 Message-ID: <20260227203944.746471-15-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224911712158500 Content-Type: text/plain; charset="utf-8" This completes the decoupling from the ATIVGAState struct. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati_2d.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index a93a267465..440c1d159a 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -123,12 +123,12 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, AT= I2DCtx *ctx) (ctx->top_to_bottom ? 'v' : '^')); } =20 -static void ati_2d_do_blt(ATIVGAState *s, ATI2DCtx *ctx) +static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman) { /* FIXME it is probably more complex than this and may need to be */ /* rewritten but for now as a start just to get some output: */ - bool use_pixman_fill =3D s->use_pixman & BIT(0); - bool use_pixman_blt =3D s->use_pixman & BIT(1); + bool use_pixman_fill =3D use_pixman & BIT(0); + bool use_pixman_blt =3D use_pixman & BIT(1); if (!ctx->bpp) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); return; @@ -268,6 +268,6 @@ void ati_2d_blt(ATIVGAState *s) { ATI2DCtx ctx; setup_2d_blt_ctx(s, &ctx); - ati_2d_do_blt(s, &ctx); + ati_2d_do_blt(&ctx, s->use_pixman); ati_set_dirty(&s->vga, &ctx); } --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224940; cv=none; d=zohomail.com; s=zohoarc; b=bdkiEH1jjESYwrWHmuEMr7VLjkRc4TyRxN9x8F+aE7kG+F7wBU/eOXKboEwZBIMXsPEnbk3mvEOYCmcAZ6p9pxrm0hc7mT3PH4uKu3lN7gg8+0nCGEvZdpjdqAMMDZ2Rink4Q95UVCDXosRAkvyDc+OkTx2Uz2iZf1JMCAIrjJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224940; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RDbi4ttHSzdqquBLMjV4+kyLt9CNxdkTZv/NdVntPT4=; b=PXMCTF9/A8sIXRy3FcgpF2B1fhvO90x+m4E868wduspBdwl2HGO5W1dDV35dfhNW/QxspqCrTTw8dgFpTP4gjlhJL7ENzRc8NVx7M+8cCf68QkuzRguaKzbNWt5RiNf0JA7gIRKpNNkAI48AIKnhBToWLix/OM7JdeJKukI+nLg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17722249402331021.8419635461497; Fri, 27 Feb 2026 12:42:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eX-0003Oj-Iw; Fri, 27 Feb 2026 15:41:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4eC-0002c8-MF for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:16 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4eB-0007Qj-5A for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:16 -0500 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8CAE6140018E; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Fri, 27 Feb 2026 15:41:01 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 7f897a38; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224861; x= 1772311261; bh=RDbi4ttHSzdqquBLMjV4+kyLt9CNxdkTZv/NdVntPT4=; b=L XjUivcWSfsexWCdRmcyuO+dyA6A8u3mOOCTBgs22sZ8OSzx3DH5SBReiuCPB6gfG YSyRBOLY9Q9/5gSMuHF0QSZNNApycr4NDBSna14i5WViIZvVu8yy+2yslnC1GjoJ ecxDPxsfaG9gVH9VrXpKN37rAcw/HJCfc6NNFDqYI9M/1g74s3jYMRtgIA6t/9nL 2IpPnDU/c4LVUPSjM9GkpccCplTSiYiM4PvvAqLb1wNycmUgPrQLISSufMP2l4hy EJthGXhMHHOxt9mIjg3QzjVlJI6roUqzxRaxlKW2IqrQLC35rDKWK7hTNJX4mSE0 2FwOcruhcqeKrU5L5kyIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224861; x=1772311261; bh=R Dbi4ttHSzdqquBLMjV4+kyLt9CNxdkTZv/NdVntPT4=; b=rzofRfbYtTebl8L2V FBwjsReIk3dmyAPPd6HRzpYtk/wlPTGr09NYUbVAkePn+PDyhpq+ywMn25NlSG88 PqMQqieoDWtlTZp1WuGMOJJ/FC68wvtMKig3SNXCJJS1QY2juJ91+x36skG9KPjW XQTdy/XloX+HKzVjGnpMikLwl9elJtopNzJJKGhPXSnyG760YrIC2VNMZBCRIZ1z LHpF1MMuX3fgSEHq5PiiP5+YBaOVjPfgukqp+4FREzOBkNxeaz78dfSjCGENMvXQ Pyu7beNCfYCz69FIsbMIHDBu3cpwN8zaDWoAUVUA+SFN/a86XPUjGjqiYoqYjH18 LJSSw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehqvghmuhdqug gvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtghpthhtohepmhgrrhgtrghnughrvgdrlhhu rhgvrghusehrvgguhhgrthdrtghomhdprhgtphhtthhopehkrhgrgigvlhesrhgvughhrg htrdgtohhmpdhrtghpthhtohepsggrlhgrthhonhesvghikhdrsghmvgdrhhhupdhrtghp thhtoheptghhrggusehjrggslhhonhhskhhirdighiii X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 15/18] ati-vga: Move source bounds validation to ati_2d_blt Date: Fri, 27 Feb 2026 15:39:41 -0500 Message-ID: <20260227203944.746471-16-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224941638158500 Content-Type: text/plain; charset="utf-8" A call to ati_2d_blt implies that the source will be vram. Checking bounds is useful in that case. Other sources (HOST_DATA) will not make sense to check against vram bounds. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- Changes from v8: The source bound validation was being performed in all cases, even for blits that weren't using the source. It now limits the validation to the ROP3_SRCCOPY case. --- hw/display/ati_2d.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 440c1d159a..dbc8791824 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -138,9 +138,9 @@ static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pi= xman) return; } int dst_stride_words =3D ctx->dst_stride / sizeof(uint32_t); - if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff - || ctx->dst_bits >=3D ctx->vram_end || ctx->dst_bits + ctx->dst.x - + (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >=3D ctx->vram= _end) { + if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff || + ctx->dst_bits >=3D ctx->vram_end || ctx->dst_bits + ctx->dst.x + + (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >=3D ctx->vram_en= d) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } @@ -153,13 +153,6 @@ static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_p= ixman) return; } int src_stride_words =3D ctx->src_stride / sizeof(uint32_t); - if (ctx->src.x > 0x3fff || ctx->src.y > 0x3fff - || ctx->src_bits >=3D ctx->vram_end - || ctx->src_bits + ctx->src.x + (ctx->src.y + ctx->dst.height) - * ctx->src_stride >=3D ctx->vram_end) { - qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); - return; - } =20 DPRINTF("pixman_blt(%p, %p, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d= )\n", ctx->src_bits, ctx->dst_bits, src_stride_words, @@ -268,6 +261,12 @@ void ati_2d_blt(ATIVGAState *s) { ATI2DCtx ctx; setup_2d_blt_ctx(s, &ctx); + if (ctx.rop3 =3D=3D ROP3_SRCCOPY && (ctx.src.x > 0x3fff || ctx.src.y >= 0x3fff || + ctx.src_bits >=3D ctx.vram_end || ctx.src_bits + ctx.src.x + + (ctx.src.y + ctx.dst.height) * ctx.src_stride >=3D ctx.vram_end)) { + qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); + return; + } ati_2d_do_blt(&ctx, s->use_pixman); ati_set_dirty(&s->vga, &ctx); } --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224928; cv=none; d=zohomail.com; s=zohoarc; b=MEMr1xUi1LRIR8fUA8XA6But1PsirtcUKbeGJ/Fu5QEsgjpwbOqccHrU7BVeHkW1QP0H62yCRpHkfeFW7gy3FYGnrNraZsivbJXhGG3Pb2ZgP8Tmf8tBOYzgPlEBQ5cByY7f0OqAEeDZU5cuwVZzvGY76vsWUJt974+xARIwi/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224928; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oO60WbuNx27iFmAGnYWmwzzQ7h70ucPm/vTJ+m1zWW4=; b=NUEiLuFMaoa7Bux68n0uoX4HrudIEgFM0o9+4hgHqsWF88w7NB8APVF6/PIjixN7vVcJ9BW77Pp5+g28jktqvWPS93Ibg6N/pdrqjPCxhKhyNMPT3K1cPXKpD8d02advn8A+8O26mxr6cxHe1rObYfFwSuIxmYwy4HT02wuvsCg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224928181812.22625526373; Fri, 27 Feb 2026 12:42:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eU-0002ua-B5; Fri, 27 Feb 2026 15:41:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e3-0001io-OJ for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:07 -0500 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e1-0007Qo-4Z for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:07 -0500 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id ED8DDEC0647; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 27 Feb 2026 15:41:01 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 06823647; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224861; x= 1772311261; bh=oO60WbuNx27iFmAGnYWmwzzQ7h70ucPm/vTJ+m1zWW4=; b=M h1q45r50O/0EDCWAw6Cu8+DTxcqj9nsexw0PNfhcLKV81LlFV0jKsqNMyRd26VQA 7Kd/5I0nqba83p744sP7BpuLnwTgA/otly3cPiY91ht4XfVCOQE0/QN0oDGuuiGf HNEQj3EzzoO90NF2brOsdnMEy/pWp4E85Vm0o6N7QOisLsLwqmcRcaiug5lUS9Ie qPUjONC80ns5FJ1v2tpRLxTy/ejwEzbn2qOvdIGmNG75gilPw9BG6uKpdk8Cmwi5 ts52yF6aZoygoCviEJEFPxyRA7lqoc8Fwwpg2nBAYgfLYl19YV3vseLxxxsTK6vx HiYoscePYafmZ8lQehnXQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224861; x=1772311261; bh=o O60WbuNx27iFmAGnYWmwzzQ7h70ucPm/vTJ+m1zWW4=; b=VWkwtFAyLkk1TiPJ6 o2VXxxw7YfWEEvwW3kAIBPUYCUPzTF+D7LnFJUewr999KGBfQqyz13YCuCABEOxw IYIkE6Et/76YWF8u0RKdEPYNXR2gQbpjCN7Oj5TdHpjBrWJBLoYHzZ0tjZ96pik2 ee/mDoytu8+Pqqx5deqKEQrp9h6B2x+lZuQSUKazWAy69Z0N74OCr0pL9lJj5CbS yIww3OEEY5W62L9QEfHj8ykFdMLGwXAwF47LRVwcS2OSIU/xaJeEHU3iMT8lbYtj Rjnusd68aaHqi0OJP7L9D37r4XBYmYlF1mZn/yX8d/2griCc/xejxCeG4R7+375s I/t9Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehkrhgrgigvlh esrhgvughhrghtrdgtohhmpdhrtghpthhtoheptghhrggusehjrggslhhonhhskhhirdig hiiipdhrtghpthhtohepmhgrrhgtrghnughrvgdrlhhurhgvrghusehrvgguhhgrthdrtg homhdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtghp thhtohepsggrlhgrthhonhesvghikhdrsghmvgdrhhhu X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 16/18] ati-vga: Implement scissor rectangle clipping for 2D operations Date: Fri, 27 Feb 2026 15:39:42 -0500 Message-ID: <20260227203944.746471-17-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.144; envelope-from=chad@jablonski.xyz; helo=fout-a1-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224929725158500 Content-Type: text/plain; charset="utf-8" Use scissor registers to clip blit operations. This is required for text rendering in X using the r128 driver. Without it overly-wide glyphs are drawn and create all sorts of chaos. The visible destination rectangle (vis_dst) is the intersection of the scissor rectangle and the destination rectangle (dst). The src also needs to be offset if clipped on the top and/or left sides to ensure that src data is read correctly and appears clipped when drawn rather than shifted. Signed-off-by: Chad Jablonski --- hw/display/ati_2d.c | 80 +++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index dbc8791824..2b3a239da3 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -52,6 +52,7 @@ typedef struct { uint32_t frgd_clr; const uint8_t *palette; const uint8_t *vram_end; + QemuRect scissor; =20 QemuRect dst; int dst_stride; @@ -91,6 +92,11 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2D= Ctx *ctx) 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; + ctx->scissor.x =3D s->regs.sc_left; + ctx->scissor.y =3D s->regs.sc_top; + ctx->dst.width =3D s->regs.dst_width; ctx->dst.height =3D s->regs.dst_height; ctx->dst.x =3D (ctx->left_to_right ? @@ -129,6 +135,7 @@ static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pi= xman) /* rewritten but for now as a start just to get some output: */ bool use_pixman_fill =3D use_pixman & BIT(0); bool use_pixman_blt =3D use_pixman & BIT(1); + QemuRect vis_src, vis_dst; if (!ctx->bpp) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); return; @@ -144,6 +151,29 @@ static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_p= ixman) qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } + qemu_rect_intersect(&ctx->dst, &ctx->scissor, &vis_dst); + if (!vis_dst.height || !vis_dst.width) { + /* Nothing is visible, completely clipped */ + return; + } + /* + * The src must be offset if clipping is applied to the dst. + * This is so that when the source is blit to a dst clipped + * on the top or left the src image is not shifted into the + * clipped region but actually clipped. + */ + vis_src.x =3D ctx->src.x + (vis_dst.x - ctx->dst.x); + vis_src.y =3D ctx->src.y + (vis_dst.y - ctx->dst.y); + vis_src.width =3D vis_dst.width; + vis_src.height =3D vis_dst.height; + + DPRINTF("dst: (%d,%d) %dx%d -> vis_dst: (%d,%d) %dx%d\n", + ctx->dst.x, ctx->dst.y, ctx->dst.width, ctx->dst.height, + vis_dst.x, vis_dst.y, vis_dst.width, vis_dst.height); + DPRINTF("src: (%d,%d) %dx%d -> vis_src: (%d,%d) %dx%d\n", + ctx->src.x, ctx->src.y, ctx->src.width, ctx->src.height, + vis_src.x, vis_src.y, vis_src.width, vis_src.height); + switch (ctx->rop3) { case ROP3_SRCCOPY: { @@ -156,31 +186,31 @@ static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_= pixman) =20 DPRINTF("pixman_blt(%p, %p, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d= )\n", ctx->src_bits, ctx->dst_bits, src_stride_words, - dst_stride_words, ctx->bpp, ctx->bpp, ctx->src.x, ctx->src= .y, - ctx->dst.x, ctx->dst.y, ctx->dst.width, ctx->dst.height); + dst_stride_words, ctx->bpp, ctx->bpp, vis_src.x, vis_src.y, + vis_dst.x, vis_dst.y, vis_dst.width, vis_dst.height); #ifdef CONFIG_PIXMAN if (use_pixman_blt && ctx->left_to_right && ctx->top_to_bottom) { fallback =3D !pixman_blt((uint32_t *)ctx->src_bits, (uint32_t *)ctx->dst_bits, src_stride_w= ords, dst_stride_words, ctx->bpp, ctx->bpp, - ctx->src.x, ctx->src.y, ctx->dst.x, - ctx->dst.y, ctx->dst.width, ctx->dst.he= ight); + vis_src.x, vis_src.y, vis_dst.x, vis_ds= t.y, + vis_dst.width, vis_dst.height); } else if (use_pixman_blt) { /* FIXME: We only really need a temporary if src and dst overl= ap */ - int llb =3D ctx->dst.width * (ctx->bpp / 8); + int llb =3D vis_dst.width * (ctx->bpp / 8); int tmp_stride_words =3D DIV_ROUND_UP(llb, sizeof(uint32_t)); uint32_t *tmp =3D g_malloc(tmp_stride_words * sizeof(uint32_t)= * - ctx->dst.height); + vis_dst.height); fallback =3D !pixman_blt((uint32_t *)ctx->src_bits, tmp, src_stride_words, tmp_stride_words, ctx= ->bpp, - ctx->bpp, ctx->src.x, ctx->src.y, 0, 0, - ctx->dst.width, ctx->dst.height); + ctx->bpp, vis_src.x, vis_src.y, 0, 0, + vis_dst.width, vis_dst.height); if (!fallback) { fallback =3D !pixman_blt(tmp, (uint32_t *)ctx->dst_bits, tmp_stride_words, dst_stride_words, ctx->bpp, ctx->bpp, 0, 0, - ctx->dst.x, ctx->dst.y, - ctx->dst.width, ctx->dst.height); + vis_dst.x, vis_dst.y, + vis_dst.width, vis_dst.height); } g_free(tmp); } else @@ -190,20 +220,20 @@ static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_= pixman) } if (fallback) { unsigned int y, i, j, bypp =3D ctx->bpp / 8; - for (y =3D 0; y < ctx->dst.height; y++) { - i =3D ctx->dst.x * bypp; - j =3D ctx->src.x * bypp; + for (y =3D 0; y < vis_dst.height; y++) { + i =3D vis_dst.x * bypp; + j =3D vis_src.x * bypp; if (ctx->top_to_bottom) { - i +=3D (ctx->dst.y + y) * ctx->dst_stride; - j +=3D (ctx->src.y + y) * ctx->src_stride; + i +=3D (vis_dst.y + y) * ctx->dst_stride; + j +=3D (vis_src.y + y) * ctx->src_stride; } else { - i +=3D (ctx->dst.y + ctx->dst.height - 1 - y) + i +=3D (vis_dst.y + vis_dst.height - 1 - y) * ctx->dst_stride; - j +=3D (ctx->src.y + ctx->dst.height - 1 - y) + j +=3D (vis_src.y + vis_dst.height - 1 - y) * ctx->src_stride; } memmove(&ctx->dst_bits[i], &ctx->src_bits[j], - ctx->dst.width * bypp); + vis_dst.width * bypp); } } break; @@ -231,20 +261,20 @@ static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_= pixman) } =20 DPRINTF("pixman_fill(%p, %d, %d, %d, %d, %d, %d, %x)\n", - ctx->dst_bits, dst_stride_words, ctx->bpp, ctx->dst.x, - ctx->dst.y, ctx->dst.width, ctx->dst.height, filler); + ctx->dst_bits, dst_stride_words, ctx->bpp, vis_dst.x, + vis_dst.y, vis_dst.width, vis_dst.height, filler); #ifdef CONFIG_PIXMAN if (!use_pixman_fill || !pixman_fill((uint32_t *)ctx->dst_bits, dst_stride_words, ctx-= >bpp, - ctx->dst.x, ctx->dst.y, - ctx->dst.width, ctx->dst.height, filler)) + vis_dst.x, vis_dst.y, vis_dst.width, vis_dst.heig= ht, + filler)) #endif { /* fallback when pixman failed or we don't want to call it */ unsigned int x, y, i, bypp =3D ctx->bpp / 8; - for (y =3D 0; y < ctx->dst.height; y++) { - i =3D ctx->dst.x * bypp + (ctx->dst.y + y) * ctx->dst_stri= de; - for (x =3D 0; x < ctx->dst.width; x++, i +=3D bypp) { + for (y =3D 0; y < vis_dst.height; y++) { + i =3D vis_dst.x * bypp + (vis_dst.y + y) * ctx->dst_stride; + for (x =3D 0; x < vis_dst.width; x++, i +=3D bypp) { stn_he_p(&ctx->dst_bits[i], bypp, filler); } } --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224910; cv=none; d=zohomail.com; s=zohoarc; b=kHZiDg8QA30k8/cI4n1/3waZUaGNje/ih7H92QA27O4p7MjNtQG2TACXHG5Y+IGEmCTeKxLCGz5MNe2z4qRRZnrYoSpvf5df4w0XRHIDnbNivmZECIxPkwXFWsBttXoJ1kDtAdSVwPKsxCKXRN3UaHV4tkKNYPLrjOcNOsTSasg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224910; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KjHEB8cmWHa2uUjg4kmJyfG0LpAhVZnYiRB4AQrz5hA=; b=TyVCguKjMzcpi7X8C6LhAZvUa2OE1R7iXDglYWv1NrOpYKzyPE8HJWG1JyoP5Zch2DpKM2goh2JSOqnNJVtNr46y/BNEDx0LKWPyPsnrYeLCeKq5JRTFOlNnL0mRyZgnrZ7CSGOFwwk5AtA9KpL3KNfdQ448z2mr/NeKYRkea2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224910724516.875325581989; Fri, 27 Feb 2026 12:41:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4e4-0001mL-Ef; Fri, 27 Feb 2026 15:41:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e2-0001bV-Q8 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:06 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0007Qk-Q7 for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:06 -0500 Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 32E78140021E; Fri, 27 Feb 2026 15:41:02 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 27 Feb 2026 15:41:02 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 63ba524a; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224862; x= 1772311262; bh=KjHEB8cmWHa2uUjg4kmJyfG0LpAhVZnYiRB4AQrz5hA=; b=E SxYhtSL8MF/7DHSryIVr/OYCVM2YnmAtCJP7wxUZ84BuD1vcm+IzjSNqCxxRVN3p zV/k0l6ijRa5WibUsOK6m9gaRtjdMBWSn39klzFm7zAtCgCF7ymZPSGCtPhMdCvN F2W7plX6BLFq1Peiq2YOScBYWyjx1GvfILo2Q1bM4d1vD3dj7nvtVPJ8P85N34GJ gIrl1/IhV8UtN9gFmZSg4Jy6Pq/ne7oIuHbO9bYt2vBdwQsyOsVcMWEticKhxVqb ywr07R1bCB/67OXfQTKDWi6MHhbIE0ZmDR0mDNGtTj+QTSdMTPMMlMYU/d4ZFWYK Hk8xCDMi92mKb1RWV+waA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224862; x=1772311262; bh=K jHEB8cmWHa2uUjg4kmJyfG0LpAhVZnYiRB4AQrz5hA=; b=mTug60T8f+W0CF3gB tchR9F4KamnY4ZHdPXEHzMvbTYMXChXLzW6QQLy1C0Vz62x9chJ4EeWBXQvEBmw9 aVJ+ZFg1oCiXgamUI3szEWG+LPpe3lf0uLXRkb/nfOD6+kKIKnCX3GCLlpiJfic5 d4FtrJ1Xf308HnJ/1JAWtgI2695jkSKFL1jzvfsvz1enaiiW5IHoMSIKQ6hglKIj dmzMwbMLFI3pIzRB4JVKeLWozCR63AXv/CYwvo3xPjxwCIsNdPk10f09iHtb8wZd tjyuYEjtwH/HVKw9YhYe/66FYxeW5TuxmfPsAbHgDPKD15ib/0PNpKAKNDohQlil zdnZA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsrghlrghtoh hnsegvihhkrdgsmhgvrdhhuhdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhg nhhurdhorhhgpdhrtghpthhtohepmhgrrhgtrghnughrvgdrlhhurhgvrghusehrvgguhh grthdrtghomhdprhgtphhtthhopehkrhgrgigvlhesrhgvughhrghtrdgtohhmpdhrtghp thhtoheptghhrggusehjrggslhhonhhskhhirdighiii X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 17/18] ati-vga: Implement HOST_DATA register writes Date: Fri, 27 Feb 2026 15:39:43 -0500 Message-ID: <20260227203944.746471-18-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224911770158500 Content-Type: text/plain; charset="utf-8" Writing to any of the HOST_DATA0-7 registers pushes the written data into a 128-bit accumulator. When the accumulator is full a flush is triggered to copy it to the framebuffer. A final write to HOST_DATA_LAST will also initiate a flush. The flush itself is left for the next patch. Unaligned HOST_DATA* writes result in, from what I can tell, undefined behavior on real hardware. A well-behaved driver shouldn't be doing this anyway. For that reason they are not handled here at all. Signed-off-by: Chad Jablonski Reviewed-by: BALATON Zoltan --- hw/display/ati.c | 32 ++++++++++++++++++++++++++++++++ hw/display/ati_dbg.c | 9 +++++++++ hw/display/ati_int.h | 11 +++++++++++ hw/display/ati_regs.h | 9 +++++++++ 4 files changed, 61 insertions(+) diff --git a/hw/display/ati.c b/hw/display/ati.c index 6cf243bcf9..3757b8426e 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -1024,6 +1024,33 @@ static void ati_mm_write(void *opaque, hwaddr addr, case SRC_SC_BOTTOM: s->regs.src_sc_bottom =3D data & 0x3fff; break; + case HOST_DATA0: + case HOST_DATA1: + case HOST_DATA2: + case HOST_DATA3: + case HOST_DATA4: + case HOST_DATA5: + case HOST_DATA6: + case HOST_DATA7: + if (!s->host_data.active) { + break; + } + s->host_data.acc[s->host_data.next] =3D data; + if (s->host_data.next % ATI_HOST_DATA_FLUSH_WORDS =3D=3D + ATI_HOST_DATA_FLUSH_WORDS - 1) { + qemu_log_mask(LOG_UNIMP, "HOST_DATA flush not yet implemented\= n"); + } + s->host_data.next =3D (s->host_data.next + 1) % + ARRAY_SIZE(s->host_data.acc); + break; + case HOST_DATA_LAST: + if (!s->host_data.active) { + break; + } + s->host_data.acc[s->host_data.next] =3D data; + qemu_log_mask(LOG_UNIMP, + "HOST_DATA finish flush not yet implemented\n"); + break; default: break; } @@ -1129,6 +1156,11 @@ static void ati_vga_reset(DeviceState *dev) /* reset vga */ vga_common_reset(&s->vga); s->mode =3D VGA_MODE; + + s->host_data.active =3D false; + s->host_data.next =3D 0; + s->host_data.row =3D 0; + s->host_data.col =3D 0; } =20 static void ati_vga_exit(PCIDevice *dev) diff --git a/hw/display/ati_dbg.c b/hw/display/ati_dbg.c index 3ffa7f35df..5c799d540a 100644 --- a/hw/display/ati_dbg.c +++ b/hw/display/ati_dbg.c @@ -252,6 +252,15 @@ static struct ati_regdesc ati_reg_names[] =3D { {"MC_SRC1_CNTL", 0x19D8}, {"TEX_CNTL", 0x1800}, {"RAGE128_MPP_TB_CONFIG", 0x01c0}, + {"HOST_DATA0", 0x17c0}, + {"HOST_DATA1", 0x17c4}, + {"HOST_DATA2", 0x17c8}, + {"HOST_DATA3", 0x17cc}, + {"HOST_DATA4", 0x17d0}, + {"HOST_DATA5", 0x17d4}, + {"HOST_DATA6", 0x17d8}, + {"HOST_DATA7", 0x17dc}, + {"HOST_DATA_LAST", 0x17e0}, {NULL, -1} }; =20 diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index 98f57ca5fa..b285b6eba5 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -32,6 +32,8 @@ =20 #define ATI_RAGE128_LINEAR_APER_SIZE (64 * MiB) #define ATI_R100_LINEAR_APER_SIZE (128 * MiB) +#define ATI_HOST_DATA_FLUSH_BITS 128 +#define ATI_HOST_DATA_FLUSH_WORDS (ATI_HOST_DATA_FLUSH_BITS / 32) =20 #define TYPE_ATI_VGA "ati-vga" OBJECT_DECLARE_SIMPLE_TYPE(ATIVGAState, ATI_VGA) @@ -95,6 +97,14 @@ typedef struct ATIVGARegs { uint32_t default_tile; } ATIVGARegs; =20 +typedef struct ATIHostDataState { + bool active; + uint32_t row; + uint32_t col; + uint32_t next; + uint32_t acc[ATI_HOST_DATA_FLUSH_WORDS * 2]; +} ATIHostDataState; + struct ATIVGAState { PCIDevice dev; VGACommonState vga; @@ -112,6 +122,7 @@ struct ATIVGAState { MemoryRegion io; MemoryRegion mm; ATIVGARegs regs; + ATIHostDataState host_data; }; =20 const char *ati_reg_name(int num); diff --git a/hw/display/ati_regs.h b/hw/display/ati_regs.h index 3999edb9b7..48f15e9b1d 100644 --- a/hw/display/ati_regs.h +++ b/hw/display/ati_regs.h @@ -252,6 +252,15 @@ #define DP_T12_CNTL 0x178c #define DST_BRES_T1_LNTH 0x1790 #define DST_BRES_T2_LNTH 0x1794 +#define HOST_DATA0 0x17c0 +#define HOST_DATA1 0x17c4 +#define HOST_DATA2 0x17c8 +#define HOST_DATA3 0x17cc +#define HOST_DATA4 0x17d0 +#define HOST_DATA5 0x17d4 +#define HOST_DATA6 0x17d8 +#define HOST_DATA7 0x17dc +#define HOST_DATA_LAST 0x17e0 #define SCALE_SRC_HEIGHT_WIDTH 0x1994 #define SCALE_OFFSET_0 0x1998 #define SCALE_PITCH 0x199c --=20 2.52.0 From nobody Sat Feb 28 00:35:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1772224916; cv=none; d=zohomail.com; s=zohoarc; b=nESojIJlZ4T9xCn91/SymTtCERbXdt55PJzsnqHELS9ZB05KTLYCrIu4jPfFf6hcW9EnMW3o2fUhM/MXz5UluaDPsZopBNb3ZwwqS5EqXi7WnuR8izYTy+FA7dikGAnEIoRM2eVeDrxXv4n7u9VBzlgjuzBftivQxx3DbiSQ7PU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772224916; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bg1pEv+jWssKiS2j9WPghce6rJN8doMUtH8ssfpl4sg=; b=AEXhGdJ+I9V98+JtI2vgrqQUwqyABYHkEEgoY9HDS0uxP+TKQNfns6yxrUf6UFkfyJKUfST3GYdYOZw2+SM24eOW2cCUmmMSUdm9+Ou/Bo0Uj496V5y3ZnYmMWaEYJfLo75AJwBcqu15TNkLNAAGU1sxhMk5lKBAYOg18PV0NzU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772224916868717.3414924052677; Fri, 27 Feb 2026 12:41:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vw4eW-0003D3-T0; Fri, 27 Feb 2026 15:41:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4e3-0001f3-6Y for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:07 -0500 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vw4dz-0007Qn-SO for qemu-devel@nongnu.org; Fri, 27 Feb 2026 15:41:06 -0500 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 4CC24140021F; Fri, 27 Feb 2026 15:41:02 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Fri, 27 Feb 2026 15:41:02 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 15:41:01 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 18a79bad; Fri, 27 Feb 2026 20:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1772224862; x= 1772311262; bh=bg1pEv+jWssKiS2j9WPghce6rJN8doMUtH8ssfpl4sg=; b=k KACyQJXK+v1v4/n3dHau5hUsr6ZwnkfHQrHoxLumbnlEwCBw6DPUvkSHHxuU6+lO 9Z8tF4Qhy78rwneEW5BtiVk0UvRa4/Y9xy1Aop8y9QWEmZNyV0DOWdDlRixP6z2r DRnrqMqn/5fLK5ejL3bb9/ACc3maEAiVib8giLOuPWaMfL+ttyk2Z4CIZQL318Sf /IdXeO1x7J9bNb9phQGyLiTxzUBicZxFYOIeJLvU+NcuyhE6C3wwsCn3A0e+1Ygv cE6LU2oKgPIl/AjtRPpSfNosYm33Osn6hllPV2sMBuzkMlL3SZvCfpMs4ZHBdNyh eeJ0dToBLt4Qu2odUipRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772224862; x=1772311262; bh=b g1pEv+jWssKiS2j9WPghce6rJN8doMUtH8ssfpl4sg=; b=vBvY9R6mUjouYgjOH lpZsB/hYPIB9ilfNWn64uvJ7h3Bjqp0siuCnLjOwJkGIgKTJqtQ83ZapjZsUzMLF ysiEDrQMVBkhVcgNO3s4/541c7TZLnhEW4YorDShEEr+OFpUXxRK5091BBJ8LuHF Irz1Mvine0vbDsiNjEz7ZJ3WLKZaunXwplqgmX05T4BptryonAb3hqcvFgYVT2Jl Ti1tN9G9ZVIJCWKguJFGqdoDilb+nmA4UWmxuFBxPYCEjnhqaVaJWjMWFKRBc8ya /k7cNjjs5hY1QKJ3Ss8uoJNTO1UCykQg9FeFunNwc4AWAr4bwVTy2cqz9C6tgJlG BOerA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeelleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcuoegthhgrugesjhgrsghlohhnsh hkihdrgiihiieqnecuggftrfgrthhtvghrnhepgfeiteejhfelheefieetjefgleejfffh ueffvdduieejgfeuueeuvddvkeejhfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheptghhrggusehjrggslhhonhhskhhirdighiiipdhnsggp rhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthhgrugesjh grsghlohhnshhkihdrgiihiidprhgtphhtthhopehkrhgrgigvlhesrhgvughhrghtrdgt ohhmpdhrtghpthhtohepmhgrrhgtrghnughrvgdrlhhurhgvrghusehrvgguhhgrthdrtg homhdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtghp thhtohepsggrlhgrthhonhesvghikhdrsghmvgdrhhhu X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v9 18/18] ati-vga: Implement HOST_DATA flush to VRAM Date: Fri, 27 Feb 2026 15:39:44 -0500 Message-ID: <20260227203944.746471-19-chad@jablonski.xyz> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260227203944.746471-1-chad@jablonski.xyz> References: <20260227203944.746471-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.158; envelope-from=chad@jablonski.xyz; helo=fhigh-a7-smtp.messagingengine.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.706, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.401, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1772224917666158500 Content-Type: text/plain; charset="utf-8" Implement flushing the 128-bit HOST_DATA accumulator to VRAM to enable text rendering in X. Supports all datatypes (monochrome frgd/bkgd, monochrome frgd, and color), however monochrome frgd support is partial and does not properly handle transparency/leave-alone. The flush is broken up into two steps. First, if necessary, expansion of the monochrome bits to the destination color depth. Then the expanded pixels are sent to the ati_2d_do_blt one scanline at a time. ati_2d_do_blt then clips and performs the blit. Signed-off-by: Chad Jablonski --- hw/display/ati.c | 5 +- hw/display/ati_2d.c | 126 ++++++++++++++++++++++++++++++++++++++++++ hw/display/ati_int.h | 2 + hw/display/ati_regs.h | 4 ++ 4 files changed, 134 insertions(+), 3 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 3757b8426e..4468c345b1 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -1038,7 +1038,7 @@ static void ati_mm_write(void *opaque, hwaddr addr, s->host_data.acc[s->host_data.next] =3D data; if (s->host_data.next % ATI_HOST_DATA_FLUSH_WORDS =3D=3D ATI_HOST_DATA_FLUSH_WORDS - 1) { - qemu_log_mask(LOG_UNIMP, "HOST_DATA flush not yet implemented\= n"); + ati_flush_host_data(s); } s->host_data.next =3D (s->host_data.next + 1) % ARRAY_SIZE(s->host_data.acc); @@ -1048,8 +1048,7 @@ static void ati_mm_write(void *opaque, hwaddr addr, break; } s->host_data.acc[s->host_data.next] =3D data; - qemu_log_mask(LOG_UNIMP, - "HOST_DATA finish flush not yet implemented\n"); + ati_finish_host_data(s); break; default: break; diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 2b3a239da3..8de9d0f414 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -290,6 +290,19 @@ static void ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_p= ixman) void ati_2d_blt(ATIVGAState *s) { ATI2DCtx ctx; + uint32_t src_source =3D s->regs.dp_mix & DP_SRC_SOURCE; + + /* Finish any active HOST_DATA blits before starting a new blit */ + ati_finish_host_data(s); + + if (src_source =3D=3D DP_SRC_HOST || src_source =3D=3D DP_SRC_HOST_BYT= EALIGN) { + /* Begin a HOST_DATA blit */ + s->host_data.active =3D true; + s->host_data.next =3D 0; + s->host_data.col =3D 0; + s->host_data.row =3D 0; + return; + } setup_2d_blt_ctx(s, &ctx); if (ctx.rop3 =3D=3D ROP3_SRCCOPY && (ctx.src.x > 0x3fff || ctx.src.y >= 0x3fff || ctx.src_bits >=3D ctx.vram_end || ctx.src_bits + ctx.src.x + @@ -300,3 +313,116 @@ void ati_2d_blt(ATIVGAState *s) ati_2d_do_blt(&ctx, s->use_pixman); ati_set_dirty(&s->vga, &ctx); } + +bool ati_flush_host_data(ATIVGAState *s) +{ + ATI2DCtx ctx, chunk; + uint32_t fg =3D s->regs.dp_src_frgd_clr; + uint32_t bg =3D s->regs.dp_src_bkgd_clr; + unsigned bypp, pix_count, row, col, base, idx; + uint8_t pix_buf[ATI_HOST_DATA_FLUSH_BITS * sizeof(uint32_t)]; + uint32_t byte_pix_order =3D s->regs.dp_datatype & DP_BYTE_PIX_ORDER; + uint32_t src_source =3D s->regs.dp_mix & DP_SRC_SOURCE; + uint32_t src_datatype =3D s->regs.dp_datatype & DP_SRC_DATATYPE; + + if (!s->host_data.active) { + return false; + } + if (src_source !=3D DP_SRC_HOST) { + qemu_log_mask(LOG_GUEST_ERROR, + "host_data_blt: unsupported src_source %x\n", src_so= urce); + return false; + } + if (src_datatype !=3D SRC_MONO_FRGD_BKGD && src_datatype !=3D SRC_MONO= _FRGD && + src_datatype !=3D SRC_COLOR) { + qemu_log_mask(LOG_GUEST_ERROR, + "host_data_blt: undefined src_datatype %x\n", + src_datatype); + return false; + } + + setup_2d_blt_ctx(s, &ctx); + + if (!ctx.left_to_right || !ctx.top_to_bottom) { + qemu_log_mask(LOG_UNIMP, + "host_data_blt: unsupported blit direction %c%c\n", + ctx.left_to_right ? '>' : '<', + ctx.top_to_bottom ? 'v' : '^'); + return false; + } + + bypp =3D ctx.bpp / 8; + base =3D (s->host_data.next / ATI_HOST_DATA_FLUSH_WORDS) * + ATI_HOST_DATA_FLUSH_WORDS; + DPRINTF("expand @ base: %d\n", base); + + if (src_datatype =3D=3D SRC_COLOR) { + pix_count =3D ATI_HOST_DATA_FLUSH_BITS / ctx.bpp; + memcpy(pix_buf, &s->host_data.acc[base], + ATI_HOST_DATA_FLUSH_WORDS * sizeof(uint32_t)); + } else { + pix_count =3D ATI_HOST_DATA_FLUSH_BITS; + /* Expand monochrome bits to color pixels */ + idx =3D 0; + for (int word =3D base; word < base + ATI_HOST_DATA_FLUSH_WORDS; w= ord++) { + for (int byte =3D 0; byte < 4; byte++) { + uint8_t byte_val =3D s->host_data.acc[word] >> (byte * 8); + for (int i =3D 0; i < 8; i++) { + bool is_fg =3D byte_val & BIT(byte_pix_order ? i : 7 -= i); + uint32_t color =3D is_fg ? fg : bg; + stn_he_p(&pix_buf[idx * bypp], bypp, color); + idx +=3D 1; + } + } + } + } + + /* Copy and then modify blit ctx for use in a chunked blit */ + chunk =3D ctx; + chunk.src_bits =3D pix_buf; + chunk.src.y =3D 0; + chunk.src_stride =3D ATI_HOST_DATA_FLUSH_BITS * bypp; + + /* Blit one scanline chunk at a time */ + row =3D s->host_data.row; + col =3D s->host_data.col; + idx =3D 0; + DPRINTF("blt %dpx @ row: %d, col: %d\n", pix_count, row, col); + while (idx < pix_count && row < ctx.dst.height) { + unsigned pix_in_scanline =3D MIN(pix_count - idx, + ctx.dst.width - col); + chunk.src.x =3D idx; + /* Build a rect for this scanline chunk */ + chunk.dst.x =3D ctx.dst.x + col; + chunk.dst.y =3D ctx.dst.y + row; + chunk.dst.width =3D pix_in_scanline; + chunk.dst.height =3D 1; + DPRINTF("blt %dpx span @ row: %d, col: %d to dst (%d,%d)\n", + pix_in_scanline, row, col, chunk.dst.x, chunk.dst.y); + ati_2d_do_blt(&chunk, s->use_pixman); + ati_set_dirty(&s->vga, &chunk); + idx +=3D pix_in_scanline; + col +=3D pix_in_scanline; + if (col >=3D ctx.dst.width) { + col =3D 0; + row +=3D 1; + } + } + + /* Track state of the overall blit for use by the next flush */ + s->host_data.row =3D row; + s->host_data.col =3D col; + if (s->host_data.row >=3D ctx.dst.height) { + s->host_data.active =3D false; + } + + return s->host_data.active; +} + +void ati_finish_host_data(ATIVGAState *s) +{ + while (ati_flush_host_data(s)) { + s->host_data.next =3D (s->host_data.next + ATI_HOST_DATA_FLUSH_WOR= DS) % + ARRAY_SIZE(s->host_data.acc); + } +} diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index b285b6eba5..9e77bf8ebd 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -128,5 +128,7 @@ struct ATIVGAState { const char *ati_reg_name(int num); =20 void ati_2d_blt(ATIVGAState *s); +bool ati_flush_host_data(ATIVGAState *s); +void ati_finish_host_data(ATIVGAState *s); =20 #endif /* ATI_INT_H */ diff --git a/hw/display/ati_regs.h b/hw/display/ati_regs.h index 48f15e9b1d..b813fa119e 100644 --- a/hw/display/ati_regs.h +++ b/hw/display/ati_regs.h @@ -397,7 +397,11 @@ #define DST_32BPP 0x00000006 #define DP_DST_DATATYPE 0x0000000f #define DP_BRUSH_DATATYPE 0x00000f00 +#define SRC_MONO_FRGD_BKGD 0x00000000 +#define SRC_MONO_FRGD 0x00010000 +#define SRC_COLOR 0x00030000 #define DP_SRC_DATATYPE 0x00030000 +#define DP_BYTE_PIX_ORDER 0x40000000 =20 #define BRUSH_SOLIDCOLOR 0x00000d00 =20 --=20 2.52.0