gallium: Add a cap for offset_units_unscaled
authorAxel Davy <axel.davy@ens.fr>
Mon, 13 Jun 2016 20:28:32 +0000 (22:28 +0200)
committerAxel Davy <axel.davy@ens.fr>
Sat, 25 Jun 2016 08:16:15 +0000 (10:16 +0200)
D3D9 has a different behaviour for depth bias.

For OGL/D3D1X, the depth bias unit is the
minimal resolvable value for the depth buffer,
which depends on the format (and has different
behaviour for float depth buffers).

For D3D9, the depth bias unit is 1.0f.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
19 files changed:
src/gallium/docs/source/cso/rasterizer.rst
src/gallium/docs/source/screen.rst
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nouveau/nv30/nv30_screen.c
src/gallium/drivers/nouveau/nv50/nv50_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/swr/swr_screen.cpp
src/gallium/drivers/vc4/vc4_screen.c
src/gallium/drivers/virgl/virgl_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_state.h

index 8d473b8446e000b0ab00c028a7461ef5cbe63ffb..616e4511a2d514b65679c477ff7111e0aa0f3f1e 100644 (file)
@@ -127,6 +127,12 @@ offset_tri
 
 offset_units
     Specifies the polygon offset bias
+offset_units_unscaled
+    Specifies the unit of the polygon offset bias. If false, use the
+    GL/D3D1X behaviour. If true, offset_units is a floating point offset
+    which isn't scaled (D3D9). Note that GL/D3D1X behaviour has different
+    formula whether the depth buffer is unorm or float, which is not
+    the case for D3D9.
 offset_scale
     Specifies the polygon offset scale
 offset_clamp
index a20b372b1a94df45dd151e33a7205366b1997407..141b45aa8058b5cfe947ec061d9704406a3e0109 100644 (file)
@@ -343,6 +343,8 @@ The integer capabilities:
 * ``PIPE_CAP_TGSI_VOTE``: Whether the ``VOTE_*`` ops can be used in shaders.
 * ``PIPE_CAP_MAX_WINDOW_RECTANGLES``: The maxium number of window rectangles
   supported in ``set_window_rectangles``.
+* ``PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED``: If true, the driver implements support
+  for ``pipe_rasterizer_state::offset_units_unscaled``.
 
 
 .. _pipe_capf:
index 91380241f3caec6c75153812b984fde171b5e203..93b70e0884e50df3d76d5f0c016136991455a527 100644 (file)
@@ -264,6 +264,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
        case PIPE_CAP_TGSI_VOTE:
        case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+       case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
                return 0;
 
        case PIPE_CAP_MAX_VIEWPORTS:
index e898f7ee20ad0d7bb8c3a49bd31134833a4043c0..3f0ab98a3c556cb15201d36fbf5ff5b34b30811c 100644 (file)
@@ -275,6 +275,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
 
    case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
index a775aa60dc2839f734ef67e8d944efc82ed3b2ae..2024688ecdb9fd5d844f68c31a1bef06bd30beb6 100644 (file)
@@ -504,6 +504,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 7d01e6458f7b48aa22a42615381472750b5bb257..684c7a539efbd327979a382462053e287f096ff4 100644 (file)
@@ -327,6 +327,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
    }
    /* should only get here on unhandled cases */
index 0a3d8b2faba5e3161c0f366cc724dc94076c3dba..68d8317bd6005db8588af69fb6996fa4f9960816 100644 (file)
@@ -198,6 +198,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 042148e74558642fbf05ce930465a8bbdaad2804..303ecf121ae1c16a8b1c37eec329d8ffe490e0f2 100644 (file)
@@ -252,6 +252,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 08ec4136880494e5cec2fabc85bae900041e9784..a5c37c5b7135ad114013aa5a1e0871ad977ca285 100644 (file)
@@ -263,6 +263,7 @@ 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 8822b4d11bdce7b3ecc320db7aa60a384c83a81f..d47b70d65b317d850d142cc96d416b34798ba4db 100644 (file)
@@ -220,6 +220,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
         case PIPE_CAP_TGSI_VOTE:
         case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+        case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
             return 0;
 
         /* SWTCL-only features. */
index f4811c4feaa23384284de139a2391103d46bbad8..fe1af7c64bbcd7fc6687980c89012f94cf8f0953 100644 (file)
@@ -370,6 +370,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
        case PIPE_CAP_TGSI_VOTE:
        case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+       case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
                return 0;
 
        case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
index 3259d5f42b2df35ebe0bc45b7a5bc667f1dcc9c6..37406aa27d6e3cd1cedec1913337d5b5febc0a21 100644 (file)
@@ -415,6 +415,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
        case PIPE_CAP_TGSI_VOTE:
        case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+       case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
                return 0;
 
        case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
index a4b2299c26f654d75a9faeba6d34dcbe680232e9..93022db8055d1462f3dad2577056fac80b376466 100644 (file)
@@ -277,6 +277,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
    case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
       return 4;
index f6f53afe7eabc166ea6c93746a1f2039bad0a7ec..4c2774d3f174f3c9c58aa4a446af2de097057501 100644 (file)
@@ -410,6 +410,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
    }
 
index 792b09cd4381e0f0bb6db86587da24aa3fb978c2..d47840575120ebf7304b81c6cbdd73f5e3cee85c 100644 (file)
@@ -363,6 +363,7 @@ swr_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
    }
 
index c38e4f4381f44d117383746a164e38cb9833157e..0f0d119b1df5b0cd5f1e48ab264e975a60ec16d1 100644 (file)
@@ -213,6 +213,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
         case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
         case PIPE_CAP_TGSI_VOTE:
         case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+        case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
                 return 0;
 
                 /* Stream output. */
index 65574fae78816f1a8f4ed53735c657fc7c99a5d8..b94b01716745762a23621d0edc31fef49b6a2e9a 100644 (file)
@@ -245,6 +245,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
+   case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
       return 0;
    case PIPE_CAP_VENDOR_ID:
       return 0x1af4;
index c46ac5a6a63dc9e279a1d31eb24c6f89ef348461..62fa67374f2c2f29b2d10e294153578c9c8ac997 100644 (file)
@@ -731,6 +731,7 @@ enum pipe_cap
    PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES,
    PIPE_CAP_TGSI_VOTE,
    PIPE_CAP_MAX_WINDOW_RECTANGLES,
+   PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED,
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
index 9c693555c7eae4d81fcbef9a77b0d7a8aad454d2..1543e90972e9902008bf4a6c0a31bdff45d2817d 100644 (file)
@@ -139,6 +139,13 @@ struct pipe_rasterizer_state
     */
    unsigned clip_halfz:1;
 
+   /**
+    * When true do not scale offset_units and use same rules for unorm and
+    * float depth buffers (D3D9). When false use GL/D3D1X behaviour.
+    * This depends on PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED.
+    */
+   unsigned offset_units_unscaled:1;
+
    /**
     * Enable bits for clipping half-spaces.
     * This applies to both user clip planes and shader clip distances.