diff options
author | Qiang Yu <[email protected]> | 2019-08-17 16:40:49 +0800 |
---|---|---|
committer | Qiang Yu <[email protected]> | 2019-08-25 11:52:29 +0800 |
commit | 5ff41b9fc5ed2298b70772666573ad47418d12fd (patch) | |
tree | 79eabc150a4d5e00d2d24cd50479d28592f9c892 /src/gallium/drivers/lima/lima_texture.c | |
parent | fe0ec41c4d36fd5a82e7579d89e34cce7423c4e5 (diff) |
lima: move format handling to unified place
Create a unified table to handle pipe format to texture
and render target format lookup.
Reviewed-by: Vasily Khoruzhick <[email protected]>
Reviewed-by: Erico Nunes <[email protected]>
Signed-off-by: Qiang Yu <[email protected]>
Diffstat (limited to 'src/gallium/drivers/lima/lima_texture.c')
-rw-r--r-- | src/gallium/drivers/lima/lima_texture.c | 60 |
1 files changed, 3 insertions, 57 deletions
diff --git a/src/gallium/drivers/lima/lima_texture.c b/src/gallium/drivers/lima/lima_texture.c index 9fb6313cf53..379bf387330 100644 --- a/src/gallium/drivers/lima/lima_texture.c +++ b/src/gallium/drivers/lima/lima_texture.c @@ -36,66 +36,15 @@ #include "lima_resource.h" #include "lima_submit.h" #include "lima_util.h" +#include "lima_format.h" #include <drm-uapi/lima_drm.h> -#define LIMA_TEXEL_FORMAT_L8 0x09 -#define LIMA_TEXEL_FORMAT_A8 0x0a -#define LIMA_TEXEL_FORMAT_I8 0x0b -#define LIMA_TEXEL_FORMAT_BGR_565 0x0e -#define LIMA_TEXEL_FORMAT_L8A8 0x11 -#define LIMA_TEXEL_FORMAT_L16 0x12 -#define LIMA_TEXEL_FORMAT_A16 0x13 -#define LIMA_TEXEL_FORMAT_I16 0x14 -#define LIMA_TEXEL_FORMAT_RGB_888 0x15 -#define LIMA_TEXEL_FORMAT_RGBA_8888 0x16 -#define LIMA_TEXEL_FORMAT_RGBX_8888 0x17 -#define LIMA_TEXEL_FORMAT_Z24S8 0x2c #define lima_tex_list_size 64 -typedef struct { - bool present; - uint32_t lima_format; - bool swap_r_b; -} lima_format; - -#define LIMA_FORMAT(pipe, lima, swap) \ - [PIPE_FORMAT_##pipe] = { .present = true, .lima_format = lima, \ - .swap_r_b = swap } - -static const lima_format lima_format_table[] = { - LIMA_FORMAT(R8G8B8A8_UNORM, LIMA_TEXEL_FORMAT_RGBA_8888, true), - LIMA_FORMAT(B8G8R8A8_UNORM, LIMA_TEXEL_FORMAT_RGBA_8888, false), - LIMA_FORMAT(R8G8B8A8_SRGB, LIMA_TEXEL_FORMAT_RGBA_8888, true), - LIMA_FORMAT(B8G8R8A8_SRGB, LIMA_TEXEL_FORMAT_RGBA_8888, false), - LIMA_FORMAT(R8G8B8X8_UNORM, LIMA_TEXEL_FORMAT_RGBX_8888, true), - LIMA_FORMAT(B8G8R8X8_UNORM, LIMA_TEXEL_FORMAT_RGBX_8888, false), - LIMA_FORMAT(R8G8B8_UNORM, LIMA_TEXEL_FORMAT_RGB_888, true), - LIMA_FORMAT(B5G6R5_UNORM, LIMA_TEXEL_FORMAT_BGR_565, false), - LIMA_FORMAT(Z24_UNORM_S8_UINT, LIMA_TEXEL_FORMAT_Z24S8, false), - LIMA_FORMAT(Z24X8_UNORM, LIMA_TEXEL_FORMAT_Z24S8, false), - /* Blob uses L16 for Z16 */ - LIMA_FORMAT(Z16_UNORM, LIMA_TEXEL_FORMAT_L16, false), - LIMA_FORMAT(L16_UNORM, LIMA_TEXEL_FORMAT_L16, false), - LIMA_FORMAT(L8_UNORM, LIMA_TEXEL_FORMAT_L8, false), - LIMA_FORMAT(A16_UNORM, LIMA_TEXEL_FORMAT_A16, false), - LIMA_FORMAT(A8_UNORM, LIMA_TEXEL_FORMAT_A8, false), - LIMA_FORMAT(I16_UNORM, LIMA_TEXEL_FORMAT_I16, false), - LIMA_FORMAT(I8_UNORM, LIMA_TEXEL_FORMAT_I8, false), - LIMA_FORMAT(L8A8_UNORM, LIMA_TEXEL_FORMAT_L8A8, false), -}; - static_assert(offsetof(lima_tex_desc, va) == 24, "lima_tex_desc->va offset isn't 24"); -bool -lima_texel_format_supported(enum pipe_format pformat) -{ - if (pformat >= ARRAY_SIZE(lima_format_table)) - return false; - - return lima_format_table[pformat].present; -} static void lima_texture_desc_set_va(lima_tex_desc *desc, @@ -129,11 +78,8 @@ lima_texture_desc_set_res(struct lima_context *ctx, lima_tex_desc *desc, height = u_minify(height, first_level); } - assert(prsc->format < ARRAY_SIZE(lima_format_table)); - assert(lima_format_table[prsc->format].present); - - desc->format = lima_format_table[prsc->format].lima_format; - desc->swap_r_b = lima_format_table[prsc->format].swap_r_b; + desc->format = lima_format_get_texel(prsc->format); + desc->swap_r_b = lima_format_get_swap_rb(prsc->format); desc->width = width; desc->height = height; desc->unknown_3_1 = 1; |