wined3d: CMP supports _SAT.
[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
45 void *d3d10_rb_alloc(size_t size) DECLSPEC_HIDDEN;
46 void *d3d10_rb_realloc(void *ptr, size_t size) DECLSPEC_HIDDEN;
47 void d3d10_rb_free(void *ptr) DECLSPEC_HIDDEN;
48
49 enum d3d10_effect_object_type
50 {
51     D3D10_EOT_VERTEXSHADER = 6,
52     D3D10_EOT_PIXELSHADER = 7,
53     D3D10_EOT_GEOMETRYSHADER = 8,
54 };
55
56 enum d3d10_effect_object_operation
57 {
58     D3D10_EOO_VALUE = 1,
59     D3D10_EOO_PARSED_OBJECT = 2,
60     D3D10_EOO_PARSED_OBJECT_INDEX = 3,
61     D3D10_EOO_ANONYMOUS_SHADER = 7,
62 };
63
64 struct d3d10_effect_object
65 {
66     struct d3d10_effect_pass *pass;
67     enum d3d10_effect_object_type type;
68     DWORD idx_offset;
69     DWORD index;
70     void *data;
71 };
72
73 struct d3d10_effect_shader_signature
74 {
75     char *signature;
76     UINT signature_size;
77     UINT element_count;
78     D3D10_SIGNATURE_PARAMETER_DESC *elements;
79 };
80
81 struct d3d10_effect_shader_variable
82 {
83     struct d3d10_effect_shader_signature input_signature;
84     struct d3d10_effect_shader_signature output_signature;
85     union
86     {
87         ID3D10VertexShader *vs;
88         ID3D10PixelShader *ps;
89         ID3D10GeometryShader *gs;
90     } shader;
91 };
92
93 /* ID3D10EffectType */
94 struct d3d10_effect_type
95 {
96     const struct ID3D10EffectTypeVtbl *vtbl;
97
98     char *name;
99     D3D10_SHADER_VARIABLE_TYPE basetype;
100     D3D10_SHADER_VARIABLE_CLASS type_class;
101
102     DWORD id;
103     struct wine_rb_entry entry;
104     struct d3d10_effect *effect;
105
106     DWORD element_count;
107     DWORD size_unpacked;
108     DWORD stride;
109     DWORD size_packed;
110     DWORD member_count;
111     DWORD column_count;
112     DWORD row_count;
113     struct d3d10_effect_type *elementtype;
114     struct d3d10_effect_type_member *members;
115 };
116
117 struct d3d10_effect_type_member
118 {
119     char *name;
120     char *semantic;
121     DWORD buffer_offset;
122     struct d3d10_effect_type *type;
123 };
124
125 /* ID3D10EffectVariable */
126 struct d3d10_effect_variable
127 {
128     const struct ID3D10EffectVariableVtbl *vtbl;
129
130     struct d3d10_effect_variable *buffer;
131     struct d3d10_effect_type *type;
132
133     void *data;
134     char *name;
135     char *semantic;
136     DWORD buffer_offset;
137     DWORD annotation_count;
138     DWORD flag;
139     DWORD data_size;
140     struct d3d10_effect *effect;
141     struct d3d10_effect_variable *elements;
142     struct d3d10_effect_variable *members;
143     struct d3d10_effect_variable *annotations;
144 };
145
146 /* ID3D10EffectPass */
147 struct d3d10_effect_pass
148 {
149     const struct ID3D10EffectPassVtbl *vtbl;
150
151     struct d3d10_effect_technique *technique;
152     char *name;
153     DWORD start;
154     DWORD object_count;
155     DWORD annotation_count;
156     struct d3d10_effect_object *objects;
157     struct d3d10_effect_variable *annotations;
158 };
159
160 /* ID3D10EffectTechnique */
161 struct d3d10_effect_technique
162 {
163     const struct ID3D10EffectTechniqueVtbl *vtbl;
164
165     struct d3d10_effect *effect;
166     char *name;
167     DWORD pass_count;
168     DWORD annotation_count;
169     struct d3d10_effect_pass *passes;
170     struct d3d10_effect_variable *annotations;
171 };
172
173 struct d3d10_effect_anonymous_shader
174 {
175     struct d3d10_effect_variable shader;
176     struct d3d10_effect_type type;
177 };
178
179 /* ID3D10Effect */
180 extern const struct ID3D10EffectVtbl d3d10_effect_vtbl DECLSPEC_HIDDEN;
181 struct d3d10_effect
182 {
183     const struct ID3D10EffectVtbl *vtbl;
184     LONG refcount;
185
186     ID3D10Device *device;
187     DWORD version;
188     DWORD local_buffer_count;
189     DWORD variable_count;
190     DWORD local_variable_count;
191     DWORD sharedbuffers_count;
192     DWORD sharedobjects_count;
193     DWORD technique_count;
194     DWORD index_offset;
195     DWORD texture_count;
196     DWORD dephstencilstate_count;
197     DWORD blendstate_count;
198     DWORD rasterizerstate_count;
199     DWORD samplerstate_count;
200     DWORD rendertargetview_count;
201     DWORD depthstencilview_count;
202     DWORD used_shader_count;
203     DWORD anonymous_shader_count;
204
205     DWORD used_shader_current;
206     DWORD anonymous_shader_current;
207
208     struct wine_rb_tree types;
209     struct d3d10_effect_variable *local_buffers;
210     struct d3d10_effect_variable *local_variables;
211     struct d3d10_effect_anonymous_shader *anonymous_shaders;
212     struct d3d10_effect_variable **used_shaders;
213     struct d3d10_effect_technique *techniques;
214 };
215
216 /* ID3D10ShaderReflection */
217 extern const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl DECLSPEC_HIDDEN;
218 struct d3d10_shader_reflection
219 {
220     const struct ID3D10ShaderReflectionVtbl *vtbl;
221     LONG refcount;
222 };
223
224 HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T data_size) DECLSPEC_HIDDEN;
225
226 /* D3D10Core */
227 HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter,
228         UINT flags, void *unknown0, ID3D10Device **device);
229
230 #define MAKE_TAG(ch0, ch1, ch2, ch3) \
231     ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
232     ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
233 #define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
234 #define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
235 #define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N')
236 #define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N')
237 #define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R')
238
239 HRESULT parse_dxbc(const char *data, SIZE_T data_size,
240         HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN;
241
242 static inline void read_dword(const char **ptr, DWORD *d)
243 {
244     memcpy(d, *ptr, sizeof(*d));
245     *ptr += sizeof(*d);
246 }
247
248 static inline void write_dword(char **ptr, DWORD d)
249 {
250     memcpy(*ptr, &d, sizeof(d));
251     *ptr += sizeof(d);
252 }
253
254 void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
255 void write_dword_unknown(char **ptr, DWORD d) DECLSPEC_HIDDEN;
256
257 #endif /* __WINE_D3D10_PRIVATE_H */