d3dx9: Implement ID3DXEffect::Begin().
[wine.git] / dlls / d3dx9_36 / effect.c
bloba1bdc5d0f110889c9b6d9a1717067e6dcb91a90e
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 enum STATE_TYPE
90 ST_CONSTANT,
93 struct d3dx_parameter
95 char *name;
96 char *semantic;
97 void *data;
98 D3DXPARAMETER_CLASS class;
99 D3DXPARAMETER_TYPE type;
100 UINT rows;
101 UINT columns;
102 UINT element_count;
103 UINT annotation_count;
104 UINT member_count;
105 DWORD flags;
106 UINT bytes;
108 D3DXHANDLE *annotation_handles;
109 D3DXHANDLE *member_handles;
112 struct d3dx_state
114 UINT operation;
115 UINT index;
116 enum STATE_TYPE type;
117 D3DXHANDLE parameter;
120 struct d3dx_sampler
122 UINT state_count;
123 struct d3dx_state *states;
126 struct d3dx_pass
128 char *name;
129 UINT state_count;
130 UINT annotation_count;
132 struct d3dx_state *states;
133 D3DXHANDLE *annotation_handles;
136 struct d3dx_technique
138 char *name;
139 UINT pass_count;
140 UINT annotation_count;
142 D3DXHANDLE *annotation_handles;
143 D3DXHANDLE *pass_handles;
146 struct ID3DXBaseEffectImpl
148 ID3DXBaseEffect ID3DXBaseEffect_iface;
149 LONG ref;
151 struct ID3DXEffectImpl *effect;
153 UINT parameter_count;
154 UINT technique_count;
156 D3DXHANDLE *parameter_handles;
157 D3DXHANDLE *technique_handles;
160 struct ID3DXEffectImpl
162 ID3DXEffect ID3DXEffect_iface;
163 LONG ref;
165 LPD3DXEFFECTSTATEMANAGER manager;
166 LPDIRECT3DDEVICE9 device;
167 LPD3DXEFFECTPOOL pool;
168 D3DXHANDLE active_technique;
170 ID3DXBaseEffect *base_effect;
173 struct ID3DXEffectCompilerImpl
175 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
176 LONG ref;
178 ID3DXBaseEffect *base_effect;
181 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
182 struct d3dx_parameter *parameter, LPCSTR name);
183 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
184 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
185 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
187 static const struct
189 enum STATE_CLASS class;
190 UINT op;
191 LPCSTR name;
193 state_table[] =
195 /* Render sates */
196 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
197 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
198 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
199 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
200 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
201 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
202 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
203 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
204 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
205 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
206 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
207 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
208 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
209 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
210 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
211 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
212 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
213 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
214 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
215 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
216 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
217 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
218 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
219 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
220 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
221 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
222 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
223 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
224 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
225 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
226 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
227 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
228 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
229 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
230 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
231 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
232 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
233 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
234 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
235 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
236 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
237 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
238 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
239 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
240 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
241 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
242 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
243 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
244 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
245 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
246 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
247 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
248 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
249 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
250 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
251 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
252 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
253 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
254 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
255 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
256 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
257 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
258 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
259 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
260 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
261 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
262 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
263 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
264 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
265 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
266 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
267 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
268 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
269 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
270 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
271 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
272 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
273 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
274 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
275 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
276 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
277 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
278 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
279 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
280 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
281 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
282 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
283 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
284 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
285 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
286 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
287 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
288 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
289 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
290 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
291 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
292 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
293 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
294 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
295 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
296 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
297 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
298 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
299 /* Texture stages */
300 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
301 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
302 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
303 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
304 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
305 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
306 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
307 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
308 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
309 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
310 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
311 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
312 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
313 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
314 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
315 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
316 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
317 /* */
318 {SC_UNKNOWN, 0, "UNKNOWN"},
319 /* NPatchMode */
320 {SC_NPATCHMODE, 0, "NPatchMode"},
321 /* */
322 {SC_UNKNOWN, 0, "UNKNOWN"},
323 /* Transform */
324 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
325 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
326 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
327 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
328 /* Material */
329 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
330 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
331 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
332 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
333 {SC_MATERIAL, MT_POWER, "MaterialPower"},
334 /* Light */
335 {SC_LIGHT, LT_TYPE, "LightType"},
336 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
337 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
338 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
339 {SC_LIGHT, LT_POSITION, "LightPosition"},
340 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
341 {SC_LIGHT, LT_RANGE, "LightRange"},
342 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
343 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
344 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
345 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
346 {SC_LIGHT, LT_THETA, "LightTheta"},
347 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
348 /* Ligthenable */
349 {SC_LIGHTENABLE, 0, "LightEnable"},
350 /* Vertexshader */
351 {SC_VERTEXSHADER, 0, "Vertexshader"},
352 /* Pixelshader */
353 {SC_PIXELSHADER, 0, "Pixelshader"},
354 /* Shader constants */
355 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
356 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
357 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
358 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
359 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
360 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
361 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
362 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
363 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
364 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
365 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
366 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
367 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
368 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
369 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
370 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
371 /* Texture */
372 {SC_TEXTURE, 0, "Texture"},
373 /* Sampler states */
374 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
375 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
376 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
377 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
378 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
379 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
380 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
381 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
382 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
383 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
384 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
385 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
386 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
387 /* Set sampler */
388 {SC_SETSAMPLER, 0, "Sampler"},
391 static inline void read_dword(const char **ptr, DWORD *d)
393 memcpy(d, *ptr, sizeof(*d));
394 *ptr += sizeof(*d);
397 static void skip_dword_unknown(const char **ptr, unsigned int count)
399 unsigned int i;
400 DWORD d;
402 FIXME("Skipping %u unknown DWORDs:\n", count);
403 for (i = 0; i < count; ++i)
405 read_dword(ptr, &d);
406 FIXME("\t0x%08x\n", d);
410 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
412 return (struct d3dx_parameter *) handle;
415 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
417 return (struct d3dx_pass *) handle;
420 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
422 return (struct d3dx_technique *) handle;
425 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
427 return (D3DXHANDLE) parameter;
430 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
432 return (D3DXHANDLE) technique;
435 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
437 return (D3DXHANDLE) pass;
440 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
442 unsigned int i;
444 for (i = 0; i < base->technique_count; ++i)
446 if (base->technique_handles[i] == technique)
448 return get_technique_struct(technique);
452 return NULL;
455 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
457 unsigned int i, k;
459 for (i = 0; i < base->technique_count; ++i)
461 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
463 for (k = 0; k < technique->pass_count; ++k)
465 if (technique->pass_handles[k] == pass)
467 return get_pass_struct(pass);
472 return NULL;
475 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
477 unsigned int i, count;
478 struct d3dx_parameter *p;
480 for (i = 0; i < param->annotation_count; ++i)
482 if (param->annotation_handles[i] == parameter)
484 return get_parameter_struct(parameter);
487 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
488 if (p) return p;
491 if (param->element_count) count = param->element_count;
492 else count = param->member_count;
494 for (i = 0; i < count; ++i)
496 if (param->member_handles[i] == parameter)
498 return get_parameter_struct(parameter);
501 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
502 if (p) return p;
505 return NULL;
508 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
510 unsigned int i, k, m;
511 struct d3dx_parameter *p;
513 for (i = 0; i < base->parameter_count; ++i)
515 if (base->parameter_handles[i] == parameter)
517 return get_parameter_struct(parameter);
520 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
521 if (p) return p;
524 for (i = 0; i < base->technique_count; ++i)
526 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
528 for (k = 0; k < technique->pass_count; ++k)
530 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
532 for (m = 0; m < pass->annotation_count; ++m)
534 if (pass->annotation_handles[i] == parameter)
536 return get_parameter_struct(parameter);
539 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
540 if (p) return p;
544 for (k = 0; k < technique->annotation_count; ++k)
546 if (technique->annotation_handles[k] == parameter)
548 return get_parameter_struct(parameter);
551 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
552 if (p) return p;
556 return NULL;
559 static void free_state(struct d3dx_state *state)
561 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
564 static void free_sampler(struct d3dx_sampler *sampler)
566 UINT i;
568 for (i = 0; i < sampler->state_count; ++i)
570 free_state(&sampler->states[i]);
572 HeapFree(GetProcessHeap(), 0, sampler->states);
575 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
577 free_parameter_state(handle, element, child, ST_CONSTANT);
580 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
582 unsigned int i;
583 struct d3dx_parameter *param = get_parameter_struct(handle);
585 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
586 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
588 if (!param)
590 return;
593 if (param->annotation_handles)
595 for (i = 0; i < param->annotation_count; ++i)
597 free_parameter(param->annotation_handles[i], FALSE, FALSE);
599 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
602 if (param->member_handles)
604 unsigned int count;
606 if (param->element_count) count = param->element_count;
607 else count = param->member_count;
609 for (i = 0; i < count; ++i)
611 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
613 HeapFree(GetProcessHeap(), 0, param->member_handles);
616 if (param->class == D3DXPC_OBJECT && !param->element_count)
618 switch (param->type)
620 case D3DXPT_STRING:
621 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
622 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
623 break;
625 case D3DXPT_TEXTURE:
626 case D3DXPT_TEXTURE1D:
627 case D3DXPT_TEXTURE2D:
628 case D3DXPT_TEXTURE3D:
629 case D3DXPT_TEXTURECUBE:
630 case D3DXPT_PIXELSHADER:
631 case D3DXPT_VERTEXSHADER:
632 if (st == ST_CONSTANT)
634 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
636 else
638 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
640 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
641 break;
643 case D3DXPT_SAMPLER:
644 case D3DXPT_SAMPLER1D:
645 case D3DXPT_SAMPLER2D:
646 case D3DXPT_SAMPLER3D:
647 case D3DXPT_SAMPLERCUBE:
648 if (st == ST_CONSTANT)
650 free_sampler((struct d3dx_sampler *)param->data);
652 else
654 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
656 /* samplers have always own data, so free that */
657 HeapFree(GetProcessHeap(), 0, param->data);
658 break;
660 default:
661 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
662 break;
665 else
667 if (!child)
669 if (st != ST_CONSTANT)
671 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
673 HeapFree(GetProcessHeap(), 0, param->data);
677 /* only the parent has to release name and semantic */
678 if (!element)
680 HeapFree(GetProcessHeap(), 0, param->name);
681 HeapFree(GetProcessHeap(), 0, param->semantic);
684 HeapFree(GetProcessHeap(), 0, param);
687 static void free_pass(D3DXHANDLE handle)
689 unsigned int i;
690 struct d3dx_pass *pass = get_pass_struct(handle);
692 TRACE("Free pass %p\n", pass);
694 if (!pass)
696 return;
699 if (pass->annotation_handles)
701 for (i = 0; i < pass->annotation_count; ++i)
703 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
705 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
708 if (pass->states)
710 for (i = 0; i < pass->state_count; ++i)
712 free_state(&pass->states[i]);
714 HeapFree(GetProcessHeap(), 0, pass->states);
717 HeapFree(GetProcessHeap(), 0, pass->name);
718 HeapFree(GetProcessHeap(), 0, pass);
721 static void free_technique(D3DXHANDLE handle)
723 unsigned int i;
724 struct d3dx_technique *technique = get_technique_struct(handle);
726 TRACE("Free technique %p\n", technique);
728 if (!technique)
730 return;
733 if (technique->annotation_handles)
735 for (i = 0; i < technique->annotation_count; ++i)
737 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
739 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
742 if (technique->pass_handles)
744 for (i = 0; i < technique->pass_count; ++i)
746 free_pass(technique->pass_handles[i]);
748 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
751 HeapFree(GetProcessHeap(), 0, technique->name);
752 HeapFree(GetProcessHeap(), 0, technique);
755 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
757 unsigned int i;
759 TRACE("Free base effect %p\n", base);
761 if (base->parameter_handles)
763 for (i = 0; i < base->parameter_count; ++i)
765 free_parameter(base->parameter_handles[i], FALSE, FALSE);
767 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
770 if (base->technique_handles)
772 for (i = 0; i < base->technique_count; ++i)
774 free_technique(base->technique_handles[i]);
776 HeapFree(GetProcessHeap(), 0, base->technique_handles);
780 static void free_effect(struct ID3DXEffectImpl *effect)
782 TRACE("Free effect %p\n", effect);
784 if (effect->base_effect)
786 effect->base_effect->lpVtbl->Release(effect->base_effect);
789 if (effect->pool)
791 effect->pool->lpVtbl->Release(effect->pool);
794 if (effect->manager)
796 IUnknown_Release(effect->manager);
799 IDirect3DDevice9_Release(effect->device);
802 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
804 TRACE("Free effect compiler %p\n", compiler);
806 if (compiler->base_effect)
808 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
812 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
814 INT i;
816 switch (type)
818 case D3DXPT_FLOAT:
819 i = *(FLOAT *)data;
820 break;
822 case D3DXPT_INT:
823 i = *(INT *)data;
824 break;
826 case D3DXPT_BOOL:
827 i = *(BOOL *)data;
828 break;
830 default:
831 i = 0;
832 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
833 break;
836 return i;
839 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
841 FLOAT f;
843 switch (type)
845 case D3DXPT_FLOAT:
846 f = *(FLOAT *)data;
847 break;
849 case D3DXPT_INT:
850 f = *(INT *)data;
851 break;
853 case D3DXPT_BOOL:
854 f = *(BOOL *)data;
855 break;
857 default:
858 f = 0.0f;
859 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
860 break;
863 return f;
866 static inline BOOL get_bool(void *data)
868 return (*(DWORD *)data) ? TRUE : FALSE;
871 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
873 UINT element;
874 struct d3dx_parameter *temp_parameter;
875 LPCSTR part;
877 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
879 if (!name || !*name) return parameter;
881 element = atoi(name);
882 part = strchr(name, ']') + 1;
884 if (parameter->element_count > element)
886 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
888 switch (*part++)
890 case '.':
891 return get_parameter_by_name(NULL, temp_parameter, part);
893 case '@':
894 return get_parameter_annotation_by_name(temp_parameter, part);
896 case '\0':
897 TRACE("Returning parameter %p\n", temp_parameter);
898 return temp_parameter;
900 default:
901 FIXME("Unhandled case \"%c\"\n", *--part);
902 break;
906 TRACE("Parameter not found\n");
907 return NULL;
910 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
912 UINT i, length;
913 struct d3dx_parameter *temp_parameter;
914 LPCSTR part;
916 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
918 if (!name || !*name) return parameter;
920 length = strcspn( name, "[.@" );
921 part = name + length;
923 for (i = 0; i < parameter->annotation_count; ++i)
925 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
927 if (!strcmp(temp_parameter->name, name))
929 TRACE("Returning parameter %p\n", temp_parameter);
930 return temp_parameter;
932 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
934 switch (*part++)
936 case '.':
937 return get_parameter_by_name(NULL, temp_parameter, part);
939 case '[':
940 return get_parameter_element_by_name(temp_parameter, part);
942 default:
943 FIXME("Unhandled case \"%c\"\n", *--part);
944 break;
949 TRACE("Parameter not found\n");
950 return NULL;
953 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
954 struct d3dx_parameter *parameter, LPCSTR name)
956 UINT i, count, length;
957 struct d3dx_parameter *temp_parameter;
958 D3DXHANDLE *handles;
959 LPCSTR part;
961 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
963 if (!name || !*name) return parameter;
965 if (!parameter)
967 count = base->parameter_count;
968 handles = base->parameter_handles;
970 else
972 count = parameter->member_count;
973 handles = parameter->member_handles;
976 length = strcspn( name, "[.@" );
977 part = name + length;
979 for (i = 0; i < count; i++)
981 temp_parameter = get_parameter_struct(handles[i]);
983 if (!strcmp(temp_parameter->name, name))
985 TRACE("Returning parameter %p\n", temp_parameter);
986 return temp_parameter;
988 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
990 switch (*part++)
992 case '.':
993 return get_parameter_by_name(NULL, temp_parameter, part);
995 case '@':
996 return get_parameter_annotation_by_name(temp_parameter, part);
998 case '[':
999 return get_parameter_element_by_name(temp_parameter, part);
1001 default:
1002 FIXME("Unhandled case \"%c\"\n", *--part);
1003 break;
1008 TRACE("Parameter not found\n");
1009 return NULL;
1012 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1014 return (0xfeff0000 | ((major) << 8) | (minor));
1017 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1019 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1022 /*** IUnknown methods ***/
1023 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1025 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1027 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1029 if (IsEqualGUID(riid, &IID_IUnknown) ||
1030 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1032 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1033 *object = This;
1034 return S_OK;
1037 ERR("Interface %s not found\n", debugstr_guid(riid));
1039 return E_NOINTERFACE;
1042 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1044 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1046 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1048 return InterlockedIncrement(&This->ref);
1051 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1053 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1054 ULONG ref = InterlockedDecrement(&This->ref);
1056 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1058 if (!ref)
1060 free_base_effect(This);
1061 HeapFree(GetProcessHeap(), 0, This);
1064 return ref;
1067 /*** ID3DXBaseEffect methods ***/
1068 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1070 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1072 FIXME("iface %p, desc %p partial stub\n", This, desc);
1074 if (!desc)
1076 WARN("Invalid argument specified.\n");
1077 return D3DERR_INVALIDCALL;
1080 /* Todo: add creator and function count */
1081 desc->Creator = NULL;
1082 desc->Functions = 0;
1083 desc->Parameters = This->parameter_count;
1084 desc->Techniques = This->technique_count;
1086 return D3D_OK;
1089 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1091 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1092 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1094 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1096 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
1098 if (!desc || !param)
1100 WARN("Invalid argument specified.\n");
1101 return D3DERR_INVALIDCALL;
1104 desc->Name = param->name;
1105 desc->Semantic = param->semantic;
1106 desc->Class = param->class;
1107 desc->Type = param->type;
1108 desc->Rows = param->rows;
1109 desc->Columns = param->columns;
1110 desc->Elements = param->element_count;
1111 desc->Annotations = param->annotation_count;
1112 desc->StructMembers = param->member_count;
1113 desc->Flags = param->flags;
1114 desc->Bytes = param->bytes;
1116 return D3D_OK;
1119 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1121 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1122 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1124 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1126 if (!desc || !tech)
1128 WARN("Invalid argument specified.\n");
1129 return D3DERR_INVALIDCALL;
1132 desc->Name = tech->name;
1133 desc->Passes = tech->pass_count;
1134 desc->Annotations = tech->annotation_count;
1136 return D3D_OK;
1139 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1141 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1142 struct d3dx_pass *p = is_valid_pass(This, pass);
1144 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1146 if (!desc || !p)
1148 WARN("Invalid argument specified.\n");
1149 return D3DERR_INVALIDCALL;
1152 desc->Name = p->name;
1153 desc->Annotations = p->annotation_count;
1155 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1156 desc->pVertexShaderFunction = NULL;
1157 desc->pPixelShaderFunction = NULL;
1159 return D3D_OK;
1162 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1164 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1166 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1168 return E_NOTIMPL;
1171 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1173 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1174 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1176 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1178 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1180 if (!parameter)
1182 if (index < This->parameter_count)
1184 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1185 return This->parameter_handles[index];
1188 else
1190 if (param && !param->element_count && index < param->member_count)
1192 TRACE("Returning parameter %p\n", param->member_handles[index]);
1193 return param->member_handles[index];
1197 WARN("Invalid argument specified.\n");
1199 return NULL;
1202 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1204 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1205 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1206 D3DXHANDLE handle;
1208 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1210 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1212 if (!name)
1214 handle = get_parameter_handle(param);
1215 TRACE("Returning parameter %p\n", handle);
1216 return handle;
1219 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1220 TRACE("Returning parameter %p\n", handle);
1222 return handle;
1225 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1227 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1228 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1229 struct d3dx_parameter *temp_param;
1230 UINT i;
1232 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1234 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1236 if (!parameter)
1238 for (i = 0; i < This->parameter_count; ++i)
1240 temp_param = get_parameter_struct(This->parameter_handles[i]);
1242 if (!temp_param->semantic)
1244 if (!semantic)
1246 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1247 return This->parameter_handles[i];
1249 continue;
1252 if (!strcasecmp(temp_param->semantic, semantic))
1254 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1255 return This->parameter_handles[i];
1259 else if (param)
1261 for (i = 0; i < param->member_count; ++i)
1263 temp_param = get_parameter_struct(param->member_handles[i]);
1265 if (!temp_param->semantic)
1267 if (!semantic)
1269 TRACE("Returning parameter %p\n", param->member_handles[i]);
1270 return param->member_handles[i];
1272 continue;
1275 if (!strcasecmp(temp_param->semantic, semantic))
1277 TRACE("Returning parameter %p\n", param->member_handles[i]);
1278 return param->member_handles[i];
1283 WARN("Invalid argument specified\n");
1285 return NULL;
1288 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1290 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1291 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1293 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1295 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1297 if (!param)
1299 if (index < This->parameter_count)
1301 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1302 return This->parameter_handles[index];
1305 else
1307 if (index < param->element_count)
1309 TRACE("Returning parameter %p\n", param->member_handles[index]);
1310 return param->member_handles[index];
1314 WARN("Invalid argument specified\n");
1316 return NULL;
1319 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1321 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1323 TRACE("iface %p, index %u\n", This, index);
1325 if (index >= This->technique_count)
1327 WARN("Invalid argument specified.\n");
1328 return NULL;
1331 TRACE("Returning technique %p\n", This->technique_handles[index]);
1333 return This->technique_handles[index];
1336 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1338 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1339 unsigned int i;
1341 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1343 if (!name)
1345 WARN("Invalid argument specified.\n");
1346 return NULL;
1349 for (i = 0; i < This->technique_count; ++i)
1351 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1353 if (!strcmp(tech->name, name))
1355 TRACE("Returning technique %p\n", This->technique_handles[i]);
1356 return This->technique_handles[i];
1360 WARN("Invalid argument specified.\n");
1362 return NULL;
1365 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1367 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1368 struct d3dx_technique *tech = is_valid_technique(This, technique);
1370 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1372 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1374 if (tech && index < tech->pass_count)
1376 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1377 return tech->pass_handles[index];
1380 WARN("Invalid argument specified.\n");
1382 return NULL;
1385 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1387 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1388 struct d3dx_technique *tech = is_valid_technique(This, technique);
1390 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1392 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1394 if (tech && name)
1396 unsigned int i;
1398 for (i = 0; i < tech->pass_count; ++i)
1400 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1402 if (!strcmp(pass->name, name))
1404 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1405 return tech->pass_handles[i];
1410 WARN("Invalid argument specified.\n");
1412 return NULL;
1415 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1417 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1419 FIXME("iface %p, index %u stub\n", This, index);
1421 return NULL;
1424 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1426 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1428 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1430 return NULL;
1433 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1435 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1436 struct d3dx_parameter *param = is_valid_parameter(This, object);
1437 struct d3dx_pass *pass = is_valid_pass(This, object);
1438 struct d3dx_technique *technique = is_valid_technique(This, object);
1439 UINT annotation_count = 0;
1440 D3DXHANDLE *annotation_handles = NULL;
1442 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1444 if (pass)
1446 annotation_count = pass->annotation_count;
1447 annotation_handles = pass->annotation_handles;
1449 else if (technique)
1451 annotation_count = technique->annotation_count;
1452 annotation_handles = technique->annotation_handles;
1454 else
1456 if (!param) param = get_parameter_by_name(This, NULL, object);
1458 if (param)
1460 annotation_count = param->annotation_count;
1461 annotation_handles = param->annotation_handles;
1464 /* Todo: add funcs */
1466 if (index < annotation_count)
1468 TRACE("Returning parameter %p\n", annotation_handles[index]);
1469 return annotation_handles[index];
1472 WARN("Invalid argument specified\n");
1474 return NULL;
1477 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1479 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1480 struct d3dx_parameter *param = is_valid_parameter(This, object);
1481 struct d3dx_pass *pass = is_valid_pass(This, object);
1482 struct d3dx_technique *technique = is_valid_technique(This, object);
1483 UINT annotation_count = 0, i;
1484 D3DXHANDLE *annotation_handles = NULL;
1486 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1488 if (!name)
1490 WARN("Invalid argument specified\n");
1491 return NULL;
1494 if (pass)
1496 annotation_count = pass->annotation_count;
1497 annotation_handles = pass->annotation_handles;
1499 else if (technique)
1501 annotation_count = technique->annotation_count;
1502 annotation_handles = technique->annotation_handles;
1504 else
1506 if (!param) param = get_parameter_by_name(This, NULL, object);
1508 if (param)
1510 annotation_count = param->annotation_count;
1511 annotation_handles = param->annotation_handles;
1514 /* Todo: add funcs */
1516 for (i = 0; i < annotation_count; i++)
1518 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1520 if (!strcmp(anno->name, name))
1522 TRACE("Returning parameter %p\n", anno);
1523 return get_parameter_handle(anno);
1527 WARN("Invalid argument specified\n");
1529 return NULL;
1532 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1534 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1536 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1538 return E_NOTIMPL;
1541 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1543 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1544 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1546 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1548 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1549 if (!param)
1551 WARN("Invalid parameter %p specified\n", parameter);
1552 return D3DERR_INVALIDCALL;
1555 /* samplers don't touch data */
1556 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1557 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1558 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1560 TRACE("Sampler: returning E_FAIL\n");
1561 return E_FAIL;
1564 if (data && param->bytes <= bytes)
1566 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1568 switch (param->type)
1570 case D3DXPT_VOID:
1571 case D3DXPT_BOOL:
1572 case D3DXPT_INT:
1573 case D3DXPT_FLOAT:
1574 case D3DXPT_STRING:
1575 break;
1577 case D3DXPT_VERTEXSHADER:
1578 case D3DXPT_PIXELSHADER:
1579 case D3DXPT_TEXTURE:
1580 case D3DXPT_TEXTURE1D:
1581 case D3DXPT_TEXTURE2D:
1582 case D3DXPT_TEXTURE3D:
1583 case D3DXPT_TEXTURECUBE:
1585 UINT i;
1587 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1589 IUnknown *unk = ((IUnknown **)param->data)[i];
1590 if (unk) IUnknown_AddRef(unk);
1592 break;
1595 default:
1596 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1597 break;
1600 TRACE("Copy %u bytes\n", param->bytes);
1601 memcpy(data, param->data, param->bytes);
1602 return D3D_OK;
1605 WARN("Invalid argument specified\n");
1607 return D3DERR_INVALIDCALL;
1610 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1612 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1614 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1616 return E_NOTIMPL;
1619 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1621 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1622 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1624 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1626 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1628 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1630 *b = get_bool(param->data);
1631 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1632 return D3D_OK;
1635 WARN("Invalid argument specified\n");
1637 return D3DERR_INVALIDCALL;
1640 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1642 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1644 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1646 return E_NOTIMPL;
1649 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1651 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1652 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1654 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1656 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1658 if (b && param && (param->class == D3DXPC_SCALAR
1659 || param->class == D3DXPC_VECTOR
1660 || param->class == D3DXPC_MATRIX_ROWS
1661 || param->class == D3DXPC_MATRIX_COLUMNS))
1663 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1665 for (i = 0; i < size; ++i)
1667 b[i] = get_bool((DWORD *)param->data + i);
1669 return D3D_OK;
1672 WARN("Invalid argument specified\n");
1674 return D3DERR_INVALIDCALL;
1677 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1679 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1681 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1683 return E_NOTIMPL;
1686 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1688 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1689 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1691 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1693 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1695 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1697 *n = get_int(param->type, param->data);
1698 TRACE("Returning %i\n", *n);
1699 return D3D_OK;
1702 WARN("Invalid argument specified\n");
1704 return D3DERR_INVALIDCALL;
1707 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1709 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1711 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1713 return E_NOTIMPL;
1716 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1718 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1719 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1721 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1723 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1725 if (n && param && (param->class == D3DXPC_SCALAR
1726 || param->class == D3DXPC_VECTOR
1727 || param->class == D3DXPC_MATRIX_ROWS
1728 || param->class == D3DXPC_MATRIX_COLUMNS))
1730 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1732 for (i = 0; i < size; ++i)
1734 n[i] = get_int(param->type, (DWORD *)param->data + i);
1736 return D3D_OK;
1739 WARN("Invalid argument specified\n");
1741 return D3DERR_INVALIDCALL;
1744 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1746 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1748 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1750 return E_NOTIMPL;
1753 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1755 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1756 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1758 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1760 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1762 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1764 f = param->data;
1765 TRACE("Returning %f\n", *f);
1766 return D3D_OK;
1769 WARN("Invalid argument specified\n");
1771 return D3DERR_INVALIDCALL;
1774 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1776 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1778 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1780 return E_NOTIMPL;
1783 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1785 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1786 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1788 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1790 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1792 if (f && param && (param->class == D3DXPC_SCALAR
1793 || param->class == D3DXPC_VECTOR
1794 || param->class == D3DXPC_MATRIX_ROWS
1795 || param->class == D3DXPC_MATRIX_COLUMNS))
1797 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1799 for (i = 0; i < size; ++i)
1801 f[i] = get_float(param->type, (DWORD *)param->data + i);
1803 return D3D_OK;
1806 WARN("Invalid argument specified\n");
1808 return D3DERR_INVALIDCALL;
1811 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1813 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1815 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1817 return E_NOTIMPL;
1820 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1822 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1824 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1826 return E_NOTIMPL;
1829 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1831 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1833 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1835 return E_NOTIMPL;
1838 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1840 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1842 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1844 return E_NOTIMPL;
1847 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1849 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1851 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1853 return E_NOTIMPL;
1856 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1858 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1860 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1862 return E_NOTIMPL;
1865 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1867 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1869 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1871 return E_NOTIMPL;
1874 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1876 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1878 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1880 return E_NOTIMPL;
1883 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1885 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1887 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1889 return E_NOTIMPL;
1892 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1894 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1896 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1898 return E_NOTIMPL;
1901 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1903 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1905 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1907 return E_NOTIMPL;
1910 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1912 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1914 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1916 return E_NOTIMPL;
1919 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1921 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1923 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1925 return E_NOTIMPL;
1928 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1930 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1932 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1934 return E_NOTIMPL;
1937 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1939 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1941 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1943 return E_NOTIMPL;
1946 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1948 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1950 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1952 return E_NOTIMPL;
1955 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1957 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1959 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1961 return E_NOTIMPL;
1964 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1966 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1967 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1969 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1971 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1973 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1975 *string = *(LPCSTR *)param->data;
1976 TRACE("Returning %s\n", debugstr_a(*string));
1977 return D3D_OK;
1980 WARN("Invalid argument specified\n");
1982 return D3DERR_INVALIDCALL;
1985 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1987 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1989 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1991 return E_NOTIMPL;
1994 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
1996 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1997 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1999 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2001 if (texture && param && !param->element_count &&
2002 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2003 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2004 || param->type == D3DXPT_TEXTURECUBE))
2006 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2007 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2008 TRACE("Returning %p\n", *texture);
2009 return D3D_OK;
2012 WARN("Invalid argument specified\n");
2014 return D3DERR_INVALIDCALL;
2017 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2019 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2020 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2022 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2024 if (!param) param = get_parameter_by_name(This, NULL, parameter);
2026 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2028 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2029 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2030 TRACE("Returning %p\n", *pshader);
2031 return D3D_OK;
2034 WARN("Invalid argument specified\n");
2036 return D3DERR_INVALIDCALL;
2039 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2041 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2042 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2044 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2046 if (!param) param = get_parameter_by_name(This, NULL, parameter);
2048 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2050 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2051 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2052 TRACE("Returning %p\n", *vshader);
2053 return D3D_OK;
2056 WARN("Invalid argument specified\n");
2058 return D3DERR_INVALIDCALL;
2061 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2063 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2065 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2067 return E_NOTIMPL;
2070 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2072 /*** IUnknown methods ***/
2073 ID3DXBaseEffectImpl_QueryInterface,
2074 ID3DXBaseEffectImpl_AddRef,
2075 ID3DXBaseEffectImpl_Release,
2076 /*** ID3DXBaseEffect methods ***/
2077 ID3DXBaseEffectImpl_GetDesc,
2078 ID3DXBaseEffectImpl_GetParameterDesc,
2079 ID3DXBaseEffectImpl_GetTechniqueDesc,
2080 ID3DXBaseEffectImpl_GetPassDesc,
2081 ID3DXBaseEffectImpl_GetFunctionDesc,
2082 ID3DXBaseEffectImpl_GetParameter,
2083 ID3DXBaseEffectImpl_GetParameterByName,
2084 ID3DXBaseEffectImpl_GetParameterBySemantic,
2085 ID3DXBaseEffectImpl_GetParameterElement,
2086 ID3DXBaseEffectImpl_GetTechnique,
2087 ID3DXBaseEffectImpl_GetTechniqueByName,
2088 ID3DXBaseEffectImpl_GetPass,
2089 ID3DXBaseEffectImpl_GetPassByName,
2090 ID3DXBaseEffectImpl_GetFunction,
2091 ID3DXBaseEffectImpl_GetFunctionByName,
2092 ID3DXBaseEffectImpl_GetAnnotation,
2093 ID3DXBaseEffectImpl_GetAnnotationByName,
2094 ID3DXBaseEffectImpl_SetValue,
2095 ID3DXBaseEffectImpl_GetValue,
2096 ID3DXBaseEffectImpl_SetBool,
2097 ID3DXBaseEffectImpl_GetBool,
2098 ID3DXBaseEffectImpl_SetBoolArray,
2099 ID3DXBaseEffectImpl_GetBoolArray,
2100 ID3DXBaseEffectImpl_SetInt,
2101 ID3DXBaseEffectImpl_GetInt,
2102 ID3DXBaseEffectImpl_SetIntArray,
2103 ID3DXBaseEffectImpl_GetIntArray,
2104 ID3DXBaseEffectImpl_SetFloat,
2105 ID3DXBaseEffectImpl_GetFloat,
2106 ID3DXBaseEffectImpl_SetFloatArray,
2107 ID3DXBaseEffectImpl_GetFloatArray,
2108 ID3DXBaseEffectImpl_SetVector,
2109 ID3DXBaseEffectImpl_GetVector,
2110 ID3DXBaseEffectImpl_SetVectorArray,
2111 ID3DXBaseEffectImpl_GetVectorArray,
2112 ID3DXBaseEffectImpl_SetMatrix,
2113 ID3DXBaseEffectImpl_GetMatrix,
2114 ID3DXBaseEffectImpl_SetMatrixArray,
2115 ID3DXBaseEffectImpl_GetMatrixArray,
2116 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2117 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2118 ID3DXBaseEffectImpl_SetMatrixTranspose,
2119 ID3DXBaseEffectImpl_GetMatrixTranspose,
2120 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2121 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2122 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2123 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2124 ID3DXBaseEffectImpl_SetString,
2125 ID3DXBaseEffectImpl_GetString,
2126 ID3DXBaseEffectImpl_SetTexture,
2127 ID3DXBaseEffectImpl_GetTexture,
2128 ID3DXBaseEffectImpl_GetPixelShader,
2129 ID3DXBaseEffectImpl_GetVertexShader,
2130 ID3DXBaseEffectImpl_SetArrayRange,
2133 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2135 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2138 /*** IUnknown methods ***/
2139 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2141 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2143 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2145 if (IsEqualGUID(riid, &IID_IUnknown) ||
2146 IsEqualGUID(riid, &IID_ID3DXEffect))
2148 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2149 *object = This;
2150 return S_OK;
2153 ERR("Interface %s not found\n", debugstr_guid(riid));
2155 return E_NOINTERFACE;
2158 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2160 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2162 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2164 return InterlockedIncrement(&This->ref);
2167 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2169 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2170 ULONG ref = InterlockedDecrement(&This->ref);
2172 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2174 if (!ref)
2176 free_effect(This);
2177 HeapFree(GetProcessHeap(), 0, This);
2180 return ref;
2183 /*** ID3DXBaseEffect methods ***/
2184 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2186 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2187 ID3DXBaseEffect *base = This->base_effect;
2189 TRACE("Forward iface %p, base %p\n", This, base);
2191 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2194 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2196 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2197 ID3DXBaseEffect *base = This->base_effect;
2199 TRACE("Forward iface %p, base %p\n", This, base);
2201 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2204 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2206 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2207 ID3DXBaseEffect *base = This->base_effect;
2209 TRACE("Forward iface %p, base %p\n", This, base);
2211 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2214 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2216 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2217 ID3DXBaseEffect *base = This->base_effect;
2219 TRACE("Forward iface %p, base %p\n", This, base);
2221 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2224 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2226 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2227 ID3DXBaseEffect *base = This->base_effect;
2229 TRACE("Forward iface %p, base %p\n", This, base);
2231 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2234 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2236 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2237 ID3DXBaseEffect *base = This->base_effect;
2239 TRACE("Forward iface %p, base %p\n", This, base);
2241 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2244 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2246 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2247 ID3DXBaseEffect *base = This->base_effect;
2249 TRACE("Forward iface %p, base %p\n", This, base);
2251 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2254 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2256 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2257 ID3DXBaseEffect *base = This->base_effect;
2259 TRACE("Forward iface %p, base %p\n", This, base);
2261 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2264 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2266 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2267 ID3DXBaseEffect *base = This->base_effect;
2269 TRACE("Forward iface %p, base %p\n", This, base);
2271 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2274 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2276 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2277 ID3DXBaseEffect *base = This->base_effect;
2279 TRACE("Forward iface %p, base %p\n", This, base);
2281 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2284 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2286 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2287 ID3DXBaseEffect *base = This->base_effect;
2289 TRACE("Forward iface %p, base %p\n", This, base);
2291 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2294 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2296 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2297 ID3DXBaseEffect *base = This->base_effect;
2299 TRACE("Forward iface %p, base %p\n", This, base);
2301 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2304 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2306 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2307 ID3DXBaseEffect *base = This->base_effect;
2309 TRACE("Forward iface %p, base %p\n", This, base);
2311 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2314 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2316 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2317 ID3DXBaseEffect *base = This->base_effect;
2319 TRACE("Forward iface %p, base %p\n", This, base);
2321 return ID3DXBaseEffectImpl_GetFunction(base, index);
2324 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2326 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2327 ID3DXBaseEffect *base = This->base_effect;
2329 TRACE("Forward iface %p, base %p\n", This, base);
2331 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2334 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2336 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2337 ID3DXBaseEffect *base = This->base_effect;
2339 TRACE("Forward iface %p, base %p\n", This, base);
2341 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2344 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2346 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2347 ID3DXBaseEffect *base = This->base_effect;
2349 TRACE("Forward iface %p, base %p\n", This, base);
2351 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2354 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2356 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2357 ID3DXBaseEffect *base = This->base_effect;
2359 TRACE("Forward iface %p, base %p\n", This, base);
2361 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2364 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2366 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2367 ID3DXBaseEffect *base = This->base_effect;
2369 TRACE("Forward iface %p, base %p\n", This, base);
2371 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2374 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2376 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2377 ID3DXBaseEffect *base = This->base_effect;
2379 TRACE("Forward iface %p, base %p\n", This, base);
2381 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2384 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2386 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2387 ID3DXBaseEffect *base = This->base_effect;
2389 TRACE("Forward iface %p, base %p\n", This, base);
2391 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2394 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2396 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2397 ID3DXBaseEffect *base = This->base_effect;
2399 TRACE("Forward iface %p, base %p\n", This, base);
2401 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2404 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2406 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2407 ID3DXBaseEffect *base = This->base_effect;
2409 TRACE("Forward iface %p, base %p\n", This, base);
2411 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2414 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2416 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2417 ID3DXBaseEffect *base = This->base_effect;
2419 TRACE("Forward iface %p, base %p\n", This, base);
2421 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2424 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2426 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2427 ID3DXBaseEffect *base = This->base_effect;
2429 TRACE("Forward iface %p, base %p\n", This, base);
2431 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2434 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2436 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2437 ID3DXBaseEffect *base = This->base_effect;
2439 TRACE("Forward iface %p, base %p\n", This, base);
2441 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2444 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2446 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2447 ID3DXBaseEffect *base = This->base_effect;
2449 TRACE("Forward iface %p, base %p\n", This, base);
2451 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2454 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2456 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2457 ID3DXBaseEffect *base = This->base_effect;
2459 TRACE("Forward iface %p, base %p\n", This, base);
2461 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2464 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2466 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2467 ID3DXBaseEffect *base = This->base_effect;
2469 TRACE("Forward iface %p, base %p\n", This, base);
2471 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2474 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2476 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2477 ID3DXBaseEffect *base = This->base_effect;
2479 TRACE("Forward iface %p, base %p\n", This, base);
2481 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2484 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2486 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2487 ID3DXBaseEffect *base = This->base_effect;
2489 TRACE("Forward iface %p, base %p\n", This, base);
2491 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2494 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2496 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2497 ID3DXBaseEffect *base = This->base_effect;
2499 TRACE("Forward iface %p, base %p\n", This, base);
2501 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2504 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2506 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2507 ID3DXBaseEffect *base = This->base_effect;
2509 TRACE("Forward iface %p, base %p\n", This, base);
2511 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2514 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2516 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2517 ID3DXBaseEffect *base = This->base_effect;
2519 TRACE("Forward iface %p, base %p\n", This, base);
2521 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2524 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2526 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2527 ID3DXBaseEffect *base = This->base_effect;
2529 TRACE("Forward iface %p, base %p\n", This, base);
2531 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2534 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2536 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2537 ID3DXBaseEffect *base = This->base_effect;
2539 TRACE("Forward iface %p, base %p\n", This, base);
2541 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2544 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2546 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2547 ID3DXBaseEffect *base = This->base_effect;
2549 TRACE("Forward iface %p, base %p\n", This, base);
2551 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2554 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2556 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2557 ID3DXBaseEffect *base = This->base_effect;
2559 TRACE("Forward iface %p, base %p\n", This, base);
2561 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2564 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2566 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2567 ID3DXBaseEffect *base = This->base_effect;
2569 TRACE("Forward iface %p, base %p\n", This, base);
2571 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2574 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2576 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2577 ID3DXBaseEffect *base = This->base_effect;
2579 TRACE("Forward iface %p, base %p\n", This, base);
2581 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2584 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2586 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2587 ID3DXBaseEffect *base = This->base_effect;
2589 TRACE("Forward iface %p, base %p\n", This, base);
2591 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2594 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2596 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2597 ID3DXBaseEffect *base = This->base_effect;
2599 TRACE("Forward iface %p, base %p\n", This, base);
2601 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2604 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2606 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2607 ID3DXBaseEffect *base = This->base_effect;
2609 TRACE("Forward iface %p, base %p\n", This, base);
2611 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2614 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2616 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2617 ID3DXBaseEffect *base = This->base_effect;
2619 TRACE("Forward iface %p, base %p\n", This, base);
2621 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2624 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2626 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2627 ID3DXBaseEffect *base = This->base_effect;
2629 TRACE("Forward iface %p, base %p\n", This, base);
2631 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2634 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2636 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2637 ID3DXBaseEffect *base = This->base_effect;
2639 TRACE("Forward iface %p, base %p\n", This, base);
2641 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2644 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2646 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2647 ID3DXBaseEffect *base = This->base_effect;
2649 TRACE("Forward iface %p, base %p\n", This, base);
2651 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2654 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2656 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2657 ID3DXBaseEffect *base = This->base_effect;
2659 TRACE("Forward iface %p, base %p\n", This, base);
2661 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2664 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2666 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2667 ID3DXBaseEffect *base = This->base_effect;
2669 TRACE("Forward iface %p, base %p\n", This, base);
2671 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2674 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2676 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2677 ID3DXBaseEffect *base = This->base_effect;
2679 TRACE("Forward iface %p, base %p\n", This, base);
2681 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2684 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2686 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2687 ID3DXBaseEffect *base = This->base_effect;
2689 TRACE("Forward iface %p, base %p\n", This, base);
2691 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2694 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2696 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2697 ID3DXBaseEffect *base = This->base_effect;
2699 TRACE("Forward iface %p, base %p\n", This, base);
2701 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2704 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2706 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2707 ID3DXBaseEffect *base = This->base_effect;
2709 TRACE("Forward iface %p, base %p\n", This, base);
2711 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2714 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2716 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2717 ID3DXBaseEffect *base = This->base_effect;
2719 TRACE("Forward iface %p, base %p\n", This, base);
2721 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2724 /*** ID3DXEffect methods ***/
2725 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2727 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2729 TRACE("iface %p, pool %p\n", This, pool);
2731 if (!pool)
2733 WARN("Invalid argument supplied.\n");
2734 return D3DERR_INVALIDCALL;
2737 if (This->pool)
2739 This->pool->lpVtbl->AddRef(This->pool);
2742 *pool = This->pool;
2744 TRACE("Returning pool %p\n", *pool);
2746 return S_OK;
2749 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2751 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2753 FIXME("(%p)->(%p): stub\n", This, technique);
2755 return E_NOTIMPL;
2758 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
2760 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2762 FIXME("(%p)->(): stub\n", This);
2764 return NULL;
2767 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2769 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2771 FIXME("(%p)->(%p): stub\n", This, technique);
2773 return D3D_OK;
2776 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2778 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2780 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2782 return E_NOTIMPL;
2785 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2787 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2789 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2791 return FALSE;
2794 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
2796 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2797 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2799 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
2801 if (passes && technique)
2803 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
2805 TRACE("State capturing disabled.\n");
2807 else
2809 FIXME("State capturing not supported, yet!\n");
2812 *passes = technique->pass_count;
2814 return D3D_OK;
2817 WARN("Invalid argument supplied.\n");
2819 return D3DERR_INVALIDCALL;
2822 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
2824 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2826 FIXME("(%p)->(%u): stub\n", This, pass);
2828 return E_NOTIMPL;
2831 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2833 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2835 FIXME("(%p)->(): stub\n", This);
2837 return E_NOTIMPL;
2840 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
2842 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2844 FIXME("(%p)->(): stub\n", This);
2846 return E_NOTIMPL;
2849 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2851 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2853 FIXME("(%p)->(): stub\n", This);
2855 return E_NOTIMPL;
2858 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2860 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2862 TRACE("iface %p, device %p\n", This, device);
2864 if (!device)
2866 WARN("Invalid argument supplied.\n");
2867 return D3DERR_INVALIDCALL;
2870 IDirect3DDevice9_AddRef(This->device);
2872 *device = This->device;
2874 TRACE("Returning device %p\n", *device);
2876 return S_OK;
2879 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2881 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2883 FIXME("(%p)->(): stub\n", This);
2885 return E_NOTIMPL;
2888 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2890 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2892 FIXME("(%p)->(): stub\n", This);
2894 return E_NOTIMPL;
2897 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2899 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2901 TRACE("iface %p, manager %p\n", This, manager);
2903 if (This->manager) IUnknown_Release(This->manager);
2904 if (manager) IUnknown_AddRef(manager);
2906 This->manager = manager;
2908 return D3D_OK;
2911 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2913 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2915 TRACE("iface %p, manager %p\n", This, manager);
2917 if (!manager)
2919 WARN("Invalid argument supplied.\n");
2920 return D3DERR_INVALIDCALL;
2923 if (This->manager) IUnknown_AddRef(This->manager);
2924 *manager = This->manager;
2926 return D3D_OK;
2929 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2931 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2933 FIXME("(%p)->(): stub\n", This);
2935 return E_NOTIMPL;
2938 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2940 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2942 FIXME("(%p)->(): stub\n", This);
2944 return NULL;
2947 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2949 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2951 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2953 return E_NOTIMPL;
2956 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2958 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2960 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2962 return E_NOTIMPL;
2965 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
2967 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2969 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
2971 return E_NOTIMPL;
2974 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
2976 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2978 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
2980 return E_NOTIMPL;
2983 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
2985 /*** IUnknown methods ***/
2986 ID3DXEffectImpl_QueryInterface,
2987 ID3DXEffectImpl_AddRef,
2988 ID3DXEffectImpl_Release,
2989 /*** ID3DXBaseEffect methods ***/
2990 ID3DXEffectImpl_GetDesc,
2991 ID3DXEffectImpl_GetParameterDesc,
2992 ID3DXEffectImpl_GetTechniqueDesc,
2993 ID3DXEffectImpl_GetPassDesc,
2994 ID3DXEffectImpl_GetFunctionDesc,
2995 ID3DXEffectImpl_GetParameter,
2996 ID3DXEffectImpl_GetParameterByName,
2997 ID3DXEffectImpl_GetParameterBySemantic,
2998 ID3DXEffectImpl_GetParameterElement,
2999 ID3DXEffectImpl_GetTechnique,
3000 ID3DXEffectImpl_GetTechniqueByName,
3001 ID3DXEffectImpl_GetPass,
3002 ID3DXEffectImpl_GetPassByName,
3003 ID3DXEffectImpl_GetFunction,
3004 ID3DXEffectImpl_GetFunctionByName,
3005 ID3DXEffectImpl_GetAnnotation,
3006 ID3DXEffectImpl_GetAnnotationByName,
3007 ID3DXEffectImpl_SetValue,
3008 ID3DXEffectImpl_GetValue,
3009 ID3DXEffectImpl_SetBool,
3010 ID3DXEffectImpl_GetBool,
3011 ID3DXEffectImpl_SetBoolArray,
3012 ID3DXEffectImpl_GetBoolArray,
3013 ID3DXEffectImpl_SetInt,
3014 ID3DXEffectImpl_GetInt,
3015 ID3DXEffectImpl_SetIntArray,
3016 ID3DXEffectImpl_GetIntArray,
3017 ID3DXEffectImpl_SetFloat,
3018 ID3DXEffectImpl_GetFloat,
3019 ID3DXEffectImpl_SetFloatArray,
3020 ID3DXEffectImpl_GetFloatArray,
3021 ID3DXEffectImpl_SetVector,
3022 ID3DXEffectImpl_GetVector,
3023 ID3DXEffectImpl_SetVectorArray,
3024 ID3DXEffectImpl_GetVectorArray,
3025 ID3DXEffectImpl_SetMatrix,
3026 ID3DXEffectImpl_GetMatrix,
3027 ID3DXEffectImpl_SetMatrixArray,
3028 ID3DXEffectImpl_GetMatrixArray,
3029 ID3DXEffectImpl_SetMatrixPointerArray,
3030 ID3DXEffectImpl_GetMatrixPointerArray,
3031 ID3DXEffectImpl_SetMatrixTranspose,
3032 ID3DXEffectImpl_GetMatrixTranspose,
3033 ID3DXEffectImpl_SetMatrixTransposeArray,
3034 ID3DXEffectImpl_GetMatrixTransposeArray,
3035 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3036 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3037 ID3DXEffectImpl_SetString,
3038 ID3DXEffectImpl_GetString,
3039 ID3DXEffectImpl_SetTexture,
3040 ID3DXEffectImpl_GetTexture,
3041 ID3DXEffectImpl_GetPixelShader,
3042 ID3DXEffectImpl_GetVertexShader,
3043 ID3DXEffectImpl_SetArrayRange,
3044 /*** ID3DXEffect methods ***/
3045 ID3DXEffectImpl_GetPool,
3046 ID3DXEffectImpl_SetTechnique,
3047 ID3DXEffectImpl_GetCurrentTechnique,
3048 ID3DXEffectImpl_ValidateTechnique,
3049 ID3DXEffectImpl_FindNextValidTechnique,
3050 ID3DXEffectImpl_IsParameterUsed,
3051 ID3DXEffectImpl_Begin,
3052 ID3DXEffectImpl_BeginPass,
3053 ID3DXEffectImpl_CommitChanges,
3054 ID3DXEffectImpl_EndPass,
3055 ID3DXEffectImpl_End,
3056 ID3DXEffectImpl_GetDevice,
3057 ID3DXEffectImpl_OnLostDevice,
3058 ID3DXEffectImpl_OnResetDevice,
3059 ID3DXEffectImpl_SetStateManager,
3060 ID3DXEffectImpl_GetStateManager,
3061 ID3DXEffectImpl_BeginParameterBlock,
3062 ID3DXEffectImpl_EndParameterBlock,
3063 ID3DXEffectImpl_ApplyParameterBlock,
3064 ID3DXEffectImpl_DeleteParameterBlock,
3065 ID3DXEffectImpl_CloneEffect,
3066 ID3DXEffectImpl_SetRawValue
3069 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3071 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3074 /*** IUnknown methods ***/
3075 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3077 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3079 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3081 if (IsEqualGUID(riid, &IID_IUnknown) ||
3082 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3084 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3085 *object = This;
3086 return S_OK;
3089 ERR("Interface %s not found\n", debugstr_guid(riid));
3091 return E_NOINTERFACE;
3094 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3096 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3098 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3100 return InterlockedIncrement(&This->ref);
3103 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3105 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3106 ULONG ref = InterlockedDecrement(&This->ref);
3108 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3110 if (!ref)
3112 free_effect_compiler(This);
3113 HeapFree(GetProcessHeap(), 0, This);
3116 return ref;
3119 /*** ID3DXBaseEffect methods ***/
3120 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3122 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3123 ID3DXBaseEffect *base = This->base_effect;
3125 TRACE("Forward iface %p, base %p\n", This, base);
3127 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3130 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3132 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3133 ID3DXBaseEffect *base = This->base_effect;
3135 TRACE("Forward iface %p, base %p\n", This, base);
3137 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3140 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3142 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3143 ID3DXBaseEffect *base = This->base_effect;
3145 TRACE("Forward iface %p, base %p\n", This, base);
3147 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3150 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3152 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3153 ID3DXBaseEffect *base = This->base_effect;
3155 TRACE("Forward iface %p, base %p\n", This, base);
3157 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3160 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3162 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3163 ID3DXBaseEffect *base = This->base_effect;
3165 TRACE("Forward iface %p, base %p\n", This, base);
3167 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3170 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3172 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3173 ID3DXBaseEffect *base = This->base_effect;
3175 TRACE("Forward iface %p, base %p\n", This, base);
3177 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3180 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3182 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3183 ID3DXBaseEffect *base = This->base_effect;
3185 TRACE("Forward iface %p, base %p\n", This, base);
3187 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3190 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3192 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3193 ID3DXBaseEffect *base = This->base_effect;
3195 TRACE("Forward iface %p, base %p\n", This, base);
3197 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3200 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3202 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3203 ID3DXBaseEffect *base = This->base_effect;
3205 TRACE("Forward iface %p, base %p\n", This, base);
3207 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3210 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3212 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3213 ID3DXBaseEffect *base = This->base_effect;
3215 TRACE("Forward iface %p, base %p\n", This, base);
3217 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3220 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3222 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3223 ID3DXBaseEffect *base = This->base_effect;
3225 TRACE("Forward iface %p, base %p\n", This, base);
3227 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3230 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3232 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3233 ID3DXBaseEffect *base = This->base_effect;
3235 TRACE("Forward iface %p, base %p\n", This, base);
3237 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3240 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3242 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3243 ID3DXBaseEffect *base = This->base_effect;
3245 TRACE("Forward iface %p, base %p\n", This, base);
3247 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3250 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3252 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3253 ID3DXBaseEffect *base = This->base_effect;
3255 TRACE("Forward iface %p, base %p\n", This, base);
3257 return ID3DXBaseEffectImpl_GetFunction(base, index);
3260 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3262 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3263 ID3DXBaseEffect *base = This->base_effect;
3265 TRACE("Forward iface %p, base %p\n", This, base);
3267 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3270 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3272 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3273 ID3DXBaseEffect *base = This->base_effect;
3275 TRACE("Forward iface %p, base %p\n", This, base);
3277 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3280 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3282 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3283 ID3DXBaseEffect *base = This->base_effect;
3285 TRACE("Forward iface %p, base %p\n", This, base);
3287 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3290 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3292 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3293 ID3DXBaseEffect *base = This->base_effect;
3295 TRACE("Forward iface %p, base %p\n", This, base);
3297 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3300 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3302 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3303 ID3DXBaseEffect *base = This->base_effect;
3305 TRACE("Forward iface %p, base %p\n", This, base);
3307 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3310 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3312 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3313 ID3DXBaseEffect *base = This->base_effect;
3315 TRACE("Forward iface %p, base %p\n", This, base);
3317 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3320 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3322 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3323 ID3DXBaseEffect *base = This->base_effect;
3325 TRACE("Forward iface %p, base %p\n", This, base);
3327 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3330 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3332 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3333 ID3DXBaseEffect *base = This->base_effect;
3335 TRACE("Forward iface %p, base %p\n", This, base);
3337 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3340 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3342 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3343 ID3DXBaseEffect *base = This->base_effect;
3345 TRACE("Forward iface %p, base %p\n", This, base);
3347 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3350 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3352 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3353 ID3DXBaseEffect *base = This->base_effect;
3355 TRACE("Forward iface %p, base %p\n", This, base);
3357 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3360 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3362 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3363 ID3DXBaseEffect *base = This->base_effect;
3365 TRACE("Forward iface %p, base %p\n", This, base);
3367 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3370 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3372 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3373 ID3DXBaseEffect *base = This->base_effect;
3375 TRACE("Forward iface %p, base %p\n", This, base);
3377 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3380 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3382 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3383 ID3DXBaseEffect *base = This->base_effect;
3385 TRACE("Forward iface %p, base %p\n", This, base);
3387 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3390 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3392 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3393 ID3DXBaseEffect *base = This->base_effect;
3395 TRACE("Forward iface %p, base %p\n", This, base);
3397 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3400 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3402 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3403 ID3DXBaseEffect *base = This->base_effect;
3405 TRACE("Forward iface %p, base %p\n", This, base);
3407 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3410 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3412 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3413 ID3DXBaseEffect *base = This->base_effect;
3415 TRACE("Forward iface %p, base %p\n", This, base);
3417 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3420 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3422 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3423 ID3DXBaseEffect *base = This->base_effect;
3425 TRACE("Forward iface %p, base %p\n", This, base);
3427 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3430 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3432 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3433 ID3DXBaseEffect *base = This->base_effect;
3435 TRACE("Forward iface %p, base %p\n", This, base);
3437 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3440 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3442 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3443 ID3DXBaseEffect *base = This->base_effect;
3445 TRACE("Forward iface %p, base %p\n", This, base);
3447 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3450 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3452 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3453 ID3DXBaseEffect *base = This->base_effect;
3455 TRACE("Forward iface %p, base %p\n", This, base);
3457 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3460 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3462 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3463 ID3DXBaseEffect *base = This->base_effect;
3465 TRACE("Forward iface %p, base %p\n", This, base);
3467 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3470 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3472 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3473 ID3DXBaseEffect *base = This->base_effect;
3475 TRACE("Forward iface %p, base %p\n", This, base);
3477 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3480 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3482 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3483 ID3DXBaseEffect *base = This->base_effect;
3485 TRACE("Forward iface %p, base %p\n", This, base);
3487 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3490 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3492 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3493 ID3DXBaseEffect *base = This->base_effect;
3495 TRACE("Forward iface %p, base %p\n", This, base);
3497 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3500 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3502 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3503 ID3DXBaseEffect *base = This->base_effect;
3505 TRACE("Forward iface %p, base %p\n", This, base);
3507 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3510 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3512 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3513 ID3DXBaseEffect *base = This->base_effect;
3515 TRACE("Forward iface %p, base %p\n", This, base);
3517 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3520 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3522 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3523 ID3DXBaseEffect *base = This->base_effect;
3525 TRACE("Forward iface %p, base %p\n", This, base);
3527 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3530 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3532 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3533 ID3DXBaseEffect *base = This->base_effect;
3535 TRACE("Forward iface %p, base %p\n", This, base);
3537 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3540 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3542 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3543 ID3DXBaseEffect *base = This->base_effect;
3545 TRACE("Forward iface %p, base %p\n", This, base);
3547 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3550 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3552 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3553 ID3DXBaseEffect *base = This->base_effect;
3555 TRACE("Forward iface %p, base %p\n", This, base);
3557 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3560 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3562 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3563 ID3DXBaseEffect *base = This->base_effect;
3565 TRACE("Forward iface %p, base %p\n", This, base);
3567 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3570 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3572 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3573 ID3DXBaseEffect *base = This->base_effect;
3575 TRACE("Forward iface %p, base %p\n", This, base);
3577 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3580 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3582 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3583 ID3DXBaseEffect *base = This->base_effect;
3585 TRACE("Forward iface %p, base %p\n", This, base);
3587 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3590 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3592 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3593 ID3DXBaseEffect *base = This->base_effect;
3595 TRACE("Forward iface %p, base %p\n", This, base);
3597 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3600 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3602 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3603 ID3DXBaseEffect *base = This->base_effect;
3605 TRACE("Forward iface %p, base %p\n", This, base);
3607 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3610 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3612 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3613 ID3DXBaseEffect *base = This->base_effect;
3615 TRACE("Forward iface %p, base %p\n", This, base);
3617 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3620 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3622 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3623 ID3DXBaseEffect *base = This->base_effect;
3625 TRACE("Forward iface %p, base %p\n", This, base);
3627 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3630 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3632 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3633 ID3DXBaseEffect *base = This->base_effect;
3635 TRACE("Forward iface %p, base %p\n", This, base);
3637 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3640 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3642 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3643 ID3DXBaseEffect *base = This->base_effect;
3645 TRACE("Forward iface %p, base %p\n", This, base);
3647 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3650 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3652 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3653 ID3DXBaseEffect *base = This->base_effect;
3655 TRACE("Forward iface %p, base %p\n", This, base);
3657 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3660 /*** ID3DXEffectCompiler methods ***/
3661 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3663 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3665 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3667 return E_NOTIMPL;
3670 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3672 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3674 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3676 return E_NOTIMPL;
3679 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3680 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3682 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3684 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3686 return E_NOTIMPL;
3689 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3690 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3692 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3694 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3695 This, function, target, flags, shader, error_msgs, constant_table);
3697 return E_NOTIMPL;
3700 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3702 /*** IUnknown methods ***/
3703 ID3DXEffectCompilerImpl_QueryInterface,
3704 ID3DXEffectCompilerImpl_AddRef,
3705 ID3DXEffectCompilerImpl_Release,
3706 /*** ID3DXBaseEffect methods ***/
3707 ID3DXEffectCompilerImpl_GetDesc,
3708 ID3DXEffectCompilerImpl_GetParameterDesc,
3709 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3710 ID3DXEffectCompilerImpl_GetPassDesc,
3711 ID3DXEffectCompilerImpl_GetFunctionDesc,
3712 ID3DXEffectCompilerImpl_GetParameter,
3713 ID3DXEffectCompilerImpl_GetParameterByName,
3714 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3715 ID3DXEffectCompilerImpl_GetParameterElement,
3716 ID3DXEffectCompilerImpl_GetTechnique,
3717 ID3DXEffectCompilerImpl_GetTechniqueByName,
3718 ID3DXEffectCompilerImpl_GetPass,
3719 ID3DXEffectCompilerImpl_GetPassByName,
3720 ID3DXEffectCompilerImpl_GetFunction,
3721 ID3DXEffectCompilerImpl_GetFunctionByName,
3722 ID3DXEffectCompilerImpl_GetAnnotation,
3723 ID3DXEffectCompilerImpl_GetAnnotationByName,
3724 ID3DXEffectCompilerImpl_SetValue,
3725 ID3DXEffectCompilerImpl_GetValue,
3726 ID3DXEffectCompilerImpl_SetBool,
3727 ID3DXEffectCompilerImpl_GetBool,
3728 ID3DXEffectCompilerImpl_SetBoolArray,
3729 ID3DXEffectCompilerImpl_GetBoolArray,
3730 ID3DXEffectCompilerImpl_SetInt,
3731 ID3DXEffectCompilerImpl_GetInt,
3732 ID3DXEffectCompilerImpl_SetIntArray,
3733 ID3DXEffectCompilerImpl_GetIntArray,
3734 ID3DXEffectCompilerImpl_SetFloat,
3735 ID3DXEffectCompilerImpl_GetFloat,
3736 ID3DXEffectCompilerImpl_SetFloatArray,
3737 ID3DXEffectCompilerImpl_GetFloatArray,
3738 ID3DXEffectCompilerImpl_SetVector,
3739 ID3DXEffectCompilerImpl_GetVector,
3740 ID3DXEffectCompilerImpl_SetVectorArray,
3741 ID3DXEffectCompilerImpl_GetVectorArray,
3742 ID3DXEffectCompilerImpl_SetMatrix,
3743 ID3DXEffectCompilerImpl_GetMatrix,
3744 ID3DXEffectCompilerImpl_SetMatrixArray,
3745 ID3DXEffectCompilerImpl_GetMatrixArray,
3746 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3747 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3748 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3749 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3750 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3751 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3752 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3753 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3754 ID3DXEffectCompilerImpl_SetString,
3755 ID3DXEffectCompilerImpl_GetString,
3756 ID3DXEffectCompilerImpl_SetTexture,
3757 ID3DXEffectCompilerImpl_GetTexture,
3758 ID3DXEffectCompilerImpl_GetPixelShader,
3759 ID3DXEffectCompilerImpl_GetVertexShader,
3760 ID3DXEffectCompilerImpl_SetArrayRange,
3761 /*** ID3DXEffectCompiler methods ***/
3762 ID3DXEffectCompilerImpl_SetLiteral,
3763 ID3DXEffectCompilerImpl_GetLiteral,
3764 ID3DXEffectCompilerImpl_CompileEffect,
3765 ID3DXEffectCompilerImpl_CompileShader,
3768 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
3770 HRESULT hr;
3771 UINT i;
3772 struct d3dx_state *states;
3774 read_dword(ptr, &sampler->state_count);
3775 TRACE("Count: %u\n", sampler->state_count);
3777 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
3778 if (!states)
3780 ERR("Out of memory\n");
3781 return E_OUTOFMEMORY;
3784 for (i = 0; i < sampler->state_count; ++i)
3786 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
3787 if (hr != D3D_OK)
3789 WARN("Failed to parse state\n");
3790 goto err_out;
3794 sampler->states = states;
3796 return D3D_OK;
3798 err_out:
3800 for (i = 0; i < sampler->state_count; ++i)
3802 free_state(&states[i]);
3805 HeapFree(GetProcessHeap(), 0, states);
3807 return hr;
3810 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
3812 unsigned int i;
3813 HRESULT hr;
3814 UINT old_size = 0;
3815 DWORD id;
3817 if (param->element_count)
3819 param->data = value;
3821 for (i = 0; i < param->element_count; ++i)
3823 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3825 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
3826 if (hr != D3D_OK)
3828 WARN("Failed to parse value\n");
3829 return hr;
3832 old_size += member->bytes;
3835 return D3D_OK;
3838 switch(param->class)
3840 case D3DXPC_SCALAR:
3841 case D3DXPC_VECTOR:
3842 case D3DXPC_MATRIX_ROWS:
3843 case D3DXPC_MATRIX_COLUMNS:
3844 param->data = value;
3845 break;
3847 case D3DXPC_STRUCT:
3848 param->data = value;
3850 for (i = 0; i < param->member_count; ++i)
3852 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3854 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
3855 if (hr != D3D_OK)
3857 WARN("Failed to parse value\n");
3858 return hr;
3861 old_size += member->bytes;
3863 break;
3865 case D3DXPC_OBJECT:
3866 switch (param->type)
3868 case D3DXPT_STRING:
3869 case D3DXPT_TEXTURE:
3870 case D3DXPT_TEXTURE1D:
3871 case D3DXPT_TEXTURE2D:
3872 case D3DXPT_TEXTURE3D:
3873 case D3DXPT_TEXTURECUBE:
3874 case D3DXPT_PIXELSHADER:
3875 case D3DXPT_VERTEXSHADER:
3876 read_dword(ptr, &id);
3877 TRACE("Id: %u\n", id);
3878 objects[id] = get_parameter_handle(param);
3879 param->data = value;
3880 break;
3882 case D3DXPT_SAMPLER:
3883 case D3DXPT_SAMPLER1D:
3884 case D3DXPT_SAMPLER2D:
3885 case D3DXPT_SAMPLER3D:
3886 case D3DXPT_SAMPLERCUBE:
3888 struct d3dx_sampler *sampler;
3890 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
3891 if (!sampler)
3893 ERR("Out of memory\n");
3894 return E_OUTOFMEMORY;
3897 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
3898 if (hr != D3D_OK)
3900 HeapFree(GetProcessHeap(), 0, sampler);
3901 WARN("Failed to parse sampler\n");
3902 return hr;
3905 param->data = sampler;
3906 break;
3909 default:
3910 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3911 break;
3913 break;
3915 default:
3916 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3917 break;
3920 return D3D_OK;
3923 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
3925 UINT size = param->bytes;
3926 HRESULT hr;
3927 void *value = NULL;
3929 TRACE("param size: %u\n", size);
3931 if (size)
3933 value = HeapAlloc(GetProcessHeap(), 0, size);
3934 if (!value)
3936 ERR("Failed to allocate data memory.\n");
3937 return E_OUTOFMEMORY;
3940 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3941 memcpy(value, ptr, size);
3944 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
3945 if (hr != D3D_OK)
3947 WARN("Failed to parse value\n");
3948 HeapFree(GetProcessHeap(), 0, value);
3949 return hr;
3952 return D3D_OK;
3955 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
3957 DWORD size;
3959 read_dword(&ptr, &size);
3960 TRACE("Name size: %#x\n", size);
3962 if (!size)
3964 return D3D_OK;
3967 *name = HeapAlloc(GetProcessHeap(), 0, size);
3968 if (!*name)
3970 ERR("Failed to allocate name memory.\n");
3971 return E_OUTOFMEMORY;
3974 TRACE("Name: %s.\n", debugstr_an(ptr, size));
3975 memcpy(*name, ptr, size);
3977 return D3D_OK;
3980 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
3982 DWORD size;
3983 HRESULT hr;
3985 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
3987 read_dword(ptr, &size);
3988 TRACE("Data size: %#x\n", size);
3990 if (!size)
3992 TRACE("Size is 0\n");
3993 *(void **)param->data = NULL;
3994 return D3D_OK;
3997 switch (param->type)
3999 case D3DXPT_STRING:
4000 /* re-read with size (sizeof(DWORD) = 4) */
4001 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4002 if (hr != D3D_OK)
4004 WARN("Failed to parse string data\n");
4005 return hr;
4007 break;
4009 case D3DXPT_VERTEXSHADER:
4010 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4011 if (hr != D3D_OK)
4013 WARN("Failed to create vertex shader\n");
4014 return hr;
4016 break;
4018 case D3DXPT_PIXELSHADER:
4019 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4020 if (hr != D3D_OK)
4022 WARN("Failed to create pixel shader\n");
4023 return hr;
4025 break;
4027 default:
4028 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4029 break;
4033 *ptr += ((size + 3) & ~3);
4035 return D3D_OK;
4038 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4039 struct d3dx_parameter *parent, UINT flags)
4041 DWORD offset;
4042 HRESULT hr;
4043 D3DXHANDLE *member_handles = NULL;
4044 UINT i;
4046 param->flags = flags;
4048 if (!parent)
4050 read_dword(ptr, &param->type);
4051 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4053 read_dword(ptr, &param->class);
4054 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4056 read_dword(ptr, &offset);
4057 TRACE("Type name offset: %#x\n", offset);
4058 hr = d3dx9_parse_name(&param->name, data + offset);
4059 if (hr != D3D_OK)
4061 WARN("Failed to parse name\n");
4062 goto err_out;
4065 read_dword(ptr, &offset);
4066 TRACE("Type semantic offset: %#x\n", offset);
4067 hr = d3dx9_parse_name(&param->semantic, data + offset);
4068 if (hr != D3D_OK)
4070 WARN("Failed to parse semantic\n");
4071 goto err_out;
4074 read_dword(ptr, &param->element_count);
4075 TRACE("Elements: %u\n", param->element_count);
4077 switch (param->class)
4079 case D3DXPC_VECTOR:
4080 read_dword(ptr, &param->columns);
4081 TRACE("Columns: %u\n", param->columns);
4083 read_dword(ptr, &param->rows);
4084 TRACE("Rows: %u\n", param->rows);
4086 /* sizeof(DWORD) * rows * columns */
4087 param->bytes = 4 * param->rows * param->columns;
4088 break;
4090 case D3DXPC_SCALAR:
4091 case D3DXPC_MATRIX_ROWS:
4092 case D3DXPC_MATRIX_COLUMNS:
4093 read_dword(ptr, &param->rows);
4094 TRACE("Rows: %u\n", param->rows);
4096 read_dword(ptr, &param->columns);
4097 TRACE("Columns: %u\n", param->columns);
4099 /* sizeof(DWORD) * rows * columns */
4100 param->bytes = 4 * param->rows * param->columns;
4101 break;
4103 case D3DXPC_STRUCT:
4104 read_dword(ptr, &param->member_count);
4105 TRACE("Members: %u\n", param->member_count);
4106 break;
4108 case D3DXPC_OBJECT:
4109 switch (param->type)
4111 case D3DXPT_STRING:
4112 param->bytes = sizeof(LPCSTR);
4113 break;
4115 case D3DXPT_PIXELSHADER:
4116 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4117 break;
4119 case D3DXPT_VERTEXSHADER:
4120 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4121 break;
4123 case D3DXPT_TEXTURE:
4124 case D3DXPT_TEXTURE1D:
4125 case D3DXPT_TEXTURE2D:
4126 case D3DXPT_TEXTURE3D:
4127 case D3DXPT_TEXTURECUBE:
4128 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4129 break;
4131 case D3DXPT_SAMPLER:
4132 case D3DXPT_SAMPLER1D:
4133 case D3DXPT_SAMPLER2D:
4134 case D3DXPT_SAMPLER3D:
4135 case D3DXPT_SAMPLERCUBE:
4136 param->bytes = 0;
4137 break;
4139 default:
4140 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4141 break;
4143 break;
4145 default:
4146 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4147 break;
4150 else
4152 /* elements */
4153 param->type = parent->type;
4154 param->class = parent->class;
4155 param->name = parent->name;
4156 param->semantic = parent->semantic;
4157 param->element_count = 0;
4158 param->annotation_count = 0;
4159 param->member_count = parent->member_count;
4160 param->bytes = parent->bytes;
4161 param->rows = parent->rows;
4162 param->columns = parent->columns;
4165 if (param->element_count)
4167 unsigned int param_bytes = 0;
4168 const char *save_ptr = *ptr;
4170 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4171 if (!member_handles)
4173 ERR("Out of memory\n");
4174 hr = E_OUTOFMEMORY;
4175 goto err_out;
4178 for (i = 0; i < param->element_count; ++i)
4180 struct d3dx_parameter *member;
4181 *ptr = save_ptr;
4183 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4184 if (!member)
4186 ERR("Out of memory\n");
4187 hr = E_OUTOFMEMORY;
4188 goto err_out;
4191 member_handles[i] = get_parameter_handle(member);
4193 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4194 if (hr != D3D_OK)
4196 WARN("Failed to parse member\n");
4197 goto err_out;
4200 param_bytes += member->bytes;
4203 param->bytes = param_bytes;
4205 else if (param->member_count)
4207 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4208 if (!member_handles)
4210 ERR("Out of memory\n");
4211 hr = E_OUTOFMEMORY;
4212 goto err_out;
4215 for (i = 0; i < param->member_count; ++i)
4217 struct d3dx_parameter *member;
4219 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4220 if (!member)
4222 ERR("Out of memory\n");
4223 hr = E_OUTOFMEMORY;
4224 goto err_out;
4227 member_handles[i] = get_parameter_handle(member);
4229 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4230 if (hr != D3D_OK)
4232 WARN("Failed to parse member\n");
4233 goto err_out;
4236 param->bytes += member->bytes;
4240 param->member_handles = member_handles;
4242 return D3D_OK;
4244 err_out:
4246 if (member_handles)
4248 unsigned int count;
4250 if (param->element_count) count = param->element_count;
4251 else count = param->member_count;
4253 for (i = 0; i < count; ++i)
4255 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4257 HeapFree(GetProcessHeap(), 0, member_handles);
4260 if (!parent)
4262 HeapFree(GetProcessHeap(), 0, param->name);
4263 HeapFree(GetProcessHeap(), 0, param->semantic);
4265 param->name = NULL;
4266 param->semantic = NULL;
4268 return hr;
4271 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4273 DWORD offset;
4274 const char *ptr2;
4275 HRESULT hr;
4277 anno->flags = D3DX_PARAMETER_ANNOTATION;
4279 read_dword(ptr, &offset);
4280 TRACE("Typedef offset: %#x\n", offset);
4281 ptr2 = data + offset;
4282 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4283 if (hr != D3D_OK)
4285 WARN("Failed to parse type definition\n");
4286 return hr;
4289 read_dword(ptr, &offset);
4290 TRACE("Value offset: %#x\n", offset);
4291 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4292 if (hr != D3D_OK)
4294 WARN("Failed to parse value\n");
4295 return hr;
4298 return D3D_OK;
4301 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4303 DWORD offset;
4304 const char *ptr2;
4305 HRESULT hr;
4306 struct d3dx_parameter *parameter;
4308 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4309 if (!parameter)
4311 ERR("Out of memory\n");
4312 return E_OUTOFMEMORY;
4315 state->type = ST_CONSTANT;
4317 read_dword(ptr, &state->operation);
4318 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4320 read_dword(ptr, &state->index);
4321 TRACE("Index: %#x\n", state->index);
4323 read_dword(ptr, &offset);
4324 TRACE("Typedef offset: %#x\n", offset);
4325 ptr2 = data + offset;
4326 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4327 if (hr != D3D_OK)
4329 WARN("Failed to parse type definition\n");
4330 goto err_out;
4333 read_dword(ptr, &offset);
4334 TRACE("Value offset: %#x\n", offset);
4335 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4336 if (hr != D3D_OK)
4338 WARN("Failed to parse value\n");
4339 goto err_out;
4342 state->parameter = get_parameter_handle(parameter);
4344 return D3D_OK;
4346 err_out:
4348 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4350 return hr;
4353 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4355 DWORD offset;
4356 HRESULT hr;
4357 unsigned int i;
4358 D3DXHANDLE *annotation_handles = NULL;
4359 const char *ptr2;
4361 read_dword(ptr, &offset);
4362 TRACE("Typedef offset: %#x\n", offset);
4363 ptr2 = data + offset;
4365 read_dword(ptr, &offset);
4366 TRACE("Value offset: %#x\n", offset);
4368 read_dword(ptr, &param->flags);
4369 TRACE("Flags: %#x\n", param->flags);
4371 read_dword(ptr, &param->annotation_count);
4372 TRACE("Annotation count: %u\n", param->annotation_count);
4374 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4375 if (hr != D3D_OK)
4377 WARN("Failed to parse type definition\n");
4378 return hr;
4381 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4382 if (hr != D3D_OK)
4384 WARN("Failed to parse value\n");
4385 return hr;
4388 if (param->annotation_count)
4390 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4391 if (!annotation_handles)
4393 ERR("Out of memory\n");
4394 hr = E_OUTOFMEMORY;
4395 goto err_out;
4398 for (i = 0; i < param->annotation_count; ++i)
4400 struct d3dx_parameter *annotation;
4402 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4403 if (!annotation)
4405 ERR("Out of memory\n");
4406 hr = E_OUTOFMEMORY;
4407 goto err_out;
4410 annotation_handles[i] = get_parameter_handle(annotation);
4412 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4413 if (hr != D3D_OK)
4415 WARN("Failed to parse annotation\n");
4416 goto err_out;
4421 param->annotation_handles = annotation_handles;
4423 return D3D_OK;
4425 err_out:
4427 if (annotation_handles)
4429 for (i = 0; i < param->annotation_count; ++i)
4431 free_parameter(annotation_handles[i], FALSE, FALSE);
4433 HeapFree(GetProcessHeap(), 0, annotation_handles);
4436 return hr;
4439 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4441 DWORD offset;
4442 HRESULT hr;
4443 unsigned int i;
4444 D3DXHANDLE *annotation_handles = NULL;
4445 struct d3dx_state *states = NULL;
4446 char *name = NULL;
4448 read_dword(ptr, &offset);
4449 TRACE("Pass name offset: %#x\n", offset);
4450 hr = d3dx9_parse_name(&name, data + offset);
4451 if (hr != D3D_OK)
4453 WARN("Failed to parse name\n");
4454 goto err_out;
4457 read_dword(ptr, &pass->annotation_count);
4458 TRACE("Annotation count: %u\n", pass->annotation_count);
4460 read_dword(ptr, &pass->state_count);
4461 TRACE("State count: %u\n", pass->state_count);
4463 if (pass->annotation_count)
4465 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4466 if (!annotation_handles)
4468 ERR("Out of memory\n");
4469 hr = E_OUTOFMEMORY;
4470 goto err_out;
4473 for (i = 0; i < pass->annotation_count; ++i)
4475 struct d3dx_parameter *annotation;
4477 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4478 if (!annotation)
4480 ERR("Out of memory\n");
4481 hr = E_OUTOFMEMORY;
4482 goto err_out;
4485 annotation_handles[i] = get_parameter_handle(annotation);
4487 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4488 if (hr != D3D_OK)
4490 WARN("Failed to parse annotations\n");
4491 goto err_out;
4496 if (pass->state_count)
4498 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4499 if (!states)
4501 ERR("Out of memory\n");
4502 hr = E_OUTOFMEMORY;
4503 goto err_out;
4506 for (i = 0; i < pass->state_count; ++i)
4508 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4509 if (hr != D3D_OK)
4511 WARN("Failed to parse annotations\n");
4512 goto err_out;
4517 pass->name = name;
4518 pass->annotation_handles = annotation_handles;
4519 pass->states = states;
4521 return D3D_OK;
4523 err_out:
4525 if (annotation_handles)
4527 for (i = 0; i < pass->annotation_count; ++i)
4529 free_parameter(annotation_handles[i], FALSE, FALSE);
4531 HeapFree(GetProcessHeap(), 0, annotation_handles);
4534 if (states)
4536 for (i = 0; i < pass->state_count; ++i)
4538 free_state(&states[i]);
4540 HeapFree(GetProcessHeap(), 0, states);
4543 HeapFree(GetProcessHeap(), 0, name);
4545 return hr;
4548 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4550 DWORD offset;
4551 HRESULT hr;
4552 unsigned int i;
4553 D3DXHANDLE *annotation_handles = NULL;
4554 D3DXHANDLE *pass_handles = NULL;
4555 char *name = NULL;
4557 read_dword(ptr, &offset);
4558 TRACE("Technique name offset: %#x\n", offset);
4559 hr = d3dx9_parse_name(&name, data + offset);
4560 if (hr != D3D_OK)
4562 WARN("Failed to parse name\n");
4563 goto err_out;
4566 read_dword(ptr, &technique->annotation_count);
4567 TRACE("Annotation count: %u\n", technique->annotation_count);
4569 read_dword(ptr, &technique->pass_count);
4570 TRACE("Pass count: %u\n", technique->pass_count);
4572 if (technique->annotation_count)
4574 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4575 if (!annotation_handles)
4577 ERR("Out of memory\n");
4578 hr = E_OUTOFMEMORY;
4579 goto err_out;
4582 for (i = 0; i < technique->annotation_count; ++i)
4584 struct d3dx_parameter *annotation;
4586 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4587 if (!annotation)
4589 ERR("Out of memory\n");
4590 hr = E_OUTOFMEMORY;
4591 goto err_out;
4594 annotation_handles[i] = get_parameter_handle(annotation);
4596 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4597 if (hr != D3D_OK)
4599 WARN("Failed to parse annotations\n");
4600 goto err_out;
4605 if (technique->pass_count)
4607 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4608 if (!pass_handles)
4610 ERR("Out of memory\n");
4611 hr = E_OUTOFMEMORY;
4612 goto err_out;
4615 for (i = 0; i < technique->pass_count; ++i)
4617 struct d3dx_pass *pass;
4619 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4620 if (!pass)
4622 ERR("Out of memory\n");
4623 hr = E_OUTOFMEMORY;
4624 goto err_out;
4627 pass_handles[i] = get_pass_handle(pass);
4629 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
4630 if (hr != D3D_OK)
4632 WARN("Failed to parse passes\n");
4633 goto err_out;
4638 technique->name = name;
4639 technique->pass_handles = pass_handles;
4640 technique->annotation_handles = annotation_handles;
4642 return D3D_OK;
4644 err_out:
4646 if (pass_handles)
4648 for (i = 0; i < technique->pass_count; ++i)
4650 free_pass(pass_handles[i]);
4652 HeapFree(GetProcessHeap(), 0, pass_handles);
4655 if (annotation_handles)
4657 for (i = 0; i < technique->annotation_count; ++i)
4659 free_parameter(annotation_handles[i], FALSE, FALSE);
4661 HeapFree(GetProcessHeap(), 0, annotation_handles);
4664 HeapFree(GetProcessHeap(), 0, name);
4666 return hr;
4669 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
4671 DWORD technique_index;
4672 DWORD index, state_index, usage;
4673 struct d3dx_state *state;
4674 struct d3dx_parameter *param;
4675 HRESULT hr;
4677 read_dword(ptr, &technique_index);
4678 TRACE("techn: %u\n", technique_index);
4680 read_dword(ptr, &index);
4681 TRACE("index: %u\n", index);
4683 skip_dword_unknown(ptr, 1);
4685 read_dword(ptr, &state_index);
4686 TRACE("state: %u\n", state_index);
4688 read_dword(ptr, &usage);
4689 TRACE("usage: %u\n", usage);
4691 if (technique_index == 0xffffffff)
4693 struct d3dx_parameter *parameter;
4694 struct d3dx_sampler *sampler;
4696 if (index >= base->parameter_count)
4698 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
4699 return E_FAIL;
4702 parameter = get_parameter_struct(base->parameter_handles[index]);
4703 sampler = parameter->data;
4704 if (state_index >= sampler->state_count)
4706 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
4707 return E_FAIL;
4710 state = &sampler->states[state_index];
4712 else
4714 struct d3dx_technique *technique;
4715 struct d3dx_pass *pass;
4717 if (technique_index >= base->technique_count)
4719 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
4720 return E_FAIL;
4723 technique = get_technique_struct(base->technique_handles[technique_index]);
4724 if (index >= technique->pass_count)
4726 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
4727 return E_FAIL;
4730 pass = get_pass_struct(technique->pass_handles[index]);
4731 if (state_index >= pass->state_count)
4733 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
4734 return E_FAIL;
4737 state = &pass->states[state_index];
4740 param = get_parameter_struct(state->parameter);
4742 switch (usage)
4744 case 0:
4745 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
4746 switch (param->type)
4748 case D3DXPT_VERTEXSHADER:
4749 case D3DXPT_PIXELSHADER:
4750 state->type = ST_CONSTANT;
4751 hr = d3dx9_parse_data(param, ptr, base->effect->device);
4752 break;
4754 default:
4755 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4756 hr=E_FAIL;
4757 break;
4759 break;
4761 default:
4762 FIXME("Unknown usage %x\n", usage);
4763 hr=E_FAIL;
4764 break;
4767 return hr;
4770 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4772 const char *ptr = data + start;
4773 D3DXHANDLE *parameter_handles = NULL;
4774 D3DXHANDLE *technique_handles = NULL;
4775 D3DXHANDLE *objects = NULL;
4776 UINT stringcount, objectcount, resourcecount;
4777 HRESULT hr;
4778 UINT i;
4780 read_dword(&ptr, &base->parameter_count);
4781 TRACE("Parameter count: %u\n", base->parameter_count);
4783 read_dword(&ptr, &base->technique_count);
4784 TRACE("Technique count: %u\n", base->technique_count);
4786 skip_dword_unknown(&ptr, 1);
4788 read_dword(&ptr, &objectcount);
4789 TRACE("Object count: %u\n", objectcount);
4791 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
4792 if (!objects)
4794 ERR("Out of memory\n");
4795 hr = E_OUTOFMEMORY;
4796 goto err_out;
4799 if (base->parameter_count)
4801 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4802 if (!parameter_handles)
4804 ERR("Out of memory\n");
4805 hr = E_OUTOFMEMORY;
4806 goto err_out;
4809 for (i = 0; i < base->parameter_count; ++i)
4811 struct d3dx_parameter *parameter;
4813 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4814 if (!parameter)
4816 ERR("Out of memory\n");
4817 hr = E_OUTOFMEMORY;
4818 goto err_out;
4821 parameter_handles[i] = get_parameter_handle(parameter);
4823 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
4824 if (hr != D3D_OK)
4826 WARN("Failed to parse parameter\n");
4827 goto err_out;
4832 if (base->technique_count)
4834 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4835 if (!technique_handles)
4837 ERR("Out of memory\n");
4838 hr = E_OUTOFMEMORY;
4839 goto err_out;
4842 for (i = 0; i < base->technique_count; ++i)
4844 struct d3dx_technique *technique;
4846 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4847 if (!technique)
4849 ERR("Out of memory\n");
4850 hr = E_OUTOFMEMORY;
4851 goto err_out;
4854 technique_handles[i] = get_technique_handle(technique);
4856 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
4857 if (hr != D3D_OK)
4859 WARN("Failed to parse technique\n");
4860 goto err_out;
4865 /* needed for further parsing */
4866 base->technique_handles = technique_handles;
4867 base->parameter_handles = parameter_handles;
4869 read_dword(&ptr, &stringcount);
4870 TRACE("String count: %u\n", stringcount);
4872 read_dword(&ptr, &resourcecount);
4873 TRACE("Resource count: %u\n", resourcecount);
4875 for (i = 0; i < stringcount; ++i)
4877 DWORD id;
4878 struct d3dx_parameter *param;
4880 read_dword(&ptr, &id);
4881 TRACE("Id: %u\n", id);
4883 param = get_parameter_struct(objects[id]);
4885 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
4886 if (hr != D3D_OK)
4888 WARN("Failed to parse data\n");
4889 goto err_out;
4893 for (i = 0; i < resourcecount; ++i)
4895 TRACE("parse resource %u\n", i);
4897 hr = d3dx9_parse_resource(base, data, &ptr);
4898 if (hr != D3D_OK)
4900 WARN("Failed to parse data\n");
4901 goto err_out;
4905 HeapFree(GetProcessHeap(), 0, objects);
4907 return D3D_OK;
4909 err_out:
4911 if (technique_handles)
4913 for (i = 0; i < base->technique_count; ++i)
4915 free_technique(technique_handles[i]);
4917 HeapFree(GetProcessHeap(), 0, technique_handles);
4920 if (parameter_handles)
4922 for (i = 0; i < base->parameter_count; ++i)
4924 free_parameter(parameter_handles[i], FALSE, FALSE);
4926 HeapFree(GetProcessHeap(), 0, parameter_handles);
4929 base->technique_handles = NULL;
4930 base->parameter_handles = NULL;
4932 HeapFree(GetProcessHeap(), 0, objects);
4934 return hr;
4937 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
4938 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
4940 DWORD tag, offset;
4941 const char *ptr = data;
4942 HRESULT hr;
4944 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
4946 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
4947 base->ref = 1;
4948 base->effect = effect;
4950 read_dword(&ptr, &tag);
4951 TRACE("Tag: %x\n", tag);
4953 if (tag != d3dx9_effect_version(9, 1))
4955 /* todo: compile hlsl ascii code */
4956 FIXME("HLSL ascii effects not supported, yet\n");
4958 /* Show the start of the shader for debugging info. */
4959 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
4961 else
4963 read_dword(&ptr, &offset);
4964 TRACE("Offset: %x\n", offset);
4966 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
4967 if (hr != D3D_OK)
4969 FIXME("Failed to parse effect.\n");
4970 return hr;
4974 return D3D_OK;
4977 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
4978 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
4980 HRESULT hr;
4981 struct ID3DXBaseEffectImpl *object = NULL;
4983 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
4985 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
4986 effect->ref = 1;
4988 if (pool) pool->lpVtbl->AddRef(pool);
4989 effect->pool = pool;
4991 IDirect3DDevice9_AddRef(device);
4992 effect->device = device;
4994 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4995 if (!object)
4997 ERR("Out of memory\n");
4998 hr = E_OUTOFMEMORY;
4999 goto err_out;
5002 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5003 if (hr != D3D_OK)
5005 FIXME("Failed to parse effect.\n");
5006 goto err_out;
5009 effect->base_effect = &object->ID3DXBaseEffect_iface;
5011 /* initialize defaults - check because of unsupported ascii effects */
5012 if (object->technique_handles)
5014 effect->active_technique = object->technique_handles[0];
5017 return D3D_OK;
5019 err_out:
5021 HeapFree(GetProcessHeap(), 0, object);
5022 free_effect(effect);
5024 return hr;
5027 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5028 LPCVOID srcdata,
5029 UINT srcdatalen,
5030 CONST D3DXMACRO* defines,
5031 LPD3DXINCLUDE include,
5032 LPCSTR skip_constants,
5033 DWORD flags,
5034 LPD3DXEFFECTPOOL pool,
5035 LPD3DXEFFECT* effect,
5036 LPD3DXBUFFER* compilation_errors)
5038 struct ID3DXEffectImpl *object;
5039 HRESULT hr;
5041 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5042 skip_constants, flags, pool, effect, compilation_errors);
5044 if (!device || !srcdata)
5045 return D3DERR_INVALIDCALL;
5047 if (!srcdatalen)
5048 return E_FAIL;
5050 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5051 if (!effect)
5052 return D3D_OK;
5054 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5055 if (!object)
5057 ERR("Out of memory\n");
5058 return E_OUTOFMEMORY;
5061 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5062 if (FAILED(hr))
5064 WARN("Failed to initialize shader reflection\n");
5065 HeapFree(GetProcessHeap(), 0, object);
5066 return hr;
5069 *effect = &object->ID3DXEffect_iface;
5071 TRACE("Created ID3DXEffect %p\n", object);
5073 return D3D_OK;
5076 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5077 LPCVOID srcdata,
5078 UINT srcdatalen,
5079 CONST D3DXMACRO* defines,
5080 LPD3DXINCLUDE include,
5081 DWORD flags,
5082 LPD3DXEFFECTPOOL pool,
5083 LPD3DXEFFECT* effect,
5084 LPD3DXBUFFER* compilation_errors)
5086 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5087 include, flags, pool, effect, compilation_errors);
5089 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5092 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5094 HRESULT hr;
5095 struct ID3DXBaseEffectImpl *object = NULL;
5097 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5099 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5100 compiler->ref = 1;
5102 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5103 if (!object)
5105 ERR("Out of memory\n");
5106 hr = E_OUTOFMEMORY;
5107 goto err_out;
5110 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5111 if (hr != D3D_OK)
5113 FIXME("Failed to parse effect.\n");
5114 goto err_out;
5117 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5119 return D3D_OK;
5121 err_out:
5123 HeapFree(GetProcessHeap(), 0, object);
5124 free_effect_compiler(compiler);
5126 return hr;
5129 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5130 UINT srcdatalen,
5131 CONST D3DXMACRO *defines,
5132 LPD3DXINCLUDE include,
5133 DWORD flags,
5134 LPD3DXEFFECTCOMPILER *compiler,
5135 LPD3DXBUFFER *parse_errors)
5137 struct ID3DXEffectCompilerImpl *object;
5138 HRESULT hr;
5140 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5141 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5143 if (!srcdata || !compiler)
5145 WARN("Invalid arguments supplied\n");
5146 return D3DERR_INVALIDCALL;
5149 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5150 if (!object)
5152 ERR("Out of memory\n");
5153 return E_OUTOFMEMORY;
5156 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5157 if (FAILED(hr))
5159 WARN("Failed to initialize effect compiler\n");
5160 HeapFree(GetProcessHeap(), 0, object);
5161 return hr;
5164 *compiler = &object->ID3DXEffectCompiler_iface;
5166 TRACE("Created ID3DXEffectCompiler %p\n", object);
5168 return D3D_OK;
5171 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5173 struct ID3DXEffectPoolImpl
5175 ID3DXEffectPool ID3DXEffectPool_iface;
5176 LONG ref;
5179 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5181 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5184 /*** IUnknown methods ***/
5185 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5187 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5189 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5191 if (IsEqualGUID(riid, &IID_IUnknown) ||
5192 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5194 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5195 *object = This;
5196 return S_OK;
5199 WARN("Interface %s not found\n", debugstr_guid(riid));
5201 return E_NOINTERFACE;
5204 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5206 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5208 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5210 return InterlockedIncrement(&This->ref);
5213 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5215 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5216 ULONG ref = InterlockedDecrement(&This->ref);
5218 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5220 if (!ref)
5221 HeapFree(GetProcessHeap(), 0, This);
5223 return ref;
5226 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5228 /*** IUnknown methods ***/
5229 ID3DXEffectPoolImpl_QueryInterface,
5230 ID3DXEffectPoolImpl_AddRef,
5231 ID3DXEffectPoolImpl_Release
5234 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5236 struct ID3DXEffectPoolImpl *object;
5238 TRACE("(%p)\n", pool);
5240 if (!pool)
5241 return D3DERR_INVALIDCALL;
5243 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5244 if (!object)
5246 ERR("Out of memory\n");
5247 return E_OUTOFMEMORY;
5250 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5251 object->ref = 1;
5253 *pool = &object->ID3DXEffectPool_iface;
5255 return S_OK;
5258 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5259 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5260 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5262 LPVOID buffer;
5263 HRESULT ret;
5264 DWORD size;
5266 TRACE("(%s): relay\n", debugstr_w(srcfile));
5268 if (!device || !srcfile)
5269 return D3DERR_INVALIDCALL;
5271 ret = map_view_of_file(srcfile, &buffer, &size);
5273 if (FAILED(ret))
5274 return D3DXERR_INVALIDDATA;
5276 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5277 UnmapViewOfFile(buffer);
5279 return ret;
5282 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5283 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5284 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5286 LPWSTR srcfileW;
5287 HRESULT ret;
5288 DWORD len;
5290 TRACE("(void): relay\n");
5292 if (!srcfile)
5293 return D3DERR_INVALIDCALL;
5295 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5296 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5297 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5299 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5300 HeapFree(GetProcessHeap(), 0, srcfileW);
5302 return ret;
5305 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5306 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5307 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5309 TRACE("(void): relay\n");
5310 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5313 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5314 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5315 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5317 TRACE("(void): relay\n");
5318 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5321 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5322 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5323 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5325 HRSRC resinfo;
5327 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5329 if (!device)
5330 return D3DERR_INVALIDCALL;
5332 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5334 if (resinfo)
5336 LPVOID buffer;
5337 HRESULT ret;
5338 DWORD size;
5340 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5342 if (FAILED(ret))
5343 return D3DXERR_INVALIDDATA;
5345 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5348 return D3DXERR_INVALIDDATA;
5351 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5352 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5353 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5355 HRSRC resinfo;
5357 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5359 if (!device)
5360 return D3DERR_INVALIDCALL;
5362 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5364 if (resinfo)
5366 LPVOID buffer;
5367 HRESULT ret;
5368 DWORD size;
5370 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5372 if (FAILED(ret))
5373 return D3DXERR_INVALIDDATA;
5375 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5378 return D3DXERR_INVALIDDATA;
5381 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5382 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5383 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5385 TRACE("(void): relay\n");
5386 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5389 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5390 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5391 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5393 TRACE("(void): relay\n");
5394 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5397 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5398 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5400 LPVOID buffer;
5401 HRESULT ret;
5402 DWORD size;
5404 TRACE("(%s): relay\n", debugstr_w(srcfile));
5406 if (!srcfile)
5407 return D3DERR_INVALIDCALL;
5409 ret = map_view_of_file(srcfile, &buffer, &size);
5411 if (FAILED(ret))
5412 return D3DXERR_INVALIDDATA;
5414 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5415 UnmapViewOfFile(buffer);
5417 return ret;
5420 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5421 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5423 LPWSTR srcfileW;
5424 HRESULT ret;
5425 DWORD len;
5427 TRACE("(void): relay\n");
5429 if (!srcfile)
5430 return D3DERR_INVALIDCALL;
5432 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5433 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5434 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5436 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5437 HeapFree(GetProcessHeap(), 0, srcfileW);
5439 return ret;
5442 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5443 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5445 HRSRC resinfo;
5447 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5449 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5451 if (resinfo)
5453 LPVOID buffer;
5454 HRESULT ret;
5455 DWORD size;
5457 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5459 if (FAILED(ret))
5460 return D3DXERR_INVALIDDATA;
5462 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5465 return D3DXERR_INVALIDDATA;
5468 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5469 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5471 HRSRC resinfo;
5473 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5475 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5477 if (resinfo)
5479 LPVOID buffer;
5480 HRESULT ret;
5481 DWORD size;
5483 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5485 if (FAILED(ret))
5486 return D3DXERR_INVALIDDATA;
5488 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5491 return D3DXERR_INVALIDDATA;