[Mesa-dev] [PATCH] nv50, nvc0: disable depth offsets when there is no depth buffer
Roland Scheidegger
sroland at vmware.com
Mon Jan 16 16:12:39 UTC 2017
I'm pretty sure it's undefined in GL (because there's no defined minimum
resolvable difference in depth buffer format), IIRC this is stated
somewhere but can't remember.
d3d10 has a definition which doesn't make much sense (as it still says
to use the unorm formula in this case for which "r is the minimum
representable value > 0 in the depth-buffer format converted to
float32":
https://msdn.microsoft.com/en-us/library/windows/desktop/cc308048(v=vs.85).aspx
Albeit the scale part still would work fine...
Not sure though it's really the drivers job to hack around these...
Roland
Am 15.01.2017 um 21:52 schrieb Ilia Mirkin:
> While I can find no support for this in the GL spec, this is apparently
> what D3D9 wants. Also appears to fix a very long-standing bug in Tomb
> Raider: Underworld and Deus Ex: Human Revolution (probably based on the
> same engines).
>
> Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D91247&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=_QIjpv-UJ77xEQY8fIYoQtr5qv8wKrPJc7v7_-CYAb0&m=fR-7SJseyJKibacwjqB22vAW8uf-C69bqQPlj0ApZ48&s=T0bGXIRFrc7Qm6Njye1wA-S-wWRHltfTQT1E-pa0XpM&e=
> References: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_iXit_Mesa-2D3D_issues_224&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=_QIjpv-UJ77xEQY8fIYoQtr5qv8wKrPJc7v7_-CYAb0&m=fR-7SJseyJKibacwjqB22vAW8uf-C69bqQPlj0ApZ48&s=5Kfu_g8K6BI7DVL9FngDmtJcsyo5zVlW_n_RNWWcNWk&e=
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/gallium/drivers/nouveau/nv50/nv50_state.c | 4 ----
> src/gallium/drivers/nouveau/nv50/nv50_state_validate.c | 17 +++++++++++++++++
> src/gallium/drivers/nouveau/nv50/nv50_stateobj.h | 2 +-
> src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 4 ----
> src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c | 5 +++++
> src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h | 2 +-
> 6 files changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c
> index 99d70d1..e66257a 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_state.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c
> @@ -301,10 +301,6 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
>
> SB_BEGIN_3D(so, POLYGON_STIPPLE_ENABLE, 1);
> SB_DATA (so, cso->poly_stipple_enable);
> - SB_BEGIN_3D(so, POLYGON_OFFSET_POINT_ENABLE, 3);
> - SB_DATA (so, cso->offset_point);
> - SB_DATA (so, cso->offset_line);
> - SB_DATA (so, cso->offset_tri);
>
> if (cso->offset_point || cso->offset_line || cso->offset_tri) {
> SB_BEGIN_3D(so, POLYGON_OFFSET_FACTOR, 1);
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
> index c6f0363..0db13d9 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
> @@ -347,6 +347,22 @@ nv50_validate_derived_2(struct nv50_context *nv50)
> }
>
> static void
> +nv50_validate_rast_fb(struct nv50_context *nv50)
> +{
> + struct nouveau_pushbuf *push = nv50->base.pushbuf;
> + struct pipe_framebuffer_state *fb = &nv50->framebuffer;
> + struct pipe_rasterizer_state *rast = &nv50->rast->pipe;
> +
> + if (!rast)
> + return;
> +
> + BEGIN_NV04(push, NV50_3D(POLYGON_OFFSET_POINT_ENABLE), 3);
> + PUSH_DATA (push, rast->offset_point * !!fb->zsbuf);
> + PUSH_DATA (push, rast->offset_line * !!fb->zsbuf);
> + PUSH_DATA (push, rast->offset_tri * !!fb->zsbuf);
> +}
> +
> +static void
> nv50_validate_clip(struct nv50_context *nv50)
> {
> struct nouveau_pushbuf *push = nv50->base.pushbuf;
> @@ -515,6 +531,7 @@ validate_list_3d[] = {
> { nv50_validate_derived_rs, NV50_NEW_3D_FRAGPROG | NV50_NEW_3D_RASTERIZER |
> NV50_NEW_3D_VERTPROG | NV50_NEW_3D_GMTYPROG },
> { nv50_validate_derived_2, NV50_NEW_3D_ZSA | NV50_NEW_3D_FRAMEBUFFER },
> + { nv50_validate_rast_fb, NV50_NEW_3D_RASTERIZER | NV50_NEW_3D_FRAMEBUFFER },
> { nv50_validate_clip, NV50_NEW_3D_CLIP | NV50_NEW_3D_RASTERIZER |
> NV50_NEW_3D_VERTPROG | NV50_NEW_3D_GMTYPROG },
> { nv50_constbufs_validate, NV50_NEW_3D_CONSTBUF },
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_stateobj.h b/src/gallium/drivers/nouveau/nv50/nv50_stateobj.h
> index 579da9a..a5af115 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_stateobj.h
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_stateobj.h
> @@ -25,7 +25,7 @@ struct nv50_blend_stateobj {
> struct nv50_rasterizer_stateobj {
> struct pipe_rasterizer_state pipe;
> int size;
> - uint32_t state[49];
> + uint32_t state[45];
> };
>
> struct nv50_zsa_stateobj {
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
> index bba35f1..1c953eb 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
> @@ -285,10 +285,6 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe,
> }
>
> SB_IMMED_3D(so, POLYGON_STIPPLE_ENABLE, cso->poly_stipple_enable);
> - SB_BEGIN_3D(so, POLYGON_OFFSET_POINT_ENABLE, 3);
> - SB_DATA (so, cso->offset_point);
> - SB_DATA (so, cso->offset_line);
> - SB_DATA (so, cso->offset_tri);
>
> if (cso->offset_point || cso->offset_line || cso->offset_tri) {
> SB_BEGIN_3D(so, POLYGON_OFFSET_FACTOR, 1);
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
> index d4931cb..4dbcb1c 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
> @@ -689,6 +689,11 @@ nvc0_validate_rast_fb(struct nvc0_context *nvc0)
> else
> PUSH_DATAf(push, rast->offset_units * (1 << 24));
> }
> +
> + BEGIN_NVC0(push, NVC0_3D(POLYGON_OFFSET_POINT_ENABLE), 3);
> + PUSH_DATA (push, rast->offset_point * !!fb->zsbuf);
> + PUSH_DATA (push, rast->offset_line * !!fb->zsbuf);
> + PUSH_DATA (push, rast->offset_tri * !!fb->zsbuf);
> }
>
>
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h b/src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h
> index 054b1e7..e93da9d 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h
> @@ -23,7 +23,7 @@ struct nvc0_blend_stateobj {
> struct nvc0_rasterizer_stateobj {
> struct pipe_rasterizer_state pipe;
> int size;
> - uint32_t state[42];
> + uint32_t state[38];
> };
>
> struct nvc0_zsa_stateobj {
>
More information about the mesa-dev
mailing list