Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a2xx/fd2_util.h
4574 views
/*1* Copyright (C) 2012-2013 Rob Clark <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#ifndef FD2_UTIL_H_27#define FD2_UTIL_H_2829#include "freedreno_util.h"3031#include "a2xx.xml.h"3233struct surface_format {34/* If enum is a signed type, 0x7f is out of range. Cast it to avoid warnings. */35#define FMT_INVALID ((enum a2xx_sq_surfaceformat)0x7f)36enum a2xx_sq_surfaceformat format : 7;37enum sq_tex_sign sign : 2;38enum sq_tex_num_format num_format : 1;39int exp_adjust : 6;40};4142struct surface_format fd2_pipe2surface(enum pipe_format format);43enum a2xx_colorformatx fd2_pipe2color(enum pipe_format format);44uint32_t fd2_tex_swiz(enum pipe_format format, unsigned swizzle_r,45unsigned swizzle_g, unsigned swizzle_b,46unsigned swizzle_a);47uint32_t fd2_vtx_swiz(enum pipe_format format, unsigned swizzle);4849/* convert x,y to dword */50static inline uint32_t51xy2d(uint16_t x, uint16_t y)52{53return ((y & 0x3fff) << 16) | (x & 0x3fff);54}5556#endif /* FD2_UTIL_H_ */575859