From 5c97d1c83704107e4977fbabbcf63176cd0ec101 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 30 May 2021 22:48:37 +0530 Subject: [PATCH] asahi: Implement wide lines Identify line width field and route through the Gallium line width. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/cmdbuf.xml | 3 ++- src/gallium/drivers/asahi/agx_pipe.c | 2 +- src/gallium/drivers/asahi/agx_state.c | 9 +++++++++ src/gallium/drivers/asahi/agx_state.h | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/asahi/lib/cmdbuf.xml b/src/asahi/lib/cmdbuf.xml index 83e793b092d..74c2795f3ce 100644 --- a/src/asahi/lib/cmdbuf.xml +++ b/src/asahi/lib/cmdbuf.xml @@ -176,7 +176,8 @@ - + + diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index fd61ef31f84..c25e6f7ca99 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -709,7 +709,7 @@ agx_get_paramf(struct pipe_screen* pscreen, switch (param) { case PIPE_CAPF_MAX_LINE_WIDTH: case PIPE_CAPF_MAX_LINE_WIDTH_AA: - return 255.0; /* arbitrary */ + return 16.0; /* Off-by-one fixed point 4:4 encoding */ case PIPE_CAPF_MAX_POINT_WIDTH: case PIPE_CAPF_MAX_POINT_WIDTH_AA: diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index b978803e505..ff93f74d95b 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -154,6 +154,12 @@ agx_create_rs_state(struct pipe_context *ctx, struct agx_rasterizer *so = CALLOC_STRUCT(agx_rasterizer); so->base = *cso; + /* Line width is packed in a 4:4 fixed point format */ + unsigned line_width_fixed = ((unsigned) (cso->line_width * 16.0f)) - 1; + + /* Clamp to maximum line width */ + so->line_width = MIN2(line_width_fixed, 0xFF); + agx_pack(so->cull, CULL, cfg) { cfg.cull_front = cso->cull_face & PIPE_FACE_FRONT; cfg.cull_back = cso->cull_face & PIPE_FACE_BACK; @@ -1091,11 +1097,14 @@ static uint64_t demo_rasterizer(struct agx_context *ctx, struct agx_pool *pool) { struct agx_ptr t = agx_pool_alloc_aligned(pool, AGX_RASTERIZER_LENGTH, 64); + struct agx_rasterizer *rast = ctx->rast; agx_pack(t.cpu, RASTERIZER, cfg) { cfg.front.depth_function = ctx->zs.z_func; cfg.back.depth_function = ctx->zs.z_func; + cfg.front.line_width = cfg.back.line_width = rast->line_width; + cfg.front.disable_depth_write = ctx->zs.disable_z_write; cfg.back.disable_depth_write = ctx->zs.disable_z_write; diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index 420eeec496f..220708dd481 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -159,6 +159,7 @@ agx_context(struct pipe_context *pctx) struct agx_rasterizer { struct pipe_rasterizer_state base; uint8_t cull[AGX_CULL_LENGTH]; + uint8_t line_width; }; struct agx_query {