quartz: Fix discontinuities in wave parser.
[wine] / dlls / wined3d / wined3d_private_types.h
1 /*
2  * Direct3D wine internal header: D3D equivalent types
3  *
4  * Copyright 2002-2003 Jason Edmeades
5  * Copyright 2002-2003 Raphael Junqueira
6  * Copyright 2005 Oliver Stieber
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #ifndef __WINE_WINED3D_TYPES_INTERNAL_H
24 #define __WINE_WINED3D_TYPES_INTERNAL_H
25
26 /* Depth copy state */
27 typedef enum {
28     WINED3D_DCS_INITIAL = 0,
29     WINED3D_DCS_COPY    = 1,
30     WINED3D_DCS_NO_COPY = 2
31 } WINED3D_DEPTHCOPYSTATE;
32
33 /* WineD3D pixel format flags */
34 #define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x1
35 #define WINED3DFMT_FLAG_FILTERING                0x2
36 #define WINED3DFMT_FLAG_DEPTH                    0x4
37 #define WINED3DFMT_FLAG_STENCIL                  0x8
38 #define WINED3DFMT_FLAG_RENDERTARGET             0x10
39
40 /** DCL usage masks **/
41 #define WINED3DSP_DCL_USAGE_SHIFT 0
42 #define WINED3DSP_DCL_USAGE_MASK  0x0000000f
43 #define WINED3DSP_DCL_USAGEINDEX_SHIFT 16
44 #define WINED3DSP_DCL_USAGEINDEX_MASK  0x000f0000
45
46 /** DCL sampler texture type **/
47 #define WINED3DSP_TEXTURETYPE_SHIFT 27
48 #define WINED3DSP_TEXTURETYPE_MASK  0x78000000
49
50 typedef enum _WINED3DSAMPLER_TEXTURE_TYPE {
51   WINED3DSTT_UNKNOWN      = 0 << WINED3DSP_TEXTURETYPE_SHIFT,
52   WINED3DSTT_1D           = 1 << WINED3DSP_TEXTURETYPE_SHIFT,
53   WINED3DSTT_2D           = 2 << WINED3DSP_TEXTURETYPE_SHIFT,
54   WINED3DSTT_CUBE         = 3 << WINED3DSP_TEXTURETYPE_SHIFT,
55   WINED3DSTT_VOLUME       = 4 << WINED3DSP_TEXTURETYPE_SHIFT,
56
57   WINED3DSTT_FORCE_DWORD  = 0x7FFFFFFF
58 } WINED3DSAMPLER_TEXTURE_TYPE;
59
60 /** Register number mask **/
61 #define WINED3DSP_REGNUM_MASK        0x000007FF
62
63 /** Register type masks  **/
64 #define WINED3DSP_REGTYPE_SHIFT      28
65 #define WINED3DSP_REGTYPE_SHIFT2     8
66 #define WINED3DSP_REGTYPE_MASK       (0x7 << WINED3DSP_REGTYPE_SHIFT)
67 #define WINED3DSP_REGTYPE_MASK2      0x00001800
68
69 /** Register types **/
70 typedef enum _WINED3DSHADER_PARAM_REGISTER_TYPE {
71   WINED3DSPR_TEMP         =  0, 
72   WINED3DSPR_INPUT        =  1,
73   WINED3DSPR_CONST        =  2,
74   WINED3DSPR_ADDR         =  3,
75   WINED3DSPR_TEXTURE      =  3,
76   WINED3DSPR_RASTOUT      =  4,
77   WINED3DSPR_ATTROUT      =  5,
78   WINED3DSPR_TEXCRDOUT    =  6,
79   WINED3DSPR_OUTPUT       =  6,
80   WINED3DSPR_CONSTINT     =  7,
81   WINED3DSPR_COLOROUT     =  8,
82   WINED3DSPR_DEPTHOUT     =  9,
83   WINED3DSPR_SAMPLER      = 10,
84   WINED3DSPR_CONST2       = 11,
85   WINED3DSPR_CONST3       = 12,
86   WINED3DSPR_CONST4       = 13,
87   WINED3DSPR_CONSTBOOL    = 14,
88   WINED3DSPR_LOOP         = 15,
89   WINED3DSPR_TEMPFLOAT16  = 16,
90   WINED3DSPR_MISCTYPE     = 17,
91   WINED3DSPR_LABEL        = 18,
92   WINED3DSPR_PREDICATE    = 19,
93
94   WINED3DSPR_FORCE_DWORD  = 0x7FFFFFFF
95 } WINED3DSHADER_PARAM_REGISTER_TYPE;
96
97 /* RASTOUT register offsets */
98 typedef enum _WINED3DVS_RASTOUT_OFFSETS {
99   WINED3DSRO_POSITION     = 0,
100   WINED3DSRO_FOG          = 1,
101   WINED3DSRO_POINT_SIZE   = 2,
102
103   WINED3DSRO_FORCE_DWORD  = 0x7FFFFFFF
104 } WINED3DVS_RASTOUT_OFFSETS;
105
106 /** Source register modifiers **/
107 #define WINED3DVS_SWIZZLE_SHIFT      16
108 #define WINED3DVS_SWIZZLE_MASK       (0xFF << WINED3DVS_SWIZZLE_SHIFT)
109 #define WINED3DSP_SWIZZLE_SHIFT      16
110 #define WINED3DSP_SWIZZLE_MASK       (0xFF << WINED3DSP_SWIZZLE_SHIFT)
111
112 #define WINED3DVS_X_X       (0 << WINED3DVS_SWIZZLE_SHIFT)
113 #define WINED3DVS_X_Y       (1 << WINED3DVS_SWIZZLE_SHIFT)
114 #define WINED3DVS_X_Z       (2 << WINED3DVS_SWIZZLE_SHIFT)
115 #define WINED3DVS_X_W       (3 << WINED3DVS_SWIZZLE_SHIFT)
116
117 #define WINED3DVS_Y_X       (0 << (WINED3DVS_SWIZZLE_SHIFT + 2))
118 #define WINED3DVS_Y_Y       (1 << (WINED3DVS_SWIZZLE_SHIFT + 2))
119 #define WINED3DVS_Y_Z       (2 << (WINED3DVS_SWIZZLE_SHIFT + 2))
120 #define WINED3DVS_Y_W       (3 << (WINED3DVS_SWIZZLE_SHIFT + 2))
121
122 #define WINED3DVS_Z_X       (0 << (WINED3DVS_SWIZZLE_SHIFT + 4))
123 #define WINED3DVS_Z_Y       (1 << (WINED3DVS_SWIZZLE_SHIFT + 4))
124 #define WINED3DVS_Z_Z       (2 << (WINED3DVS_SWIZZLE_SHIFT + 4))
125 #define WINED3DVS_Z_W       (3 << (WINED3DVS_SWIZZLE_SHIFT + 4))
126
127 #define WINED3DVS_W_X       (0 << (WINED3DVS_SWIZZLE_SHIFT + 6))
128 #define WINED3DVS_W_Y       (1 << (WINED3DVS_SWIZZLE_SHIFT + 6))
129 #define WINED3DVS_W_Z       (2 << (WINED3DVS_SWIZZLE_SHIFT + 6))
130 #define WINED3DVS_W_W       (3 << (WINED3DVS_SWIZZLE_SHIFT + 6))
131
132 #define WINED3DVS_NOSWIZZLE (WINED3DVS_X_X | WINED3DVS_Y_Y | WINED3DVS_Z_Z | WINED3DVS_W_W)
133
134 #define WINED3DSP_NOSWIZZLE \
135     ((0 << (WINED3DSP_SWIZZLE_SHIFT + 0)) | (1 << (WINED3DSP_SWIZZLE_SHIFT + 2)) | \
136      (2 << (WINED3DSP_SWIZZLE_SHIFT + 4)) | (3 << (WINED3DSP_SWIZZLE_SHIFT + 6)))
137
138 #define WINED3DSP_SRCMOD_SHIFT      24
139 #define WINED3DSP_SRCMOD_MASK       (0xF << WINED3DSP_SRCMOD_SHIFT)
140
141 typedef enum _WINED3DSHADER_PARAM_SRCMOD_TYPE {
142   WINED3DSPSM_NONE         =  0 << WINED3DSP_SRCMOD_SHIFT,
143   WINED3DSPSM_NEG          =  1 << WINED3DSP_SRCMOD_SHIFT,
144   WINED3DSPSM_BIAS         =  2 << WINED3DSP_SRCMOD_SHIFT,
145   WINED3DSPSM_BIASNEG      =  3 << WINED3DSP_SRCMOD_SHIFT,
146   WINED3DSPSM_SIGN         =  4 << WINED3DSP_SRCMOD_SHIFT,
147   WINED3DSPSM_SIGNNEG      =  5 << WINED3DSP_SRCMOD_SHIFT,
148   WINED3DSPSM_COMP         =  6 << WINED3DSP_SRCMOD_SHIFT,
149   WINED3DSPSM_X2           =  7 << WINED3DSP_SRCMOD_SHIFT,
150   WINED3DSPSM_X2NEG        =  8 << WINED3DSP_SRCMOD_SHIFT,
151   WINED3DSPSM_DZ           =  9 << WINED3DSP_SRCMOD_SHIFT,
152   WINED3DSPSM_DW           = 10 << WINED3DSP_SRCMOD_SHIFT,
153   WINED3DSPSM_ABS          = 11 << WINED3DSP_SRCMOD_SHIFT,
154   WINED3DSPSM_ABSNEG       = 12 << WINED3DSP_SRCMOD_SHIFT,
155   WINED3DSPSM_NOT          = 13 << WINED3DSP_SRCMOD_SHIFT,
156
157   WINED3DSPSM_FORCE_DWORD  = 0x7FFFFFFF
158 } WINED3DSHADER_PARAM_SRCMOD_TYPE;
159
160 /** Destination register modifiers **/
161 #define WINED3DSP_WRITEMASK_0       0x00010000 /* .x r */
162 #define WINED3DSP_WRITEMASK_1       0x00020000 /* .y g */
163 #define WINED3DSP_WRITEMASK_2       0x00040000 /* .z b */
164 #define WINED3DSP_WRITEMASK_3       0x00080000 /* .w a */
165 #define WINED3DSP_WRITEMASK_ALL     0x000F0000 /* all */
166
167 #define WINED3DSP_DSTMOD_SHIFT      20
168 #define WINED3DSP_DSTMOD_MASK       (0xF << WINED3DSP_DSTMOD_SHIFT)
169
170 typedef enum _WINED3DSHADER_PARAM_DSTMOD_TYPE {
171   WINED3DSPDM_NONE             = 0 << WINED3DSP_DSTMOD_SHIFT,
172   WINED3DSPDM_SATURATE         = 1 << WINED3DSP_DSTMOD_SHIFT,
173   WINED3DSPDM_PARTIALPRECISION = 2 << WINED3DSP_DSTMOD_SHIFT,
174   WINED3DSPDM_MSAMPCENTROID    = 4 << WINED3DSP_DSTMOD_SHIFT,
175
176   WINED3DSPDM_FORCE_DWORD  = 0x7FFFFFFF
177 } WINED3DSHADER_PARAM_DSTMOD_TYPE;
178
179 #define WINED3DSP_DSTSHIFT_SHIFT     24
180 #define WINED3DSP_DSTSHIFT_MASK      (0xF << WINED3DSP_DSTSHIFT_SHIFT)
181
182 /** Register addressing modes **/
183 #define WINED3DSHADER_ADDRESSMODE_SHIFT 13
184 #define WINED3DSHADER_ADDRESSMODE_MASK  (1 << WINED3DSHADER_ADDRESSMODE_SHIFT)
185
186 typedef enum _WINED3DSHADER_ADDRESSMODE_TYPE {
187   WINED3DSHADER_ADDRMODE_ABSOLUTE    = 0 << WINED3DSHADER_ADDRESSMODE_SHIFT,
188   WINED3DSHADER_ADDRMODE_RELATIVE    = 1 << WINED3DSHADER_ADDRESSMODE_SHIFT,
189
190   WINED3DSHADER_ADDRMODE_FORCE_DWORD = 0x7FFFFFFF
191 } WINED3DSHADER_ADDRESSMODE_TYPE;
192
193 /** Opcode types */
194 typedef enum _WINED3DSHADER_INSTRUCTION_OPCODE_TYPE {
195   WINED3DSIO_NOP          =  0,
196   WINED3DSIO_MOV          =  1,
197   WINED3DSIO_ADD          =  2,
198   WINED3DSIO_SUB          =  3,
199   WINED3DSIO_MAD          =  4,
200   WINED3DSIO_MUL          =  5,
201   WINED3DSIO_RCP          =  6,
202   WINED3DSIO_RSQ          =  7,
203   WINED3DSIO_DP3          =  8,
204   WINED3DSIO_DP4          =  9,
205   WINED3DSIO_MIN          = 10,
206   WINED3DSIO_MAX          = 11,
207   WINED3DSIO_SLT          = 12,
208   WINED3DSIO_SGE          = 13,
209   WINED3DSIO_EXP          = 14,
210   WINED3DSIO_LOG          = 15,
211   WINED3DSIO_LIT          = 16,
212   WINED3DSIO_DST          = 17,
213   WINED3DSIO_LRP          = 18,
214   WINED3DSIO_FRC          = 19,
215   WINED3DSIO_M4x4         = 20,
216   WINED3DSIO_M4x3         = 21,
217   WINED3DSIO_M3x4         = 22,
218   WINED3DSIO_M3x3         = 23,
219   WINED3DSIO_M3x2         = 24,
220   WINED3DSIO_CALL         = 25,
221   WINED3DSIO_CALLNZ       = 26,
222   WINED3DSIO_LOOP         = 27,
223   WINED3DSIO_RET          = 28,
224   WINED3DSIO_ENDLOOP      = 29,
225   WINED3DSIO_LABEL        = 30,
226   WINED3DSIO_DCL          = 31,
227   WINED3DSIO_POW          = 32,
228   WINED3DSIO_CRS          = 33,
229   WINED3DSIO_SGN          = 34,
230   WINED3DSIO_ABS          = 35,
231   WINED3DSIO_NRM          = 36,
232   WINED3DSIO_SINCOS       = 37,
233   WINED3DSIO_REP          = 38,
234   WINED3DSIO_ENDREP       = 39,
235   WINED3DSIO_IF           = 40,
236   WINED3DSIO_IFC          = 41,
237   WINED3DSIO_ELSE         = 42,
238   WINED3DSIO_ENDIF        = 43,
239   WINED3DSIO_BREAK        = 44,
240   WINED3DSIO_BREAKC       = 45,
241   WINED3DSIO_MOVA         = 46,
242   WINED3DSIO_DEFB         = 47,
243   WINED3DSIO_DEFI         = 48,
244
245   WINED3DSIO_TEXCOORD     = 64,
246   WINED3DSIO_TEXKILL      = 65,
247   WINED3DSIO_TEX          = 66,
248   WINED3DSIO_TEXBEM       = 67,
249   WINED3DSIO_TEXBEML      = 68,
250   WINED3DSIO_TEXREG2AR    = 69,
251   WINED3DSIO_TEXREG2GB    = 70,
252   WINED3DSIO_TEXM3x2PAD   = 71,
253   WINED3DSIO_TEXM3x2TEX   = 72,
254   WINED3DSIO_TEXM3x3PAD   = 73,
255   WINED3DSIO_TEXM3x3TEX   = 74,
256   WINED3DSIO_TEXM3x3DIFF  = 75,
257   WINED3DSIO_TEXM3x3SPEC  = 76,
258   WINED3DSIO_TEXM3x3VSPEC = 77,
259   WINED3DSIO_EXPP         = 78,
260   WINED3DSIO_LOGP         = 79,
261   WINED3DSIO_CND          = 80,
262   WINED3DSIO_DEF          = 81,
263   WINED3DSIO_TEXREG2RGB   = 82,
264   WINED3DSIO_TEXDP3TEX    = 83,
265   WINED3DSIO_TEXM3x2DEPTH = 84,
266   WINED3DSIO_TEXDP3       = 85,
267   WINED3DSIO_TEXM3x3      = 86,
268   WINED3DSIO_TEXDEPTH     = 87,
269   WINED3DSIO_CMP          = 88,
270   WINED3DSIO_BEM          = 89,
271   WINED3DSIO_DP2ADD       = 90,
272   WINED3DSIO_DSX          = 91,
273   WINED3DSIO_DSY          = 92,
274   WINED3DSIO_TEXLDD       = 93,
275   WINED3DSIO_SETP         = 94,
276   WINED3DSIO_TEXLDL       = 95,
277   WINED3DSIO_BREAKP       = 96,
278
279   WINED3DSIO_PHASE        = 0xFFFD,
280   WINED3DSIO_COMMENT      = 0xFFFE,
281   WINED3DSIO_END          = 0XFFFF,
282
283   WINED3DSIO_FORCE_DWORD  = 0X7FFFFFFF /** for 32-bit alignment */
284 } WINED3DSHADER_INSTRUCTION_OPCODE_TYPE;
285
286 /** opcode-related masks **/
287
288 #define WINED3DSI_OPCODE_MASK       0x0000FFFF
289 #define WINED3DSI_INSTLENGTH_MASK   0x0F000000
290 #define WINED3DSI_INSTLENGTH_SHIFT  24
291
292 #define WINED3DSI_COISSUE 0x40000000
293
294 #define WINED3DSI_COMMENTSIZE_SHIFT 16
295 #define WINED3DSI_COMMENTSIZE_MASK (0x7FFF << WINED3DSI_COMMENTSIZE_SHIFT)
296 #define WINED3DSHADER_COMMENT(commentSize) \
297   ((((commentSize) << WINED3DSI_COMMENTSIZE_SHIFT) & WINED3DSI_COMMENTSIZE_MASK) | WINED3DSIO_COMMENT)
298
299 #define WINED3DSHADER_INSTRUCTION_PREDICATED (1 << 28)
300
301 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
302 #define WINED3DSI_TEXLD_PROJECT 0x00010000
303 #define WINED3DSI_TEXLD_BIAS    0x00020000
304
305 /** Shader version tokens, and shader end tokens **/
306
307 #define WINED3DPS_VERSION(major, minor) (0xFFFF0000 | ((major) << 8) | (minor))
308 #define WINED3DVS_VERSION(major, minor) (0xFFFE0000 | ((major) << 8) | (minor))
309 #define WINED3DSHADER_VERSION_MAJOR(version) (((version) >> 8) & 0xFF)
310 #define WINED3DSHADER_VERSION_MINOR(version) (((version) >> 0) & 0xFF)
311 #define WINED3DPS_END() 0x0000FFFF
312 #define WINED3DVS_END() 0x0000FFFF
313
314 /* Multithreaded flag. Removed from the public header to signal that IWineD3D::CreateDevice ignores it */
315 #define WINED3DCREATE_MULTITHREADED                 0x00000004
316
317 #endif