diff options
author | Vasily Khoruzhick <[email protected]> | 2020-02-25 23:26:36 -0800 |
---|---|---|
committer | Vasily Khoruzhick <[email protected]> | 2020-03-02 12:48:44 -0800 |
commit | 646fbb1c4f39f61648c1a1153070df2452153450 (patch) | |
tree | 020fe8a809fb5dd6e8830fdf352b77cf0c0c57b4 /src/gallium | |
parent | ede93a32786ff8548ab4c6f48eb8af7a81872ee5 (diff) |
lima: add RGBA5551 and RGBA4444 formats
We also need to set channel_layout in pp_frame reg (previously known as
foureight) depending on cbuf format.
Reviewed-by: Andreas Baierl <[email protected]>
Signed-off-by: Vasily Khoruzhick <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3972>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3972>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/lima/lima_format.c | 58 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_format.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_gpu.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_job.c | 12 |
4 files changed, 48 insertions, 25 deletions
diff --git a/src/gallium/drivers/lima/lima_format.c b/src/gallium/drivers/lima/lima_format.c index e57139af660..126a9a5c59c 100644 --- a/src/gallium/drivers/lima/lima_format.c +++ b/src/gallium/drivers/lima/lima_format.c @@ -23,6 +23,7 @@ * */ +#include <stdint.h> #include <stdlib.h> #include <util/macros.h> @@ -33,6 +34,8 @@ #define LIMA_TEXEL_FORMAT_A8 0x0a #define LIMA_TEXEL_FORMAT_I8 0x0b #define LIMA_TEXEL_FORMAT_BGR_565 0x0e +#define LIMA_TEXEL_FORMAT_BGRA_5551 0x0f +#define LIMA_TEXEL_FORMAT_BGRA_4444 0x10 #define LIMA_TEXEL_FORMAT_L8A8 0x11 #define LIMA_TEXEL_FORMAT_L16 0x12 #define LIMA_TEXEL_FORMAT_A16 0x13 @@ -45,6 +48,8 @@ #define LIMA_TEXEL_FORMAT_NONE -1 #define LIMA_PIXEL_FORMAT_B5G6R5 0x00 +#define LIMA_PIXEL_FORMAT_B5G5R5A1 0x01 +#define LIMA_PIXEL_FORMAT_B4G4R4A4 0x02 #define LIMA_PIXEL_FORMAT_B8G8R8A8 0x03 #define LIMA_PIXEL_FORMAT_Z16 0x0e #define LIMA_PIXEL_FORMAT_Z24S8 0x0f @@ -55,34 +60,39 @@ struct lima_format { int texel; int pixel; bool swap_r_b; + uint32_t channel_layout; }; -#define LIMA_FORMAT(pipe, tex, pix, swap) \ - [PIPE_FORMAT_##pipe] = { \ - .present = true, .texel = LIMA_TEXEL_FORMAT_##tex, \ +#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, \ } static const struct lima_format lima_format_table[] = { - LIMA_FORMAT(R8G8B8A8_UNORM, RGBA_8888, B8G8R8A8, true), - LIMA_FORMAT(B8G8R8A8_UNORM, RGBA_8888, B8G8R8A8, false), - LIMA_FORMAT(R8G8B8A8_SRGB, RGBA_8888, B8G8R8A8, true), - LIMA_FORMAT(B8G8R8A8_SRGB, RGBA_8888, B8G8R8A8, false), - LIMA_FORMAT(R8G8B8X8_UNORM, RGBX_8888, B8G8R8A8, true), - LIMA_FORMAT(B8G8R8X8_UNORM, RGBX_8888, B8G8R8A8, false), - LIMA_FORMAT(B5G6R5_UNORM, BGR_565, B5G6R5, false), - LIMA_FORMAT(Z24_UNORM_S8_UINT, Z24S8, Z24S8, false), - LIMA_FORMAT(Z24X8_UNORM, Z24S8, Z24S8, false), + 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, Z24S8, Z24S8, false, 0x0000), + LIMA_FORMAT(Z24X8_UNORM, Z24S8, Z24S8, false, 0x0000), /* Blob uses L16 for Z16 */ - LIMA_FORMAT(Z16_UNORM, L16, Z16, false), - LIMA_FORMAT(L16_UNORM, L16, NONE, false), - LIMA_FORMAT(L8_UNORM, L8, NONE, false), - LIMA_FORMAT(A16_UNORM, A16, NONE, false), - LIMA_FORMAT(A8_UNORM, A8, NONE, false), - LIMA_FORMAT(I16_UNORM, I16, NONE, false), - LIMA_FORMAT(I8_UNORM, I8, NONE, false), - LIMA_FORMAT(L8A8_UNORM, L8A8, NONE, false), - LIMA_FORMAT(ETC1_RGB8, ETC1_RGB8, NONE, false), + LIMA_FORMAT(Z16_UNORM, L16, Z16, 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), }; static const struct lima_format * @@ -134,3 +144,9 @@ lima_format_get_swap_rb(enum pipe_format f) { return lima_format_table[f].swap_r_b; } + +uint32_t +lima_format_get_channel_layout(enum pipe_format f) +{ + return lima_format_table[f].channel_layout; +} diff --git a/src/gallium/drivers/lima/lima_format.h b/src/gallium/drivers/lima/lima_format.h index 3caa0994573..e3d7e9f9441 100644 --- a/src/gallium/drivers/lima/lima_format.h +++ b/src/gallium/drivers/lima/lima_format.h @@ -33,5 +33,6 @@ bool lima_format_pixel_supported(enum pipe_format f); int lima_format_get_texel(enum pipe_format f); int lima_format_get_pixel(enum pipe_format f); bool lima_format_get_swap_rb(enum pipe_format f); +uint32_t lima_format_get_channel_layout(enum pipe_format f); #endif diff --git a/src/gallium/drivers/lima/lima_gpu.h b/src/gallium/drivers/lima/lima_gpu.h index acf365cbcc2..4d35640592f 100644 --- a/src/gallium/drivers/lima/lima_gpu.h +++ b/src/gallium/drivers/lima/lima_gpu.h @@ -63,7 +63,7 @@ struct lima_pp_frame_reg { uint32_t onscreen; uint32_t blocking; uint32_t scale; - uint32_t foureight; + uint32_t channel_layout; }; struct lima_pp_wb_reg { diff --git a/src/gallium/drivers/lima/lima_job.c b/src/gallium/drivers/lima/lima_job.c index 7cdf585c77f..3a00d689242 100644 --- a/src/gallium/drivers/lima/lima_job.c +++ b/src/gallium/drivers/lima/lima_job.c @@ -763,7 +763,8 @@ lima_pack_wb_zsbuf_reg(struct lima_job *job, uint32_t *wb_reg, int wb_idx) } static void -lima_pack_wb_cbuf_reg(struct lima_job *job, uint32_t *wb_reg, int wb_idx) +lima_pack_wb_cbuf_reg(struct lima_job *job, uint32_t *frame_reg, + uint32_t *wb_reg, int wb_idx) { struct lima_job_fb_info *fb = &job->fb; struct pipe_surface *cbuf = job->key.cbuf; @@ -773,6 +774,9 @@ lima_pack_wb_cbuf_reg(struct lima_job *job, uint32_t *wb_reg, int wb_idx) uint32_t format = lima_format_get_pixel(cbuf->format); bool swap_channels = lima_format_get_swap_rb(cbuf->format); + struct lima_pp_frame_reg *frame = (void *)frame_reg; + frame->channel_layout = lima_format_get_channel_layout(cbuf->format); + struct lima_pp_wb_reg *wb = (void *)wb_reg; wb[wb_idx].type = 0x02; /* 2 for color buffer */ wb[wb_idx].address = res->bo->va + res->levels[level].offset + layer * res->levels[level].layer_stride; @@ -824,10 +828,12 @@ lima_pack_pp_frame_reg(struct lima_job *job, uint32_t *frame_reg, frame->dubya = 0x77; frame->onscreen = 1; frame->blocking = (fb->shift_min << 28) | (fb->shift_h << 16) | fb->shift_w; - frame->foureight = 0x8888; + + /* Set default layout to 8888 */ + frame->channel_layout = 0x8888; if (job->key.cbuf && (job->resolve & PIPE_CLEAR_COLOR0)) - lima_pack_wb_cbuf_reg(job, wb_reg, wb_idx++); + lima_pack_wb_cbuf_reg(job, frame_reg, wb_reg, wb_idx++); if (job->key.zsbuf && (job->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) |