Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1055345rdb; Fri, 2 Feb 2024 12:04:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmfQBU/4Qzrhfzn2fYCswBRd5RrGHH3ziP7d0AyW1VPoCu49vkrrRoX1+rXqSb4DvzdrMd X-Received: by 2002:a92:c5d0:0:b0:363:a6f7:ee27 with SMTP id s16-20020a92c5d0000000b00363a6f7ee27mr2856119ilt.2.1706904247031; Fri, 02 Feb 2024 12:04:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706904247; cv=pass; d=google.com; s=arc-20160816; b=odFqDKIgKC9/LKUMHsJoUldu2t69MbZzpr+W2uEoEjvSMjNHYXYQ9ZW6koqOcHkM5E Fwvs2dZHj67u6r0yMJAa+12dtAflCR2/KQBpXcjoMzhkj2EuOr8r6HIyVLDZCxTftNV/ KDlqHcMq5Cp6y1xoHWYxUhIiHpGxpL+bHgGAa/OTY44U1GERSdUOXTrRcQVEfRaacsQL uxZa6y14K3LZaMlQ1CNWVxIOX2DrxkYl6CZKqAUBytjvoEjofG3kg//vwGAiwu8NULwm Q4SdVqgquq0Ayu4WuQFjYbeuhC2RYxHH5WJ25p+fRf3oCtwkIBKHkfsxlDXRytk+KnhR ChEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=OfYp1WQnMmKiA+PMtY95A2atjQJiHwTjXYfXeJyto5o=; fh=l+Uez6uTGQVJNot30bxV2xx+Wehw1IQ9ziDECb2m2VI=; b=LJiSNgTgqrYMwZ6jUCsrVUZ0mWo4v/kg3xuboNF/KXTRzQW3D7G4glf5qxsS6JtdUc 9Pr0wk6oHCHhGs9X86iWrOSROdKO4a6qqE+UhVGWctiV3qlavdZvdIcsDhTbnWM2bCC8 +In15L5USbtQ/INat71EmhVlpr0YZxC/lKuz3HDXx9ImqrxuZGYwc66hbnLkAnX8amS0 9e5MT2XvHK6WgeSbSWJotyvzW1O1OJZC/ysm094px0ruh4OBUretqutWANuUsUMzhrv6 KH0ooW/pc2FsEQl+MGAHcR2GfcASS47IW2be7to594XIdNeG/mna/LcInb8QrgHArteb amKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b="cI/JFAFg"; arc=pass (i=1 spf=pass spfdomain=riseup.net dkim=pass dkdomain=riseup.net dmarc=pass fromdomain=riseup.net); spf=pass (google.com: domain of linux-kernel+bounces-50523-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50523-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net X-Forwarded-Encrypted: i=1; AJvYcCXeTVFcjVzyZi867NV6MuNh1LnJTNoWwou7zFReUBwczwc03pLChi44odLAICiY4suXX7uFzCO4stXVptrBu84n32Fb550jUHWhP9xr5w== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bz19-20020a056a02061300b005d8b5aace80si2084219pgb.371.2024.02.02.12.04.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 12:04:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50523-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b="cI/JFAFg"; arc=pass (i=1 spf=pass spfdomain=riseup.net dkim=pass dkdomain=riseup.net dmarc=pass fromdomain=riseup.net); spf=pass (google.com: domain of linux-kernel+bounces-50523-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50523-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6C48D28A891 for ; Fri, 2 Feb 2024 20:03:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B0F78063B; Fri, 2 Feb 2024 20:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=riseup.net header.i=@riseup.net header.b="cI/JFAFg" Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E18D80625 for ; Fri, 2 Feb 2024 20:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.252.153.129 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706904153; cv=none; b=BVJAbOn74p+M2x33Z8G/5v7b8OzpLW4mlL7vWCjPc3uYLHJTjxjYeO0slBtmv3tvZk9ZFFgV5LK8Bmpqvs2DnMKTOyhyhn2nU4tR+HvT2hTaqU2WNOVsi1evfI6b3WeO9A+PnVl8ofQtCOdOtD1pte1XhSPGPiqzmfDOK9UvxM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706904153; c=relaxed/simple; bh=EayggpD20ZVxvOuBUHp6GQDJdR4ntp9uMY9cbHbb30I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UC2lqFOU2Khec8ITiaMCSfDE0LyOsgWsx02+bD8VJetjEunQgVvT86ffksFNF44c3exP1s3IAdPguqn1Y0124W/nhIcNCqzjeVZcIUUKqAAwl5f520+bEhfcwh4Iv18woURR8d7z8ZXotdbyON8P5pApwU8oqWZUdKC3dLyYMbo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riseup.net; spf=pass smtp.mailfrom=riseup.net; dkim=pass (1024-bit key) header.d=riseup.net header.i=@riseup.net header.b=cI/JFAFg; arc=none smtp.client-ip=198.252.153.129 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riseup.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riseup.net Received: from fews02-sea.riseup.net (fews02-sea-pn.riseup.net [10.0.1.112]) (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 mx1.riseup.net (Postfix) with ESMTPS id 4TRRWn6dTrzDq8D; Fri, 2 Feb 2024 20:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1706904150; bh=EayggpD20ZVxvOuBUHp6GQDJdR4ntp9uMY9cbHbb30I=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=cI/JFAFg1rFMS70ZTBUTRo6ymeh73P7sSijXzXmSUjn/8PwDYCykzIIeFnWjzcwd3 kgmpV8gQuWK0UMyeLlJFUYGcBRVtpHrmB2VdEZNbKDhacfBfI6cN4k0CQsIQANPrka 7IigYT89fPdC8G1IHGZD7rjdSBhF+IbiCKStwX1c= X-Riseup-User-ID: 918AF2773BAFBA0FA6A8F54866A4FC8F79B59C8D58DAD5DE7946EB67FE979219 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4TRRWh0lHnzFpvw; Fri, 2 Feb 2024 20:02:23 +0000 (UTC) Message-ID: <14ac793c-6660-434f-998d-af1f51b3b1d2@riseup.net> Date: Fri, 2 Feb 2024 17:02:20 -0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 2/2] drm/vkms: Use a simpler composition function Content-Language: en-US To: Pekka Paalanen , Miquel Raynal Cc: Maxime Ripard , Louis Chauvet , Rodrigo Siqueira , Melissa Wen , =?UTF-8?Q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , David Airlie , marcheu@google.com, seanpaul@google.com, nicolejadeyee@google.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com References: <20240201-yuv-v1-0-3ca376f27632@bootlin.com> <20240201-yuv-v1-2-3ca376f27632@bootlin.com> <20240202105522.43128e19@eldfell> <20240202102601.70b6d49c@xps-13> <3nofkwzgnf4yva2wfogdbii47ohpi2wm5vp6aijtg3emxyoowt@twyreqz7ai3g> <20240202131322.5471e184@xps-13> <20240202174913.789a9db9@eldfell> From: Arthur Grillo In-Reply-To: <20240202174913.789a9db9@eldfell> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 02/02/24 12:49, Pekka Paalanen wrote: > On Fri, 2 Feb 2024 13:13:22 +0100 > Miquel Raynal wrote: > >> Hello Maxime, >> >> + Arthur >> >> mripard@kernel.org wrote on Fri, 2 Feb 2024 10:53:37 +0100: >> >>> Hi Miquel, >>> >>> On Fri, Feb 02, 2024 at 10:26:01AM +0100, Miquel Raynal wrote: >>>> pekka.paalanen@haloniitty.fi wrote on Fri, 2 Feb 2024 10:55:22 +0200: >>>> >>>>> On Thu, 01 Feb 2024 18:31:32 +0100 >>>>> Louis Chauvet wrote: >>>>> >>>>>> Change the composition algorithm to iterate over pixels instead of lines. >>>>>> It allows a simpler management of rotation and pixel access for complex formats. >>>>>> >>>>>> This new algorithm allows read_pixel function to have access to x/y >>>>>> coordinates and make it possible to read the correct thing in a block >>>>>> when block_w and block_h are not 1. >>>>>> The iteration pixel-by-pixel in the same method also allows a simpler >>>>>> management of rotation with drm_rect_* helpers. This way it's not needed >>>>>> anymore to have misterious switch-case distributed in multiple places. >>>>> >>>>> Hi, >>>>> >>>>> there was a very good reason to write this code using lines: >>>>> performance. Before lines, it was indeed operating on individual pixels. >>>>> >>>>> Please, include performance measurements before and after this series >>>>> to quantify the impact on the previously already supported pixel >>>>> formats, particularly the 32-bit-per-pixel RGB variants. >>>>> >>>>> VKMS will be used more and more in CI for userspace projects, and >>>>> performance actually matters there. >>>>> >>>>> I'm worrying that this performance degradation here is significant. I >>>>> believe it is possible to keep blending with lines, if you add new line >>>>> getters for reading from rotated, sub-sampled etc. images. That way you >>>>> don't have to regress the most common formats' performance. >>>> >>>> While I understand performance is important and should be taken into >>>> account seriously, I cannot understand how broken testing could be >>>> considered better. Fast but inaccurate will always be significantly >>>> less attractive to my eyes. >>> >>> AFAIK, neither the cover letter nor the commit log claimed it was fixing >>> something broken, just that it was "better" (according to what >>> criteria?). >> >> Better is probably too vague and I agree the "fixing" part is not >> clearly explained in the commit log. The cover-letter however states: >> >>> Patch 2/2: This patch is more complex. My main target was to solve issues >>> I found in [1], but as it was very complex to do it "in place", I choose >>> to rework the composition function. >> ... >>> [1]: https://lore.kernel.org/dri-devel/20240110-vkms-yuv-v2-0-952fcaa5a193@riseup.net/ >> >> If you follow this link you will find all the feedback and especially >> the "broken" parts. Just to be clear, writing bugs is totally expected >> and review/testing is supposed to help on this regard. I am not blaming >> the author in any way, just focusing on getting this code in a more >> readable shape and hopefully reinforce the testing procedure. >> >>> If something is truly broken, it must be stated what exactly is so we >>> can all come up with a solution that will satisfy everyone. >> >> Maybe going through the series pointed above will give more context >> but AFAIU: the YUV composition is not totally right (and the tests used >> to validate it need to be more complex as well in order to fail). >> >> Here is a proposal. >> >> Today's RGB implementation is only optimized in the line-by-line case >> when there is no rotation. The logic is bit convoluted and may possibly >> be slightly clarified with a per-format read_line() implementation, >> at a very light performance cost. Such an improvement would definitely >> benefit to the clarity of the code, especially when transformations >> (especially the rotations) come into play because they would be clearly >> handled differently instead of being "hidden" in the optimized logic. >> Performances would not change much as this path is not optimized today >> anyway (the pixel-oriented logic is already used in the rotation case). >> >> Arthur's YUV implementation is indeed well optimized but the added >> complexity probably lead to small mistakes in the logic. The >> per-format read_line() implementation mentioned above could be >> extended to the YUV format as well, which would leverage Arthur's >> proposal by re-using his optimized version. Louis will help on this >> regard. However, for more complex cases such as when there is a >> rotation, it will be easier (and not sub-optimized compared to the RGB >> case) to also fallback to a pixel-oriented processing. >> >> Would this approach make sense? > > Hi, > > I think it would, if I understand what you mean. Ever since I proposed > a line-by-line algorithm to improve the performance, I was thinking of > per-format read_line() functions that would be selected outside of any > loops. Extending that to support YUV is only natural. I can imagine > rotation complicates things, and I won't oppose that resulting in a > much heavier read_line() implementation used in those cases. They might > perhaps call the original read_line() implementations pixel-by-pixel or > plane-by-plane (i.e. YUV planes) per pixel. Chroma-siting complicates > things even further. That way one could compose any > rotation-format-siting combination by chaining function pointers. > > I haven't looked at VKMS in a long time, and I am disappointed to find > that vkms_compose_row() is calling plane->pixel_read() pixel-by-pixel. > The reading vfunc should be called with many pixels at a time when the > source FB layout allows it. The whole point of the line-based functions > was that they repeat the innermost loop in every function body to make > the per-pixel overhead as small as possible. The VKMS implementations > benchmarked before and after the original line-based algorithm showed > that calling a function pointer per-pixel is relatively very expensive. > Or maybe it was a switch-case. Hi, I think I'm the culprit for that, as stated on [1]. My intention with the suggestion was to remove some code repetition and too facilitate the rotation support implementation. Going back, I think I was to high on DRY at the time and didn't worry about optimization, which was a mistake. But, I agree with Miquel that the rotation logic is easier to implement in a pixel-based way. So going pixel-by-pixel only when rotation occurs would be great. Best Regards, ~Arthur Grillo [1]: https://lore.kernel.org/dri-devel/20230418130525.128733-2-mcanal@igalia.com/ > > Sorry, I didn't realize the optimization had already been lost. > > Btw. I'd suggest renaming vkms_compose_row() to vkms_fetch_row() since > it's not composing anything and the name mislead me. > > I think if you inspect the compositing code as of revision > 8356b97906503a02125c8d03c9b88a61ea46a05a you'll get a better feeling of > what it was supposed to be. > > > Thanks, > pq