d3dx9: Implement ID3DXEffect::GetCurrentTechnique().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blob0f9d413688faec7cb0763d1ad992b207002c22df
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;
169 D3DXHANDLE active_pass;
171 ID3DXBaseEffect *base_effect;
174 struct ID3DXEffectCompilerImpl
176 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
177 LONG ref;
179 ID3DXBaseEffect *base_effect;
182 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
183 struct d3dx_parameter *parameter, LPCSTR name);
184 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
185 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
186 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
188 static const struct
190 enum STATE_CLASS class;
191 UINT op;
192 LPCSTR name;
194 state_table[] =
196 /* Render sates */
197 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
198 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
199 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
200 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
201 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
202 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
203 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
204 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
205 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
206 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
207 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
208 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
209 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
210 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
211 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
212 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
213 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
214 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
215 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
216 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
217 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
218 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
219 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
220 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
221 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
222 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
223 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
224 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
225 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
226 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
227 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
228 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
229 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
230 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
231 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
232 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
233 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
234 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
235 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
236 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
237 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
238 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
239 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
240 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
241 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
242 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
243 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
244 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
245 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
246 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
247 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
248 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
249 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
250 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
251 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
252 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
253 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
254 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
255 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
256 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
257 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
258 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
259 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
260 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
261 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
262 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
263 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
264 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
265 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
266 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
267 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
268 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
269 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
270 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
271 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
272 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
273 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
274 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
275 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
276 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
277 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
278 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
279 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
280 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
281 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
282 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
283 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
284 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
285 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
286 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
287 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
288 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
289 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
290 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
291 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
292 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
293 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
294 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
295 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
296 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
297 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
298 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
299 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
300 /* Texture stages */
301 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
302 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
303 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
304 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
305 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
306 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
307 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
308 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
309 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
310 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
311 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
312 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
313 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
314 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
315 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
316 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
317 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
318 /* */
319 {SC_UNKNOWN, 0, "UNKNOWN"},
320 /* NPatchMode */
321 {SC_NPATCHMODE, 0, "NPatchMode"},
322 /* */
323 {SC_UNKNOWN, 0, "UNKNOWN"},
324 /* Transform */
325 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
326 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
327 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
328 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
329 /* Material */
330 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
331 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
332 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
333 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
334 {SC_MATERIAL, MT_POWER, "MaterialPower"},
335 /* Light */
336 {SC_LIGHT, LT_TYPE, "LightType"},
337 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
338 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
339 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
340 {SC_LIGHT, LT_POSITION, "LightPosition"},
341 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
342 {SC_LIGHT, LT_RANGE, "LightRange"},
343 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
344 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
345 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
346 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
347 {SC_LIGHT, LT_THETA, "LightTheta"},
348 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
349 /* Ligthenable */
350 {SC_LIGHTENABLE, 0, "LightEnable"},
351 /* Vertexshader */
352 {SC_VERTEXSHADER, 0, "Vertexshader"},
353 /* Pixelshader */
354 {SC_PIXELSHADER, 0, "Pixelshader"},
355 /* Shader constants */
356 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
357 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
358 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
359 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
360 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
361 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
362 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
363 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
364 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
365 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
366 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
367 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
368 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
369 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
370 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
371 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
372 /* Texture */
373 {SC_TEXTURE, 0, "Texture"},
374 /* Sampler states */
375 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
376 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
377 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
378 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
379 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
380 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
381 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
382 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
383 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
384 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
385 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
386 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
387 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
388 /* Set sampler */
389 {SC_SETSAMPLER, 0, "Sampler"},
392 static inline void read_dword(const char **ptr, DWORD *d)
394 memcpy(d, *ptr, sizeof(*d));
395 *ptr += sizeof(*d);
398 static void skip_dword_unknown(const char **ptr, unsigned int count)
400 unsigned int i;
401 DWORD d;
403 FIXME("Skipping %u unknown DWORDs:\n", count);
404 for (i = 0; i < count; ++i)
406 read_dword(ptr, &d);
407 FIXME("\t0x%08x\n", d);
411 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
413 return (struct d3dx_parameter *) handle;
416 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
418 return (struct d3dx_pass *) handle;
421 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
423 return (struct d3dx_technique *) handle;
426 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
428 return (D3DXHANDLE) parameter;
431 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
433 return (D3DXHANDLE) technique;
436 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
438 return (D3DXHANDLE) pass;
441 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
443 unsigned int i;
445 for (i = 0; i < base->technique_count; ++i)
447 if (base->technique_handles[i] == technique)
449 return get_technique_struct(technique);
453 return NULL;
456 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
458 unsigned int i, k;
460 for (i = 0; i < base->technique_count; ++i)
462 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
464 for (k = 0; k < technique->pass_count; ++k)
466 if (technique->pass_handles[k] == pass)
468 return get_pass_struct(pass);
473 return NULL;
476 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
478 unsigned int i, count;
479 struct d3dx_parameter *p;
481 for (i = 0; i < param->annotation_count; ++i)
483 if (param->annotation_handles[i] == parameter)
485 return get_parameter_struct(parameter);
488 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
489 if (p) return p;
492 if (param->element_count) count = param->element_count;
493 else count = param->member_count;
495 for (i = 0; i < count; ++i)
497 if (param->member_handles[i] == parameter)
499 return get_parameter_struct(parameter);
502 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
503 if (p) return p;
506 return NULL;
509 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
511 unsigned int i, k, m;
512 struct d3dx_parameter *p;
514 for (i = 0; i < base->parameter_count; ++i)
516 if (base->parameter_handles[i] == parameter)
518 return get_parameter_struct(parameter);
521 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
522 if (p) return p;
525 for (i = 0; i < base->technique_count; ++i)
527 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
529 for (k = 0; k < technique->pass_count; ++k)
531 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
533 for (m = 0; m < pass->annotation_count; ++m)
535 if (pass->annotation_handles[i] == parameter)
537 return get_parameter_struct(parameter);
540 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
541 if (p) return p;
545 for (k = 0; k < technique->annotation_count; ++k)
547 if (technique->annotation_handles[k] == parameter)
549 return get_parameter_struct(parameter);
552 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
553 if (p) return p;
557 return NULL;
560 static void free_state(struct d3dx_state *state)
562 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
565 static void free_sampler(struct d3dx_sampler *sampler)
567 UINT i;
569 for (i = 0; i < sampler->state_count; ++i)
571 free_state(&sampler->states[i]);
573 HeapFree(GetProcessHeap(), 0, sampler->states);
576 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
578 free_parameter_state(handle, element, child, ST_CONSTANT);
581 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
583 unsigned int i;
584 struct d3dx_parameter *param = get_parameter_struct(handle);
586 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
587 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
589 if (!param)
591 return;
594 if (param->annotation_handles)
596 for (i = 0; i < param->annotation_count; ++i)
598 free_parameter(param->annotation_handles[i], FALSE, FALSE);
600 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
603 if (param->member_handles)
605 unsigned int count;
607 if (param->element_count) count = param->element_count;
608 else count = param->member_count;
610 for (i = 0; i < count; ++i)
612 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
614 HeapFree(GetProcessHeap(), 0, param->member_handles);
617 if (param->class == D3DXPC_OBJECT && !param->element_count)
619 switch (param->type)
621 case D3DXPT_STRING:
622 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
623 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
624 break;
626 case D3DXPT_TEXTURE:
627 case D3DXPT_TEXTURE1D:
628 case D3DXPT_TEXTURE2D:
629 case D3DXPT_TEXTURE3D:
630 case D3DXPT_TEXTURECUBE:
631 case D3DXPT_PIXELSHADER:
632 case D3DXPT_VERTEXSHADER:
633 if (st == ST_CONSTANT)
635 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
637 else
639 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
641 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
642 break;
644 case D3DXPT_SAMPLER:
645 case D3DXPT_SAMPLER1D:
646 case D3DXPT_SAMPLER2D:
647 case D3DXPT_SAMPLER3D:
648 case D3DXPT_SAMPLERCUBE:
649 if (st == ST_CONSTANT)
651 free_sampler((struct d3dx_sampler *)param->data);
653 else
655 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
657 /* samplers have always own data, so free that */
658 HeapFree(GetProcessHeap(), 0, param->data);
659 break;
661 default:
662 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
663 break;
666 else
668 if (!child)
670 if (st != ST_CONSTANT)
672 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
674 HeapFree(GetProcessHeap(), 0, param->data);
678 /* only the parent has to release name and semantic */
679 if (!element)
681 HeapFree(GetProcessHeap(), 0, param->name);
682 HeapFree(GetProcessHeap(), 0, param->semantic);
685 HeapFree(GetProcessHeap(), 0, param);
688 static void free_pass(D3DXHANDLE handle)
690 unsigned int i;
691 struct d3dx_pass *pass = get_pass_struct(handle);
693 TRACE("Free pass %p\n", pass);
695 if (!pass)
697 return;
700 if (pass->annotation_handles)
702 for (i = 0; i < pass->annotation_count; ++i)
704 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
706 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
709 if (pass->states)
711 for (i = 0; i < pass->state_count; ++i)
713 free_state(&pass->states[i]);
715 HeapFree(GetProcessHeap(), 0, pass->states);
718 HeapFree(GetProcessHeap(), 0, pass->name);
719 HeapFree(GetProcessHeap(), 0, pass);
722 static void free_technique(D3DXHANDLE handle)
724 unsigned int i;
725 struct d3dx_technique *technique = get_technique_struct(handle);
727 TRACE("Free technique %p\n", technique);
729 if (!technique)
731 return;
734 if (technique->annotation_handles)
736 for (i = 0; i < technique->annotation_count; ++i)
738 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
740 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
743 if (technique->pass_handles)
745 for (i = 0; i < technique->pass_count; ++i)
747 free_pass(technique->pass_handles[i]);
749 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
752 HeapFree(GetProcessHeap(), 0, technique->name);
753 HeapFree(GetProcessHeap(), 0, technique);
756 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
758 unsigned int i;
760 TRACE("Free base effect %p\n", base);
762 if (base->parameter_handles)
764 for (i = 0; i < base->parameter_count; ++i)
766 free_parameter(base->parameter_handles[i], FALSE, FALSE);
768 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
771 if (base->technique_handles)
773 for (i = 0; i < base->technique_count; ++i)
775 free_technique(base->technique_handles[i]);
777 HeapFree(GetProcessHeap(), 0, base->technique_handles);
781 static void free_effect(struct ID3DXEffectImpl *effect)
783 TRACE("Free effect %p\n", effect);
785 if (effect->base_effect)
787 effect->base_effect->lpVtbl->Release(effect->base_effect);
790 if (effect->pool)
792 effect->pool->lpVtbl->Release(effect->pool);
795 if (effect->manager)
797 IUnknown_Release(effect->manager);
800 IDirect3DDevice9_Release(effect->device);
803 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
805 TRACE("Free effect compiler %p\n", compiler);
807 if (compiler->base_effect)
809 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
813 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
815 INT i;
817 switch (type)
819 case D3DXPT_FLOAT:
820 i = *(FLOAT *)data;
821 break;
823 case D3DXPT_INT:
824 i = *(INT *)data;
825 break;
827 case D3DXPT_BOOL:
828 i = *(BOOL *)data;
829 break;
831 default:
832 i = 0;
833 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
834 break;
837 return i;
840 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
842 FLOAT f;
844 switch (type)
846 case D3DXPT_FLOAT:
847 f = *(FLOAT *)data;
848 break;
850 case D3DXPT_INT:
851 f = *(INT *)data;
852 break;
854 case D3DXPT_BOOL:
855 f = *(BOOL *)data;
856 break;
858 default:
859 f = 0.0f;
860 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
861 break;
864 return f;
867 static inline BOOL get_bool(void *data)
869 return (*(DWORD *)data) ? TRUE : FALSE;
872 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
874 UINT element;
875 struct d3dx_parameter *temp_parameter;
876 LPCSTR part;
878 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
880 if (!name || !*name) return parameter;
882 element = atoi(name);
883 part = strchr(name, ']') + 1;
885 if (parameter->element_count > element)
887 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
889 switch (*part++)
891 case '.':
892 return get_parameter_by_name(NULL, temp_parameter, part);
894 case '@':
895 return get_parameter_annotation_by_name(temp_parameter, part);
897 case '\0':
898 TRACE("Returning parameter %p\n", temp_parameter);
899 return temp_parameter;
901 default:
902 FIXME("Unhandled case \"%c\"\n", *--part);
903 break;
907 TRACE("Parameter not found\n");
908 return NULL;
911 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
913 UINT i, length;
914 struct d3dx_parameter *temp_parameter;
915 LPCSTR part;
917 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
919 if (!name || !*name) return parameter;
921 length = strcspn( name, "[.@" );
922 part = name + length;
924 for (i = 0; i < parameter->annotation_count; ++i)
926 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
928 if (!strcmp(temp_parameter->name, name))
930 TRACE("Returning parameter %p\n", temp_parameter);
931 return temp_parameter;
933 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
935 switch (*part++)
937 case '.':
938 return get_parameter_by_name(NULL, temp_parameter, part);
940 case '[':
941 return get_parameter_element_by_name(temp_parameter, part);
943 default:
944 FIXME("Unhandled case \"%c\"\n", *--part);
945 break;
950 TRACE("Parameter not found\n");
951 return NULL;
954 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
955 struct d3dx_parameter *parameter, LPCSTR name)
957 UINT i, count, length;
958 struct d3dx_parameter *temp_parameter;
959 D3DXHANDLE *handles;
960 LPCSTR part;
962 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
964 if (!name || !*name) return parameter;
966 if (!parameter)
968 count = base->parameter_count;
969 handles = base->parameter_handles;
971 else
973 count = parameter->member_count;
974 handles = parameter->member_handles;
977 length = strcspn( name, "[.@" );
978 part = name + length;
980 for (i = 0; i < count; i++)
982 temp_parameter = get_parameter_struct(handles[i]);
984 if (!strcmp(temp_parameter->name, name))
986 TRACE("Returning parameter %p\n", temp_parameter);
987 return temp_parameter;
989 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
991 switch (*part++)
993 case '.':
994 return get_parameter_by_name(NULL, temp_parameter, part);
996 case '@':
997 return get_parameter_annotation_by_name(temp_parameter, part);
999 case '[':
1000 return get_parameter_element_by_name(temp_parameter, part);
1002 default:
1003 FIXME("Unhandled case \"%c\"\n", *--part);
1004 break;
1009 TRACE("Parameter not found\n");
1010 return NULL;
1013 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1015 return (0xfeff0000 | ((major) << 8) | (minor));
1018 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1020 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1023 /*** IUnknown methods ***/
1024 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1026 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1028 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1030 if (IsEqualGUID(riid, &IID_IUnknown) ||
1031 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1033 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1034 *object = This;
1035 return S_OK;
1038 ERR("Interface %s not found\n", debugstr_guid(riid));
1040 return E_NOINTERFACE;
1043 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1045 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1047 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1049 return InterlockedIncrement(&This->ref);
1052 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1054 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1055 ULONG ref = InterlockedDecrement(&This->ref);
1057 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1059 if (!ref)
1061 free_base_effect(This);
1062 HeapFree(GetProcessHeap(), 0, This);
1065 return ref;
1068 /*** ID3DXBaseEffect methods ***/
1069 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1071 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1073 FIXME("iface %p, desc %p partial stub\n", This, desc);
1075 if (!desc)
1077 WARN("Invalid argument specified.\n");
1078 return D3DERR_INVALIDCALL;
1081 /* Todo: add creator and function count */
1082 desc->Creator = NULL;
1083 desc->Functions = 0;
1084 desc->Parameters = This->parameter_count;
1085 desc->Techniques = This->technique_count;
1087 return D3D_OK;
1090 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1092 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1093 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1095 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1097 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
1099 if (!desc || !param)
1101 WARN("Invalid argument specified.\n");
1102 return D3DERR_INVALIDCALL;
1105 desc->Name = param->name;
1106 desc->Semantic = param->semantic;
1107 desc->Class = param->class;
1108 desc->Type = param->type;
1109 desc->Rows = param->rows;
1110 desc->Columns = param->columns;
1111 desc->Elements = param->element_count;
1112 desc->Annotations = param->annotation_count;
1113 desc->StructMembers = param->member_count;
1114 desc->Flags = param->flags;
1115 desc->Bytes = param->bytes;
1117 return D3D_OK;
1120 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1122 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1123 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1125 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1127 if (!desc || !tech)
1129 WARN("Invalid argument specified.\n");
1130 return D3DERR_INVALIDCALL;
1133 desc->Name = tech->name;
1134 desc->Passes = tech->pass_count;
1135 desc->Annotations = tech->annotation_count;
1137 return D3D_OK;
1140 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1142 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1143 struct d3dx_pass *p = is_valid_pass(This, pass);
1145 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1147 if (!desc || !p)
1149 WARN("Invalid argument specified.\n");
1150 return D3DERR_INVALIDCALL;
1153 desc->Name = p->name;
1154 desc->Annotations = p->annotation_count;
1156 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1157 desc->pVertexShaderFunction = NULL;
1158 desc->pPixelShaderFunction = NULL;
1160 return D3D_OK;
1163 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1165 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1167 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1169 return E_NOTIMPL;
1172 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1174 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1175 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1177 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1179 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1181 if (!parameter)
1183 if (index < This->parameter_count)
1185 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1186 return This->parameter_handles[index];
1189 else
1191 if (param && !param->element_count && index < param->member_count)
1193 TRACE("Returning parameter %p\n", param->member_handles[index]);
1194 return param->member_handles[index];
1198 WARN("Invalid argument specified.\n");
1200 return NULL;
1203 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1205 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1206 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1207 D3DXHANDLE handle;
1209 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1211 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1213 if (!name)
1215 handle = get_parameter_handle(param);
1216 TRACE("Returning parameter %p\n", handle);
1217 return handle;
1220 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1221 TRACE("Returning parameter %p\n", handle);
1223 return handle;
1226 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1228 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1229 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1230 struct d3dx_parameter *temp_param;
1231 UINT i;
1233 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1235 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1237 if (!parameter)
1239 for (i = 0; i < This->parameter_count; ++i)
1241 temp_param = get_parameter_struct(This->parameter_handles[i]);
1243 if (!temp_param->semantic)
1245 if (!semantic)
1247 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1248 return This->parameter_handles[i];
1250 continue;
1253 if (!strcasecmp(temp_param->semantic, semantic))
1255 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1256 return This->parameter_handles[i];
1260 else if (param)
1262 for (i = 0; i < param->member_count; ++i)
1264 temp_param = get_parameter_struct(param->member_handles[i]);
1266 if (!temp_param->semantic)
1268 if (!semantic)
1270 TRACE("Returning parameter %p\n", param->member_handles[i]);
1271 return param->member_handles[i];
1273 continue;
1276 if (!strcasecmp(temp_param->semantic, semantic))
1278 TRACE("Returning parameter %p\n", param->member_handles[i]);
1279 return param->member_handles[i];
1284 WARN("Invalid argument specified\n");
1286 return NULL;
1289 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1291 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1292 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1294 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1296 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1298 if (!param)
1300 if (index < This->parameter_count)
1302 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1303 return This->parameter_handles[index];
1306 else
1308 if (index < param->element_count)
1310 TRACE("Returning parameter %p\n", param->member_handles[index]);
1311 return param->member_handles[index];
1315 WARN("Invalid argument specified\n");
1317 return NULL;
1320 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1322 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1324 TRACE("iface %p, index %u\n", This, index);
1326 if (index >= This->technique_count)
1328 WARN("Invalid argument specified.\n");
1329 return NULL;
1332 TRACE("Returning technique %p\n", This->technique_handles[index]);
1334 return This->technique_handles[index];
1337 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1339 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1340 unsigned int i;
1342 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1344 if (!name)
1346 WARN("Invalid argument specified.\n");
1347 return NULL;
1350 for (i = 0; i < This->technique_count; ++i)
1352 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1354 if (!strcmp(tech->name, name))
1356 TRACE("Returning technique %p\n", This->technique_handles[i]);
1357 return This->technique_handles[i];
1361 WARN("Invalid argument specified.\n");
1363 return NULL;
1366 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1368 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1369 struct d3dx_technique *tech = is_valid_technique(This, technique);
1371 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1373 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1375 if (tech && index < tech->pass_count)
1377 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1378 return tech->pass_handles[index];
1381 WARN("Invalid argument specified.\n");
1383 return NULL;
1386 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1388 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1389 struct d3dx_technique *tech = is_valid_technique(This, technique);
1391 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1393 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1395 if (tech && name)
1397 unsigned int i;
1399 for (i = 0; i < tech->pass_count; ++i)
1401 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1403 if (!strcmp(pass->name, name))
1405 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1406 return tech->pass_handles[i];
1411 WARN("Invalid argument specified.\n");
1413 return NULL;
1416 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1418 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1420 FIXME("iface %p, index %u stub\n", This, index);
1422 return NULL;
1425 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1427 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1429 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1431 return NULL;
1434 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1436 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1437 struct d3dx_parameter *param = is_valid_parameter(This, object);
1438 struct d3dx_pass *pass = is_valid_pass(This, object);
1439 struct d3dx_technique *technique = is_valid_technique(This, object);
1440 UINT annotation_count = 0;
1441 D3DXHANDLE *annotation_handles = NULL;
1443 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1445 if (pass)
1447 annotation_count = pass->annotation_count;
1448 annotation_handles = pass->annotation_handles;
1450 else if (technique)
1452 annotation_count = technique->annotation_count;
1453 annotation_handles = technique->annotation_handles;
1455 else
1457 if (!param) param = get_parameter_by_name(This, NULL, object);
1459 if (param)
1461 annotation_count = param->annotation_count;
1462 annotation_handles = param->annotation_handles;
1465 /* Todo: add funcs */
1467 if (index < annotation_count)
1469 TRACE("Returning parameter %p\n", annotation_handles[index]);
1470 return annotation_handles[index];
1473 WARN("Invalid argument specified\n");
1475 return NULL;
1478 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1480 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1481 struct d3dx_parameter *param = is_valid_parameter(This, object);
1482 struct d3dx_pass *pass = is_valid_pass(This, object);
1483 struct d3dx_technique *technique = is_valid_technique(This, object);
1484 UINT annotation_count = 0, i;
1485 D3DXHANDLE *annotation_handles = NULL;
1487 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1489 if (!name)
1491 WARN("Invalid argument specified\n");
1492 return NULL;
1495 if (pass)
1497 annotation_count = pass->annotation_count;
1498 annotation_handles = pass->annotation_handles;
1500 else if (technique)
1502 annotation_count = technique->annotation_count;
1503 annotation_handles = technique->annotation_handles;
1505 else
1507 if (!param) param = get_parameter_by_name(This, NULL, object);
1509 if (param)
1511 annotation_count = param->annotation_count;
1512 annotation_handles = param->annotation_handles;
1515 /* Todo: add funcs */
1517 for (i = 0; i < annotation_count; i++)
1519 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1521 if (!strcmp(anno->name, name))
1523 TRACE("Returning parameter %p\n", anno);
1524 return get_parameter_handle(anno);
1528 WARN("Invalid argument specified\n");
1530 return NULL;
1533 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1535 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1537 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1539 return E_NOTIMPL;
1542 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1544 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1545 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1547 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1549 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1550 if (!param)
1552 WARN("Invalid parameter %p specified\n", parameter);
1553 return D3DERR_INVALIDCALL;
1556 /* samplers don't touch data */
1557 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1558 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1559 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1561 TRACE("Sampler: returning E_FAIL\n");
1562 return E_FAIL;
1565 if (data && param->bytes <= bytes)
1567 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1569 switch (param->type)
1571 case D3DXPT_VOID:
1572 case D3DXPT_BOOL:
1573 case D3DXPT_INT:
1574 case D3DXPT_FLOAT:
1575 case D3DXPT_STRING:
1576 break;
1578 case D3DXPT_VERTEXSHADER:
1579 case D3DXPT_PIXELSHADER:
1580 case D3DXPT_TEXTURE:
1581 case D3DXPT_TEXTURE1D:
1582 case D3DXPT_TEXTURE2D:
1583 case D3DXPT_TEXTURE3D:
1584 case D3DXPT_TEXTURECUBE:
1586 UINT i;
1588 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1590 IUnknown *unk = ((IUnknown **)param->data)[i];
1591 if (unk) IUnknown_AddRef(unk);
1593 break;
1596 default:
1597 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1598 break;
1601 TRACE("Copy %u bytes\n", param->bytes);
1602 memcpy(data, param->data, param->bytes);
1603 return D3D_OK;
1606 WARN("Invalid argument specified\n");
1608 return D3DERR_INVALIDCALL;
1611 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1613 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1615 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1617 return E_NOTIMPL;
1620 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1622 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1623 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1625 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1627 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1629 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1631 *b = get_bool(param->data);
1632 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1633 return D3D_OK;
1636 WARN("Invalid argument specified\n");
1638 return D3DERR_INVALIDCALL;
1641 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1643 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1645 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1647 return E_NOTIMPL;
1650 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1652 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1653 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1655 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1657 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1659 if (b && param && (param->class == D3DXPC_SCALAR
1660 || param->class == D3DXPC_VECTOR
1661 || param->class == D3DXPC_MATRIX_ROWS
1662 || param->class == D3DXPC_MATRIX_COLUMNS))
1664 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1666 for (i = 0; i < size; ++i)
1668 b[i] = get_bool((DWORD *)param->data + i);
1670 return D3D_OK;
1673 WARN("Invalid argument specified\n");
1675 return D3DERR_INVALIDCALL;
1678 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1680 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1682 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1684 return E_NOTIMPL;
1687 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1689 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1690 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1692 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1694 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1696 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1698 *n = get_int(param->type, param->data);
1699 TRACE("Returning %i\n", *n);
1700 return D3D_OK;
1703 WARN("Invalid argument specified\n");
1705 return D3DERR_INVALIDCALL;
1708 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1710 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1712 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1714 return E_NOTIMPL;
1717 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1719 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1720 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1722 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1724 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1726 if (n && param && (param->class == D3DXPC_SCALAR
1727 || param->class == D3DXPC_VECTOR
1728 || param->class == D3DXPC_MATRIX_ROWS
1729 || param->class == D3DXPC_MATRIX_COLUMNS))
1731 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1733 for (i = 0; i < size; ++i)
1735 n[i] = get_int(param->type, (DWORD *)param->data + i);
1737 return D3D_OK;
1740 WARN("Invalid argument specified\n");
1742 return D3DERR_INVALIDCALL;
1745 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1747 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1749 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1751 return E_NOTIMPL;
1754 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1756 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1757 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1759 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1761 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1763 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1765 f = param->data;
1766 TRACE("Returning %f\n", *f);
1767 return D3D_OK;
1770 WARN("Invalid argument specified\n");
1772 return D3DERR_INVALIDCALL;
1775 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1777 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1779 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1781 return E_NOTIMPL;
1784 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1786 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1787 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1789 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1791 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1793 if (f && param && (param->class == D3DXPC_SCALAR
1794 || param->class == D3DXPC_VECTOR
1795 || param->class == D3DXPC_MATRIX_ROWS
1796 || param->class == D3DXPC_MATRIX_COLUMNS))
1798 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1800 for (i = 0; i < size; ++i)
1802 f[i] = get_float(param->type, (DWORD *)param->data + i);
1804 return D3D_OK;
1807 WARN("Invalid argument specified\n");
1809 return D3DERR_INVALIDCALL;
1812 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1814 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1816 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1818 return E_NOTIMPL;
1821 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1823 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1825 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1827 return E_NOTIMPL;
1830 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1832 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1834 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1836 return E_NOTIMPL;
1839 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1841 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1843 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1845 return E_NOTIMPL;
1848 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1850 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1852 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1854 return E_NOTIMPL;
1857 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1859 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1861 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1863 return E_NOTIMPL;
1866 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1868 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1870 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1872 return E_NOTIMPL;
1875 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1877 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1879 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1881 return E_NOTIMPL;
1884 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1886 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1888 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1890 return E_NOTIMPL;
1893 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1895 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1897 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1899 return E_NOTIMPL;
1902 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1904 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1906 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1908 return E_NOTIMPL;
1911 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1913 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1915 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1917 return E_NOTIMPL;
1920 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1922 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1924 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1926 return E_NOTIMPL;
1929 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1931 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1933 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1935 return E_NOTIMPL;
1938 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1940 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1942 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1944 return E_NOTIMPL;
1947 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1949 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1951 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1953 return E_NOTIMPL;
1956 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1958 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1960 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1962 return E_NOTIMPL;
1965 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1967 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1968 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1970 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1972 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1974 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1976 *string = *(LPCSTR *)param->data;
1977 TRACE("Returning %s\n", debugstr_a(*string));
1978 return D3D_OK;
1981 WARN("Invalid argument specified\n");
1983 return D3DERR_INVALIDCALL;
1986 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1988 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1990 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1992 return E_NOTIMPL;
1995 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
1997 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1998 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2000 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2002 if (texture && param && !param->element_count &&
2003 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2004 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2005 || param->type == D3DXPT_TEXTURECUBE))
2007 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2008 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2009 TRACE("Returning %p\n", *texture);
2010 return D3D_OK;
2013 WARN("Invalid argument specified\n");
2015 return D3DERR_INVALIDCALL;
2018 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2020 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2021 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2023 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2025 if (!param) param = get_parameter_by_name(This, NULL, parameter);
2027 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2029 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2030 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2031 TRACE("Returning %p\n", *pshader);
2032 return D3D_OK;
2035 WARN("Invalid argument specified\n");
2037 return D3DERR_INVALIDCALL;
2040 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2042 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2043 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2045 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2047 if (!param) param = get_parameter_by_name(This, NULL, parameter);
2049 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2051 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2052 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2053 TRACE("Returning %p\n", *vshader);
2054 return D3D_OK;
2057 WARN("Invalid argument specified\n");
2059 return D3DERR_INVALIDCALL;
2062 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2064 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2066 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2068 return E_NOTIMPL;
2071 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2073 /*** IUnknown methods ***/
2074 ID3DXBaseEffectImpl_QueryInterface,
2075 ID3DXBaseEffectImpl_AddRef,
2076 ID3DXBaseEffectImpl_Release,
2077 /*** ID3DXBaseEffect methods ***/
2078 ID3DXBaseEffectImpl_GetDesc,
2079 ID3DXBaseEffectImpl_GetParameterDesc,
2080 ID3DXBaseEffectImpl_GetTechniqueDesc,
2081 ID3DXBaseEffectImpl_GetPassDesc,
2082 ID3DXBaseEffectImpl_GetFunctionDesc,
2083 ID3DXBaseEffectImpl_GetParameter,
2084 ID3DXBaseEffectImpl_GetParameterByName,
2085 ID3DXBaseEffectImpl_GetParameterBySemantic,
2086 ID3DXBaseEffectImpl_GetParameterElement,
2087 ID3DXBaseEffectImpl_GetTechnique,
2088 ID3DXBaseEffectImpl_GetTechniqueByName,
2089 ID3DXBaseEffectImpl_GetPass,
2090 ID3DXBaseEffectImpl_GetPassByName,
2091 ID3DXBaseEffectImpl_GetFunction,
2092 ID3DXBaseEffectImpl_GetFunctionByName,
2093 ID3DXBaseEffectImpl_GetAnnotation,
2094 ID3DXBaseEffectImpl_GetAnnotationByName,
2095 ID3DXBaseEffectImpl_SetValue,
2096 ID3DXBaseEffectImpl_GetValue,
2097 ID3DXBaseEffectImpl_SetBool,
2098 ID3DXBaseEffectImpl_GetBool,
2099 ID3DXBaseEffectImpl_SetBoolArray,
2100 ID3DXBaseEffectImpl_GetBoolArray,
2101 ID3DXBaseEffectImpl_SetInt,
2102 ID3DXBaseEffectImpl_GetInt,
2103 ID3DXBaseEffectImpl_SetIntArray,
2104 ID3DXBaseEffectImpl_GetIntArray,
2105 ID3DXBaseEffectImpl_SetFloat,
2106 ID3DXBaseEffectImpl_GetFloat,
2107 ID3DXBaseEffectImpl_SetFloatArray,
2108 ID3DXBaseEffectImpl_GetFloatArray,
2109 ID3DXBaseEffectImpl_SetVector,
2110 ID3DXBaseEffectImpl_GetVector,
2111 ID3DXBaseEffectImpl_SetVectorArray,
2112 ID3DXBaseEffectImpl_GetVectorArray,
2113 ID3DXBaseEffectImpl_SetMatrix,
2114 ID3DXBaseEffectImpl_GetMatrix,
2115 ID3DXBaseEffectImpl_SetMatrixArray,
2116 ID3DXBaseEffectImpl_GetMatrixArray,
2117 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2118 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2119 ID3DXBaseEffectImpl_SetMatrixTranspose,
2120 ID3DXBaseEffectImpl_GetMatrixTranspose,
2121 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2122 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2123 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2124 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2125 ID3DXBaseEffectImpl_SetString,
2126 ID3DXBaseEffectImpl_GetString,
2127 ID3DXBaseEffectImpl_SetTexture,
2128 ID3DXBaseEffectImpl_GetTexture,
2129 ID3DXBaseEffectImpl_GetPixelShader,
2130 ID3DXBaseEffectImpl_GetVertexShader,
2131 ID3DXBaseEffectImpl_SetArrayRange,
2134 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2136 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2139 /*** IUnknown methods ***/
2140 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2142 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2144 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2146 if (IsEqualGUID(riid, &IID_IUnknown) ||
2147 IsEqualGUID(riid, &IID_ID3DXEffect))
2149 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2150 *object = This;
2151 return S_OK;
2154 ERR("Interface %s not found\n", debugstr_guid(riid));
2156 return E_NOINTERFACE;
2159 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2161 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2163 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2165 return InterlockedIncrement(&This->ref);
2168 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2170 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2171 ULONG ref = InterlockedDecrement(&This->ref);
2173 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2175 if (!ref)
2177 free_effect(This);
2178 HeapFree(GetProcessHeap(), 0, This);
2181 return ref;
2184 /*** ID3DXBaseEffect methods ***/
2185 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2187 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2188 ID3DXBaseEffect *base = This->base_effect;
2190 TRACE("Forward iface %p, base %p\n", This, base);
2192 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2195 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2197 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2198 ID3DXBaseEffect *base = This->base_effect;
2200 TRACE("Forward iface %p, base %p\n", This, base);
2202 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2205 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2207 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2208 ID3DXBaseEffect *base = This->base_effect;
2210 TRACE("Forward iface %p, base %p\n", This, base);
2212 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2215 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2217 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2218 ID3DXBaseEffect *base = This->base_effect;
2220 TRACE("Forward iface %p, base %p\n", This, base);
2222 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2225 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2227 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2228 ID3DXBaseEffect *base = This->base_effect;
2230 TRACE("Forward iface %p, base %p\n", This, base);
2232 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2235 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2237 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2238 ID3DXBaseEffect *base = This->base_effect;
2240 TRACE("Forward iface %p, base %p\n", This, base);
2242 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2245 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2247 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2248 ID3DXBaseEffect *base = This->base_effect;
2250 TRACE("Forward iface %p, base %p\n", This, base);
2252 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2255 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2257 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2258 ID3DXBaseEffect *base = This->base_effect;
2260 TRACE("Forward iface %p, base %p\n", This, base);
2262 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2265 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2267 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2268 ID3DXBaseEffect *base = This->base_effect;
2270 TRACE("Forward iface %p, base %p\n", This, base);
2272 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2275 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2277 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2278 ID3DXBaseEffect *base = This->base_effect;
2280 TRACE("Forward iface %p, base %p\n", This, base);
2282 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2285 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2287 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2288 ID3DXBaseEffect *base = This->base_effect;
2290 TRACE("Forward iface %p, base %p\n", This, base);
2292 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2295 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2297 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2298 ID3DXBaseEffect *base = This->base_effect;
2300 TRACE("Forward iface %p, base %p\n", This, base);
2302 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2305 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2307 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2308 ID3DXBaseEffect *base = This->base_effect;
2310 TRACE("Forward iface %p, base %p\n", This, base);
2312 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2315 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2317 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2318 ID3DXBaseEffect *base = This->base_effect;
2320 TRACE("Forward iface %p, base %p\n", This, base);
2322 return ID3DXBaseEffectImpl_GetFunction(base, index);
2325 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2327 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2328 ID3DXBaseEffect *base = This->base_effect;
2330 TRACE("Forward iface %p, base %p\n", This, base);
2332 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2335 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2337 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2338 ID3DXBaseEffect *base = This->base_effect;
2340 TRACE("Forward iface %p, base %p\n", This, base);
2342 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2345 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2347 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2348 ID3DXBaseEffect *base = This->base_effect;
2350 TRACE("Forward iface %p, base %p\n", This, base);
2352 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2355 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2357 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2358 ID3DXBaseEffect *base = This->base_effect;
2360 TRACE("Forward iface %p, base %p\n", This, base);
2362 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2365 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2367 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2368 ID3DXBaseEffect *base = This->base_effect;
2370 TRACE("Forward iface %p, base %p\n", This, base);
2372 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2375 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2377 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2378 ID3DXBaseEffect *base = This->base_effect;
2380 TRACE("Forward iface %p, base %p\n", This, base);
2382 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2385 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2387 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2388 ID3DXBaseEffect *base = This->base_effect;
2390 TRACE("Forward iface %p, base %p\n", This, base);
2392 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2395 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2397 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2398 ID3DXBaseEffect *base = This->base_effect;
2400 TRACE("Forward iface %p, base %p\n", This, base);
2402 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2405 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2407 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2408 ID3DXBaseEffect *base = This->base_effect;
2410 TRACE("Forward iface %p, base %p\n", This, base);
2412 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2415 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2417 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2418 ID3DXBaseEffect *base = This->base_effect;
2420 TRACE("Forward iface %p, base %p\n", This, base);
2422 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2425 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2427 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2428 ID3DXBaseEffect *base = This->base_effect;
2430 TRACE("Forward iface %p, base %p\n", This, base);
2432 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2435 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2437 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2438 ID3DXBaseEffect *base = This->base_effect;
2440 TRACE("Forward iface %p, base %p\n", This, base);
2442 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2445 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2447 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2448 ID3DXBaseEffect *base = This->base_effect;
2450 TRACE("Forward iface %p, base %p\n", This, base);
2452 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2455 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2457 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2458 ID3DXBaseEffect *base = This->base_effect;
2460 TRACE("Forward iface %p, base %p\n", This, base);
2462 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2465 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2467 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2468 ID3DXBaseEffect *base = This->base_effect;
2470 TRACE("Forward iface %p, base %p\n", This, base);
2472 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2475 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2477 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2478 ID3DXBaseEffect *base = This->base_effect;
2480 TRACE("Forward iface %p, base %p\n", This, base);
2482 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2485 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2487 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2488 ID3DXBaseEffect *base = This->base_effect;
2490 TRACE("Forward iface %p, base %p\n", This, base);
2492 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2495 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2497 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2498 ID3DXBaseEffect *base = This->base_effect;
2500 TRACE("Forward iface %p, base %p\n", This, base);
2502 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2505 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2507 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2508 ID3DXBaseEffect *base = This->base_effect;
2510 TRACE("Forward iface %p, base %p\n", This, base);
2512 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2515 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2517 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2518 ID3DXBaseEffect *base = This->base_effect;
2520 TRACE("Forward iface %p, base %p\n", This, base);
2522 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2525 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2527 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2528 ID3DXBaseEffect *base = This->base_effect;
2530 TRACE("Forward iface %p, base %p\n", This, base);
2532 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2535 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2537 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2538 ID3DXBaseEffect *base = This->base_effect;
2540 TRACE("Forward iface %p, base %p\n", This, base);
2542 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2545 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2547 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2548 ID3DXBaseEffect *base = This->base_effect;
2550 TRACE("Forward iface %p, base %p\n", This, base);
2552 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2555 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2557 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2558 ID3DXBaseEffect *base = This->base_effect;
2560 TRACE("Forward iface %p, base %p\n", This, base);
2562 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2565 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2567 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2568 ID3DXBaseEffect *base = This->base_effect;
2570 TRACE("Forward iface %p, base %p\n", This, base);
2572 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2575 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2577 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2578 ID3DXBaseEffect *base = This->base_effect;
2580 TRACE("Forward iface %p, base %p\n", This, base);
2582 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2585 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2587 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2588 ID3DXBaseEffect *base = This->base_effect;
2590 TRACE("Forward iface %p, base %p\n", This, base);
2592 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2595 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2597 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2598 ID3DXBaseEffect *base = This->base_effect;
2600 TRACE("Forward iface %p, base %p\n", This, base);
2602 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2605 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2607 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2608 ID3DXBaseEffect *base = This->base_effect;
2610 TRACE("Forward iface %p, base %p\n", This, base);
2612 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2615 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2617 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2618 ID3DXBaseEffect *base = This->base_effect;
2620 TRACE("Forward iface %p, base %p\n", This, base);
2622 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2625 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2627 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2628 ID3DXBaseEffect *base = This->base_effect;
2630 TRACE("Forward iface %p, base %p\n", This, base);
2632 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2635 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2637 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2638 ID3DXBaseEffect *base = This->base_effect;
2640 TRACE("Forward iface %p, base %p\n", This, base);
2642 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2645 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2647 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2648 ID3DXBaseEffect *base = This->base_effect;
2650 TRACE("Forward iface %p, base %p\n", This, base);
2652 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2655 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2657 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2658 ID3DXBaseEffect *base = This->base_effect;
2660 TRACE("Forward iface %p, base %p\n", This, base);
2662 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2665 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2667 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2668 ID3DXBaseEffect *base = This->base_effect;
2670 TRACE("Forward iface %p, base %p\n", This, base);
2672 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2675 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2677 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2678 ID3DXBaseEffect *base = This->base_effect;
2680 TRACE("Forward iface %p, base %p\n", This, base);
2682 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2685 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2687 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2688 ID3DXBaseEffect *base = This->base_effect;
2690 TRACE("Forward iface %p, base %p\n", This, base);
2692 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2695 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2697 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2698 ID3DXBaseEffect *base = This->base_effect;
2700 TRACE("Forward iface %p, base %p\n", This, base);
2702 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2705 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2707 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2708 ID3DXBaseEffect *base = This->base_effect;
2710 TRACE("Forward iface %p, base %p\n", This, base);
2712 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2715 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2717 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2718 ID3DXBaseEffect *base = This->base_effect;
2720 TRACE("Forward iface %p, base %p\n", This, base);
2722 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2725 /*** ID3DXEffect methods ***/
2726 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2728 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2730 TRACE("iface %p, pool %p\n", This, pool);
2732 if (!pool)
2734 WARN("Invalid argument supplied.\n");
2735 return D3DERR_INVALIDCALL;
2738 if (This->pool)
2740 This->pool->lpVtbl->AddRef(This->pool);
2743 *pool = This->pool;
2745 TRACE("Returning pool %p\n", *pool);
2747 return S_OK;
2750 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2752 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2754 FIXME("(%p)->(%p): stub\n", This, technique);
2756 return E_NOTIMPL;
2759 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
2761 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2763 TRACE("iface %p\n", This);
2765 return This->active_technique;
2768 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2770 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2772 FIXME("(%p)->(%p): stub\n", This, technique);
2774 return D3D_OK;
2777 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2779 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2781 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2783 return E_NOTIMPL;
2786 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2788 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2790 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2792 return FALSE;
2795 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
2797 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2798 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2800 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
2802 if (passes && technique)
2804 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
2806 TRACE("State capturing disabled.\n");
2808 else
2810 FIXME("State capturing not supported, yet!\n");
2813 *passes = technique->pass_count;
2815 return D3D_OK;
2818 WARN("Invalid argument supplied.\n");
2820 return D3DERR_INVALIDCALL;
2823 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
2825 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2826 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2828 TRACE("iface %p, pass %u\n", This, pass);
2830 if (technique && pass < technique->pass_count && !This->active_pass)
2832 This->active_pass = technique->pass_handles[pass];
2834 FIXME("No states applied, yet!\n");
2836 return D3D_OK;
2839 WARN("Invalid argument supplied.\n");
2841 return D3DERR_INVALIDCALL;
2844 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2846 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2848 FIXME("(%p)->(): stub\n", This);
2850 return E_NOTIMPL;
2853 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
2855 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2857 FIXME("(%p)->(): stub\n", This);
2859 return E_NOTIMPL;
2862 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2864 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2866 FIXME("(%p)->(): stub\n", This);
2868 return E_NOTIMPL;
2871 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2873 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2875 TRACE("iface %p, device %p\n", This, device);
2877 if (!device)
2879 WARN("Invalid argument supplied.\n");
2880 return D3DERR_INVALIDCALL;
2883 IDirect3DDevice9_AddRef(This->device);
2885 *device = This->device;
2887 TRACE("Returning device %p\n", *device);
2889 return S_OK;
2892 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2894 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2896 FIXME("(%p)->(): stub\n", This);
2898 return E_NOTIMPL;
2901 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2903 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2905 FIXME("(%p)->(): stub\n", This);
2907 return E_NOTIMPL;
2910 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2912 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2914 TRACE("iface %p, manager %p\n", This, manager);
2916 if (This->manager) IUnknown_Release(This->manager);
2917 if (manager) IUnknown_AddRef(manager);
2919 This->manager = manager;
2921 return D3D_OK;
2924 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2926 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2928 TRACE("iface %p, manager %p\n", This, manager);
2930 if (!manager)
2932 WARN("Invalid argument supplied.\n");
2933 return D3DERR_INVALIDCALL;
2936 if (This->manager) IUnknown_AddRef(This->manager);
2937 *manager = This->manager;
2939 return D3D_OK;
2942 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2944 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2946 FIXME("(%p)->(): stub\n", This);
2948 return E_NOTIMPL;
2951 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2953 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2955 FIXME("(%p)->(): stub\n", This);
2957 return NULL;
2960 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2962 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2964 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2966 return E_NOTIMPL;
2969 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2971 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2973 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2975 return E_NOTIMPL;
2978 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
2980 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2982 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
2984 return E_NOTIMPL;
2987 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
2989 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2991 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
2993 return E_NOTIMPL;
2996 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
2998 /*** IUnknown methods ***/
2999 ID3DXEffectImpl_QueryInterface,
3000 ID3DXEffectImpl_AddRef,
3001 ID3DXEffectImpl_Release,
3002 /*** ID3DXBaseEffect methods ***/
3003 ID3DXEffectImpl_GetDesc,
3004 ID3DXEffectImpl_GetParameterDesc,
3005 ID3DXEffectImpl_GetTechniqueDesc,
3006 ID3DXEffectImpl_GetPassDesc,
3007 ID3DXEffectImpl_GetFunctionDesc,
3008 ID3DXEffectImpl_GetParameter,
3009 ID3DXEffectImpl_GetParameterByName,
3010 ID3DXEffectImpl_GetParameterBySemantic,
3011 ID3DXEffectImpl_GetParameterElement,
3012 ID3DXEffectImpl_GetTechnique,
3013 ID3DXEffectImpl_GetTechniqueByName,
3014 ID3DXEffectImpl_GetPass,
3015 ID3DXEffectImpl_GetPassByName,
3016 ID3DXEffectImpl_GetFunction,
3017 ID3DXEffectImpl_GetFunctionByName,
3018 ID3DXEffectImpl_GetAnnotation,
3019 ID3DXEffectImpl_GetAnnotationByName,
3020 ID3DXEffectImpl_SetValue,
3021 ID3DXEffectImpl_GetValue,
3022 ID3DXEffectImpl_SetBool,
3023 ID3DXEffectImpl_GetBool,
3024 ID3DXEffectImpl_SetBoolArray,
3025 ID3DXEffectImpl_GetBoolArray,
3026 ID3DXEffectImpl_SetInt,
3027 ID3DXEffectImpl_GetInt,
3028 ID3DXEffectImpl_SetIntArray,
3029 ID3DXEffectImpl_GetIntArray,
3030 ID3DXEffectImpl_SetFloat,
3031 ID3DXEffectImpl_GetFloat,
3032 ID3DXEffectImpl_SetFloatArray,
3033 ID3DXEffectImpl_GetFloatArray,
3034 ID3DXEffectImpl_SetVector,
3035 ID3DXEffectImpl_GetVector,
3036 ID3DXEffectImpl_SetVectorArray,
3037 ID3DXEffectImpl_GetVectorArray,
3038 ID3DXEffectImpl_SetMatrix,
3039 ID3DXEffectImpl_GetMatrix,
3040 ID3DXEffectImpl_SetMatrixArray,
3041 ID3DXEffectImpl_GetMatrixArray,
3042 ID3DXEffectImpl_SetMatrixPointerArray,
3043 ID3DXEffectImpl_GetMatrixPointerArray,
3044 ID3DXEffectImpl_SetMatrixTranspose,
3045 ID3DXEffectImpl_GetMatrixTranspose,
3046 ID3DXEffectImpl_SetMatrixTransposeArray,
3047 ID3DXEffectImpl_GetMatrixTransposeArray,
3048 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3049 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3050 ID3DXEffectImpl_SetString,
3051 ID3DXEffectImpl_GetString,
3052 ID3DXEffectImpl_SetTexture,
3053 ID3DXEffectImpl_GetTexture,
3054 ID3DXEffectImpl_GetPixelShader,
3055 ID3DXEffectImpl_GetVertexShader,
3056 ID3DXEffectImpl_SetArrayRange,
3057 /*** ID3DXEffect methods ***/
3058 ID3DXEffectImpl_GetPool,
3059 ID3DXEffectImpl_SetTechnique,
3060 ID3DXEffectImpl_GetCurrentTechnique,
3061 ID3DXEffectImpl_ValidateTechnique,
3062 ID3DXEffectImpl_FindNextValidTechnique,
3063 ID3DXEffectImpl_IsParameterUsed,
3064 ID3DXEffectImpl_Begin,
3065 ID3DXEffectImpl_BeginPass,
3066 ID3DXEffectImpl_CommitChanges,
3067 ID3DXEffectImpl_EndPass,
3068 ID3DXEffectImpl_End,
3069 ID3DXEffectImpl_GetDevice,
3070 ID3DXEffectImpl_OnLostDevice,
3071 ID3DXEffectImpl_OnResetDevice,
3072 ID3DXEffectImpl_SetStateManager,
3073 ID3DXEffectImpl_GetStateManager,
3074 ID3DXEffectImpl_BeginParameterBlock,
3075 ID3DXEffectImpl_EndParameterBlock,
3076 ID3DXEffectImpl_ApplyParameterBlock,
3077 ID3DXEffectImpl_DeleteParameterBlock,
3078 ID3DXEffectImpl_CloneEffect,
3079 ID3DXEffectImpl_SetRawValue
3082 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3084 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3087 /*** IUnknown methods ***/
3088 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3090 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3092 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3094 if (IsEqualGUID(riid, &IID_IUnknown) ||
3095 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3097 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3098 *object = This;
3099 return S_OK;
3102 ERR("Interface %s not found\n", debugstr_guid(riid));
3104 return E_NOINTERFACE;
3107 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3109 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3111 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3113 return InterlockedIncrement(&This->ref);
3116 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3118 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3119 ULONG ref = InterlockedDecrement(&This->ref);
3121 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3123 if (!ref)
3125 free_effect_compiler(This);
3126 HeapFree(GetProcessHeap(), 0, This);
3129 return ref;
3132 /*** ID3DXBaseEffect methods ***/
3133 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3135 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3136 ID3DXBaseEffect *base = This->base_effect;
3138 TRACE("Forward iface %p, base %p\n", This, base);
3140 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3143 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3145 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3146 ID3DXBaseEffect *base = This->base_effect;
3148 TRACE("Forward iface %p, base %p\n", This, base);
3150 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3153 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3155 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3156 ID3DXBaseEffect *base = This->base_effect;
3158 TRACE("Forward iface %p, base %p\n", This, base);
3160 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3163 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3165 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3166 ID3DXBaseEffect *base = This->base_effect;
3168 TRACE("Forward iface %p, base %p\n", This, base);
3170 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3173 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3175 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3176 ID3DXBaseEffect *base = This->base_effect;
3178 TRACE("Forward iface %p, base %p\n", This, base);
3180 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3183 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3185 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3186 ID3DXBaseEffect *base = This->base_effect;
3188 TRACE("Forward iface %p, base %p\n", This, base);
3190 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3193 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3195 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3196 ID3DXBaseEffect *base = This->base_effect;
3198 TRACE("Forward iface %p, base %p\n", This, base);
3200 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3203 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3205 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3206 ID3DXBaseEffect *base = This->base_effect;
3208 TRACE("Forward iface %p, base %p\n", This, base);
3210 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3213 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3215 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3216 ID3DXBaseEffect *base = This->base_effect;
3218 TRACE("Forward iface %p, base %p\n", This, base);
3220 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3223 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3225 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3226 ID3DXBaseEffect *base = This->base_effect;
3228 TRACE("Forward iface %p, base %p\n", This, base);
3230 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3233 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3235 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3236 ID3DXBaseEffect *base = This->base_effect;
3238 TRACE("Forward iface %p, base %p\n", This, base);
3240 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3243 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3245 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3246 ID3DXBaseEffect *base = This->base_effect;
3248 TRACE("Forward iface %p, base %p\n", This, base);
3250 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3253 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3255 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3256 ID3DXBaseEffect *base = This->base_effect;
3258 TRACE("Forward iface %p, base %p\n", This, base);
3260 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3263 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3265 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3266 ID3DXBaseEffect *base = This->base_effect;
3268 TRACE("Forward iface %p, base %p\n", This, base);
3270 return ID3DXBaseEffectImpl_GetFunction(base, index);
3273 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3275 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3276 ID3DXBaseEffect *base = This->base_effect;
3278 TRACE("Forward iface %p, base %p\n", This, base);
3280 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3283 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3285 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3286 ID3DXBaseEffect *base = This->base_effect;
3288 TRACE("Forward iface %p, base %p\n", This, base);
3290 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3293 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3295 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3296 ID3DXBaseEffect *base = This->base_effect;
3298 TRACE("Forward iface %p, base %p\n", This, base);
3300 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3303 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3305 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3306 ID3DXBaseEffect *base = This->base_effect;
3308 TRACE("Forward iface %p, base %p\n", This, base);
3310 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3313 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3315 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3316 ID3DXBaseEffect *base = This->base_effect;
3318 TRACE("Forward iface %p, base %p\n", This, base);
3320 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3323 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3325 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3326 ID3DXBaseEffect *base = This->base_effect;
3328 TRACE("Forward iface %p, base %p\n", This, base);
3330 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3333 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3335 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3336 ID3DXBaseEffect *base = This->base_effect;
3338 TRACE("Forward iface %p, base %p\n", This, base);
3340 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3343 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3345 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3346 ID3DXBaseEffect *base = This->base_effect;
3348 TRACE("Forward iface %p, base %p\n", This, base);
3350 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3353 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3355 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3356 ID3DXBaseEffect *base = This->base_effect;
3358 TRACE("Forward iface %p, base %p\n", This, base);
3360 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3363 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3365 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3366 ID3DXBaseEffect *base = This->base_effect;
3368 TRACE("Forward iface %p, base %p\n", This, base);
3370 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3373 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3375 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3376 ID3DXBaseEffect *base = This->base_effect;
3378 TRACE("Forward iface %p, base %p\n", This, base);
3380 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3383 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3385 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3386 ID3DXBaseEffect *base = This->base_effect;
3388 TRACE("Forward iface %p, base %p\n", This, base);
3390 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3393 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3395 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3396 ID3DXBaseEffect *base = This->base_effect;
3398 TRACE("Forward iface %p, base %p\n", This, base);
3400 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3403 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3405 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3406 ID3DXBaseEffect *base = This->base_effect;
3408 TRACE("Forward iface %p, base %p\n", This, base);
3410 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3413 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3415 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3416 ID3DXBaseEffect *base = This->base_effect;
3418 TRACE("Forward iface %p, base %p\n", This, base);
3420 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3423 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3425 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3426 ID3DXBaseEffect *base = This->base_effect;
3428 TRACE("Forward iface %p, base %p\n", This, base);
3430 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3433 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3435 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3436 ID3DXBaseEffect *base = This->base_effect;
3438 TRACE("Forward iface %p, base %p\n", This, base);
3440 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3443 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3445 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3446 ID3DXBaseEffect *base = This->base_effect;
3448 TRACE("Forward iface %p, base %p\n", This, base);
3450 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3453 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3455 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3456 ID3DXBaseEffect *base = This->base_effect;
3458 TRACE("Forward iface %p, base %p\n", This, base);
3460 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3463 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3465 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3466 ID3DXBaseEffect *base = This->base_effect;
3468 TRACE("Forward iface %p, base %p\n", This, base);
3470 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3473 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3475 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3476 ID3DXBaseEffect *base = This->base_effect;
3478 TRACE("Forward iface %p, base %p\n", This, base);
3480 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3483 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3485 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3486 ID3DXBaseEffect *base = This->base_effect;
3488 TRACE("Forward iface %p, base %p\n", This, base);
3490 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3493 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3495 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3496 ID3DXBaseEffect *base = This->base_effect;
3498 TRACE("Forward iface %p, base %p\n", This, base);
3500 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3503 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3505 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3506 ID3DXBaseEffect *base = This->base_effect;
3508 TRACE("Forward iface %p, base %p\n", This, base);
3510 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3513 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3515 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3516 ID3DXBaseEffect *base = This->base_effect;
3518 TRACE("Forward iface %p, base %p\n", This, base);
3520 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3523 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3525 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3526 ID3DXBaseEffect *base = This->base_effect;
3528 TRACE("Forward iface %p, base %p\n", This, base);
3530 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3533 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3535 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3536 ID3DXBaseEffect *base = This->base_effect;
3538 TRACE("Forward iface %p, base %p\n", This, base);
3540 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3543 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3545 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3546 ID3DXBaseEffect *base = This->base_effect;
3548 TRACE("Forward iface %p, base %p\n", This, base);
3550 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3553 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3555 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3556 ID3DXBaseEffect *base = This->base_effect;
3558 TRACE("Forward iface %p, base %p\n", This, base);
3560 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3563 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3565 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3566 ID3DXBaseEffect *base = This->base_effect;
3568 TRACE("Forward iface %p, base %p\n", This, base);
3570 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3573 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3575 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3576 ID3DXBaseEffect *base = This->base_effect;
3578 TRACE("Forward iface %p, base %p\n", This, base);
3580 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3583 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3585 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3586 ID3DXBaseEffect *base = This->base_effect;
3588 TRACE("Forward iface %p, base %p\n", This, base);
3590 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3593 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3595 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3596 ID3DXBaseEffect *base = This->base_effect;
3598 TRACE("Forward iface %p, base %p\n", This, base);
3600 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3603 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3605 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3606 ID3DXBaseEffect *base = This->base_effect;
3608 TRACE("Forward iface %p, base %p\n", This, base);
3610 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3613 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3615 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3616 ID3DXBaseEffect *base = This->base_effect;
3618 TRACE("Forward iface %p, base %p\n", This, base);
3620 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3623 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3625 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3626 ID3DXBaseEffect *base = This->base_effect;
3628 TRACE("Forward iface %p, base %p\n", This, base);
3630 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3633 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3635 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3636 ID3DXBaseEffect *base = This->base_effect;
3638 TRACE("Forward iface %p, base %p\n", This, base);
3640 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3643 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3645 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3646 ID3DXBaseEffect *base = This->base_effect;
3648 TRACE("Forward iface %p, base %p\n", This, base);
3650 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3653 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3655 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3656 ID3DXBaseEffect *base = This->base_effect;
3658 TRACE("Forward iface %p, base %p\n", This, base);
3660 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3663 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3665 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3666 ID3DXBaseEffect *base = This->base_effect;
3668 TRACE("Forward iface %p, base %p\n", This, base);
3670 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3673 /*** ID3DXEffectCompiler methods ***/
3674 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3676 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3678 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3680 return E_NOTIMPL;
3683 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3685 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3687 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3689 return E_NOTIMPL;
3692 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3693 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3695 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3697 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3699 return E_NOTIMPL;
3702 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3703 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3705 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3707 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3708 This, function, target, flags, shader, error_msgs, constant_table);
3710 return E_NOTIMPL;
3713 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3715 /*** IUnknown methods ***/
3716 ID3DXEffectCompilerImpl_QueryInterface,
3717 ID3DXEffectCompilerImpl_AddRef,
3718 ID3DXEffectCompilerImpl_Release,
3719 /*** ID3DXBaseEffect methods ***/
3720 ID3DXEffectCompilerImpl_GetDesc,
3721 ID3DXEffectCompilerImpl_GetParameterDesc,
3722 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3723 ID3DXEffectCompilerImpl_GetPassDesc,
3724 ID3DXEffectCompilerImpl_GetFunctionDesc,
3725 ID3DXEffectCompilerImpl_GetParameter,
3726 ID3DXEffectCompilerImpl_GetParameterByName,
3727 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3728 ID3DXEffectCompilerImpl_GetParameterElement,
3729 ID3DXEffectCompilerImpl_GetTechnique,
3730 ID3DXEffectCompilerImpl_GetTechniqueByName,
3731 ID3DXEffectCompilerImpl_GetPass,
3732 ID3DXEffectCompilerImpl_GetPassByName,
3733 ID3DXEffectCompilerImpl_GetFunction,
3734 ID3DXEffectCompilerImpl_GetFunctionByName,
3735 ID3DXEffectCompilerImpl_GetAnnotation,
3736 ID3DXEffectCompilerImpl_GetAnnotationByName,
3737 ID3DXEffectCompilerImpl_SetValue,
3738 ID3DXEffectCompilerImpl_GetValue,
3739 ID3DXEffectCompilerImpl_SetBool,
3740 ID3DXEffectCompilerImpl_GetBool,
3741 ID3DXEffectCompilerImpl_SetBoolArray,
3742 ID3DXEffectCompilerImpl_GetBoolArray,
3743 ID3DXEffectCompilerImpl_SetInt,
3744 ID3DXEffectCompilerImpl_GetInt,
3745 ID3DXEffectCompilerImpl_SetIntArray,
3746 ID3DXEffectCompilerImpl_GetIntArray,
3747 ID3DXEffectCompilerImpl_SetFloat,
3748 ID3DXEffectCompilerImpl_GetFloat,
3749 ID3DXEffectCompilerImpl_SetFloatArray,
3750 ID3DXEffectCompilerImpl_GetFloatArray,
3751 ID3DXEffectCompilerImpl_SetVector,
3752 ID3DXEffectCompilerImpl_GetVector,
3753 ID3DXEffectCompilerImpl_SetVectorArray,
3754 ID3DXEffectCompilerImpl_GetVectorArray,
3755 ID3DXEffectCompilerImpl_SetMatrix,
3756 ID3DXEffectCompilerImpl_GetMatrix,
3757 ID3DXEffectCompilerImpl_SetMatrixArray,
3758 ID3DXEffectCompilerImpl_GetMatrixArray,
3759 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3760 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3761 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3762 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3763 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3764 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3765 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3766 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3767 ID3DXEffectCompilerImpl_SetString,
3768 ID3DXEffectCompilerImpl_GetString,
3769 ID3DXEffectCompilerImpl_SetTexture,
3770 ID3DXEffectCompilerImpl_GetTexture,
3771 ID3DXEffectCompilerImpl_GetPixelShader,
3772 ID3DXEffectCompilerImpl_GetVertexShader,
3773 ID3DXEffectCompilerImpl_SetArrayRange,
3774 /*** ID3DXEffectCompiler methods ***/
3775 ID3DXEffectCompilerImpl_SetLiteral,
3776 ID3DXEffectCompilerImpl_GetLiteral,
3777 ID3DXEffectCompilerImpl_CompileEffect,
3778 ID3DXEffectCompilerImpl_CompileShader,
3781 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
3783 HRESULT hr;
3784 UINT i;
3785 struct d3dx_state *states;
3787 read_dword(ptr, &sampler->state_count);
3788 TRACE("Count: %u\n", sampler->state_count);
3790 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
3791 if (!states)
3793 ERR("Out of memory\n");
3794 return E_OUTOFMEMORY;
3797 for (i = 0; i < sampler->state_count; ++i)
3799 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
3800 if (hr != D3D_OK)
3802 WARN("Failed to parse state\n");
3803 goto err_out;
3807 sampler->states = states;
3809 return D3D_OK;
3811 err_out:
3813 for (i = 0; i < sampler->state_count; ++i)
3815 free_state(&states[i]);
3818 HeapFree(GetProcessHeap(), 0, states);
3820 return hr;
3823 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
3825 unsigned int i;
3826 HRESULT hr;
3827 UINT old_size = 0;
3828 DWORD id;
3830 if (param->element_count)
3832 param->data = value;
3834 for (i = 0; i < param->element_count; ++i)
3836 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3838 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
3839 if (hr != D3D_OK)
3841 WARN("Failed to parse value\n");
3842 return hr;
3845 old_size += member->bytes;
3848 return D3D_OK;
3851 switch(param->class)
3853 case D3DXPC_SCALAR:
3854 case D3DXPC_VECTOR:
3855 case D3DXPC_MATRIX_ROWS:
3856 case D3DXPC_MATRIX_COLUMNS:
3857 param->data = value;
3858 break;
3860 case D3DXPC_STRUCT:
3861 param->data = value;
3863 for (i = 0; i < param->member_count; ++i)
3865 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3867 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
3868 if (hr != D3D_OK)
3870 WARN("Failed to parse value\n");
3871 return hr;
3874 old_size += member->bytes;
3876 break;
3878 case D3DXPC_OBJECT:
3879 switch (param->type)
3881 case D3DXPT_STRING:
3882 case D3DXPT_TEXTURE:
3883 case D3DXPT_TEXTURE1D:
3884 case D3DXPT_TEXTURE2D:
3885 case D3DXPT_TEXTURE3D:
3886 case D3DXPT_TEXTURECUBE:
3887 case D3DXPT_PIXELSHADER:
3888 case D3DXPT_VERTEXSHADER:
3889 read_dword(ptr, &id);
3890 TRACE("Id: %u\n", id);
3891 objects[id] = get_parameter_handle(param);
3892 param->data = value;
3893 break;
3895 case D3DXPT_SAMPLER:
3896 case D3DXPT_SAMPLER1D:
3897 case D3DXPT_SAMPLER2D:
3898 case D3DXPT_SAMPLER3D:
3899 case D3DXPT_SAMPLERCUBE:
3901 struct d3dx_sampler *sampler;
3903 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
3904 if (!sampler)
3906 ERR("Out of memory\n");
3907 return E_OUTOFMEMORY;
3910 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
3911 if (hr != D3D_OK)
3913 HeapFree(GetProcessHeap(), 0, sampler);
3914 WARN("Failed to parse sampler\n");
3915 return hr;
3918 param->data = sampler;
3919 break;
3922 default:
3923 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3924 break;
3926 break;
3928 default:
3929 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3930 break;
3933 return D3D_OK;
3936 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
3938 UINT size = param->bytes;
3939 HRESULT hr;
3940 void *value = NULL;
3942 TRACE("param size: %u\n", size);
3944 if (size)
3946 value = HeapAlloc(GetProcessHeap(), 0, size);
3947 if (!value)
3949 ERR("Failed to allocate data memory.\n");
3950 return E_OUTOFMEMORY;
3953 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3954 memcpy(value, ptr, size);
3957 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
3958 if (hr != D3D_OK)
3960 WARN("Failed to parse value\n");
3961 HeapFree(GetProcessHeap(), 0, value);
3962 return hr;
3965 return D3D_OK;
3968 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
3970 DWORD size;
3972 read_dword(&ptr, &size);
3973 TRACE("Name size: %#x\n", size);
3975 if (!size)
3977 return D3D_OK;
3980 *name = HeapAlloc(GetProcessHeap(), 0, size);
3981 if (!*name)
3983 ERR("Failed to allocate name memory.\n");
3984 return E_OUTOFMEMORY;
3987 TRACE("Name: %s.\n", debugstr_an(ptr, size));
3988 memcpy(*name, ptr, size);
3990 return D3D_OK;
3993 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
3995 DWORD size;
3996 HRESULT hr;
3998 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4000 read_dword(ptr, &size);
4001 TRACE("Data size: %#x\n", size);
4003 if (!size)
4005 TRACE("Size is 0\n");
4006 *(void **)param->data = NULL;
4007 return D3D_OK;
4010 switch (param->type)
4012 case D3DXPT_STRING:
4013 /* re-read with size (sizeof(DWORD) = 4) */
4014 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4015 if (hr != D3D_OK)
4017 WARN("Failed to parse string data\n");
4018 return hr;
4020 break;
4022 case D3DXPT_VERTEXSHADER:
4023 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4024 if (hr != D3D_OK)
4026 WARN("Failed to create vertex shader\n");
4027 return hr;
4029 break;
4031 case D3DXPT_PIXELSHADER:
4032 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4033 if (hr != D3D_OK)
4035 WARN("Failed to create pixel shader\n");
4036 return hr;
4038 break;
4040 default:
4041 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4042 break;
4046 *ptr += ((size + 3) & ~3);
4048 return D3D_OK;
4051 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4052 struct d3dx_parameter *parent, UINT flags)
4054 DWORD offset;
4055 HRESULT hr;
4056 D3DXHANDLE *member_handles = NULL;
4057 UINT i;
4059 param->flags = flags;
4061 if (!parent)
4063 read_dword(ptr, &param->type);
4064 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4066 read_dword(ptr, &param->class);
4067 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4069 read_dword(ptr, &offset);
4070 TRACE("Type name offset: %#x\n", offset);
4071 hr = d3dx9_parse_name(&param->name, data + offset);
4072 if (hr != D3D_OK)
4074 WARN("Failed to parse name\n");
4075 goto err_out;
4078 read_dword(ptr, &offset);
4079 TRACE("Type semantic offset: %#x\n", offset);
4080 hr = d3dx9_parse_name(&param->semantic, data + offset);
4081 if (hr != D3D_OK)
4083 WARN("Failed to parse semantic\n");
4084 goto err_out;
4087 read_dword(ptr, &param->element_count);
4088 TRACE("Elements: %u\n", param->element_count);
4090 switch (param->class)
4092 case D3DXPC_VECTOR:
4093 read_dword(ptr, &param->columns);
4094 TRACE("Columns: %u\n", param->columns);
4096 read_dword(ptr, &param->rows);
4097 TRACE("Rows: %u\n", param->rows);
4099 /* sizeof(DWORD) * rows * columns */
4100 param->bytes = 4 * param->rows * param->columns;
4101 break;
4103 case D3DXPC_SCALAR:
4104 case D3DXPC_MATRIX_ROWS:
4105 case D3DXPC_MATRIX_COLUMNS:
4106 read_dword(ptr, &param->rows);
4107 TRACE("Rows: %u\n", param->rows);
4109 read_dword(ptr, &param->columns);
4110 TRACE("Columns: %u\n", param->columns);
4112 /* sizeof(DWORD) * rows * columns */
4113 param->bytes = 4 * param->rows * param->columns;
4114 break;
4116 case D3DXPC_STRUCT:
4117 read_dword(ptr, &param->member_count);
4118 TRACE("Members: %u\n", param->member_count);
4119 break;
4121 case D3DXPC_OBJECT:
4122 switch (param->type)
4124 case D3DXPT_STRING:
4125 param->bytes = sizeof(LPCSTR);
4126 break;
4128 case D3DXPT_PIXELSHADER:
4129 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4130 break;
4132 case D3DXPT_VERTEXSHADER:
4133 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4134 break;
4136 case D3DXPT_TEXTURE:
4137 case D3DXPT_TEXTURE1D:
4138 case D3DXPT_TEXTURE2D:
4139 case D3DXPT_TEXTURE3D:
4140 case D3DXPT_TEXTURECUBE:
4141 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4142 break;
4144 case D3DXPT_SAMPLER:
4145 case D3DXPT_SAMPLER1D:
4146 case D3DXPT_SAMPLER2D:
4147 case D3DXPT_SAMPLER3D:
4148 case D3DXPT_SAMPLERCUBE:
4149 param->bytes = 0;
4150 break;
4152 default:
4153 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4154 break;
4156 break;
4158 default:
4159 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4160 break;
4163 else
4165 /* elements */
4166 param->type = parent->type;
4167 param->class = parent->class;
4168 param->name = parent->name;
4169 param->semantic = parent->semantic;
4170 param->element_count = 0;
4171 param->annotation_count = 0;
4172 param->member_count = parent->member_count;
4173 param->bytes = parent->bytes;
4174 param->rows = parent->rows;
4175 param->columns = parent->columns;
4178 if (param->element_count)
4180 unsigned int param_bytes = 0;
4181 const char *save_ptr = *ptr;
4183 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4184 if (!member_handles)
4186 ERR("Out of memory\n");
4187 hr = E_OUTOFMEMORY;
4188 goto err_out;
4191 for (i = 0; i < param->element_count; ++i)
4193 struct d3dx_parameter *member;
4194 *ptr = save_ptr;
4196 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4197 if (!member)
4199 ERR("Out of memory\n");
4200 hr = E_OUTOFMEMORY;
4201 goto err_out;
4204 member_handles[i] = get_parameter_handle(member);
4206 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4207 if (hr != D3D_OK)
4209 WARN("Failed to parse member\n");
4210 goto err_out;
4213 param_bytes += member->bytes;
4216 param->bytes = param_bytes;
4218 else if (param->member_count)
4220 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4221 if (!member_handles)
4223 ERR("Out of memory\n");
4224 hr = E_OUTOFMEMORY;
4225 goto err_out;
4228 for (i = 0; i < param->member_count; ++i)
4230 struct d3dx_parameter *member;
4232 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4233 if (!member)
4235 ERR("Out of memory\n");
4236 hr = E_OUTOFMEMORY;
4237 goto err_out;
4240 member_handles[i] = get_parameter_handle(member);
4242 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4243 if (hr != D3D_OK)
4245 WARN("Failed to parse member\n");
4246 goto err_out;
4249 param->bytes += member->bytes;
4253 param->member_handles = member_handles;
4255 return D3D_OK;
4257 err_out:
4259 if (member_handles)
4261 unsigned int count;
4263 if (param->element_count) count = param->element_count;
4264 else count = param->member_count;
4266 for (i = 0; i < count; ++i)
4268 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4270 HeapFree(GetProcessHeap(), 0, member_handles);
4273 if (!parent)
4275 HeapFree(GetProcessHeap(), 0, param->name);
4276 HeapFree(GetProcessHeap(), 0, param->semantic);
4278 param->name = NULL;
4279 param->semantic = NULL;
4281 return hr;
4284 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4286 DWORD offset;
4287 const char *ptr2;
4288 HRESULT hr;
4290 anno->flags = D3DX_PARAMETER_ANNOTATION;
4292 read_dword(ptr, &offset);
4293 TRACE("Typedef offset: %#x\n", offset);
4294 ptr2 = data + offset;
4295 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4296 if (hr != D3D_OK)
4298 WARN("Failed to parse type definition\n");
4299 return hr;
4302 read_dword(ptr, &offset);
4303 TRACE("Value offset: %#x\n", offset);
4304 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4305 if (hr != D3D_OK)
4307 WARN("Failed to parse value\n");
4308 return hr;
4311 return D3D_OK;
4314 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4316 DWORD offset;
4317 const char *ptr2;
4318 HRESULT hr;
4319 struct d3dx_parameter *parameter;
4321 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4322 if (!parameter)
4324 ERR("Out of memory\n");
4325 return E_OUTOFMEMORY;
4328 state->type = ST_CONSTANT;
4330 read_dword(ptr, &state->operation);
4331 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4333 read_dword(ptr, &state->index);
4334 TRACE("Index: %#x\n", state->index);
4336 read_dword(ptr, &offset);
4337 TRACE("Typedef offset: %#x\n", offset);
4338 ptr2 = data + offset;
4339 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4340 if (hr != D3D_OK)
4342 WARN("Failed to parse type definition\n");
4343 goto err_out;
4346 read_dword(ptr, &offset);
4347 TRACE("Value offset: %#x\n", offset);
4348 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4349 if (hr != D3D_OK)
4351 WARN("Failed to parse value\n");
4352 goto err_out;
4355 state->parameter = get_parameter_handle(parameter);
4357 return D3D_OK;
4359 err_out:
4361 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4363 return hr;
4366 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4368 DWORD offset;
4369 HRESULT hr;
4370 unsigned int i;
4371 D3DXHANDLE *annotation_handles = NULL;
4372 const char *ptr2;
4374 read_dword(ptr, &offset);
4375 TRACE("Typedef offset: %#x\n", offset);
4376 ptr2 = data + offset;
4378 read_dword(ptr, &offset);
4379 TRACE("Value offset: %#x\n", offset);
4381 read_dword(ptr, &param->flags);
4382 TRACE("Flags: %#x\n", param->flags);
4384 read_dword(ptr, &param->annotation_count);
4385 TRACE("Annotation count: %u\n", param->annotation_count);
4387 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4388 if (hr != D3D_OK)
4390 WARN("Failed to parse type definition\n");
4391 return hr;
4394 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4395 if (hr != D3D_OK)
4397 WARN("Failed to parse value\n");
4398 return hr;
4401 if (param->annotation_count)
4403 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4404 if (!annotation_handles)
4406 ERR("Out of memory\n");
4407 hr = E_OUTOFMEMORY;
4408 goto err_out;
4411 for (i = 0; i < param->annotation_count; ++i)
4413 struct d3dx_parameter *annotation;
4415 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4416 if (!annotation)
4418 ERR("Out of memory\n");
4419 hr = E_OUTOFMEMORY;
4420 goto err_out;
4423 annotation_handles[i] = get_parameter_handle(annotation);
4425 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4426 if (hr != D3D_OK)
4428 WARN("Failed to parse annotation\n");
4429 goto err_out;
4434 param->annotation_handles = annotation_handles;
4436 return D3D_OK;
4438 err_out:
4440 if (annotation_handles)
4442 for (i = 0; i < param->annotation_count; ++i)
4444 free_parameter(annotation_handles[i], FALSE, FALSE);
4446 HeapFree(GetProcessHeap(), 0, annotation_handles);
4449 return hr;
4452 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4454 DWORD offset;
4455 HRESULT hr;
4456 unsigned int i;
4457 D3DXHANDLE *annotation_handles = NULL;
4458 struct d3dx_state *states = NULL;
4459 char *name = NULL;
4461 read_dword(ptr, &offset);
4462 TRACE("Pass name offset: %#x\n", offset);
4463 hr = d3dx9_parse_name(&name, data + offset);
4464 if (hr != D3D_OK)
4466 WARN("Failed to parse name\n");
4467 goto err_out;
4470 read_dword(ptr, &pass->annotation_count);
4471 TRACE("Annotation count: %u\n", pass->annotation_count);
4473 read_dword(ptr, &pass->state_count);
4474 TRACE("State count: %u\n", pass->state_count);
4476 if (pass->annotation_count)
4478 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4479 if (!annotation_handles)
4481 ERR("Out of memory\n");
4482 hr = E_OUTOFMEMORY;
4483 goto err_out;
4486 for (i = 0; i < pass->annotation_count; ++i)
4488 struct d3dx_parameter *annotation;
4490 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4491 if (!annotation)
4493 ERR("Out of memory\n");
4494 hr = E_OUTOFMEMORY;
4495 goto err_out;
4498 annotation_handles[i] = get_parameter_handle(annotation);
4500 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4501 if (hr != D3D_OK)
4503 WARN("Failed to parse annotations\n");
4504 goto err_out;
4509 if (pass->state_count)
4511 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4512 if (!states)
4514 ERR("Out of memory\n");
4515 hr = E_OUTOFMEMORY;
4516 goto err_out;
4519 for (i = 0; i < pass->state_count; ++i)
4521 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4522 if (hr != D3D_OK)
4524 WARN("Failed to parse annotations\n");
4525 goto err_out;
4530 pass->name = name;
4531 pass->annotation_handles = annotation_handles;
4532 pass->states = states;
4534 return D3D_OK;
4536 err_out:
4538 if (annotation_handles)
4540 for (i = 0; i < pass->annotation_count; ++i)
4542 free_parameter(annotation_handles[i], FALSE, FALSE);
4544 HeapFree(GetProcessHeap(), 0, annotation_handles);
4547 if (states)
4549 for (i = 0; i < pass->state_count; ++i)
4551 free_state(&states[i]);
4553 HeapFree(GetProcessHeap(), 0, states);
4556 HeapFree(GetProcessHeap(), 0, name);
4558 return hr;
4561 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4563 DWORD offset;
4564 HRESULT hr;
4565 unsigned int i;
4566 D3DXHANDLE *annotation_handles = NULL;
4567 D3DXHANDLE *pass_handles = NULL;
4568 char *name = NULL;
4570 read_dword(ptr, &offset);
4571 TRACE("Technique name offset: %#x\n", offset);
4572 hr = d3dx9_parse_name(&name, data + offset);
4573 if (hr != D3D_OK)
4575 WARN("Failed to parse name\n");
4576 goto err_out;
4579 read_dword(ptr, &technique->annotation_count);
4580 TRACE("Annotation count: %u\n", technique->annotation_count);
4582 read_dword(ptr, &technique->pass_count);
4583 TRACE("Pass count: %u\n", technique->pass_count);
4585 if (technique->annotation_count)
4587 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4588 if (!annotation_handles)
4590 ERR("Out of memory\n");
4591 hr = E_OUTOFMEMORY;
4592 goto err_out;
4595 for (i = 0; i < technique->annotation_count; ++i)
4597 struct d3dx_parameter *annotation;
4599 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4600 if (!annotation)
4602 ERR("Out of memory\n");
4603 hr = E_OUTOFMEMORY;
4604 goto err_out;
4607 annotation_handles[i] = get_parameter_handle(annotation);
4609 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4610 if (hr != D3D_OK)
4612 WARN("Failed to parse annotations\n");
4613 goto err_out;
4618 if (technique->pass_count)
4620 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4621 if (!pass_handles)
4623 ERR("Out of memory\n");
4624 hr = E_OUTOFMEMORY;
4625 goto err_out;
4628 for (i = 0; i < technique->pass_count; ++i)
4630 struct d3dx_pass *pass;
4632 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4633 if (!pass)
4635 ERR("Out of memory\n");
4636 hr = E_OUTOFMEMORY;
4637 goto err_out;
4640 pass_handles[i] = get_pass_handle(pass);
4642 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
4643 if (hr != D3D_OK)
4645 WARN("Failed to parse passes\n");
4646 goto err_out;
4651 technique->name = name;
4652 technique->pass_handles = pass_handles;
4653 technique->annotation_handles = annotation_handles;
4655 return D3D_OK;
4657 err_out:
4659 if (pass_handles)
4661 for (i = 0; i < technique->pass_count; ++i)
4663 free_pass(pass_handles[i]);
4665 HeapFree(GetProcessHeap(), 0, pass_handles);
4668 if (annotation_handles)
4670 for (i = 0; i < technique->annotation_count; ++i)
4672 free_parameter(annotation_handles[i], FALSE, FALSE);
4674 HeapFree(GetProcessHeap(), 0, annotation_handles);
4677 HeapFree(GetProcessHeap(), 0, name);
4679 return hr;
4682 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
4684 DWORD technique_index;
4685 DWORD index, state_index, usage;
4686 struct d3dx_state *state;
4687 struct d3dx_parameter *param;
4688 HRESULT hr;
4690 read_dword(ptr, &technique_index);
4691 TRACE("techn: %u\n", technique_index);
4693 read_dword(ptr, &index);
4694 TRACE("index: %u\n", index);
4696 skip_dword_unknown(ptr, 1);
4698 read_dword(ptr, &state_index);
4699 TRACE("state: %u\n", state_index);
4701 read_dword(ptr, &usage);
4702 TRACE("usage: %u\n", usage);
4704 if (technique_index == 0xffffffff)
4706 struct d3dx_parameter *parameter;
4707 struct d3dx_sampler *sampler;
4709 if (index >= base->parameter_count)
4711 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
4712 return E_FAIL;
4715 parameter = get_parameter_struct(base->parameter_handles[index]);
4716 sampler = parameter->data;
4717 if (state_index >= sampler->state_count)
4719 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
4720 return E_FAIL;
4723 state = &sampler->states[state_index];
4725 else
4727 struct d3dx_technique *technique;
4728 struct d3dx_pass *pass;
4730 if (technique_index >= base->technique_count)
4732 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
4733 return E_FAIL;
4736 technique = get_technique_struct(base->technique_handles[technique_index]);
4737 if (index >= technique->pass_count)
4739 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
4740 return E_FAIL;
4743 pass = get_pass_struct(technique->pass_handles[index]);
4744 if (state_index >= pass->state_count)
4746 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
4747 return E_FAIL;
4750 state = &pass->states[state_index];
4753 param = get_parameter_struct(state->parameter);
4755 switch (usage)
4757 case 0:
4758 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
4759 switch (param->type)
4761 case D3DXPT_VERTEXSHADER:
4762 case D3DXPT_PIXELSHADER:
4763 state->type = ST_CONSTANT;
4764 hr = d3dx9_parse_data(param, ptr, base->effect->device);
4765 break;
4767 default:
4768 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4769 hr=E_FAIL;
4770 break;
4772 break;
4774 default:
4775 FIXME("Unknown usage %x\n", usage);
4776 hr=E_FAIL;
4777 break;
4780 return hr;
4783 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4785 const char *ptr = data + start;
4786 D3DXHANDLE *parameter_handles = NULL;
4787 D3DXHANDLE *technique_handles = NULL;
4788 D3DXHANDLE *objects = NULL;
4789 UINT stringcount, objectcount, resourcecount;
4790 HRESULT hr;
4791 UINT i;
4793 read_dword(&ptr, &base->parameter_count);
4794 TRACE("Parameter count: %u\n", base->parameter_count);
4796 read_dword(&ptr, &base->technique_count);
4797 TRACE("Technique count: %u\n", base->technique_count);
4799 skip_dword_unknown(&ptr, 1);
4801 read_dword(&ptr, &objectcount);
4802 TRACE("Object count: %u\n", objectcount);
4804 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
4805 if (!objects)
4807 ERR("Out of memory\n");
4808 hr = E_OUTOFMEMORY;
4809 goto err_out;
4812 if (base->parameter_count)
4814 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4815 if (!parameter_handles)
4817 ERR("Out of memory\n");
4818 hr = E_OUTOFMEMORY;
4819 goto err_out;
4822 for (i = 0; i < base->parameter_count; ++i)
4824 struct d3dx_parameter *parameter;
4826 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4827 if (!parameter)
4829 ERR("Out of memory\n");
4830 hr = E_OUTOFMEMORY;
4831 goto err_out;
4834 parameter_handles[i] = get_parameter_handle(parameter);
4836 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
4837 if (hr != D3D_OK)
4839 WARN("Failed to parse parameter\n");
4840 goto err_out;
4845 if (base->technique_count)
4847 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4848 if (!technique_handles)
4850 ERR("Out of memory\n");
4851 hr = E_OUTOFMEMORY;
4852 goto err_out;
4855 for (i = 0; i < base->technique_count; ++i)
4857 struct d3dx_technique *technique;
4859 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4860 if (!technique)
4862 ERR("Out of memory\n");
4863 hr = E_OUTOFMEMORY;
4864 goto err_out;
4867 technique_handles[i] = get_technique_handle(technique);
4869 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
4870 if (hr != D3D_OK)
4872 WARN("Failed to parse technique\n");
4873 goto err_out;
4878 /* needed for further parsing */
4879 base->technique_handles = technique_handles;
4880 base->parameter_handles = parameter_handles;
4882 read_dword(&ptr, &stringcount);
4883 TRACE("String count: %u\n", stringcount);
4885 read_dword(&ptr, &resourcecount);
4886 TRACE("Resource count: %u\n", resourcecount);
4888 for (i = 0; i < stringcount; ++i)
4890 DWORD id;
4891 struct d3dx_parameter *param;
4893 read_dword(&ptr, &id);
4894 TRACE("Id: %u\n", id);
4896 param = get_parameter_struct(objects[id]);
4898 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
4899 if (hr != D3D_OK)
4901 WARN("Failed to parse data\n");
4902 goto err_out;
4906 for (i = 0; i < resourcecount; ++i)
4908 TRACE("parse resource %u\n", i);
4910 hr = d3dx9_parse_resource(base, data, &ptr);
4911 if (hr != D3D_OK)
4913 WARN("Failed to parse data\n");
4914 goto err_out;
4918 HeapFree(GetProcessHeap(), 0, objects);
4920 return D3D_OK;
4922 err_out:
4924 if (technique_handles)
4926 for (i = 0; i < base->technique_count; ++i)
4928 free_technique(technique_handles[i]);
4930 HeapFree(GetProcessHeap(), 0, technique_handles);
4933 if (parameter_handles)
4935 for (i = 0; i < base->parameter_count; ++i)
4937 free_parameter(parameter_handles[i], FALSE, FALSE);
4939 HeapFree(GetProcessHeap(), 0, parameter_handles);
4942 base->technique_handles = NULL;
4943 base->parameter_handles = NULL;
4945 HeapFree(GetProcessHeap(), 0, objects);
4947 return hr;
4950 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
4951 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
4953 DWORD tag, offset;
4954 const char *ptr = data;
4955 HRESULT hr;
4957 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
4959 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
4960 base->ref = 1;
4961 base->effect = effect;
4963 read_dword(&ptr, &tag);
4964 TRACE("Tag: %x\n", tag);
4966 if (tag != d3dx9_effect_version(9, 1))
4968 /* todo: compile hlsl ascii code */
4969 FIXME("HLSL ascii effects not supported, yet\n");
4971 /* Show the start of the shader for debugging info. */
4972 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
4974 else
4976 read_dword(&ptr, &offset);
4977 TRACE("Offset: %x\n", offset);
4979 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
4980 if (hr != D3D_OK)
4982 FIXME("Failed to parse effect.\n");
4983 return hr;
4987 return D3D_OK;
4990 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
4991 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
4993 HRESULT hr;
4994 struct ID3DXBaseEffectImpl *object = NULL;
4996 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
4998 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
4999 effect->ref = 1;
5001 if (pool) pool->lpVtbl->AddRef(pool);
5002 effect->pool = pool;
5004 IDirect3DDevice9_AddRef(device);
5005 effect->device = device;
5007 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5008 if (!object)
5010 ERR("Out of memory\n");
5011 hr = E_OUTOFMEMORY;
5012 goto err_out;
5015 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5016 if (hr != D3D_OK)
5018 FIXME("Failed to parse effect.\n");
5019 goto err_out;
5022 effect->base_effect = &object->ID3DXBaseEffect_iface;
5024 /* initialize defaults - check because of unsupported ascii effects */
5025 if (object->technique_handles)
5027 effect->active_technique = object->technique_handles[0];
5028 effect->active_pass = NULL;
5031 return D3D_OK;
5033 err_out:
5035 HeapFree(GetProcessHeap(), 0, object);
5036 free_effect(effect);
5038 return hr;
5041 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5042 LPCVOID srcdata,
5043 UINT srcdatalen,
5044 CONST D3DXMACRO* defines,
5045 LPD3DXINCLUDE include,
5046 LPCSTR skip_constants,
5047 DWORD flags,
5048 LPD3DXEFFECTPOOL pool,
5049 LPD3DXEFFECT* effect,
5050 LPD3DXBUFFER* compilation_errors)
5052 struct ID3DXEffectImpl *object;
5053 HRESULT hr;
5055 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5056 skip_constants, flags, pool, effect, compilation_errors);
5058 if (!device || !srcdata)
5059 return D3DERR_INVALIDCALL;
5061 if (!srcdatalen)
5062 return E_FAIL;
5064 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5065 if (!effect)
5066 return D3D_OK;
5068 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5069 if (!object)
5071 ERR("Out of memory\n");
5072 return E_OUTOFMEMORY;
5075 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5076 if (FAILED(hr))
5078 WARN("Failed to initialize shader reflection\n");
5079 HeapFree(GetProcessHeap(), 0, object);
5080 return hr;
5083 *effect = &object->ID3DXEffect_iface;
5085 TRACE("Created ID3DXEffect %p\n", object);
5087 return D3D_OK;
5090 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5091 LPCVOID srcdata,
5092 UINT srcdatalen,
5093 CONST D3DXMACRO* defines,
5094 LPD3DXINCLUDE include,
5095 DWORD flags,
5096 LPD3DXEFFECTPOOL pool,
5097 LPD3DXEFFECT* effect,
5098 LPD3DXBUFFER* compilation_errors)
5100 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5101 include, flags, pool, effect, compilation_errors);
5103 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5106 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5108 HRESULT hr;
5109 struct ID3DXBaseEffectImpl *object = NULL;
5111 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5113 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5114 compiler->ref = 1;
5116 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5117 if (!object)
5119 ERR("Out of memory\n");
5120 hr = E_OUTOFMEMORY;
5121 goto err_out;
5124 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5125 if (hr != D3D_OK)
5127 FIXME("Failed to parse effect.\n");
5128 goto err_out;
5131 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5133 return D3D_OK;
5135 err_out:
5137 HeapFree(GetProcessHeap(), 0, object);
5138 free_effect_compiler(compiler);
5140 return hr;
5143 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5144 UINT srcdatalen,
5145 CONST D3DXMACRO *defines,
5146 LPD3DXINCLUDE include,
5147 DWORD flags,
5148 LPD3DXEFFECTCOMPILER *compiler,
5149 LPD3DXBUFFER *parse_errors)
5151 struct ID3DXEffectCompilerImpl *object;
5152 HRESULT hr;
5154 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5155 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5157 if (!srcdata || !compiler)
5159 WARN("Invalid arguments supplied\n");
5160 return D3DERR_INVALIDCALL;
5163 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5164 if (!object)
5166 ERR("Out of memory\n");
5167 return E_OUTOFMEMORY;
5170 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5171 if (FAILED(hr))
5173 WARN("Failed to initialize effect compiler\n");
5174 HeapFree(GetProcessHeap(), 0, object);
5175 return hr;
5178 *compiler = &object->ID3DXEffectCompiler_iface;
5180 TRACE("Created ID3DXEffectCompiler %p\n", object);
5182 return D3D_OK;
5185 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5187 struct ID3DXEffectPoolImpl
5189 ID3DXEffectPool ID3DXEffectPool_iface;
5190 LONG ref;
5193 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5195 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5198 /*** IUnknown methods ***/
5199 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5201 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5203 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5205 if (IsEqualGUID(riid, &IID_IUnknown) ||
5206 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5208 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5209 *object = This;
5210 return S_OK;
5213 WARN("Interface %s not found\n", debugstr_guid(riid));
5215 return E_NOINTERFACE;
5218 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5220 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5222 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5224 return InterlockedIncrement(&This->ref);
5227 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5229 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5230 ULONG ref = InterlockedDecrement(&This->ref);
5232 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5234 if (!ref)
5235 HeapFree(GetProcessHeap(), 0, This);
5237 return ref;
5240 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5242 /*** IUnknown methods ***/
5243 ID3DXEffectPoolImpl_QueryInterface,
5244 ID3DXEffectPoolImpl_AddRef,
5245 ID3DXEffectPoolImpl_Release
5248 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5250 struct ID3DXEffectPoolImpl *object;
5252 TRACE("(%p)\n", pool);
5254 if (!pool)
5255 return D3DERR_INVALIDCALL;
5257 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5258 if (!object)
5260 ERR("Out of memory\n");
5261 return E_OUTOFMEMORY;
5264 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5265 object->ref = 1;
5267 *pool = &object->ID3DXEffectPool_iface;
5269 return S_OK;
5272 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5273 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5274 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5276 LPVOID buffer;
5277 HRESULT ret;
5278 DWORD size;
5280 TRACE("(%s): relay\n", debugstr_w(srcfile));
5282 if (!device || !srcfile)
5283 return D3DERR_INVALIDCALL;
5285 ret = map_view_of_file(srcfile, &buffer, &size);
5287 if (FAILED(ret))
5288 return D3DXERR_INVALIDDATA;
5290 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5291 UnmapViewOfFile(buffer);
5293 return ret;
5296 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5297 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5298 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5300 LPWSTR srcfileW;
5301 HRESULT ret;
5302 DWORD len;
5304 TRACE("(void): relay\n");
5306 if (!srcfile)
5307 return D3DERR_INVALIDCALL;
5309 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5310 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5311 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5313 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5314 HeapFree(GetProcessHeap(), 0, srcfileW);
5316 return ret;
5319 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5320 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5321 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5323 TRACE("(void): relay\n");
5324 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5327 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5328 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5329 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5331 TRACE("(void): relay\n");
5332 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5335 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5336 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5337 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5339 HRSRC resinfo;
5341 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5343 if (!device)
5344 return D3DERR_INVALIDCALL;
5346 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5348 if (resinfo)
5350 LPVOID buffer;
5351 HRESULT ret;
5352 DWORD size;
5354 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5356 if (FAILED(ret))
5357 return D3DXERR_INVALIDDATA;
5359 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5362 return D3DXERR_INVALIDDATA;
5365 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5366 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5367 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5369 HRSRC resinfo;
5371 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5373 if (!device)
5374 return D3DERR_INVALIDCALL;
5376 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5378 if (resinfo)
5380 LPVOID buffer;
5381 HRESULT ret;
5382 DWORD size;
5384 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5386 if (FAILED(ret))
5387 return D3DXERR_INVALIDDATA;
5389 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5392 return D3DXERR_INVALIDDATA;
5395 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5396 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5397 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5399 TRACE("(void): relay\n");
5400 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5403 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5404 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5405 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5407 TRACE("(void): relay\n");
5408 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5411 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5412 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5414 LPVOID buffer;
5415 HRESULT ret;
5416 DWORD size;
5418 TRACE("(%s): relay\n", debugstr_w(srcfile));
5420 if (!srcfile)
5421 return D3DERR_INVALIDCALL;
5423 ret = map_view_of_file(srcfile, &buffer, &size);
5425 if (FAILED(ret))
5426 return D3DXERR_INVALIDDATA;
5428 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5429 UnmapViewOfFile(buffer);
5431 return ret;
5434 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5435 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5437 LPWSTR srcfileW;
5438 HRESULT ret;
5439 DWORD len;
5441 TRACE("(void): relay\n");
5443 if (!srcfile)
5444 return D3DERR_INVALIDCALL;
5446 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5447 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5448 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5450 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5451 HeapFree(GetProcessHeap(), 0, srcfileW);
5453 return ret;
5456 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5457 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5459 HRSRC resinfo;
5461 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5463 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5465 if (resinfo)
5467 LPVOID buffer;
5468 HRESULT ret;
5469 DWORD size;
5471 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5473 if (FAILED(ret))
5474 return D3DXERR_INVALIDDATA;
5476 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5479 return D3DXERR_INVALIDDATA;
5482 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5483 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5485 HRSRC resinfo;
5487 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5489 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5491 if (resinfo)
5493 LPVOID buffer;
5494 HRESULT ret;
5495 DWORD size;
5497 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5499 if (FAILED(ret))
5500 return D3DXERR_INVALIDDATA;
5502 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5505 return D3DXERR_INVALIDDATA;