From patchwork Sat Nov 25 19:39:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10075079 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 35F7160353 for ; Sat, 25 Nov 2017 19:40:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20A1F28E4E for ; Sat, 25 Nov 2017 19:40:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0418628E58; Sat, 25 Nov 2017 19:40:00 +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 9BE9E28E4E for ; Sat, 25 Nov 2017 19:39:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFE0F6E13A; Sat, 25 Nov 2017 19:39:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x243.google.com (mail-qk0-x243.google.com [IPv6:2607:f8b0:400d:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2C0E16E13A for ; Sat, 25 Nov 2017 19:39:55 +0000 (UTC) Received: by mail-qk0-x243.google.com with SMTP id p19so28040575qke.2 for ; Sat, 25 Nov 2017 11:39:55 -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=i0arct8bkaENr9vzGeU6L7FoG1Wd28lBttzBsaxoX4M=; b=hJ2YvsZ13oUKiaqBXT0eaj62wQ4psGoI2KS5DqS/hOqNB8mWx1ytXocJ1totukKiw2 Z2eKwAYjn5m/+HcEOxp1qx5TfChhL1c+UESqbRYxybGlY+u71IRphNw7Og+6Ox8vwfFS It5AYl7DnOhWtuhTvbkchoSURM8LuCvDuM0dQkhGvsr4mHr27HS1FqLWf95ChBNjrf/Z 3ECha5VQjr0vEIwO88OGGnktcAvM/IQaBSREahGkWaxG8zfvB1OqJ+z3a/ie2Xzv7O59 falVpNDZjy6LxmSiQ4HpSOwAbOFKjLcW7swMRrt6pQTgJtNA7QWnZte2qqDHW3jwKYvu oGWQ== 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=i0arct8bkaENr9vzGeU6L7FoG1Wd28lBttzBsaxoX4M=; b=NVluvH1+7PGk6VuvF7831ciYhv37IjQnZR7B3V74mXWjnFQlngK74MHt7YyYUglH3x 0rDOCwKCrGG8YyioMw9vttidV74FIcApDFJjlpM+C1vmCYGg0UH6S7jns6LmcuthKkVJ gK1DakXUK8+GRh1s2PEfkIpkohG/JjdSB1uItmQCkPoAoOhzHkJNiwj7i1GTVAUz8P+7 4f9bGm3ozJLuONEOVHJwBS22/9lbtJceKlKkvZciViU885lSWnU+Nby4GSBru4vzf+uM D2QGWsDyAW6YjCyyWpAfN7z57ms9HqkUmmvz+3MqFw3KIjxuzRm64qy4hDZVF2UUWtyh 7Rog== X-Gm-Message-State: AJaThX5AujCoqKBADifaUtiLczdMm/GsdFdicY3fas6B44uS8+jZyiJO 9Tj3mMqZRxs4s6aXnMquw4s+8niV X-Google-Smtp-Source: AGs4zMb1MuQR2jY6b+uEKQcFULCqscG5LvZVt77yXT5sCoDzYleK+3BF0j3feoVnZNqESkKFT2CMbw== X-Received: by 10.55.156.17 with SMTP id f17mr50541921qke.217.1511638795070; Sat, 25 Nov 2017 11:39:55 -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 c188sm997740qkb.46.2017.11.25.11.39.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Nov 2017 11:39:54 -0800 (PST) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2] tests: fix MAKE_RGBA macro for 10bpp modes Date: Sat, 25 Nov 2017 14:39:50 -0500 Message-Id: <20171125193950.1756-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 --- v1 -> v2: fill low bits with high bits Fun - this breaks things for GK208. Not sure why. Works on G92 though. Probably LUT-related. tests/util/pattern.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 41fb541b..5230c5c4 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -64,11 +64,22 @@ 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) +{ + /* Fill the low bits with the high bits. */ + value = (value << 8) | value; + /* Shift down to remove unwanted low bits */ + value = value >> (16 - comp->length); + /* Shift back up to where the value should be */ + return value << 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) }