#define LIMA_TEXEL_FORMAT_Z24X8 0x2c
/* This format is only used for depth/stencil reload */
#define LIMA_TEXEL_FORMAT_Z24S8_RLD 0x32
-#define LIMA_TEXEL_FORMAT_NONE -1
#define LIMA_PIXEL_FORMAT_B5G6R5 0x00
#define LIMA_PIXEL_FORMAT_B5G5R5A1 0x01
#define LIMA_PIXEL_FORMAT_B8G8R8A8 0x03
#define LIMA_PIXEL_FORMAT_Z16 0x0e
#define LIMA_PIXEL_FORMAT_Z24S8 0x0f
-#define LIMA_PIXEL_FORMAT_NONE -1
struct lima_format {
bool present;
- int texel;
- int pixel;
+ int format;
bool swap_r_b;
uint32_t channel_layout;
};
-#define LIMA_FORMAT(pipe, tex, pix, swap, ch_layout) \
- [PIPE_FORMAT_##pipe] = { \
- .present = true, .texel = LIMA_TEXEL_FORMAT_##tex, \
- .pixel = LIMA_PIXEL_FORMAT_##pix, .swap_r_b = swap, \
- .channel_layout = ch_layout, \
+#define LIMA_TEXEL_FORMAT(pipe, tex, swap) \
+ [PIPE_FORMAT_##pipe] = { \
+ .present = true, .format = LIMA_TEXEL_FORMAT_##tex, \
+ .swap_r_b = swap \
}
-static const struct lima_format lima_format_table[] = {
- LIMA_FORMAT(R8G8B8A8_UNORM, RGBA_8888, B8G8R8A8, true, 0x8888),
- LIMA_FORMAT(B8G8R8A8_UNORM, RGBA_8888, B8G8R8A8, false, 0x8888),
- LIMA_FORMAT(R8G8B8A8_SRGB, RGBA_8888, B8G8R8A8, true, 0x8888),
- LIMA_FORMAT(B8G8R8A8_SRGB, RGBA_8888, B8G8R8A8, false, 0x8888),
- LIMA_FORMAT(R8G8B8X8_UNORM, RGBX_8888, B8G8R8A8, true, 0x8888),
- LIMA_FORMAT(B8G8R8X8_UNORM, RGBX_8888, B8G8R8A8, false, 0x8888),
- LIMA_FORMAT(B5G6R5_UNORM, BGR_565, B5G6R5, false, 0x8565),
- /* BGRA_5551 seems to need channel layout 0x8565, it's not a typo */
- LIMA_FORMAT(B5G5R5A1_UNORM, BGRA_5551, B5G5R5A1, false, 0x8565),
- LIMA_FORMAT(B4G4R4A4_UNORM, BGRA_4444, B4G4R4A4, false, 0x8444),
- LIMA_FORMAT(Z24_UNORM_S8_UINT, Z24X8, Z24S8, false, 0x0000),
- LIMA_FORMAT(Z24X8_UNORM, Z24X8, Z24S8, false, 0x0000),
- LIMA_FORMAT(L16_UNORM, L16, NONE, false, 0x0000),
- LIMA_FORMAT(L8_UNORM, L8, NONE, false, 0x0000),
- LIMA_FORMAT(A16_UNORM, A16, NONE, false, 0x0000),
- LIMA_FORMAT(A8_UNORM, A8, NONE, false, 0x0000),
- LIMA_FORMAT(I16_UNORM, I16, NONE, false, 0x0000),
- LIMA_FORMAT(I8_UNORM, I8, NONE, false, 0x0000),
- LIMA_FORMAT(L8A8_UNORM, L8A8, NONE, false, 0x0000),
- LIMA_FORMAT(ETC1_RGB8, ETC1_RGB8, NONE, false, 0x8888),
+#define LIMA_PIXEL_FORMAT(pipe, pix, swap, ch_layout) \
+ [PIPE_FORMAT_##pipe] = { \
+ .present = true, .format = LIMA_PIXEL_FORMAT_##pix, \
+ .swap_r_b = swap, .channel_layout = ch_layout \
+ }
+
+static const struct lima_format lima_texel_formats[] = {
+ LIMA_TEXEL_FORMAT(R8G8B8A8_UNORM, RGBA_8888, true),
+ LIMA_TEXEL_FORMAT(B8G8R8A8_UNORM, RGBA_8888, false),
+ LIMA_TEXEL_FORMAT(R8G8B8A8_SRGB, RGBA_8888, true),
+ LIMA_TEXEL_FORMAT(B8G8R8A8_SRGB, RGBA_8888, false),
+ LIMA_TEXEL_FORMAT(R8G8B8X8_UNORM, RGBX_8888, true),
+ LIMA_TEXEL_FORMAT(B8G8R8X8_UNORM, RGBX_8888, false),
+ LIMA_TEXEL_FORMAT(B5G6R5_UNORM, BGR_565, false),
+ LIMA_TEXEL_FORMAT(B5G5R5A1_UNORM, BGRA_5551, false),
+ LIMA_TEXEL_FORMAT(B4G4R4A4_UNORM, BGRA_4444, false),
+ LIMA_TEXEL_FORMAT(Z24_UNORM_S8_UINT, Z24X8, false),
+ LIMA_TEXEL_FORMAT(Z24X8_UNORM, Z24X8, false),
+ LIMA_TEXEL_FORMAT(L16_UNORM, L16, false),
+ LIMA_TEXEL_FORMAT(L8_UNORM, L8, false),
+ LIMA_TEXEL_FORMAT(A16_UNORM, A16, false),
+ LIMA_TEXEL_FORMAT(A8_UNORM, A8, false),
+ LIMA_TEXEL_FORMAT(I16_UNORM, I16, false),
+ LIMA_TEXEL_FORMAT(I8_UNORM, I8, false),
+ LIMA_TEXEL_FORMAT(L8A8_UNORM, L8A8, false),
+ LIMA_TEXEL_FORMAT(ETC1_RGB8, ETC1_RGB8, false),
+};
+
+static const struct lima_format lima_pixel_formats[] = {
+ LIMA_PIXEL_FORMAT(R8G8B8A8_UNORM, B8G8R8A8, true, 0x8888),
+ LIMA_PIXEL_FORMAT(B8G8R8A8_UNORM, B8G8R8A8, false, 0x8888),
+ LIMA_PIXEL_FORMAT(R8G8B8A8_SRGB, B8G8R8A8, true, 0x8888),
+ LIMA_PIXEL_FORMAT(B8G8R8A8_SRGB, B8G8R8A8, false, 0x8888),
+ LIMA_PIXEL_FORMAT(R8G8B8X8_UNORM, B8G8R8A8, true, 0x8888),
+ LIMA_PIXEL_FORMAT(B8G8R8X8_UNORM, B8G8R8A8, false, 0x8888),
+ LIMA_PIXEL_FORMAT(B5G6R5_UNORM, B5G6R5, false, 0x8565),
+ LIMA_PIXEL_FORMAT(B5G5R5A1_UNORM, B5G5R5A1, false, 0x8565),
+ LIMA_PIXEL_FORMAT(B4G4R4A4_UNORM, B4G4R4A4, false, 0x8444),
+ LIMA_PIXEL_FORMAT(Z24_UNORM_S8_UINT, Z24S8, false, 0x0000),
+ LIMA_PIXEL_FORMAT(Z24X8_UNORM, Z24S8, false, 0x0000),
};
static const struct lima_format *
-get_format(enum pipe_format f)
+get_texel_format(enum pipe_format f)
+{
+ if (f >= ARRAY_SIZE(lima_texel_formats) ||
+ !lima_texel_formats[f].present)
+ return NULL;
+
+ return lima_texel_formats + f;
+}
+
+static const struct lima_format *
+get_pixel_format(enum pipe_format f)
{
- if (f >= ARRAY_SIZE(lima_format_table) ||
- !lima_format_table[f].present)
+ if (f >= ARRAY_SIZE(lima_pixel_formats) ||
+ !lima_pixel_formats[f].present)
return NULL;
- return lima_format_table + f;
+ return lima_pixel_formats + f;
}
bool
lima_format_texel_supported(enum pipe_format f)
{
- const struct lima_format *lf = get_format(f);
+ const struct lima_format *lf = get_texel_format(f);
if (!lf)
return false;
- return lf->texel != LIMA_TEXEL_FORMAT_NONE;
+ return true;
}
bool
lima_format_pixel_supported(enum pipe_format f)
{
- const struct lima_format *lf = get_format(f);
+ const struct lima_format *lf = get_pixel_format(f);
if (!lf)
return false;
- return lf->pixel != LIMA_PIXEL_FORMAT_NONE;
+ return true;
}
int
lima_format_get_texel(enum pipe_format f)
{
- return lima_format_table[f].texel;
+ return lima_texel_formats[f].format;
}
int
int
lima_format_get_pixel(enum pipe_format f)
{
- return lima_format_table[f].pixel;
+ return lima_pixel_formats[f].format;
+}
+
+bool
+lima_format_get_texel_swap_rb(enum pipe_format f)
+{
+ return lima_texel_formats[f].swap_r_b;
}
bool
-lima_format_get_swap_rb(enum pipe_format f)
+lima_format_get_pixel_swap_rb(enum pipe_format f)
{
- return lima_format_table[f].swap_r_b;
+ return lima_pixel_formats[f].swap_r_b;
}
uint32_t
lima_format_get_channel_layout(enum pipe_format f)
{
- return lima_format_table[f].channel_layout;
+ return lima_pixel_formats[f].channel_layout;
}