gdi32: Add support for 24 bpp dibs.
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blob0e3ecf394aa12ef34ea9ffbec380a19665d67e98
1 /*
2 * Copyright 2010 Christian Costa
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.
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.
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
19 #include "config.h"
20 #include "wine/port.h"
21 #include "wine/debug.h"
22 #include "wine/unicode.h"
23 #include "windef.h"
24 #include "wingdi.h"
25 #include "d3dx9_36_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
29 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
30 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
31 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
33 enum STATE_CLASS
35 SC_LIGHTENABLE,
36 SC_FVF,
37 SC_LIGHT,
38 SC_MATERIAL,
39 SC_NPATCHMODE,
40 SC_PIXELSHADER,
41 SC_RENDERSTATE,
42 SC_SETSAMPLER,
43 SC_SAMPLERSTATE,
44 SC_TEXTURE,
45 SC_TEXTURESTAGE,
46 SC_TRANSFORM,
47 SC_VERTEXSHADER,
48 SC_SHADERCONST,
49 SC_UNKNOWN,
52 enum MATERIAL_TYPE
54 MT_DIFFUSE,
55 MT_AMBIENT,
56 MT_SPECULAR,
57 MT_EMISSIVE,
58 MT_POWER,
61 enum LIGHT_TYPE
63 LT_TYPE,
64 LT_DIFFUSE,
65 LT_SPECULAR,
66 LT_AMBIENT,
67 LT_POSITION,
68 LT_DIRECTION,
69 LT_RANGE,
70 LT_FALLOFF,
71 LT_ATTENUATION0,
72 LT_ATTENUATION1,
73 LT_ATTENUATION2,
74 LT_THETA,
75 LT_PHI,
78 enum SHADER_CONSTANT_TYPE
80 SCT_VSFLOAT,
81 SCT_VSBOOL,
82 SCT_VSINT,
83 SCT_PSFLOAT,
84 SCT_PSBOOL,
85 SCT_PSINT,
88 struct d3dx_parameter
90 char *name;
91 char *semantic;
92 void *data;
93 D3DXPARAMETER_CLASS class;
94 D3DXPARAMETER_TYPE type;
95 UINT rows;
96 UINT columns;
97 UINT element_count;
98 UINT annotation_count;
99 UINT member_count;
100 DWORD flags;
101 UINT bytes;
103 D3DXHANDLE *annotation_handles;
104 D3DXHANDLE *member_handles;
107 struct d3dx_state
109 UINT operation;
110 UINT index;
112 D3DXHANDLE parameter;
115 struct d3dx_pass
117 char *name;
118 UINT state_count;
119 UINT annotation_count;
121 struct d3dx_state *states;
122 D3DXHANDLE *annotation_handles;
125 struct d3dx_technique
127 char *name;
128 UINT pass_count;
129 UINT annotation_count;
131 D3DXHANDLE *annotation_handles;
132 D3DXHANDLE *pass_handles;
135 struct ID3DXBaseEffectImpl
137 ID3DXBaseEffect ID3DXBaseEffect_iface;
138 LONG ref;
140 struct ID3DXEffectImpl *effect;
142 UINT parameter_count;
143 UINT technique_count;
145 D3DXHANDLE *parameter_handles;
146 D3DXHANDLE *technique_handles;
149 struct ID3DXEffectImpl
151 ID3DXEffect ID3DXEffect_iface;
152 LONG ref;
154 LPD3DXEFFECTSTATEMANAGER manager;
155 LPDIRECT3DDEVICE9 device;
156 LPD3DXEFFECTPOOL pool;
158 ID3DXBaseEffect *base_effect;
161 struct ID3DXEffectCompilerImpl
163 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
164 LONG ref;
166 ID3DXBaseEffect *base_effect;
169 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
170 struct d3dx_parameter *parameter, LPCSTR name);
171 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
173 static const struct
175 enum STATE_CLASS class;
176 UINT op;
177 LPCSTR name;
179 state_table[] =
181 /* Render sates */
182 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
183 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
184 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
185 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
186 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
187 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
188 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
189 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
190 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
191 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
192 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
193 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
194 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
195 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
196 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
197 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
198 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
199 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
200 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
201 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
202 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
203 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
204 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
205 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
206 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
207 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
208 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
209 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
210 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
211 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
212 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
213 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
214 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
215 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
216 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
217 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
218 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
219 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
220 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
221 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
222 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
223 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
224 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
225 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
226 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
227 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
228 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
229 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
230 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
231 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
232 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
233 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
234 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
235 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
236 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
237 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
238 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
239 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
240 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
241 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
242 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
243 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
244 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
245 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
246 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
247 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
248 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
249 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
250 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
251 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
252 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
253 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
254 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
255 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
256 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
257 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
258 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
259 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
260 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
261 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
262 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
263 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
264 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
265 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
266 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
267 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
268 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
269 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
270 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
271 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
272 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
273 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
274 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
275 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
276 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
277 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
278 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
279 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
280 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
281 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
282 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
283 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
284 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
285 /* Texture stages */
286 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
287 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
288 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
289 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
290 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
291 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
292 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
293 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
294 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
295 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
296 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
297 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
298 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
299 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
300 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
301 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
302 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
303 /* */
304 {SC_UNKNOWN, 0, "UNKNOWN"},
305 /* NPatchMode */
306 {SC_NPATCHMODE, 0, "NPatchMode"},
307 /* */
308 {SC_UNKNOWN, 0, "UNKNOWN"},
309 /* Transform */
310 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
311 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
312 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
313 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
314 /* Material */
315 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
316 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
317 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
318 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
319 {SC_MATERIAL, MT_POWER, "MaterialPower"},
320 /* Light */
321 {SC_LIGHT, LT_TYPE, "LightType"},
322 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
323 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
324 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
325 {SC_LIGHT, LT_POSITION, "LightPosition"},
326 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
327 {SC_LIGHT, LT_RANGE, "LighRange"},
328 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
329 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
330 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
331 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
332 {SC_LIGHT, LT_THETA, "LightTheta"},
333 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
334 /* Ligthenable */
335 {SC_LIGHTENABLE, 0, "LightEnable"},
336 /* Vertexshader */
337 {SC_VERTEXSHADER, 0, "Vertexshader"},
338 /* Pixelshader */
339 {SC_PIXELSHADER, 0, "Pixelshader"},
340 /* Shader constants */
341 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
342 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
343 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
344 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
345 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
346 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
347 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
348 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
349 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
350 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
351 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
352 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
353 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
354 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
355 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
356 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
357 /* Texture */
358 {SC_TEXTURE, 0, "Texture"},
359 /* Sampler states */
360 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
361 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
362 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
363 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
364 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
365 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
366 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
367 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
368 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
369 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
370 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
371 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
372 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
373 /* Set sampler */
374 {SC_SETSAMPLER, 0, "Sampler"},
377 static inline void read_dword(const char **ptr, DWORD *d)
379 memcpy(d, *ptr, sizeof(*d));
380 *ptr += sizeof(*d);
383 static void skip_dword_unknown(const char **ptr, unsigned int count)
385 unsigned int i;
386 DWORD d;
388 FIXME("Skipping %u unknown DWORDs:\n", count);
389 for (i = 0; i < count; ++i)
391 read_dword(ptr, &d);
392 FIXME("\t0x%08x\n", d);
396 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
398 return (struct d3dx_parameter *) handle;
401 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
403 return (struct d3dx_pass *) handle;
406 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
408 return (struct d3dx_technique *) handle;
411 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
413 return (D3DXHANDLE) parameter;
416 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
418 return (D3DXHANDLE) technique;
421 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
423 return (D3DXHANDLE) pass;
426 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
428 unsigned int i;
430 for (i = 0; i < base->technique_count; ++i)
432 if (base->technique_handles[i] == technique)
434 return get_technique_struct(technique);
438 return NULL;
441 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
443 unsigned int i, k;
445 for (i = 0; i < base->technique_count; ++i)
447 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
449 for (k = 0; k < technique->pass_count; ++k)
451 if (technique->pass_handles[k] == pass)
453 return get_pass_struct(pass);
458 return NULL;
461 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
463 unsigned int i, count;
464 struct d3dx_parameter *p;
466 for (i = 0; i < param->annotation_count; ++i)
468 if (param->annotation_handles[i] == parameter)
470 return get_parameter_struct(parameter);
473 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
474 if (p) return p;
477 if (param->element_count) count = param->element_count;
478 else count = param->member_count;
480 for (i = 0; i < count; ++i)
482 if (param->member_handles[i] == parameter)
484 return get_parameter_struct(parameter);
487 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
488 if (p) return p;
491 return NULL;
494 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
496 unsigned int i, k, m;
497 struct d3dx_parameter *p;
499 for (i = 0; i < base->parameter_count; ++i)
501 if (base->parameter_handles[i] == parameter)
503 return get_parameter_struct(parameter);
506 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
507 if (p) return p;
510 for (i = 0; i < base->technique_count; ++i)
512 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
514 for (k = 0; k < technique->pass_count; ++k)
516 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
518 for (m = 0; m < pass->annotation_count; ++m)
520 if (pass->annotation_handles[i] == parameter)
522 return get_parameter_struct(parameter);
525 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
526 if (p) return p;
530 for (k = 0; k < technique->annotation_count; ++k)
532 if (technique->annotation_handles[k] == parameter)
534 return get_parameter_struct(parameter);
537 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
538 if (p) return p;
542 return NULL;
545 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
547 unsigned int i;
548 struct d3dx_parameter *param = get_parameter_struct(handle);
550 TRACE("Free parameter %p, child %s\n", param, child ? "yes" : "no");
552 if (!param)
554 return;
557 if (param->annotation_handles)
559 for (i = 0; i < param->annotation_count; ++i)
561 free_parameter(param->annotation_handles[i], FALSE, FALSE);
563 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
566 if (param->member_handles)
568 unsigned int count;
570 if (param->element_count) count = param->element_count;
571 else count = param->member_count;
573 for (i = 0; i < count; ++i)
575 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
577 HeapFree(GetProcessHeap(), 0, param->member_handles);
580 if (param->class == D3DXPC_OBJECT && !param->element_count)
582 switch (param->type)
584 case D3DXPT_STRING:
585 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
586 break;
588 case D3DXPT_TEXTURE:
589 case D3DXPT_TEXTURE1D:
590 case D3DXPT_TEXTURE2D:
591 case D3DXPT_TEXTURE3D:
592 case D3DXPT_TEXTURECUBE:
593 case D3DXPT_PIXELSHADER:
594 case D3DXPT_VERTEXSHADER:
595 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
596 break;
598 case D3DXPT_SAMPLER:
599 case D3DXPT_SAMPLER1D:
600 case D3DXPT_SAMPLER2D:
601 case D3DXPT_SAMPLER3D:
602 case D3DXPT_SAMPLERCUBE:
603 /* Todo: free sampler */
604 break;
606 default:
607 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
608 break;
612 if (!child)
614 HeapFree(GetProcessHeap(), 0, param->data);
617 /* only the parent has to release name and semantic */
618 if (!element)
620 HeapFree(GetProcessHeap(), 0, param->name);
621 HeapFree(GetProcessHeap(), 0, param->semantic);
624 HeapFree(GetProcessHeap(), 0, param);
627 static void free_state(struct d3dx_state *state)
629 free_parameter(state->parameter, FALSE, FALSE);
632 static void free_pass(D3DXHANDLE handle)
634 unsigned int i;
635 struct d3dx_pass *pass = get_pass_struct(handle);
637 TRACE("Free pass %p\n", pass);
639 if (!pass)
641 return;
644 if (pass->annotation_handles)
646 for (i = 0; i < pass->annotation_count; ++i)
648 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
650 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
653 if (pass->states)
655 for (i = 0; i < pass->state_count; ++i)
657 free_state(&pass->states[i]);
659 HeapFree(GetProcessHeap(), 0, pass->states);
662 HeapFree(GetProcessHeap(), 0, pass->name);
663 HeapFree(GetProcessHeap(), 0, pass);
666 static void free_technique(D3DXHANDLE handle)
668 unsigned int i;
669 struct d3dx_technique *technique = get_technique_struct(handle);
671 TRACE("Free technique %p\n", technique);
673 if (!technique)
675 return;
678 if (technique->annotation_handles)
680 for (i = 0; i < technique->annotation_count; ++i)
682 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
684 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
687 if (technique->pass_handles)
689 for (i = 0; i < technique->pass_count; ++i)
691 free_pass(technique->pass_handles[i]);
693 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
696 HeapFree(GetProcessHeap(), 0, technique->name);
697 HeapFree(GetProcessHeap(), 0, technique);
700 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
702 unsigned int i;
704 TRACE("Free base effect %p\n", base);
706 if (base->parameter_handles)
708 for (i = 0; i < base->parameter_count; ++i)
710 free_parameter(base->parameter_handles[i], FALSE, FALSE);
712 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
715 if (base->technique_handles)
717 for (i = 0; i < base->technique_count; ++i)
719 free_technique(base->technique_handles[i]);
721 HeapFree(GetProcessHeap(), 0, base->technique_handles);
725 static void free_effect(struct ID3DXEffectImpl *effect)
727 TRACE("Free effect %p\n", effect);
729 if (effect->base_effect)
731 effect->base_effect->lpVtbl->Release(effect->base_effect);
734 if (effect->pool)
736 effect->pool->lpVtbl->Release(effect->pool);
739 if (effect->manager)
741 IUnknown_Release(effect->manager);
744 IDirect3DDevice9_Release(effect->device);
747 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
749 TRACE("Free effect compiler %p\n", compiler);
751 if (compiler->base_effect)
753 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
757 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
759 INT i;
761 switch (type)
763 case D3DXPT_FLOAT:
764 i = *(FLOAT *)data;
765 break;
767 case D3DXPT_INT:
768 i = *(INT *)data;
769 break;
771 case D3DXPT_BOOL:
772 i = *(BOOL *)data;
773 break;
775 default:
776 i = 0;
777 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
778 break;
781 return i;
784 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
786 FLOAT f;
788 switch (type)
790 case D3DXPT_FLOAT:
791 f = *(FLOAT *)data;
792 break;
794 case D3DXPT_INT:
795 f = *(INT *)data;
796 break;
798 case D3DXPT_BOOL:
799 f = *(BOOL *)data;
800 break;
802 default:
803 f = 0.0f;
804 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
805 break;
808 return f;
811 static inline BOOL get_bool(void *data)
813 return (*(DWORD *)data) ? TRUE : FALSE;
816 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
818 UINT element;
819 struct d3dx_parameter *temp_parameter;
820 LPCSTR part;
822 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
824 if (!name || !*name) return parameter;
826 element = atoi(name);
827 part = strchr(name, ']') + 1;
829 if (parameter->element_count > element)
831 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
833 switch (*part++)
835 case '.':
836 return get_parameter_by_name(NULL, temp_parameter, part);
838 case '@':
839 return get_parameter_annotation_by_name(temp_parameter, part);
841 case '\0':
842 TRACE("Returning parameter %p\n", temp_parameter);
843 return temp_parameter;
845 default:
846 FIXME("Unhandled case \"%c\"\n", *--part);
847 break;
851 TRACE("Parameter not found\n");
852 return NULL;
855 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
857 UINT i, length;
858 struct d3dx_parameter *temp_parameter;
859 LPCSTR part;
861 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
863 if (!name || !*name) return parameter;
865 length = strcspn( name, "[.@" );
866 part = name + length;
868 for (i = 0; i < parameter->annotation_count; ++i)
870 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
872 if (!strcmp(temp_parameter->name, name))
874 TRACE("Returning parameter %p\n", temp_parameter);
875 return temp_parameter;
877 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
879 switch (*part++)
881 case '.':
882 return get_parameter_by_name(NULL, temp_parameter, part);
884 case '[':
885 return get_parameter_element_by_name(temp_parameter, part);
887 default:
888 FIXME("Unhandled case \"%c\"\n", *--part);
889 break;
894 TRACE("Parameter not found\n");
895 return NULL;
898 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
899 struct d3dx_parameter *parameter, LPCSTR name)
901 UINT i, count, length;
902 struct d3dx_parameter *temp_parameter;
903 D3DXHANDLE *handles;
904 LPCSTR part;
906 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
908 if (!name || !*name) return parameter;
910 if (!parameter)
912 count = base->parameter_count;
913 handles = base->parameter_handles;
915 else
917 count = parameter->member_count;
918 handles = parameter->member_handles;
921 length = strcspn( name, "[.@" );
922 part = name + length;
924 for (i = 0; i < count; i++)
926 temp_parameter = get_parameter_struct(handles[i]);
928 if (!strcmp(temp_parameter->name, name))
930 TRACE("Returning parameter %p\n", temp_parameter);
931 return temp_parameter;
933 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
935 switch (*part++)
937 case '.':
938 return get_parameter_by_name(NULL, temp_parameter, part);
940 case '@':
941 return get_parameter_annotation_by_name(temp_parameter, part);
943 case '[':
944 return get_parameter_element_by_name(temp_parameter, part);
946 default:
947 FIXME("Unhandled case \"%c\"\n", *--part);
948 break;
953 TRACE("Parameter not found\n");
954 return NULL;
957 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
959 return (0xfeff0000 | ((major) << 8) | (minor));
962 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
964 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
967 /*** IUnknown methods ***/
968 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
970 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
972 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
974 if (IsEqualGUID(riid, &IID_IUnknown) ||
975 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
977 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
978 *object = This;
979 return S_OK;
982 ERR("Interface %s not found\n", debugstr_guid(riid));
984 return E_NOINTERFACE;
987 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
989 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
991 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
993 return InterlockedIncrement(&This->ref);
996 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
998 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
999 ULONG ref = InterlockedDecrement(&This->ref);
1001 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1003 if (!ref)
1005 free_base_effect(This);
1006 HeapFree(GetProcessHeap(), 0, This);
1009 return ref;
1012 /*** ID3DXBaseEffect methods ***/
1013 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1015 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1017 FIXME("iface %p, desc %p partial stub\n", This, desc);
1019 if (!desc)
1021 WARN("Invalid argument specified.\n");
1022 return D3DERR_INVALIDCALL;
1025 /* Todo: add creator and function count */
1026 desc->Creator = NULL;
1027 desc->Functions = 0;
1028 desc->Parameters = This->parameter_count;
1029 desc->Techniques = This->technique_count;
1031 return D3D_OK;
1034 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1036 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1037 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1039 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1041 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
1043 if (!desc || !param)
1045 WARN("Invalid argument specified.\n");
1046 return D3DERR_INVALIDCALL;
1049 desc->Name = param->name;
1050 desc->Semantic = param->semantic;
1051 desc->Class = param->class;
1052 desc->Type = param->type;
1053 desc->Rows = param->rows;
1054 desc->Columns = param->columns;
1055 desc->Elements = param->element_count;
1056 desc->Annotations = param->annotation_count;
1057 desc->StructMembers = param->member_count;
1058 desc->Flags = param->flags;
1059 desc->Bytes = param->bytes;
1061 return D3D_OK;
1064 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1066 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1067 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1069 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1071 if (!desc || !tech)
1073 WARN("Invalid argument specified.\n");
1074 return D3DERR_INVALIDCALL;
1077 desc->Name = tech->name;
1078 desc->Passes = tech->pass_count;
1079 desc->Annotations = tech->annotation_count;
1081 return D3D_OK;
1084 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1086 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1087 struct d3dx_pass *p = is_valid_pass(This, pass);
1089 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1091 if (!desc || !p)
1093 WARN("Invalid argument specified.\n");
1094 return D3DERR_INVALIDCALL;
1097 desc->Name = p->name;
1098 desc->Annotations = p->annotation_count;
1100 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1101 desc->pVertexShaderFunction = NULL;
1102 desc->pPixelShaderFunction = NULL;
1104 return D3D_OK;
1107 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1109 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1111 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1113 return E_NOTIMPL;
1116 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1118 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1119 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1121 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1123 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1125 if (!parameter)
1127 if (index < This->parameter_count)
1129 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1130 return This->parameter_handles[index];
1133 else
1135 if (param && !param->element_count && index < param->member_count)
1137 TRACE("Returning parameter %p\n", param->member_handles[index]);
1138 return param->member_handles[index];
1142 WARN("Invalid argument specified.\n");
1144 return NULL;
1147 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1149 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1150 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1151 D3DXHANDLE handle;
1153 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1155 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1157 if (!name)
1159 handle = get_parameter_handle(param);
1160 TRACE("Returning parameter %p\n", handle);
1161 return handle;
1164 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1165 TRACE("Returning parameter %p\n", handle);
1167 return handle;
1170 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1172 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1173 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1174 struct d3dx_parameter *temp_param;
1175 UINT i;
1177 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1179 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1181 if (!parameter)
1183 for (i = 0; i < This->parameter_count; ++i)
1185 temp_param = get_parameter_struct(This->parameter_handles[i]);
1187 if (!temp_param->semantic)
1189 if (!semantic)
1191 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1192 return This->parameter_handles[i];
1194 continue;
1197 if (!strcasecmp(temp_param->semantic, semantic))
1199 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1200 return This->parameter_handles[i];
1204 else if (param)
1206 for (i = 0; i < param->member_count; ++i)
1208 temp_param = get_parameter_struct(param->member_handles[i]);
1210 if (!temp_param->semantic)
1212 if (!semantic)
1214 TRACE("Returning parameter %p\n", param->member_handles[i]);
1215 return param->member_handles[i];
1217 continue;
1220 if (!strcasecmp(temp_param->semantic, semantic))
1222 TRACE("Returning parameter %p\n", param->member_handles[i]);
1223 return param->member_handles[i];
1228 WARN("Invalid argument specified\n");
1230 return NULL;
1233 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1235 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1236 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1238 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1240 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1242 if (!param)
1244 if (index < This->parameter_count)
1246 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1247 return This->parameter_handles[index];
1250 else
1252 if (index < param->element_count)
1254 TRACE("Returning parameter %p\n", param->member_handles[index]);
1255 return param->member_handles[index];
1259 WARN("Invalid argument specified\n");
1261 return NULL;
1264 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1266 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1268 TRACE("iface %p, index %u\n", This, index);
1270 if (index >= This->technique_count)
1272 WARN("Invalid argument specified.\n");
1273 return NULL;
1276 TRACE("Returning technique %p\n", This->technique_handles[index]);
1278 return This->technique_handles[index];
1281 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1283 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1284 unsigned int i;
1286 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1288 if (!name)
1290 WARN("Invalid argument specified.\n");
1291 return NULL;
1294 for (i = 0; i < This->technique_count; ++i)
1296 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1298 if (!strcmp(tech->name, name))
1300 TRACE("Returning technique %p\n", This->technique_handles[i]);
1301 return This->technique_handles[i];
1305 WARN("Invalid argument specified.\n");
1307 return NULL;
1310 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1312 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1313 struct d3dx_technique *tech = is_valid_technique(This, technique);
1315 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1317 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1319 if (tech && index < tech->pass_count)
1321 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1322 return tech->pass_handles[index];
1325 WARN("Invalid argument specified.\n");
1327 return NULL;
1330 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1332 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1333 struct d3dx_technique *tech = is_valid_technique(This, technique);
1335 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1337 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1339 if (tech && name)
1341 unsigned int i;
1343 for (i = 0; i < tech->pass_count; ++i)
1345 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1347 if (!strcmp(pass->name, name))
1349 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1350 return tech->pass_handles[i];
1355 WARN("Invalid argument specified.\n");
1357 return NULL;
1360 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1362 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1364 FIXME("iface %p, index %u stub\n", This, index);
1366 return NULL;
1369 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1371 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1373 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1375 return NULL;
1378 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1380 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1381 struct d3dx_parameter *param = is_valid_parameter(This, object);
1382 struct d3dx_pass *pass = is_valid_pass(This, object);
1383 struct d3dx_technique *technique = is_valid_technique(This, object);
1384 UINT annotation_count = 0;
1385 D3DXHANDLE *annotation_handles = NULL;
1387 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1389 if (pass)
1391 annotation_count = pass->annotation_count;
1392 annotation_handles = pass->annotation_handles;
1394 else if (technique)
1396 annotation_count = technique->annotation_count;
1397 annotation_handles = technique->annotation_handles;
1399 else
1401 if (!param) param = get_parameter_by_name(This, NULL, object);
1403 if (param)
1405 annotation_count = param->annotation_count;
1406 annotation_handles = param->annotation_handles;
1409 /* Todo: add funcs */
1411 if (index < annotation_count)
1413 TRACE("Returning parameter %p\n", annotation_handles[index]);
1414 return annotation_handles[index];
1417 WARN("Invalid argument specified\n");
1419 return NULL;
1422 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1424 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1425 struct d3dx_parameter *param = is_valid_parameter(This, object);
1426 struct d3dx_pass *pass = is_valid_pass(This, object);
1427 struct d3dx_technique *technique = is_valid_technique(This, object);
1428 UINT annotation_count = 0, i;
1429 D3DXHANDLE *annotation_handles = NULL;
1431 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1433 if (!name)
1435 WARN("Invalid argument specified\n");
1436 return NULL;
1439 if (pass)
1441 annotation_count = pass->annotation_count;
1442 annotation_handles = pass->annotation_handles;
1444 else if (technique)
1446 annotation_count = technique->annotation_count;
1447 annotation_handles = technique->annotation_handles;
1449 else
1451 if (!param) param = get_parameter_by_name(This, NULL, object);
1453 if (param)
1455 annotation_count = param->annotation_count;
1456 annotation_handles = param->annotation_handles;
1459 /* Todo: add funcs */
1461 for (i = 0; i < annotation_count; i++)
1463 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1465 if (!strcmp(anno->name, name))
1467 TRACE("Returning parameter %p\n", anno);
1468 return get_parameter_handle(anno);
1472 WARN("Invalid argument specified\n");
1474 return NULL;
1477 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1479 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1481 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1483 return E_NOTIMPL;
1486 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1488 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1489 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1491 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1493 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1495 /* samplers don't touch data */
1496 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1497 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1498 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1500 TRACE("Sampler: returning E_FAIL\n");
1501 return E_FAIL;
1504 if (data && param && param->bytes <= bytes)
1506 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1508 switch (param->type)
1510 case D3DXPT_VOID:
1511 case D3DXPT_BOOL:
1512 case D3DXPT_INT:
1513 case D3DXPT_FLOAT:
1514 case D3DXPT_STRING:
1515 break;
1517 case D3DXPT_VERTEXSHADER:
1518 case D3DXPT_PIXELSHADER:
1519 case D3DXPT_TEXTURE:
1520 case D3DXPT_TEXTURE1D:
1521 case D3DXPT_TEXTURE2D:
1522 case D3DXPT_TEXTURE3D:
1523 case D3DXPT_TEXTURECUBE:
1525 UINT i;
1527 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1529 IUnknown *unk = ((IUnknown **)param->data)[i];
1530 if (unk) IUnknown_AddRef(unk);
1532 break;
1535 default:
1536 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1537 break;
1540 TRACE("Copy %u bytes\n", param->bytes);
1541 memcpy(data, param->data, param->bytes);
1542 return D3D_OK;
1545 WARN("Invalid argument specified\n");
1547 return D3DERR_INVALIDCALL;
1550 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1552 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1554 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1556 return E_NOTIMPL;
1559 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1561 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1562 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1564 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1566 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1568 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1570 *b = get_bool(param->data);
1571 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1572 return D3D_OK;
1575 WARN("Invalid argument specified\n");
1577 return D3DERR_INVALIDCALL;
1580 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1582 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1584 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1586 return E_NOTIMPL;
1589 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1591 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1593 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1595 return E_NOTIMPL;
1598 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1600 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1602 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1604 return E_NOTIMPL;
1607 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1609 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1610 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1612 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1614 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1616 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1618 *n = get_int(param->type, param->data);
1619 TRACE("Returning %i\n", *n);
1620 return D3D_OK;
1623 WARN("Invalid argument specified\n");
1625 return D3DERR_INVALIDCALL;
1628 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1630 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1632 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1634 return E_NOTIMPL;
1637 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1639 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1641 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1643 return E_NOTIMPL;
1646 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1648 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1650 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1652 return E_NOTIMPL;
1655 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1657 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1658 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1660 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1662 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1664 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1666 f = param->data;
1667 TRACE("Returning %f\n", *f);
1668 return D3D_OK;
1671 WARN("Invalid argument specified\n");
1673 return D3DERR_INVALIDCALL;
1676 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1678 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1680 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1682 return E_NOTIMPL;
1685 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1687 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1689 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1691 return E_NOTIMPL;
1694 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1696 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1698 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1700 return E_NOTIMPL;
1703 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1705 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1707 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1709 return E_NOTIMPL;
1712 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1714 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1716 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1718 return E_NOTIMPL;
1721 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1723 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1725 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1727 return E_NOTIMPL;
1730 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1732 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1734 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1736 return E_NOTIMPL;
1739 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1741 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1743 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1745 return E_NOTIMPL;
1748 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1750 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1752 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1754 return E_NOTIMPL;
1757 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1759 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1761 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1763 return E_NOTIMPL;
1766 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1768 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1770 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1772 return E_NOTIMPL;
1775 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1777 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1779 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1781 return E_NOTIMPL;
1784 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1786 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1788 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1790 return E_NOTIMPL;
1793 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1795 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1797 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1799 return E_NOTIMPL;
1802 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1804 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1806 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1808 return E_NOTIMPL;
1811 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1813 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1815 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1817 return E_NOTIMPL;
1820 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1822 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1824 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1826 return E_NOTIMPL;
1829 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1831 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1833 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1835 return E_NOTIMPL;
1838 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1840 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1842 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1844 return E_NOTIMPL;
1847 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1849 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1850 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1852 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1854 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1856 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1858 *string = *(LPCSTR *)param->data;
1859 TRACE("Returning %s\n", debugstr_a(*string));
1860 return D3D_OK;
1863 WARN("Invalid argument specified\n");
1865 return D3DERR_INVALIDCALL;
1868 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1870 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1872 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1874 return E_NOTIMPL;
1877 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
1879 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1880 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1882 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
1884 if (texture && param && !param->element_count &&
1885 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
1886 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
1887 || param->type == D3DXPT_TEXTURECUBE))
1889 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
1890 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
1891 TRACE("Returning %p\n", *texture);
1892 return D3D_OK;
1895 WARN("Invalid argument specified\n");
1897 return D3DERR_INVALIDCALL;
1900 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
1902 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1903 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1905 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
1907 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1909 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
1911 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
1912 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
1913 TRACE("Returning %p\n", *pshader);
1914 return D3D_OK;
1917 WARN("Invalid argument specified\n");
1919 return D3DERR_INVALIDCALL;
1922 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
1924 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1925 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1927 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
1929 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1931 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
1933 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
1934 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
1935 TRACE("Returning %p\n", *vshader);
1936 return D3D_OK;
1939 WARN("Invalid argument specified\n");
1941 return D3DERR_INVALIDCALL;
1944 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
1946 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1948 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
1950 return E_NOTIMPL;
1953 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
1955 /*** IUnknown methods ***/
1956 ID3DXBaseEffectImpl_QueryInterface,
1957 ID3DXBaseEffectImpl_AddRef,
1958 ID3DXBaseEffectImpl_Release,
1959 /*** ID3DXBaseEffect methods ***/
1960 ID3DXBaseEffectImpl_GetDesc,
1961 ID3DXBaseEffectImpl_GetParameterDesc,
1962 ID3DXBaseEffectImpl_GetTechniqueDesc,
1963 ID3DXBaseEffectImpl_GetPassDesc,
1964 ID3DXBaseEffectImpl_GetFunctionDesc,
1965 ID3DXBaseEffectImpl_GetParameter,
1966 ID3DXBaseEffectImpl_GetParameterByName,
1967 ID3DXBaseEffectImpl_GetParameterBySemantic,
1968 ID3DXBaseEffectImpl_GetParameterElement,
1969 ID3DXBaseEffectImpl_GetTechnique,
1970 ID3DXBaseEffectImpl_GetTechniqueByName,
1971 ID3DXBaseEffectImpl_GetPass,
1972 ID3DXBaseEffectImpl_GetPassByName,
1973 ID3DXBaseEffectImpl_GetFunction,
1974 ID3DXBaseEffectImpl_GetFunctionByName,
1975 ID3DXBaseEffectImpl_GetAnnotation,
1976 ID3DXBaseEffectImpl_GetAnnotationByName,
1977 ID3DXBaseEffectImpl_SetValue,
1978 ID3DXBaseEffectImpl_GetValue,
1979 ID3DXBaseEffectImpl_SetBool,
1980 ID3DXBaseEffectImpl_GetBool,
1981 ID3DXBaseEffectImpl_SetBoolArray,
1982 ID3DXBaseEffectImpl_GetBoolArray,
1983 ID3DXBaseEffectImpl_SetInt,
1984 ID3DXBaseEffectImpl_GetInt,
1985 ID3DXBaseEffectImpl_SetIntArray,
1986 ID3DXBaseEffectImpl_GetIntArray,
1987 ID3DXBaseEffectImpl_SetFloat,
1988 ID3DXBaseEffectImpl_GetFloat,
1989 ID3DXBaseEffectImpl_SetFloatArray,
1990 ID3DXBaseEffectImpl_GetFloatArray,
1991 ID3DXBaseEffectImpl_SetVector,
1992 ID3DXBaseEffectImpl_GetVector,
1993 ID3DXBaseEffectImpl_SetVectorArray,
1994 ID3DXBaseEffectImpl_GetVectorArray,
1995 ID3DXBaseEffectImpl_SetMatrix,
1996 ID3DXBaseEffectImpl_GetMatrix,
1997 ID3DXBaseEffectImpl_SetMatrixArray,
1998 ID3DXBaseEffectImpl_GetMatrixArray,
1999 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2000 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2001 ID3DXBaseEffectImpl_SetMatrixTranspose,
2002 ID3DXBaseEffectImpl_GetMatrixTranspose,
2003 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2004 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2005 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2006 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2007 ID3DXBaseEffectImpl_SetString,
2008 ID3DXBaseEffectImpl_GetString,
2009 ID3DXBaseEffectImpl_SetTexture,
2010 ID3DXBaseEffectImpl_GetTexture,
2011 ID3DXBaseEffectImpl_GetPixelShader,
2012 ID3DXBaseEffectImpl_GetVertexShader,
2013 ID3DXBaseEffectImpl_SetArrayRange,
2016 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2018 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2021 /*** IUnknown methods ***/
2022 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2024 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2026 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2028 if (IsEqualGUID(riid, &IID_IUnknown) ||
2029 IsEqualGUID(riid, &IID_ID3DXEffect))
2031 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2032 *object = This;
2033 return S_OK;
2036 ERR("Interface %s not found\n", debugstr_guid(riid));
2038 return E_NOINTERFACE;
2041 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2043 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2045 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2047 return InterlockedIncrement(&This->ref);
2050 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2052 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2053 ULONG ref = InterlockedDecrement(&This->ref);
2055 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2057 if (!ref)
2059 free_effect(This);
2060 HeapFree(GetProcessHeap(), 0, This);
2063 return ref;
2066 /*** ID3DXBaseEffect methods ***/
2067 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2069 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2070 ID3DXBaseEffect *base = This->base_effect;
2072 TRACE("Forward iface %p, base %p\n", This, base);
2074 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2077 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2079 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2080 ID3DXBaseEffect *base = This->base_effect;
2082 TRACE("Forward iface %p, base %p\n", This, base);
2084 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2087 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2089 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2090 ID3DXBaseEffect *base = This->base_effect;
2092 TRACE("Forward iface %p, base %p\n", This, base);
2094 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2097 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2099 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2100 ID3DXBaseEffect *base = This->base_effect;
2102 TRACE("Forward iface %p, base %p\n", This, base);
2104 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2107 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2109 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2110 ID3DXBaseEffect *base = This->base_effect;
2112 TRACE("Forward iface %p, base %p\n", This, base);
2114 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2117 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2119 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2120 ID3DXBaseEffect *base = This->base_effect;
2122 TRACE("Forward iface %p, base %p\n", This, base);
2124 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2127 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2129 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2130 ID3DXBaseEffect *base = This->base_effect;
2132 TRACE("Forward iface %p, base %p\n", This, base);
2134 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2137 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2139 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2140 ID3DXBaseEffect *base = This->base_effect;
2142 TRACE("Forward iface %p, base %p\n", This, base);
2144 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2147 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2149 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2150 ID3DXBaseEffect *base = This->base_effect;
2152 TRACE("Forward iface %p, base %p\n", This, base);
2154 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2157 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2159 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2160 ID3DXBaseEffect *base = This->base_effect;
2162 TRACE("Forward iface %p, base %p\n", This, base);
2164 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2167 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2169 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2170 ID3DXBaseEffect *base = This->base_effect;
2172 TRACE("Forward iface %p, base %p\n", This, base);
2174 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2177 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2179 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2180 ID3DXBaseEffect *base = This->base_effect;
2182 TRACE("Forward iface %p, base %p\n", This, base);
2184 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2187 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2189 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2190 ID3DXBaseEffect *base = This->base_effect;
2192 TRACE("Forward iface %p, base %p\n", This, base);
2194 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2197 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2199 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2200 ID3DXBaseEffect *base = This->base_effect;
2202 TRACE("Forward iface %p, base %p\n", This, base);
2204 return ID3DXBaseEffectImpl_GetFunction(base, index);
2207 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2209 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2210 ID3DXBaseEffect *base = This->base_effect;
2212 TRACE("Forward iface %p, base %p\n", This, base);
2214 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2217 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2219 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2220 ID3DXBaseEffect *base = This->base_effect;
2222 TRACE("Forward iface %p, base %p\n", This, base);
2224 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2227 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2229 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2230 ID3DXBaseEffect *base = This->base_effect;
2232 TRACE("Forward iface %p, base %p\n", This, base);
2234 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2237 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2239 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2240 ID3DXBaseEffect *base = This->base_effect;
2242 TRACE("Forward iface %p, base %p\n", This, base);
2244 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2247 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2249 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2250 ID3DXBaseEffect *base = This->base_effect;
2252 TRACE("Forward iface %p, base %p\n", This, base);
2254 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2257 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2259 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2260 ID3DXBaseEffect *base = This->base_effect;
2262 TRACE("Forward iface %p, base %p\n", This, base);
2264 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2267 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2269 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2270 ID3DXBaseEffect *base = This->base_effect;
2272 TRACE("Forward iface %p, base %p\n", This, base);
2274 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2277 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2279 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2280 ID3DXBaseEffect *base = This->base_effect;
2282 TRACE("Forward iface %p, base %p\n", This, base);
2284 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2287 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2289 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2290 ID3DXBaseEffect *base = This->base_effect;
2292 TRACE("Forward iface %p, base %p\n", This, base);
2294 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2297 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2299 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2300 ID3DXBaseEffect *base = This->base_effect;
2302 TRACE("Forward iface %p, base %p\n", This, base);
2304 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2307 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2309 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2310 ID3DXBaseEffect *base = This->base_effect;
2312 TRACE("Forward iface %p, base %p\n", This, base);
2314 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2317 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2319 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2320 ID3DXBaseEffect *base = This->base_effect;
2322 TRACE("Forward iface %p, base %p\n", This, base);
2324 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2327 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2329 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2330 ID3DXBaseEffect *base = This->base_effect;
2332 TRACE("Forward iface %p, base %p\n", This, base);
2334 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2337 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2339 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2340 ID3DXBaseEffect *base = This->base_effect;
2342 TRACE("Forward iface %p, base %p\n", This, base);
2344 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2347 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2349 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2350 ID3DXBaseEffect *base = This->base_effect;
2352 TRACE("Forward iface %p, base %p\n", This, base);
2354 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2357 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2359 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2360 ID3DXBaseEffect *base = This->base_effect;
2362 TRACE("Forward iface %p, base %p\n", This, base);
2364 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2367 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2369 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2370 ID3DXBaseEffect *base = This->base_effect;
2372 TRACE("Forward iface %p, base %p\n", This, base);
2374 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2377 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2379 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2380 ID3DXBaseEffect *base = This->base_effect;
2382 TRACE("Forward iface %p, base %p\n", This, base);
2384 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2387 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2389 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2390 ID3DXBaseEffect *base = This->base_effect;
2392 TRACE("Forward iface %p, base %p\n", This, base);
2394 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2397 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2399 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2400 ID3DXBaseEffect *base = This->base_effect;
2402 TRACE("Forward iface %p, base %p\n", This, base);
2404 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2407 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2409 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2410 ID3DXBaseEffect *base = This->base_effect;
2412 TRACE("Forward iface %p, base %p\n", This, base);
2414 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2417 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2419 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2420 ID3DXBaseEffect *base = This->base_effect;
2422 TRACE("Forward iface %p, base %p\n", This, base);
2424 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2427 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2429 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2430 ID3DXBaseEffect *base = This->base_effect;
2432 TRACE("Forward iface %p, base %p\n", This, base);
2434 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2437 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2439 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2440 ID3DXBaseEffect *base = This->base_effect;
2442 TRACE("Forward iface %p, base %p\n", This, base);
2444 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2447 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2449 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2450 ID3DXBaseEffect *base = This->base_effect;
2452 TRACE("Forward iface %p, base %p\n", This, base);
2454 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2457 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2459 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2460 ID3DXBaseEffect *base = This->base_effect;
2462 TRACE("Forward iface %p, base %p\n", This, base);
2464 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2467 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2469 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2470 ID3DXBaseEffect *base = This->base_effect;
2472 TRACE("Forward iface %p, base %p\n", This, base);
2474 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2477 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2479 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2480 ID3DXBaseEffect *base = This->base_effect;
2482 TRACE("Forward iface %p, base %p\n", This, base);
2484 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2487 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2489 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2490 ID3DXBaseEffect *base = This->base_effect;
2492 TRACE("Forward iface %p, base %p\n", This, base);
2494 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2497 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2499 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2500 ID3DXBaseEffect *base = This->base_effect;
2502 TRACE("Forward iface %p, base %p\n", This, base);
2504 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2507 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2509 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2510 ID3DXBaseEffect *base = This->base_effect;
2512 TRACE("Forward iface %p, base %p\n", This, base);
2514 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2517 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2519 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2520 ID3DXBaseEffect *base = This->base_effect;
2522 TRACE("Forward iface %p, base %p\n", This, base);
2524 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2527 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2529 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2530 ID3DXBaseEffect *base = This->base_effect;
2532 TRACE("Forward iface %p, base %p\n", This, base);
2534 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2537 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2539 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2540 ID3DXBaseEffect *base = This->base_effect;
2542 TRACE("Forward iface %p, base %p\n", This, base);
2544 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2547 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2549 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2550 ID3DXBaseEffect *base = This->base_effect;
2552 TRACE("Forward iface %p, base %p\n", This, base);
2554 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2557 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2559 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2560 ID3DXBaseEffect *base = This->base_effect;
2562 TRACE("Forward iface %p, base %p\n", This, base);
2564 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2567 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2569 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2570 ID3DXBaseEffect *base = This->base_effect;
2572 TRACE("Forward iface %p, base %p\n", This, base);
2574 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2577 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2579 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2580 ID3DXBaseEffect *base = This->base_effect;
2582 TRACE("Forward iface %p, base %p\n", This, base);
2584 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2587 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2589 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2590 ID3DXBaseEffect *base = This->base_effect;
2592 TRACE("Forward iface %p, base %p\n", This, base);
2594 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2597 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2599 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2600 ID3DXBaseEffect *base = This->base_effect;
2602 TRACE("Forward iface %p, base %p\n", This, base);
2604 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2607 /*** ID3DXEffect methods ***/
2608 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2610 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2612 TRACE("iface %p, pool %p\n", This, pool);
2614 if (!pool)
2616 WARN("Invalid argument supplied.\n");
2617 return D3DERR_INVALIDCALL;
2620 if (This->pool)
2622 This->pool->lpVtbl->AddRef(This->pool);
2625 *pool = This->pool;
2627 TRACE("Returning pool %p\n", *pool);
2629 return S_OK;
2632 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2634 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2636 FIXME("(%p)->(%p): stub\n", This, technique);
2638 return E_NOTIMPL;
2641 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
2643 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2645 FIXME("(%p)->(): stub\n", This);
2647 return NULL;
2650 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2652 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2654 FIXME("(%p)->(%p): stub\n", This, technique);
2656 return D3D_OK;
2659 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2661 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2663 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2665 return E_NOTIMPL;
2668 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2670 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2672 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2674 return FALSE;
2677 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect* iface, UINT *passes, DWORD flags)
2679 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2681 FIXME("(%p)->(%p, %#x): stub\n", This, passes, flags);
2683 return E_NOTIMPL;
2686 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
2688 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2690 FIXME("(%p)->(%u): stub\n", This, pass);
2692 return E_NOTIMPL;
2695 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2697 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2699 FIXME("(%p)->(): stub\n", This);
2701 return E_NOTIMPL;
2704 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
2706 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2708 FIXME("(%p)->(): stub\n", This);
2710 return E_NOTIMPL;
2713 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2715 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2717 FIXME("(%p)->(): stub\n", This);
2719 return E_NOTIMPL;
2722 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2724 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2726 TRACE("iface %p, device %p\n", This, device);
2728 if (!device)
2730 WARN("Invalid argument supplied.\n");
2731 return D3DERR_INVALIDCALL;
2734 IDirect3DDevice9_AddRef(This->device);
2736 *device = This->device;
2738 TRACE("Returning device %p\n", *device);
2740 return S_OK;
2743 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2745 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2747 FIXME("(%p)->(): stub\n", This);
2749 return E_NOTIMPL;
2752 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2754 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2756 FIXME("(%p)->(): stub\n", This);
2758 return E_NOTIMPL;
2761 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2763 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2765 TRACE("iface %p, manager %p\n", This, manager);
2767 if (This->manager) IUnknown_Release(This->manager);
2768 if (manager) IUnknown_AddRef(manager);
2770 This->manager = manager;
2772 return D3D_OK;
2775 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2777 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2779 TRACE("iface %p, manager %p\n", This, manager);
2781 if (!manager)
2783 WARN("Invalid argument supplied.\n");
2784 return D3DERR_INVALIDCALL;
2787 if (This->manager) IUnknown_AddRef(This->manager);
2788 *manager = This->manager;
2790 return D3D_OK;
2793 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2795 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2797 FIXME("(%p)->(): stub\n", This);
2799 return E_NOTIMPL;
2802 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2804 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2806 FIXME("(%p)->(): stub\n", This);
2808 return NULL;
2811 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2813 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2815 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2817 return E_NOTIMPL;
2820 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2822 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2824 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2826 return E_NOTIMPL;
2829 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
2831 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2833 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
2835 return E_NOTIMPL;
2838 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
2840 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2842 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
2844 return E_NOTIMPL;
2847 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
2849 /*** IUnknown methods ***/
2850 ID3DXEffectImpl_QueryInterface,
2851 ID3DXEffectImpl_AddRef,
2852 ID3DXEffectImpl_Release,
2853 /*** ID3DXBaseEffect methods ***/
2854 ID3DXEffectImpl_GetDesc,
2855 ID3DXEffectImpl_GetParameterDesc,
2856 ID3DXEffectImpl_GetTechniqueDesc,
2857 ID3DXEffectImpl_GetPassDesc,
2858 ID3DXEffectImpl_GetFunctionDesc,
2859 ID3DXEffectImpl_GetParameter,
2860 ID3DXEffectImpl_GetParameterByName,
2861 ID3DXEffectImpl_GetParameterBySemantic,
2862 ID3DXEffectImpl_GetParameterElement,
2863 ID3DXEffectImpl_GetTechnique,
2864 ID3DXEffectImpl_GetTechniqueByName,
2865 ID3DXEffectImpl_GetPass,
2866 ID3DXEffectImpl_GetPassByName,
2867 ID3DXEffectImpl_GetFunction,
2868 ID3DXEffectImpl_GetFunctionByName,
2869 ID3DXEffectImpl_GetAnnotation,
2870 ID3DXEffectImpl_GetAnnotationByName,
2871 ID3DXEffectImpl_SetValue,
2872 ID3DXEffectImpl_GetValue,
2873 ID3DXEffectImpl_SetBool,
2874 ID3DXEffectImpl_GetBool,
2875 ID3DXEffectImpl_SetBoolArray,
2876 ID3DXEffectImpl_GetBoolArray,
2877 ID3DXEffectImpl_SetInt,
2878 ID3DXEffectImpl_GetInt,
2879 ID3DXEffectImpl_SetIntArray,
2880 ID3DXEffectImpl_GetIntArray,
2881 ID3DXEffectImpl_SetFloat,
2882 ID3DXEffectImpl_GetFloat,
2883 ID3DXEffectImpl_SetFloatArray,
2884 ID3DXEffectImpl_GetFloatArray,
2885 ID3DXEffectImpl_SetVector,
2886 ID3DXEffectImpl_GetVector,
2887 ID3DXEffectImpl_SetVectorArray,
2888 ID3DXEffectImpl_GetVectorArray,
2889 ID3DXEffectImpl_SetMatrix,
2890 ID3DXEffectImpl_GetMatrix,
2891 ID3DXEffectImpl_SetMatrixArray,
2892 ID3DXEffectImpl_GetMatrixArray,
2893 ID3DXEffectImpl_SetMatrixPointerArray,
2894 ID3DXEffectImpl_GetMatrixPointerArray,
2895 ID3DXEffectImpl_SetMatrixTranspose,
2896 ID3DXEffectImpl_GetMatrixTranspose,
2897 ID3DXEffectImpl_SetMatrixTransposeArray,
2898 ID3DXEffectImpl_GetMatrixTransposeArray,
2899 ID3DXEffectImpl_SetMatrixTransposePointerArray,
2900 ID3DXEffectImpl_GetMatrixTransposePointerArray,
2901 ID3DXEffectImpl_SetString,
2902 ID3DXEffectImpl_GetString,
2903 ID3DXEffectImpl_SetTexture,
2904 ID3DXEffectImpl_GetTexture,
2905 ID3DXEffectImpl_GetPixelShader,
2906 ID3DXEffectImpl_GetVertexShader,
2907 ID3DXEffectImpl_SetArrayRange,
2908 /*** ID3DXEffect methods ***/
2909 ID3DXEffectImpl_GetPool,
2910 ID3DXEffectImpl_SetTechnique,
2911 ID3DXEffectImpl_GetCurrentTechnique,
2912 ID3DXEffectImpl_ValidateTechnique,
2913 ID3DXEffectImpl_FindNextValidTechnique,
2914 ID3DXEffectImpl_IsParameterUsed,
2915 ID3DXEffectImpl_Begin,
2916 ID3DXEffectImpl_BeginPass,
2917 ID3DXEffectImpl_CommitChanges,
2918 ID3DXEffectImpl_EndPass,
2919 ID3DXEffectImpl_End,
2920 ID3DXEffectImpl_GetDevice,
2921 ID3DXEffectImpl_OnLostDevice,
2922 ID3DXEffectImpl_OnResetDevice,
2923 ID3DXEffectImpl_SetStateManager,
2924 ID3DXEffectImpl_GetStateManager,
2925 ID3DXEffectImpl_BeginParameterBlock,
2926 ID3DXEffectImpl_EndParameterBlock,
2927 ID3DXEffectImpl_ApplyParameterBlock,
2928 ID3DXEffectImpl_DeleteParameterBlock,
2929 ID3DXEffectImpl_CloneEffect,
2930 ID3DXEffectImpl_SetRawValue
2933 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
2935 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
2938 /*** IUnknown methods ***/
2939 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
2941 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2943 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
2945 if (IsEqualGUID(riid, &IID_IUnknown) ||
2946 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
2948 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
2949 *object = This;
2950 return S_OK;
2953 ERR("Interface %s not found\n", debugstr_guid(riid));
2955 return E_NOINTERFACE;
2958 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
2960 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2962 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
2964 return InterlockedIncrement(&This->ref);
2967 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
2969 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2970 ULONG ref = InterlockedDecrement(&This->ref);
2972 TRACE("iface %p: Release from %u\n", iface, ref + 1);
2974 if (!ref)
2976 free_effect_compiler(This);
2977 HeapFree(GetProcessHeap(), 0, This);
2980 return ref;
2983 /*** ID3DXBaseEffect methods ***/
2984 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
2986 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2987 ID3DXBaseEffect *base = This->base_effect;
2989 TRACE("Forward iface %p, base %p\n", This, base);
2991 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2994 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2996 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2997 ID3DXBaseEffect *base = This->base_effect;
2999 TRACE("Forward iface %p, base %p\n", This, base);
3001 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3004 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3006 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3007 ID3DXBaseEffect *base = This->base_effect;
3009 TRACE("Forward iface %p, base %p\n", This, base);
3011 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3014 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3016 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3017 ID3DXBaseEffect *base = This->base_effect;
3019 TRACE("Forward iface %p, base %p\n", This, base);
3021 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3024 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3026 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3027 ID3DXBaseEffect *base = This->base_effect;
3029 TRACE("Forward iface %p, base %p\n", This, base);
3031 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3034 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3036 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3037 ID3DXBaseEffect *base = This->base_effect;
3039 TRACE("Forward iface %p, base %p\n", This, base);
3041 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3044 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3046 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3047 ID3DXBaseEffect *base = This->base_effect;
3049 TRACE("Forward iface %p, base %p\n", This, base);
3051 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3054 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3056 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3057 ID3DXBaseEffect *base = This->base_effect;
3059 TRACE("Forward iface %p, base %p\n", This, base);
3061 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3064 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3066 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3067 ID3DXBaseEffect *base = This->base_effect;
3069 TRACE("Forward iface %p, base %p\n", This, base);
3071 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3074 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3076 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3077 ID3DXBaseEffect *base = This->base_effect;
3079 TRACE("Forward iface %p, base %p\n", This, base);
3081 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3084 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3086 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3087 ID3DXBaseEffect *base = This->base_effect;
3089 TRACE("Forward iface %p, base %p\n", This, base);
3091 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3094 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3096 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3097 ID3DXBaseEffect *base = This->base_effect;
3099 TRACE("Forward iface %p, base %p\n", This, base);
3101 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3104 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3106 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3107 ID3DXBaseEffect *base = This->base_effect;
3109 TRACE("Forward iface %p, base %p\n", This, base);
3111 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3114 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3116 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3117 ID3DXBaseEffect *base = This->base_effect;
3119 TRACE("Forward iface %p, base %p\n", This, base);
3121 return ID3DXBaseEffectImpl_GetFunction(base, index);
3124 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3126 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3127 ID3DXBaseEffect *base = This->base_effect;
3129 TRACE("Forward iface %p, base %p\n", This, base);
3131 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3134 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3136 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3137 ID3DXBaseEffect *base = This->base_effect;
3139 TRACE("Forward iface %p, base %p\n", This, base);
3141 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3144 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3146 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3147 ID3DXBaseEffect *base = This->base_effect;
3149 TRACE("Forward iface %p, base %p\n", This, base);
3151 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3154 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3156 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3157 ID3DXBaseEffect *base = This->base_effect;
3159 TRACE("Forward iface %p, base %p\n", This, base);
3161 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3164 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3166 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3167 ID3DXBaseEffect *base = This->base_effect;
3169 TRACE("Forward iface %p, base %p\n", This, base);
3171 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3174 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3176 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3177 ID3DXBaseEffect *base = This->base_effect;
3179 TRACE("Forward iface %p, base %p\n", This, base);
3181 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3184 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3186 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3187 ID3DXBaseEffect *base = This->base_effect;
3189 TRACE("Forward iface %p, base %p\n", This, base);
3191 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3194 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3196 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3197 ID3DXBaseEffect *base = This->base_effect;
3199 TRACE("Forward iface %p, base %p\n", This, base);
3201 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3204 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3206 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3207 ID3DXBaseEffect *base = This->base_effect;
3209 TRACE("Forward iface %p, base %p\n", This, base);
3211 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3214 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3216 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3217 ID3DXBaseEffect *base = This->base_effect;
3219 TRACE("Forward iface %p, base %p\n", This, base);
3221 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3224 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3226 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3227 ID3DXBaseEffect *base = This->base_effect;
3229 TRACE("Forward iface %p, base %p\n", This, base);
3231 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3234 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3236 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3237 ID3DXBaseEffect *base = This->base_effect;
3239 TRACE("Forward iface %p, base %p\n", This, base);
3241 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3244 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3246 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3247 ID3DXBaseEffect *base = This->base_effect;
3249 TRACE("Forward iface %p, base %p\n", This, base);
3251 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3254 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3256 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3257 ID3DXBaseEffect *base = This->base_effect;
3259 TRACE("Forward iface %p, base %p\n", This, base);
3261 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3264 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3266 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3267 ID3DXBaseEffect *base = This->base_effect;
3269 TRACE("Forward iface %p, base %p\n", This, base);
3271 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3274 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3276 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3277 ID3DXBaseEffect *base = This->base_effect;
3279 TRACE("Forward iface %p, base %p\n", This, base);
3281 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3284 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3286 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3287 ID3DXBaseEffect *base = This->base_effect;
3289 TRACE("Forward iface %p, base %p\n", This, base);
3291 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3294 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3296 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3297 ID3DXBaseEffect *base = This->base_effect;
3299 TRACE("Forward iface %p, base %p\n", This, base);
3301 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3304 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3306 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3307 ID3DXBaseEffect *base = This->base_effect;
3309 TRACE("Forward iface %p, base %p\n", This, base);
3311 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3314 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3316 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3317 ID3DXBaseEffect *base = This->base_effect;
3319 TRACE("Forward iface %p, base %p\n", This, base);
3321 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3324 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3326 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3327 ID3DXBaseEffect *base = This->base_effect;
3329 TRACE("Forward iface %p, base %p\n", This, base);
3331 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3334 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3336 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3337 ID3DXBaseEffect *base = This->base_effect;
3339 TRACE("Forward iface %p, base %p\n", This, base);
3341 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3344 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3346 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3347 ID3DXBaseEffect *base = This->base_effect;
3349 TRACE("Forward iface %p, base %p\n", This, base);
3351 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3354 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3356 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3357 ID3DXBaseEffect *base = This->base_effect;
3359 TRACE("Forward iface %p, base %p\n", This, base);
3361 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3364 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3366 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3367 ID3DXBaseEffect *base = This->base_effect;
3369 TRACE("Forward iface %p, base %p\n", This, base);
3371 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3374 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3376 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3377 ID3DXBaseEffect *base = This->base_effect;
3379 TRACE("Forward iface %p, base %p\n", This, base);
3381 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3384 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3386 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3387 ID3DXBaseEffect *base = This->base_effect;
3389 TRACE("Forward iface %p, base %p\n", This, base);
3391 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3394 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3396 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3397 ID3DXBaseEffect *base = This->base_effect;
3399 TRACE("Forward iface %p, base %p\n", This, base);
3401 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3404 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3406 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3407 ID3DXBaseEffect *base = This->base_effect;
3409 TRACE("Forward iface %p, base %p\n", This, base);
3411 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3414 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3416 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3417 ID3DXBaseEffect *base = This->base_effect;
3419 TRACE("Forward iface %p, base %p\n", This, base);
3421 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3424 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3426 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3427 ID3DXBaseEffect *base = This->base_effect;
3429 TRACE("Forward iface %p, base %p\n", This, base);
3431 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3434 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3436 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3437 ID3DXBaseEffect *base = This->base_effect;
3439 TRACE("Forward iface %p, base %p\n", This, base);
3441 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3444 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3446 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3447 ID3DXBaseEffect *base = This->base_effect;
3449 TRACE("Forward iface %p, base %p\n", This, base);
3451 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3454 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3456 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3457 ID3DXBaseEffect *base = This->base_effect;
3459 TRACE("Forward iface %p, base %p\n", This, base);
3461 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3464 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3466 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3467 ID3DXBaseEffect *base = This->base_effect;
3469 TRACE("Forward iface %p, base %p\n", This, base);
3471 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3474 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3476 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3477 ID3DXBaseEffect *base = This->base_effect;
3479 TRACE("Forward iface %p, base %p\n", This, base);
3481 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3484 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3486 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3487 ID3DXBaseEffect *base = This->base_effect;
3489 TRACE("Forward iface %p, base %p\n", This, base);
3491 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3494 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3496 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3497 ID3DXBaseEffect *base = This->base_effect;
3499 TRACE("Forward iface %p, base %p\n", This, base);
3501 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3504 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3506 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3507 ID3DXBaseEffect *base = This->base_effect;
3509 TRACE("Forward iface %p, base %p\n", This, base);
3511 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3514 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3516 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3517 ID3DXBaseEffect *base = This->base_effect;
3519 TRACE("Forward iface %p, base %p\n", This, base);
3521 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3524 /*** ID3DXEffectCompiler methods ***/
3525 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3527 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3529 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3531 return E_NOTIMPL;
3534 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3536 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3538 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3540 return E_NOTIMPL;
3543 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3544 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3546 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3548 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3550 return E_NOTIMPL;
3553 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3554 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3556 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3558 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3559 This, function, target, flags, shader, error_msgs, constant_table);
3561 return E_NOTIMPL;
3564 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3566 /*** IUnknown methods ***/
3567 ID3DXEffectCompilerImpl_QueryInterface,
3568 ID3DXEffectCompilerImpl_AddRef,
3569 ID3DXEffectCompilerImpl_Release,
3570 /*** ID3DXBaseEffect methods ***/
3571 ID3DXEffectCompilerImpl_GetDesc,
3572 ID3DXEffectCompilerImpl_GetParameterDesc,
3573 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3574 ID3DXEffectCompilerImpl_GetPassDesc,
3575 ID3DXEffectCompilerImpl_GetFunctionDesc,
3576 ID3DXEffectCompilerImpl_GetParameter,
3577 ID3DXEffectCompilerImpl_GetParameterByName,
3578 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3579 ID3DXEffectCompilerImpl_GetParameterElement,
3580 ID3DXEffectCompilerImpl_GetTechnique,
3581 ID3DXEffectCompilerImpl_GetTechniqueByName,
3582 ID3DXEffectCompilerImpl_GetPass,
3583 ID3DXEffectCompilerImpl_GetPassByName,
3584 ID3DXEffectCompilerImpl_GetFunction,
3585 ID3DXEffectCompilerImpl_GetFunctionByName,
3586 ID3DXEffectCompilerImpl_GetAnnotation,
3587 ID3DXEffectCompilerImpl_GetAnnotationByName,
3588 ID3DXEffectCompilerImpl_SetValue,
3589 ID3DXEffectCompilerImpl_GetValue,
3590 ID3DXEffectCompilerImpl_SetBool,
3591 ID3DXEffectCompilerImpl_GetBool,
3592 ID3DXEffectCompilerImpl_SetBoolArray,
3593 ID3DXEffectCompilerImpl_GetBoolArray,
3594 ID3DXEffectCompilerImpl_SetInt,
3595 ID3DXEffectCompilerImpl_GetInt,
3596 ID3DXEffectCompilerImpl_SetIntArray,
3597 ID3DXEffectCompilerImpl_GetIntArray,
3598 ID3DXEffectCompilerImpl_SetFloat,
3599 ID3DXEffectCompilerImpl_GetFloat,
3600 ID3DXEffectCompilerImpl_SetFloatArray,
3601 ID3DXEffectCompilerImpl_GetFloatArray,
3602 ID3DXEffectCompilerImpl_SetVector,
3603 ID3DXEffectCompilerImpl_GetVector,
3604 ID3DXEffectCompilerImpl_SetVectorArray,
3605 ID3DXEffectCompilerImpl_GetVectorArray,
3606 ID3DXEffectCompilerImpl_SetMatrix,
3607 ID3DXEffectCompilerImpl_GetMatrix,
3608 ID3DXEffectCompilerImpl_SetMatrixArray,
3609 ID3DXEffectCompilerImpl_GetMatrixArray,
3610 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3611 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3612 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3613 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3614 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3615 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3616 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3617 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3618 ID3DXEffectCompilerImpl_SetString,
3619 ID3DXEffectCompilerImpl_GetString,
3620 ID3DXEffectCompilerImpl_SetTexture,
3621 ID3DXEffectCompilerImpl_GetTexture,
3622 ID3DXEffectCompilerImpl_GetPixelShader,
3623 ID3DXEffectCompilerImpl_GetVertexShader,
3624 ID3DXEffectCompilerImpl_SetArrayRange,
3625 /*** ID3DXEffectCompiler methods ***/
3626 ID3DXEffectCompilerImpl_SetLiteral,
3627 ID3DXEffectCompilerImpl_GetLiteral,
3628 ID3DXEffectCompilerImpl_CompileEffect,
3629 ID3DXEffectCompilerImpl_CompileShader,
3632 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char **ptr, D3DXHANDLE *objects)
3634 unsigned int i;
3635 HRESULT hr;
3636 UINT old_size = 0;
3637 DWORD id;
3639 if (param->element_count)
3641 param->data = value;
3643 for (i = 0; i < param->element_count; ++i)
3645 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3647 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, ptr, objects);
3648 if (hr != D3D_OK)
3650 WARN("Failed to parse value\n");
3651 return hr;
3654 old_size += member->bytes;
3657 return D3D_OK;
3660 switch(param->class)
3662 case D3DXPC_SCALAR:
3663 case D3DXPC_VECTOR:
3664 case D3DXPC_MATRIX_ROWS:
3665 case D3DXPC_MATRIX_COLUMNS:
3666 param->data = value;
3667 break;
3669 case D3DXPC_STRUCT:
3670 param->data = value;
3672 for (i = 0; i < param->member_count; ++i)
3674 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3676 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr, objects);
3677 if (hr != D3D_OK)
3679 WARN("Failed to parse value\n");
3680 return hr;
3683 old_size += member->bytes;
3685 break;
3687 case D3DXPC_OBJECT:
3688 switch (param->type)
3690 case D3DXPT_STRING:
3691 case D3DXPT_TEXTURE:
3692 case D3DXPT_TEXTURE1D:
3693 case D3DXPT_TEXTURE2D:
3694 case D3DXPT_TEXTURE3D:
3695 case D3DXPT_TEXTURECUBE:
3696 case D3DXPT_PIXELSHADER:
3697 case D3DXPT_VERTEXSHADER:
3698 read_dword(ptr, &id);
3699 TRACE("Id: %u\n", id);
3700 objects[id] = get_parameter_handle(param);
3701 param->data = value;
3702 break;
3704 case D3DXPT_SAMPLER:
3705 case D3DXPT_SAMPLER1D:
3706 case D3DXPT_SAMPLER2D:
3707 case D3DXPT_SAMPLER3D:
3708 case D3DXPT_SAMPLERCUBE:
3710 UINT state_count;
3712 read_dword(ptr, &state_count);
3713 TRACE("Count: %u\n", state_count);
3715 for (i = 0; i < state_count; ++i)
3717 /* Todo: parse states */
3718 skip_dword_unknown(ptr, 4);
3720 break;
3723 default:
3724 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3725 break;
3727 break;
3729 default:
3730 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3731 break;
3734 return D3D_OK;
3737 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *ptr, D3DXHANDLE *objects)
3739 UINT size = param->bytes;
3740 HRESULT hr;
3741 void *value = NULL;
3743 TRACE("param size: %u\n", size);
3745 if (size)
3747 value = HeapAlloc(GetProcessHeap(), 0, size);
3748 if (!value)
3750 ERR("Failed to allocate data memory.\n");
3751 return E_OUTOFMEMORY;
3754 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3755 memcpy(value, ptr, size);
3758 hr = d3dx9_parse_value(param, value, &ptr, objects);
3759 if (hr != D3D_OK)
3761 WARN("Failed to parse value\n");
3762 HeapFree(GetProcessHeap(), 0, value);
3763 return hr;
3766 param->data = value;
3768 return D3D_OK;
3771 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
3773 DWORD size;
3775 read_dword(&ptr, &size);
3776 TRACE("Name size: %#x\n", size);
3778 if (!size)
3780 return D3D_OK;
3783 *name = HeapAlloc(GetProcessHeap(), 0, size);
3784 if (!*name)
3786 ERR("Failed to allocate name memory.\n");
3787 return E_OUTOFMEMORY;
3790 TRACE("Name: %s.\n", debugstr_an(ptr, size));
3791 memcpy(*name, ptr, size);
3793 return D3D_OK;
3796 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
3798 DWORD size;
3799 HRESULT hr;
3801 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
3803 read_dword(ptr, &size);
3804 TRACE("Data size: %#x\n", size);
3806 if (!size)
3808 TRACE("Size is 0\n");
3809 *(void **)param->data = NULL;
3810 return D3D_OK;
3813 switch (param->type)
3815 case D3DXPT_STRING:
3816 /* re-read with size (sizeof(DWORD) = 4) */
3817 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
3818 if (hr != D3D_OK)
3820 WARN("Failed to parse string data\n");
3821 return hr;
3823 break;
3825 case D3DXPT_VERTEXSHADER:
3826 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
3827 if (hr != D3D_OK)
3829 WARN("Failed to create vertex shader\n");
3830 return hr;
3832 break;
3834 case D3DXPT_PIXELSHADER:
3835 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
3836 if (hr != D3D_OK)
3838 WARN("Failed to create pixel shader\n");
3839 return hr;
3841 break;
3843 default:
3844 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3845 break;
3849 *ptr += ((size + 3) & ~3);
3851 return D3D_OK;
3854 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
3855 struct d3dx_parameter *parent, UINT flags)
3857 DWORD offset;
3858 HRESULT hr;
3859 D3DXHANDLE *member_handles = NULL;
3860 UINT i;
3862 param->flags = flags;
3864 if (!parent)
3866 read_dword(ptr, &param->type);
3867 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
3869 read_dword(ptr, &param->class);
3870 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
3872 read_dword(ptr, &offset);
3873 TRACE("Type name offset: %#x\n", offset);
3874 hr = d3dx9_parse_name(&param->name, data + offset);
3875 if (hr != D3D_OK)
3877 WARN("Failed to parse name\n");
3878 goto err_out;
3881 read_dword(ptr, &offset);
3882 TRACE("Type semantic offset: %#x\n", offset);
3883 hr = d3dx9_parse_name(&param->semantic, data + offset);
3884 if (hr != D3D_OK)
3886 WARN("Failed to parse semantic\n");
3887 goto err_out;
3890 read_dword(ptr, &param->element_count);
3891 TRACE("Elements: %u\n", param->element_count);
3893 switch (param->class)
3895 case D3DXPC_VECTOR:
3896 read_dword(ptr, &param->columns);
3897 TRACE("Columns: %u\n", param->columns);
3899 read_dword(ptr, &param->rows);
3900 TRACE("Rows: %u\n", param->rows);
3902 /* sizeof(DWORD) * rows * columns */
3903 param->bytes = 4 * param->rows * param->columns;
3904 break;
3906 case D3DXPC_SCALAR:
3907 case D3DXPC_MATRIX_ROWS:
3908 case D3DXPC_MATRIX_COLUMNS:
3909 read_dword(ptr, &param->rows);
3910 TRACE("Rows: %u\n", param->rows);
3912 read_dword(ptr, &param->columns);
3913 TRACE("Columns: %u\n", param->columns);
3915 /* sizeof(DWORD) * rows * columns */
3916 param->bytes = 4 * param->rows * param->columns;
3917 break;
3919 case D3DXPC_STRUCT:
3920 read_dword(ptr, &param->member_count);
3921 TRACE("Members: %u\n", param->member_count);
3922 break;
3924 case D3DXPC_OBJECT:
3925 switch (param->type)
3927 case D3DXPT_STRING:
3928 param->bytes = sizeof(LPCSTR);
3929 break;
3931 case D3DXPT_PIXELSHADER:
3932 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
3933 break;
3935 case D3DXPT_VERTEXSHADER:
3936 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
3937 break;
3939 case D3DXPT_TEXTURE:
3940 case D3DXPT_TEXTURE1D:
3941 case D3DXPT_TEXTURE2D:
3942 case D3DXPT_TEXTURE3D:
3943 case D3DXPT_TEXTURECUBE:
3944 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
3945 break;
3947 case D3DXPT_SAMPLER:
3948 case D3DXPT_SAMPLER1D:
3949 case D3DXPT_SAMPLER2D:
3950 case D3DXPT_SAMPLER3D:
3951 case D3DXPT_SAMPLERCUBE:
3952 param->bytes = 0;
3953 break;
3955 default:
3956 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3957 break;
3959 break;
3961 default:
3962 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3963 break;
3966 else
3968 /* elements */
3969 param->type = parent->type;
3970 param->class = parent->class;
3971 param->name = parent->name;
3972 param->semantic = parent->semantic;
3973 param->element_count = 0;
3974 param->annotation_count = 0;
3975 param->member_count = parent->member_count;
3976 param->bytes = parent->bytes;
3977 param->rows = parent->rows;
3978 param->columns = parent->columns;
3981 if (param->element_count)
3983 unsigned int param_bytes = 0;
3984 const char *save_ptr = *ptr;
3986 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
3987 if (!member_handles)
3989 ERR("Out of memory\n");
3990 hr = E_OUTOFMEMORY;
3991 goto err_out;
3994 for (i = 0; i < param->element_count; ++i)
3996 struct d3dx_parameter *member;
3997 *ptr = save_ptr;
3999 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4000 if (!member)
4002 ERR("Out of memory\n");
4003 hr = E_OUTOFMEMORY;
4004 goto err_out;
4007 member_handles[i] = get_parameter_handle(member);
4009 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4010 if (hr != D3D_OK)
4012 WARN("Failed to parse member\n");
4013 goto err_out;
4016 param_bytes += member->bytes;
4019 param->bytes = param_bytes;
4021 else if (param->member_count)
4023 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4024 if (!member_handles)
4026 ERR("Out of memory\n");
4027 hr = E_OUTOFMEMORY;
4028 goto err_out;
4031 for (i = 0; i < param->member_count; ++i)
4033 struct d3dx_parameter *member;
4035 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4036 if (!member)
4038 ERR("Out of memory\n");
4039 hr = E_OUTOFMEMORY;
4040 goto err_out;
4043 member_handles[i] = get_parameter_handle(member);
4045 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4046 if (hr != D3D_OK)
4048 WARN("Failed to parse member\n");
4049 goto err_out;
4052 param->bytes += member->bytes;
4056 param->member_handles = member_handles;
4058 return D3D_OK;
4060 err_out:
4062 if (member_handles)
4064 unsigned int count;
4066 if (param->element_count) count = param->element_count;
4067 else count = param->member_count;
4069 for (i = 0; i < count; ++i)
4071 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4073 HeapFree(GetProcessHeap(), 0, member_handles);
4076 if (!parent)
4078 HeapFree(GetProcessHeap(), 0, param->name);
4079 HeapFree(GetProcessHeap(), 0, param->semantic);
4081 param->name = NULL;
4082 param->semantic = NULL;
4084 return hr;
4087 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4089 DWORD offset;
4090 const char *ptr2;
4091 HRESULT hr;
4093 anno->flags = D3DX_PARAMETER_ANNOTATION;
4095 read_dword(ptr, &offset);
4096 TRACE("Typedef offset: %#x\n", offset);
4097 ptr2 = data + offset;
4098 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4099 if (hr != D3D_OK)
4101 WARN("Failed to parse type definition\n");
4102 return hr;
4105 read_dword(ptr, &offset);
4106 TRACE("Value offset: %#x\n", offset);
4107 hr = d3dx9_parse_init_value(anno, data + offset, objects);
4108 if (hr != D3D_OK)
4110 WARN("Failed to parse value\n");
4111 return hr;
4114 return D3D_OK;
4117 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4119 DWORD offset;
4120 const char *ptr2;
4121 HRESULT hr;
4122 struct d3dx_parameter *parameter;
4124 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4125 if (!parameter)
4127 ERR("Out of memory\n");
4128 return E_OUTOFMEMORY;
4131 read_dword(ptr, &state->operation);
4132 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4134 read_dword(ptr, &state->index);
4135 TRACE("Index: %#x\n", state->index);
4137 read_dword(ptr, &offset);
4138 TRACE("Typedef offset: %#x\n", offset);
4139 ptr2 = data + offset;
4140 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4141 if (hr != D3D_OK)
4143 WARN("Failed to parse type definition\n");
4144 goto err_out;
4147 read_dword(ptr, &offset);
4148 TRACE("Value offset: %#x\n", offset);
4149 hr = d3dx9_parse_init_value(parameter, data + offset, objects);
4150 if (hr != D3D_OK)
4152 WARN("Failed to parse value\n");
4153 goto err_out;
4156 state->parameter = get_parameter_handle(parameter);
4158 return D3D_OK;
4160 err_out:
4162 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4164 return hr;
4167 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4169 DWORD offset;
4170 HRESULT hr;
4171 unsigned int i;
4172 D3DXHANDLE *annotation_handles = NULL;
4173 const char *ptr2;
4175 read_dword(ptr, &offset);
4176 TRACE("Typedef offset: %#x\n", offset);
4177 ptr2 = data + offset;
4179 read_dword(ptr, &offset);
4180 TRACE("Value offset: %#x\n", offset);
4182 read_dword(ptr, &param->flags);
4183 TRACE("Flags: %#x\n", param->flags);
4185 read_dword(ptr, &param->annotation_count);
4186 TRACE("Annotation count: %u\n", param->annotation_count);
4188 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4189 if (hr != D3D_OK)
4191 WARN("Failed to parse type definition\n");
4192 return hr;
4195 hr = d3dx9_parse_init_value(param, data + offset, objects);
4196 if (hr != D3D_OK)
4198 WARN("Failed to parse value\n");
4199 return hr;
4202 if (param->annotation_count)
4204 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4205 if (!annotation_handles)
4207 ERR("Out of memory\n");
4208 hr = E_OUTOFMEMORY;
4209 goto err_out;
4212 for (i = 0; i < param->annotation_count; ++i)
4214 struct d3dx_parameter *annotation;
4216 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4217 if (!annotation)
4219 ERR("Out of memory\n");
4220 hr = E_OUTOFMEMORY;
4221 goto err_out;
4224 annotation_handles[i] = get_parameter_handle(annotation);
4226 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4227 if (hr != D3D_OK)
4229 WARN("Failed to parse annotation\n");
4230 goto err_out;
4235 param->annotation_handles = annotation_handles;
4237 return D3D_OK;
4239 err_out:
4241 if (annotation_handles)
4243 for (i = 0; i < param->annotation_count; ++i)
4245 free_parameter(annotation_handles[i], FALSE, FALSE);
4247 HeapFree(GetProcessHeap(), 0, annotation_handles);
4250 return hr;
4253 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4255 DWORD offset;
4256 HRESULT hr;
4257 unsigned int i;
4258 D3DXHANDLE *annotation_handles = NULL;
4259 struct d3dx_state *states = NULL;
4260 char *name = NULL;
4262 read_dword(ptr, &offset);
4263 TRACE("Pass name offset: %#x\n", offset);
4264 hr = d3dx9_parse_name(&name, data + offset);
4265 if (hr != D3D_OK)
4267 WARN("Failed to parse name\n");
4268 goto err_out;
4271 read_dword(ptr, &pass->annotation_count);
4272 TRACE("Annotation count: %u\n", pass->annotation_count);
4274 read_dword(ptr, &pass->state_count);
4275 TRACE("State count: %u\n", pass->state_count);
4277 if (pass->annotation_count)
4279 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4280 if (!annotation_handles)
4282 ERR("Out of memory\n");
4283 hr = E_OUTOFMEMORY;
4284 goto err_out;
4287 for (i = 0; i < pass->annotation_count; ++i)
4289 struct d3dx_parameter *annotation;
4291 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4292 if (!annotation)
4294 ERR("Out of memory\n");
4295 hr = E_OUTOFMEMORY;
4296 goto err_out;
4299 annotation_handles[i] = get_parameter_handle(annotation);
4301 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4302 if (hr != D3D_OK)
4304 WARN("Failed to parse annotations\n");
4305 goto err_out;
4310 if (pass->state_count)
4312 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4313 if (!states)
4315 ERR("Out of memory\n");
4316 hr = E_OUTOFMEMORY;
4317 goto err_out;
4320 for (i = 0; i < pass->state_count; ++i)
4322 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4323 if (hr != D3D_OK)
4325 WARN("Failed to parse annotations\n");
4326 goto err_out;
4331 pass->name = name;
4332 pass->annotation_handles = annotation_handles;
4333 pass->states = states;
4335 return D3D_OK;
4337 err_out:
4339 if (annotation_handles)
4341 for (i = 0; i < pass->annotation_count; ++i)
4343 free_parameter(annotation_handles[i], FALSE, FALSE);
4345 HeapFree(GetProcessHeap(), 0, annotation_handles);
4348 if (states)
4350 for (i = 0; i < pass->state_count; ++i)
4352 free_state(&states[i]);
4354 HeapFree(GetProcessHeap(), 0, states);
4357 HeapFree(GetProcessHeap(), 0, name);
4359 return hr;
4362 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4364 DWORD offset;
4365 HRESULT hr;
4366 unsigned int i;
4367 D3DXHANDLE *annotation_handles = NULL;
4368 D3DXHANDLE *pass_handles = NULL;
4369 char *name = NULL;
4371 read_dword(ptr, &offset);
4372 TRACE("Technique name offset: %#x\n", offset);
4373 hr = d3dx9_parse_name(&name, data + offset);
4374 if (hr != D3D_OK)
4376 WARN("Failed to parse name\n");
4377 goto err_out;
4380 read_dword(ptr, &technique->annotation_count);
4381 TRACE("Annotation count: %u\n", technique->annotation_count);
4383 read_dword(ptr, &technique->pass_count);
4384 TRACE("Pass count: %u\n", technique->pass_count);
4386 if (technique->annotation_count)
4388 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4389 if (!annotation_handles)
4391 ERR("Out of memory\n");
4392 hr = E_OUTOFMEMORY;
4393 goto err_out;
4396 for (i = 0; i < technique->annotation_count; ++i)
4398 struct d3dx_parameter *annotation;
4400 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4401 if (!annotation)
4403 ERR("Out of memory\n");
4404 hr = E_OUTOFMEMORY;
4405 goto err_out;
4408 annotation_handles[i] = get_parameter_handle(annotation);
4410 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4411 if (hr != D3D_OK)
4413 WARN("Failed to parse annotations\n");
4414 goto err_out;
4419 if (technique->pass_count)
4421 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4422 if (!pass_handles)
4424 ERR("Out of memory\n");
4425 hr = E_OUTOFMEMORY;
4426 goto err_out;
4429 for (i = 0; i < technique->pass_count; ++i)
4431 struct d3dx_pass *pass;
4433 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4434 if (!pass)
4436 ERR("Out of memory\n");
4437 hr = E_OUTOFMEMORY;
4438 goto err_out;
4441 pass_handles[i] = get_pass_handle(pass);
4443 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
4444 if (hr != D3D_OK)
4446 WARN("Failed to parse passes\n");
4447 goto err_out;
4452 technique->name = name;
4453 technique->pass_handles = pass_handles;
4454 technique->annotation_handles = annotation_handles;
4456 return D3D_OK;
4458 err_out:
4460 if (pass_handles)
4462 for (i = 0; i < technique->pass_count; ++i)
4464 free_pass(pass_handles[i]);
4466 HeapFree(GetProcessHeap(), 0, pass_handles);
4469 if (annotation_handles)
4471 for (i = 0; i < technique->annotation_count; ++i)
4473 free_parameter(annotation_handles[i], FALSE, FALSE);
4475 HeapFree(GetProcessHeap(), 0, annotation_handles);
4478 HeapFree(GetProcessHeap(), 0, name);
4480 return hr;
4483 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4485 const char *ptr = data + start;
4486 D3DXHANDLE *parameter_handles = NULL;
4487 D3DXHANDLE *technique_handles = NULL;
4488 D3DXHANDLE *objects = NULL;
4489 UINT stringcount, objectcount;
4490 HRESULT hr;
4491 UINT i;
4493 read_dword(&ptr, &base->parameter_count);
4494 TRACE("Parameter count: %u\n", base->parameter_count);
4496 read_dword(&ptr, &base->technique_count);
4497 TRACE("Technique count: %u\n", base->technique_count);
4499 skip_dword_unknown(&ptr, 1);
4501 read_dword(&ptr, &objectcount);
4502 TRACE("Object count: %u\n", objectcount);
4504 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
4505 if (!objects)
4507 ERR("Out of memory\n");
4508 hr = E_OUTOFMEMORY;
4509 goto err_out;
4512 if (base->parameter_count)
4514 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4515 if (!parameter_handles)
4517 ERR("Out of memory\n");
4518 hr = E_OUTOFMEMORY;
4519 goto err_out;
4522 for (i = 0; i < base->parameter_count; ++i)
4524 struct d3dx_parameter *parameter;
4526 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4527 if (!parameter)
4529 ERR("Out of memory\n");
4530 hr = E_OUTOFMEMORY;
4531 goto err_out;
4534 parameter_handles[i] = get_parameter_handle(parameter);
4536 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
4537 if (hr != D3D_OK)
4539 WARN("Failed to parse parameter\n");
4540 goto err_out;
4545 if (base->technique_count)
4547 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4548 if (!technique_handles)
4550 ERR("Out of memory\n");
4551 hr = E_OUTOFMEMORY;
4552 goto err_out;
4555 for (i = 0; i < base->technique_count; ++i)
4557 struct d3dx_technique *technique;
4559 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4560 if (!technique)
4562 ERR("Out of memory\n");
4563 hr = E_OUTOFMEMORY;
4564 goto err_out;
4567 technique_handles[i] = get_technique_handle(technique);
4569 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
4570 if (hr != D3D_OK)
4572 WARN("Failed to parse technique\n");
4573 goto err_out;
4578 read_dword(&ptr, &stringcount);
4579 TRACE("String count: %u\n", stringcount);
4581 skip_dword_unknown(&ptr, 1);
4583 for (i = 0; i < stringcount; ++i)
4585 DWORD id;
4586 struct d3dx_parameter *param;
4588 read_dword(&ptr, &id);
4589 TRACE("Id: %u\n", id);
4591 param = get_parameter_struct(objects[id]);
4593 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
4594 if (hr != D3D_OK)
4596 WARN("Failed to parse data\n");
4597 goto err_out;
4601 HeapFree(GetProcessHeap(), 0, objects);
4603 base->technique_handles = technique_handles;
4604 base->parameter_handles = parameter_handles;
4606 return D3D_OK;
4608 err_out:
4610 if (technique_handles)
4612 for (i = 0; i < base->technique_count; ++i)
4614 free_technique(technique_handles[i]);
4616 HeapFree(GetProcessHeap(), 0, technique_handles);
4619 if (parameter_handles)
4621 for (i = 0; i < base->parameter_count; ++i)
4623 free_parameter(parameter_handles[i], FALSE, FALSE);
4625 HeapFree(GetProcessHeap(), 0, parameter_handles);
4628 HeapFree(GetProcessHeap(), 0, objects);
4630 return hr;
4633 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
4634 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
4636 DWORD tag, offset;
4637 const char *ptr = data;
4638 HRESULT hr;
4640 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
4642 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
4643 base->ref = 1;
4644 base->effect = effect;
4646 read_dword(&ptr, &tag);
4647 TRACE("Tag: %x\n", tag);
4649 if (tag != d3dx9_effect_version(9, 1))
4651 /* todo: compile hlsl ascii code */
4652 FIXME("HLSL ascii effects not supported, yet\n");
4654 /* Show the start of the shader for debugging info. */
4655 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
4657 else
4659 read_dword(&ptr, &offset);
4660 TRACE("Offset: %x\n", offset);
4662 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
4663 if (hr != D3D_OK)
4665 FIXME("Failed to parse effect.\n");
4666 return hr;
4670 return D3D_OK;
4673 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
4674 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
4676 HRESULT hr;
4677 struct ID3DXBaseEffectImpl *object = NULL;
4679 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
4681 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
4682 effect->ref = 1;
4684 if (pool) pool->lpVtbl->AddRef(pool);
4685 effect->pool = pool;
4687 IDirect3DDevice9_AddRef(device);
4688 effect->device = device;
4690 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4691 if (!object)
4693 ERR("Out of memory\n");
4694 hr = E_OUTOFMEMORY;
4695 goto err_out;
4698 hr = d3dx9_base_effect_init(object, data, data_size, effect);
4699 if (hr != D3D_OK)
4701 FIXME("Failed to parse effect.\n");
4702 goto err_out;
4705 effect->base_effect = &object->ID3DXBaseEffect_iface;
4707 return D3D_OK;
4709 err_out:
4711 HeapFree(GetProcessHeap(), 0, object);
4712 free_effect(effect);
4714 return hr;
4717 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
4718 LPCVOID srcdata,
4719 UINT srcdatalen,
4720 CONST D3DXMACRO* defines,
4721 LPD3DXINCLUDE include,
4722 LPCSTR skip_constants,
4723 DWORD flags,
4724 LPD3DXEFFECTPOOL pool,
4725 LPD3DXEFFECT* effect,
4726 LPD3DXBUFFER* compilation_errors)
4728 struct ID3DXEffectImpl *object;
4729 HRESULT hr;
4731 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
4732 skip_constants, flags, pool, effect, compilation_errors);
4734 if (!device || !srcdata)
4735 return D3DERR_INVALIDCALL;
4737 if (!srcdatalen)
4738 return E_FAIL;
4740 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
4741 if (!effect)
4742 return D3D_OK;
4744 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4745 if (!object)
4747 ERR("Out of memory\n");
4748 return E_OUTOFMEMORY;
4751 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
4752 if (FAILED(hr))
4754 WARN("Failed to initialize shader reflection\n");
4755 HeapFree(GetProcessHeap(), 0, object);
4756 return hr;
4759 *effect = &object->ID3DXEffect_iface;
4761 TRACE("Created ID3DXEffect %p\n", object);
4763 return D3D_OK;
4766 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
4767 LPCVOID srcdata,
4768 UINT srcdatalen,
4769 CONST D3DXMACRO* defines,
4770 LPD3DXINCLUDE include,
4771 DWORD flags,
4772 LPD3DXEFFECTPOOL pool,
4773 LPD3DXEFFECT* effect,
4774 LPD3DXBUFFER* compilation_errors)
4776 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
4777 include, flags, pool, effect, compilation_errors);
4779 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
4782 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
4784 HRESULT hr;
4785 struct ID3DXBaseEffectImpl *object = NULL;
4787 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
4789 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
4790 compiler->ref = 1;
4792 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4793 if (!object)
4795 ERR("Out of memory\n");
4796 hr = E_OUTOFMEMORY;
4797 goto err_out;
4800 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
4801 if (hr != D3D_OK)
4803 FIXME("Failed to parse effect.\n");
4804 goto err_out;
4807 compiler->base_effect = &object->ID3DXBaseEffect_iface;
4809 return D3D_OK;
4811 err_out:
4813 HeapFree(GetProcessHeap(), 0, object);
4814 free_effect_compiler(compiler);
4816 return hr;
4819 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
4820 UINT srcdatalen,
4821 CONST D3DXMACRO *defines,
4822 LPD3DXINCLUDE include,
4823 DWORD flags,
4824 LPD3DXEFFECTCOMPILER *compiler,
4825 LPD3DXBUFFER *parse_errors)
4827 struct ID3DXEffectCompilerImpl *object;
4828 HRESULT hr;
4830 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
4831 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
4833 if (!srcdata || !compiler)
4835 WARN("Invalid arguments supplied\n");
4836 return D3DERR_INVALIDCALL;
4839 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4840 if (!object)
4842 ERR("Out of memory\n");
4843 return E_OUTOFMEMORY;
4846 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
4847 if (FAILED(hr))
4849 WARN("Failed to initialize effect compiler\n");
4850 HeapFree(GetProcessHeap(), 0, object);
4851 return hr;
4854 *compiler = &object->ID3DXEffectCompiler_iface;
4856 TRACE("Created ID3DXEffectCompiler %p\n", object);
4858 return D3D_OK;
4861 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
4863 struct ID3DXEffectPoolImpl
4865 ID3DXEffectPool ID3DXEffectPool_iface;
4866 LONG ref;
4869 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
4871 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
4874 /*** IUnknown methods ***/
4875 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
4877 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4879 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
4881 if (IsEqualGUID(riid, &IID_IUnknown) ||
4882 IsEqualGUID(riid, &IID_ID3DXEffectPool))
4884 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
4885 *object = This;
4886 return S_OK;
4889 WARN("Interface %s not found\n", debugstr_guid(riid));
4891 return E_NOINTERFACE;
4894 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
4896 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4898 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
4900 return InterlockedIncrement(&This->ref);
4903 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
4905 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4906 ULONG ref = InterlockedDecrement(&This->ref);
4908 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
4910 if (!ref)
4911 HeapFree(GetProcessHeap(), 0, This);
4913 return ref;
4916 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
4918 /*** IUnknown methods ***/
4919 ID3DXEffectPoolImpl_QueryInterface,
4920 ID3DXEffectPoolImpl_AddRef,
4921 ID3DXEffectPoolImpl_Release
4924 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
4926 struct ID3DXEffectPoolImpl *object;
4928 TRACE("(%p)\n", pool);
4930 if (!pool)
4931 return D3DERR_INVALIDCALL;
4933 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4934 if (!object)
4936 ERR("Out of memory\n");
4937 return E_OUTOFMEMORY;
4940 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
4941 object->ref = 1;
4943 *pool = &object->ID3DXEffectPool_iface;
4945 return S_OK;
4948 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4949 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4950 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4952 LPVOID buffer;
4953 HRESULT ret;
4954 DWORD size;
4956 TRACE("(%s): relay\n", debugstr_w(srcfile));
4958 if (!device || !srcfile)
4959 return D3DERR_INVALIDCALL;
4961 ret = map_view_of_file(srcfile, &buffer, &size);
4963 if (FAILED(ret))
4964 return D3DXERR_INVALIDDATA;
4966 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4967 UnmapViewOfFile(buffer);
4969 return ret;
4972 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4973 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4974 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4976 LPWSTR srcfileW;
4977 HRESULT ret;
4978 DWORD len;
4980 TRACE("(void): relay\n");
4982 if (!srcfile)
4983 return D3DERR_INVALIDCALL;
4985 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4986 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4987 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4989 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4990 HeapFree(GetProcessHeap(), 0, srcfileW);
4992 return ret;
4995 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4996 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4997 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4999 TRACE("(void): relay\n");
5000 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5003 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5004 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5005 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5007 TRACE("(void): relay\n");
5008 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5011 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5012 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5013 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5015 HRSRC resinfo;
5017 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5019 if (!device)
5020 return D3DERR_INVALIDCALL;
5022 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5024 if (resinfo)
5026 LPVOID buffer;
5027 HRESULT ret;
5028 DWORD size;
5030 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5032 if (FAILED(ret))
5033 return D3DXERR_INVALIDDATA;
5035 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5038 return D3DXERR_INVALIDDATA;
5041 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5042 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5043 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5045 HRSRC resinfo;
5047 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5049 if (!device)
5050 return D3DERR_INVALIDCALL;
5052 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5054 if (resinfo)
5056 LPVOID buffer;
5057 HRESULT ret;
5058 DWORD size;
5060 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5062 if (FAILED(ret))
5063 return D3DXERR_INVALIDDATA;
5065 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5068 return D3DXERR_INVALIDDATA;
5071 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5072 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5073 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5075 TRACE("(void): relay\n");
5076 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5079 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5080 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5081 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5083 TRACE("(void): relay\n");
5084 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5087 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5088 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5090 LPVOID buffer;
5091 HRESULT ret;
5092 DWORD size;
5094 TRACE("(%s): relay\n", debugstr_w(srcfile));
5096 if (!srcfile)
5097 return D3DERR_INVALIDCALL;
5099 ret = map_view_of_file(srcfile, &buffer, &size);
5101 if (FAILED(ret))
5102 return D3DXERR_INVALIDDATA;
5104 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5105 UnmapViewOfFile(buffer);
5107 return ret;
5110 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5111 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5113 LPWSTR srcfileW;
5114 HRESULT ret;
5115 DWORD len;
5117 TRACE("(void): relay\n");
5119 if (!srcfile)
5120 return D3DERR_INVALIDCALL;
5122 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5123 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5124 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5126 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5127 HeapFree(GetProcessHeap(), 0, srcfileW);
5129 return ret;
5132 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5133 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5135 HRSRC resinfo;
5137 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5139 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5141 if (resinfo)
5143 LPVOID buffer;
5144 HRESULT ret;
5145 DWORD size;
5147 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5149 if (FAILED(ret))
5150 return D3DXERR_INVALIDDATA;
5152 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5155 return D3DXERR_INVALIDDATA;
5158 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5159 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5161 HRSRC resinfo;
5163 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5165 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5167 if (resinfo)
5169 LPVOID buffer;
5170 HRESULT ret;
5171 DWORD size;
5173 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5175 if (FAILED(ret))
5176 return D3DXERR_INVALIDDATA;
5178 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5181 return D3DXERR_INVALIDDATA;