netstat: Initial implementation.
[wine] / dlls / d3d10 / d3d10_private.h
1 /*
2  * Copyright 2008-2009 Henri Verbeet for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #ifndef __WINE_D3D10_PRIVATE_H
20 #define __WINE_D3D10_PRIVATE_H
21
22 #include "wine/debug.h"
23 #include "wine/rbtree.h"
24
25 #define COBJMACROS
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "objbase.h"
29
30 #include "d3d10.h"
31 #include "d3dcompiler.h"
32
33 /*
34  * This doesn't belong here, but for some functions it is possible to return that value,
35  * see http://msdn.microsoft.com/en-us/library/bb205278%28v=VS.85%29.aspx
36  * The original definition is in D3DX10core.h.
37  */
38 #define D3DERR_INVALIDCALL 0x8876086c
39
40 /* TRACE helper functions */
41 const char *debug_d3d10_driver_type(D3D10_DRIVER_TYPE driver_type) DECLSPEC_HIDDEN;
42 const char *debug_d3d10_shader_variable_class(D3D10_SHADER_VARIABLE_CLASS c) DECLSPEC_HIDDEN;
43 const char *debug_d3d10_shader_variable_type(D3D10_SHADER_VARIABLE_TYPE t) DECLSPEC_HIDDEN;
44 const char *debug_d3d10_device_state_types(D3D10_DEVICE_STATE_TYPES t) DECLSPEC_HIDDEN;
45
46 void *d3d10_rb_alloc(size_t size) DECLSPEC_HIDDEN;
47 void *d3d10_rb_realloc(void *ptr, size_t size) DECLSPEC_HIDDEN;
48 void d3d10_rb_free(void *ptr) DECLSPEC_HIDDEN;
49
50 enum d3d10_effect_object_type
51 {
52     D3D10_EOT_RASTERIZER_STATE = 0x0,
53     D3D10_EOT_DEPTH_STENCIL_STATE = 0x1,
54     D3D10_EOT_BLEND_STATE = 0x2,
55     D3D10_EOT_VERTEXSHADER = 0x6,
56     D3D10_EOT_PIXELSHADER = 0x7,
57     D3D10_EOT_GEOMETRYSHADER = 0x8,
58     D3D10_EOT_STENCIL_REF = 0x9,
59     D3D10_EOT_BLEND_FACTOR = 0xa,
60     D3D10_EOT_SAMPLE_MASK = 0xb,
61 };
62
63 enum d3d10_effect_object_operation
64 {
65     D3D10_EOO_VALUE = 1,
66     D3D10_EOO_PARSED_OBJECT = 2,
67     D3D10_EOO_PARSED_OBJECT_INDEX = 3,
68     D3D10_EOO_ANONYMOUS_SHADER = 7,
69 };
70
71 struct d3d10_effect_object
72 {
73     struct d3d10_effect_pass *pass;
74     enum d3d10_effect_object_type type;
75     union
76     {
77         ID3D10RasterizerState *rs;
78         ID3D10DepthStencilState *ds;
79         ID3D10BlendState *bs;
80         ID3D10VertexShader *vs;
81         ID3D10PixelShader *ps;
82         ID3D10GeometryShader *gs;
83     } object;
84 };
85
86 struct d3d10_effect_shader_signature
87 {
88     char *signature;
89     UINT signature_size;
90     UINT element_count;
91     D3D10_SIGNATURE_PARAMETER_DESC *elements;
92 };
93
94 struct d3d10_effect_shader_variable
95 {
96     struct d3d10_effect_shader_signature input_signature;
97     struct d3d10_effect_shader_signature output_signature;
98     union
99     {
100         ID3D10VertexShader *vs;
101         ID3D10PixelShader *ps;
102         ID3D10GeometryShader *gs;
103     } shader;
104 };
105
106 struct d3d10_effect_state_object_variable
107 {
108     union
109     {
110         D3D10_RASTERIZER_DESC rasterizer;
111         D3D10_DEPTH_STENCIL_DESC depth_stencil;
112         D3D10_BLEND_DESC blend;
113         D3D10_SAMPLER_DESC sampler;
114     } desc;
115     union
116     {
117         ID3D10RasterizerState *rasterizer;
118         ID3D10DepthStencilState *depth_stencil;
119         ID3D10BlendState *blend;
120         ID3D10SamplerState *sampler;
121     } object;
122 };
123
124 /* ID3D10EffectType */
125 struct d3d10_effect_type
126 {
127     ID3D10EffectType ID3D10EffectType_iface;
128
129     char *name;
130     D3D10_SHADER_VARIABLE_TYPE basetype;
131     D3D10_SHADER_VARIABLE_CLASS type_class;
132
133     DWORD id;
134     struct wine_rb_entry entry;
135     struct d3d10_effect *effect;
136
137     DWORD element_count;
138     DWORD size_unpacked;
139     DWORD stride;
140     DWORD size_packed;
141     DWORD member_count;
142     DWORD column_count;
143     DWORD row_count;
144     struct d3d10_effect_type *elementtype;
145     struct d3d10_effect_type_member *members;
146 };
147
148 struct d3d10_effect_type_member
149 {
150     char *name;
151     char *semantic;
152     DWORD buffer_offset;
153     struct d3d10_effect_type *type;
154 };
155
156 /* ID3D10EffectVariable */
157 struct d3d10_effect_variable
158 {
159     ID3D10EffectVariable ID3D10EffectVariable_iface;
160
161     struct d3d10_effect_variable *buffer;
162     struct d3d10_effect_type *type;
163
164     char *name;
165     char *semantic;
166     DWORD buffer_offset;
167     DWORD annotation_count;
168     DWORD flag;
169     DWORD data_size;
170     struct d3d10_effect *effect;
171     struct d3d10_effect_variable *elements;
172     struct d3d10_effect_variable *members;
173     struct d3d10_effect_variable *annotations;
174
175     union
176     {
177         struct d3d10_effect_state_object_variable state;
178         struct d3d10_effect_shader_variable shader;
179     } u;
180 };
181
182 /* ID3D10EffectPass */
183 struct d3d10_effect_pass
184 {
185     ID3D10EffectPass ID3D10EffectPass_iface;
186
187     struct d3d10_effect_technique *technique;
188     char *name;
189     DWORD start;
190     DWORD object_count;
191     DWORD annotation_count;
192     struct d3d10_effect_object *objects;
193     struct d3d10_effect_variable *annotations;
194
195     D3D10_PASS_SHADER_DESC vs;
196     D3D10_PASS_SHADER_DESC ps;
197     D3D10_PASS_SHADER_DESC gs;
198     UINT stencil_ref;
199     UINT sample_mask;
200     float blend_factor[4];
201 };
202
203 /* ID3D10EffectTechnique */
204 struct d3d10_effect_technique
205 {
206     ID3D10EffectTechnique ID3D10EffectTechnique_iface;
207
208     struct d3d10_effect *effect;
209     char *name;
210     DWORD pass_count;
211     DWORD annotation_count;
212     struct d3d10_effect_pass *passes;
213     struct d3d10_effect_variable *annotations;
214 };
215
216 struct d3d10_effect_anonymous_shader
217 {
218     struct d3d10_effect_variable shader;
219     struct d3d10_effect_type type;
220 };
221
222 /* ID3D10Effect */
223 extern const struct ID3D10EffectVtbl d3d10_effect_vtbl DECLSPEC_HIDDEN;
224 struct d3d10_effect
225 {
226     ID3D10Effect ID3D10Effect_iface;
227     LONG refcount;
228
229     ID3D10Device *device;
230     DWORD version;
231     DWORD local_buffer_count;
232     DWORD variable_count;
233     DWORD local_variable_count;
234     DWORD sharedbuffers_count;
235     DWORD sharedobjects_count;
236     DWORD technique_count;
237     DWORD index_offset;
238     DWORD texture_count;
239     DWORD dephstencilstate_count;
240     DWORD blendstate_count;
241     DWORD rasterizerstate_count;
242     DWORD samplerstate_count;
243     DWORD rendertargetview_count;
244     DWORD depthstencilview_count;
245     DWORD used_shader_count;
246     DWORD anonymous_shader_count;
247
248     DWORD used_shader_current;
249     DWORD anonymous_shader_current;
250
251     struct wine_rb_tree types;
252     struct d3d10_effect_variable *local_buffers;
253     struct d3d10_effect_variable *local_variables;
254     struct d3d10_effect_anonymous_shader *anonymous_shaders;
255     struct d3d10_effect_variable **used_shaders;
256     struct d3d10_effect_technique *techniques;
257 };
258
259 /* ID3D10ShaderReflection */
260 extern const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl DECLSPEC_HIDDEN;
261 struct d3d10_shader_reflection
262 {
263     ID3D10ShaderReflection ID3D10ShaderReflection_iface;
264     LONG refcount;
265 };
266
267 HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T data_size) DECLSPEC_HIDDEN;
268
269 /* D3D10Core */
270 HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter,
271         UINT flags, void *unknown0, ID3D10Device **device);
272
273 #define MAKE_TAG(ch0, ch1, ch2, ch3) \
274     ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
275     ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
276 #define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
277 #define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
278 #define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N')
279 #define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N')
280 #define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R')
281
282 HRESULT parse_dxbc(const char *data, SIZE_T data_size,
283         HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN;
284
285 static inline void read_dword(const char **ptr, DWORD *d)
286 {
287     memcpy(d, *ptr, sizeof(*d));
288     *ptr += sizeof(*d);
289 }
290
291 static inline void write_dword(char **ptr, DWORD d)
292 {
293     memcpy(*ptr, &d, sizeof(d));
294     *ptr += sizeof(d);
295 }
296
297 void skip_dword_unknown(const char *location, const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
298 void write_dword_unknown(char **ptr, DWORD d) DECLSPEC_HIDDEN;
299
300 #endif /* __WINE_D3D10_PRIVATE_H */