Skip to content

Commit

Permalink
st/nine: Fix DEPTHBIAS for GW2
Browse files Browse the repository at this point in the history
Improved version of nvc0: provide support for unscaled poly offset units.
https://patchwork.freedesktop.org/patch/95229/

After rebasing this patch has to be reworked.

Fixes issue (3) for issue iXit#224.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
  • Loading branch information
siro20 authored and tr37ion committed Aug 21, 2016
1 parent e0a247a commit be62736
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
36 changes: 36 additions & 0 deletions src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
Expand Up @@ -681,6 +681,41 @@ nvc0_validate_tess_state(struct nvc0_context *nvc0)
PUSH_DATAp(push, nvc0->default_tess_inner, 2);
}

/* Disable POLYGON_OFFSET in case no depth stencil is bound.
* Apply correct offset for offset_units_unscaled.
*/
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 (!fb->zsbuf) {
BEGIN_NVC0(push, NVC0_3D(POLYGON_OFFSET_POINT_ENABLE), 3);
PUSH_DATAf (push, 0);
PUSH_DATAf (push, 0);
PUSH_DATAf (push, 0);
return;
} else {
BEGIN_NVC0(push, NVC0_3D(POLYGON_OFFSET_POINT_ENABLE), 3);
PUSH_DATAf (push, rast->offset_point);
PUSH_DATAf (push, rast->offset_line);
PUSH_DATAf (push, rast->offset_tri);
}

if (rast->offset_units_unscaled) {
BEGIN_NVC0(push, NVC0_3D(POLYGON_OFFSET_UNITS), 1);
if (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_switch_pipe_context(struct nvc0_context *ctx_to)
{
Expand Down Expand Up @@ -754,6 +789,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 |
Expand Down

0 comments on commit be62736

Please sign in to comment.