gallium: add opcodes/cap for fine derivative support
authorIlia Mirkin <imirkin@alum.mit.edu>
Thu, 14 Aug 2014 04:04:41 +0000 (00:04 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Fri, 15 Aug 2014 00:25:32 +0000 (20:25 -0400)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
Reviewed-by: Roland Scheidegger <sroland@vmware.com> (v1)
v2: Reuse opcode gaps as suggested by Marek

19 files changed:
src/gallium/auxiliary/tgsi/tgsi_info.c
src/gallium/auxiliary/tgsi/tgsi_util.c
src/gallium/docs/source/screen.rst
src/gallium/docs/source/tgsi.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/vc4/vc4_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_shader_tokens.h

index e24348f6cb5453942d628f2a8bb5355b1bec827c..74d186cfdf1cf28c59eef07669e473fb925514c3 100644 (file)
@@ -116,8 +116,8 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
    { 0, 1, 0, 0, 0, 1, NONE, "", 76 },      /* removed */
    { 0, 0, 0, 1, 1, 1, NONE, "ELSE", TGSI_OPCODE_ELSE },
    { 0, 0, 0, 0, 1, 0, NONE, "ENDIF", TGSI_OPCODE_ENDIF },
-   { 1, 0, 0, 0, 1, 0, NONE, "", 79 },      /* removed */
-   { 0, 0, 0, 0, 1, 0, NONE, "", 80 },      /* removed */
+   { 1, 1, 0, 0, 0, 0, COMP, "DDX_FINE", TGSI_OPCODE_DDX_FINE },
+   { 1, 1, 0, 0, 0, 0, COMP, "DDY_FINE", TGSI_OPCODE_DDY_FINE },
    { 0, 1, 0, 0, 0, 0, NONE, "PUSHA", TGSI_OPCODE_PUSHA },
    { 1, 0, 0, 0, 0, 0, NONE, "POPA", TGSI_OPCODE_POPA },
    { 1, 1, 0, 0, 0, 0, COMP, "CEIL", TGSI_OPCODE_CEIL },
index e48159cd600bd7a10c2956312e12de60589799f7..e1cba95c264880bacb3c3d3a04bc46fa32e95db3 100644 (file)
@@ -245,6 +245,8 @@ tgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst,
    case TGSI_OPCODE_USNE:
    case TGSI_OPCODE_IMUL_HI:
    case TGSI_OPCODE_UMUL_HI:
+   case TGSI_OPCODE_DDX_FINE:
+   case TGSI_OPCODE_DDY_FINE:
       /* Channel-wise operations */
       read_mask = write_mask;
       break;
index 814e3aec69b6ddf4fc95854c9108cb4970bd4fcc..6fecc15d6b815d9bd398635b9c56d38e3ff18fa6 100644 (file)
@@ -213,6 +213,8 @@ The integer capabilities:
 * ``PIPE_CAP_DRAW_INDIRECT``: Whether the driver supports taking draw arguments
   { count, instance_count, start, index_bias } from a PIPE_BUFFER resource.
   See pipe_draw_info.
+* ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE``: Whether the fragment shader supports
+  the FINE versions of DDX/DDY.
 
 
 .. _pipe_capf:
index ac0ea5413b3287b06985e443ba89a50e758515ac..7d5918fc4fea86263de70a50235220f48054f931 100644 (file)
@@ -433,7 +433,11 @@ This instruction replicates its result.
   dst = \cos{src.x}
 
 
-.. opcode:: DDX - Derivative Relative To X
+.. opcode:: DDX, DDX_FINE - Derivative Relative To X
+
+The fine variant is only used when ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE`` is
+advertised. When it is, the fine version guarantees one derivative per row
+while DDX is allowed to be the same for the entire 2x2 quad.
 
 .. math::
 
@@ -446,7 +450,11 @@ This instruction replicates its result.
   dst.w = partialx(src.w)
 
 
-.. opcode:: DDY - Derivative Relative To Y
+.. opcode:: DDY, DDY_FINE - Derivative Relative To Y
+
+The fine variant is only used when ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE`` is
+advertised. When it is, the fine version guarantees one derivative per column
+while DDY is allowed to be the same for the entire 2x2 quad.
 
 .. math::
 
index de69b14ce770d7acce99c6edf471a11d2eec8bb8..b156d8b3660146632762beaf05d2df47f6b42ea5 100644 (file)
@@ -216,6 +216,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
        case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
        case PIPE_CAP_DRAW_INDIRECT:
+       case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
                return 0;
 
        /* Stream output. */
index ca3dd4a6f72a3ff8934c823583ad259082088f69..53d5e7580b50a61133d19063259fea809457ed1e 100644 (file)
@@ -231,6 +231,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_DRAW_INDIRECT:
+   case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
       return 0;
 
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
index bd6d8ddb4e7576d97aa747ca906da5aa286c4d79..991d2d0de364640bdfd262f89384345ca3193a9f 100644 (file)
@@ -433,6 +433,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
    case PIPE_CAP_MAX_VERTEX_STREAMS:
    case PIPE_CAP_DRAW_INDIRECT:
+   case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
       return 0;
 
    default:
index 347b1af4f14c4c1caaa1d6941cdf1c894a1a2eaf..f4f325709f7d9e0bc317bc2249ec412fceebffdc 100644 (file)
@@ -248,6 +248,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_SAMPLE_SHADING:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
+   case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
       return 0;
    case PIPE_CAP_FAKE_SW_MSAA:
       return 1;
index 2860188961a3dc223dc71b5003634dd610ec6b8a..4766955b5ee296b742e89a3cbfd9316f87b1747d 100644 (file)
@@ -148,6 +148,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_USER_VERTEX_BUFFERS:
    case PIPE_CAP_COMPUTE:
    case PIPE_CAP_DRAW_INDIRECT:
+   case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
       return 0;
    }
 
index 7b1b1125178837447f7d462dccef7d9dd304ec45..34cca3dafc8ed975daff3b5a75d58bebfc476986 100644 (file)
@@ -200,6 +200,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
    case PIPE_CAP_COMPUTE:
    case PIPE_CAP_DRAW_INDIRECT:
+   case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
       return 0;
    }
 
index d372a0fc36b145288de408c41fd8255fb7502af1..17aee636417d49cc92da181405e3362cc0d291ff 100644 (file)
@@ -184,6 +184,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
    case PIPE_CAP_FAKE_SW_MSAA:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
+   case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
       return 0;
    }
 
index 4e46f77ee02492bf6b87fcb9e2ec8dd1a73c5340..ad599e973223cb3d323141332d32bb008e9981e5 100644 (file)
@@ -178,6 +178,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
         case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
         case PIPE_CAP_DRAW_INDIRECT:
+        case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
             return 0;
 
         /* SWTCL-only features. */
index 20d9f950e4c6560e7efc4b5564dd9bab6c6b0e88..8a5ba7951bbd487103e32b65bb9431680a5d3c75 100644 (file)
@@ -319,6 +319,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_SAMPLE_SHADING:
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
        case PIPE_CAP_DRAW_INDIRECT:
+       case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
                return 0;
 
        /* Stream output. */
index 879387f0fba711c3a93db5e8a9e6983cf3071712..0f10f3b7fb8dd2dde48aae5d8cce5f06344262df 100644 (file)
@@ -254,6 +254,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_FAKE_SW_MSAA:
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
        case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
+       case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
                return 0;
 
        case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
index 7be39d4f61896a55d96caa690d230195e97d902a..5e2640dcbb1215310b40c366efb867007cfc181e 100644 (file)
@@ -194,6 +194,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_SAMPLE_SHADING:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
+   case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
       return 0;
    case PIPE_CAP_FAKE_SW_MSAA:
       return 1;
index 2fcc75c45bce6a12ac178fe0f7b5320d6ddd217f..d140f561e800e0b5740ecba2ac2cd40539a387b8 100644 (file)
@@ -278,6 +278,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
    case PIPE_CAP_DRAW_INDIRECT:
+   case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
       return 0;
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 64;
index c044c8ee697a089beb8fd00843e9d8dd84134b11..7e5961392249f2f071f1421473cfca692709793d 100644 (file)
@@ -157,6 +157,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
         case PIPE_CAP_MAX_TEXEL_OFFSET:
         case PIPE_CAP_MAX_VERTEX_STREAMS:
         case PIPE_CAP_DRAW_INDIRECT:
+        case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
                 return 0;
 
                 /* Stream output. */
index 7a10d9833f3a0904407db608aa28f252d590e85f..53d5d4b00b528aa1487c937ad9cd54388f0d7061 100644 (file)
@@ -562,6 +562,7 @@ enum pipe_cap {
    PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION = 99,
    PIPE_CAP_MAX_VERTEX_STREAMS = 100,
    PIPE_CAP_DRAW_INDIRECT = 101,
+   PIPE_CAP_TGSI_FS_FINE_DERIVATIVE = 102,
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
index 0d3ad6abb51d0df7bfde1f8f661219561442ec25..8ab1ea85e576d9c07c6811ffc738d4858d3e556c 100644 (file)
@@ -352,7 +352,10 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_UIF                 75
 #define TGSI_OPCODE_ELSE                77
 #define TGSI_OPCODE_ENDIF               78
-                                /* gap */
+
+#define TGSI_OPCODE_DDX_FINE            79
+#define TGSI_OPCODE_DDY_FINE            80
+
 #define TGSI_OPCODE_PUSHA               81
 #define TGSI_OPCODE_POPA                82
 #define TGSI_OPCODE_CEIL                83