1bf215546Sopenharmony_ci#ifndef R600_FORMATS_H 2bf215546Sopenharmony_ci#define R600_FORMATS_H 3bf215546Sopenharmony_ci 4bf215546Sopenharmony_ci#include "util/format/u_format.h" 5bf215546Sopenharmony_ci#include "r600_pipe.h" 6bf215546Sopenharmony_ci 7bf215546Sopenharmony_ci/* list of formats from R700 ISA document - apply across GPUs in different registers */ 8bf215546Sopenharmony_ci#define FMT_INVALID 0x00000000 9bf215546Sopenharmony_ci#define FMT_8 0x00000001 10bf215546Sopenharmony_ci#define FMT_4_4 0x00000002 11bf215546Sopenharmony_ci#define FMT_3_3_2 0x00000003 12bf215546Sopenharmony_ci#define FMT_16 0x00000005 13bf215546Sopenharmony_ci#define FMT_16_FLOAT 0x00000006 14bf215546Sopenharmony_ci#define FMT_8_8 0x00000007 15bf215546Sopenharmony_ci#define FMT_5_6_5 0x00000008 16bf215546Sopenharmony_ci#define FMT_6_5_5 0x00000009 17bf215546Sopenharmony_ci#define FMT_1_5_5_5 0x0000000A 18bf215546Sopenharmony_ci#define FMT_4_4_4_4 0x0000000B 19bf215546Sopenharmony_ci#define FMT_5_5_5_1 0x0000000C 20bf215546Sopenharmony_ci#define FMT_32 0x0000000D 21bf215546Sopenharmony_ci#define FMT_32_FLOAT 0x0000000E 22bf215546Sopenharmony_ci#define FMT_16_16 0x0000000F 23bf215546Sopenharmony_ci#define FMT_16_16_FLOAT 0x00000010 24bf215546Sopenharmony_ci#define FMT_8_24 0x00000011 25bf215546Sopenharmony_ci#define FMT_8_24_FLOAT 0x00000012 26bf215546Sopenharmony_ci#define FMT_24_8 0x00000013 27bf215546Sopenharmony_ci#define FMT_24_8_FLOAT 0x00000014 28bf215546Sopenharmony_ci#define FMT_10_11_11 0x00000015 29bf215546Sopenharmony_ci#define FMT_10_11_11_FLOAT 0x00000016 30bf215546Sopenharmony_ci#define FMT_11_11_10 0x00000017 31bf215546Sopenharmony_ci#define FMT_11_11_10_FLOAT 0x00000018 32bf215546Sopenharmony_ci#define FMT_2_10_10_10 0x00000019 33bf215546Sopenharmony_ci#define FMT_8_8_8_8 0x0000001A 34bf215546Sopenharmony_ci#define FMT_10_10_10_2 0x0000001B 35bf215546Sopenharmony_ci#define FMT_X24_8_32_FLOAT 0x0000001C 36bf215546Sopenharmony_ci#define FMT_32_32 0x0000001D 37bf215546Sopenharmony_ci#define FMT_32_32_FLOAT 0x0000001E 38bf215546Sopenharmony_ci#define FMT_16_16_16_16 0x0000001F 39bf215546Sopenharmony_ci#define FMT_16_16_16_16_FLOAT 0x00000020 40bf215546Sopenharmony_ci#define FMT_32_32_32_32 0x00000022 41bf215546Sopenharmony_ci#define FMT_32_32_32_32_FLOAT 0x00000023 42bf215546Sopenharmony_ci#define FMT_1 0x00000025 43bf215546Sopenharmony_ci#define FMT_GB_GR 0x00000027 44bf215546Sopenharmony_ci#define FMT_BG_RG 0x00000028 45bf215546Sopenharmony_ci#define FMT_32_AS_8 0x00000029 46bf215546Sopenharmony_ci#define FMT_32_AS_8_8 0x0000002a 47bf215546Sopenharmony_ci#define FMT_5_9_9_9_SHAREDEXP 0x0000002b 48bf215546Sopenharmony_ci#define FMT_8_8_8 0x0000002c 49bf215546Sopenharmony_ci#define FMT_16_16_16 0x0000002d 50bf215546Sopenharmony_ci#define FMT_16_16_16_FLOAT 0x0000002e 51bf215546Sopenharmony_ci#define FMT_32_32_32 0x0000002f 52bf215546Sopenharmony_ci#define FMT_32_32_32_FLOAT 0x00000030 53bf215546Sopenharmony_ci#define FMT_BC1 0x00000031 54bf215546Sopenharmony_ci#define FMT_BC2 0x00000032 55bf215546Sopenharmony_ci#define FMT_BC3 0x00000033 56bf215546Sopenharmony_ci#define FMT_BC4 0x00000034 57bf215546Sopenharmony_ci#define FMT_BC5 0x00000035 58bf215546Sopenharmony_ci#define FMT_BC6 0x00000036 59bf215546Sopenharmony_ci#define FMT_BC7 0x00000037 60bf215546Sopenharmony_ci#define FMT_32_AS_32_32_32_32 0x00000038 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci#define ENDIAN_NONE 0 63bf215546Sopenharmony_ci#define ENDIAN_8IN16 1 64bf215546Sopenharmony_ci#define ENDIAN_8IN32 2 65bf215546Sopenharmony_ci#define ENDIAN_8IN64 3 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_cistatic inline unsigned r600_endian_swap(unsigned size) 68bf215546Sopenharmony_ci{ 69bf215546Sopenharmony_ci if (R600_BIG_ENDIAN) { 70bf215546Sopenharmony_ci switch (size) { 71bf215546Sopenharmony_ci case 64: 72bf215546Sopenharmony_ci return ENDIAN_8IN64; 73bf215546Sopenharmony_ci case 32: 74bf215546Sopenharmony_ci return ENDIAN_8IN32; 75bf215546Sopenharmony_ci case 16: 76bf215546Sopenharmony_ci return ENDIAN_8IN16; 77bf215546Sopenharmony_ci default: 78bf215546Sopenharmony_ci return ENDIAN_NONE; 79bf215546Sopenharmony_ci } 80bf215546Sopenharmony_ci } else { 81bf215546Sopenharmony_ci return ENDIAN_NONE; 82bf215546Sopenharmony_ci } 83bf215546Sopenharmony_ci} 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_cistatic inline bool r600_is_buffer_format_supported(enum pipe_format format, bool for_vbo) 86bf215546Sopenharmony_ci{ 87bf215546Sopenharmony_ci const struct util_format_description *desc = util_format_description(format); 88bf215546Sopenharmony_ci unsigned i; 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci if (format == PIPE_FORMAT_R11G11B10_FLOAT) 91bf215546Sopenharmony_ci return true; 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ci /* Find the first non-VOID channel. */ 94bf215546Sopenharmony_ci for (i = 0; i < 4; i++) { 95bf215546Sopenharmony_ci if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) 96bf215546Sopenharmony_ci break; 97bf215546Sopenharmony_ci } 98bf215546Sopenharmony_ci if (i == 4) 99bf215546Sopenharmony_ci return false; 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_ci /* No fixed, no double. */ 102bf215546Sopenharmony_ci if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN || 103bf215546Sopenharmony_ci (desc->channel[i].size == 64 && 104bf215546Sopenharmony_ci desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT) || 105bf215546Sopenharmony_ci desc->channel[i].type == UTIL_FORMAT_TYPE_FIXED) 106bf215546Sopenharmony_ci return false; 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ci /* No scaled/norm formats with 32 bits per channel. */ 109bf215546Sopenharmony_ci if (desc->channel[i].size == 32 && 110bf215546Sopenharmony_ci !desc->channel[i].pure_integer && 111bf215546Sopenharmony_ci (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED || 112bf215546Sopenharmony_ci desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)) 113bf215546Sopenharmony_ci return false; 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci /* No 8 bit 3 channel formats for TBOs */ 116bf215546Sopenharmony_ci if (desc->channel[i].size == 8 && desc->nr_channels == 3) 117bf215546Sopenharmony_ci return for_vbo; 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ci return true; 120bf215546Sopenharmony_ci} 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_cistatic inline bool r600_is_index_format_supported(enum pipe_format format) 123bf215546Sopenharmony_ci{ 124bf215546Sopenharmony_ci switch (format) { 125bf215546Sopenharmony_ci case PIPE_FORMAT_R8_UINT: 126bf215546Sopenharmony_ci case PIPE_FORMAT_R16_UINT: 127bf215546Sopenharmony_ci case PIPE_FORMAT_R32_UINT: 128bf215546Sopenharmony_ci return true; 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_ci default: 131bf215546Sopenharmony_ci return false; 132bf215546Sopenharmony_ci } 133bf215546Sopenharmony_ci} 134bf215546Sopenharmony_ci 135bf215546Sopenharmony_ci#endif 136