From nobody Wed Nov 27 12:29:49 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277598; cv=none; d=zohomail.com; s=zohoarc; b=R/5xCtn3dX7vQINHxHo7+Ka8y6whTlZiIMk2lMApmYbSgcyAdONoq0Dlb/hWoA4rS2vd0SW4gCFOS83BtL7Njp52zuqV/BW7dpO67byObGKl81ncGHeiiM/gGUTD4GAhsRCfU53kPeaRkDHDPog2Zl9aQV21w32gLJO03NIfuhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277598; h=Content-Type: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=Mywo8KICVCxbxzpY+mReJFJ1I78UFt3Y9PYuMgZIeBs=; b=bMttBXhTojcube5i9gSFPV0yPMCUTxWH9TcHN5ZGPKuik5mKXVYgvnj6qlLH1PgU81ChUIWZ5ogPXdq3MnQTeTOhK4M7XXNf4nlDam92qPxiRNc+yRxv5szT1esZQiIFSl+X9t2cEpRd847LhNuoZWVbk2lerm3p6x84wfOwmxA= 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 1699277598331744.2484887378263; Mon, 6 Nov 2023 05:33:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzik-0005nA-7X; Mon, 06 Nov 2023 08:32:50 -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 1qzzii-0005m7-NS for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzzig-0003lG-Ux for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:48 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-KYB8TDfGM1OurNTp5L4s9g-1; Mon, 06 Nov 2023 08:32:44 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55542185A788; Mon, 6 Nov 2023 13:32:44 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BC74492BE0; Mon, 6 Nov 2023 13:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mywo8KICVCxbxzpY+mReJFJ1I78UFt3Y9PYuMgZIeBs=; b=FzzjEPgGBIU+9wJUGs937AsL+IB+qk9vJpn5682i3sCy1pzTeVL03AhKgGkhMWVHpOJlFK 2wZzQlsrSh3w060Yk4ZN6JK/jca7X72/q8f+6ttFn4U4kKHS1PI/BALZFDbg2UIFL966YX CTVdax9FowigOiTlfZf+n8QmwrIO95k= X-MC-Unique: KYB8TDfGM1OurNTp5L4s9g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, BALATON Zoltan Subject: [PULL 05/10] ati-vga: Implement fallback for pixman routines Date: Mon, 6 Nov 2023 17:32:14 +0400 Message-ID: <20231106133219.2173660-6-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 @redhat.com) X-ZM-MESSAGEID: 1699277599140100002 From: BALATON Zoltan Pixman routines can fail if no implementation is available and it will become optional soon so add fallbacks when pixman does not work. Signed-off-by: BALATON Zoltan Acked-by: Marc-Andr=C3=A9 Lureau Message-ID: --- hw/display/ati_int.h | 1 + hw/display/ati.c | 8 +++++ hw/display/ati_2d.c | 75 +++++++++++++++++++++++++++++++------------- 3 files changed, 62 insertions(+), 22 deletions(-) diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index 8abb873f01..f5a47b82b0 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -90,6 +90,7 @@ struct ATIVGAState { char *model; uint16_t dev_id; uint8_t mode; + uint8_t use_pixman; bool cursor_guest_mode; uint16_t cursor_size; uint32_t cursor_offset; diff --git a/hw/display/ati.c b/hw/display/ati.c index 4868f95cf2..9a87a5504a 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -1033,6 +1033,7 @@ static Property ati_vga_properties[] =3D { DEFINE_PROP_UINT16("x-device-id", ATIVGAState, dev_id, PCI_DEVICE_ID_ATI_RAGE128_PF), DEFINE_PROP_BOOL("guest_hwcursor", ATIVGAState, cursor_guest_mode, fal= se), + DEFINE_PROP_UINT8("x-pixman", ATIVGAState, use_pixman, 3), DEFINE_PROP_END_OF_LIST() }; =20 @@ -1054,11 +1055,18 @@ static void ati_vga_class_init(ObjectClass *klass, = void *data) k->exit =3D ati_vga_exit; } =20 +static void ati_vga_init(Object *o) +{ + object_property_set_description(o, "x-pixman", "Use pixman for: " + "1: fill, 2: blit"); +} + static const TypeInfo ati_vga_info =3D { .name =3D TYPE_ATI_VGA, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(ATIVGAState), .class_init =3D ati_vga_class_init, + .instance_init =3D ati_vga_init, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, { }, diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 7d786653e8..0e6b8e4367 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -92,6 +92,7 @@ void ati_2d_blt(ATIVGAState *s) switch (s->regs.dp_mix & GMC_ROP3_MASK) { 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 ? @@ -122,27 +123,50 @@ void ati_2d_blt(ATIVGAState *s) src_bits, dst_bits, src_stride, dst_stride, bpp, bpp, src_x, src_y, dst_x, dst_y, s->regs.dst_width, s->regs.dst_height); - if (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT && + if ((s->use_pixman & BIT(1)) && + s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT && s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) { - pixman_blt((uint32_t *)src_bits, (uint32_t *)dst_bits, - src_stride, dst_stride, bpp, bpp, - src_x, src_y, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height); - } else { + fallback =3D !pixman_blt((uint32_t *)src_bits, (uint32_t *)dst= _bits, + src_stride, dst_stride, 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) * s->regs.dst_height); - pixman_blt((uint32_t *)src_bits, tmp, - src_stride, tmp_stride, bpp, bpp, - src_x, src_y, 0, 0, - s->regs.dst_width, s->regs.dst_height); - pixman_blt(tmp, (uint32_t *)dst_bits, - tmp_stride, dst_stride, bpp, bpp, - 0, 0, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height); + fallback =3D !pixman_blt((uint32_t *)src_bits, tmp, + src_stride, tmp_stride, 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, + s->regs.dst_width, s->regs.dst_heig= ht); + } g_free(tmp); + } else { + fallback =3D true; + } + 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; + } 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; + } + 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 + @@ -180,14 +204,21 @@ void ati_2d_blt(ATIVGAState *s) =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, - s->regs.dst_width, s->regs.dst_height, - filler); - pixman_fill((uint32_t *)dst_bits, dst_stride, bpp, - dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height, - filler); + dst_bits, dst_stride, bpp, dst_x, dst_y, + s->regs.dst_width, s->regs.dst_height, filler); + 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)) { + /* 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; + for (x =3D 0; x < s->regs.dst_width; x++, i +=3D bypp) { + stn_he_p(&dst_bits[i], bypp, filler); + } + } + } 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= ) { --=20 2.41.0