gallium: add FMA and DFMA opcodes (v3)
[mesa.git] / src / gallium / include / pipe / p_shader_tokens.h
index 3fc7a4715e3de35b254bef486118ba1a30e3681b..c14bcbca33613cc2c4f8d7674b172011feebfb1e 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  * 
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
  * Copyright 2009-2010 VMware, Inc.
  * All Rights Reserved.
  * 
@@ -19,7 +19,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -74,10 +74,8 @@ enum tgsi_file_type {
    TGSI_FILE_IMMEDIATE           =7,
    TGSI_FILE_PREDICATE           =8,
    TGSI_FILE_SYSTEM_VALUE        =9,
-   TGSI_FILE_IMMEDIATE_ARRAY     =10,
-   TGSI_FILE_TEMPORARY_ARRAY     =11,
-   TGSI_FILE_RESOURCE            =12,
-   TGSI_FILE_SAMPLER_VIEW        =13,
+   TGSI_FILE_RESOURCE            =10,
+   TGSI_FILE_SAMPLER_VIEW        =11,
    TGSI_FILE_COUNT      /**< how many TGSI_FILE_ types */
 };
 
@@ -105,6 +103,11 @@ enum tgsi_file_type {
 #define TGSI_INTERPOLATE_COLOR         3 /* special color case for smooth/flat */
 #define TGSI_INTERPOLATE_COUNT         4
 
+#define TGSI_INTERPOLATE_LOC_CENTER    0
+#define TGSI_INTERPOLATE_LOC_CENTROID  1
+#define TGSI_INTERPOLATE_LOC_SAMPLE    2
+#define TGSI_INTERPOLATE_LOC_COUNT     3
+
 #define TGSI_CYLINDRICAL_WRAP_X (1 << 0)
 #define TGSI_CYLINDRICAL_WRAP_Y (1 << 1)
 #define TGSI_CYLINDRICAL_WRAP_Z (1 << 2)
@@ -120,7 +123,9 @@ struct tgsi_declaration
    unsigned Semantic    : 1;  /**< BOOL, any semantic info? */
    unsigned Interpolate : 1;  /**< any interpolation info? */
    unsigned Invariant   : 1;  /**< invariant optimization? */
-   unsigned Padding     : 8;
+   unsigned Local       : 1;  /**< optimize as subroutine local variable? */
+   unsigned Array       : 1;  /**< extra array info? */
+   unsigned Padding     : 6;
 };
 
 struct tgsi_declaration_range
@@ -138,9 +143,9 @@ struct tgsi_declaration_dimension
 struct tgsi_declaration_interp
 {
    unsigned Interpolate : 4;   /**< one of TGSI_INTERPOLATE_x */
-   unsigned Centroid    : 1;   /**< centroid sampling? */
+   unsigned Location    : 2;   /**< one of TGSI_INTERPOLATE_LOC_x */
    unsigned CylindricalWrap:4; /**< TGSI_CYLINDRICAL_WRAP_x flags */
-   unsigned Padding     : 23;
+   unsigned Padding     : 22;
 };
 
 #define TGSI_SEMANTIC_POSITION   0
@@ -153,12 +158,27 @@ struct tgsi_declaration_interp
 #define TGSI_SEMANTIC_FACE       7
 #define TGSI_SEMANTIC_EDGEFLAG   8
 #define TGSI_SEMANTIC_PRIMID     9
-#define TGSI_SEMANTIC_INSTANCEID 10
+#define TGSI_SEMANTIC_INSTANCEID 10 /**< doesn't include start_instance */
 #define TGSI_SEMANTIC_VERTEXID   11
 #define TGSI_SEMANTIC_STENCIL    12
 #define TGSI_SEMANTIC_CLIPDIST   13
 #define TGSI_SEMANTIC_CLIPVERTEX 14
-#define TGSI_SEMANTIC_COUNT      15 /**< number of semantic values */
+#define TGSI_SEMANTIC_GRID_SIZE  15 /**< grid size in blocks */
+#define TGSI_SEMANTIC_BLOCK_ID   16 /**< id of the current block */
+#define TGSI_SEMANTIC_BLOCK_SIZE 17 /**< block size in threads */
+#define TGSI_SEMANTIC_THREAD_ID  18 /**< block-relative id of the current thread */
+#define TGSI_SEMANTIC_TEXCOORD   19 /**< texture or sprite coordinates */
+#define TGSI_SEMANTIC_PCOORD     20 /**< point sprite coordinate */
+#define TGSI_SEMANTIC_VIEWPORT_INDEX 21 /**< viewport index */
+#define TGSI_SEMANTIC_LAYER      22 /**< layer (rendertarget index) */
+#define TGSI_SEMANTIC_CULLDIST   23
+#define TGSI_SEMANTIC_SAMPLEID   24
+#define TGSI_SEMANTIC_SAMPLEPOS  25
+#define TGSI_SEMANTIC_SAMPLEMASK 26
+#define TGSI_SEMANTIC_INVOCATIONID 27
+#define TGSI_SEMANTIC_VERTEXID_NOBASE 28
+#define TGSI_SEMANTIC_BASEVERTEX 29
+#define TGSI_SEMANTIC_COUNT      30 /**< number of semantic values */
 
 struct tgsi_declaration_semantic
 {
@@ -170,15 +190,30 @@ struct tgsi_declaration_semantic
 struct tgsi_declaration_resource {
    unsigned Resource    : 8; /**< one of TGSI_TEXTURE_ */
    unsigned Raw         : 1;
-   unsigned Padding     : 23;
+   unsigned Writable    : 1;
+   unsigned Padding     : 22;
+};
+
+enum tgsi_return_type {
+   TGSI_RETURN_TYPE_UNORM = 0,
+   TGSI_RETURN_TYPE_SNORM,
+   TGSI_RETURN_TYPE_SINT,
+   TGSI_RETURN_TYPE_UINT,
+   TGSI_RETURN_TYPE_FLOAT,
+   TGSI_RETURN_TYPE_COUNT
 };
 
 struct tgsi_declaration_sampler_view {
    unsigned Resource    : 8; /**< one of TGSI_TEXTURE_ */
-   unsigned ReturnTypeX : 6; /**< one of enum pipe_type */
-   unsigned ReturnTypeY : 6; /**< one of enum pipe_type */
-   unsigned ReturnTypeZ : 6; /**< one of enum pipe_type */
-   unsigned ReturnTypeW : 6; /**< one of enum pipe_type */
+   unsigned ReturnTypeX : 6; /**< one of enum tgsi_return_type */
+   unsigned ReturnTypeY : 6; /**< one of enum tgsi_return_type */
+   unsigned ReturnTypeZ : 6; /**< one of enum tgsi_return_type */
+   unsigned ReturnTypeW : 6; /**< one of enum tgsi_return_type */
+};
+
+struct tgsi_declaration_array {
+   unsigned ArrayID : 10;
+   unsigned Padding : 22;
 };
 
 /*
@@ -193,6 +228,7 @@ struct tgsi_declaration_sampler_view {
 #define TGSI_IMM_FLOAT32   0
 #define TGSI_IMM_UINT32    1
 #define TGSI_IMM_INT32     2
+#define TGSI_IMM_FLOAT64   3
 
 struct tgsi_immediate
 {
@@ -217,7 +253,9 @@ union tgsi_immediate_data
 #define TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS 5
 #define TGSI_PROPERTY_FS_DEPTH_LAYOUT        6
 #define TGSI_PROPERTY_VS_PROHIBIT_UCPS       7
-#define TGSI_PROPERTY_COUNT                  8
+#define TGSI_PROPERTY_GS_INVOCATIONS         8
+#define TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION 9
+#define TGSI_PROPERTY_COUNT                  10
 
 struct tgsi_property {
    unsigned Type         : 4;  /**< TGSI_TOKEN_TYPE_PROPERTY */
@@ -268,8 +306,8 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_MAD                 16
 #define TGSI_OPCODE_SUB                 17
 #define TGSI_OPCODE_LRP                 18
-#define TGSI_OPCODE_CND                 19
-                                /* gap */
+#define TGSI_OPCODE_FMA                 19
+#define TGSI_OPCODE_SQRT                20
 #define TGSI_OPCODE_DP2A                21
                                 /* gap */
 #define TGSI_OPCODE_FRC                 24
@@ -282,24 +320,24 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_XPD                 31
                                 /* gap */
 #define TGSI_OPCODE_ABS                 33
-#define TGSI_OPCODE_RCC                 34
+                                /* gap */
 #define TGSI_OPCODE_DPH                 35
 #define TGSI_OPCODE_COS                 36
 #define TGSI_OPCODE_DDX                 37
 #define TGSI_OPCODE_DDY                 38
-#define TGSI_OPCODE_KILP                39  /* predicated kill */
+#define TGSI_OPCODE_KILL                39 /* unconditional */
 #define TGSI_OPCODE_PK2H                40
 #define TGSI_OPCODE_PK2US               41
 #define TGSI_OPCODE_PK4B                42
 #define TGSI_OPCODE_PK4UB               43
-#define TGSI_OPCODE_RFL                 44
+                                /* gap */
 #define TGSI_OPCODE_SEQ                 45
-#define TGSI_OPCODE_SFL                 46
+                                /* gap */
 #define TGSI_OPCODE_SGT                 47
 #define TGSI_OPCODE_SIN                 48
 #define TGSI_OPCODE_SLE                 49
 #define TGSI_OPCODE_SNE                 50
-#define TGSI_OPCODE_STR                 51
+                                /* gap */
 #define TGSI_OPCODE_TEX                 52
 #define TGSI_OPCODE_TXD                 53
 #define TGSI_OPCODE_TXP                 54
@@ -307,26 +345,28 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_UP2US               56
 #define TGSI_OPCODE_UP4B                57
 #define TGSI_OPCODE_UP4UB               58
-#define TGSI_OPCODE_X2D                 59
-#define TGSI_OPCODE_ARA                 60
+                                /* gap */
 #define TGSI_OPCODE_ARR                 61
-#define TGSI_OPCODE_BRA                 62
+                                /* gap */
 #define TGSI_OPCODE_CAL                 63
 #define TGSI_OPCODE_RET                 64
 #define TGSI_OPCODE_SSG                 65 /* SGN */
 #define TGSI_OPCODE_CMP                 66
 #define TGSI_OPCODE_SCS                 67
 #define TGSI_OPCODE_TXB                 68
-#define TGSI_OPCODE_NRM                 69
+                                /* gap */
 #define TGSI_OPCODE_DIV                 70
 #define TGSI_OPCODE_DP2                 71
 #define TGSI_OPCODE_TXL                 72
 #define TGSI_OPCODE_BRK                 73
 #define TGSI_OPCODE_IF                  74
-                                /* gap */
+#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
@@ -349,16 +389,22 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_BGNSUB              100
 #define TGSI_OPCODE_ENDLOOP             101
 #define TGSI_OPCODE_ENDSUB              102
+#define TGSI_OPCODE_TXQ_LZ              103 /* TXQ for mipmap level 0 */
                                 /* gap */
 #define TGSI_OPCODE_NOP                 107
+
+#define TGSI_OPCODE_FSEQ                108
+#define TGSI_OPCODE_FSGE                109
+#define TGSI_OPCODE_FSLT                110
+#define TGSI_OPCODE_FSNE                111
+
                                 /* gap */
-#define TGSI_OPCODE_NRM4                112
 #define TGSI_OPCODE_CALLNZ              113
-#define TGSI_OPCODE_IFC                 114
+                                /* gap */
 #define TGSI_OPCODE_BREAKC              115
-#define TGSI_OPCODE_KIL                 116  /* conditional kill */
+#define TGSI_OPCODE_KILL_IF             116  /* conditional kill */
 #define TGSI_OPCODE_END                 117  /* aka HALT */
-                                /* gap */
+#define TGSI_OPCODE_DFMA                118
 #define TGSI_OPCODE_F2I                 119
 #define TGSI_OPCODE_IDIV                120
 #define TGSI_OPCODE_IMAX                121
@@ -406,8 +452,79 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_ISSG                160
 
 #define TGSI_OPCODE_LOAD                161
-
-#define TGSI_OPCODE_LAST                162
+#define TGSI_OPCODE_STORE               162
+
+#define TGSI_OPCODE_MFENCE              163
+#define TGSI_OPCODE_LFENCE              164
+#define TGSI_OPCODE_SFENCE              165
+#define TGSI_OPCODE_BARRIER             166
+
+#define TGSI_OPCODE_ATOMUADD            167
+#define TGSI_OPCODE_ATOMXCHG            168
+#define TGSI_OPCODE_ATOMCAS             169
+#define TGSI_OPCODE_ATOMAND             170
+#define TGSI_OPCODE_ATOMOR              171
+#define TGSI_OPCODE_ATOMXOR             172
+#define TGSI_OPCODE_ATOMUMIN            173
+#define TGSI_OPCODE_ATOMUMAX            174
+#define TGSI_OPCODE_ATOMIMIN            175
+#define TGSI_OPCODE_ATOMIMAX            176
+
+/* to be used for shadow cube map compares */
+#define TGSI_OPCODE_TEX2                177
+#define TGSI_OPCODE_TXB2                178
+#define TGSI_OPCODE_TXL2                179
+
+#define TGSI_OPCODE_IMUL_HI             180
+#define TGSI_OPCODE_UMUL_HI             181
+
+#define TGSI_OPCODE_TG4                 182
+
+#define TGSI_OPCODE_LODQ                183
+
+#define TGSI_OPCODE_IBFE                184
+#define TGSI_OPCODE_UBFE                185
+#define TGSI_OPCODE_BFI                 186
+#define TGSI_OPCODE_BREV                187
+#define TGSI_OPCODE_POPC                188
+#define TGSI_OPCODE_LSB                 189
+#define TGSI_OPCODE_IMSB                190
+#define TGSI_OPCODE_UMSB                191
+
+#define TGSI_OPCODE_INTERP_CENTROID     192
+#define TGSI_OPCODE_INTERP_SAMPLE       193
+#define TGSI_OPCODE_INTERP_OFFSET       194
+
+/* sm5 marked opcodes are supported in D3D11 optionally - also DMOV, DMOVC */
+#define TGSI_OPCODE_F2D                 195 /* SM5 */
+#define TGSI_OPCODE_D2F                 196
+#define TGSI_OPCODE_DABS                197
+#define TGSI_OPCODE_DNEG                198 /* SM5 */
+#define TGSI_OPCODE_DADD                199 /* SM5 */
+#define TGSI_OPCODE_DMUL                200 /* SM5 */
+#define TGSI_OPCODE_DMAX                201 /* SM5 */
+#define TGSI_OPCODE_DMIN                202 /* SM5 */
+#define TGSI_OPCODE_DSLT                203 /* SM5 */
+#define TGSI_OPCODE_DSGE                204 /* SM5 */
+#define TGSI_OPCODE_DSEQ                205 /* SM5 */
+#define TGSI_OPCODE_DSNE                206 /* SM5 */
+#define TGSI_OPCODE_DRCP                207 /* eg, cayman */
+#define TGSI_OPCODE_DSQRT               208 /* eg, cayman also has DRSQ */
+#define TGSI_OPCODE_DMAD                209
+#define TGSI_OPCODE_DFRAC               210 /* eg, cayman */
+#define TGSI_OPCODE_DLDEXP              211 /* eg, cayman */
+#define TGSI_OPCODE_DFRACEXP            212 /* eg, cayman */
+#define TGSI_OPCODE_D2I                 213
+#define TGSI_OPCODE_I2D                 214
+#define TGSI_OPCODE_D2U                 215
+#define TGSI_OPCODE_U2D                 216
+#define TGSI_OPCODE_DRSQ                217 /* eg, cayman also has DRSQ */
+#define TGSI_OPCODE_DTRUNC              218 /* nvc0 */
+#define TGSI_OPCODE_DCEIL               219 /* nvc0 */
+#define TGSI_OPCODE_DFLR                220 /* nvc0 */
+#define TGSI_OPCODE_DROUND              221 /* nvc0 */
+#define TGSI_OPCODE_DSSG                222
+#define TGSI_OPCODE_LAST                223
 
 #define TGSI_SAT_NONE            0  /* do not saturate */
 #define TGSI_SAT_ZERO_ONE        1  /* clamp to [0,1] */
@@ -467,7 +584,7 @@ struct tgsi_instruction_label
    unsigned Padding  : 8;
 };
 
-#define TGSI_BUFFER                 0
+#define TGSI_TEXTURE_BUFFER         0
 #define TGSI_TEXTURE_1D             1
 #define TGSI_TEXTURE_2D             2
 #define TGSI_TEXTURE_3D             3
@@ -481,7 +598,12 @@ struct tgsi_instruction_label
 #define TGSI_TEXTURE_SHADOW1D_ARRAY 11
 #define TGSI_TEXTURE_SHADOW2D_ARRAY 12
 #define TGSI_TEXTURE_SHADOWCUBE     13
-#define TGSI_TEXTURE_COUNT          14
+#define TGSI_TEXTURE_2D_MSAA        14
+#define TGSI_TEXTURE_2D_ARRAY_MSAA  15
+#define TGSI_TEXTURE_CUBE_ARRAY     16
+#define TGSI_TEXTURE_SHADOWCUBE_ARRAY 17
+#define TGSI_TEXTURE_UNKNOWN        18
+#define TGSI_TEXTURE_COUNT          19
 
 struct tgsi_instruction_texture
 {
@@ -525,7 +647,7 @@ struct tgsi_instruction_predicate
  *
  * Index specifies the element number of a register in the register file.
  *
- * If Indirect is TRUE, Index should be offset by the X component of a source
+ * If Indirect is TRUE, Index should be offset by the X component of the indirect
  * register that follows. The register can be now fetched into local storage
  * for further processing.
  *
@@ -551,14 +673,26 @@ struct tgsi_src_register
 };
 
 /**
- * If tgsi_src_register::Modifier is TRUE, tgsi_src_register_modifier follows.
- * 
- * Then, if tgsi_src_register::Indirect is TRUE, another tgsi_src_register
- * follows.
+ * If tgsi_src_register::Indirect is TRUE, tgsi_ind_register follows.
+ *
+ * File, Index and Swizzle are handled the same as in tgsi_src_register.
+ *
+ * If ArrayID is zero the whole register file might be is indirectly addressed,
+ * if not only the Declaration with this ArrayID is accessed by this operand.
  *
- * Then, if tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
  */
 
+struct tgsi_ind_register
+{
+   unsigned File    : 4;  /* TGSI_FILE_ */
+   int      Index   : 16; /* SINT */
+   unsigned Swizzle : 2;  /* TGSI_SWIZZLE_ */
+   unsigned ArrayID : 10; /* UINT */
+};
+
+/**
+ * If tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
+ */
 
 struct tgsi_dimension
 {