hhctrl.ocx: Don't fail if ole is already initialised.
[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 /** DCL usage masks **/
27 #define WINED3DSP_DCL_USAGE_SHIFT 0
28 #define WINED3DSP_DCL_USAGE_MASK  0x0000000f
29 #define WINED3DSP_DCL_USAGEINDEX_SHIFT 16
30 #define WINED3DSP_DCL_USAGEINDEX_MASK  0x000f0000
31
32 /** DCL sampler texture type **/
33 #define WINED3DSP_TEXTURETYPE_SHIFT 27
34 #define WINED3DSP_TEXTURETYPE_MASK  0x78000000
35
36 typedef enum _WINED3DSAMPLER_TEXTURE_TYPE {
37   WINED3DSTT_UNKNOWN      = 0 << WINED3DSP_TEXTURETYPE_SHIFT,
38   WINED3DSTT_1D           = 1 << WINED3DSP_TEXTURETYPE_SHIFT,
39   WINED3DSTT_2D           = 2 << WINED3DSP_TEXTURETYPE_SHIFT,
40   WINED3DSTT_CUBE         = 3 << WINED3DSP_TEXTURETYPE_SHIFT,
41   WINED3DSTT_VOLUME       = 4 << WINED3DSP_TEXTURETYPE_SHIFT,
42
43   WINED3DSTT_FORCE_DWORD  = 0x7FFFFFFF
44 } WINED3DSAMPLER_TEXTURE_TYPE;
45
46 /** Register number mask **/
47 #define WINED3DSP_REGNUM_MASK        0x000007FF
48
49 /** Register type masks  **/
50 #define WINED3DSP_REGTYPE_SHIFT      28
51 #define WINED3DSP_REGTYPE_SHIFT2     8
52 #define WINED3DSP_REGTYPE_MASK       (0x7 << WINED3DSP_REGTYPE_SHIFT)
53 #define WINED3DSP_REGTYPE_MASK2      0x00001800
54
55 /** Register types **/
56 typedef enum _WINED3DSHADER_PARAM_REGISTER_TYPE {
57   WINED3DSPR_TEMP         =  0, 
58   WINED3DSPR_INPUT        =  1,
59   WINED3DSPR_CONST        =  2,
60   WINED3DSPR_ADDR         =  3,
61   WINED3DSPR_TEXTURE      =  3,
62   WINED3DSPR_RASTOUT      =  4,
63   WINED3DSPR_ATTROUT      =  5,
64   WINED3DSPR_TEXCRDOUT    =  6,
65   WINED3DSPR_OUTPUT       =  6,
66   WINED3DSPR_CONSTINT     =  7,
67   WINED3DSPR_COLOROUT     =  8,
68   WINED3DSPR_DEPTHOUT     =  9,
69   WINED3DSPR_SAMPLER      = 10,
70   WINED3DSPR_CONST2       = 11,
71   WINED3DSPR_CONST3       = 12,
72   WINED3DSPR_CONST4       = 13,
73   WINED3DSPR_CONSTBOOL    = 14,
74   WINED3DSPR_LOOP         = 15,
75   WINED3DSPR_TEMPFLOAT16  = 16,
76   WINED3DSPR_MISCTYPE     = 17,
77   WINED3DSPR_LABEL        = 18,
78   WINED3DSPR_PREDICATE    = 19,
79
80   WINED3DSPR_FORCE_DWORD  = 0x7FFFFFFF
81 } WINED3DSHADER_PARAM_REGISTER_TYPE;
82
83 /* RASTOUT register offsets */
84 typedef enum _WINED3DVS_RASTOUT_OFFSETS {
85   WINED3DSRO_POSITION     = 0,
86   WINED3DSRO_FOG          = 1,
87   WINED3DSRO_POINT_SIZE   = 2,
88
89   WINED3DSRO_FORCE_DWORD  = 0x7FFFFFFF
90 } WINED3DVS_RASTOUT_OFFSETS;
91
92 /** Source register modifiers **/
93 #define WINED3DVS_SWIZZLE_SHIFT      16
94 #define WINED3DVS_SWIZZLE_MASK       (0xFF << WINED3DVS_SWIZZLE_SHIFT)
95 #define WINED3DSP_SWIZZLE_SHIFT      16
96 #define WINED3DSP_SWIZZLE_MASK       (0xFF << WINED3DSP_SWIZZLE_SHIFT)
97
98 #define WINED3DVS_X_X       (0 << WINED3DVS_SWIZZLE_SHIFT)
99 #define WINED3DVS_X_Y       (1 << WINED3DVS_SWIZZLE_SHIFT)
100 #define WINED3DVS_X_Z       (2 << WINED3DVS_SWIZZLE_SHIFT)
101 #define WINED3DVS_X_W       (3 << WINED3DVS_SWIZZLE_SHIFT)
102
103 #define WINED3DVS_Y_X       (0 << (WINED3DVS_SWIZZLE_SHIFT + 2))
104 #define WINED3DVS_Y_Y       (1 << (WINED3DVS_SWIZZLE_SHIFT + 2))
105 #define WINED3DVS_Y_Z       (2 << (WINED3DVS_SWIZZLE_SHIFT + 2))
106 #define WINED3DVS_Y_W       (3 << (WINED3DVS_SWIZZLE_SHIFT + 2))
107
108 #define WINED3DVS_Z_X       (0 << (WINED3DVS_SWIZZLE_SHIFT + 4))
109 #define WINED3DVS_Z_Y       (1 << (WINED3DVS_SWIZZLE_SHIFT + 4))
110 #define WINED3DVS_Z_Z       (2 << (WINED3DVS_SWIZZLE_SHIFT + 4))
111 #define WINED3DVS_Z_W       (3 << (WINED3DVS_SWIZZLE_SHIFT + 4))
112
113 #define WINED3DVS_W_X       (0 << (WINED3DVS_SWIZZLE_SHIFT + 6))
114 #define WINED3DVS_W_Y       (1 << (WINED3DVS_SWIZZLE_SHIFT + 6))
115 #define WINED3DVS_W_Z       (2 << (WINED3DVS_SWIZZLE_SHIFT + 6))
116 #define WINED3DVS_W_W       (3 << (WINED3DVS_SWIZZLE_SHIFT + 6))
117
118 #define WINED3DVS_NOSWIZZLE (WINED3DVS_X_X | WINED3DVS_Y_Y | WINED3DVS_Z_Z | WINED3DVS_W_W)
119
120 #define WINED3DSP_NOSWIZZLE \
121     ((0 << (WINED3DSP_SWIZZLE_SHIFT + 0)) | (1 << (WINED3DSP_SWIZZLE_SHIFT + 2)) | \
122      (2 << (WINED3DSP_SWIZZLE_SHIFT + 4)) | (3 << (WINED3DSP_SWIZZLE_SHIFT + 6)))
123
124 #define WINED3DSP_SRCMOD_SHIFT      24
125 #define WINED3DSP_SRCMOD_MASK       (0xF << WINED3DSP_SRCMOD_SHIFT)
126
127 typedef enum _WINED3DSHADER_PARAM_SRCMOD_TYPE {
128   WINED3DSPSM_NONE         =  0 << WINED3DSP_SRCMOD_SHIFT,
129   WINED3DSPSM_NEG          =  1 << WINED3DSP_SRCMOD_SHIFT,
130   WINED3DSPSM_BIAS         =  2 << WINED3DSP_SRCMOD_SHIFT,
131   WINED3DSPSM_BIASNEG      =  3 << WINED3DSP_SRCMOD_SHIFT,
132   WINED3DSPSM_SIGN         =  4 << WINED3DSP_SRCMOD_SHIFT,
133   WINED3DSPSM_SIGNNEG      =  5 << WINED3DSP_SRCMOD_SHIFT,
134   WINED3DSPSM_COMP         =  6 << WINED3DSP_SRCMOD_SHIFT,
135   WINED3DSPSM_X2           =  7 << WINED3DSP_SRCMOD_SHIFT,
136   WINED3DSPSM_X2NEG        =  8 << WINED3DSP_SRCMOD_SHIFT,
137   WINED3DSPSM_DZ           =  9 << WINED3DSP_SRCMOD_SHIFT,
138   WINED3DSPSM_DW           = 10 << WINED3DSP_SRCMOD_SHIFT,
139   WINED3DSPSM_ABS          = 11 << WINED3DSP_SRCMOD_SHIFT,
140   WINED3DSPSM_ABSNEG       = 12 << WINED3DSP_SRCMOD_SHIFT,
141   WINED3DSPSM_NOT          = 13 << WINED3DSP_SRCMOD_SHIFT,
142
143   WINED3DSPSM_FORCE_DWORD  = 0x7FFFFFFF
144 } WINED3DSHADER_PARAM_SRCMOD_TYPE;
145
146 /** Destination register modifiers **/
147 #define WINED3DSP_WRITEMASK_0       0x00010000 /* .x r */
148 #define WINED3DSP_WRITEMASK_1       0x00020000 /* .y g */
149 #define WINED3DSP_WRITEMASK_2       0x00040000 /* .z b */
150 #define WINED3DSP_WRITEMASK_3       0x00080000 /* .w a */
151 #define WINED3DSP_WRITEMASK_ALL     0x000F0000 /* all */
152
153 #define WINED3DSP_DSTMOD_SHIFT      20
154 #define WINED3DSP_DSTMOD_MASK       (0xF << WINED3DSP_DSTMOD_SHIFT)
155
156 typedef enum _WINED3DSHADER_PARAM_DSTMOD_TYPE {
157   WINED3DSPDM_NONE             = 0 << WINED3DSP_DSTMOD_SHIFT,
158   WINED3DSPDM_SATURATE         = 1 << WINED3DSP_DSTMOD_SHIFT,
159   WINED3DSPDM_PARTIALPRECISION = 2 << WINED3DSP_DSTMOD_SHIFT,
160   WINED3DSPDM_MSAMPCENTROID    = 4 << WINED3DSP_DSTMOD_SHIFT,
161
162   WINED3DSPDM_FORCE_DWORD  = 0x7FFFFFFF
163 } WINED3DSHADER_PARAM_DSTMOD_TYPE;
164
165 #define WINED3DSP_DSTSHIFT_SHIFT     24
166 #define WINED3DSP_DSTSHIFT_MASK      (0xF << WINED3DSP_DSTSHIFT_SHIFT)
167
168 /** Register addressing modes **/
169 #define WINED3DSHADER_ADDRESSMODE_SHIFT 13
170 #define WINED3DSHADER_ADDRESSMODE_MASK  (1 << WINED3DSHADER_ADDRESSMODE_SHIFT)
171
172 typedef enum _WINED3DSHADER_ADDRESSMODE_TYPE {
173   WINED3DSHADER_ADDRMODE_ABSOLUTE    = 0 << WINED3DSHADER_ADDRESSMODE_SHIFT,
174   WINED3DSHADER_ADDRMODE_RELATIVE    = 1 << WINED3DSHADER_ADDRESSMODE_SHIFT,
175
176   WINED3DSHADER_ADDRMODE_FORCE_DWORD = 0x7FFFFFFF
177 } WINED3DSHADER_ADDRESSMODE_TYPE;
178
179 /** Opcode types */
180 typedef enum _WINED3DSHADER_INSTRUCTION_OPCODE_TYPE {
181   WINED3DSIO_NOP          =  0,
182   WINED3DSIO_MOV          =  1,
183   WINED3DSIO_ADD          =  2,
184   WINED3DSIO_SUB          =  3,
185   WINED3DSIO_MAD          =  4,
186   WINED3DSIO_MUL          =  5,
187   WINED3DSIO_RCP          =  6,
188   WINED3DSIO_RSQ          =  7,
189   WINED3DSIO_DP3          =  8,
190   WINED3DSIO_DP4          =  9,
191   WINED3DSIO_MIN          = 10,
192   WINED3DSIO_MAX          = 11,
193   WINED3DSIO_SLT          = 12,
194   WINED3DSIO_SGE          = 13,
195   WINED3DSIO_EXP          = 14,
196   WINED3DSIO_LOG          = 15,
197   WINED3DSIO_LIT          = 16,
198   WINED3DSIO_DST          = 17,
199   WINED3DSIO_LRP          = 18,
200   WINED3DSIO_FRC          = 19,
201   WINED3DSIO_M4x4         = 20,
202   WINED3DSIO_M4x3         = 21,
203   WINED3DSIO_M3x4         = 22,
204   WINED3DSIO_M3x3         = 23,
205   WINED3DSIO_M3x2         = 24,
206   WINED3DSIO_CALL         = 25,
207   WINED3DSIO_CALLNZ       = 26,
208   WINED3DSIO_LOOP         = 27,
209   WINED3DSIO_RET          = 28,
210   WINED3DSIO_ENDLOOP      = 29,
211   WINED3DSIO_LABEL        = 30,
212   WINED3DSIO_DCL          = 31,
213   WINED3DSIO_POW          = 32,
214   WINED3DSIO_CRS          = 33,
215   WINED3DSIO_SGN          = 34,
216   WINED3DSIO_ABS          = 35,
217   WINED3DSIO_NRM          = 36,
218   WINED3DSIO_SINCOS       = 37,
219   WINED3DSIO_REP          = 38,
220   WINED3DSIO_ENDREP       = 39,
221   WINED3DSIO_IF           = 40,
222   WINED3DSIO_IFC          = 41,
223   WINED3DSIO_ELSE         = 42,
224   WINED3DSIO_ENDIF        = 43,
225   WINED3DSIO_BREAK        = 44,
226   WINED3DSIO_BREAKC       = 45,
227   WINED3DSIO_MOVA         = 46,
228   WINED3DSIO_DEFB         = 47,
229   WINED3DSIO_DEFI         = 48,
230
231   WINED3DSIO_TEXCOORD     = 64,
232   WINED3DSIO_TEXKILL      = 65,
233   WINED3DSIO_TEX          = 66,
234   WINED3DSIO_TEXBEM       = 67,
235   WINED3DSIO_TEXBEML      = 68,
236   WINED3DSIO_TEXREG2AR    = 69,
237   WINED3DSIO_TEXREG2GB    = 70,
238   WINED3DSIO_TEXM3x2PAD   = 71,
239   WINED3DSIO_TEXM3x2TEX   = 72,
240   WINED3DSIO_TEXM3x3PAD   = 73,
241   WINED3DSIO_TEXM3x3TEX   = 74,
242   WINED3DSIO_TEXM3x3DIFF  = 75,
243   WINED3DSIO_TEXM3x3SPEC  = 76,
244   WINED3DSIO_TEXM3x3VSPEC = 77,
245   WINED3DSIO_EXPP         = 78,
246   WINED3DSIO_LOGP         = 79,
247   WINED3DSIO_CND          = 80,
248   WINED3DSIO_DEF          = 81,
249   WINED3DSIO_TEXREG2RGB   = 82,
250   WINED3DSIO_TEXDP3TEX    = 83,
251   WINED3DSIO_TEXM3x2DEPTH = 84,
252   WINED3DSIO_TEXDP3       = 85,
253   WINED3DSIO_TEXM3x3      = 86,
254   WINED3DSIO_TEXDEPTH     = 87,
255   WINED3DSIO_CMP          = 88,
256   WINED3DSIO_BEM          = 89,
257   WINED3DSIO_DP2ADD       = 90,
258   WINED3DSIO_DSX          = 91,
259   WINED3DSIO_DSY          = 92,
260   WINED3DSIO_TEXLDD       = 93,
261   WINED3DSIO_SETP         = 94,
262   WINED3DSIO_TEXLDL       = 95,
263   WINED3DSIO_BREAKP       = 96,
264
265   WINED3DSIO_PHASE        = 0xFFFD,
266   WINED3DSIO_COMMENT      = 0xFFFE,
267   WINED3DSIO_END          = 0XFFFF,
268
269   WINED3DSIO_FORCE_DWORD  = 0X7FFFFFFF /** for 32-bit alignment */
270 } WINED3DSHADER_INSTRUCTION_OPCODE_TYPE;
271
272 /** opcode-related masks **/
273
274 #define WINED3DSI_OPCODE_MASK       0x0000FFFF
275 #define WINED3DSI_INSTLENGTH_MASK   0x0F000000
276 #define WINED3DSI_INSTLENGTH_SHIFT  24
277
278 #define WINED3DSI_COISSUE 0x40000000
279
280 #define WINED3DSI_COMMENTSIZE_SHIFT 16
281 #define WINED3DSI_COMMENTSIZE_MASK (0x7FFF << WINED3DSI_COMMENTSIZE_SHIFT)
282 #define WINED3DSHADER_COMMENT(commentSize) \
283   ((((commentSize) << WINED3DSI_COMMENTSIZE_SHIFT) & WINED3DSI_COMMENTSIZE_MASK) | WINED3DSIO_COMMENT)
284
285 #define WINED3DSHADER_INSTRUCTION_PREDICATED (1 << 28)
286
287 /** Shader version tokens, and shader end tokens **/
288
289 #define WINED3DPS_VERSION(major, minor) (0xFFFF0000 | ((major) << 8) | (minor))
290 #define WINED3DVS_VERSION(major, minor) (0xFFFE0000 | ((major) << 8) | (minor))
291 #define WINED3DSHADER_VERSION_MAJOR(version) (((version) >> 8) & 0xFF)
292 #define WINED3DSHADER_VERSION_MINOR(version) (((version) >> 0) & 0xFF)
293 #define WINED3DPS_END() 0x0000FFFF
294 #define WINED3DVS_END() 0x0000FFFF
295   
296 #endif