Mesa (master): lima: implement polygon offset

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jan 12 08:33:26 UTC 2020


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

Author: Vasily Khoruzhick <anarsoul at gmail.com>
Date:   Fri Jan 10 19:48:11 2020 -0800

lima: implement polygon offset

Fixes some of dEQP-GLES2.functional.polygon_offset.* tests and shadows in Q3A.

Reviewed-by: Qiang Yu <yuq825 at gmail.com>
Tested-by: Andreas Baierl <ichgeh at imkreisrum.de>
Signed-off-by: Vasily Khoruzhick <anarsoul at gmail.com>

---

 src/gallium/drivers/lima/lima_draw.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c
index d8ca64c9253..ec98469f39f 100644
--- a/src/gallium/drivers/lima/lima_draw.c
+++ b/src/gallium/drivers/lima/lima_draw.c
@@ -1030,29 +1030,24 @@ lima_stencil_op(enum pipe_stencil_op pipe)
 }
 #endif
 
-static int
+static unsigned
 lima_calculate_depth_test(struct pipe_depth_state *depth, struct pipe_rasterizer_state *rst)
 {
+   int offset_scale = 0, offset_units = 0;
    enum pipe_compare_func func = (depth->enabled ? depth->func : PIPE_FUNC_ALWAYS);
 
-   int offset_scale = 0;
-
-   //TODO: implement polygon offset
-#if 0
-   if (rst->offset_scale < -32)
-      offset_scale = -32;
-   else if (rst->offset_scale > 31)
-      offset_scale = 31;
-   else
-      offset_scale = rst->offset_scale * 4;
-
+   offset_scale = CLAMP(rst->offset_scale * 4, -128, 127);
    if (offset_scale < 0)
-      offset_scale = 0x100 + offset_scale;
-#endif
+      offset_scale += 0x100;
+
+   offset_units = CLAMP(rst->offset_units * 2, -128, 127);
+   if (offset_units < 0)
+      offset_units += 0x100;
 
    return (depth->enabled && depth->writemask) |
       ((int)func << 1) |
       (offset_scale << 16) |
+      (offset_units << 24) |
       0x30; /* find out what is this */
 }
 




More information about the mesa-commit mailing list