d3dx9: Implement ID3DXBaseEffect::SetTexture().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blob88c6a16ef5ec408ddcc091ac9c3798ea30e490ee
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,
91 ST_PARAMETER,
92 ST_FXLC,
95 struct d3dx_parameter
97 char *name;
98 char *semantic;
99 void *data;
100 D3DXPARAMETER_CLASS class;
101 D3DXPARAMETER_TYPE type;
102 UINT rows;
103 UINT columns;
104 UINT element_count;
105 UINT annotation_count;
106 UINT member_count;
107 DWORD flags;
108 UINT bytes;
110 D3DXHANDLE *annotation_handles;
111 D3DXHANDLE *member_handles;
114 struct d3dx_state
116 UINT operation;
117 UINT index;
118 enum STATE_TYPE type;
119 D3DXHANDLE parameter;
122 struct d3dx_sampler
124 UINT state_count;
125 struct d3dx_state *states;
128 struct d3dx_pass
130 char *name;
131 UINT state_count;
132 UINT annotation_count;
134 struct d3dx_state *states;
135 D3DXHANDLE *annotation_handles;
138 struct d3dx_technique
140 char *name;
141 UINT pass_count;
142 UINT annotation_count;
144 D3DXHANDLE *annotation_handles;
145 D3DXHANDLE *pass_handles;
148 struct ID3DXBaseEffectImpl
150 ID3DXBaseEffect ID3DXBaseEffect_iface;
151 LONG ref;
153 struct ID3DXEffectImpl *effect;
155 UINT parameter_count;
156 UINT technique_count;
158 D3DXHANDLE *parameter_handles;
159 D3DXHANDLE *technique_handles;
162 struct ID3DXEffectImpl
164 ID3DXEffect ID3DXEffect_iface;
165 LONG ref;
167 LPD3DXEFFECTSTATEMANAGER manager;
168 LPDIRECT3DDEVICE9 device;
169 LPD3DXEFFECTPOOL pool;
170 D3DXHANDLE active_technique;
171 D3DXHANDLE active_pass;
173 ID3DXBaseEffect *base_effect;
176 struct ID3DXEffectCompilerImpl
178 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
179 LONG ref;
181 ID3DXBaseEffect *base_effect;
184 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
185 struct d3dx_parameter *parameter, LPCSTR name);
186 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
187 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
188 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
190 static const struct
192 enum STATE_CLASS class;
193 UINT op;
194 LPCSTR name;
196 state_table[] =
198 /* Render sates */
199 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
200 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
201 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
202 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
203 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
204 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
205 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
206 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
207 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
208 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
209 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
210 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
211 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
212 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
213 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
214 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
215 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
216 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
217 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
218 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
219 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
220 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
221 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
222 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
223 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
224 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
225 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
226 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
227 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
228 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
229 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
230 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
231 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
232 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
233 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
234 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
235 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
236 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
237 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
238 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
239 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
240 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
241 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
242 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
243 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
244 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
245 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
246 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
247 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
248 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
249 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
250 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
251 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
252 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
253 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
254 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
255 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
256 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
257 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
258 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
259 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
260 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
261 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
262 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
263 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
264 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
265 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
266 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
267 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
268 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
269 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
270 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
271 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
272 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
273 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
274 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
275 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
276 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
277 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
278 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
279 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
280 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
281 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
282 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
283 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
284 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
285 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
286 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
287 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
288 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
289 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
290 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
291 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
292 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
293 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
294 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
295 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
296 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
297 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
298 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
299 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
300 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
301 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
302 /* Texture stages */
303 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
304 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
305 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
306 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
307 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
308 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
309 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
310 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
311 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
312 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
313 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
314 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
315 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
316 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
317 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
318 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
319 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
320 /* */
321 {SC_UNKNOWN, 0, "UNKNOWN"},
322 /* NPatchMode */
323 {SC_NPATCHMODE, 0, "NPatchMode"},
324 /* */
325 {SC_UNKNOWN, 0, "UNKNOWN"},
326 /* Transform */
327 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
328 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
329 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
330 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
331 /* Material */
332 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
333 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
334 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
335 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
336 {SC_MATERIAL, MT_POWER, "MaterialPower"},
337 /* Light */
338 {SC_LIGHT, LT_TYPE, "LightType"},
339 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
340 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
341 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
342 {SC_LIGHT, LT_POSITION, "LightPosition"},
343 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
344 {SC_LIGHT, LT_RANGE, "LightRange"},
345 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
346 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
347 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
348 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
349 {SC_LIGHT, LT_THETA, "LightTheta"},
350 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
351 /* Ligthenable */
352 {SC_LIGHTENABLE, 0, "LightEnable"},
353 /* Vertexshader */
354 {SC_VERTEXSHADER, 0, "Vertexshader"},
355 /* Pixelshader */
356 {SC_PIXELSHADER, 0, "Pixelshader"},
357 /* Shader constants */
358 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
359 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
360 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
361 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
362 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
363 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
364 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
365 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
366 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
367 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
368 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
369 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
370 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
371 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
372 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
373 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
374 /* Texture */
375 {SC_TEXTURE, 0, "Texture"},
376 /* Sampler states */
377 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
378 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
379 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
380 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
381 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
382 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
383 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
384 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
385 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
386 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
387 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
388 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
389 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
390 /* Set sampler */
391 {SC_SETSAMPLER, 0, "Sampler"},
394 static inline void read_dword(const char **ptr, DWORD *d)
396 memcpy(d, *ptr, sizeof(*d));
397 *ptr += sizeof(*d);
400 static void skip_dword_unknown(const char **ptr, unsigned int count)
402 unsigned int i;
403 DWORD d;
405 FIXME("Skipping %u unknown DWORDs:\n", count);
406 for (i = 0; i < count; ++i)
408 read_dword(ptr, &d);
409 FIXME("\t0x%08x\n", d);
413 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
415 return (struct d3dx_parameter *) handle;
418 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
420 return (struct d3dx_pass *) handle;
423 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
425 return (struct d3dx_technique *) handle;
428 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
430 return (D3DXHANDLE) parameter;
433 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
435 return (D3DXHANDLE) technique;
438 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
440 return (D3DXHANDLE) pass;
443 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
445 unsigned int i;
447 for (i = 0; i < base->technique_count; ++i)
449 if (base->technique_handles[i] == technique)
451 return get_technique_struct(technique);
455 return NULL;
458 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
460 unsigned int i, k;
462 for (i = 0; i < base->technique_count; ++i)
464 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
466 for (k = 0; k < technique->pass_count; ++k)
468 if (technique->pass_handles[k] == pass)
470 return get_pass_struct(pass);
475 return NULL;
478 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
480 unsigned int i, count;
481 struct d3dx_parameter *p;
483 for (i = 0; i < param->annotation_count; ++i)
485 if (param->annotation_handles[i] == parameter)
487 return get_parameter_struct(parameter);
490 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
491 if (p) return p;
494 if (param->element_count) count = param->element_count;
495 else count = param->member_count;
497 for (i = 0; i < count; ++i)
499 if (param->member_handles[i] == parameter)
501 return get_parameter_struct(parameter);
504 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
505 if (p) return p;
508 return NULL;
511 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
513 unsigned int i, k, m;
514 struct d3dx_parameter *p;
516 for (i = 0; i < base->parameter_count; ++i)
518 if (base->parameter_handles[i] == parameter)
520 return get_parameter_struct(parameter);
523 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
524 if (p) return p;
527 for (i = 0; i < base->technique_count; ++i)
529 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
531 for (k = 0; k < technique->pass_count; ++k)
533 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
535 for (m = 0; m < pass->annotation_count; ++m)
537 if (pass->annotation_handles[i] == parameter)
539 return get_parameter_struct(parameter);
542 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
543 if (p) return p;
547 for (k = 0; k < technique->annotation_count; ++k)
549 if (technique->annotation_handles[k] == parameter)
551 return get_parameter_struct(parameter);
554 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
555 if (p) return p;
559 return NULL;
562 static void free_state(struct d3dx_state *state)
564 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
567 static void free_sampler(struct d3dx_sampler *sampler)
569 UINT i;
571 for (i = 0; i < sampler->state_count; ++i)
573 free_state(&sampler->states[i]);
575 HeapFree(GetProcessHeap(), 0, sampler->states);
578 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
580 free_parameter_state(handle, element, child, ST_CONSTANT);
583 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
585 unsigned int i;
586 struct d3dx_parameter *param = get_parameter_struct(handle);
588 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
589 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
591 if (!param)
593 return;
596 if (param->annotation_handles)
598 for (i = 0; i < param->annotation_count; ++i)
600 free_parameter(param->annotation_handles[i], FALSE, FALSE);
602 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
605 if (param->member_handles)
607 unsigned int count;
609 if (param->element_count) count = param->element_count;
610 else count = param->member_count;
612 for (i = 0; i < count; ++i)
614 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
616 HeapFree(GetProcessHeap(), 0, param->member_handles);
619 if (param->class == D3DXPC_OBJECT && !param->element_count)
621 switch (param->type)
623 case D3DXPT_STRING:
624 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
625 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
626 break;
628 case D3DXPT_TEXTURE:
629 case D3DXPT_TEXTURE1D:
630 case D3DXPT_TEXTURE2D:
631 case D3DXPT_TEXTURE3D:
632 case D3DXPT_TEXTURECUBE:
633 case D3DXPT_PIXELSHADER:
634 case D3DXPT_VERTEXSHADER:
635 if (st == ST_CONSTANT)
637 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
639 else
641 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
643 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
644 break;
646 case D3DXPT_SAMPLER:
647 case D3DXPT_SAMPLER1D:
648 case D3DXPT_SAMPLER2D:
649 case D3DXPT_SAMPLER3D:
650 case D3DXPT_SAMPLERCUBE:
651 if (st == ST_CONSTANT)
653 free_sampler((struct d3dx_sampler *)param->data);
655 else
657 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
659 /* samplers have always own data, so free that */
660 HeapFree(GetProcessHeap(), 0, param->data);
661 break;
663 default:
664 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
665 break;
668 else
670 if (!child)
672 if (st != ST_CONSTANT)
674 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
676 HeapFree(GetProcessHeap(), 0, param->data);
680 /* only the parent has to release name and semantic */
681 if (!element)
683 HeapFree(GetProcessHeap(), 0, param->name);
684 HeapFree(GetProcessHeap(), 0, param->semantic);
687 HeapFree(GetProcessHeap(), 0, param);
690 static void free_pass(D3DXHANDLE handle)
692 unsigned int i;
693 struct d3dx_pass *pass = get_pass_struct(handle);
695 TRACE("Free pass %p\n", pass);
697 if (!pass)
699 return;
702 if (pass->annotation_handles)
704 for (i = 0; i < pass->annotation_count; ++i)
706 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
708 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
711 if (pass->states)
713 for (i = 0; i < pass->state_count; ++i)
715 free_state(&pass->states[i]);
717 HeapFree(GetProcessHeap(), 0, pass->states);
720 HeapFree(GetProcessHeap(), 0, pass->name);
721 HeapFree(GetProcessHeap(), 0, pass);
724 static void free_technique(D3DXHANDLE handle)
726 unsigned int i;
727 struct d3dx_technique *technique = get_technique_struct(handle);
729 TRACE("Free technique %p\n", technique);
731 if (!technique)
733 return;
736 if (technique->annotation_handles)
738 for (i = 0; i < technique->annotation_count; ++i)
740 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
742 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
745 if (technique->pass_handles)
747 for (i = 0; i < technique->pass_count; ++i)
749 free_pass(technique->pass_handles[i]);
751 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
754 HeapFree(GetProcessHeap(), 0, technique->name);
755 HeapFree(GetProcessHeap(), 0, technique);
758 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
760 unsigned int i;
762 TRACE("Free base effect %p\n", base);
764 if (base->parameter_handles)
766 for (i = 0; i < base->parameter_count; ++i)
768 free_parameter(base->parameter_handles[i], FALSE, FALSE);
770 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
773 if (base->technique_handles)
775 for (i = 0; i < base->technique_count; ++i)
777 free_technique(base->technique_handles[i]);
779 HeapFree(GetProcessHeap(), 0, base->technique_handles);
783 static void free_effect(struct ID3DXEffectImpl *effect)
785 TRACE("Free effect %p\n", effect);
787 if (effect->base_effect)
789 effect->base_effect->lpVtbl->Release(effect->base_effect);
792 if (effect->pool)
794 effect->pool->lpVtbl->Release(effect->pool);
797 if (effect->manager)
799 IUnknown_Release(effect->manager);
802 IDirect3DDevice9_Release(effect->device);
805 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
807 TRACE("Free effect compiler %p\n", compiler);
809 if (compiler->base_effect)
811 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
815 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
817 INT i;
819 switch (type)
821 case D3DXPT_FLOAT:
822 i = *(FLOAT *)data;
823 break;
825 case D3DXPT_INT:
826 i = *(INT *)data;
827 break;
829 case D3DXPT_BOOL:
830 i = *(BOOL *)data;
831 break;
833 default:
834 i = 0;
835 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
836 break;
839 return i;
842 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
844 FLOAT f;
846 switch (type)
848 case D3DXPT_FLOAT:
849 f = *(FLOAT *)data;
850 break;
852 case D3DXPT_INT:
853 f = *(INT *)data;
854 break;
856 case D3DXPT_BOOL:
857 f = *(BOOL *)data;
858 break;
860 default:
861 f = 0.0f;
862 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
863 break;
866 return f;
869 static inline BOOL get_bool(void *data)
871 return (*(DWORD *)data) ? TRUE : FALSE;
874 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
876 UINT element;
877 struct d3dx_parameter *temp_parameter;
878 LPCSTR part;
880 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
882 if (!name || !*name) return parameter;
884 element = atoi(name);
885 part = strchr(name, ']') + 1;
887 if (parameter->element_count > element)
889 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
891 switch (*part++)
893 case '.':
894 return get_parameter_by_name(NULL, temp_parameter, part);
896 case '@':
897 return get_parameter_annotation_by_name(temp_parameter, part);
899 case '\0':
900 TRACE("Returning parameter %p\n", temp_parameter);
901 return temp_parameter;
903 default:
904 FIXME("Unhandled case \"%c\"\n", *--part);
905 break;
909 TRACE("Parameter not found\n");
910 return NULL;
913 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
915 UINT i, length;
916 struct d3dx_parameter *temp_parameter;
917 LPCSTR part;
919 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
921 if (!name || !*name) return parameter;
923 length = strcspn( name, "[.@" );
924 part = name + length;
926 for (i = 0; i < parameter->annotation_count; ++i)
928 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
930 if (!strcmp(temp_parameter->name, name))
932 TRACE("Returning parameter %p\n", temp_parameter);
933 return temp_parameter;
935 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
937 switch (*part++)
939 case '.':
940 return get_parameter_by_name(NULL, temp_parameter, part);
942 case '[':
943 return get_parameter_element_by_name(temp_parameter, part);
945 default:
946 FIXME("Unhandled case \"%c\"\n", *--part);
947 break;
952 TRACE("Parameter not found\n");
953 return NULL;
956 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
957 struct d3dx_parameter *parameter, LPCSTR name)
959 UINT i, count, length;
960 struct d3dx_parameter *temp_parameter;
961 D3DXHANDLE *handles;
962 LPCSTR part;
964 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
966 if (!name || !*name) return parameter;
968 if (!parameter)
970 count = base->parameter_count;
971 handles = base->parameter_handles;
973 else
975 count = parameter->member_count;
976 handles = parameter->member_handles;
979 length = strcspn( name, "[.@" );
980 part = name + length;
982 for (i = 0; i < count; i++)
984 temp_parameter = get_parameter_struct(handles[i]);
986 if (!strcmp(temp_parameter->name, name))
988 TRACE("Returning parameter %p\n", temp_parameter);
989 return temp_parameter;
991 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
993 switch (*part++)
995 case '.':
996 return get_parameter_by_name(NULL, temp_parameter, part);
998 case '@':
999 return get_parameter_annotation_by_name(temp_parameter, part);
1001 case '[':
1002 return get_parameter_element_by_name(temp_parameter, part);
1004 default:
1005 FIXME("Unhandled case \"%c\"\n", *--part);
1006 break;
1011 TRACE("Parameter not found\n");
1012 return NULL;
1015 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1017 return (0xfeff0000 | ((major) << 8) | (minor));
1020 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1022 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1025 /*** IUnknown methods ***/
1026 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1028 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1030 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1032 if (IsEqualGUID(riid, &IID_IUnknown) ||
1033 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1035 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1036 *object = This;
1037 return S_OK;
1040 ERR("Interface %s not found\n", debugstr_guid(riid));
1042 return E_NOINTERFACE;
1045 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1047 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1049 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1051 return InterlockedIncrement(&This->ref);
1054 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1056 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1057 ULONG ref = InterlockedDecrement(&This->ref);
1059 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1061 if (!ref)
1063 free_base_effect(This);
1064 HeapFree(GetProcessHeap(), 0, This);
1067 return ref;
1070 /*** ID3DXBaseEffect methods ***/
1071 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1073 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1075 FIXME("iface %p, desc %p partial stub\n", This, desc);
1077 if (!desc)
1079 WARN("Invalid argument specified.\n");
1080 return D3DERR_INVALIDCALL;
1083 /* Todo: add creator and function count */
1084 desc->Creator = NULL;
1085 desc->Functions = 0;
1086 desc->Parameters = This->parameter_count;
1087 desc->Techniques = This->technique_count;
1089 return D3D_OK;
1092 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1094 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1095 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1097 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1099 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
1101 if (!desc || !param)
1103 WARN("Invalid argument specified.\n");
1104 return D3DERR_INVALIDCALL;
1107 desc->Name = param->name;
1108 desc->Semantic = param->semantic;
1109 desc->Class = param->class;
1110 desc->Type = param->type;
1111 desc->Rows = param->rows;
1112 desc->Columns = param->columns;
1113 desc->Elements = param->element_count;
1114 desc->Annotations = param->annotation_count;
1115 desc->StructMembers = param->member_count;
1116 desc->Flags = param->flags;
1117 desc->Bytes = param->bytes;
1119 return D3D_OK;
1122 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1124 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1125 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1127 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1129 if (!desc || !tech)
1131 WARN("Invalid argument specified.\n");
1132 return D3DERR_INVALIDCALL;
1135 desc->Name = tech->name;
1136 desc->Passes = tech->pass_count;
1137 desc->Annotations = tech->annotation_count;
1139 return D3D_OK;
1142 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1144 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1145 struct d3dx_pass *p = is_valid_pass(This, pass);
1147 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1149 if (!desc || !p)
1151 WARN("Invalid argument specified.\n");
1152 return D3DERR_INVALIDCALL;
1155 desc->Name = p->name;
1156 desc->Annotations = p->annotation_count;
1158 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1159 desc->pVertexShaderFunction = NULL;
1160 desc->pPixelShaderFunction = NULL;
1162 return D3D_OK;
1165 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1167 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1169 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1171 return E_NOTIMPL;
1174 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1176 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1177 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1179 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1181 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1183 if (!parameter)
1185 if (index < This->parameter_count)
1187 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1188 return This->parameter_handles[index];
1191 else
1193 if (param && !param->element_count && index < param->member_count)
1195 TRACE("Returning parameter %p\n", param->member_handles[index]);
1196 return param->member_handles[index];
1200 WARN("Invalid argument specified.\n");
1202 return NULL;
1205 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1207 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1208 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1209 D3DXHANDLE handle;
1211 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1213 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1215 if (!name)
1217 handle = get_parameter_handle(param);
1218 TRACE("Returning parameter %p\n", handle);
1219 return handle;
1222 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1223 TRACE("Returning parameter %p\n", handle);
1225 return handle;
1228 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1230 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1231 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1232 struct d3dx_parameter *temp_param;
1233 UINT i;
1235 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1237 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1239 if (!parameter)
1241 for (i = 0; i < This->parameter_count; ++i)
1243 temp_param = get_parameter_struct(This->parameter_handles[i]);
1245 if (!temp_param->semantic)
1247 if (!semantic)
1249 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1250 return This->parameter_handles[i];
1252 continue;
1255 if (!strcasecmp(temp_param->semantic, semantic))
1257 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1258 return This->parameter_handles[i];
1262 else if (param)
1264 for (i = 0; i < param->member_count; ++i)
1266 temp_param = get_parameter_struct(param->member_handles[i]);
1268 if (!temp_param->semantic)
1270 if (!semantic)
1272 TRACE("Returning parameter %p\n", param->member_handles[i]);
1273 return param->member_handles[i];
1275 continue;
1278 if (!strcasecmp(temp_param->semantic, semantic))
1280 TRACE("Returning parameter %p\n", param->member_handles[i]);
1281 return param->member_handles[i];
1286 WARN("Invalid argument specified\n");
1288 return NULL;
1291 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1293 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1294 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1296 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1298 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1300 if (!param)
1302 if (index < This->parameter_count)
1304 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1305 return This->parameter_handles[index];
1308 else
1310 if (index < param->element_count)
1312 TRACE("Returning parameter %p\n", param->member_handles[index]);
1313 return param->member_handles[index];
1317 WARN("Invalid argument specified\n");
1319 return NULL;
1322 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1324 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1326 TRACE("iface %p, index %u\n", This, index);
1328 if (index >= This->technique_count)
1330 WARN("Invalid argument specified.\n");
1331 return NULL;
1334 TRACE("Returning technique %p\n", This->technique_handles[index]);
1336 return This->technique_handles[index];
1339 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1341 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1342 unsigned int i;
1344 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1346 if (!name)
1348 WARN("Invalid argument specified.\n");
1349 return NULL;
1352 for (i = 0; i < This->technique_count; ++i)
1354 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1356 if (!strcmp(tech->name, name))
1358 TRACE("Returning technique %p\n", This->technique_handles[i]);
1359 return This->technique_handles[i];
1363 WARN("Invalid argument specified.\n");
1365 return NULL;
1368 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1370 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1371 struct d3dx_technique *tech = is_valid_technique(This, technique);
1373 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1375 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1377 if (tech && index < tech->pass_count)
1379 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1380 return tech->pass_handles[index];
1383 WARN("Invalid argument specified.\n");
1385 return NULL;
1388 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1390 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1391 struct d3dx_technique *tech = is_valid_technique(This, technique);
1393 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1395 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1397 if (tech && name)
1399 unsigned int i;
1401 for (i = 0; i < tech->pass_count; ++i)
1403 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1405 if (!strcmp(pass->name, name))
1407 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1408 return tech->pass_handles[i];
1413 WARN("Invalid argument specified.\n");
1415 return NULL;
1418 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1420 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1422 FIXME("iface %p, index %u stub\n", This, index);
1424 return NULL;
1427 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1429 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1431 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1433 return NULL;
1436 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1438 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1439 struct d3dx_parameter *param = is_valid_parameter(This, object);
1440 struct d3dx_pass *pass = is_valid_pass(This, object);
1441 struct d3dx_technique *technique = is_valid_technique(This, object);
1442 UINT annotation_count = 0;
1443 D3DXHANDLE *annotation_handles = NULL;
1445 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1447 if (pass)
1449 annotation_count = pass->annotation_count;
1450 annotation_handles = pass->annotation_handles;
1452 else if (technique)
1454 annotation_count = technique->annotation_count;
1455 annotation_handles = technique->annotation_handles;
1457 else
1459 if (!param) param = get_parameter_by_name(This, NULL, object);
1461 if (param)
1463 annotation_count = param->annotation_count;
1464 annotation_handles = param->annotation_handles;
1467 /* Todo: add funcs */
1469 if (index < annotation_count)
1471 TRACE("Returning parameter %p\n", annotation_handles[index]);
1472 return annotation_handles[index];
1475 WARN("Invalid argument specified\n");
1477 return NULL;
1480 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1482 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1483 struct d3dx_parameter *param = is_valid_parameter(This, object);
1484 struct d3dx_pass *pass = is_valid_pass(This, object);
1485 struct d3dx_technique *technique = is_valid_technique(This, object);
1486 UINT annotation_count = 0, i;
1487 D3DXHANDLE *annotation_handles = NULL;
1489 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1491 if (!name)
1493 WARN("Invalid argument specified\n");
1494 return NULL;
1497 if (pass)
1499 annotation_count = pass->annotation_count;
1500 annotation_handles = pass->annotation_handles;
1502 else if (technique)
1504 annotation_count = technique->annotation_count;
1505 annotation_handles = technique->annotation_handles;
1507 else
1509 if (!param) param = get_parameter_by_name(This, NULL, object);
1511 if (param)
1513 annotation_count = param->annotation_count;
1514 annotation_handles = param->annotation_handles;
1517 /* Todo: add funcs */
1519 for (i = 0; i < annotation_count; i++)
1521 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1523 if (!strcmp(anno->name, name))
1525 TRACE("Returning parameter %p\n", anno);
1526 return get_parameter_handle(anno);
1530 WARN("Invalid argument specified\n");
1532 return NULL;
1535 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1537 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1539 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1541 return E_NOTIMPL;
1544 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1546 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1547 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1549 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1551 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1552 if (!param)
1554 WARN("Invalid parameter %p specified\n", parameter);
1555 return D3DERR_INVALIDCALL;
1558 /* samplers don't touch data */
1559 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1560 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1561 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1563 TRACE("Sampler: returning E_FAIL\n");
1564 return E_FAIL;
1567 if (data && param->bytes <= bytes)
1569 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1571 switch (param->type)
1573 case D3DXPT_VOID:
1574 case D3DXPT_BOOL:
1575 case D3DXPT_INT:
1576 case D3DXPT_FLOAT:
1577 case D3DXPT_STRING:
1578 break;
1580 case D3DXPT_VERTEXSHADER:
1581 case D3DXPT_PIXELSHADER:
1582 case D3DXPT_TEXTURE:
1583 case D3DXPT_TEXTURE1D:
1584 case D3DXPT_TEXTURE2D:
1585 case D3DXPT_TEXTURE3D:
1586 case D3DXPT_TEXTURECUBE:
1588 UINT i;
1590 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1592 IUnknown *unk = ((IUnknown **)param->data)[i];
1593 if (unk) IUnknown_AddRef(unk);
1595 break;
1598 default:
1599 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1600 break;
1603 TRACE("Copy %u bytes\n", param->bytes);
1604 memcpy(data, param->data, param->bytes);
1605 return D3D_OK;
1608 WARN("Invalid argument specified\n");
1610 return D3DERR_INVALIDCALL;
1613 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1615 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1617 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1619 return E_NOTIMPL;
1622 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1624 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1625 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1627 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1629 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1631 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1633 *b = get_bool(param->data);
1634 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1635 return D3D_OK;
1638 WARN("Invalid argument specified\n");
1640 return D3DERR_INVALIDCALL;
1643 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1645 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1647 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1649 return E_NOTIMPL;
1652 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1654 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1655 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1657 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1659 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1661 if (b && param && (param->class == D3DXPC_SCALAR
1662 || param->class == D3DXPC_VECTOR
1663 || param->class == D3DXPC_MATRIX_ROWS
1664 || param->class == D3DXPC_MATRIX_COLUMNS))
1666 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1668 for (i = 0; i < size; ++i)
1670 b[i] = get_bool((DWORD *)param->data + i);
1672 return D3D_OK;
1675 WARN("Invalid argument specified\n");
1677 return D3DERR_INVALIDCALL;
1680 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1682 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1684 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1686 return E_NOTIMPL;
1689 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1691 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1692 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1694 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1696 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1698 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1700 *n = get_int(param->type, param->data);
1701 TRACE("Returning %i\n", *n);
1702 return D3D_OK;
1705 WARN("Invalid argument specified\n");
1707 return D3DERR_INVALIDCALL;
1710 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1712 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1714 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1716 return E_NOTIMPL;
1719 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1721 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1722 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1724 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1726 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1728 if (n && param && (param->class == D3DXPC_SCALAR
1729 || param->class == D3DXPC_VECTOR
1730 || param->class == D3DXPC_MATRIX_ROWS
1731 || param->class == D3DXPC_MATRIX_COLUMNS))
1733 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1735 for (i = 0; i < size; ++i)
1737 n[i] = get_int(param->type, (DWORD *)param->data + i);
1739 return D3D_OK;
1742 WARN("Invalid argument specified\n");
1744 return D3DERR_INVALIDCALL;
1747 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1749 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1751 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1753 return E_NOTIMPL;
1756 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1758 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1759 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1761 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1763 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1765 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1767 f = param->data;
1768 TRACE("Returning %f\n", *f);
1769 return D3D_OK;
1772 WARN("Invalid argument specified\n");
1774 return D3DERR_INVALIDCALL;
1777 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1779 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1781 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1783 return E_NOTIMPL;
1786 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1788 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1789 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1791 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1793 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1795 if (f && param && (param->class == D3DXPC_SCALAR
1796 || param->class == D3DXPC_VECTOR
1797 || param->class == D3DXPC_MATRIX_ROWS
1798 || param->class == D3DXPC_MATRIX_COLUMNS))
1800 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1802 for (i = 0; i < size; ++i)
1804 f[i] = get_float(param->type, (DWORD *)param->data + i);
1806 return D3D_OK;
1809 WARN("Invalid argument specified\n");
1811 return D3DERR_INVALIDCALL;
1814 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1816 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1818 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1820 return E_NOTIMPL;
1823 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1825 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1827 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1829 return E_NOTIMPL;
1832 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1834 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1836 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1838 return E_NOTIMPL;
1841 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1843 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1845 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1847 return E_NOTIMPL;
1850 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1852 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1854 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1856 return E_NOTIMPL;
1859 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1861 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1863 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1865 return E_NOTIMPL;
1868 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1870 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1872 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1874 return E_NOTIMPL;
1877 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1879 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1881 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1883 return E_NOTIMPL;
1886 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1888 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1890 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1892 return E_NOTIMPL;
1895 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1897 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1899 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1901 return E_NOTIMPL;
1904 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1906 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1908 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1910 return E_NOTIMPL;
1913 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1915 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1917 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1919 return E_NOTIMPL;
1922 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1924 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1926 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1928 return E_NOTIMPL;
1931 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1933 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1935 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1937 return E_NOTIMPL;
1940 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1942 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1944 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1946 return E_NOTIMPL;
1949 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1951 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1953 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1955 return E_NOTIMPL;
1958 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1960 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1962 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1964 return E_NOTIMPL;
1967 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1969 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1970 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1972 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1974 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1976 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1978 *string = *(LPCSTR *)param->data;
1979 TRACE("Returning %s\n", debugstr_a(*string));
1980 return D3D_OK;
1983 WARN("Invalid argument specified\n");
1985 return D3DERR_INVALIDCALL;
1988 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1990 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1991 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1993 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
1995 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1997 if (texture && param && !param->element_count &&
1998 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
1999 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2000 || param->type == D3DXPT_TEXTURECUBE))
2002 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2004 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2005 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2007 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2009 return D3D_OK;
2012 WARN("Invalid argument specified\n");
2014 return D3DERR_INVALIDCALL;
2017 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2019 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2020 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2022 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2024 if (texture && param && !param->element_count &&
2025 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2026 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2027 || param->type == D3DXPT_TEXTURECUBE))
2029 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2030 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2031 TRACE("Returning %p\n", *texture);
2032 return D3D_OK;
2035 WARN("Invalid argument specified\n");
2037 return D3DERR_INVALIDCALL;
2040 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2042 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2043 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2045 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2047 if (!param) param = get_parameter_by_name(This, NULL, parameter);
2049 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2051 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2052 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2053 TRACE("Returning %p\n", *pshader);
2054 return D3D_OK;
2057 WARN("Invalid argument specified\n");
2059 return D3DERR_INVALIDCALL;
2062 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2064 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2065 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2067 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2069 if (!param) param = get_parameter_by_name(This, NULL, parameter);
2071 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2073 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2074 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2075 TRACE("Returning %p\n", *vshader);
2076 return D3D_OK;
2079 WARN("Invalid argument specified\n");
2081 return D3DERR_INVALIDCALL;
2084 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2086 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2088 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2090 return E_NOTIMPL;
2093 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2095 /*** IUnknown methods ***/
2096 ID3DXBaseEffectImpl_QueryInterface,
2097 ID3DXBaseEffectImpl_AddRef,
2098 ID3DXBaseEffectImpl_Release,
2099 /*** ID3DXBaseEffect methods ***/
2100 ID3DXBaseEffectImpl_GetDesc,
2101 ID3DXBaseEffectImpl_GetParameterDesc,
2102 ID3DXBaseEffectImpl_GetTechniqueDesc,
2103 ID3DXBaseEffectImpl_GetPassDesc,
2104 ID3DXBaseEffectImpl_GetFunctionDesc,
2105 ID3DXBaseEffectImpl_GetParameter,
2106 ID3DXBaseEffectImpl_GetParameterByName,
2107 ID3DXBaseEffectImpl_GetParameterBySemantic,
2108 ID3DXBaseEffectImpl_GetParameterElement,
2109 ID3DXBaseEffectImpl_GetTechnique,
2110 ID3DXBaseEffectImpl_GetTechniqueByName,
2111 ID3DXBaseEffectImpl_GetPass,
2112 ID3DXBaseEffectImpl_GetPassByName,
2113 ID3DXBaseEffectImpl_GetFunction,
2114 ID3DXBaseEffectImpl_GetFunctionByName,
2115 ID3DXBaseEffectImpl_GetAnnotation,
2116 ID3DXBaseEffectImpl_GetAnnotationByName,
2117 ID3DXBaseEffectImpl_SetValue,
2118 ID3DXBaseEffectImpl_GetValue,
2119 ID3DXBaseEffectImpl_SetBool,
2120 ID3DXBaseEffectImpl_GetBool,
2121 ID3DXBaseEffectImpl_SetBoolArray,
2122 ID3DXBaseEffectImpl_GetBoolArray,
2123 ID3DXBaseEffectImpl_SetInt,
2124 ID3DXBaseEffectImpl_GetInt,
2125 ID3DXBaseEffectImpl_SetIntArray,
2126 ID3DXBaseEffectImpl_GetIntArray,
2127 ID3DXBaseEffectImpl_SetFloat,
2128 ID3DXBaseEffectImpl_GetFloat,
2129 ID3DXBaseEffectImpl_SetFloatArray,
2130 ID3DXBaseEffectImpl_GetFloatArray,
2131 ID3DXBaseEffectImpl_SetVector,
2132 ID3DXBaseEffectImpl_GetVector,
2133 ID3DXBaseEffectImpl_SetVectorArray,
2134 ID3DXBaseEffectImpl_GetVectorArray,
2135 ID3DXBaseEffectImpl_SetMatrix,
2136 ID3DXBaseEffectImpl_GetMatrix,
2137 ID3DXBaseEffectImpl_SetMatrixArray,
2138 ID3DXBaseEffectImpl_GetMatrixArray,
2139 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2140 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2141 ID3DXBaseEffectImpl_SetMatrixTranspose,
2142 ID3DXBaseEffectImpl_GetMatrixTranspose,
2143 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2144 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2145 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2146 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2147 ID3DXBaseEffectImpl_SetString,
2148 ID3DXBaseEffectImpl_GetString,
2149 ID3DXBaseEffectImpl_SetTexture,
2150 ID3DXBaseEffectImpl_GetTexture,
2151 ID3DXBaseEffectImpl_GetPixelShader,
2152 ID3DXBaseEffectImpl_GetVertexShader,
2153 ID3DXBaseEffectImpl_SetArrayRange,
2156 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2158 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2161 /*** IUnknown methods ***/
2162 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2164 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2166 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2168 if (IsEqualGUID(riid, &IID_IUnknown) ||
2169 IsEqualGUID(riid, &IID_ID3DXEffect))
2171 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2172 *object = This;
2173 return S_OK;
2176 ERR("Interface %s not found\n", debugstr_guid(riid));
2178 return E_NOINTERFACE;
2181 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2183 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2185 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2187 return InterlockedIncrement(&This->ref);
2190 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2192 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2193 ULONG ref = InterlockedDecrement(&This->ref);
2195 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2197 if (!ref)
2199 free_effect(This);
2200 HeapFree(GetProcessHeap(), 0, This);
2203 return ref;
2206 /*** ID3DXBaseEffect methods ***/
2207 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2209 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2210 ID3DXBaseEffect *base = This->base_effect;
2212 TRACE("Forward iface %p, base %p\n", This, base);
2214 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2217 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2219 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2220 ID3DXBaseEffect *base = This->base_effect;
2222 TRACE("Forward iface %p, base %p\n", This, base);
2224 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2227 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2229 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2230 ID3DXBaseEffect *base = This->base_effect;
2232 TRACE("Forward iface %p, base %p\n", This, base);
2234 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2237 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2239 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2240 ID3DXBaseEffect *base = This->base_effect;
2242 TRACE("Forward iface %p, base %p\n", This, base);
2244 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2247 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2249 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2250 ID3DXBaseEffect *base = This->base_effect;
2252 TRACE("Forward iface %p, base %p\n", This, base);
2254 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2257 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2259 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2260 ID3DXBaseEffect *base = This->base_effect;
2262 TRACE("Forward iface %p, base %p\n", This, base);
2264 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2267 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2269 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2270 ID3DXBaseEffect *base = This->base_effect;
2272 TRACE("Forward iface %p, base %p\n", This, base);
2274 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2277 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2279 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2280 ID3DXBaseEffect *base = This->base_effect;
2282 TRACE("Forward iface %p, base %p\n", This, base);
2284 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2287 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2289 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2290 ID3DXBaseEffect *base = This->base_effect;
2292 TRACE("Forward iface %p, base %p\n", This, base);
2294 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2297 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2299 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2300 ID3DXBaseEffect *base = This->base_effect;
2302 TRACE("Forward iface %p, base %p\n", This, base);
2304 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2307 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2309 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2310 ID3DXBaseEffect *base = This->base_effect;
2312 TRACE("Forward iface %p, base %p\n", This, base);
2314 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2317 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2319 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2320 ID3DXBaseEffect *base = This->base_effect;
2322 TRACE("Forward iface %p, base %p\n", This, base);
2324 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2327 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2329 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2330 ID3DXBaseEffect *base = This->base_effect;
2332 TRACE("Forward iface %p, base %p\n", This, base);
2334 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2337 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2339 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2340 ID3DXBaseEffect *base = This->base_effect;
2342 TRACE("Forward iface %p, base %p\n", This, base);
2344 return ID3DXBaseEffectImpl_GetFunction(base, index);
2347 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2349 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2350 ID3DXBaseEffect *base = This->base_effect;
2352 TRACE("Forward iface %p, base %p\n", This, base);
2354 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2357 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2359 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2360 ID3DXBaseEffect *base = This->base_effect;
2362 TRACE("Forward iface %p, base %p\n", This, base);
2364 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2367 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2369 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2370 ID3DXBaseEffect *base = This->base_effect;
2372 TRACE("Forward iface %p, base %p\n", This, base);
2374 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2377 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2379 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2380 ID3DXBaseEffect *base = This->base_effect;
2382 TRACE("Forward iface %p, base %p\n", This, base);
2384 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2387 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2389 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2390 ID3DXBaseEffect *base = This->base_effect;
2392 TRACE("Forward iface %p, base %p\n", This, base);
2394 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2397 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2399 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2400 ID3DXBaseEffect *base = This->base_effect;
2402 TRACE("Forward iface %p, base %p\n", This, base);
2404 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2407 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2409 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2410 ID3DXBaseEffect *base = This->base_effect;
2412 TRACE("Forward iface %p, base %p\n", This, base);
2414 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2417 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2419 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2420 ID3DXBaseEffect *base = This->base_effect;
2422 TRACE("Forward iface %p, base %p\n", This, base);
2424 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2427 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2429 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2430 ID3DXBaseEffect *base = This->base_effect;
2432 TRACE("Forward iface %p, base %p\n", This, base);
2434 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2437 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2439 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2440 ID3DXBaseEffect *base = This->base_effect;
2442 TRACE("Forward iface %p, base %p\n", This, base);
2444 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2447 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2449 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2450 ID3DXBaseEffect *base = This->base_effect;
2452 TRACE("Forward iface %p, base %p\n", This, base);
2454 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2457 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2459 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2460 ID3DXBaseEffect *base = This->base_effect;
2462 TRACE("Forward iface %p, base %p\n", This, base);
2464 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2467 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2469 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2470 ID3DXBaseEffect *base = This->base_effect;
2472 TRACE("Forward iface %p, base %p\n", This, base);
2474 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2477 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2479 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2480 ID3DXBaseEffect *base = This->base_effect;
2482 TRACE("Forward iface %p, base %p\n", This, base);
2484 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2487 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2489 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2490 ID3DXBaseEffect *base = This->base_effect;
2492 TRACE("Forward iface %p, base %p\n", This, base);
2494 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2497 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2499 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2500 ID3DXBaseEffect *base = This->base_effect;
2502 TRACE("Forward iface %p, base %p\n", This, base);
2504 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2507 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2509 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2510 ID3DXBaseEffect *base = This->base_effect;
2512 TRACE("Forward iface %p, base %p\n", This, base);
2514 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2517 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2519 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2520 ID3DXBaseEffect *base = This->base_effect;
2522 TRACE("Forward iface %p, base %p\n", This, base);
2524 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2527 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2529 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2530 ID3DXBaseEffect *base = This->base_effect;
2532 TRACE("Forward iface %p, base %p\n", This, base);
2534 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2537 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2539 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2540 ID3DXBaseEffect *base = This->base_effect;
2542 TRACE("Forward iface %p, base %p\n", This, base);
2544 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2547 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2549 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2550 ID3DXBaseEffect *base = This->base_effect;
2552 TRACE("Forward iface %p, base %p\n", This, base);
2554 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2557 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2559 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2560 ID3DXBaseEffect *base = This->base_effect;
2562 TRACE("Forward iface %p, base %p\n", This, base);
2564 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2567 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2569 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2570 ID3DXBaseEffect *base = This->base_effect;
2572 TRACE("Forward iface %p, base %p\n", This, base);
2574 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2577 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2579 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2580 ID3DXBaseEffect *base = This->base_effect;
2582 TRACE("Forward iface %p, base %p\n", This, base);
2584 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2587 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2589 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2590 ID3DXBaseEffect *base = This->base_effect;
2592 TRACE("Forward iface %p, base %p\n", This, base);
2594 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2597 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2599 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2600 ID3DXBaseEffect *base = This->base_effect;
2602 TRACE("Forward iface %p, base %p\n", This, base);
2604 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2607 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2609 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2610 ID3DXBaseEffect *base = This->base_effect;
2612 TRACE("Forward iface %p, base %p\n", This, base);
2614 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2617 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2619 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2620 ID3DXBaseEffect *base = This->base_effect;
2622 TRACE("Forward iface %p, base %p\n", This, base);
2624 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2627 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2629 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2630 ID3DXBaseEffect *base = This->base_effect;
2632 TRACE("Forward iface %p, base %p\n", This, base);
2634 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2637 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2639 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2640 ID3DXBaseEffect *base = This->base_effect;
2642 TRACE("Forward iface %p, base %p\n", This, base);
2644 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2647 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2649 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2650 ID3DXBaseEffect *base = This->base_effect;
2652 TRACE("Forward iface %p, base %p\n", This, base);
2654 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2657 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2659 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2660 ID3DXBaseEffect *base = This->base_effect;
2662 TRACE("Forward iface %p, base %p\n", This, base);
2664 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2667 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2669 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2670 ID3DXBaseEffect *base = This->base_effect;
2672 TRACE("Forward iface %p, base %p\n", This, base);
2674 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2677 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2679 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2680 ID3DXBaseEffect *base = This->base_effect;
2682 TRACE("Forward iface %p, base %p\n", This, base);
2684 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2687 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2689 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2690 ID3DXBaseEffect *base = This->base_effect;
2692 TRACE("Forward iface %p, base %p\n", This, base);
2694 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2697 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2699 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2700 ID3DXBaseEffect *base = This->base_effect;
2702 TRACE("Forward iface %p, base %p\n", This, base);
2704 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2707 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2709 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2710 ID3DXBaseEffect *base = This->base_effect;
2712 TRACE("Forward iface %p, base %p\n", This, base);
2714 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2717 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2719 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2720 ID3DXBaseEffect *base = This->base_effect;
2722 TRACE("Forward iface %p, base %p\n", This, base);
2724 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2727 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2729 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2730 ID3DXBaseEffect *base = This->base_effect;
2732 TRACE("Forward iface %p, base %p\n", This, base);
2734 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2737 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2739 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2740 ID3DXBaseEffect *base = This->base_effect;
2742 TRACE("Forward iface %p, base %p\n", This, base);
2744 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2747 /*** ID3DXEffect methods ***/
2748 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2750 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2752 TRACE("iface %p, pool %p\n", This, pool);
2754 if (!pool)
2756 WARN("Invalid argument supplied.\n");
2757 return D3DERR_INVALIDCALL;
2760 if (This->pool)
2762 This->pool->lpVtbl->AddRef(This->pool);
2765 *pool = This->pool;
2767 TRACE("Returning pool %p\n", *pool);
2769 return S_OK;
2772 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
2774 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2775 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
2776 struct d3dx_technique *tech = is_valid_technique(base, technique);
2778 TRACE("iface %p, technique %p\n", This, technique);
2780 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
2782 if (tech)
2784 UINT i;
2786 for (i = 0; i < base->technique_count; ++i)
2788 struct d3dx_technique *t = get_technique_struct(base->technique_handles[i]);
2790 if (tech == t)
2792 This->active_technique = get_technique_handle(t);
2793 TRACE("Technique %u (%p)\n", i, tech);
2794 return D3D_OK;
2799 WARN("Invalid argument supplied.\n");
2801 return D3DERR_INVALIDCALL;
2804 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
2806 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2808 TRACE("iface %p\n", This);
2810 return This->active_technique;
2813 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2815 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2817 FIXME("(%p)->(%p): stub\n", This, technique);
2819 return D3D_OK;
2822 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2824 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2826 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2828 return E_NOTIMPL;
2831 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2833 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2835 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2837 return FALSE;
2840 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
2842 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2843 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2845 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
2847 if (passes && technique)
2849 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
2851 TRACE("State capturing disabled.\n");
2853 else
2855 FIXME("State capturing not supported, yet!\n");
2858 *passes = technique->pass_count;
2860 return D3D_OK;
2863 WARN("Invalid argument supplied.\n");
2865 return D3DERR_INVALIDCALL;
2868 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
2870 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2871 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2873 TRACE("iface %p, pass %u\n", This, pass);
2875 if (technique && pass < technique->pass_count && !This->active_pass)
2877 This->active_pass = technique->pass_handles[pass];
2879 FIXME("No states applied, yet!\n");
2881 return D3D_OK;
2884 WARN("Invalid argument supplied.\n");
2886 return D3DERR_INVALIDCALL;
2889 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2891 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2893 FIXME("(%p)->(): stub\n", This);
2895 return E_NOTIMPL;
2898 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
2900 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2902 TRACE("iface %p\n", This);
2904 if (This->active_pass)
2906 This->active_pass = NULL;
2907 return D3D_OK;
2910 WARN("Invalid call.\n");
2912 return D3DERR_INVALIDCALL;
2915 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2917 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2919 FIXME("(%p)->(): stub\n", This);
2921 return E_NOTIMPL;
2924 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2926 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2928 TRACE("iface %p, device %p\n", This, device);
2930 if (!device)
2932 WARN("Invalid argument supplied.\n");
2933 return D3DERR_INVALIDCALL;
2936 IDirect3DDevice9_AddRef(This->device);
2938 *device = This->device;
2940 TRACE("Returning device %p\n", *device);
2942 return S_OK;
2945 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2947 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2949 FIXME("(%p)->(): stub\n", This);
2951 return E_NOTIMPL;
2954 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2956 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2958 FIXME("(%p)->(): stub\n", This);
2960 return E_NOTIMPL;
2963 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2965 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2967 TRACE("iface %p, manager %p\n", This, manager);
2969 if (manager) IUnknown_AddRef(manager);
2970 if (This->manager) IUnknown_Release(This->manager);
2972 This->manager = manager;
2974 return D3D_OK;
2977 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2979 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2981 TRACE("iface %p, manager %p\n", This, manager);
2983 if (!manager)
2985 WARN("Invalid argument supplied.\n");
2986 return D3DERR_INVALIDCALL;
2989 if (This->manager) IUnknown_AddRef(This->manager);
2990 *manager = This->manager;
2992 return D3D_OK;
2995 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2997 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2999 FIXME("(%p)->(): stub\n", This);
3001 return E_NOTIMPL;
3004 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3006 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3008 FIXME("(%p)->(): stub\n", This);
3010 return NULL;
3013 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3015 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3017 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3019 return E_NOTIMPL;
3022 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3024 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3026 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3028 return E_NOTIMPL;
3031 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3033 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3035 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3037 return E_NOTIMPL;
3040 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3042 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3044 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3046 return E_NOTIMPL;
3049 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3051 /*** IUnknown methods ***/
3052 ID3DXEffectImpl_QueryInterface,
3053 ID3DXEffectImpl_AddRef,
3054 ID3DXEffectImpl_Release,
3055 /*** ID3DXBaseEffect methods ***/
3056 ID3DXEffectImpl_GetDesc,
3057 ID3DXEffectImpl_GetParameterDesc,
3058 ID3DXEffectImpl_GetTechniqueDesc,
3059 ID3DXEffectImpl_GetPassDesc,
3060 ID3DXEffectImpl_GetFunctionDesc,
3061 ID3DXEffectImpl_GetParameter,
3062 ID3DXEffectImpl_GetParameterByName,
3063 ID3DXEffectImpl_GetParameterBySemantic,
3064 ID3DXEffectImpl_GetParameterElement,
3065 ID3DXEffectImpl_GetTechnique,
3066 ID3DXEffectImpl_GetTechniqueByName,
3067 ID3DXEffectImpl_GetPass,
3068 ID3DXEffectImpl_GetPassByName,
3069 ID3DXEffectImpl_GetFunction,
3070 ID3DXEffectImpl_GetFunctionByName,
3071 ID3DXEffectImpl_GetAnnotation,
3072 ID3DXEffectImpl_GetAnnotationByName,
3073 ID3DXEffectImpl_SetValue,
3074 ID3DXEffectImpl_GetValue,
3075 ID3DXEffectImpl_SetBool,
3076 ID3DXEffectImpl_GetBool,
3077 ID3DXEffectImpl_SetBoolArray,
3078 ID3DXEffectImpl_GetBoolArray,
3079 ID3DXEffectImpl_SetInt,
3080 ID3DXEffectImpl_GetInt,
3081 ID3DXEffectImpl_SetIntArray,
3082 ID3DXEffectImpl_GetIntArray,
3083 ID3DXEffectImpl_SetFloat,
3084 ID3DXEffectImpl_GetFloat,
3085 ID3DXEffectImpl_SetFloatArray,
3086 ID3DXEffectImpl_GetFloatArray,
3087 ID3DXEffectImpl_SetVector,
3088 ID3DXEffectImpl_GetVector,
3089 ID3DXEffectImpl_SetVectorArray,
3090 ID3DXEffectImpl_GetVectorArray,
3091 ID3DXEffectImpl_SetMatrix,
3092 ID3DXEffectImpl_GetMatrix,
3093 ID3DXEffectImpl_SetMatrixArray,
3094 ID3DXEffectImpl_GetMatrixArray,
3095 ID3DXEffectImpl_SetMatrixPointerArray,
3096 ID3DXEffectImpl_GetMatrixPointerArray,
3097 ID3DXEffectImpl_SetMatrixTranspose,
3098 ID3DXEffectImpl_GetMatrixTranspose,
3099 ID3DXEffectImpl_SetMatrixTransposeArray,
3100 ID3DXEffectImpl_GetMatrixTransposeArray,
3101 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3102 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3103 ID3DXEffectImpl_SetString,
3104 ID3DXEffectImpl_GetString,
3105 ID3DXEffectImpl_SetTexture,
3106 ID3DXEffectImpl_GetTexture,
3107 ID3DXEffectImpl_GetPixelShader,
3108 ID3DXEffectImpl_GetVertexShader,
3109 ID3DXEffectImpl_SetArrayRange,
3110 /*** ID3DXEffect methods ***/
3111 ID3DXEffectImpl_GetPool,
3112 ID3DXEffectImpl_SetTechnique,
3113 ID3DXEffectImpl_GetCurrentTechnique,
3114 ID3DXEffectImpl_ValidateTechnique,
3115 ID3DXEffectImpl_FindNextValidTechnique,
3116 ID3DXEffectImpl_IsParameterUsed,
3117 ID3DXEffectImpl_Begin,
3118 ID3DXEffectImpl_BeginPass,
3119 ID3DXEffectImpl_CommitChanges,
3120 ID3DXEffectImpl_EndPass,
3121 ID3DXEffectImpl_End,
3122 ID3DXEffectImpl_GetDevice,
3123 ID3DXEffectImpl_OnLostDevice,
3124 ID3DXEffectImpl_OnResetDevice,
3125 ID3DXEffectImpl_SetStateManager,
3126 ID3DXEffectImpl_GetStateManager,
3127 ID3DXEffectImpl_BeginParameterBlock,
3128 ID3DXEffectImpl_EndParameterBlock,
3129 ID3DXEffectImpl_ApplyParameterBlock,
3130 ID3DXEffectImpl_DeleteParameterBlock,
3131 ID3DXEffectImpl_CloneEffect,
3132 ID3DXEffectImpl_SetRawValue
3135 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3137 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3140 /*** IUnknown methods ***/
3141 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3143 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3145 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3147 if (IsEqualGUID(riid, &IID_IUnknown) ||
3148 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3150 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3151 *object = This;
3152 return S_OK;
3155 ERR("Interface %s not found\n", debugstr_guid(riid));
3157 return E_NOINTERFACE;
3160 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3162 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3164 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3166 return InterlockedIncrement(&This->ref);
3169 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3171 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3172 ULONG ref = InterlockedDecrement(&This->ref);
3174 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3176 if (!ref)
3178 free_effect_compiler(This);
3179 HeapFree(GetProcessHeap(), 0, This);
3182 return ref;
3185 /*** ID3DXBaseEffect methods ***/
3186 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3188 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3189 ID3DXBaseEffect *base = This->base_effect;
3191 TRACE("Forward iface %p, base %p\n", This, base);
3193 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3196 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3198 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3199 ID3DXBaseEffect *base = This->base_effect;
3201 TRACE("Forward iface %p, base %p\n", This, base);
3203 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3206 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3208 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3209 ID3DXBaseEffect *base = This->base_effect;
3211 TRACE("Forward iface %p, base %p\n", This, base);
3213 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3216 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3218 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3219 ID3DXBaseEffect *base = This->base_effect;
3221 TRACE("Forward iface %p, base %p\n", This, base);
3223 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3226 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3228 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3229 ID3DXBaseEffect *base = This->base_effect;
3231 TRACE("Forward iface %p, base %p\n", This, base);
3233 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3236 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3238 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3239 ID3DXBaseEffect *base = This->base_effect;
3241 TRACE("Forward iface %p, base %p\n", This, base);
3243 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3246 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3248 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3249 ID3DXBaseEffect *base = This->base_effect;
3251 TRACE("Forward iface %p, base %p\n", This, base);
3253 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3256 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3258 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3259 ID3DXBaseEffect *base = This->base_effect;
3261 TRACE("Forward iface %p, base %p\n", This, base);
3263 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3266 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3268 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3269 ID3DXBaseEffect *base = This->base_effect;
3271 TRACE("Forward iface %p, base %p\n", This, base);
3273 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3276 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3278 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3279 ID3DXBaseEffect *base = This->base_effect;
3281 TRACE("Forward iface %p, base %p\n", This, base);
3283 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3286 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3288 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3289 ID3DXBaseEffect *base = This->base_effect;
3291 TRACE("Forward iface %p, base %p\n", This, base);
3293 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3296 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3298 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3299 ID3DXBaseEffect *base = This->base_effect;
3301 TRACE("Forward iface %p, base %p\n", This, base);
3303 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3306 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3308 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3309 ID3DXBaseEffect *base = This->base_effect;
3311 TRACE("Forward iface %p, base %p\n", This, base);
3313 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3316 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3318 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3319 ID3DXBaseEffect *base = This->base_effect;
3321 TRACE("Forward iface %p, base %p\n", This, base);
3323 return ID3DXBaseEffectImpl_GetFunction(base, index);
3326 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3328 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3329 ID3DXBaseEffect *base = This->base_effect;
3331 TRACE("Forward iface %p, base %p\n", This, base);
3333 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3336 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3338 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3339 ID3DXBaseEffect *base = This->base_effect;
3341 TRACE("Forward iface %p, base %p\n", This, base);
3343 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3346 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3348 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3349 ID3DXBaseEffect *base = This->base_effect;
3351 TRACE("Forward iface %p, base %p\n", This, base);
3353 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3356 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3358 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3359 ID3DXBaseEffect *base = This->base_effect;
3361 TRACE("Forward iface %p, base %p\n", This, base);
3363 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3366 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3368 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3369 ID3DXBaseEffect *base = This->base_effect;
3371 TRACE("Forward iface %p, base %p\n", This, base);
3373 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3376 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3378 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3379 ID3DXBaseEffect *base = This->base_effect;
3381 TRACE("Forward iface %p, base %p\n", This, base);
3383 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3386 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3388 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3389 ID3DXBaseEffect *base = This->base_effect;
3391 TRACE("Forward iface %p, base %p\n", This, base);
3393 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3396 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3398 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3399 ID3DXBaseEffect *base = This->base_effect;
3401 TRACE("Forward iface %p, base %p\n", This, base);
3403 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3406 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3408 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3409 ID3DXBaseEffect *base = This->base_effect;
3411 TRACE("Forward iface %p, base %p\n", This, base);
3413 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3416 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3418 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3419 ID3DXBaseEffect *base = This->base_effect;
3421 TRACE("Forward iface %p, base %p\n", This, base);
3423 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3426 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3428 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3429 ID3DXBaseEffect *base = This->base_effect;
3431 TRACE("Forward iface %p, base %p\n", This, base);
3433 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3436 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3438 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3439 ID3DXBaseEffect *base = This->base_effect;
3441 TRACE("Forward iface %p, base %p\n", This, base);
3443 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3446 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3448 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3449 ID3DXBaseEffect *base = This->base_effect;
3451 TRACE("Forward iface %p, base %p\n", This, base);
3453 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3456 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3458 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3459 ID3DXBaseEffect *base = This->base_effect;
3461 TRACE("Forward iface %p, base %p\n", This, base);
3463 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3466 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3468 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3469 ID3DXBaseEffect *base = This->base_effect;
3471 TRACE("Forward iface %p, base %p\n", This, base);
3473 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3476 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3478 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3479 ID3DXBaseEffect *base = This->base_effect;
3481 TRACE("Forward iface %p, base %p\n", This, base);
3483 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3486 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3488 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3489 ID3DXBaseEffect *base = This->base_effect;
3491 TRACE("Forward iface %p, base %p\n", This, base);
3493 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3496 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3498 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3499 ID3DXBaseEffect *base = This->base_effect;
3501 TRACE("Forward iface %p, base %p\n", This, base);
3503 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3506 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3508 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3509 ID3DXBaseEffect *base = This->base_effect;
3511 TRACE("Forward iface %p, base %p\n", This, base);
3513 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3516 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3518 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3519 ID3DXBaseEffect *base = This->base_effect;
3521 TRACE("Forward iface %p, base %p\n", This, base);
3523 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3526 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3528 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3529 ID3DXBaseEffect *base = This->base_effect;
3531 TRACE("Forward iface %p, base %p\n", This, base);
3533 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3536 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3538 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3539 ID3DXBaseEffect *base = This->base_effect;
3541 TRACE("Forward iface %p, base %p\n", This, base);
3543 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3546 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3548 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3549 ID3DXBaseEffect *base = This->base_effect;
3551 TRACE("Forward iface %p, base %p\n", This, base);
3553 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3556 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3558 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3559 ID3DXBaseEffect *base = This->base_effect;
3561 TRACE("Forward iface %p, base %p\n", This, base);
3563 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3566 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3568 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3569 ID3DXBaseEffect *base = This->base_effect;
3571 TRACE("Forward iface %p, base %p\n", This, base);
3573 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3576 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3578 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3579 ID3DXBaseEffect *base = This->base_effect;
3581 TRACE("Forward iface %p, base %p\n", This, base);
3583 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3586 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3588 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3589 ID3DXBaseEffect *base = This->base_effect;
3591 TRACE("Forward iface %p, base %p\n", This, base);
3593 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3596 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3598 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3599 ID3DXBaseEffect *base = This->base_effect;
3601 TRACE("Forward iface %p, base %p\n", This, base);
3603 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3606 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3608 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3609 ID3DXBaseEffect *base = This->base_effect;
3611 TRACE("Forward iface %p, base %p\n", This, base);
3613 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3616 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3618 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3619 ID3DXBaseEffect *base = This->base_effect;
3621 TRACE("Forward iface %p, base %p\n", This, base);
3623 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3626 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3628 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3629 ID3DXBaseEffect *base = This->base_effect;
3631 TRACE("Forward iface %p, base %p\n", This, base);
3633 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3636 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3638 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3639 ID3DXBaseEffect *base = This->base_effect;
3641 TRACE("Forward iface %p, base %p\n", This, base);
3643 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3646 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3648 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3649 ID3DXBaseEffect *base = This->base_effect;
3651 TRACE("Forward iface %p, base %p\n", This, base);
3653 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3656 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3658 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3659 ID3DXBaseEffect *base = This->base_effect;
3661 TRACE("Forward iface %p, base %p\n", This, base);
3663 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3666 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3668 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3669 ID3DXBaseEffect *base = This->base_effect;
3671 TRACE("Forward iface %p, base %p\n", This, base);
3673 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3676 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3678 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3679 ID3DXBaseEffect *base = This->base_effect;
3681 TRACE("Forward iface %p, base %p\n", This, base);
3683 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3686 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3688 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3689 ID3DXBaseEffect *base = This->base_effect;
3691 TRACE("Forward iface %p, base %p\n", This, base);
3693 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3696 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3698 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3699 ID3DXBaseEffect *base = This->base_effect;
3701 TRACE("Forward iface %p, base %p\n", This, base);
3703 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3706 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3708 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3709 ID3DXBaseEffect *base = This->base_effect;
3711 TRACE("Forward iface %p, base %p\n", This, base);
3713 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3716 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3718 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3719 ID3DXBaseEffect *base = This->base_effect;
3721 TRACE("Forward iface %p, base %p\n", This, base);
3723 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3726 /*** ID3DXEffectCompiler methods ***/
3727 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3729 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3731 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3733 return E_NOTIMPL;
3736 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3738 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3740 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3742 return E_NOTIMPL;
3745 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3746 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3748 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3750 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3752 return E_NOTIMPL;
3755 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3756 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3758 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3760 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3761 This, function, target, flags, shader, error_msgs, constant_table);
3763 return E_NOTIMPL;
3766 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3768 /*** IUnknown methods ***/
3769 ID3DXEffectCompilerImpl_QueryInterface,
3770 ID3DXEffectCompilerImpl_AddRef,
3771 ID3DXEffectCompilerImpl_Release,
3772 /*** ID3DXBaseEffect methods ***/
3773 ID3DXEffectCompilerImpl_GetDesc,
3774 ID3DXEffectCompilerImpl_GetParameterDesc,
3775 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3776 ID3DXEffectCompilerImpl_GetPassDesc,
3777 ID3DXEffectCompilerImpl_GetFunctionDesc,
3778 ID3DXEffectCompilerImpl_GetParameter,
3779 ID3DXEffectCompilerImpl_GetParameterByName,
3780 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3781 ID3DXEffectCompilerImpl_GetParameterElement,
3782 ID3DXEffectCompilerImpl_GetTechnique,
3783 ID3DXEffectCompilerImpl_GetTechniqueByName,
3784 ID3DXEffectCompilerImpl_GetPass,
3785 ID3DXEffectCompilerImpl_GetPassByName,
3786 ID3DXEffectCompilerImpl_GetFunction,
3787 ID3DXEffectCompilerImpl_GetFunctionByName,
3788 ID3DXEffectCompilerImpl_GetAnnotation,
3789 ID3DXEffectCompilerImpl_GetAnnotationByName,
3790 ID3DXEffectCompilerImpl_SetValue,
3791 ID3DXEffectCompilerImpl_GetValue,
3792 ID3DXEffectCompilerImpl_SetBool,
3793 ID3DXEffectCompilerImpl_GetBool,
3794 ID3DXEffectCompilerImpl_SetBoolArray,
3795 ID3DXEffectCompilerImpl_GetBoolArray,
3796 ID3DXEffectCompilerImpl_SetInt,
3797 ID3DXEffectCompilerImpl_GetInt,
3798 ID3DXEffectCompilerImpl_SetIntArray,
3799 ID3DXEffectCompilerImpl_GetIntArray,
3800 ID3DXEffectCompilerImpl_SetFloat,
3801 ID3DXEffectCompilerImpl_GetFloat,
3802 ID3DXEffectCompilerImpl_SetFloatArray,
3803 ID3DXEffectCompilerImpl_GetFloatArray,
3804 ID3DXEffectCompilerImpl_SetVector,
3805 ID3DXEffectCompilerImpl_GetVector,
3806 ID3DXEffectCompilerImpl_SetVectorArray,
3807 ID3DXEffectCompilerImpl_GetVectorArray,
3808 ID3DXEffectCompilerImpl_SetMatrix,
3809 ID3DXEffectCompilerImpl_GetMatrix,
3810 ID3DXEffectCompilerImpl_SetMatrixArray,
3811 ID3DXEffectCompilerImpl_GetMatrixArray,
3812 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3813 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3814 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3815 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3816 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3817 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3818 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3819 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3820 ID3DXEffectCompilerImpl_SetString,
3821 ID3DXEffectCompilerImpl_GetString,
3822 ID3DXEffectCompilerImpl_SetTexture,
3823 ID3DXEffectCompilerImpl_GetTexture,
3824 ID3DXEffectCompilerImpl_GetPixelShader,
3825 ID3DXEffectCompilerImpl_GetVertexShader,
3826 ID3DXEffectCompilerImpl_SetArrayRange,
3827 /*** ID3DXEffectCompiler methods ***/
3828 ID3DXEffectCompilerImpl_SetLiteral,
3829 ID3DXEffectCompilerImpl_GetLiteral,
3830 ID3DXEffectCompilerImpl_CompileEffect,
3831 ID3DXEffectCompilerImpl_CompileShader,
3834 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
3836 HRESULT hr;
3837 UINT i;
3838 struct d3dx_state *states;
3840 read_dword(ptr, &sampler->state_count);
3841 TRACE("Count: %u\n", sampler->state_count);
3843 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
3844 if (!states)
3846 ERR("Out of memory\n");
3847 return E_OUTOFMEMORY;
3850 for (i = 0; i < sampler->state_count; ++i)
3852 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
3853 if (hr != D3D_OK)
3855 WARN("Failed to parse state\n");
3856 goto err_out;
3860 sampler->states = states;
3862 return D3D_OK;
3864 err_out:
3866 for (i = 0; i < sampler->state_count; ++i)
3868 free_state(&states[i]);
3871 HeapFree(GetProcessHeap(), 0, states);
3873 return hr;
3876 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
3878 unsigned int i;
3879 HRESULT hr;
3880 UINT old_size = 0;
3881 DWORD id;
3883 if (param->element_count)
3885 param->data = value;
3887 for (i = 0; i < param->element_count; ++i)
3889 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3891 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
3892 if (hr != D3D_OK)
3894 WARN("Failed to parse value\n");
3895 return hr;
3898 old_size += member->bytes;
3901 return D3D_OK;
3904 switch(param->class)
3906 case D3DXPC_SCALAR:
3907 case D3DXPC_VECTOR:
3908 case D3DXPC_MATRIX_ROWS:
3909 case D3DXPC_MATRIX_COLUMNS:
3910 param->data = value;
3911 break;
3913 case D3DXPC_STRUCT:
3914 param->data = value;
3916 for (i = 0; i < param->member_count; ++i)
3918 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3920 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
3921 if (hr != D3D_OK)
3923 WARN("Failed to parse value\n");
3924 return hr;
3927 old_size += member->bytes;
3929 break;
3931 case D3DXPC_OBJECT:
3932 switch (param->type)
3934 case D3DXPT_STRING:
3935 case D3DXPT_TEXTURE:
3936 case D3DXPT_TEXTURE1D:
3937 case D3DXPT_TEXTURE2D:
3938 case D3DXPT_TEXTURE3D:
3939 case D3DXPT_TEXTURECUBE:
3940 case D3DXPT_PIXELSHADER:
3941 case D3DXPT_VERTEXSHADER:
3942 read_dword(ptr, &id);
3943 TRACE("Id: %u\n", id);
3944 objects[id] = get_parameter_handle(param);
3945 param->data = value;
3946 break;
3948 case D3DXPT_SAMPLER:
3949 case D3DXPT_SAMPLER1D:
3950 case D3DXPT_SAMPLER2D:
3951 case D3DXPT_SAMPLER3D:
3952 case D3DXPT_SAMPLERCUBE:
3954 struct d3dx_sampler *sampler;
3956 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
3957 if (!sampler)
3959 ERR("Out of memory\n");
3960 return E_OUTOFMEMORY;
3963 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
3964 if (hr != D3D_OK)
3966 HeapFree(GetProcessHeap(), 0, sampler);
3967 WARN("Failed to parse sampler\n");
3968 return hr;
3971 param->data = sampler;
3972 break;
3975 default:
3976 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3977 break;
3979 break;
3981 default:
3982 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3983 break;
3986 return D3D_OK;
3989 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
3991 UINT size = param->bytes;
3992 HRESULT hr;
3993 void *value = NULL;
3995 TRACE("param size: %u\n", size);
3997 if (size)
3999 value = HeapAlloc(GetProcessHeap(), 0, size);
4000 if (!value)
4002 ERR("Failed to allocate data memory.\n");
4003 return E_OUTOFMEMORY;
4006 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4007 memcpy(value, ptr, size);
4010 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4011 if (hr != D3D_OK)
4013 WARN("Failed to parse value\n");
4014 HeapFree(GetProcessHeap(), 0, value);
4015 return hr;
4018 return D3D_OK;
4021 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4023 DWORD size;
4025 read_dword(&ptr, &size);
4026 TRACE("Name size: %#x\n", size);
4028 if (!size)
4030 return D3D_OK;
4033 *name = HeapAlloc(GetProcessHeap(), 0, size);
4034 if (!*name)
4036 ERR("Failed to allocate name memory.\n");
4037 return E_OUTOFMEMORY;
4040 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4041 memcpy(*name, ptr, size);
4043 return D3D_OK;
4046 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4048 DWORD size;
4050 read_dword(ptr, &size);
4051 TRACE("Data size: %#x\n", size);
4053 *str = HeapAlloc(GetProcessHeap(), 0, size);
4054 if (!*str)
4056 ERR("Failed to allocate name memory.\n");
4057 return E_OUTOFMEMORY;
4060 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4061 memcpy(*str, *ptr, size);
4063 *ptr += ((size + 3) & ~3);
4065 return D3D_OK;
4068 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4070 DWORD size;
4071 HRESULT hr;
4073 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4075 read_dword(ptr, &size);
4076 TRACE("Data size: %#x\n", size);
4078 if (!size)
4080 TRACE("Size is 0\n");
4081 *(void **)param->data = NULL;
4082 return D3D_OK;
4085 switch (param->type)
4087 case D3DXPT_STRING:
4088 /* re-read with size (sizeof(DWORD) = 4) */
4089 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4090 if (hr != D3D_OK)
4092 WARN("Failed to parse string data\n");
4093 return hr;
4095 break;
4097 case D3DXPT_VERTEXSHADER:
4098 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4099 if (hr != D3D_OK)
4101 WARN("Failed to create vertex shader\n");
4102 return hr;
4104 break;
4106 case D3DXPT_PIXELSHADER:
4107 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4108 if (hr != D3D_OK)
4110 WARN("Failed to create pixel shader\n");
4111 return hr;
4113 break;
4115 default:
4116 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4117 break;
4121 *ptr += ((size + 3) & ~3);
4123 return D3D_OK;
4126 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4127 struct d3dx_parameter *parent, UINT flags)
4129 DWORD offset;
4130 HRESULT hr;
4131 D3DXHANDLE *member_handles = NULL;
4132 UINT i;
4134 param->flags = flags;
4136 if (!parent)
4138 read_dword(ptr, &param->type);
4139 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4141 read_dword(ptr, &param->class);
4142 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4144 read_dword(ptr, &offset);
4145 TRACE("Type name offset: %#x\n", offset);
4146 hr = d3dx9_parse_name(&param->name, data + offset);
4147 if (hr != D3D_OK)
4149 WARN("Failed to parse name\n");
4150 goto err_out;
4153 read_dword(ptr, &offset);
4154 TRACE("Type semantic offset: %#x\n", offset);
4155 hr = d3dx9_parse_name(&param->semantic, data + offset);
4156 if (hr != D3D_OK)
4158 WARN("Failed to parse semantic\n");
4159 goto err_out;
4162 read_dword(ptr, &param->element_count);
4163 TRACE("Elements: %u\n", param->element_count);
4165 switch (param->class)
4167 case D3DXPC_VECTOR:
4168 read_dword(ptr, &param->columns);
4169 TRACE("Columns: %u\n", param->columns);
4171 read_dword(ptr, &param->rows);
4172 TRACE("Rows: %u\n", param->rows);
4174 /* sizeof(DWORD) * rows * columns */
4175 param->bytes = 4 * param->rows * param->columns;
4176 break;
4178 case D3DXPC_SCALAR:
4179 case D3DXPC_MATRIX_ROWS:
4180 case D3DXPC_MATRIX_COLUMNS:
4181 read_dword(ptr, &param->rows);
4182 TRACE("Rows: %u\n", param->rows);
4184 read_dword(ptr, &param->columns);
4185 TRACE("Columns: %u\n", param->columns);
4187 /* sizeof(DWORD) * rows * columns */
4188 param->bytes = 4 * param->rows * param->columns;
4189 break;
4191 case D3DXPC_STRUCT:
4192 read_dword(ptr, &param->member_count);
4193 TRACE("Members: %u\n", param->member_count);
4194 break;
4196 case D3DXPC_OBJECT:
4197 switch (param->type)
4199 case D3DXPT_STRING:
4200 param->bytes = sizeof(LPCSTR);
4201 break;
4203 case D3DXPT_PIXELSHADER:
4204 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4205 break;
4207 case D3DXPT_VERTEXSHADER:
4208 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4209 break;
4211 case D3DXPT_TEXTURE:
4212 case D3DXPT_TEXTURE1D:
4213 case D3DXPT_TEXTURE2D:
4214 case D3DXPT_TEXTURE3D:
4215 case D3DXPT_TEXTURECUBE:
4216 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4217 break;
4219 case D3DXPT_SAMPLER:
4220 case D3DXPT_SAMPLER1D:
4221 case D3DXPT_SAMPLER2D:
4222 case D3DXPT_SAMPLER3D:
4223 case D3DXPT_SAMPLERCUBE:
4224 param->bytes = 0;
4225 break;
4227 default:
4228 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4229 break;
4231 break;
4233 default:
4234 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4235 break;
4238 else
4240 /* elements */
4241 param->type = parent->type;
4242 param->class = parent->class;
4243 param->name = parent->name;
4244 param->semantic = parent->semantic;
4245 param->element_count = 0;
4246 param->annotation_count = 0;
4247 param->member_count = parent->member_count;
4248 param->bytes = parent->bytes;
4249 param->rows = parent->rows;
4250 param->columns = parent->columns;
4253 if (param->element_count)
4255 unsigned int param_bytes = 0;
4256 const char *save_ptr = *ptr;
4258 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4259 if (!member_handles)
4261 ERR("Out of memory\n");
4262 hr = E_OUTOFMEMORY;
4263 goto err_out;
4266 for (i = 0; i < param->element_count; ++i)
4268 struct d3dx_parameter *member;
4269 *ptr = save_ptr;
4271 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4272 if (!member)
4274 ERR("Out of memory\n");
4275 hr = E_OUTOFMEMORY;
4276 goto err_out;
4279 member_handles[i] = get_parameter_handle(member);
4281 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4282 if (hr != D3D_OK)
4284 WARN("Failed to parse member\n");
4285 goto err_out;
4288 param_bytes += member->bytes;
4291 param->bytes = param_bytes;
4293 else if (param->member_count)
4295 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4296 if (!member_handles)
4298 ERR("Out of memory\n");
4299 hr = E_OUTOFMEMORY;
4300 goto err_out;
4303 for (i = 0; i < param->member_count; ++i)
4305 struct d3dx_parameter *member;
4307 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4308 if (!member)
4310 ERR("Out of memory\n");
4311 hr = E_OUTOFMEMORY;
4312 goto err_out;
4315 member_handles[i] = get_parameter_handle(member);
4317 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4318 if (hr != D3D_OK)
4320 WARN("Failed to parse member\n");
4321 goto err_out;
4324 param->bytes += member->bytes;
4328 param->member_handles = member_handles;
4330 return D3D_OK;
4332 err_out:
4334 if (member_handles)
4336 unsigned int count;
4338 if (param->element_count) count = param->element_count;
4339 else count = param->member_count;
4341 for (i = 0; i < count; ++i)
4343 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4345 HeapFree(GetProcessHeap(), 0, member_handles);
4348 if (!parent)
4350 HeapFree(GetProcessHeap(), 0, param->name);
4351 HeapFree(GetProcessHeap(), 0, param->semantic);
4353 param->name = NULL;
4354 param->semantic = NULL;
4356 return hr;
4359 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4361 DWORD offset;
4362 const char *ptr2;
4363 HRESULT hr;
4365 anno->flags = D3DX_PARAMETER_ANNOTATION;
4367 read_dword(ptr, &offset);
4368 TRACE("Typedef offset: %#x\n", offset);
4369 ptr2 = data + offset;
4370 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4371 if (hr != D3D_OK)
4373 WARN("Failed to parse type definition\n");
4374 return hr;
4377 read_dword(ptr, &offset);
4378 TRACE("Value offset: %#x\n", offset);
4379 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4380 if (hr != D3D_OK)
4382 WARN("Failed to parse value\n");
4383 return hr;
4386 return D3D_OK;
4389 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4391 DWORD offset;
4392 const char *ptr2;
4393 HRESULT hr;
4394 struct d3dx_parameter *parameter;
4396 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4397 if (!parameter)
4399 ERR("Out of memory\n");
4400 return E_OUTOFMEMORY;
4403 state->type = ST_CONSTANT;
4405 read_dword(ptr, &state->operation);
4406 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4408 read_dword(ptr, &state->index);
4409 TRACE("Index: %#x\n", state->index);
4411 read_dword(ptr, &offset);
4412 TRACE("Typedef offset: %#x\n", offset);
4413 ptr2 = data + offset;
4414 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4415 if (hr != D3D_OK)
4417 WARN("Failed to parse type definition\n");
4418 goto err_out;
4421 read_dword(ptr, &offset);
4422 TRACE("Value offset: %#x\n", offset);
4423 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4424 if (hr != D3D_OK)
4426 WARN("Failed to parse value\n");
4427 goto err_out;
4430 state->parameter = get_parameter_handle(parameter);
4432 return D3D_OK;
4434 err_out:
4436 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4438 return hr;
4441 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4443 DWORD offset;
4444 HRESULT hr;
4445 unsigned int i;
4446 D3DXHANDLE *annotation_handles = NULL;
4447 const char *ptr2;
4449 read_dword(ptr, &offset);
4450 TRACE("Typedef offset: %#x\n", offset);
4451 ptr2 = data + offset;
4453 read_dword(ptr, &offset);
4454 TRACE("Value offset: %#x\n", offset);
4456 read_dword(ptr, &param->flags);
4457 TRACE("Flags: %#x\n", param->flags);
4459 read_dword(ptr, &param->annotation_count);
4460 TRACE("Annotation count: %u\n", param->annotation_count);
4462 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4463 if (hr != D3D_OK)
4465 WARN("Failed to parse type definition\n");
4466 return hr;
4469 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4470 if (hr != D3D_OK)
4472 WARN("Failed to parse value\n");
4473 return hr;
4476 if (param->annotation_count)
4478 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->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 < param->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 annotation\n");
4504 goto err_out;
4509 param->annotation_handles = annotation_handles;
4511 return D3D_OK;
4513 err_out:
4515 if (annotation_handles)
4517 for (i = 0; i < param->annotation_count; ++i)
4519 free_parameter(annotation_handles[i], FALSE, FALSE);
4521 HeapFree(GetProcessHeap(), 0, annotation_handles);
4524 return hr;
4527 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4529 DWORD offset;
4530 HRESULT hr;
4531 unsigned int i;
4532 D3DXHANDLE *annotation_handles = NULL;
4533 struct d3dx_state *states = NULL;
4534 char *name = NULL;
4536 read_dword(ptr, &offset);
4537 TRACE("Pass name offset: %#x\n", offset);
4538 hr = d3dx9_parse_name(&name, data + offset);
4539 if (hr != D3D_OK)
4541 WARN("Failed to parse name\n");
4542 goto err_out;
4545 read_dword(ptr, &pass->annotation_count);
4546 TRACE("Annotation count: %u\n", pass->annotation_count);
4548 read_dword(ptr, &pass->state_count);
4549 TRACE("State count: %u\n", pass->state_count);
4551 if (pass->annotation_count)
4553 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4554 if (!annotation_handles)
4556 ERR("Out of memory\n");
4557 hr = E_OUTOFMEMORY;
4558 goto err_out;
4561 for (i = 0; i < pass->annotation_count; ++i)
4563 struct d3dx_parameter *annotation;
4565 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4566 if (!annotation)
4568 ERR("Out of memory\n");
4569 hr = E_OUTOFMEMORY;
4570 goto err_out;
4573 annotation_handles[i] = get_parameter_handle(annotation);
4575 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4576 if (hr != D3D_OK)
4578 WARN("Failed to parse annotations\n");
4579 goto err_out;
4584 if (pass->state_count)
4586 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4587 if (!states)
4589 ERR("Out of memory\n");
4590 hr = E_OUTOFMEMORY;
4591 goto err_out;
4594 for (i = 0; i < pass->state_count; ++i)
4596 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4597 if (hr != D3D_OK)
4599 WARN("Failed to parse annotations\n");
4600 goto err_out;
4605 pass->name = name;
4606 pass->annotation_handles = annotation_handles;
4607 pass->states = states;
4609 return D3D_OK;
4611 err_out:
4613 if (annotation_handles)
4615 for (i = 0; i < pass->annotation_count; ++i)
4617 free_parameter(annotation_handles[i], FALSE, FALSE);
4619 HeapFree(GetProcessHeap(), 0, annotation_handles);
4622 if (states)
4624 for (i = 0; i < pass->state_count; ++i)
4626 free_state(&states[i]);
4628 HeapFree(GetProcessHeap(), 0, states);
4631 HeapFree(GetProcessHeap(), 0, name);
4633 return hr;
4636 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4638 DWORD offset;
4639 HRESULT hr;
4640 unsigned int i;
4641 D3DXHANDLE *annotation_handles = NULL;
4642 D3DXHANDLE *pass_handles = NULL;
4643 char *name = NULL;
4645 read_dword(ptr, &offset);
4646 TRACE("Technique name offset: %#x\n", offset);
4647 hr = d3dx9_parse_name(&name, data + offset);
4648 if (hr != D3D_OK)
4650 WARN("Failed to parse name\n");
4651 goto err_out;
4654 read_dword(ptr, &technique->annotation_count);
4655 TRACE("Annotation count: %u\n", technique->annotation_count);
4657 read_dword(ptr, &technique->pass_count);
4658 TRACE("Pass count: %u\n", technique->pass_count);
4660 if (technique->annotation_count)
4662 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4663 if (!annotation_handles)
4665 ERR("Out of memory\n");
4666 hr = E_OUTOFMEMORY;
4667 goto err_out;
4670 for (i = 0; i < technique->annotation_count; ++i)
4672 struct d3dx_parameter *annotation;
4674 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4675 if (!annotation)
4677 ERR("Out of memory\n");
4678 hr = E_OUTOFMEMORY;
4679 goto err_out;
4682 annotation_handles[i] = get_parameter_handle(annotation);
4684 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4685 if (hr != D3D_OK)
4687 WARN("Failed to parse annotations\n");
4688 goto err_out;
4693 if (technique->pass_count)
4695 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4696 if (!pass_handles)
4698 ERR("Out of memory\n");
4699 hr = E_OUTOFMEMORY;
4700 goto err_out;
4703 for (i = 0; i < technique->pass_count; ++i)
4705 struct d3dx_pass *pass;
4707 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4708 if (!pass)
4710 ERR("Out of memory\n");
4711 hr = E_OUTOFMEMORY;
4712 goto err_out;
4715 pass_handles[i] = get_pass_handle(pass);
4717 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
4718 if (hr != D3D_OK)
4720 WARN("Failed to parse passes\n");
4721 goto err_out;
4726 technique->name = name;
4727 technique->pass_handles = pass_handles;
4728 technique->annotation_handles = annotation_handles;
4730 return D3D_OK;
4732 err_out:
4734 if (pass_handles)
4736 for (i = 0; i < technique->pass_count; ++i)
4738 free_pass(pass_handles[i]);
4740 HeapFree(GetProcessHeap(), 0, pass_handles);
4743 if (annotation_handles)
4745 for (i = 0; i < technique->annotation_count; ++i)
4747 free_parameter(annotation_handles[i], FALSE, FALSE);
4749 HeapFree(GetProcessHeap(), 0, annotation_handles);
4752 HeapFree(GetProcessHeap(), 0, name);
4754 return hr;
4757 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
4759 DWORD technique_index;
4760 DWORD index, state_index, usage, element_index;
4761 struct d3dx_state *state;
4762 struct d3dx_parameter *param;
4763 HRESULT hr = E_FAIL;
4765 read_dword(ptr, &technique_index);
4766 TRACE("techn: %u\n", technique_index);
4768 read_dword(ptr, &index);
4769 TRACE("index: %u\n", index);
4771 read_dword(ptr, &element_index);
4772 TRACE("element_index: %u\n", element_index);
4774 read_dword(ptr, &state_index);
4775 TRACE("state_index: %u\n", state_index);
4777 read_dword(ptr, &usage);
4778 TRACE("usage: %u\n", usage);
4780 if (technique_index == 0xffffffff)
4782 struct d3dx_parameter *parameter;
4783 struct d3dx_sampler *sampler;
4785 if (index >= base->parameter_count)
4787 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
4788 return E_FAIL;
4791 parameter = get_parameter_struct(base->parameter_handles[index]);
4792 if (element_index != 0xffffffff)
4794 if (element_index >= parameter->element_count && parameter->element_count != 0)
4796 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
4797 return E_FAIL;
4800 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
4803 sampler = parameter->data;
4804 if (state_index >= sampler->state_count)
4806 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
4807 return E_FAIL;
4810 state = &sampler->states[state_index];
4812 else
4814 struct d3dx_technique *technique;
4815 struct d3dx_pass *pass;
4817 if (technique_index >= base->technique_count)
4819 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
4820 return E_FAIL;
4823 technique = get_technique_struct(base->technique_handles[technique_index]);
4824 if (index >= technique->pass_count)
4826 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
4827 return E_FAIL;
4830 pass = get_pass_struct(technique->pass_handles[index]);
4831 if (state_index >= pass->state_count)
4833 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
4834 return E_FAIL;
4837 state = &pass->states[state_index];
4840 param = get_parameter_struct(state->parameter);
4842 switch (usage)
4844 case 0:
4845 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
4846 switch (param->type)
4848 case D3DXPT_VERTEXSHADER:
4849 case D3DXPT_PIXELSHADER:
4850 state->type = ST_CONSTANT;
4851 hr = d3dx9_parse_data(param, ptr, base->effect->device);
4852 break;
4854 case D3DXPT_BOOL:
4855 case D3DXPT_INT:
4856 case D3DXPT_FLOAT:
4857 case D3DXPT_STRING:
4858 state->type = ST_FXLC;
4859 hr = d3dx9_copy_data(param->data, ptr);
4860 break;
4862 default:
4863 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4864 break;
4866 break;
4868 case 1:
4869 state->type = ST_PARAMETER;
4870 hr = d3dx9_copy_data(param->data, ptr);
4871 if (hr == D3D_OK)
4873 TRACE("Mapping to parameter %s\n", *(char **)param->data);
4875 break;
4877 default:
4878 FIXME("Unknown usage %x\n", usage);
4879 break;
4882 return hr;
4885 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4887 const char *ptr = data + start;
4888 D3DXHANDLE *parameter_handles = NULL;
4889 D3DXHANDLE *technique_handles = NULL;
4890 D3DXHANDLE *objects = NULL;
4891 UINT stringcount, objectcount, resourcecount;
4892 HRESULT hr;
4893 UINT i;
4895 read_dword(&ptr, &base->parameter_count);
4896 TRACE("Parameter count: %u\n", base->parameter_count);
4898 read_dword(&ptr, &base->technique_count);
4899 TRACE("Technique count: %u\n", base->technique_count);
4901 skip_dword_unknown(&ptr, 1);
4903 read_dword(&ptr, &objectcount);
4904 TRACE("Object count: %u\n", objectcount);
4906 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
4907 if (!objects)
4909 ERR("Out of memory\n");
4910 hr = E_OUTOFMEMORY;
4911 goto err_out;
4914 if (base->parameter_count)
4916 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4917 if (!parameter_handles)
4919 ERR("Out of memory\n");
4920 hr = E_OUTOFMEMORY;
4921 goto err_out;
4924 for (i = 0; i < base->parameter_count; ++i)
4926 struct d3dx_parameter *parameter;
4928 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4929 if (!parameter)
4931 ERR("Out of memory\n");
4932 hr = E_OUTOFMEMORY;
4933 goto err_out;
4936 parameter_handles[i] = get_parameter_handle(parameter);
4938 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
4939 if (hr != D3D_OK)
4941 WARN("Failed to parse parameter\n");
4942 goto err_out;
4947 if (base->technique_count)
4949 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4950 if (!technique_handles)
4952 ERR("Out of memory\n");
4953 hr = E_OUTOFMEMORY;
4954 goto err_out;
4957 for (i = 0; i < base->technique_count; ++i)
4959 struct d3dx_technique *technique;
4961 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4962 if (!technique)
4964 ERR("Out of memory\n");
4965 hr = E_OUTOFMEMORY;
4966 goto err_out;
4969 technique_handles[i] = get_technique_handle(technique);
4971 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
4972 if (hr != D3D_OK)
4974 WARN("Failed to parse technique\n");
4975 goto err_out;
4980 /* needed for further parsing */
4981 base->technique_handles = technique_handles;
4982 base->parameter_handles = parameter_handles;
4984 read_dword(&ptr, &stringcount);
4985 TRACE("String count: %u\n", stringcount);
4987 read_dword(&ptr, &resourcecount);
4988 TRACE("Resource count: %u\n", resourcecount);
4990 for (i = 0; i < stringcount; ++i)
4992 DWORD id;
4993 struct d3dx_parameter *param;
4995 read_dword(&ptr, &id);
4996 TRACE("Id: %u\n", id);
4998 param = get_parameter_struct(objects[id]);
5000 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5001 if (hr != D3D_OK)
5003 WARN("Failed to parse data\n");
5004 goto err_out;
5008 for (i = 0; i < resourcecount; ++i)
5010 TRACE("parse resource %u\n", i);
5012 hr = d3dx9_parse_resource(base, data, &ptr);
5013 if (hr != D3D_OK)
5015 WARN("Failed to parse data\n");
5016 goto err_out;
5020 HeapFree(GetProcessHeap(), 0, objects);
5022 return D3D_OK;
5024 err_out:
5026 if (technique_handles)
5028 for (i = 0; i < base->technique_count; ++i)
5030 free_technique(technique_handles[i]);
5032 HeapFree(GetProcessHeap(), 0, technique_handles);
5035 if (parameter_handles)
5037 for (i = 0; i < base->parameter_count; ++i)
5039 free_parameter(parameter_handles[i], FALSE, FALSE);
5041 HeapFree(GetProcessHeap(), 0, parameter_handles);
5044 base->technique_handles = NULL;
5045 base->parameter_handles = NULL;
5047 HeapFree(GetProcessHeap(), 0, objects);
5049 return hr;
5052 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5053 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5055 DWORD tag, offset;
5056 const char *ptr = data;
5057 HRESULT hr;
5059 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5061 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5062 base->ref = 1;
5063 base->effect = effect;
5065 read_dword(&ptr, &tag);
5066 TRACE("Tag: %x\n", tag);
5068 if (tag != d3dx9_effect_version(9, 1))
5070 /* todo: compile hlsl ascii code */
5071 FIXME("HLSL ascii effects not supported, yet\n");
5073 /* Show the start of the shader for debugging info. */
5074 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5076 else
5078 read_dword(&ptr, &offset);
5079 TRACE("Offset: %x\n", offset);
5081 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5082 if (hr != D3D_OK)
5084 FIXME("Failed to parse effect.\n");
5085 return hr;
5089 return D3D_OK;
5092 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5093 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5095 HRESULT hr;
5096 struct ID3DXBaseEffectImpl *object = NULL;
5098 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5100 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5101 effect->ref = 1;
5103 if (pool) pool->lpVtbl->AddRef(pool);
5104 effect->pool = pool;
5106 IDirect3DDevice9_AddRef(device);
5107 effect->device = device;
5109 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5110 if (!object)
5112 ERR("Out of memory\n");
5113 hr = E_OUTOFMEMORY;
5114 goto err_out;
5117 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5118 if (hr != D3D_OK)
5120 FIXME("Failed to parse effect.\n");
5121 goto err_out;
5124 effect->base_effect = &object->ID3DXBaseEffect_iface;
5126 /* initialize defaults - check because of unsupported ascii effects */
5127 if (object->technique_handles)
5129 effect->active_technique = object->technique_handles[0];
5130 effect->active_pass = NULL;
5133 return D3D_OK;
5135 err_out:
5137 HeapFree(GetProcessHeap(), 0, object);
5138 free_effect(effect);
5140 return hr;
5143 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5144 LPCVOID srcdata,
5145 UINT srcdatalen,
5146 CONST D3DXMACRO* defines,
5147 LPD3DXINCLUDE include,
5148 LPCSTR skip_constants,
5149 DWORD flags,
5150 LPD3DXEFFECTPOOL pool,
5151 LPD3DXEFFECT* effect,
5152 LPD3DXBUFFER* compilation_errors)
5154 struct ID3DXEffectImpl *object;
5155 HRESULT hr;
5157 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5158 skip_constants, flags, pool, effect, compilation_errors);
5160 if (!device || !srcdata)
5161 return D3DERR_INVALIDCALL;
5163 if (!srcdatalen)
5164 return E_FAIL;
5166 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5167 if (!effect)
5168 return D3D_OK;
5170 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5171 if (!object)
5173 ERR("Out of memory\n");
5174 return E_OUTOFMEMORY;
5177 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5178 if (FAILED(hr))
5180 WARN("Failed to initialize shader reflection\n");
5181 HeapFree(GetProcessHeap(), 0, object);
5182 return hr;
5185 *effect = &object->ID3DXEffect_iface;
5187 TRACE("Created ID3DXEffect %p\n", object);
5189 return D3D_OK;
5192 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5193 LPCVOID srcdata,
5194 UINT srcdatalen,
5195 CONST D3DXMACRO* defines,
5196 LPD3DXINCLUDE include,
5197 DWORD flags,
5198 LPD3DXEFFECTPOOL pool,
5199 LPD3DXEFFECT* effect,
5200 LPD3DXBUFFER* compilation_errors)
5202 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5203 include, flags, pool, effect, compilation_errors);
5205 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5208 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5210 HRESULT hr;
5211 struct ID3DXBaseEffectImpl *object = NULL;
5213 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5215 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5216 compiler->ref = 1;
5218 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5219 if (!object)
5221 ERR("Out of memory\n");
5222 hr = E_OUTOFMEMORY;
5223 goto err_out;
5226 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5227 if (hr != D3D_OK)
5229 FIXME("Failed to parse effect.\n");
5230 goto err_out;
5233 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5235 return D3D_OK;
5237 err_out:
5239 HeapFree(GetProcessHeap(), 0, object);
5240 free_effect_compiler(compiler);
5242 return hr;
5245 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5246 UINT srcdatalen,
5247 CONST D3DXMACRO *defines,
5248 LPD3DXINCLUDE include,
5249 DWORD flags,
5250 LPD3DXEFFECTCOMPILER *compiler,
5251 LPD3DXBUFFER *parse_errors)
5253 struct ID3DXEffectCompilerImpl *object;
5254 HRESULT hr;
5256 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5257 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5259 if (!srcdata || !compiler)
5261 WARN("Invalid arguments supplied\n");
5262 return D3DERR_INVALIDCALL;
5265 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5266 if (!object)
5268 ERR("Out of memory\n");
5269 return E_OUTOFMEMORY;
5272 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5273 if (FAILED(hr))
5275 WARN("Failed to initialize effect compiler\n");
5276 HeapFree(GetProcessHeap(), 0, object);
5277 return hr;
5280 *compiler = &object->ID3DXEffectCompiler_iface;
5282 TRACE("Created ID3DXEffectCompiler %p\n", object);
5284 return D3D_OK;
5287 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5289 struct ID3DXEffectPoolImpl
5291 ID3DXEffectPool ID3DXEffectPool_iface;
5292 LONG ref;
5295 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5297 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5300 /*** IUnknown methods ***/
5301 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5303 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5305 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5307 if (IsEqualGUID(riid, &IID_IUnknown) ||
5308 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5310 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5311 *object = This;
5312 return S_OK;
5315 WARN("Interface %s not found\n", debugstr_guid(riid));
5317 return E_NOINTERFACE;
5320 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5322 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5324 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5326 return InterlockedIncrement(&This->ref);
5329 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5331 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5332 ULONG ref = InterlockedDecrement(&This->ref);
5334 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5336 if (!ref)
5337 HeapFree(GetProcessHeap(), 0, This);
5339 return ref;
5342 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5344 /*** IUnknown methods ***/
5345 ID3DXEffectPoolImpl_QueryInterface,
5346 ID3DXEffectPoolImpl_AddRef,
5347 ID3DXEffectPoolImpl_Release
5350 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5352 struct ID3DXEffectPoolImpl *object;
5354 TRACE("(%p)\n", pool);
5356 if (!pool)
5357 return D3DERR_INVALIDCALL;
5359 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5360 if (!object)
5362 ERR("Out of memory\n");
5363 return E_OUTOFMEMORY;
5366 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5367 object->ref = 1;
5369 *pool = &object->ID3DXEffectPool_iface;
5371 return S_OK;
5374 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5375 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5376 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5378 LPVOID buffer;
5379 HRESULT ret;
5380 DWORD size;
5382 TRACE("(%s): relay\n", debugstr_w(srcfile));
5384 if (!device || !srcfile)
5385 return D3DERR_INVALIDCALL;
5387 ret = map_view_of_file(srcfile, &buffer, &size);
5389 if (FAILED(ret))
5390 return D3DXERR_INVALIDDATA;
5392 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5393 UnmapViewOfFile(buffer);
5395 return ret;
5398 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5399 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5400 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5402 LPWSTR srcfileW;
5403 HRESULT ret;
5404 DWORD len;
5406 TRACE("(void): relay\n");
5408 if (!srcfile)
5409 return D3DERR_INVALIDCALL;
5411 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5412 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5413 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5415 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5416 HeapFree(GetProcessHeap(), 0, srcfileW);
5418 return ret;
5421 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5422 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5423 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5425 TRACE("(void): relay\n");
5426 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5429 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5430 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5431 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5433 TRACE("(void): relay\n");
5434 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5437 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5438 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5439 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5441 HRSRC resinfo;
5443 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5445 if (!device)
5446 return D3DERR_INVALIDCALL;
5448 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5450 if (resinfo)
5452 LPVOID buffer;
5453 HRESULT ret;
5454 DWORD size;
5456 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5458 if (FAILED(ret))
5459 return D3DXERR_INVALIDDATA;
5461 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5464 return D3DXERR_INVALIDDATA;
5467 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5468 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5469 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5471 HRSRC resinfo;
5473 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5475 if (!device)
5476 return D3DERR_INVALIDCALL;
5478 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5480 if (resinfo)
5482 LPVOID buffer;
5483 HRESULT ret;
5484 DWORD size;
5486 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5488 if (FAILED(ret))
5489 return D3DXERR_INVALIDDATA;
5491 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5494 return D3DXERR_INVALIDDATA;
5497 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5498 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5499 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5501 TRACE("(void): relay\n");
5502 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5505 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5506 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5507 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5509 TRACE("(void): relay\n");
5510 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5513 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5514 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5516 LPVOID buffer;
5517 HRESULT ret;
5518 DWORD size;
5520 TRACE("(%s): relay\n", debugstr_w(srcfile));
5522 if (!srcfile)
5523 return D3DERR_INVALIDCALL;
5525 ret = map_view_of_file(srcfile, &buffer, &size);
5527 if (FAILED(ret))
5528 return D3DXERR_INVALIDDATA;
5530 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5531 UnmapViewOfFile(buffer);
5533 return ret;
5536 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5537 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5539 LPWSTR srcfileW;
5540 HRESULT ret;
5541 DWORD len;
5543 TRACE("(void): relay\n");
5545 if (!srcfile)
5546 return D3DERR_INVALIDCALL;
5548 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5549 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5550 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5552 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5553 HeapFree(GetProcessHeap(), 0, srcfileW);
5555 return ret;
5558 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5559 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5561 HRSRC resinfo;
5563 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5565 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5567 if (resinfo)
5569 LPVOID buffer;
5570 HRESULT ret;
5571 DWORD size;
5573 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5575 if (FAILED(ret))
5576 return D3DXERR_INVALIDDATA;
5578 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5581 return D3DXERR_INVALIDDATA;
5584 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5585 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5587 HRSRC resinfo;
5589 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5591 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5593 if (resinfo)
5595 LPVOID buffer;
5596 HRESULT ret;
5597 DWORD size;
5599 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5601 if (FAILED(ret))
5602 return D3DXERR_INVALIDDATA;
5604 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5607 return D3DXERR_INVALIDDATA;