From: Ilia Mirkin Date: Sat, 25 Jun 2016 19:20:00 +0000 (-0400) Subject: nvc0: provide support for unscaled poly offset units X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=89a7496b9d3e705b7940e503b5cc01417da04495;p=mesa.git nvc0: provide support for unscaled poly offset units On at least Kepler hardware, the units differ based on RT format. Emit a properly scaled value for Z16 depth buffers vs other formats, to help out st/nine. Signed-off-by: Ilia Mirkin --- diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index a5c37c5b713..abcbfbfbac4 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -234,6 +234,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: case PIPE_CAP_COMPUTE: case PIPE_CAP_TGSI_VOTE: + case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED: return 1; case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: return (class_3d >= NVE4_3D_CLASS) ? 1 : 0; @@ -263,7 +264,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_PCI_BUS: case PIPE_CAP_PCI_DEVICE: case PIPE_CAP_PCI_FUNCTION: - case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED: return 0; case PIPE_CAP_VENDOR_ID: diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index b389a7703ff..441cfc97454 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -283,8 +283,10 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe, if (cso->offset_point || cso->offset_line || cso->offset_tri) { SB_BEGIN_3D(so, POLYGON_OFFSET_FACTOR, 1); SB_DATA (so, fui(cso->offset_scale)); - SB_BEGIN_3D(so, POLYGON_OFFSET_UNITS, 1); - SB_DATA (so, fui(cso->offset_units * 2.0f)); + if (!cso->offset_units_unscaled) { + SB_BEGIN_3D(so, POLYGON_OFFSET_UNITS, 1); + SB_DATA (so, fui(cso->offset_units * 2.0f)); + } SB_BEGIN_3D(so, POLYGON_OFFSET_CLAMP, 1); SB_DATA (so, fui(cso->offset_clamp)); } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c index 05c15ce070a..ea0bd23f002 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c @@ -671,6 +671,26 @@ nvc0_validate_derived_3(struct nvc0_context *nvc0) PUSH_DATA (push, ms); } +static void +nvc0_validate_derived_4(struct nvc0_context *nvc0) +{ + struct nouveau_pushbuf *push = nvc0->base.pushbuf; + struct pipe_framebuffer_state *fb = &nvc0->framebuffer; + struct pipe_rasterizer_state *rast = &nvc0->rast->pipe; + + if (!rast) + return; + + if (rast->offset_units_unscaled) { + BEGIN_NVC0(push, NVC0_3D(POLYGON_OFFSET_UNITS), 1); + if (fb->zsbuf && fb->zsbuf->format == PIPE_FORMAT_Z16_UNORM) + PUSH_DATAf(push, rast->offset_units * (1 << 16)); + else + PUSH_DATAf(push, rast->offset_units * (1 << 24)); + } +} + + static void nvc0_validate_tess_state(struct nvc0_context *nvc0) { @@ -754,6 +774,7 @@ validate_list_3d[] = { NVC0_NEW_3D_RASTERIZER }, { nvc0_validate_derived_2, NVC0_NEW_3D_ZSA | NVC0_NEW_3D_FRAMEBUFFER }, { nvc0_validate_derived_3, NVC0_NEW_3D_BLEND | NVC0_NEW_3D_FRAMEBUFFER }, + { nvc0_validate_derived_4, NVC0_NEW_3D_RASTERIZER | NVC0_NEW_3D_FRAMEBUFFER }, { nvc0_validate_clip, NVC0_NEW_3D_CLIP | NVC0_NEW_3D_RASTERIZER | NVC0_NEW_3D_VERTPROG | NVC0_NEW_3D_TEVLPROG |