summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2018-06-13 13:44:01 -0700
committerEric Anholt <eric@anholt.net>2018-06-14 17:03:16 -0700
commitcd2e673abc436d71e304fd5ad577054197041c7f (patch)
treebde441620854c98c91cff193dfaa23d7c49fc7a0 /src/gallium/drivers
parentd91e06a06572a4c4772b02dfc39dcbd283b490f9 (diff)
v3d: Fix polygon offset for Z16 buffers.
Fixes: dEQP-GLES3.functional.polygon_offset.fixed16_displacement_with_units dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/v3d/v3d_context.h5
-rw-r--r--src/gallium/drivers/v3d/v3dx_emit.c10
-rw-r--r--src/gallium/drivers/v3d/v3dx_state.c1
3 files changed, 14 insertions, 2 deletions
diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h
index f74541fae33..c0de05d3630 100644
--- a/src/gallium/drivers/v3d/v3d_context.h
+++ b/src/gallium/drivers/v3d/v3d_context.h
@@ -432,6 +432,11 @@ struct v3d_rasterizer_state {
*/
uint16_t offset_units;
/**
+ * The HW treats polygon offset units based on a Z24 buffer, so we
+ * need to scale up offset_units if we're only Z16.
+ */
+ uint16_t z16_offset_units;
+ /**
* Half-float (1/8/7 bits) value of polygon offset scale for
* VC5_PACKET_DEPTH_OFFSET
*/
diff --git a/src/gallium/drivers/v3d/v3dx_emit.c b/src/gallium/drivers/v3d/v3dx_emit.c
index 161ce51b2ff..ac93badfda8 100644
--- a/src/gallium/drivers/v3d/v3dx_emit.c
+++ b/src/gallium/drivers/v3d/v3dx_emit.c
@@ -431,8 +431,14 @@ v3dX(emit_state)(struct pipe_context *pctx)
cl_emit(&job->bcl, DEPTH_OFFSET, depth) {
depth.depth_offset_factor =
v3d->rasterizer->offset_factor;
- depth.depth_offset_units =
- v3d->rasterizer->offset_units;
+ if (job->zsbuf &&
+ job->zsbuf->format == PIPE_FORMAT_Z16_UNORM) {
+ depth.depth_offset_units =
+ v3d->rasterizer->z16_offset_units;
+ } else {
+ depth.depth_offset_units =
+ v3d->rasterizer->offset_units;
+ }
}
}
diff --git a/src/gallium/drivers/v3d/v3dx_state.c b/src/gallium/drivers/v3d/v3dx_state.c
index 22a0ba92a00..ec6e8ebfef9 100644
--- a/src/gallium/drivers/v3d/v3dx_state.c
+++ b/src/gallium/drivers/v3d/v3dx_state.c
@@ -116,6 +116,7 @@ v3d_create_rasterizer_state(struct pipe_context *pctx,
if (cso->offset_tri) {
so->offset_units = float_to_187_half(cso->offset_units);
+ so->z16_offset_units = float_to_187_half(cso->offset_units * 256.0);
so->offset_factor = float_to_187_half(cso->offset_scale);
}