a4xx: add polygon offset clamp, fix units
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 6 Jul 2020 02:06:48 +0000 (22:06 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 6 Jul 2020 18:01:31 +0000 (18:01 +0000)
For some reason, in order to get all tests to pass, pretty much all
hardware (across vendors) has to program in offset_units * 2. This fixes
dEQP-GLES3.functional.polygon_offset.float32_displacement_with_units.

While we're at it, add polygon offset clamp support.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5763>

src/gallium/drivers/freedreno/a4xx/fd4_emit.c
src/gallium/drivers/freedreno/a4xx/fd4_rasterizer.c
src/gallium/drivers/freedreno/a4xx/fd4_rasterizer.h
src/gallium/drivers/freedreno/freedreno_screen.c

index e6848a1aecc1e882378a73cb8d0d85282921ddcd..256167298e6d67588894899230cad9ad36a05054 100644 (file)
@@ -613,9 +613,10 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
                OUT_RING(ring, rasterizer->gras_su_point_minmax);
                OUT_RING(ring, rasterizer->gras_su_point_size);
 
-               OUT_PKT0(ring, REG_A4XX_GRAS_SU_POLY_OFFSET_SCALE, 2);
+               OUT_PKT0(ring, REG_A4XX_GRAS_SU_POLY_OFFSET_SCALE, 3);
                OUT_RING(ring, rasterizer->gras_su_poly_offset_scale);
                OUT_RING(ring, rasterizer->gras_su_poly_offset_offset);
+               OUT_RING(ring, rasterizer->gras_su_poly_offset_clamp);
 
                OUT_PKT0(ring, REG_A4XX_GRAS_CL_CLIP_CNTL, 1);
                OUT_RING(ring, rasterizer->gras_cl_clip_cntl);
index 3477a43653ab0696cd31b4a881ba389ba618c31d..8d674debe9a3520d3b0fd81ea9b97a0793f23a41 100644 (file)
@@ -71,7 +71,9 @@ fd4_rasterizer_state_create(struct pipe_context *pctx,
        so->gras_su_poly_offset_scale =
                        A4XX_GRAS_SU_POLY_OFFSET_SCALE(cso->offset_scale);
        so->gras_su_poly_offset_offset =
-                       A4XX_GRAS_SU_POLY_OFFSET_OFFSET(cso->offset_units);
+                       A4XX_GRAS_SU_POLY_OFFSET_OFFSET(cso->offset_units * 2.0f);
+       so->gras_su_poly_offset_clamp =
+                       A4XX_GRAS_SU_POLY_OFFSET_CLAMP(cso->offset_clamp);
 
        so->gras_su_mode_control =
                        A4XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH(cso->line_width/2.0);
index 40bd2f6824dbba1797d21ee91794c88309d944d5..b9019c3e6672aca3f5c74ddbe02645296ae9cdf3 100644 (file)
@@ -36,6 +36,7 @@ struct fd4_rasterizer_stateobj {
        uint32_t gras_su_point_size;
        uint32_t gras_su_poly_offset_scale;
        uint32_t gras_su_poly_offset_offset;
+       uint32_t gras_su_poly_offset_clamp;
 
        uint32_t gras_su_mode_control;
        uint32_t gras_cl_clip_cntl;
index 0ab93801ba867abc5031cde10f37e4549242913a..bda4dcf788cf2b448dca9745fc5e938450f137db 100644 (file)
@@ -263,7 +263,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                return is_a3xx(screen) || is_a4xx(screen);
 
        case PIPE_CAP_POLYGON_OFFSET_CLAMP:
-               return is_a5xx(screen) || is_a6xx(screen);
+               return is_a4xx(screen) || is_a5xx(screen) || is_a6xx(screen);
 
        case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
                if (is_a3xx(screen)) return 16;