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
20 #include "wine/port.h"
21 #include "wine/debug.h"
22 #include "wine/unicode.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;
78 enum SHADER_CONSTANT_TYPE
100 D3DXPARAMETER_CLASS class;
101 D3DXPARAMETER_TYPE type;
105 UINT annotation_count;
110 D3DXHANDLE *annotation_handles;
111 D3DXHANDLE *member_handles;
118 enum STATE_TYPE type;
119 D3DXHANDLE parameter;
125 struct d3dx_state *states;
132 UINT annotation_count;
134 struct d3dx_state *states;
135 D3DXHANDLE *annotation_handles;
138 struct d3dx_technique
142 UINT annotation_count;
144 D3DXHANDLE *annotation_handles;
145 D3DXHANDLE *pass_handles;
148 struct ID3DXBaseEffectImpl
150 ID3DXBaseEffect ID3DXBaseEffect_iface;
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;
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;
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);
192 enum STATE_CLASS class;
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"},
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"},
321 {SC_UNKNOWN, 0, "UNKNOWN"},
323 {SC_NPATCHMODE, 0, "NPatchMode"},
325 {SC_UNKNOWN, 0, "UNKNOWN"},
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"},
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"},
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 */
352 {SC_LIGHTENABLE, 0, "LightEnable"},
354 {SC_VERTEXSHADER, 0, "Vertexshader"},
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"},
375 {SC_TEXTURE, 0, "Texture"},
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"},
391 {SC_SETSAMPLER, 0, "Sampler"},
394 static inline void read_dword(const char **ptr, DWORD *d)
396 memcpy(d, *ptr, sizeof(*d));
400 static void skip_dword_unknown(const char **ptr, unsigned int count)
405 FIXME("Skipping %u unknown DWORDs:\n", count);
406 for (i = 0; i < count; ++i)
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)
447 for (i = 0; i < base->technique_count; ++i)
449 if (base->technique_handles[i] == technique)
451 return get_technique_struct(technique);
458 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
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);
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);
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);
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);
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);
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);
562 static inline struct d3dx_parameter *get_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
564 struct d3dx_parameter *param = is_valid_parameter(base, parameter);
566 if (!param) param = get_parameter_by_name(base, NULL, parameter);
571 static void free_state(struct d3dx_state *state)
573 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
576 static void free_sampler(struct d3dx_sampler *sampler)
580 for (i = 0; i < sampler->state_count; ++i)
582 free_state(&sampler->states[i]);
584 HeapFree(GetProcessHeap(), 0, sampler->states);
587 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
589 free_parameter_state(handle, element, child, ST_CONSTANT);
592 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
595 struct d3dx_parameter *param = get_parameter_struct(handle);
597 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
598 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
605 if (param->annotation_handles)
607 for (i = 0; i < param->annotation_count; ++i)
609 free_parameter(param->annotation_handles[i], FALSE, FALSE);
611 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
614 if (param->member_handles)
618 if (param->element_count) count = param->element_count;
619 else count = param->member_count;
621 for (i = 0; i < count; ++i)
623 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
625 HeapFree(GetProcessHeap(), 0, param->member_handles);
628 if (param->class == D3DXPC_OBJECT && !param->element_count)
633 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
634 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
638 case D3DXPT_TEXTURE1D:
639 case D3DXPT_TEXTURE2D:
640 case D3DXPT_TEXTURE3D:
641 case D3DXPT_TEXTURECUBE:
642 case D3DXPT_PIXELSHADER:
643 case D3DXPT_VERTEXSHADER:
644 if (st == ST_CONSTANT)
646 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
650 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
652 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
656 case D3DXPT_SAMPLER1D:
657 case D3DXPT_SAMPLER2D:
658 case D3DXPT_SAMPLER3D:
659 case D3DXPT_SAMPLERCUBE:
660 if (st == ST_CONSTANT)
662 free_sampler((struct d3dx_sampler *)param->data);
666 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
668 /* samplers have always own data, so free that */
669 HeapFree(GetProcessHeap(), 0, param->data);
673 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
681 if (st != ST_CONSTANT)
683 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
685 HeapFree(GetProcessHeap(), 0, param->data);
689 /* only the parent has to release name and semantic */
692 HeapFree(GetProcessHeap(), 0, param->name);
693 HeapFree(GetProcessHeap(), 0, param->semantic);
696 HeapFree(GetProcessHeap(), 0, param);
699 static void free_pass(D3DXHANDLE handle)
702 struct d3dx_pass *pass = get_pass_struct(handle);
704 TRACE("Free pass %p\n", pass);
711 if (pass->annotation_handles)
713 for (i = 0; i < pass->annotation_count; ++i)
715 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
717 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
722 for (i = 0; i < pass->state_count; ++i)
724 free_state(&pass->states[i]);
726 HeapFree(GetProcessHeap(), 0, pass->states);
729 HeapFree(GetProcessHeap(), 0, pass->name);
730 HeapFree(GetProcessHeap(), 0, pass);
733 static void free_technique(D3DXHANDLE handle)
736 struct d3dx_technique *technique = get_technique_struct(handle);
738 TRACE("Free technique %p\n", technique);
745 if (technique->annotation_handles)
747 for (i = 0; i < technique->annotation_count; ++i)
749 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
751 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
754 if (technique->pass_handles)
756 for (i = 0; i < technique->pass_count; ++i)
758 free_pass(technique->pass_handles[i]);
760 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
763 HeapFree(GetProcessHeap(), 0, technique->name);
764 HeapFree(GetProcessHeap(), 0, technique);
767 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
771 TRACE("Free base effect %p\n", base);
773 if (base->parameter_handles)
775 for (i = 0; i < base->parameter_count; ++i)
777 free_parameter(base->parameter_handles[i], FALSE, FALSE);
779 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
782 if (base->technique_handles)
784 for (i = 0; i < base->technique_count; ++i)
786 free_technique(base->technique_handles[i]);
788 HeapFree(GetProcessHeap(), 0, base->technique_handles);
792 static void free_effect(struct ID3DXEffectImpl *effect)
794 TRACE("Free effect %p\n", effect);
796 if (effect->base_effect)
798 effect->base_effect->lpVtbl->Release(effect->base_effect);
803 effect->pool->lpVtbl->Release(effect->pool);
808 IUnknown_Release(effect->manager);
811 IDirect3DDevice9_Release(effect->device);
814 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
816 TRACE("Free effect compiler %p\n", compiler);
818 if (compiler->base_effect)
820 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
824 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
844 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
851 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
871 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
878 static inline BOOL get_bool(void *data)
880 return (*(DWORD *)data) ? TRUE : FALSE;
883 static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector)
885 vector->x = get_float(param->type, (float *)param->data);
886 vector->y = param->columns > 1 ? get_float(param->type, (float *)param->data + 1) : 0.0f;
887 vector->z = param->columns > 2 ? get_float(param->type, (float *)param->data + 2) : 0.0f;
888 vector->w = param->columns > 3 ? get_float(param->type, (float *)param->data + 3) : 0.0f;
891 static void get_matrix(struct d3dx_parameter *param, D3DXMATRIX *matrix)
895 for (i = 0; i < 4; ++i)
897 for (k = 0; k < 4; ++k)
899 if ((i < param->rows) && (k < param->columns))
900 matrix->m[i][k] = get_float(param->type, (float *)param->data + i * param->columns + k);
902 matrix->m[i][k] = 0.0f;
907 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
910 struct d3dx_parameter *temp_parameter;
913 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
915 if (!name || !*name) return parameter;
917 element = atoi(name);
918 part = strchr(name, ']') + 1;
920 if (parameter->element_count > element)
922 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
927 return get_parameter_by_name(NULL, temp_parameter, part);
930 return get_parameter_annotation_by_name(temp_parameter, part);
933 TRACE("Returning parameter %p\n", temp_parameter);
934 return temp_parameter;
937 FIXME("Unhandled case \"%c\"\n", *--part);
942 TRACE("Parameter not found\n");
946 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
949 struct d3dx_parameter *temp_parameter;
952 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
954 if (!name || !*name) return parameter;
956 length = strcspn( name, "[.@" );
957 part = name + length;
959 for (i = 0; i < parameter->annotation_count; ++i)
961 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
963 if (!strcmp(temp_parameter->name, name))
965 TRACE("Returning parameter %p\n", temp_parameter);
966 return temp_parameter;
968 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
973 return get_parameter_by_name(NULL, temp_parameter, part);
976 return get_parameter_element_by_name(temp_parameter, part);
979 FIXME("Unhandled case \"%c\"\n", *--part);
985 TRACE("Parameter not found\n");
989 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
990 struct d3dx_parameter *parameter, LPCSTR name)
992 UINT i, count, length;
993 struct d3dx_parameter *temp_parameter;
997 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
999 if (!name || !*name) return parameter;
1003 count = base->parameter_count;
1004 handles = base->parameter_handles;
1008 count = parameter->member_count;
1009 handles = parameter->member_handles;
1012 length = strcspn( name, "[.@" );
1013 part = name + length;
1015 for (i = 0; i < count; i++)
1017 temp_parameter = get_parameter_struct(handles[i]);
1019 if (!strcmp(temp_parameter->name, name))
1021 TRACE("Returning parameter %p\n", temp_parameter);
1022 return temp_parameter;
1024 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1029 return get_parameter_by_name(NULL, temp_parameter, part);
1032 return get_parameter_annotation_by_name(temp_parameter, part);
1035 return get_parameter_element_by_name(temp_parameter, part);
1038 FIXME("Unhandled case \"%c\"\n", *--part);
1044 TRACE("Parameter not found\n");
1048 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1050 return (0xfeff0000 | ((major) << 8) | (minor));
1053 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1055 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1058 /*** IUnknown methods ***/
1059 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1061 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1063 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1065 if (IsEqualGUID(riid, &IID_IUnknown) ||
1066 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1068 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1073 ERR("Interface %s not found\n", debugstr_guid(riid));
1075 return E_NOINTERFACE;
1078 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1080 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1082 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1084 return InterlockedIncrement(&This->ref);
1087 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1089 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1090 ULONG ref = InterlockedDecrement(&This->ref);
1092 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1096 free_base_effect(This);
1097 HeapFree(GetProcessHeap(), 0, This);
1103 /*** ID3DXBaseEffect methods ***/
1104 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1106 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1108 FIXME("iface %p, desc %p partial stub\n", This, desc);
1112 WARN("Invalid argument specified.\n");
1113 return D3DERR_INVALIDCALL;
1116 /* Todo: add creator and function count */
1117 desc->Creator = NULL;
1118 desc->Functions = 0;
1119 desc->Parameters = This->parameter_count;
1120 desc->Techniques = This->technique_count;
1125 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1127 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1128 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1130 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1132 if (!desc || !param)
1134 WARN("Invalid argument specified.\n");
1135 return D3DERR_INVALIDCALL;
1138 desc->Name = param->name;
1139 desc->Semantic = param->semantic;
1140 desc->Class = param->class;
1141 desc->Type = param->type;
1142 desc->Rows = param->rows;
1143 desc->Columns = param->columns;
1144 desc->Elements = param->element_count;
1145 desc->Annotations = param->annotation_count;
1146 desc->StructMembers = param->member_count;
1147 desc->Flags = param->flags;
1148 desc->Bytes = param->bytes;
1153 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1155 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1156 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1158 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1162 WARN("Invalid argument specified.\n");
1163 return D3DERR_INVALIDCALL;
1166 desc->Name = tech->name;
1167 desc->Passes = tech->pass_count;
1168 desc->Annotations = tech->annotation_count;
1173 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1175 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1176 struct d3dx_pass *p = is_valid_pass(This, pass);
1178 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1182 WARN("Invalid argument specified.\n");
1183 return D3DERR_INVALIDCALL;
1186 desc->Name = p->name;
1187 desc->Annotations = p->annotation_count;
1189 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1190 desc->pVertexShaderFunction = NULL;
1191 desc->pPixelShaderFunction = NULL;
1196 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1198 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1200 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1205 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1207 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1208 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1210 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1214 if (index < This->parameter_count)
1216 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1217 return This->parameter_handles[index];
1222 if (param && !param->element_count && index < param->member_count)
1224 TRACE("Returning parameter %p\n", param->member_handles[index]);
1225 return param->member_handles[index];
1229 WARN("Invalid argument specified.\n");
1234 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1236 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1237 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1240 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1244 handle = get_parameter_handle(param);
1245 TRACE("Returning parameter %p\n", handle);
1249 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1250 TRACE("Returning parameter %p\n", handle);
1255 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1257 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1258 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1259 struct d3dx_parameter *temp_param;
1262 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1266 for (i = 0; i < This->parameter_count; ++i)
1268 temp_param = get_parameter_struct(This->parameter_handles[i]);
1270 if (!temp_param->semantic)
1274 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1275 return This->parameter_handles[i];
1280 if (!strcasecmp(temp_param->semantic, semantic))
1282 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1283 return This->parameter_handles[i];
1289 for (i = 0; i < param->member_count; ++i)
1291 temp_param = get_parameter_struct(param->member_handles[i]);
1293 if (!temp_param->semantic)
1297 TRACE("Returning parameter %p\n", param->member_handles[i]);
1298 return param->member_handles[i];
1303 if (!strcasecmp(temp_param->semantic, semantic))
1305 TRACE("Returning parameter %p\n", param->member_handles[i]);
1306 return param->member_handles[i];
1311 WARN("Invalid argument specified\n");
1316 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1318 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1319 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1321 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1325 if (index < This->parameter_count)
1327 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1328 return This->parameter_handles[index];
1333 if (index < param->element_count)
1335 TRACE("Returning parameter %p\n", param->member_handles[index]);
1336 return param->member_handles[index];
1340 WARN("Invalid argument specified\n");
1345 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1347 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1349 TRACE("iface %p, index %u\n", This, index);
1351 if (index >= This->technique_count)
1353 WARN("Invalid argument specified.\n");
1357 TRACE("Returning technique %p\n", This->technique_handles[index]);
1359 return This->technique_handles[index];
1362 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1364 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1367 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1371 WARN("Invalid argument specified.\n");
1375 for (i = 0; i < This->technique_count; ++i)
1377 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1379 if (!strcmp(tech->name, name))
1381 TRACE("Returning technique %p\n", This->technique_handles[i]);
1382 return This->technique_handles[i];
1386 WARN("Invalid argument specified.\n");
1391 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1393 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1394 struct d3dx_technique *tech = is_valid_technique(This, technique);
1396 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1398 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1400 if (tech && index < tech->pass_count)
1402 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1403 return tech->pass_handles[index];
1406 WARN("Invalid argument specified.\n");
1411 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1413 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1414 struct d3dx_technique *tech = is_valid_technique(This, technique);
1416 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1418 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1424 for (i = 0; i < tech->pass_count; ++i)
1426 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1428 if (!strcmp(pass->name, name))
1430 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1431 return tech->pass_handles[i];
1436 WARN("Invalid argument specified.\n");
1441 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1443 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1445 FIXME("iface %p, index %u stub\n", This, index);
1450 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1452 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1454 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1459 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1461 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1462 struct d3dx_parameter *param = get_valid_parameter(This, object);
1463 struct d3dx_pass *pass = is_valid_pass(This, object);
1464 struct d3dx_technique *technique = is_valid_technique(This, object);
1465 UINT annotation_count = 0;
1466 D3DXHANDLE *annotation_handles = NULL;
1468 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1472 annotation_count = pass->annotation_count;
1473 annotation_handles = pass->annotation_handles;
1477 annotation_count = technique->annotation_count;
1478 annotation_handles = technique->annotation_handles;
1482 annotation_count = param->annotation_count;
1483 annotation_handles = param->annotation_handles;
1485 /* Todo: add funcs */
1487 if (index < annotation_count)
1489 TRACE("Returning parameter %p\n", annotation_handles[index]);
1490 return annotation_handles[index];
1493 WARN("Invalid argument specified\n");
1498 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1500 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1501 struct d3dx_parameter *param = get_valid_parameter(This, object);
1502 struct d3dx_pass *pass = is_valid_pass(This, object);
1503 struct d3dx_technique *technique = is_valid_technique(This, object);
1504 UINT annotation_count = 0, i;
1505 D3DXHANDLE *annotation_handles = NULL;
1507 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1511 WARN("Invalid argument specified\n");
1517 annotation_count = pass->annotation_count;
1518 annotation_handles = pass->annotation_handles;
1522 annotation_count = technique->annotation_count;
1523 annotation_handles = technique->annotation_handles;
1527 annotation_count = param->annotation_count;
1528 annotation_handles = param->annotation_handles;
1530 /* Todo: add funcs */
1532 for (i = 0; i < annotation_count; i++)
1534 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1536 if (!strcmp(anno->name, name))
1538 TRACE("Returning parameter %p\n", anno);
1539 return get_parameter_handle(anno);
1543 WARN("Invalid argument specified\n");
1548 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1550 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1552 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1557 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1559 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1560 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1562 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1566 WARN("Invalid parameter %p specified\n", parameter);
1567 return D3DERR_INVALIDCALL;
1570 /* samplers don't touch data */
1571 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1572 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1573 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1575 TRACE("Sampler: returning E_FAIL\n");
1579 if (data && param->bytes <= bytes)
1581 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1583 switch (param->type)
1592 case D3DXPT_VERTEXSHADER:
1593 case D3DXPT_PIXELSHADER:
1594 case D3DXPT_TEXTURE:
1595 case D3DXPT_TEXTURE1D:
1596 case D3DXPT_TEXTURE2D:
1597 case D3DXPT_TEXTURE3D:
1598 case D3DXPT_TEXTURECUBE:
1602 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1604 IUnknown *unk = ((IUnknown **)param->data)[i];
1605 if (unk) IUnknown_AddRef(unk);
1611 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1615 TRACE("Copy %u bytes\n", param->bytes);
1616 memcpy(data, param->data, param->bytes);
1620 WARN("Invalid argument specified\n");
1622 return D3DERR_INVALIDCALL;
1625 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1627 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1629 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1634 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1636 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1637 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1639 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1641 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1643 *b = get_bool(param->data);
1644 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1648 WARN("Invalid argument specified\n");
1650 return D3DERR_INVALIDCALL;
1653 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1655 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1657 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1662 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1664 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1665 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1667 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1669 if (b && param && (param->class == D3DXPC_SCALAR
1670 || param->class == D3DXPC_VECTOR
1671 || param->class == D3DXPC_MATRIX_ROWS
1672 || param->class == D3DXPC_MATRIX_COLUMNS))
1674 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1676 for (i = 0; i < size; ++i)
1678 b[i] = get_bool((DWORD *)param->data + i);
1683 WARN("Invalid argument specified\n");
1685 return D3DERR_INVALIDCALL;
1688 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1690 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1692 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1697 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1699 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1700 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1702 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1704 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1706 *n = get_int(param->type, param->data);
1707 TRACE("Returning %i\n", *n);
1711 WARN("Invalid argument specified\n");
1713 return D3DERR_INVALIDCALL;
1716 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1718 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1720 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1725 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1727 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1728 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1730 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1732 if (n && param && (param->class == D3DXPC_SCALAR
1733 || param->class == D3DXPC_VECTOR
1734 || param->class == D3DXPC_MATRIX_ROWS
1735 || param->class == D3DXPC_MATRIX_COLUMNS))
1737 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1739 for (i = 0; i < size; ++i)
1741 n[i] = get_int(param->type, (DWORD *)param->data + i);
1746 WARN("Invalid argument specified\n");
1748 return D3DERR_INVALIDCALL;
1751 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1753 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1755 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1760 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1762 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1763 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1765 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1767 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1769 *f = get_float(param->type, (DWORD *)param->data);
1770 TRACE("Returning %f\n", *f);
1774 WARN("Invalid argument specified\n");
1776 return D3DERR_INVALIDCALL;
1779 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1781 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1783 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1788 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1790 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1791 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1793 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
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);
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);
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);
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);
1841 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1843 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1844 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1846 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
1848 if (!count) return D3D_OK;
1850 if (vector && param && count <= param->element_count)
1854 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1856 switch (param->class)
1859 for (i = 0; i < count; ++i)
1861 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
1866 case D3DXPC_MATRIX_ROWS:
1872 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1877 WARN("Invalid argument specified\n");
1879 return D3DERR_INVALIDCALL;
1882 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1884 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1886 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1891 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1893 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1894 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1896 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
1898 if (matrix && param && !param->element_count)
1900 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1902 switch (param->class)
1904 case D3DXPC_MATRIX_ROWS:
1905 get_matrix(param, matrix);
1915 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1920 WARN("Invalid argument specified\n");
1922 return D3DERR_INVALIDCALL;
1925 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1927 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1929 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1934 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1936 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1938 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1943 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1945 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1947 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1952 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1954 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1956 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1961 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1963 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1965 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1970 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1972 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1973 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1976 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
1978 if (matrix && param && !param->element_count)
1980 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1982 switch (param->class)
1986 get_matrix(param, matrix);
1989 case D3DXPC_MATRIX_ROWS:
1990 get_matrix(param, &m);
1991 D3DXMatrixTranspose(matrix, &m);
1999 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2004 WARN("Invalid argument specified\n");
2006 return D3DERR_INVALIDCALL;
2009 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2011 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2013 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2018 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2020 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2022 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2027 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2029 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2031 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2036 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2038 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2040 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2045 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2047 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2049 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2054 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2056 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2057 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2059 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2061 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2063 *string = *(LPCSTR *)param->data;
2064 TRACE("Returning %s\n", debugstr_a(*string));
2068 WARN("Invalid argument specified\n");
2070 return D3DERR_INVALIDCALL;
2073 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2075 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2076 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2078 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2080 if (texture && param && !param->element_count &&
2081 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2082 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2083 || param->type == D3DXPT_TEXTURECUBE))
2085 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2087 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2088 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2090 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2095 WARN("Invalid argument specified\n");
2097 return D3DERR_INVALIDCALL;
2100 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2102 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2103 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2105 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2107 if (texture && param && !param->element_count &&
2108 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2109 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2110 || param->type == D3DXPT_TEXTURECUBE))
2112 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2113 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2114 TRACE("Returning %p\n", *texture);
2118 WARN("Invalid argument specified\n");
2120 return D3DERR_INVALIDCALL;
2123 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2125 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2126 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2128 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2130 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2132 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2133 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2134 TRACE("Returning %p\n", *pshader);
2138 WARN("Invalid argument specified\n");
2140 return D3DERR_INVALIDCALL;
2143 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2145 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2146 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2148 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2150 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2152 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2153 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2154 TRACE("Returning %p\n", *vshader);
2158 WARN("Invalid argument specified\n");
2160 return D3DERR_INVALIDCALL;
2163 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2165 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2167 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2172 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2174 /*** IUnknown methods ***/
2175 ID3DXBaseEffectImpl_QueryInterface,
2176 ID3DXBaseEffectImpl_AddRef,
2177 ID3DXBaseEffectImpl_Release,
2178 /*** ID3DXBaseEffect methods ***/
2179 ID3DXBaseEffectImpl_GetDesc,
2180 ID3DXBaseEffectImpl_GetParameterDesc,
2181 ID3DXBaseEffectImpl_GetTechniqueDesc,
2182 ID3DXBaseEffectImpl_GetPassDesc,
2183 ID3DXBaseEffectImpl_GetFunctionDesc,
2184 ID3DXBaseEffectImpl_GetParameter,
2185 ID3DXBaseEffectImpl_GetParameterByName,
2186 ID3DXBaseEffectImpl_GetParameterBySemantic,
2187 ID3DXBaseEffectImpl_GetParameterElement,
2188 ID3DXBaseEffectImpl_GetTechnique,
2189 ID3DXBaseEffectImpl_GetTechniqueByName,
2190 ID3DXBaseEffectImpl_GetPass,
2191 ID3DXBaseEffectImpl_GetPassByName,
2192 ID3DXBaseEffectImpl_GetFunction,
2193 ID3DXBaseEffectImpl_GetFunctionByName,
2194 ID3DXBaseEffectImpl_GetAnnotation,
2195 ID3DXBaseEffectImpl_GetAnnotationByName,
2196 ID3DXBaseEffectImpl_SetValue,
2197 ID3DXBaseEffectImpl_GetValue,
2198 ID3DXBaseEffectImpl_SetBool,
2199 ID3DXBaseEffectImpl_GetBool,
2200 ID3DXBaseEffectImpl_SetBoolArray,
2201 ID3DXBaseEffectImpl_GetBoolArray,
2202 ID3DXBaseEffectImpl_SetInt,
2203 ID3DXBaseEffectImpl_GetInt,
2204 ID3DXBaseEffectImpl_SetIntArray,
2205 ID3DXBaseEffectImpl_GetIntArray,
2206 ID3DXBaseEffectImpl_SetFloat,
2207 ID3DXBaseEffectImpl_GetFloat,
2208 ID3DXBaseEffectImpl_SetFloatArray,
2209 ID3DXBaseEffectImpl_GetFloatArray,
2210 ID3DXBaseEffectImpl_SetVector,
2211 ID3DXBaseEffectImpl_GetVector,
2212 ID3DXBaseEffectImpl_SetVectorArray,
2213 ID3DXBaseEffectImpl_GetVectorArray,
2214 ID3DXBaseEffectImpl_SetMatrix,
2215 ID3DXBaseEffectImpl_GetMatrix,
2216 ID3DXBaseEffectImpl_SetMatrixArray,
2217 ID3DXBaseEffectImpl_GetMatrixArray,
2218 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2219 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2220 ID3DXBaseEffectImpl_SetMatrixTranspose,
2221 ID3DXBaseEffectImpl_GetMatrixTranspose,
2222 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2223 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2224 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2225 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2226 ID3DXBaseEffectImpl_SetString,
2227 ID3DXBaseEffectImpl_GetString,
2228 ID3DXBaseEffectImpl_SetTexture,
2229 ID3DXBaseEffectImpl_GetTexture,
2230 ID3DXBaseEffectImpl_GetPixelShader,
2231 ID3DXBaseEffectImpl_GetVertexShader,
2232 ID3DXBaseEffectImpl_SetArrayRange,
2235 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2237 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2240 /*** IUnknown methods ***/
2241 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2243 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2245 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2247 if (IsEqualGUID(riid, &IID_IUnknown) ||
2248 IsEqualGUID(riid, &IID_ID3DXEffect))
2250 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2255 ERR("Interface %s not found\n", debugstr_guid(riid));
2257 return E_NOINTERFACE;
2260 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2262 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2264 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2266 return InterlockedIncrement(&This->ref);
2269 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2271 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2272 ULONG ref = InterlockedDecrement(&This->ref);
2274 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2279 HeapFree(GetProcessHeap(), 0, This);
2285 /*** ID3DXBaseEffect methods ***/
2286 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2288 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2289 ID3DXBaseEffect *base = This->base_effect;
2291 TRACE("Forward iface %p, base %p\n", This, base);
2293 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2296 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2298 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2299 ID3DXBaseEffect *base = This->base_effect;
2301 TRACE("Forward iface %p, base %p\n", This, base);
2303 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2306 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2308 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2309 ID3DXBaseEffect *base = This->base_effect;
2311 TRACE("Forward iface %p, base %p\n", This, base);
2313 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2316 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2318 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2319 ID3DXBaseEffect *base = This->base_effect;
2321 TRACE("Forward iface %p, base %p\n", This, base);
2323 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2326 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2328 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2329 ID3DXBaseEffect *base = This->base_effect;
2331 TRACE("Forward iface %p, base %p\n", This, base);
2333 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2336 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2338 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2339 ID3DXBaseEffect *base = This->base_effect;
2341 TRACE("Forward iface %p, base %p\n", This, base);
2343 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2346 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2348 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2349 ID3DXBaseEffect *base = This->base_effect;
2351 TRACE("Forward iface %p, base %p\n", This, base);
2353 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2356 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2358 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2359 ID3DXBaseEffect *base = This->base_effect;
2361 TRACE("Forward iface %p, base %p\n", This, base);
2363 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2366 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2368 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2369 ID3DXBaseEffect *base = This->base_effect;
2371 TRACE("Forward iface %p, base %p\n", This, base);
2373 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2376 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2378 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2379 ID3DXBaseEffect *base = This->base_effect;
2381 TRACE("Forward iface %p, base %p\n", This, base);
2383 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2386 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2388 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2389 ID3DXBaseEffect *base = This->base_effect;
2391 TRACE("Forward iface %p, base %p\n", This, base);
2393 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2396 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2398 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2399 ID3DXBaseEffect *base = This->base_effect;
2401 TRACE("Forward iface %p, base %p\n", This, base);
2403 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2406 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2408 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2409 ID3DXBaseEffect *base = This->base_effect;
2411 TRACE("Forward iface %p, base %p\n", This, base);
2413 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2416 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2418 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2419 ID3DXBaseEffect *base = This->base_effect;
2421 TRACE("Forward iface %p, base %p\n", This, base);
2423 return ID3DXBaseEffectImpl_GetFunction(base, index);
2426 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2428 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2429 ID3DXBaseEffect *base = This->base_effect;
2431 TRACE("Forward iface %p, base %p\n", This, base);
2433 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2436 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2438 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2439 ID3DXBaseEffect *base = This->base_effect;
2441 TRACE("Forward iface %p, base %p\n", This, base);
2443 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2446 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2448 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2449 ID3DXBaseEffect *base = This->base_effect;
2451 TRACE("Forward iface %p, base %p\n", This, base);
2453 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2456 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2458 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2459 ID3DXBaseEffect *base = This->base_effect;
2461 TRACE("Forward iface %p, base %p\n", This, base);
2463 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2466 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2468 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2469 ID3DXBaseEffect *base = This->base_effect;
2471 TRACE("Forward iface %p, base %p\n", This, base);
2473 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2476 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2478 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2479 ID3DXBaseEffect *base = This->base_effect;
2481 TRACE("Forward iface %p, base %p\n", This, base);
2483 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2486 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2488 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2489 ID3DXBaseEffect *base = This->base_effect;
2491 TRACE("Forward iface %p, base %p\n", This, base);
2493 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2496 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2498 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2499 ID3DXBaseEffect *base = This->base_effect;
2501 TRACE("Forward iface %p, base %p\n", This, base);
2503 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2506 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2508 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2509 ID3DXBaseEffect *base = This->base_effect;
2511 TRACE("Forward iface %p, base %p\n", This, base);
2513 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2516 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2518 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2519 ID3DXBaseEffect *base = This->base_effect;
2521 TRACE("Forward iface %p, base %p\n", This, base);
2523 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2526 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2528 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2529 ID3DXBaseEffect *base = This->base_effect;
2531 TRACE("Forward iface %p, base %p\n", This, base);
2533 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2536 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2538 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2539 ID3DXBaseEffect *base = This->base_effect;
2541 TRACE("Forward iface %p, base %p\n", This, base);
2543 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2546 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2548 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2549 ID3DXBaseEffect *base = This->base_effect;
2551 TRACE("Forward iface %p, base %p\n", This, base);
2553 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2556 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2558 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2559 ID3DXBaseEffect *base = This->base_effect;
2561 TRACE("Forward iface %p, base %p\n", This, base);
2563 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2566 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2568 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2569 ID3DXBaseEffect *base = This->base_effect;
2571 TRACE("Forward iface %p, base %p\n", This, base);
2573 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2576 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2578 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2579 ID3DXBaseEffect *base = This->base_effect;
2581 TRACE("Forward iface %p, base %p\n", This, base);
2583 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2586 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2588 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2589 ID3DXBaseEffect *base = This->base_effect;
2591 TRACE("Forward iface %p, base %p\n", This, base);
2593 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2596 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2598 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2599 ID3DXBaseEffect *base = This->base_effect;
2601 TRACE("Forward iface %p, base %p\n", This, base);
2603 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2606 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2608 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2609 ID3DXBaseEffect *base = This->base_effect;
2611 TRACE("Forward iface %p, base %p\n", This, base);
2613 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2616 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2618 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2619 ID3DXBaseEffect *base = This->base_effect;
2621 TRACE("Forward iface %p, base %p\n", This, base);
2623 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2626 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2628 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2629 ID3DXBaseEffect *base = This->base_effect;
2631 TRACE("Forward iface %p, base %p\n", This, base);
2633 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2636 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2638 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2639 ID3DXBaseEffect *base = This->base_effect;
2641 TRACE("Forward iface %p, base %p\n", This, base);
2643 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2646 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2648 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2649 ID3DXBaseEffect *base = This->base_effect;
2651 TRACE("Forward iface %p, base %p\n", This, base);
2653 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2656 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2658 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2659 ID3DXBaseEffect *base = This->base_effect;
2661 TRACE("Forward iface %p, base %p\n", This, base);
2663 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2666 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2668 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2669 ID3DXBaseEffect *base = This->base_effect;
2671 TRACE("Forward iface %p, base %p\n", This, base);
2673 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2676 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2678 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2679 ID3DXBaseEffect *base = This->base_effect;
2681 TRACE("Forward iface %p, base %p\n", This, base);
2683 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2686 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2688 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2689 ID3DXBaseEffect *base = This->base_effect;
2691 TRACE("Forward iface %p, base %p\n", This, base);
2693 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2696 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2698 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2699 ID3DXBaseEffect *base = This->base_effect;
2701 TRACE("Forward iface %p, base %p\n", This, base);
2703 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2706 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2708 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2709 ID3DXBaseEffect *base = This->base_effect;
2711 TRACE("Forward iface %p, base %p\n", This, base);
2713 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2716 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2718 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2719 ID3DXBaseEffect *base = This->base_effect;
2721 TRACE("Forward iface %p, base %p\n", This, base);
2723 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2726 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2728 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2729 ID3DXBaseEffect *base = This->base_effect;
2731 TRACE("Forward iface %p, base %p\n", This, base);
2733 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2736 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2738 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2739 ID3DXBaseEffect *base = This->base_effect;
2741 TRACE("Forward iface %p, base %p\n", This, base);
2743 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2746 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2748 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2749 ID3DXBaseEffect *base = This->base_effect;
2751 TRACE("Forward iface %p, base %p\n", This, base);
2753 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2756 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2758 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2759 ID3DXBaseEffect *base = This->base_effect;
2761 TRACE("Forward iface %p, base %p\n", This, base);
2763 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2766 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2768 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2769 ID3DXBaseEffect *base = This->base_effect;
2771 TRACE("Forward iface %p, base %p\n", This, base);
2773 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2776 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2778 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2779 ID3DXBaseEffect *base = This->base_effect;
2781 TRACE("Forward iface %p, base %p\n", This, base);
2783 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2786 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2788 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2789 ID3DXBaseEffect *base = This->base_effect;
2791 TRACE("Forward iface %p, base %p\n", This, base);
2793 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2796 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2798 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2799 ID3DXBaseEffect *base = This->base_effect;
2801 TRACE("Forward iface %p, base %p\n", This, base);
2803 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2806 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2808 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2809 ID3DXBaseEffect *base = This->base_effect;
2811 TRACE("Forward iface %p, base %p\n", This, base);
2813 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2816 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2818 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2819 ID3DXBaseEffect *base = This->base_effect;
2821 TRACE("Forward iface %p, base %p\n", This, base);
2823 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2826 /*** ID3DXEffect methods ***/
2827 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2829 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2831 TRACE("iface %p, pool %p\n", This, pool);
2835 WARN("Invalid argument supplied.\n");
2836 return D3DERR_INVALIDCALL;
2841 This->pool->lpVtbl->AddRef(This->pool);
2846 TRACE("Returning pool %p\n", *pool);
2851 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
2853 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2854 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
2855 struct d3dx_technique *tech = is_valid_technique(base, technique);
2857 TRACE("iface %p, technique %p\n", This, technique);
2859 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
2865 for (i = 0; i < base->technique_count; ++i)
2867 struct d3dx_technique *t = get_technique_struct(base->technique_handles[i]);
2871 This->active_technique = get_technique_handle(t);
2872 TRACE("Technique %u (%p)\n", i, tech);
2878 WARN("Invalid argument supplied.\n");
2880 return D3DERR_INVALIDCALL;
2883 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
2885 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2887 TRACE("iface %p\n", This);
2889 return This->active_technique;
2892 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2894 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2896 FIXME("(%p)->(%p): stub\n", This, technique);
2901 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2903 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2905 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2910 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2912 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2914 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2919 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
2921 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2922 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2924 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
2926 if (passes && technique)
2928 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
2930 TRACE("State capturing disabled.\n");
2934 FIXME("State capturing not supported, yet!\n");
2937 *passes = technique->pass_count;
2942 WARN("Invalid argument supplied.\n");
2944 return D3DERR_INVALIDCALL;
2947 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
2949 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2950 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2952 TRACE("iface %p, pass %u\n", This, pass);
2954 if (technique && pass < technique->pass_count && !This->active_pass)
2956 This->active_pass = technique->pass_handles[pass];
2958 FIXME("No states applied, yet!\n");
2963 WARN("Invalid argument supplied.\n");
2965 return D3DERR_INVALIDCALL;
2968 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2970 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2972 FIXME("(%p)->(): stub\n", This);
2977 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
2979 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2981 TRACE("iface %p\n", This);
2983 if (This->active_pass)
2985 This->active_pass = NULL;
2989 WARN("Invalid call.\n");
2991 return D3DERR_INVALIDCALL;
2994 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2996 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2998 FIXME("(%p)->(): stub\n", This);
3003 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3005 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3007 TRACE("iface %p, device %p\n", This, device);
3011 WARN("Invalid argument supplied.\n");
3012 return D3DERR_INVALIDCALL;
3015 IDirect3DDevice9_AddRef(This->device);
3017 *device = This->device;
3019 TRACE("Returning device %p\n", *device);
3024 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3026 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3028 FIXME("(%p)->(): stub\n", This);
3033 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3035 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3037 FIXME("(%p)->(): stub\n", This);
3042 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3044 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3046 TRACE("iface %p, manager %p\n", This, manager);
3048 if (manager) IUnknown_AddRef(manager);
3049 if (This->manager) IUnknown_Release(This->manager);
3051 This->manager = manager;
3056 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3058 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3060 TRACE("iface %p, manager %p\n", This, manager);
3064 WARN("Invalid argument supplied.\n");
3065 return D3DERR_INVALIDCALL;
3068 if (This->manager) IUnknown_AddRef(This->manager);
3069 *manager = This->manager;
3074 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3076 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3078 FIXME("(%p)->(): stub\n", This);
3083 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3085 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3087 FIXME("(%p)->(): stub\n", This);
3092 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3094 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3096 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3101 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3103 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3105 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3110 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3112 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3114 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3119 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3121 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3123 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3128 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3130 /*** IUnknown methods ***/
3131 ID3DXEffectImpl_QueryInterface,
3132 ID3DXEffectImpl_AddRef,
3133 ID3DXEffectImpl_Release,
3134 /*** ID3DXBaseEffect methods ***/
3135 ID3DXEffectImpl_GetDesc,
3136 ID3DXEffectImpl_GetParameterDesc,
3137 ID3DXEffectImpl_GetTechniqueDesc,
3138 ID3DXEffectImpl_GetPassDesc,
3139 ID3DXEffectImpl_GetFunctionDesc,
3140 ID3DXEffectImpl_GetParameter,
3141 ID3DXEffectImpl_GetParameterByName,
3142 ID3DXEffectImpl_GetParameterBySemantic,
3143 ID3DXEffectImpl_GetParameterElement,
3144 ID3DXEffectImpl_GetTechnique,
3145 ID3DXEffectImpl_GetTechniqueByName,
3146 ID3DXEffectImpl_GetPass,
3147 ID3DXEffectImpl_GetPassByName,
3148 ID3DXEffectImpl_GetFunction,
3149 ID3DXEffectImpl_GetFunctionByName,
3150 ID3DXEffectImpl_GetAnnotation,
3151 ID3DXEffectImpl_GetAnnotationByName,
3152 ID3DXEffectImpl_SetValue,
3153 ID3DXEffectImpl_GetValue,
3154 ID3DXEffectImpl_SetBool,
3155 ID3DXEffectImpl_GetBool,
3156 ID3DXEffectImpl_SetBoolArray,
3157 ID3DXEffectImpl_GetBoolArray,
3158 ID3DXEffectImpl_SetInt,
3159 ID3DXEffectImpl_GetInt,
3160 ID3DXEffectImpl_SetIntArray,
3161 ID3DXEffectImpl_GetIntArray,
3162 ID3DXEffectImpl_SetFloat,
3163 ID3DXEffectImpl_GetFloat,
3164 ID3DXEffectImpl_SetFloatArray,
3165 ID3DXEffectImpl_GetFloatArray,
3166 ID3DXEffectImpl_SetVector,
3167 ID3DXEffectImpl_GetVector,
3168 ID3DXEffectImpl_SetVectorArray,
3169 ID3DXEffectImpl_GetVectorArray,
3170 ID3DXEffectImpl_SetMatrix,
3171 ID3DXEffectImpl_GetMatrix,
3172 ID3DXEffectImpl_SetMatrixArray,
3173 ID3DXEffectImpl_GetMatrixArray,
3174 ID3DXEffectImpl_SetMatrixPointerArray,
3175 ID3DXEffectImpl_GetMatrixPointerArray,
3176 ID3DXEffectImpl_SetMatrixTranspose,
3177 ID3DXEffectImpl_GetMatrixTranspose,
3178 ID3DXEffectImpl_SetMatrixTransposeArray,
3179 ID3DXEffectImpl_GetMatrixTransposeArray,
3180 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3181 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3182 ID3DXEffectImpl_SetString,
3183 ID3DXEffectImpl_GetString,
3184 ID3DXEffectImpl_SetTexture,
3185 ID3DXEffectImpl_GetTexture,
3186 ID3DXEffectImpl_GetPixelShader,
3187 ID3DXEffectImpl_GetVertexShader,
3188 ID3DXEffectImpl_SetArrayRange,
3189 /*** ID3DXEffect methods ***/
3190 ID3DXEffectImpl_GetPool,
3191 ID3DXEffectImpl_SetTechnique,
3192 ID3DXEffectImpl_GetCurrentTechnique,
3193 ID3DXEffectImpl_ValidateTechnique,
3194 ID3DXEffectImpl_FindNextValidTechnique,
3195 ID3DXEffectImpl_IsParameterUsed,
3196 ID3DXEffectImpl_Begin,
3197 ID3DXEffectImpl_BeginPass,
3198 ID3DXEffectImpl_CommitChanges,
3199 ID3DXEffectImpl_EndPass,
3200 ID3DXEffectImpl_End,
3201 ID3DXEffectImpl_GetDevice,
3202 ID3DXEffectImpl_OnLostDevice,
3203 ID3DXEffectImpl_OnResetDevice,
3204 ID3DXEffectImpl_SetStateManager,
3205 ID3DXEffectImpl_GetStateManager,
3206 ID3DXEffectImpl_BeginParameterBlock,
3207 ID3DXEffectImpl_EndParameterBlock,
3208 ID3DXEffectImpl_ApplyParameterBlock,
3209 ID3DXEffectImpl_DeleteParameterBlock,
3210 ID3DXEffectImpl_CloneEffect,
3211 ID3DXEffectImpl_SetRawValue
3214 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3216 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3219 /*** IUnknown methods ***/
3220 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3222 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3224 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3226 if (IsEqualGUID(riid, &IID_IUnknown) ||
3227 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3229 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3234 ERR("Interface %s not found\n", debugstr_guid(riid));
3236 return E_NOINTERFACE;
3239 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3241 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3243 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3245 return InterlockedIncrement(&This->ref);
3248 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3250 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3251 ULONG ref = InterlockedDecrement(&This->ref);
3253 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3257 free_effect_compiler(This);
3258 HeapFree(GetProcessHeap(), 0, This);
3264 /*** ID3DXBaseEffect methods ***/
3265 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3267 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3268 ID3DXBaseEffect *base = This->base_effect;
3270 TRACE("Forward iface %p, base %p\n", This, base);
3272 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3275 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3277 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3278 ID3DXBaseEffect *base = This->base_effect;
3280 TRACE("Forward iface %p, base %p\n", This, base);
3282 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3285 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3287 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3288 ID3DXBaseEffect *base = This->base_effect;
3290 TRACE("Forward iface %p, base %p\n", This, base);
3292 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3295 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3297 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3298 ID3DXBaseEffect *base = This->base_effect;
3300 TRACE("Forward iface %p, base %p\n", This, base);
3302 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3305 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3307 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3308 ID3DXBaseEffect *base = This->base_effect;
3310 TRACE("Forward iface %p, base %p\n", This, base);
3312 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3315 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3317 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3318 ID3DXBaseEffect *base = This->base_effect;
3320 TRACE("Forward iface %p, base %p\n", This, base);
3322 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3325 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3327 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3328 ID3DXBaseEffect *base = This->base_effect;
3330 TRACE("Forward iface %p, base %p\n", This, base);
3332 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3335 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3337 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3338 ID3DXBaseEffect *base = This->base_effect;
3340 TRACE("Forward iface %p, base %p\n", This, base);
3342 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3345 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3347 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3348 ID3DXBaseEffect *base = This->base_effect;
3350 TRACE("Forward iface %p, base %p\n", This, base);
3352 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3355 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3357 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3358 ID3DXBaseEffect *base = This->base_effect;
3360 TRACE("Forward iface %p, base %p\n", This, base);
3362 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3365 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3367 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3368 ID3DXBaseEffect *base = This->base_effect;
3370 TRACE("Forward iface %p, base %p\n", This, base);
3372 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3375 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3377 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3378 ID3DXBaseEffect *base = This->base_effect;
3380 TRACE("Forward iface %p, base %p\n", This, base);
3382 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3385 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3387 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3388 ID3DXBaseEffect *base = This->base_effect;
3390 TRACE("Forward iface %p, base %p\n", This, base);
3392 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3395 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3397 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3398 ID3DXBaseEffect *base = This->base_effect;
3400 TRACE("Forward iface %p, base %p\n", This, base);
3402 return ID3DXBaseEffectImpl_GetFunction(base, index);
3405 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3407 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3408 ID3DXBaseEffect *base = This->base_effect;
3410 TRACE("Forward iface %p, base %p\n", This, base);
3412 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3415 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3417 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3418 ID3DXBaseEffect *base = This->base_effect;
3420 TRACE("Forward iface %p, base %p\n", This, base);
3422 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3425 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3427 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3428 ID3DXBaseEffect *base = This->base_effect;
3430 TRACE("Forward iface %p, base %p\n", This, base);
3432 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3435 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3437 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3438 ID3DXBaseEffect *base = This->base_effect;
3440 TRACE("Forward iface %p, base %p\n", This, base);
3442 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3445 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3447 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3448 ID3DXBaseEffect *base = This->base_effect;
3450 TRACE("Forward iface %p, base %p\n", This, base);
3452 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3455 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3457 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3458 ID3DXBaseEffect *base = This->base_effect;
3460 TRACE("Forward iface %p, base %p\n", This, base);
3462 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3465 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3467 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3468 ID3DXBaseEffect *base = This->base_effect;
3470 TRACE("Forward iface %p, base %p\n", This, base);
3472 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3475 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3477 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3478 ID3DXBaseEffect *base = This->base_effect;
3480 TRACE("Forward iface %p, base %p\n", This, base);
3482 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3485 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3487 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3488 ID3DXBaseEffect *base = This->base_effect;
3490 TRACE("Forward iface %p, base %p\n", This, base);
3492 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3495 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3497 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3498 ID3DXBaseEffect *base = This->base_effect;
3500 TRACE("Forward iface %p, base %p\n", This, base);
3502 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3505 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3507 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3508 ID3DXBaseEffect *base = This->base_effect;
3510 TRACE("Forward iface %p, base %p\n", This, base);
3512 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3515 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3517 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3518 ID3DXBaseEffect *base = This->base_effect;
3520 TRACE("Forward iface %p, base %p\n", This, base);
3522 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3525 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3527 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3528 ID3DXBaseEffect *base = This->base_effect;
3530 TRACE("Forward iface %p, base %p\n", This, base);
3532 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3535 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3537 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3538 ID3DXBaseEffect *base = This->base_effect;
3540 TRACE("Forward iface %p, base %p\n", This, base);
3542 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3545 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3547 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3548 ID3DXBaseEffect *base = This->base_effect;
3550 TRACE("Forward iface %p, base %p\n", This, base);
3552 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3555 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3557 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3558 ID3DXBaseEffect *base = This->base_effect;
3560 TRACE("Forward iface %p, base %p\n", This, base);
3562 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3565 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3567 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3568 ID3DXBaseEffect *base = This->base_effect;
3570 TRACE("Forward iface %p, base %p\n", This, base);
3572 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3575 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3577 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3578 ID3DXBaseEffect *base = This->base_effect;
3580 TRACE("Forward iface %p, base %p\n", This, base);
3582 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3585 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3587 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3588 ID3DXBaseEffect *base = This->base_effect;
3590 TRACE("Forward iface %p, base %p\n", This, base);
3592 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3595 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3597 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3598 ID3DXBaseEffect *base = This->base_effect;
3600 TRACE("Forward iface %p, base %p\n", This, base);
3602 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3605 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3607 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3608 ID3DXBaseEffect *base = This->base_effect;
3610 TRACE("Forward iface %p, base %p\n", This, base);
3612 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3615 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3617 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3618 ID3DXBaseEffect *base = This->base_effect;
3620 TRACE("Forward iface %p, base %p\n", This, base);
3622 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3625 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3627 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3628 ID3DXBaseEffect *base = This->base_effect;
3630 TRACE("Forward iface %p, base %p\n", This, base);
3632 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3635 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3637 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3638 ID3DXBaseEffect *base = This->base_effect;
3640 TRACE("Forward iface %p, base %p\n", This, base);
3642 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3645 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3647 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3648 ID3DXBaseEffect *base = This->base_effect;
3650 TRACE("Forward iface %p, base %p\n", This, base);
3652 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3655 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3657 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3658 ID3DXBaseEffect *base = This->base_effect;
3660 TRACE("Forward iface %p, base %p\n", This, base);
3662 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3665 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3667 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3668 ID3DXBaseEffect *base = This->base_effect;
3670 TRACE("Forward iface %p, base %p\n", This, base);
3672 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3675 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3677 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3678 ID3DXBaseEffect *base = This->base_effect;
3680 TRACE("Forward iface %p, base %p\n", This, base);
3682 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3685 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3687 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3688 ID3DXBaseEffect *base = This->base_effect;
3690 TRACE("Forward iface %p, base %p\n", This, base);
3692 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3695 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3697 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3698 ID3DXBaseEffect *base = This->base_effect;
3700 TRACE("Forward iface %p, base %p\n", This, base);
3702 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3705 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3707 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3708 ID3DXBaseEffect *base = This->base_effect;
3710 TRACE("Forward iface %p, base %p\n", This, base);
3712 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3715 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3717 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3718 ID3DXBaseEffect *base = This->base_effect;
3720 TRACE("Forward iface %p, base %p\n", This, base);
3722 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3725 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3727 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3728 ID3DXBaseEffect *base = This->base_effect;
3730 TRACE("Forward iface %p, base %p\n", This, base);
3732 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3735 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3737 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3738 ID3DXBaseEffect *base = This->base_effect;
3740 TRACE("Forward iface %p, base %p\n", This, base);
3742 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3745 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3747 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3748 ID3DXBaseEffect *base = This->base_effect;
3750 TRACE("Forward iface %p, base %p\n", This, base);
3752 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3755 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3757 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3758 ID3DXBaseEffect *base = This->base_effect;
3760 TRACE("Forward iface %p, base %p\n", This, base);
3762 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3765 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3767 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3768 ID3DXBaseEffect *base = This->base_effect;
3770 TRACE("Forward iface %p, base %p\n", This, base);
3772 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3775 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3777 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3778 ID3DXBaseEffect *base = This->base_effect;
3780 TRACE("Forward iface %p, base %p\n", This, base);
3782 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3785 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3787 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3788 ID3DXBaseEffect *base = This->base_effect;
3790 TRACE("Forward iface %p, base %p\n", This, base);
3792 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3795 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3797 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3798 ID3DXBaseEffect *base = This->base_effect;
3800 TRACE("Forward iface %p, base %p\n", This, base);
3802 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3805 /*** ID3DXEffectCompiler methods ***/
3806 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3808 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3810 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3815 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3817 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3819 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3824 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3825 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3827 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3829 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3834 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3835 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3837 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3839 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3840 This, function, target, flags, shader, error_msgs, constant_table);
3845 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3847 /*** IUnknown methods ***/
3848 ID3DXEffectCompilerImpl_QueryInterface,
3849 ID3DXEffectCompilerImpl_AddRef,
3850 ID3DXEffectCompilerImpl_Release,
3851 /*** ID3DXBaseEffect methods ***/
3852 ID3DXEffectCompilerImpl_GetDesc,
3853 ID3DXEffectCompilerImpl_GetParameterDesc,
3854 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3855 ID3DXEffectCompilerImpl_GetPassDesc,
3856 ID3DXEffectCompilerImpl_GetFunctionDesc,
3857 ID3DXEffectCompilerImpl_GetParameter,
3858 ID3DXEffectCompilerImpl_GetParameterByName,
3859 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3860 ID3DXEffectCompilerImpl_GetParameterElement,
3861 ID3DXEffectCompilerImpl_GetTechnique,
3862 ID3DXEffectCompilerImpl_GetTechniqueByName,
3863 ID3DXEffectCompilerImpl_GetPass,
3864 ID3DXEffectCompilerImpl_GetPassByName,
3865 ID3DXEffectCompilerImpl_GetFunction,
3866 ID3DXEffectCompilerImpl_GetFunctionByName,
3867 ID3DXEffectCompilerImpl_GetAnnotation,
3868 ID3DXEffectCompilerImpl_GetAnnotationByName,
3869 ID3DXEffectCompilerImpl_SetValue,
3870 ID3DXEffectCompilerImpl_GetValue,
3871 ID3DXEffectCompilerImpl_SetBool,
3872 ID3DXEffectCompilerImpl_GetBool,
3873 ID3DXEffectCompilerImpl_SetBoolArray,
3874 ID3DXEffectCompilerImpl_GetBoolArray,
3875 ID3DXEffectCompilerImpl_SetInt,
3876 ID3DXEffectCompilerImpl_GetInt,
3877 ID3DXEffectCompilerImpl_SetIntArray,
3878 ID3DXEffectCompilerImpl_GetIntArray,
3879 ID3DXEffectCompilerImpl_SetFloat,
3880 ID3DXEffectCompilerImpl_GetFloat,
3881 ID3DXEffectCompilerImpl_SetFloatArray,
3882 ID3DXEffectCompilerImpl_GetFloatArray,
3883 ID3DXEffectCompilerImpl_SetVector,
3884 ID3DXEffectCompilerImpl_GetVector,
3885 ID3DXEffectCompilerImpl_SetVectorArray,
3886 ID3DXEffectCompilerImpl_GetVectorArray,
3887 ID3DXEffectCompilerImpl_SetMatrix,
3888 ID3DXEffectCompilerImpl_GetMatrix,
3889 ID3DXEffectCompilerImpl_SetMatrixArray,
3890 ID3DXEffectCompilerImpl_GetMatrixArray,
3891 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3892 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3893 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3894 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3895 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3896 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3897 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3898 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3899 ID3DXEffectCompilerImpl_SetString,
3900 ID3DXEffectCompilerImpl_GetString,
3901 ID3DXEffectCompilerImpl_SetTexture,
3902 ID3DXEffectCompilerImpl_GetTexture,
3903 ID3DXEffectCompilerImpl_GetPixelShader,
3904 ID3DXEffectCompilerImpl_GetVertexShader,
3905 ID3DXEffectCompilerImpl_SetArrayRange,
3906 /*** ID3DXEffectCompiler methods ***/
3907 ID3DXEffectCompilerImpl_SetLiteral,
3908 ID3DXEffectCompilerImpl_GetLiteral,
3909 ID3DXEffectCompilerImpl_CompileEffect,
3910 ID3DXEffectCompilerImpl_CompileShader,
3913 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
3917 struct d3dx_state *states;
3919 read_dword(ptr, &sampler->state_count);
3920 TRACE("Count: %u\n", sampler->state_count);
3922 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
3925 ERR("Out of memory\n");
3926 return E_OUTOFMEMORY;
3929 for (i = 0; i < sampler->state_count; ++i)
3931 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
3934 WARN("Failed to parse state\n");
3939 sampler->states = states;
3945 for (i = 0; i < sampler->state_count; ++i)
3947 free_state(&states[i]);
3950 HeapFree(GetProcessHeap(), 0, states);
3955 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
3962 if (param->element_count)
3964 param->data = value;
3966 for (i = 0; i < param->element_count; ++i)
3968 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3970 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
3973 WARN("Failed to parse value\n");
3977 old_size += member->bytes;
3983 switch(param->class)
3987 case D3DXPC_MATRIX_ROWS:
3988 case D3DXPC_MATRIX_COLUMNS:
3989 param->data = value;
3993 param->data = value;
3995 for (i = 0; i < param->member_count; ++i)
3997 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3999 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4002 WARN("Failed to parse value\n");
4006 old_size += member->bytes;
4011 switch (param->type)
4014 case D3DXPT_TEXTURE:
4015 case D3DXPT_TEXTURE1D:
4016 case D3DXPT_TEXTURE2D:
4017 case D3DXPT_TEXTURE3D:
4018 case D3DXPT_TEXTURECUBE:
4019 case D3DXPT_PIXELSHADER:
4020 case D3DXPT_VERTEXSHADER:
4021 read_dword(ptr, &id);
4022 TRACE("Id: %u\n", id);
4023 objects[id] = get_parameter_handle(param);
4024 param->data = value;
4027 case D3DXPT_SAMPLER:
4028 case D3DXPT_SAMPLER1D:
4029 case D3DXPT_SAMPLER2D:
4030 case D3DXPT_SAMPLER3D:
4031 case D3DXPT_SAMPLERCUBE:
4033 struct d3dx_sampler *sampler;
4035 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4038 ERR("Out of memory\n");
4039 return E_OUTOFMEMORY;
4042 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4045 HeapFree(GetProcessHeap(), 0, sampler);
4046 WARN("Failed to parse sampler\n");
4050 param->data = sampler;
4055 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4061 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4068 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4070 UINT size = param->bytes;
4074 TRACE("param size: %u\n", size);
4078 value = HeapAlloc(GetProcessHeap(), 0, size);
4081 ERR("Failed to allocate data memory.\n");
4082 return E_OUTOFMEMORY;
4085 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4086 memcpy(value, ptr, size);
4089 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4092 WARN("Failed to parse value\n");
4093 HeapFree(GetProcessHeap(), 0, value);
4100 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4104 read_dword(&ptr, &size);
4105 TRACE("Name size: %#x\n", size);
4112 *name = HeapAlloc(GetProcessHeap(), 0, size);
4115 ERR("Failed to allocate name memory.\n");
4116 return E_OUTOFMEMORY;
4119 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4120 memcpy(*name, ptr, size);
4125 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4129 read_dword(ptr, &size);
4130 TRACE("Data size: %#x\n", size);
4132 *str = HeapAlloc(GetProcessHeap(), 0, size);
4135 ERR("Failed to allocate name memory.\n");
4136 return E_OUTOFMEMORY;
4139 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4140 memcpy(*str, *ptr, size);
4142 *ptr += ((size + 3) & ~3);
4147 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4152 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4154 read_dword(ptr, &size);
4155 TRACE("Data size: %#x\n", size);
4159 TRACE("Size is 0\n");
4160 *(void **)param->data = NULL;
4164 switch (param->type)
4167 /* re-read with size (sizeof(DWORD) = 4) */
4168 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4171 WARN("Failed to parse string data\n");
4176 case D3DXPT_VERTEXSHADER:
4177 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4180 WARN("Failed to create vertex shader\n");
4185 case D3DXPT_PIXELSHADER:
4186 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4189 WARN("Failed to create pixel shader\n");
4195 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4200 *ptr += ((size + 3) & ~3);
4205 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4206 struct d3dx_parameter *parent, UINT flags)
4210 D3DXHANDLE *member_handles = NULL;
4213 param->flags = flags;
4217 read_dword(ptr, ¶m->type);
4218 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4220 read_dword(ptr, ¶m->class);
4221 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4223 read_dword(ptr, &offset);
4224 TRACE("Type name offset: %#x\n", offset);
4225 hr = d3dx9_parse_name(¶m->name, data + offset);
4228 WARN("Failed to parse name\n");
4232 read_dword(ptr, &offset);
4233 TRACE("Type semantic offset: %#x\n", offset);
4234 hr = d3dx9_parse_name(¶m->semantic, data + offset);
4237 WARN("Failed to parse semantic\n");
4241 read_dword(ptr, ¶m->element_count);
4242 TRACE("Elements: %u\n", param->element_count);
4244 switch (param->class)
4247 read_dword(ptr, ¶m->columns);
4248 TRACE("Columns: %u\n", param->columns);
4250 read_dword(ptr, ¶m->rows);
4251 TRACE("Rows: %u\n", param->rows);
4253 /* sizeof(DWORD) * rows * columns */
4254 param->bytes = 4 * param->rows * param->columns;
4258 case D3DXPC_MATRIX_ROWS:
4259 case D3DXPC_MATRIX_COLUMNS:
4260 read_dword(ptr, ¶m->rows);
4261 TRACE("Rows: %u\n", param->rows);
4263 read_dword(ptr, ¶m->columns);
4264 TRACE("Columns: %u\n", param->columns);
4266 /* sizeof(DWORD) * rows * columns */
4267 param->bytes = 4 * param->rows * param->columns;
4271 read_dword(ptr, ¶m->member_count);
4272 TRACE("Members: %u\n", param->member_count);
4276 switch (param->type)
4279 param->bytes = sizeof(LPCSTR);
4282 case D3DXPT_PIXELSHADER:
4283 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4286 case D3DXPT_VERTEXSHADER:
4287 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4290 case D3DXPT_TEXTURE:
4291 case D3DXPT_TEXTURE1D:
4292 case D3DXPT_TEXTURE2D:
4293 case D3DXPT_TEXTURE3D:
4294 case D3DXPT_TEXTURECUBE:
4295 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4298 case D3DXPT_SAMPLER:
4299 case D3DXPT_SAMPLER1D:
4300 case D3DXPT_SAMPLER2D:
4301 case D3DXPT_SAMPLER3D:
4302 case D3DXPT_SAMPLERCUBE:
4307 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4313 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4320 param->type = parent->type;
4321 param->class = parent->class;
4322 param->name = parent->name;
4323 param->semantic = parent->semantic;
4324 param->element_count = 0;
4325 param->annotation_count = 0;
4326 param->member_count = parent->member_count;
4327 param->bytes = parent->bytes;
4328 param->rows = parent->rows;
4329 param->columns = parent->columns;
4332 if (param->element_count)
4334 unsigned int param_bytes = 0;
4335 const char *save_ptr = *ptr;
4337 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4338 if (!member_handles)
4340 ERR("Out of memory\n");
4345 for (i = 0; i < param->element_count; ++i)
4347 struct d3dx_parameter *member;
4350 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4353 ERR("Out of memory\n");
4358 member_handles[i] = get_parameter_handle(member);
4360 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4363 WARN("Failed to parse member\n");
4367 param_bytes += member->bytes;
4370 param->bytes = param_bytes;
4372 else if (param->member_count)
4374 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4375 if (!member_handles)
4377 ERR("Out of memory\n");
4382 for (i = 0; i < param->member_count; ++i)
4384 struct d3dx_parameter *member;
4386 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4389 ERR("Out of memory\n");
4394 member_handles[i] = get_parameter_handle(member);
4396 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4399 WARN("Failed to parse member\n");
4403 param->bytes += member->bytes;
4407 param->member_handles = member_handles;
4417 if (param->element_count) count = param->element_count;
4418 else count = param->member_count;
4420 for (i = 0; i < count; ++i)
4422 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4424 HeapFree(GetProcessHeap(), 0, member_handles);
4429 HeapFree(GetProcessHeap(), 0, param->name);
4430 HeapFree(GetProcessHeap(), 0, param->semantic);
4433 param->semantic = NULL;
4438 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4444 anno->flags = D3DX_PARAMETER_ANNOTATION;
4446 read_dword(ptr, &offset);
4447 TRACE("Typedef offset: %#x\n", offset);
4448 ptr2 = data + offset;
4449 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4452 WARN("Failed to parse type definition\n");
4456 read_dword(ptr, &offset);
4457 TRACE("Value offset: %#x\n", offset);
4458 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4461 WARN("Failed to parse value\n");
4468 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4473 struct d3dx_parameter *parameter;
4475 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4478 ERR("Out of memory\n");
4479 return E_OUTOFMEMORY;
4482 state->type = ST_CONSTANT;
4484 read_dword(ptr, &state->operation);
4485 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4487 read_dword(ptr, &state->index);
4488 TRACE("Index: %#x\n", state->index);
4490 read_dword(ptr, &offset);
4491 TRACE("Typedef offset: %#x\n", offset);
4492 ptr2 = data + offset;
4493 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4496 WARN("Failed to parse type definition\n");
4500 read_dword(ptr, &offset);
4501 TRACE("Value offset: %#x\n", offset);
4502 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4505 WARN("Failed to parse value\n");
4509 state->parameter = get_parameter_handle(parameter);
4515 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4520 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4525 D3DXHANDLE *annotation_handles = NULL;
4528 read_dword(ptr, &offset);
4529 TRACE("Typedef offset: %#x\n", offset);
4530 ptr2 = data + offset;
4532 read_dword(ptr, &offset);
4533 TRACE("Value offset: %#x\n", offset);
4535 read_dword(ptr, ¶m->flags);
4536 TRACE("Flags: %#x\n", param->flags);
4538 read_dword(ptr, ¶m->annotation_count);
4539 TRACE("Annotation count: %u\n", param->annotation_count);
4541 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4544 WARN("Failed to parse type definition\n");
4548 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4551 WARN("Failed to parse value\n");
4555 if (param->annotation_count)
4557 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4558 if (!annotation_handles)
4560 ERR("Out of memory\n");
4565 for (i = 0; i < param->annotation_count; ++i)
4567 struct d3dx_parameter *annotation;
4569 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4572 ERR("Out of memory\n");
4577 annotation_handles[i] = get_parameter_handle(annotation);
4579 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4582 WARN("Failed to parse annotation\n");
4588 param->annotation_handles = annotation_handles;
4594 if (annotation_handles)
4596 for (i = 0; i < param->annotation_count; ++i)
4598 free_parameter(annotation_handles[i], FALSE, FALSE);
4600 HeapFree(GetProcessHeap(), 0, annotation_handles);
4606 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4611 D3DXHANDLE *annotation_handles = NULL;
4612 struct d3dx_state *states = NULL;
4615 read_dword(ptr, &offset);
4616 TRACE("Pass name offset: %#x\n", offset);
4617 hr = d3dx9_parse_name(&name, data + offset);
4620 WARN("Failed to parse name\n");
4624 read_dword(ptr, &pass->annotation_count);
4625 TRACE("Annotation count: %u\n", pass->annotation_count);
4627 read_dword(ptr, &pass->state_count);
4628 TRACE("State count: %u\n", pass->state_count);
4630 if (pass->annotation_count)
4632 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4633 if (!annotation_handles)
4635 ERR("Out of memory\n");
4640 for (i = 0; i < pass->annotation_count; ++i)
4642 struct d3dx_parameter *annotation;
4644 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4647 ERR("Out of memory\n");
4652 annotation_handles[i] = get_parameter_handle(annotation);
4654 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4657 WARN("Failed to parse annotations\n");
4663 if (pass->state_count)
4665 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4668 ERR("Out of memory\n");
4673 for (i = 0; i < pass->state_count; ++i)
4675 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4678 WARN("Failed to parse annotations\n");
4685 pass->annotation_handles = annotation_handles;
4686 pass->states = states;
4692 if (annotation_handles)
4694 for (i = 0; i < pass->annotation_count; ++i)
4696 free_parameter(annotation_handles[i], FALSE, FALSE);
4698 HeapFree(GetProcessHeap(), 0, annotation_handles);
4703 for (i = 0; i < pass->state_count; ++i)
4705 free_state(&states[i]);
4707 HeapFree(GetProcessHeap(), 0, states);
4710 HeapFree(GetProcessHeap(), 0, name);
4715 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4720 D3DXHANDLE *annotation_handles = NULL;
4721 D3DXHANDLE *pass_handles = NULL;
4724 read_dword(ptr, &offset);
4725 TRACE("Technique name offset: %#x\n", offset);
4726 hr = d3dx9_parse_name(&name, data + offset);
4729 WARN("Failed to parse name\n");
4733 read_dword(ptr, &technique->annotation_count);
4734 TRACE("Annotation count: %u\n", technique->annotation_count);
4736 read_dword(ptr, &technique->pass_count);
4737 TRACE("Pass count: %u\n", technique->pass_count);
4739 if (technique->annotation_count)
4741 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4742 if (!annotation_handles)
4744 ERR("Out of memory\n");
4749 for (i = 0; i < technique->annotation_count; ++i)
4751 struct d3dx_parameter *annotation;
4753 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4756 ERR("Out of memory\n");
4761 annotation_handles[i] = get_parameter_handle(annotation);
4763 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4766 WARN("Failed to parse annotations\n");
4772 if (technique->pass_count)
4774 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4777 ERR("Out of memory\n");
4782 for (i = 0; i < technique->pass_count; ++i)
4784 struct d3dx_pass *pass;
4786 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4789 ERR("Out of memory\n");
4794 pass_handles[i] = get_pass_handle(pass);
4796 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
4799 WARN("Failed to parse passes\n");
4805 technique->name = name;
4806 technique->pass_handles = pass_handles;
4807 technique->annotation_handles = annotation_handles;
4815 for (i = 0; i < technique->pass_count; ++i)
4817 free_pass(pass_handles[i]);
4819 HeapFree(GetProcessHeap(), 0, pass_handles);
4822 if (annotation_handles)
4824 for (i = 0; i < technique->annotation_count; ++i)
4826 free_parameter(annotation_handles[i], FALSE, FALSE);
4828 HeapFree(GetProcessHeap(), 0, annotation_handles);
4831 HeapFree(GetProcessHeap(), 0, name);
4836 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
4838 DWORD technique_index;
4839 DWORD index, state_index, usage, element_index;
4840 struct d3dx_state *state;
4841 struct d3dx_parameter *param;
4842 HRESULT hr = E_FAIL;
4844 read_dword(ptr, &technique_index);
4845 TRACE("techn: %u\n", technique_index);
4847 read_dword(ptr, &index);
4848 TRACE("index: %u\n", index);
4850 read_dword(ptr, &element_index);
4851 TRACE("element_index: %u\n", element_index);
4853 read_dword(ptr, &state_index);
4854 TRACE("state_index: %u\n", state_index);
4856 read_dword(ptr, &usage);
4857 TRACE("usage: %u\n", usage);
4859 if (technique_index == 0xffffffff)
4861 struct d3dx_parameter *parameter;
4862 struct d3dx_sampler *sampler;
4864 if (index >= base->parameter_count)
4866 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
4870 parameter = get_parameter_struct(base->parameter_handles[index]);
4871 if (element_index != 0xffffffff)
4873 if (element_index >= parameter->element_count && parameter->element_count != 0)
4875 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
4879 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
4882 sampler = parameter->data;
4883 if (state_index >= sampler->state_count)
4885 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
4889 state = &sampler->states[state_index];
4893 struct d3dx_technique *technique;
4894 struct d3dx_pass *pass;
4896 if (technique_index >= base->technique_count)
4898 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
4902 technique = get_technique_struct(base->technique_handles[technique_index]);
4903 if (index >= technique->pass_count)
4905 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
4909 pass = get_pass_struct(technique->pass_handles[index]);
4910 if (state_index >= pass->state_count)
4912 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
4916 state = &pass->states[state_index];
4919 param = get_parameter_struct(state->parameter);
4924 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
4925 switch (param->type)
4927 case D3DXPT_VERTEXSHADER:
4928 case D3DXPT_PIXELSHADER:
4929 state->type = ST_CONSTANT;
4930 hr = d3dx9_parse_data(param, ptr, base->effect->device);
4937 state->type = ST_FXLC;
4938 hr = d3dx9_copy_data(param->data, ptr);
4942 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4948 state->type = ST_PARAMETER;
4949 hr = d3dx9_copy_data(param->data, ptr);
4952 TRACE("Mapping to parameter %s\n", *(char **)param->data);
4957 FIXME("Unknown usage %x\n", usage);
4964 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4966 const char *ptr = data + start;
4967 D3DXHANDLE *parameter_handles = NULL;
4968 D3DXHANDLE *technique_handles = NULL;
4969 D3DXHANDLE *objects = NULL;
4970 UINT stringcount, objectcount, resourcecount;
4974 read_dword(&ptr, &base->parameter_count);
4975 TRACE("Parameter count: %u\n", base->parameter_count);
4977 read_dword(&ptr, &base->technique_count);
4978 TRACE("Technique count: %u\n", base->technique_count);
4980 skip_dword_unknown(&ptr, 1);
4982 read_dword(&ptr, &objectcount);
4983 TRACE("Object count: %u\n", objectcount);
4985 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
4988 ERR("Out of memory\n");
4993 if (base->parameter_count)
4995 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4996 if (!parameter_handles)
4998 ERR("Out of memory\n");
5003 for (i = 0; i < base->parameter_count; ++i)
5005 struct d3dx_parameter *parameter;
5007 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5010 ERR("Out of memory\n");
5015 parameter_handles[i] = get_parameter_handle(parameter);
5017 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5020 WARN("Failed to parse parameter\n");
5026 if (base->technique_count)
5028 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5029 if (!technique_handles)
5031 ERR("Out of memory\n");
5036 for (i = 0; i < base->technique_count; ++i)
5038 struct d3dx_technique *technique;
5040 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5043 ERR("Out of memory\n");
5048 technique_handles[i] = get_technique_handle(technique);
5050 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5053 WARN("Failed to parse technique\n");
5059 /* needed for further parsing */
5060 base->technique_handles = technique_handles;
5061 base->parameter_handles = parameter_handles;
5063 read_dword(&ptr, &stringcount);
5064 TRACE("String count: %u\n", stringcount);
5066 read_dword(&ptr, &resourcecount);
5067 TRACE("Resource count: %u\n", resourcecount);
5069 for (i = 0; i < stringcount; ++i)
5072 struct d3dx_parameter *param;
5074 read_dword(&ptr, &id);
5075 TRACE("Id: %u\n", id);
5077 param = get_parameter_struct(objects[id]);
5079 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5082 WARN("Failed to parse data\n");
5087 for (i = 0; i < resourcecount; ++i)
5089 TRACE("parse resource %u\n", i);
5091 hr = d3dx9_parse_resource(base, data, &ptr);
5094 WARN("Failed to parse data\n");
5099 HeapFree(GetProcessHeap(), 0, objects);
5105 if (technique_handles)
5107 for (i = 0; i < base->technique_count; ++i)
5109 free_technique(technique_handles[i]);
5111 HeapFree(GetProcessHeap(), 0, technique_handles);
5114 if (parameter_handles)
5116 for (i = 0; i < base->parameter_count; ++i)
5118 free_parameter(parameter_handles[i], FALSE, FALSE);
5120 HeapFree(GetProcessHeap(), 0, parameter_handles);
5123 base->technique_handles = NULL;
5124 base->parameter_handles = NULL;
5126 HeapFree(GetProcessHeap(), 0, objects);
5131 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5132 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5135 const char *ptr = data;
5138 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5140 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5142 base->effect = effect;
5144 read_dword(&ptr, &tag);
5145 TRACE("Tag: %x\n", tag);
5147 if (tag != d3dx9_effect_version(9, 1))
5149 /* todo: compile hlsl ascii code */
5150 FIXME("HLSL ascii effects not supported, yet\n");
5152 /* Show the start of the shader for debugging info. */
5153 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5157 read_dword(&ptr, &offset);
5158 TRACE("Offset: %x\n", offset);
5160 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5163 FIXME("Failed to parse effect.\n");
5171 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5172 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5175 struct ID3DXBaseEffectImpl *object = NULL;
5177 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5179 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5182 if (pool) pool->lpVtbl->AddRef(pool);
5183 effect->pool = pool;
5185 IDirect3DDevice9_AddRef(device);
5186 effect->device = device;
5188 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5191 ERR("Out of memory\n");
5196 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5199 FIXME("Failed to parse effect.\n");
5203 effect->base_effect = &object->ID3DXBaseEffect_iface;
5205 /* initialize defaults - check because of unsupported ascii effects */
5206 if (object->technique_handles)
5208 effect->active_technique = object->technique_handles[0];
5209 effect->active_pass = NULL;
5216 HeapFree(GetProcessHeap(), 0, object);
5217 free_effect(effect);
5222 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5225 CONST D3DXMACRO* defines,
5226 LPD3DXINCLUDE include,
5227 LPCSTR skip_constants,
5229 LPD3DXEFFECTPOOL pool,
5230 LPD3DXEFFECT* effect,
5231 LPD3DXBUFFER* compilation_errors)
5233 struct ID3DXEffectImpl *object;
5236 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5237 skip_constants, flags, pool, effect, compilation_errors);
5239 if (!device || !srcdata)
5240 return D3DERR_INVALIDCALL;
5245 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5249 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5252 ERR("Out of memory\n");
5253 return E_OUTOFMEMORY;
5256 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5259 WARN("Failed to initialize shader reflection\n");
5260 HeapFree(GetProcessHeap(), 0, object);
5264 *effect = &object->ID3DXEffect_iface;
5266 TRACE("Created ID3DXEffect %p\n", object);
5271 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5274 CONST D3DXMACRO* defines,
5275 LPD3DXINCLUDE include,
5277 LPD3DXEFFECTPOOL pool,
5278 LPD3DXEFFECT* effect,
5279 LPD3DXBUFFER* compilation_errors)
5281 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5282 include, flags, pool, effect, compilation_errors);
5284 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5287 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5290 struct ID3DXBaseEffectImpl *object = NULL;
5292 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5294 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5297 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5300 ERR("Out of memory\n");
5305 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5308 FIXME("Failed to parse effect.\n");
5312 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5318 HeapFree(GetProcessHeap(), 0, object);
5319 free_effect_compiler(compiler);
5324 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5326 CONST D3DXMACRO *defines,
5327 LPD3DXINCLUDE include,
5329 LPD3DXEFFECTCOMPILER *compiler,
5330 LPD3DXBUFFER *parse_errors)
5332 struct ID3DXEffectCompilerImpl *object;
5335 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5336 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5338 if (!srcdata || !compiler)
5340 WARN("Invalid arguments supplied\n");
5341 return D3DERR_INVALIDCALL;
5344 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5347 ERR("Out of memory\n");
5348 return E_OUTOFMEMORY;
5351 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5354 WARN("Failed to initialize effect compiler\n");
5355 HeapFree(GetProcessHeap(), 0, object);
5359 *compiler = &object->ID3DXEffectCompiler_iface;
5361 TRACE("Created ID3DXEffectCompiler %p\n", object);
5366 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5368 struct ID3DXEffectPoolImpl
5370 ID3DXEffectPool ID3DXEffectPool_iface;
5374 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5376 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5379 /*** IUnknown methods ***/
5380 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5382 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5384 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5386 if (IsEqualGUID(riid, &IID_IUnknown) ||
5387 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5389 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5394 WARN("Interface %s not found\n", debugstr_guid(riid));
5396 return E_NOINTERFACE;
5399 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5401 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5403 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5405 return InterlockedIncrement(&This->ref);
5408 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5410 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5411 ULONG ref = InterlockedDecrement(&This->ref);
5413 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5416 HeapFree(GetProcessHeap(), 0, This);
5421 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5423 /*** IUnknown methods ***/
5424 ID3DXEffectPoolImpl_QueryInterface,
5425 ID3DXEffectPoolImpl_AddRef,
5426 ID3DXEffectPoolImpl_Release
5429 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5431 struct ID3DXEffectPoolImpl *object;
5433 TRACE("(%p)\n", pool);
5436 return D3DERR_INVALIDCALL;
5438 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5441 ERR("Out of memory\n");
5442 return E_OUTOFMEMORY;
5445 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5448 *pool = &object->ID3DXEffectPool_iface;
5453 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5454 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5455 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5461 TRACE("(%s): relay\n", debugstr_w(srcfile));
5463 if (!device || !srcfile)
5464 return D3DERR_INVALIDCALL;
5466 ret = map_view_of_file(srcfile, &buffer, &size);
5469 return D3DXERR_INVALIDDATA;
5471 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5472 UnmapViewOfFile(buffer);
5477 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5478 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5479 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5485 TRACE("(void): relay\n");
5488 return D3DERR_INVALIDCALL;
5490 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5491 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5492 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5494 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5495 HeapFree(GetProcessHeap(), 0, srcfileW);
5500 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5501 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5502 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5504 TRACE("(void): relay\n");
5505 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5508 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5509 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5510 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5512 TRACE("(void): relay\n");
5513 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5516 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5517 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5518 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5522 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5525 return D3DERR_INVALIDCALL;
5527 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5535 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5538 return D3DXERR_INVALIDDATA;
5540 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5543 return D3DXERR_INVALIDDATA;
5546 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5547 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5548 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5552 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5555 return D3DERR_INVALIDCALL;
5557 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5565 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5568 return D3DXERR_INVALIDDATA;
5570 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5573 return D3DXERR_INVALIDDATA;
5576 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5577 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5578 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5580 TRACE("(void): relay\n");
5581 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5584 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5585 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5586 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5588 TRACE("(void): relay\n");
5589 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5592 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5593 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5599 TRACE("(%s): relay\n", debugstr_w(srcfile));
5602 return D3DERR_INVALIDCALL;
5604 ret = map_view_of_file(srcfile, &buffer, &size);
5607 return D3DXERR_INVALIDDATA;
5609 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5610 UnmapViewOfFile(buffer);
5615 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5616 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5622 TRACE("(void): relay\n");
5625 return D3DERR_INVALIDCALL;
5627 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5628 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5629 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5631 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5632 HeapFree(GetProcessHeap(), 0, srcfileW);
5637 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5638 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5642 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5644 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5652 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5655 return D3DXERR_INVALIDDATA;
5657 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5660 return D3DXERR_INVALIDDATA;
5663 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5664 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5668 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5670 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5678 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5681 return D3DXERR_INVALIDDATA;
5683 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5686 return D3DXERR_INVALIDDATA;