Mesa (master): lima: fix half float render

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Apr 11 10:14:05 UTC 2021


Module: Mesa
Branch: master
Commit: 8393fad0dec602f58011a0e9c5ab825b355d5a04
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8393fad0dec602f58011a0e9c5ab825b355d5a04

Author: Erico Nunes <nunes.erico at gmail.com>
Date:   Tue Mar 30 01:03:34 2021 +0200

lima: fix half float render

Format 0x26 is invalid, formats are in a 4 bit field so they repeat
in increments of 16.
Frame reg flags needs to set 0x01 to actually enable fp16.
The clear color setup is also a bit different for fp16, need to use
the 16 bit values in the first two clear color registers.

Signed-off-by: Erico Nunes <nunes.erico at gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9916>

---

 src/gallium/drivers/lima/lima_format.c |  4 ++--
 src/gallium/drivers/lima/lima_job.c    | 21 ++++++++++++++++-----
 src/gallium/drivers/lima/lima_screen.c | 11 ++++++++---
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/lima/lima_format.c b/src/gallium/drivers/lima/lima_format.c
index 44de0273dbd..e3b61042402 100644
--- a/src/gallium/drivers/lima/lima_format.c
+++ b/src/gallium/drivers/lima/lima_format.c
@@ -61,9 +61,9 @@
 #define LIMA_PIXEL_FORMAT_B8G8R8A8     0x03
 #define LIMA_PIXEL_FORMAT_B8           0x04
 #define LIMA_PIXEL_FORMAT_G8B8         0x05
+#define LIMA_PIXEL_FORMAT_B16G16R16A16_FLOAT 0x06
 #define LIMA_PIXEL_FORMAT_Z16          0x0e
 #define LIMA_PIXEL_FORMAT_Z24S8        0x0f
-#define LIMA_PIXEL_FORMAT_R16G16B16A16_FLOAT 0x26
 
 struct lima_format {
    bool present;
@@ -138,7 +138,7 @@ static const struct lima_format lima_pixel_formats[] = {
    LIMA_PIXEL_FORMAT(R8G8_UNORM,         G8B8,     true,  0x8888),
    LIMA_PIXEL_FORMAT(Z24_UNORM_S8_UINT,  Z24S8,    false, 0x0000),
    LIMA_PIXEL_FORMAT(Z24X8_UNORM,        Z24S8,    false, 0x0000),
-   LIMA_PIXEL_FORMAT(R16G16B16A16_FLOAT, R16G16B16A16_FLOAT, true, 0x0000),
+   LIMA_PIXEL_FORMAT(R16G16B16A16_FLOAT, B16G16R16A16_FLOAT, true, 0x0000),
 };
 
 static const struct lima_format *
diff --git a/src/gallium/drivers/lima/lima_job.c b/src/gallium/drivers/lima/lima_job.c
index bd56d29a377..cec4084f312 100644
--- a/src/gallium/drivers/lima/lima_job.c
+++ b/src/gallium/drivers/lima/lima_job.c
@@ -835,18 +835,29 @@ lima_pack_pp_frame_reg(struct lima_job *job, uint32_t *frame_reg,
 {
    struct lima_context *ctx = job->ctx;
    struct lima_job_fb_info *fb = &job->fb;
+   struct pipe_surface *cbuf = job->key.cbuf;
    struct lima_pp_frame_reg *frame = (void *)frame_reg;
    struct lima_screen *screen = lima_screen(ctx->base.screen);
    int wb_idx = 0;
 
    frame->render_address = screen->pp_buffer->va + pp_frame_rsw_offset;
    frame->flags = 0x02;
+   if (cbuf && util_format_is_float(cbuf->format)) {
+      frame->flags |= 0x01; /* enable fp16 */
+      frame->clear_value_color   = (uint32_t)(job->clear.color_16pc & 0xffffffffUL);
+      frame->clear_value_color_1 = (uint32_t)(job->clear.color_16pc >> 32);
+      frame->clear_value_color_2 = 0;
+      frame->clear_value_color_3 = 0;
+   }
+   else {
+      frame->clear_value_color   = job->clear.color_8pc;
+      frame->clear_value_color_1 = job->clear.color_8pc;
+      frame->clear_value_color_2 = job->clear.color_8pc;
+      frame->clear_value_color_3 = job->clear.color_8pc;
+   }
+
    frame->clear_value_depth = job->clear.depth;
    frame->clear_value_stencil = job->clear.stencil;
-   frame->clear_value_color = job->clear.color_8pc;
-   frame->clear_value_color_1 = job->clear.color_8pc;
-   frame->clear_value_color_2 = job->clear.color_8pc;
-   frame->clear_value_color_3 = job->clear.color_8pc;
    frame->one = 1;
 
    frame->width = fb->width - 1;
@@ -870,7 +881,7 @@ lima_pack_pp_frame_reg(struct lima_job *job, uint32_t *frame_reg,
    /* Set default layout to 8888 */
    frame->channel_layout = 0x8888;
 
-   if (job->key.cbuf && (job->resolve & PIPE_CLEAR_COLOR0))
+   if (cbuf && (job->resolve & PIPE_CLEAR_COLOR0))
       lima_pack_wb_cbuf_reg(job, frame_reg, wb_reg, wb_idx++);
 
    if (job->key.zsbuf &&
diff --git a/src/gallium/drivers/lima/lima_screen.c b/src/gallium/drivers/lima/lima_screen.c
index 74f7578f4a4..9a9dea043c8 100644
--- a/src/gallium/drivers/lima/lima_screen.c
+++ b/src/gallium/drivers/lima/lima_screen.c
@@ -320,9 +320,14 @@ lima_screen_is_format_supported(struct pipe_screen *pscreen,
    if (sample_count > 1 && sample_count != 4)
       return false;
 
-   if (usage & PIPE_BIND_RENDER_TARGET &&
-       !lima_format_pixel_supported(format))
-      return false;
+   if (usage & PIPE_BIND_RENDER_TARGET) {
+      if (!lima_format_pixel_supported(format))
+         return false;
+
+      /* multisample unsupported with half float target */
+      if (sample_count > 1 && util_format_is_float(format))
+         return false;
+   }
 
    if (usage & PIPE_BIND_DEPTH_STENCIL) {
       switch (format) {



More information about the mesa-commit mailing list