From patchwork Thu Nov 23 18:59:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10073189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C86606056E for ; Thu, 23 Nov 2017 18:59:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4531286DD for ; Thu, 23 Nov 2017 18:59:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6EC22955B; Thu, 23 Nov 2017 18:59:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 420B4286DD for ; Thu, 23 Nov 2017 18:59:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 083F76E836; Thu, 23 Nov 2017 18:59:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x244.google.com (mail-qt0-x244.google.com [IPv6:2607:f8b0:400d:c0d::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D8B86E836 for ; Thu, 23 Nov 2017 18:59:31 +0000 (UTC) Received: by mail-qt0-x244.google.com with SMTP id 33so20105877qtv.1 for ; Thu, 23 Nov 2017 10:59:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=n+IyHI2COSlBPTT3aQlq1PNro9mBuzn7Dji8lTyjXh8=; b=tMJDwqRAdZgGdFhnEIL4iqTR6SQqEhefS8n5KfeqBQHNmNL0/uOxwaxSN2ucfm6ndn 5PQbrkFvt9+MI18jW7O9V/Ygyz8KXn+EI3gy6CwuHalN6BU0DzkucymCWGGA3sCjhGj4 tKxIT5SAoJjjOfh5klrKv8sA4ds5RfKEwXNAD2J7QTB0xhiY1dcGx7L1OKAJzO4tYsXI bIHrVGttvRclONGkcLzxX6wTW/V43H+QFxZIy8YS0/u594HaGytmcfKMU3kuCLUlTG2R fq6+aWU0FSgedElczorFpa2CeD3otmRaOzfPcg/44QJjTCddj20M9Rv0WNeZ7U9PWB4D htbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=n+IyHI2COSlBPTT3aQlq1PNro9mBuzn7Dji8lTyjXh8=; b=kgz/OwNsZm0MBjEJikVYg42cOczmKyzpPq6NVmTHCjTMS7VeG6JzynHOWj1pj0xiux rvY5N7HwbydwT83SCEsu4ivr0Yp7jB9x2oZE9R3N5r7QrRtJXN//AE/ne5KoqfvbKUp4 +I1tFSobW7NVngBfeprQgNfj806tEJx8gmwkmvhicyabpPeenntUATLwnHMovXeiVBQa XEgqxnRe6iX+rFeguXOPX+m1WBEjE+9y02rrEr8fRYPlzLWpoR2mGUT/TWG4NkxZQ4mI Da6f3HTJcmq6vCx1gOqbwLTc0BYIOxpeq+5oWOnCpKcDUwow5/GrurIlq/TKC8POPaX+ cXPQ== X-Gm-Message-State: AJaThX5WWI0iDR4Gyqd1QU1U0HHllos4EooHVrnYt1jbBa0DVIQ7l340 nKd7LOyivOIWR/S7D/ZoSiu5Sf9z X-Google-Smtp-Source: AGs4zMbtgwl8eO9WZJ+n3kjN3vmfG7lMCBd8c76/LSA0GutPrtUix9ct4aZVazmdgKkzizAFKJEmiA== X-Received: by 10.200.48.82 with SMTP id g18mr38216684qte.329.1511463570243; Thu, 23 Nov 2017 10:59:30 -0800 (PST) Received: from athos.fios-router.home (pool-100-2-1-206.nycmny.fios.verizon.net. [100.2.1.206]) by smtp.gmail.com with ESMTPSA id h32sm5118286qtk.8.2017.11.23.10.59.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:59:29 -0800 (PST) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] tests: fix MAKE_RGBA macro for 10bpp modes Date: Thu, 23 Nov 2017 13:59:28 -0500 Message-Id: <20171123185928.6303-1-imirkin@alum.mit.edu> X-Mailer: git-send-email 2.13.6 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We need to shift the values up, otherwise we'd end up with a negative shift. This works for up-to 16-bit components, which is fine for now. Signed-off-by: Ilia Mirkin --- tests/util/pattern.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 41fb541b..2f9bb384 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -64,11 +64,17 @@ struct color_yuv { .u = MAKE_YUV_601_U(r, g, b), \ .v = MAKE_YUV_601_V(r, g, b) } +static inline uint32_t shiftcolor(const struct util_color_component *comp, + uint32_t value) +{ + return ((value << 8) >> (16 - comp->length)) << comp->offset; +} + #define MAKE_RGBA(rgb, r, g, b, a) \ - ((((r) >> (8 - (rgb)->red.length)) << (rgb)->red.offset) | \ - (((g) >> (8 - (rgb)->green.length)) << (rgb)->green.offset) | \ - (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \ - (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset)) + (shiftcolor(&(rgb)->red, (r)) | \ + shiftcolor(&(rgb)->green, (g)) | \ + shiftcolor(&(rgb)->blue, (b)) | \ + shiftcolor(&(rgb)->alpha, (a))) #define MAKE_RGB24(rgb, r, g, b) \ { .value = MAKE_RGBA(rgb, r, g, b, 0) }