Path: blob/21.2-virgl/src/panfrost/lib/pan_format.h
4560 views
/*1* Copyright (C) 2008 VMware, Inc.2* Copyright (C) 2014 Broadcom3* Copyright (C) 2018-2019 Alyssa Rosenzweig4* Copyright (C) 2019-2020 Collabora, Ltd.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation9* the rights to use, copy, modify, merge, publish, distribute, sublicense,10* and/or sell copies of the Software, and to permit persons to whom the11* Software is furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice (including the next14* paragraph) shall be included in all copies or substantial portions of the15* Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL20* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,22* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE23* SOFTWARE.24*25*/2627#ifndef __PAN_FORMAT_H28#define __PAN_FORMAT_H2930#include "util/format/u_format.h"3132/* Formats */3334typedef uint32_t mali_pixel_format;3536struct panfrost_format {37mali_pixel_format hw;38unsigned bind;39};4041struct pan_blendable_format {42/* enum mali_color_buffer_internal_format */ uint16_t internal;43/* enum mali_mfbd_color_format */ uint16_t writeback;44mali_pixel_format bifrost;45};4647extern const struct pan_blendable_format panfrost_blendable_formats_v6[PIPE_FORMAT_COUNT];48extern const struct pan_blendable_format panfrost_blendable_formats_v7[PIPE_FORMAT_COUNT];49extern const struct panfrost_format panfrost_pipe_format_v6[PIPE_FORMAT_COUNT];50extern const struct panfrost_format panfrost_pipe_format_v7[PIPE_FORMAT_COUNT];5152/* Helpers to construct swizzles */53#ifndef PAN_PACK_H54/* Avoid the GenXML dependence */5556enum mali_channel {57MALI_CHANNEL_R = 0,58MALI_CHANNEL_G = 1,59MALI_CHANNEL_B = 2,60MALI_CHANNEL_A = 3,61MALI_CHANNEL_0 = 4,62MALI_CHANNEL_1 = 5,63};64#endif6566#define PAN_V6_SWIZZLE(R, G, B, A) ( \67((MALI_CHANNEL_ ## R) << 0) | \68((MALI_CHANNEL_ ## G) << 3) | \69((MALI_CHANNEL_ ## B) << 6) | \70((MALI_CHANNEL_ ## A) << 9))7172static inline unsigned73panfrost_get_default_swizzle(unsigned components)74{75switch (components) {76case 1:77return PAN_V6_SWIZZLE(R, 0, 0, 1);78case 2:79return PAN_V6_SWIZZLE(R, G, 0, 1);80case 3:81return PAN_V6_SWIZZLE(R, G, B, 1);82case 4:83return PAN_V6_SWIZZLE(R, G, B, A);84default:85unreachable("Invalid number of components");86}87}8889#endif909192