nvc0: provide support for unscaled poly offset units
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 25 Jun 2016 19:20:00 +0000 (15:20 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sun, 26 Jun 2016 16:04:55 +0000 (12:04 -0400)
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 <imirkin@alum.mit.edu>
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c

index a5c37c5b7135ad114013aa5a1e0871ad977ca285..abcbfbfbac467f08215e6e4d3ad3d1a088e31283 100644 (file)
@@ -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:
index b389a7703fff8a4afeae8c7e9ab388302426daa0..441cfc9745423ddd2075f33f0a940bc4e7f16612 100644 (file)
@@ -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));
     }
index 05c15ce070a4eaf540270cd852870341c11c6c66..ea0bd23f002b126fd1f3a0c3fd4ea5ca3be558f7 100644 (file)
@@ -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 |