From 0d419c76bb07cf526fa636c012285589ed8962d7 Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Sun, 21 Jun 2020 14:22:45 -0400 Subject: [PATCH] freedreno/a3xx: support LINEAR_PIXEL/PERSP_CENTROID/LINEAR_CENTROID sysvals Signed-off-by: Jonathan Marek Part-of: --- src/gallium/drivers/freedreno/a3xx/fd3_emit.c | 11 +++++++++++ src/gallium/drivers/freedreno/a3xx/fd3_program.c | 13 ++++++++++--- src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index 0758b40bf8c..90edacb6f9a 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -605,6 +605,17 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring, uint32_t val = fd3_rasterizer_stateobj(ctx->rasterizer) ->gras_cl_clip_cntl; uint8_t planes = ctx->rasterizer->clip_plane_enable; + val |= CONDREG(ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL), + A3XX_GRAS_CL_CLIP_CNTL_IJ_PERSP_CENTER); + val |= CONDREG(ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL), + A3XX_GRAS_CL_CLIP_CNTL_IJ_NON_PERSP_CENTER); + val |= CONDREG(ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID), + A3XX_GRAS_CL_CLIP_CNTL_IJ_PERSP_CENTROID); + val |= CONDREG(ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID), + A3XX_GRAS_CL_CLIP_CNTL_IJ_NON_PERSP_CENTROID); + /* docs say enable at least one of IJ_PERSP_CENTER/CENTROID when fragcoord is used */ + val |= CONDREG(ir3_find_sysval_regid(fp, SYSTEM_VALUE_FRAG_COORD), + A3XX_GRAS_CL_CLIP_CNTL_IJ_PERSP_CENTER); val |= COND(fp->writes_pos, A3XX_GRAS_CL_CLIP_CNTL_ZCLIP_DISABLE); val |= COND(fp->fragcoord_compmask != 0, A3XX_GRAS_CL_CLIP_CNTL_ZCOORD | A3XX_GRAS_CL_CLIP_CNTL_WCOORD); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c index 8ab7cd2cbb6..891a52aa6de 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c @@ -102,7 +102,7 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit, enum a3xx_instrbuffermode fpbuffer, vpbuffer; uint32_t fpbuffersz, vpbuffersz, fsoff; uint32_t pos_regid, posz_regid, psize_regid; - uint32_t vcoord_regid, face_regid, coord_regid, zwcoord_regid; + uint32_t ij_regid[4], face_regid, coord_regid, zwcoord_regid; uint32_t color_regid[4] = {0}; int constmode; int i, j; @@ -174,7 +174,10 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit, face_regid = ir3_find_sysval_regid(fp, SYSTEM_VALUE_FRONT_FACE); coord_regid = ir3_find_sysval_regid(fp, SYSTEM_VALUE_FRAG_COORD); zwcoord_regid = (coord_regid == regid(63,0)) ? regid(63,0) : (coord_regid + 2); - vcoord_regid = ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL); + ij_regid[0] = ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL); + ij_regid[1] = ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL); + ij_regid[2] = ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID); + ij_regid[3] = ir3_find_sysval_regid(fp, SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID); /* adjust regids for alpha output formats. there is no alpha render * format, so it's just treated like red @@ -203,7 +206,11 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit, A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDZWREGID(zwcoord_regid)); OUT_RING(ring, A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD(31) | A3XX_HLSQ_CONTROL_2_REG_FACENESSREGID(face_regid)); - OUT_RING(ring, A3XX_HLSQ_CONTROL_3_REG_IJPERSPCENTERREGID(vcoord_regid)); + OUT_RING(ring, + A3XX_HLSQ_CONTROL_3_REG_IJPERSPCENTERREGID(ij_regid[0]) | + A3XX_HLSQ_CONTROL_3_REG_IJNONPERSPCENTERREGID(ij_regid[1]) | + A3XX_HLSQ_CONTROL_3_REG_IJPERSPCENTROIDREGID(ij_regid[2]) | + A3XX_HLSQ_CONTROL_3_REG_IJNONPERSPCENTROIDREGID(ij_regid[3])); OUT_RING(ring, A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH(vp->constlen) | A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET(0) | A3XX_HLSQ_VS_CONTROL_REG_INSTRLENGTH(vpbuffersz)); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c b/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c index 31cc6d422a0..324998acc5e 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c @@ -63,7 +63,7 @@ fd3_rasterizer_state_create(struct pipe_context *pctx, if (cso->multisample) TODO */ - so->gras_cl_clip_cntl = A3XX_GRAS_CL_CLIP_CNTL_IJ_PERSP_CENTER /* ??? */ | + so->gras_cl_clip_cntl = COND(cso->clip_halfz, A3XX_GRAS_CL_CLIP_CNTL_ZERO_GB_SCALE_Z); so->gras_su_point_minmax = A3XX_GRAS_SU_POINT_MINMAX_MIN(psize_min) | -- 2.30.2