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 #define NONAMELESSUNION
22 #include "wine/debug.h"
23 #include "wine/unicode.h"
27 #include "d3dx9_36_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
31 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
32 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
33 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
80 enum SHADER_CONSTANT_TYPE
102 D3DXPARAMETER_CLASS class;
103 D3DXPARAMETER_TYPE type;
107 UINT annotation_count;
112 D3DXHANDLE *annotation_handles;
113 D3DXHANDLE *member_handles;
120 enum STATE_TYPE type;
121 D3DXHANDLE parameter;
127 struct d3dx_state *states;
134 UINT annotation_count;
136 struct d3dx_state *states;
137 D3DXHANDLE *annotation_handles;
140 struct d3dx_technique
144 UINT annotation_count;
146 D3DXHANDLE *annotation_handles;
147 D3DXHANDLE *pass_handles;
150 struct ID3DXBaseEffectImpl
152 ID3DXBaseEffect ID3DXBaseEffect_iface;
155 struct ID3DXEffectImpl *effect;
157 UINT parameter_count;
158 UINT technique_count;
160 D3DXHANDLE *parameter_handles;
161 D3DXHANDLE *technique_handles;
164 struct ID3DXEffectImpl
166 ID3DXEffect ID3DXEffect_iface;
169 LPD3DXEFFECTSTATEMANAGER manager;
170 LPDIRECT3DDEVICE9 device;
171 LPD3DXEFFECTPOOL pool;
172 D3DXHANDLE active_technique;
173 D3DXHANDLE active_pass;
175 ID3DXBaseEffect *base_effect;
178 struct ID3DXEffectCompilerImpl
180 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
183 ID3DXBaseEffect *base_effect;
186 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
187 struct d3dx_parameter *parameter, LPCSTR name);
188 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
189 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
190 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
194 enum STATE_CLASS class;
201 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
202 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
203 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
204 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
205 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
206 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
207 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
208 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
209 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
210 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
211 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
212 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
213 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
214 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
215 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
216 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
217 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
218 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
219 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
220 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
221 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
222 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
223 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
224 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
225 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
226 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
227 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
228 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
229 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
230 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
231 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
232 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
233 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
234 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
235 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
236 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
237 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
238 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
239 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
240 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
241 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
242 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
243 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
244 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
245 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
246 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
247 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
248 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
249 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
250 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
251 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
252 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
253 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
254 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
255 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
256 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
257 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
258 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
259 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
260 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
261 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
262 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
263 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
264 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
265 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
266 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
267 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
268 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
269 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
270 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
271 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
272 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
273 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
274 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
275 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
276 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
277 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
278 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
279 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
280 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
281 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
282 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
283 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
284 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
285 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
286 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
287 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
288 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
289 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
290 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
291 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
292 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
293 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
294 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
295 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
296 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
297 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
298 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
299 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
300 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
301 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
302 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
303 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
305 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
306 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
307 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
308 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
309 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
310 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
311 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
312 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
313 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
314 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
315 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
316 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
317 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
318 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
319 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
320 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
321 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
323 {SC_UNKNOWN, 0, "UNKNOWN"},
325 {SC_NPATCHMODE, 0, "NPatchMode"},
327 {SC_UNKNOWN, 0, "UNKNOWN"},
329 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
330 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
331 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
332 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
334 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
335 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
336 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
337 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
338 {SC_MATERIAL, MT_POWER, "MaterialPower"},
340 {SC_LIGHT, LT_TYPE, "LightType"},
341 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
342 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
343 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
344 {SC_LIGHT, LT_POSITION, "LightPosition"},
345 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
346 {SC_LIGHT, LT_RANGE, "LightRange"},
347 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
348 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
349 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
350 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
351 {SC_LIGHT, LT_THETA, "LightTheta"},
352 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
354 {SC_LIGHTENABLE, 0, "LightEnable"},
356 {SC_VERTEXSHADER, 0, "Vertexshader"},
358 {SC_PIXELSHADER, 0, "Pixelshader"},
359 /* Shader constants */
360 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
361 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
362 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
363 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
364 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
365 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
366 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
367 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
368 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
369 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
370 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
371 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
372 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
373 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
374 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
375 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
377 {SC_TEXTURE, 0, "Texture"},
379 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
380 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
381 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
382 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
383 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
384 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
385 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
386 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
387 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
388 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
389 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
390 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
391 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
393 {SC_SETSAMPLER, 0, "Sampler"},
396 static inline void read_dword(const char **ptr, DWORD *d)
398 memcpy(d, *ptr, sizeof(*d));
402 static void skip_dword_unknown(const char **ptr, unsigned int count)
407 FIXME("Skipping %u unknown DWORDs:\n", count);
408 for (i = 0; i < count; ++i)
411 FIXME("\t0x%08x\n", d);
415 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
417 return (struct d3dx_parameter *) handle;
420 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
422 return (struct d3dx_pass *) handle;
425 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
427 return (struct d3dx_technique *) handle;
430 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
432 return (D3DXHANDLE) parameter;
435 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
437 return (D3DXHANDLE) technique;
440 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
442 return (D3DXHANDLE) pass;
445 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
449 for (i = 0; i < base->technique_count; ++i)
451 if (base->technique_handles[i] == technique)
453 return get_technique_struct(technique);
460 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
464 for (i = 0; i < base->technique_count; ++i)
466 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
468 for (k = 0; k < technique->pass_count; ++k)
470 if (technique->pass_handles[k] == pass)
472 return get_pass_struct(pass);
480 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
482 unsigned int i, count;
483 struct d3dx_parameter *p;
485 for (i = 0; i < param->annotation_count; ++i)
487 if (param->annotation_handles[i] == parameter)
489 return get_parameter_struct(parameter);
492 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
496 if (param->element_count) count = param->element_count;
497 else count = param->member_count;
499 for (i = 0; i < count; ++i)
501 if (param->member_handles[i] == parameter)
503 return get_parameter_struct(parameter);
506 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
513 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
515 unsigned int i, k, m;
516 struct d3dx_parameter *p;
518 for (i = 0; i < base->parameter_count; ++i)
520 if (base->parameter_handles[i] == parameter)
522 return get_parameter_struct(parameter);
525 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
529 for (i = 0; i < base->technique_count; ++i)
531 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
533 for (k = 0; k < technique->pass_count; ++k)
535 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
537 for (m = 0; m < pass->annotation_count; ++m)
539 if (pass->annotation_handles[i] == parameter)
541 return get_parameter_struct(parameter);
544 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
549 for (k = 0; k < technique->annotation_count; ++k)
551 if (technique->annotation_handles[k] == parameter)
553 return get_parameter_struct(parameter);
556 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
564 static inline struct d3dx_parameter *get_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
566 struct d3dx_parameter *param = is_valid_parameter(base, parameter);
568 if (!param) param = get_parameter_by_name(base, NULL, parameter);
573 static void free_state(struct d3dx_state *state)
575 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
578 static void free_sampler(struct d3dx_sampler *sampler)
582 for (i = 0; i < sampler->state_count; ++i)
584 free_state(&sampler->states[i]);
586 HeapFree(GetProcessHeap(), 0, sampler->states);
589 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
591 free_parameter_state(handle, element, child, ST_CONSTANT);
594 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
597 struct d3dx_parameter *param = get_parameter_struct(handle);
599 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
600 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
607 if (param->annotation_handles)
609 for (i = 0; i < param->annotation_count; ++i)
611 free_parameter(param->annotation_handles[i], FALSE, FALSE);
613 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
616 if (param->member_handles)
620 if (param->element_count) count = param->element_count;
621 else count = param->member_count;
623 for (i = 0; i < count; ++i)
625 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
627 HeapFree(GetProcessHeap(), 0, param->member_handles);
630 if (param->class == D3DXPC_OBJECT && !param->element_count)
635 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
636 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
640 case D3DXPT_TEXTURE1D:
641 case D3DXPT_TEXTURE2D:
642 case D3DXPT_TEXTURE3D:
643 case D3DXPT_TEXTURECUBE:
644 case D3DXPT_PIXELSHADER:
645 case D3DXPT_VERTEXSHADER:
646 if (st == ST_CONSTANT)
648 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
652 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
654 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
658 case D3DXPT_SAMPLER1D:
659 case D3DXPT_SAMPLER2D:
660 case D3DXPT_SAMPLER3D:
661 case D3DXPT_SAMPLERCUBE:
662 if (st == ST_CONSTANT)
664 free_sampler((struct d3dx_sampler *)param->data);
668 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
670 /* samplers have always own data, so free that */
671 HeapFree(GetProcessHeap(), 0, param->data);
675 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
683 if (st != ST_CONSTANT)
685 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
687 HeapFree(GetProcessHeap(), 0, param->data);
691 /* only the parent has to release name and semantic */
694 HeapFree(GetProcessHeap(), 0, param->name);
695 HeapFree(GetProcessHeap(), 0, param->semantic);
698 HeapFree(GetProcessHeap(), 0, param);
701 static void free_pass(D3DXHANDLE handle)
704 struct d3dx_pass *pass = get_pass_struct(handle);
706 TRACE("Free pass %p\n", pass);
713 if (pass->annotation_handles)
715 for (i = 0; i < pass->annotation_count; ++i)
717 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
719 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
724 for (i = 0; i < pass->state_count; ++i)
726 free_state(&pass->states[i]);
728 HeapFree(GetProcessHeap(), 0, pass->states);
731 HeapFree(GetProcessHeap(), 0, pass->name);
732 HeapFree(GetProcessHeap(), 0, pass);
735 static void free_technique(D3DXHANDLE handle)
738 struct d3dx_technique *technique = get_technique_struct(handle);
740 TRACE("Free technique %p\n", technique);
747 if (technique->annotation_handles)
749 for (i = 0; i < technique->annotation_count; ++i)
751 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
753 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
756 if (technique->pass_handles)
758 for (i = 0; i < technique->pass_count; ++i)
760 free_pass(technique->pass_handles[i]);
762 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
765 HeapFree(GetProcessHeap(), 0, technique->name);
766 HeapFree(GetProcessHeap(), 0, technique);
769 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
773 TRACE("Free base effect %p\n", base);
775 if (base->parameter_handles)
777 for (i = 0; i < base->parameter_count; ++i)
779 free_parameter(base->parameter_handles[i], FALSE, FALSE);
781 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
784 if (base->technique_handles)
786 for (i = 0; i < base->technique_count; ++i)
788 free_technique(base->technique_handles[i]);
790 HeapFree(GetProcessHeap(), 0, base->technique_handles);
794 static void free_effect(struct ID3DXEffectImpl *effect)
796 TRACE("Free effect %p\n", effect);
798 if (effect->base_effect)
800 effect->base_effect->lpVtbl->Release(effect->base_effect);
805 effect->pool->lpVtbl->Release(effect->pool);
810 IUnknown_Release(effect->manager);
813 IDirect3DDevice9_Release(effect->device);
816 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
818 TRACE("Free effect compiler %p\n", compiler);
820 if (compiler->base_effect)
822 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
826 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
846 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
853 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
873 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
880 static inline BOOL get_bool(void *data)
882 return (*(DWORD *)data) ? TRUE : FALSE;
885 static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector)
887 vector->x = get_float(param->type, (float *)param->data);
888 vector->y = param->columns > 1 ? get_float(param->type, (float *)param->data + 1) : 0.0f;
889 vector->z = param->columns > 2 ? get_float(param->type, (float *)param->data + 2) : 0.0f;
890 vector->w = param->columns > 3 ? get_float(param->type, (float *)param->data + 3) : 0.0f;
893 static void get_matrix(struct d3dx_parameter *param, D3DXMATRIX *matrix)
897 for (i = 0; i < 4; ++i)
899 for (k = 0; k < 4; ++k)
901 if ((i < param->rows) && (k < param->columns))
902 matrix->u.m[i][k] = get_float(param->type, (float *)param->data + i * param->columns + k);
904 matrix->u.m[i][k] = 0.0f;
909 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
912 struct d3dx_parameter *temp_parameter;
915 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
917 if (!name || !*name) return parameter;
919 element = atoi(name);
920 part = strchr(name, ']') + 1;
922 if (parameter->element_count > element)
924 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
929 return get_parameter_by_name(NULL, temp_parameter, part);
932 return get_parameter_annotation_by_name(temp_parameter, part);
935 TRACE("Returning parameter %p\n", temp_parameter);
936 return temp_parameter;
939 FIXME("Unhandled case \"%c\"\n", *--part);
944 TRACE("Parameter not found\n");
948 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
951 struct d3dx_parameter *temp_parameter;
954 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
956 if (!name || !*name) return parameter;
958 length = strcspn( name, "[.@" );
959 part = name + length;
961 for (i = 0; i < parameter->annotation_count; ++i)
963 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
965 if (!strcmp(temp_parameter->name, name))
967 TRACE("Returning parameter %p\n", temp_parameter);
968 return temp_parameter;
970 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
975 return get_parameter_by_name(NULL, temp_parameter, part);
978 return get_parameter_element_by_name(temp_parameter, part);
981 FIXME("Unhandled case \"%c\"\n", *--part);
987 TRACE("Parameter not found\n");
991 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
992 struct d3dx_parameter *parameter, LPCSTR name)
994 UINT i, count, length;
995 struct d3dx_parameter *temp_parameter;
999 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
1001 if (!name || !*name) return parameter;
1005 count = base->parameter_count;
1006 handles = base->parameter_handles;
1010 count = parameter->member_count;
1011 handles = parameter->member_handles;
1014 length = strcspn( name, "[.@" );
1015 part = name + length;
1017 for (i = 0; i < count; i++)
1019 temp_parameter = get_parameter_struct(handles[i]);
1021 if (!strcmp(temp_parameter->name, name))
1023 TRACE("Returning parameter %p\n", temp_parameter);
1024 return temp_parameter;
1026 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1031 return get_parameter_by_name(NULL, temp_parameter, part);
1034 return get_parameter_annotation_by_name(temp_parameter, part);
1037 return get_parameter_element_by_name(temp_parameter, part);
1040 FIXME("Unhandled case \"%c\"\n", *--part);
1046 TRACE("Parameter not found\n");
1050 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1052 return (0xfeff0000 | ((major) << 8) | (minor));
1055 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1057 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1060 /*** IUnknown methods ***/
1061 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1063 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1065 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1067 if (IsEqualGUID(riid, &IID_IUnknown) ||
1068 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1070 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1075 ERR("Interface %s not found\n", debugstr_guid(riid));
1077 return E_NOINTERFACE;
1080 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1082 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1084 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1086 return InterlockedIncrement(&This->ref);
1089 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1091 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1092 ULONG ref = InterlockedDecrement(&This->ref);
1094 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1098 free_base_effect(This);
1099 HeapFree(GetProcessHeap(), 0, This);
1105 /*** ID3DXBaseEffect methods ***/
1106 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1108 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1110 FIXME("iface %p, desc %p partial stub\n", This, desc);
1114 WARN("Invalid argument specified.\n");
1115 return D3DERR_INVALIDCALL;
1118 /* Todo: add creator and function count */
1119 desc->Creator = NULL;
1120 desc->Functions = 0;
1121 desc->Parameters = This->parameter_count;
1122 desc->Techniques = This->technique_count;
1127 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1129 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1130 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1132 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1134 if (!desc || !param)
1136 WARN("Invalid argument specified.\n");
1137 return D3DERR_INVALIDCALL;
1140 desc->Name = param->name;
1141 desc->Semantic = param->semantic;
1142 desc->Class = param->class;
1143 desc->Type = param->type;
1144 desc->Rows = param->rows;
1145 desc->Columns = param->columns;
1146 desc->Elements = param->element_count;
1147 desc->Annotations = param->annotation_count;
1148 desc->StructMembers = param->member_count;
1149 desc->Flags = param->flags;
1150 desc->Bytes = param->bytes;
1155 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1157 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1158 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1160 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1164 WARN("Invalid argument specified.\n");
1165 return D3DERR_INVALIDCALL;
1168 desc->Name = tech->name;
1169 desc->Passes = tech->pass_count;
1170 desc->Annotations = tech->annotation_count;
1175 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1177 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1178 struct d3dx_pass *p = is_valid_pass(This, pass);
1180 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1184 WARN("Invalid argument specified.\n");
1185 return D3DERR_INVALIDCALL;
1188 desc->Name = p->name;
1189 desc->Annotations = p->annotation_count;
1191 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1192 desc->pVertexShaderFunction = NULL;
1193 desc->pPixelShaderFunction = NULL;
1198 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1200 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1202 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1207 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1209 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1210 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1212 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1216 if (index < This->parameter_count)
1218 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1219 return This->parameter_handles[index];
1224 if (param && !param->element_count && index < param->member_count)
1226 TRACE("Returning parameter %p\n", param->member_handles[index]);
1227 return param->member_handles[index];
1231 WARN("Invalid argument specified.\n");
1236 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1238 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1239 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1242 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1246 handle = get_parameter_handle(param);
1247 TRACE("Returning parameter %p\n", handle);
1251 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1252 TRACE("Returning parameter %p\n", handle);
1257 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1259 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1260 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1261 struct d3dx_parameter *temp_param;
1264 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1268 for (i = 0; i < This->parameter_count; ++i)
1270 temp_param = get_parameter_struct(This->parameter_handles[i]);
1272 if (!temp_param->semantic)
1276 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1277 return This->parameter_handles[i];
1282 if (!strcasecmp(temp_param->semantic, semantic))
1284 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1285 return This->parameter_handles[i];
1291 for (i = 0; i < param->member_count; ++i)
1293 temp_param = get_parameter_struct(param->member_handles[i]);
1295 if (!temp_param->semantic)
1299 TRACE("Returning parameter %p\n", param->member_handles[i]);
1300 return param->member_handles[i];
1305 if (!strcasecmp(temp_param->semantic, semantic))
1307 TRACE("Returning parameter %p\n", param->member_handles[i]);
1308 return param->member_handles[i];
1313 WARN("Invalid argument specified\n");
1318 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1320 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1321 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1323 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1327 if (index < This->parameter_count)
1329 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1330 return This->parameter_handles[index];
1335 if (index < param->element_count)
1337 TRACE("Returning parameter %p\n", param->member_handles[index]);
1338 return param->member_handles[index];
1342 WARN("Invalid argument specified\n");
1347 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1349 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1351 TRACE("iface %p, index %u\n", This, index);
1353 if (index >= This->technique_count)
1355 WARN("Invalid argument specified.\n");
1359 TRACE("Returning technique %p\n", This->technique_handles[index]);
1361 return This->technique_handles[index];
1364 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1366 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1369 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1373 WARN("Invalid argument specified.\n");
1377 for (i = 0; i < This->technique_count; ++i)
1379 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1381 if (!strcmp(tech->name, name))
1383 TRACE("Returning technique %p\n", This->technique_handles[i]);
1384 return This->technique_handles[i];
1388 WARN("Invalid argument specified.\n");
1393 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1395 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1396 struct d3dx_technique *tech = is_valid_technique(This, technique);
1398 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1400 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1402 if (tech && index < tech->pass_count)
1404 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1405 return tech->pass_handles[index];
1408 WARN("Invalid argument specified.\n");
1413 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1415 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1416 struct d3dx_technique *tech = is_valid_technique(This, technique);
1418 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1420 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1426 for (i = 0; i < tech->pass_count; ++i)
1428 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1430 if (!strcmp(pass->name, name))
1432 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1433 return tech->pass_handles[i];
1438 WARN("Invalid argument specified.\n");
1443 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1445 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1447 FIXME("iface %p, index %u stub\n", This, index);
1452 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1454 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1456 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1461 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1463 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1464 struct d3dx_parameter *param = get_valid_parameter(This, object);
1465 struct d3dx_pass *pass = is_valid_pass(This, object);
1466 struct d3dx_technique *technique = is_valid_technique(This, object);
1467 UINT annotation_count = 0;
1468 D3DXHANDLE *annotation_handles = NULL;
1470 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1474 annotation_count = pass->annotation_count;
1475 annotation_handles = pass->annotation_handles;
1479 annotation_count = technique->annotation_count;
1480 annotation_handles = technique->annotation_handles;
1484 annotation_count = param->annotation_count;
1485 annotation_handles = param->annotation_handles;
1487 /* Todo: add funcs */
1489 if (index < annotation_count)
1491 TRACE("Returning parameter %p\n", annotation_handles[index]);
1492 return annotation_handles[index];
1495 WARN("Invalid argument specified\n");
1500 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1502 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1503 struct d3dx_parameter *param = get_valid_parameter(This, object);
1504 struct d3dx_pass *pass = is_valid_pass(This, object);
1505 struct d3dx_technique *technique = is_valid_technique(This, object);
1506 UINT annotation_count = 0, i;
1507 D3DXHANDLE *annotation_handles = NULL;
1509 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1513 WARN("Invalid argument specified\n");
1519 annotation_count = pass->annotation_count;
1520 annotation_handles = pass->annotation_handles;
1524 annotation_count = technique->annotation_count;
1525 annotation_handles = technique->annotation_handles;
1529 annotation_count = param->annotation_count;
1530 annotation_handles = param->annotation_handles;
1532 /* Todo: add funcs */
1534 for (i = 0; i < annotation_count; i++)
1536 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1538 if (!strcmp(anno->name, name))
1540 TRACE("Returning parameter %p\n", anno);
1541 return get_parameter_handle(anno);
1545 WARN("Invalid argument specified\n");
1550 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1552 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1554 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1559 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1561 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1562 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1564 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1568 WARN("Invalid parameter %p specified\n", parameter);
1569 return D3DERR_INVALIDCALL;
1572 /* samplers don't touch data */
1573 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1574 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1575 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1577 TRACE("Sampler: returning E_FAIL\n");
1581 if (data && param->bytes <= bytes)
1583 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1585 switch (param->type)
1594 case D3DXPT_VERTEXSHADER:
1595 case D3DXPT_PIXELSHADER:
1596 case D3DXPT_TEXTURE:
1597 case D3DXPT_TEXTURE1D:
1598 case D3DXPT_TEXTURE2D:
1599 case D3DXPT_TEXTURE3D:
1600 case D3DXPT_TEXTURECUBE:
1604 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1606 IUnknown *unk = ((IUnknown **)param->data)[i];
1607 if (unk) IUnknown_AddRef(unk);
1613 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1617 TRACE("Copy %u bytes\n", param->bytes);
1618 memcpy(data, param->data, param->bytes);
1622 WARN("Invalid argument specified\n");
1624 return D3DERR_INVALIDCALL;
1627 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1629 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1631 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1636 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1638 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1639 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1641 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1643 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1645 *b = get_bool(param->data);
1646 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1650 WARN("Invalid argument specified\n");
1652 return D3DERR_INVALIDCALL;
1655 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1657 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1659 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1664 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1666 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1667 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1669 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1671 if (b && param && (param->class == D3DXPC_SCALAR
1672 || param->class == D3DXPC_VECTOR
1673 || param->class == D3DXPC_MATRIX_ROWS
1674 || param->class == D3DXPC_MATRIX_COLUMNS))
1676 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1678 for (i = 0; i < size; ++i)
1680 b[i] = get_bool((DWORD *)param->data + i);
1685 WARN("Invalid argument specified\n");
1687 return D3DERR_INVALIDCALL;
1690 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1692 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1694 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1699 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1701 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1702 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1704 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1706 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1708 *n = get_int(param->type, param->data);
1709 TRACE("Returning %i\n", *n);
1713 WARN("Invalid argument specified\n");
1715 return D3DERR_INVALIDCALL;
1718 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1720 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1722 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1727 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1729 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1730 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1732 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1734 if (n && param && (param->class == D3DXPC_SCALAR
1735 || param->class == D3DXPC_VECTOR
1736 || param->class == D3DXPC_MATRIX_ROWS
1737 || param->class == D3DXPC_MATRIX_COLUMNS))
1739 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1741 for (i = 0; i < size; ++i)
1743 n[i] = get_int(param->type, (DWORD *)param->data + i);
1748 WARN("Invalid argument specified\n");
1750 return D3DERR_INVALIDCALL;
1753 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1755 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1757 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1762 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1764 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1765 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1767 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1769 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1771 *f = get_float(param->type, (DWORD *)param->data);
1772 TRACE("Returning %f\n", *f);
1776 WARN("Invalid argument specified\n");
1778 return D3DERR_INVALIDCALL;
1781 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1783 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1785 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1790 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1792 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1793 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1795 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1797 if (f && param && (param->class == D3DXPC_SCALAR
1798 || param->class == D3DXPC_VECTOR
1799 || param->class == D3DXPC_MATRIX_ROWS
1800 || param->class == D3DXPC_MATRIX_COLUMNS))
1802 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1804 for (i = 0; i < size; ++i)
1806 f[i] = get_float(param->type, (DWORD *)param->data + i);
1811 WARN("Invalid argument specified\n");
1813 return D3DERR_INVALIDCALL;
1816 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1818 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1820 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1825 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1827 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1829 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1834 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1836 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1838 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1843 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1845 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1846 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1848 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
1850 if (!count) return D3D_OK;
1852 if (vector && param && count <= param->element_count)
1856 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1858 switch (param->class)
1861 for (i = 0; i < count; ++i)
1863 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
1868 case D3DXPC_MATRIX_ROWS:
1874 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1879 WARN("Invalid argument specified\n");
1881 return D3DERR_INVALIDCALL;
1884 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1886 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1888 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1893 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1895 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1896 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1898 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
1900 if (matrix && param && !param->element_count)
1902 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1904 switch (param->class)
1906 case D3DXPC_MATRIX_ROWS:
1907 get_matrix(param, matrix);
1917 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1922 WARN("Invalid argument specified\n");
1924 return D3DERR_INVALIDCALL;
1927 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1929 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1931 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1936 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1938 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1939 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1941 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
1943 if (!count) return D3D_OK;
1945 if (matrix && param && count <= param->element_count)
1949 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1951 switch (param->class)
1953 case D3DXPC_MATRIX_ROWS:
1954 for (i = 0; i < count; ++i)
1956 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i]);
1967 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1972 WARN("Invalid argument specified\n");
1974 return D3DERR_INVALIDCALL;
1977 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1979 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1981 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1986 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1988 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1990 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1995 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1997 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1999 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
2004 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2006 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2007 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2010 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2012 if (matrix && param && !param->element_count)
2014 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2016 switch (param->class)
2020 get_matrix(param, matrix);
2023 case D3DXPC_MATRIX_ROWS:
2024 get_matrix(param, &m);
2025 D3DXMatrixTranspose(matrix, &m);
2033 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2038 WARN("Invalid argument specified\n");
2040 return D3DERR_INVALIDCALL;
2043 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2045 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2047 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2052 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2054 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2055 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2057 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2059 if (!count) return D3D_OK;
2061 if (matrix && param && count <= param->element_count)
2065 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2067 switch (param->class)
2069 case D3DXPC_MATRIX_ROWS:
2070 for (i = 0; i < count; ++i)
2074 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2075 D3DXMatrixTranspose(&matrix[i], &m);
2086 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2091 WARN("Invalid argument specified\n");
2093 return D3DERR_INVALIDCALL;
2096 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2098 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2100 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2105 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2107 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2109 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2114 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2116 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2118 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2123 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2125 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2126 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2128 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2130 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2132 *string = *(LPCSTR *)param->data;
2133 TRACE("Returning %s\n", debugstr_a(*string));
2137 WARN("Invalid argument specified\n");
2139 return D3DERR_INVALIDCALL;
2142 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2144 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2145 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2147 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2149 if (texture && param && !param->element_count &&
2150 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2151 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2152 || param->type == D3DXPT_TEXTURECUBE))
2154 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2156 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2157 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2159 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2164 WARN("Invalid argument specified\n");
2166 return D3DERR_INVALIDCALL;
2169 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2171 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2172 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2174 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2176 if (texture && param && !param->element_count &&
2177 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2178 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2179 || param->type == D3DXPT_TEXTURECUBE))
2181 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2182 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2183 TRACE("Returning %p\n", *texture);
2187 WARN("Invalid argument specified\n");
2189 return D3DERR_INVALIDCALL;
2192 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2194 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2195 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2197 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2199 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2201 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2202 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2203 TRACE("Returning %p\n", *pshader);
2207 WARN("Invalid argument specified\n");
2209 return D3DERR_INVALIDCALL;
2212 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2214 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2215 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2217 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2219 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2221 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2222 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2223 TRACE("Returning %p\n", *vshader);
2227 WARN("Invalid argument specified\n");
2229 return D3DERR_INVALIDCALL;
2232 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2234 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2236 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2241 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2243 /*** IUnknown methods ***/
2244 ID3DXBaseEffectImpl_QueryInterface,
2245 ID3DXBaseEffectImpl_AddRef,
2246 ID3DXBaseEffectImpl_Release,
2247 /*** ID3DXBaseEffect methods ***/
2248 ID3DXBaseEffectImpl_GetDesc,
2249 ID3DXBaseEffectImpl_GetParameterDesc,
2250 ID3DXBaseEffectImpl_GetTechniqueDesc,
2251 ID3DXBaseEffectImpl_GetPassDesc,
2252 ID3DXBaseEffectImpl_GetFunctionDesc,
2253 ID3DXBaseEffectImpl_GetParameter,
2254 ID3DXBaseEffectImpl_GetParameterByName,
2255 ID3DXBaseEffectImpl_GetParameterBySemantic,
2256 ID3DXBaseEffectImpl_GetParameterElement,
2257 ID3DXBaseEffectImpl_GetTechnique,
2258 ID3DXBaseEffectImpl_GetTechniqueByName,
2259 ID3DXBaseEffectImpl_GetPass,
2260 ID3DXBaseEffectImpl_GetPassByName,
2261 ID3DXBaseEffectImpl_GetFunction,
2262 ID3DXBaseEffectImpl_GetFunctionByName,
2263 ID3DXBaseEffectImpl_GetAnnotation,
2264 ID3DXBaseEffectImpl_GetAnnotationByName,
2265 ID3DXBaseEffectImpl_SetValue,
2266 ID3DXBaseEffectImpl_GetValue,
2267 ID3DXBaseEffectImpl_SetBool,
2268 ID3DXBaseEffectImpl_GetBool,
2269 ID3DXBaseEffectImpl_SetBoolArray,
2270 ID3DXBaseEffectImpl_GetBoolArray,
2271 ID3DXBaseEffectImpl_SetInt,
2272 ID3DXBaseEffectImpl_GetInt,
2273 ID3DXBaseEffectImpl_SetIntArray,
2274 ID3DXBaseEffectImpl_GetIntArray,
2275 ID3DXBaseEffectImpl_SetFloat,
2276 ID3DXBaseEffectImpl_GetFloat,
2277 ID3DXBaseEffectImpl_SetFloatArray,
2278 ID3DXBaseEffectImpl_GetFloatArray,
2279 ID3DXBaseEffectImpl_SetVector,
2280 ID3DXBaseEffectImpl_GetVector,
2281 ID3DXBaseEffectImpl_SetVectorArray,
2282 ID3DXBaseEffectImpl_GetVectorArray,
2283 ID3DXBaseEffectImpl_SetMatrix,
2284 ID3DXBaseEffectImpl_GetMatrix,
2285 ID3DXBaseEffectImpl_SetMatrixArray,
2286 ID3DXBaseEffectImpl_GetMatrixArray,
2287 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2288 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2289 ID3DXBaseEffectImpl_SetMatrixTranspose,
2290 ID3DXBaseEffectImpl_GetMatrixTranspose,
2291 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2292 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2293 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2294 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2295 ID3DXBaseEffectImpl_SetString,
2296 ID3DXBaseEffectImpl_GetString,
2297 ID3DXBaseEffectImpl_SetTexture,
2298 ID3DXBaseEffectImpl_GetTexture,
2299 ID3DXBaseEffectImpl_GetPixelShader,
2300 ID3DXBaseEffectImpl_GetVertexShader,
2301 ID3DXBaseEffectImpl_SetArrayRange,
2304 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2306 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2309 /*** IUnknown methods ***/
2310 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2312 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2314 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2316 if (IsEqualGUID(riid, &IID_IUnknown) ||
2317 IsEqualGUID(riid, &IID_ID3DXEffect))
2319 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2324 ERR("Interface %s not found\n", debugstr_guid(riid));
2326 return E_NOINTERFACE;
2329 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2331 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2333 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2335 return InterlockedIncrement(&This->ref);
2338 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2340 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2341 ULONG ref = InterlockedDecrement(&This->ref);
2343 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2348 HeapFree(GetProcessHeap(), 0, This);
2354 /*** ID3DXBaseEffect methods ***/
2355 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2357 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2358 ID3DXBaseEffect *base = This->base_effect;
2360 TRACE("Forward iface %p, base %p\n", This, base);
2362 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2365 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2367 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2368 ID3DXBaseEffect *base = This->base_effect;
2370 TRACE("Forward iface %p, base %p\n", This, base);
2372 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2375 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2377 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2378 ID3DXBaseEffect *base = This->base_effect;
2380 TRACE("Forward iface %p, base %p\n", This, base);
2382 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2385 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2387 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2388 ID3DXBaseEffect *base = This->base_effect;
2390 TRACE("Forward iface %p, base %p\n", This, base);
2392 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2395 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2397 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2398 ID3DXBaseEffect *base = This->base_effect;
2400 TRACE("Forward iface %p, base %p\n", This, base);
2402 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2405 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2407 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2408 ID3DXBaseEffect *base = This->base_effect;
2410 TRACE("Forward iface %p, base %p\n", This, base);
2412 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2415 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2417 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2418 ID3DXBaseEffect *base = This->base_effect;
2420 TRACE("Forward iface %p, base %p\n", This, base);
2422 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2425 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2427 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2428 ID3DXBaseEffect *base = This->base_effect;
2430 TRACE("Forward iface %p, base %p\n", This, base);
2432 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2435 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2437 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2438 ID3DXBaseEffect *base = This->base_effect;
2440 TRACE("Forward iface %p, base %p\n", This, base);
2442 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2445 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2447 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2448 ID3DXBaseEffect *base = This->base_effect;
2450 TRACE("Forward iface %p, base %p\n", This, base);
2452 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2455 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2457 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2458 ID3DXBaseEffect *base = This->base_effect;
2460 TRACE("Forward iface %p, base %p\n", This, base);
2462 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2465 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2467 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2468 ID3DXBaseEffect *base = This->base_effect;
2470 TRACE("Forward iface %p, base %p\n", This, base);
2472 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2475 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2477 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2478 ID3DXBaseEffect *base = This->base_effect;
2480 TRACE("Forward iface %p, base %p\n", This, base);
2482 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2485 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2487 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2488 ID3DXBaseEffect *base = This->base_effect;
2490 TRACE("Forward iface %p, base %p\n", This, base);
2492 return ID3DXBaseEffectImpl_GetFunction(base, index);
2495 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2497 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2498 ID3DXBaseEffect *base = This->base_effect;
2500 TRACE("Forward iface %p, base %p\n", This, base);
2502 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2505 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2507 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2508 ID3DXBaseEffect *base = This->base_effect;
2510 TRACE("Forward iface %p, base %p\n", This, base);
2512 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2515 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2517 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2518 ID3DXBaseEffect *base = This->base_effect;
2520 TRACE("Forward iface %p, base %p\n", This, base);
2522 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2525 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2527 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2528 ID3DXBaseEffect *base = This->base_effect;
2530 TRACE("Forward iface %p, base %p\n", This, base);
2532 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2535 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2537 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2538 ID3DXBaseEffect *base = This->base_effect;
2540 TRACE("Forward iface %p, base %p\n", This, base);
2542 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2545 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2547 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2548 ID3DXBaseEffect *base = This->base_effect;
2550 TRACE("Forward iface %p, base %p\n", This, base);
2552 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2555 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2557 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2558 ID3DXBaseEffect *base = This->base_effect;
2560 TRACE("Forward iface %p, base %p\n", This, base);
2562 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2565 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2567 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2568 ID3DXBaseEffect *base = This->base_effect;
2570 TRACE("Forward iface %p, base %p\n", This, base);
2572 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2575 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2577 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2578 ID3DXBaseEffect *base = This->base_effect;
2580 TRACE("Forward iface %p, base %p\n", This, base);
2582 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2585 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2587 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2588 ID3DXBaseEffect *base = This->base_effect;
2590 TRACE("Forward iface %p, base %p\n", This, base);
2592 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2595 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2597 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2598 ID3DXBaseEffect *base = This->base_effect;
2600 TRACE("Forward iface %p, base %p\n", This, base);
2602 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2605 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2607 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2608 ID3DXBaseEffect *base = This->base_effect;
2610 TRACE("Forward iface %p, base %p\n", This, base);
2612 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2615 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2617 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2618 ID3DXBaseEffect *base = This->base_effect;
2620 TRACE("Forward iface %p, base %p\n", This, base);
2622 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2625 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2627 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2628 ID3DXBaseEffect *base = This->base_effect;
2630 TRACE("Forward iface %p, base %p\n", This, base);
2632 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2635 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2637 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2638 ID3DXBaseEffect *base = This->base_effect;
2640 TRACE("Forward iface %p, base %p\n", This, base);
2642 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2645 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2647 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2648 ID3DXBaseEffect *base = This->base_effect;
2650 TRACE("Forward iface %p, base %p\n", This, base);
2652 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2655 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2657 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2658 ID3DXBaseEffect *base = This->base_effect;
2660 TRACE("Forward iface %p, base %p\n", This, base);
2662 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2665 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2667 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2668 ID3DXBaseEffect *base = This->base_effect;
2670 TRACE("Forward iface %p, base %p\n", This, base);
2672 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2675 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2677 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2678 ID3DXBaseEffect *base = This->base_effect;
2680 TRACE("Forward iface %p, base %p\n", This, base);
2682 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2685 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2687 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2688 ID3DXBaseEffect *base = This->base_effect;
2690 TRACE("Forward iface %p, base %p\n", This, base);
2692 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2695 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2697 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2698 ID3DXBaseEffect *base = This->base_effect;
2700 TRACE("Forward iface %p, base %p\n", This, base);
2702 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2705 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2707 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2708 ID3DXBaseEffect *base = This->base_effect;
2710 TRACE("Forward iface %p, base %p\n", This, base);
2712 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2715 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2717 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2718 ID3DXBaseEffect *base = This->base_effect;
2720 TRACE("Forward iface %p, base %p\n", This, base);
2722 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2725 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2727 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2728 ID3DXBaseEffect *base = This->base_effect;
2730 TRACE("Forward iface %p, base %p\n", This, base);
2732 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2735 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2737 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2738 ID3DXBaseEffect *base = This->base_effect;
2740 TRACE("Forward iface %p, base %p\n", This, base);
2742 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2745 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2747 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2748 ID3DXBaseEffect *base = This->base_effect;
2750 TRACE("Forward iface %p, base %p\n", This, base);
2752 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2755 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2757 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2758 ID3DXBaseEffect *base = This->base_effect;
2760 TRACE("Forward iface %p, base %p\n", This, base);
2762 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2765 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2767 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2768 ID3DXBaseEffect *base = This->base_effect;
2770 TRACE("Forward iface %p, base %p\n", This, base);
2772 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2775 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2777 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2778 ID3DXBaseEffect *base = This->base_effect;
2780 TRACE("Forward iface %p, base %p\n", This, base);
2782 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2785 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2787 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2788 ID3DXBaseEffect *base = This->base_effect;
2790 TRACE("Forward iface %p, base %p\n", This, base);
2792 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2795 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2797 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2798 ID3DXBaseEffect *base = This->base_effect;
2800 TRACE("Forward iface %p, base %p\n", This, base);
2802 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2805 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2807 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2808 ID3DXBaseEffect *base = This->base_effect;
2810 TRACE("Forward iface %p, base %p\n", This, base);
2812 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2815 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2817 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2818 ID3DXBaseEffect *base = This->base_effect;
2820 TRACE("Forward iface %p, base %p\n", This, base);
2822 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2825 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2827 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2828 ID3DXBaseEffect *base = This->base_effect;
2830 TRACE("Forward iface %p, base %p\n", This, base);
2832 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2835 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2837 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2838 ID3DXBaseEffect *base = This->base_effect;
2840 TRACE("Forward iface %p, base %p\n", This, base);
2842 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2845 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2847 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2848 ID3DXBaseEffect *base = This->base_effect;
2850 TRACE("Forward iface %p, base %p\n", This, base);
2852 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2855 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2857 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2858 ID3DXBaseEffect *base = This->base_effect;
2860 TRACE("Forward iface %p, base %p\n", This, base);
2862 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2865 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2867 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2868 ID3DXBaseEffect *base = This->base_effect;
2870 TRACE("Forward iface %p, base %p\n", This, base);
2872 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2875 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2877 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2878 ID3DXBaseEffect *base = This->base_effect;
2880 TRACE("Forward iface %p, base %p\n", This, base);
2882 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2885 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2887 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2888 ID3DXBaseEffect *base = This->base_effect;
2890 TRACE("Forward iface %p, base %p\n", This, base);
2892 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2895 /*** ID3DXEffect methods ***/
2896 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2898 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2900 TRACE("iface %p, pool %p\n", This, pool);
2904 WARN("Invalid argument supplied.\n");
2905 return D3DERR_INVALIDCALL;
2910 This->pool->lpVtbl->AddRef(This->pool);
2915 TRACE("Returning pool %p\n", *pool);
2920 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
2922 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2923 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
2924 struct d3dx_technique *tech = is_valid_technique(base, technique);
2926 TRACE("iface %p, technique %p\n", This, technique);
2928 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
2934 for (i = 0; i < base->technique_count; ++i)
2936 struct d3dx_technique *t = get_technique_struct(base->technique_handles[i]);
2940 This->active_technique = get_technique_handle(t);
2941 TRACE("Technique %u (%p)\n", i, tech);
2947 WARN("Invalid argument supplied.\n");
2949 return D3DERR_INVALIDCALL;
2952 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
2954 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2956 TRACE("iface %p\n", This);
2958 return This->active_technique;
2961 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2963 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2965 FIXME("(%p)->(%p): stub\n", This, technique);
2970 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2972 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2974 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2979 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2981 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2983 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2988 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
2990 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2991 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2993 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
2995 if (passes && technique)
2997 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
2999 TRACE("State capturing disabled.\n");
3003 FIXME("State capturing not supported, yet!\n");
3006 *passes = technique->pass_count;
3011 WARN("Invalid argument supplied.\n");
3013 return D3DERR_INVALIDCALL;
3016 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3018 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3019 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3021 TRACE("iface %p, pass %u\n", This, pass);
3023 if (technique && pass < technique->pass_count && !This->active_pass)
3025 This->active_pass = technique->pass_handles[pass];
3027 FIXME("No states applied, yet!\n");
3032 WARN("Invalid argument supplied.\n");
3034 return D3DERR_INVALIDCALL;
3037 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3039 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3041 FIXME("(%p)->(): stub\n", This);
3046 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3048 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3050 TRACE("iface %p\n", This);
3052 if (This->active_pass)
3054 This->active_pass = NULL;
3058 WARN("Invalid call.\n");
3060 return D3DERR_INVALIDCALL;
3063 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3065 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3067 FIXME("(%p)->(): stub\n", This);
3072 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3074 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3076 TRACE("iface %p, device %p\n", This, device);
3080 WARN("Invalid argument supplied.\n");
3081 return D3DERR_INVALIDCALL;
3084 IDirect3DDevice9_AddRef(This->device);
3086 *device = This->device;
3088 TRACE("Returning device %p\n", *device);
3093 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3095 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3097 FIXME("(%p)->(): stub\n", This);
3102 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3104 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3106 FIXME("(%p)->(): stub\n", This);
3111 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3113 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3115 TRACE("iface %p, manager %p\n", This, manager);
3117 if (manager) IUnknown_AddRef(manager);
3118 if (This->manager) IUnknown_Release(This->manager);
3120 This->manager = manager;
3125 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3127 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3129 TRACE("iface %p, manager %p\n", This, manager);
3133 WARN("Invalid argument supplied.\n");
3134 return D3DERR_INVALIDCALL;
3137 if (This->manager) IUnknown_AddRef(This->manager);
3138 *manager = This->manager;
3143 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3145 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3147 FIXME("(%p)->(): stub\n", This);
3152 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3154 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3156 FIXME("(%p)->(): stub\n", This);
3161 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3163 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3165 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3170 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3172 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3174 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3179 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3181 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3183 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3188 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3190 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3192 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3197 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3199 /*** IUnknown methods ***/
3200 ID3DXEffectImpl_QueryInterface,
3201 ID3DXEffectImpl_AddRef,
3202 ID3DXEffectImpl_Release,
3203 /*** ID3DXBaseEffect methods ***/
3204 ID3DXEffectImpl_GetDesc,
3205 ID3DXEffectImpl_GetParameterDesc,
3206 ID3DXEffectImpl_GetTechniqueDesc,
3207 ID3DXEffectImpl_GetPassDesc,
3208 ID3DXEffectImpl_GetFunctionDesc,
3209 ID3DXEffectImpl_GetParameter,
3210 ID3DXEffectImpl_GetParameterByName,
3211 ID3DXEffectImpl_GetParameterBySemantic,
3212 ID3DXEffectImpl_GetParameterElement,
3213 ID3DXEffectImpl_GetTechnique,
3214 ID3DXEffectImpl_GetTechniqueByName,
3215 ID3DXEffectImpl_GetPass,
3216 ID3DXEffectImpl_GetPassByName,
3217 ID3DXEffectImpl_GetFunction,
3218 ID3DXEffectImpl_GetFunctionByName,
3219 ID3DXEffectImpl_GetAnnotation,
3220 ID3DXEffectImpl_GetAnnotationByName,
3221 ID3DXEffectImpl_SetValue,
3222 ID3DXEffectImpl_GetValue,
3223 ID3DXEffectImpl_SetBool,
3224 ID3DXEffectImpl_GetBool,
3225 ID3DXEffectImpl_SetBoolArray,
3226 ID3DXEffectImpl_GetBoolArray,
3227 ID3DXEffectImpl_SetInt,
3228 ID3DXEffectImpl_GetInt,
3229 ID3DXEffectImpl_SetIntArray,
3230 ID3DXEffectImpl_GetIntArray,
3231 ID3DXEffectImpl_SetFloat,
3232 ID3DXEffectImpl_GetFloat,
3233 ID3DXEffectImpl_SetFloatArray,
3234 ID3DXEffectImpl_GetFloatArray,
3235 ID3DXEffectImpl_SetVector,
3236 ID3DXEffectImpl_GetVector,
3237 ID3DXEffectImpl_SetVectorArray,
3238 ID3DXEffectImpl_GetVectorArray,
3239 ID3DXEffectImpl_SetMatrix,
3240 ID3DXEffectImpl_GetMatrix,
3241 ID3DXEffectImpl_SetMatrixArray,
3242 ID3DXEffectImpl_GetMatrixArray,
3243 ID3DXEffectImpl_SetMatrixPointerArray,
3244 ID3DXEffectImpl_GetMatrixPointerArray,
3245 ID3DXEffectImpl_SetMatrixTranspose,
3246 ID3DXEffectImpl_GetMatrixTranspose,
3247 ID3DXEffectImpl_SetMatrixTransposeArray,
3248 ID3DXEffectImpl_GetMatrixTransposeArray,
3249 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3250 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3251 ID3DXEffectImpl_SetString,
3252 ID3DXEffectImpl_GetString,
3253 ID3DXEffectImpl_SetTexture,
3254 ID3DXEffectImpl_GetTexture,
3255 ID3DXEffectImpl_GetPixelShader,
3256 ID3DXEffectImpl_GetVertexShader,
3257 ID3DXEffectImpl_SetArrayRange,
3258 /*** ID3DXEffect methods ***/
3259 ID3DXEffectImpl_GetPool,
3260 ID3DXEffectImpl_SetTechnique,
3261 ID3DXEffectImpl_GetCurrentTechnique,
3262 ID3DXEffectImpl_ValidateTechnique,
3263 ID3DXEffectImpl_FindNextValidTechnique,
3264 ID3DXEffectImpl_IsParameterUsed,
3265 ID3DXEffectImpl_Begin,
3266 ID3DXEffectImpl_BeginPass,
3267 ID3DXEffectImpl_CommitChanges,
3268 ID3DXEffectImpl_EndPass,
3269 ID3DXEffectImpl_End,
3270 ID3DXEffectImpl_GetDevice,
3271 ID3DXEffectImpl_OnLostDevice,
3272 ID3DXEffectImpl_OnResetDevice,
3273 ID3DXEffectImpl_SetStateManager,
3274 ID3DXEffectImpl_GetStateManager,
3275 ID3DXEffectImpl_BeginParameterBlock,
3276 ID3DXEffectImpl_EndParameterBlock,
3277 ID3DXEffectImpl_ApplyParameterBlock,
3278 ID3DXEffectImpl_DeleteParameterBlock,
3279 ID3DXEffectImpl_CloneEffect,
3280 ID3DXEffectImpl_SetRawValue
3283 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3285 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3288 /*** IUnknown methods ***/
3289 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3291 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3293 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3295 if (IsEqualGUID(riid, &IID_IUnknown) ||
3296 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3298 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3303 ERR("Interface %s not found\n", debugstr_guid(riid));
3305 return E_NOINTERFACE;
3308 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3310 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3312 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3314 return InterlockedIncrement(&This->ref);
3317 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3319 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3320 ULONG ref = InterlockedDecrement(&This->ref);
3322 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3326 free_effect_compiler(This);
3327 HeapFree(GetProcessHeap(), 0, This);
3333 /*** ID3DXBaseEffect methods ***/
3334 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3336 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3337 ID3DXBaseEffect *base = This->base_effect;
3339 TRACE("Forward iface %p, base %p\n", This, base);
3341 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3344 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3346 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3347 ID3DXBaseEffect *base = This->base_effect;
3349 TRACE("Forward iface %p, base %p\n", This, base);
3351 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3354 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3356 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3357 ID3DXBaseEffect *base = This->base_effect;
3359 TRACE("Forward iface %p, base %p\n", This, base);
3361 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3364 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3366 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3367 ID3DXBaseEffect *base = This->base_effect;
3369 TRACE("Forward iface %p, base %p\n", This, base);
3371 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3374 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3376 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3377 ID3DXBaseEffect *base = This->base_effect;
3379 TRACE("Forward iface %p, base %p\n", This, base);
3381 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3384 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3386 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3387 ID3DXBaseEffect *base = This->base_effect;
3389 TRACE("Forward iface %p, base %p\n", This, base);
3391 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3394 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3396 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3397 ID3DXBaseEffect *base = This->base_effect;
3399 TRACE("Forward iface %p, base %p\n", This, base);
3401 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3404 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3406 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3407 ID3DXBaseEffect *base = This->base_effect;
3409 TRACE("Forward iface %p, base %p\n", This, base);
3411 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3414 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3416 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3417 ID3DXBaseEffect *base = This->base_effect;
3419 TRACE("Forward iface %p, base %p\n", This, base);
3421 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3424 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3426 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3427 ID3DXBaseEffect *base = This->base_effect;
3429 TRACE("Forward iface %p, base %p\n", This, base);
3431 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3434 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3436 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3437 ID3DXBaseEffect *base = This->base_effect;
3439 TRACE("Forward iface %p, base %p\n", This, base);
3441 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3444 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3446 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3447 ID3DXBaseEffect *base = This->base_effect;
3449 TRACE("Forward iface %p, base %p\n", This, base);
3451 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3454 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3456 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3457 ID3DXBaseEffect *base = This->base_effect;
3459 TRACE("Forward iface %p, base %p\n", This, base);
3461 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3464 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3466 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3467 ID3DXBaseEffect *base = This->base_effect;
3469 TRACE("Forward iface %p, base %p\n", This, base);
3471 return ID3DXBaseEffectImpl_GetFunction(base, index);
3474 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3476 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3477 ID3DXBaseEffect *base = This->base_effect;
3479 TRACE("Forward iface %p, base %p\n", This, base);
3481 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3484 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3486 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3487 ID3DXBaseEffect *base = This->base_effect;
3489 TRACE("Forward iface %p, base %p\n", This, base);
3491 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3494 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3496 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3497 ID3DXBaseEffect *base = This->base_effect;
3499 TRACE("Forward iface %p, base %p\n", This, base);
3501 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3504 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3506 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3507 ID3DXBaseEffect *base = This->base_effect;
3509 TRACE("Forward iface %p, base %p\n", This, base);
3511 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3514 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3516 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3517 ID3DXBaseEffect *base = This->base_effect;
3519 TRACE("Forward iface %p, base %p\n", This, base);
3521 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3524 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3526 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3527 ID3DXBaseEffect *base = This->base_effect;
3529 TRACE("Forward iface %p, base %p\n", This, base);
3531 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3534 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3536 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3537 ID3DXBaseEffect *base = This->base_effect;
3539 TRACE("Forward iface %p, base %p\n", This, base);
3541 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3544 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3546 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3547 ID3DXBaseEffect *base = This->base_effect;
3549 TRACE("Forward iface %p, base %p\n", This, base);
3551 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3554 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3556 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3557 ID3DXBaseEffect *base = This->base_effect;
3559 TRACE("Forward iface %p, base %p\n", This, base);
3561 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3564 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3566 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3567 ID3DXBaseEffect *base = This->base_effect;
3569 TRACE("Forward iface %p, base %p\n", This, base);
3571 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3574 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3576 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3577 ID3DXBaseEffect *base = This->base_effect;
3579 TRACE("Forward iface %p, base %p\n", This, base);
3581 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3584 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3586 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3587 ID3DXBaseEffect *base = This->base_effect;
3589 TRACE("Forward iface %p, base %p\n", This, base);
3591 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3594 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3596 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3597 ID3DXBaseEffect *base = This->base_effect;
3599 TRACE("Forward iface %p, base %p\n", This, base);
3601 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3604 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3606 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3607 ID3DXBaseEffect *base = This->base_effect;
3609 TRACE("Forward iface %p, base %p\n", This, base);
3611 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3614 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3616 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3617 ID3DXBaseEffect *base = This->base_effect;
3619 TRACE("Forward iface %p, base %p\n", This, base);
3621 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3624 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3626 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3627 ID3DXBaseEffect *base = This->base_effect;
3629 TRACE("Forward iface %p, base %p\n", This, base);
3631 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3634 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3636 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3637 ID3DXBaseEffect *base = This->base_effect;
3639 TRACE("Forward iface %p, base %p\n", This, base);
3641 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3644 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3646 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3647 ID3DXBaseEffect *base = This->base_effect;
3649 TRACE("Forward iface %p, base %p\n", This, base);
3651 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3654 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3656 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3657 ID3DXBaseEffect *base = This->base_effect;
3659 TRACE("Forward iface %p, base %p\n", This, base);
3661 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3664 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3666 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3667 ID3DXBaseEffect *base = This->base_effect;
3669 TRACE("Forward iface %p, base %p\n", This, base);
3671 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3674 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3676 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3677 ID3DXBaseEffect *base = This->base_effect;
3679 TRACE("Forward iface %p, base %p\n", This, base);
3681 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3684 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3686 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3687 ID3DXBaseEffect *base = This->base_effect;
3689 TRACE("Forward iface %p, base %p\n", This, base);
3691 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3694 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3696 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3697 ID3DXBaseEffect *base = This->base_effect;
3699 TRACE("Forward iface %p, base %p\n", This, base);
3701 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3704 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3706 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3707 ID3DXBaseEffect *base = This->base_effect;
3709 TRACE("Forward iface %p, base %p\n", This, base);
3711 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3714 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3716 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3717 ID3DXBaseEffect *base = This->base_effect;
3719 TRACE("Forward iface %p, base %p\n", This, base);
3721 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3724 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3726 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3727 ID3DXBaseEffect *base = This->base_effect;
3729 TRACE("Forward iface %p, base %p\n", This, base);
3731 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3734 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3736 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3737 ID3DXBaseEffect *base = This->base_effect;
3739 TRACE("Forward iface %p, base %p\n", This, base);
3741 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3744 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3746 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3747 ID3DXBaseEffect *base = This->base_effect;
3749 TRACE("Forward iface %p, base %p\n", This, base);
3751 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3754 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3756 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3757 ID3DXBaseEffect *base = This->base_effect;
3759 TRACE("Forward iface %p, base %p\n", This, base);
3761 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3764 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3766 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3767 ID3DXBaseEffect *base = This->base_effect;
3769 TRACE("Forward iface %p, base %p\n", This, base);
3771 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3774 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3776 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3777 ID3DXBaseEffect *base = This->base_effect;
3779 TRACE("Forward iface %p, base %p\n", This, base);
3781 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3784 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3786 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3787 ID3DXBaseEffect *base = This->base_effect;
3789 TRACE("Forward iface %p, base %p\n", This, base);
3791 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3794 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3796 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3797 ID3DXBaseEffect *base = This->base_effect;
3799 TRACE("Forward iface %p, base %p\n", This, base);
3801 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3804 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3806 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3807 ID3DXBaseEffect *base = This->base_effect;
3809 TRACE("Forward iface %p, base %p\n", This, base);
3811 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3814 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3816 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3817 ID3DXBaseEffect *base = This->base_effect;
3819 TRACE("Forward iface %p, base %p\n", This, base);
3821 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3824 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3826 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3827 ID3DXBaseEffect *base = This->base_effect;
3829 TRACE("Forward iface %p, base %p\n", This, base);
3831 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3834 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3836 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3837 ID3DXBaseEffect *base = This->base_effect;
3839 TRACE("Forward iface %p, base %p\n", This, base);
3841 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3844 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3846 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3847 ID3DXBaseEffect *base = This->base_effect;
3849 TRACE("Forward iface %p, base %p\n", This, base);
3851 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3854 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3856 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3857 ID3DXBaseEffect *base = This->base_effect;
3859 TRACE("Forward iface %p, base %p\n", This, base);
3861 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3864 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3866 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3867 ID3DXBaseEffect *base = This->base_effect;
3869 TRACE("Forward iface %p, base %p\n", This, base);
3871 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3874 /*** ID3DXEffectCompiler methods ***/
3875 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3877 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3879 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3884 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3886 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3888 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3893 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3894 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3896 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3898 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3903 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3904 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3906 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3908 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3909 This, function, target, flags, shader, error_msgs, constant_table);
3914 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3916 /*** IUnknown methods ***/
3917 ID3DXEffectCompilerImpl_QueryInterface,
3918 ID3DXEffectCompilerImpl_AddRef,
3919 ID3DXEffectCompilerImpl_Release,
3920 /*** ID3DXBaseEffect methods ***/
3921 ID3DXEffectCompilerImpl_GetDesc,
3922 ID3DXEffectCompilerImpl_GetParameterDesc,
3923 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3924 ID3DXEffectCompilerImpl_GetPassDesc,
3925 ID3DXEffectCompilerImpl_GetFunctionDesc,
3926 ID3DXEffectCompilerImpl_GetParameter,
3927 ID3DXEffectCompilerImpl_GetParameterByName,
3928 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3929 ID3DXEffectCompilerImpl_GetParameterElement,
3930 ID3DXEffectCompilerImpl_GetTechnique,
3931 ID3DXEffectCompilerImpl_GetTechniqueByName,
3932 ID3DXEffectCompilerImpl_GetPass,
3933 ID3DXEffectCompilerImpl_GetPassByName,
3934 ID3DXEffectCompilerImpl_GetFunction,
3935 ID3DXEffectCompilerImpl_GetFunctionByName,
3936 ID3DXEffectCompilerImpl_GetAnnotation,
3937 ID3DXEffectCompilerImpl_GetAnnotationByName,
3938 ID3DXEffectCompilerImpl_SetValue,
3939 ID3DXEffectCompilerImpl_GetValue,
3940 ID3DXEffectCompilerImpl_SetBool,
3941 ID3DXEffectCompilerImpl_GetBool,
3942 ID3DXEffectCompilerImpl_SetBoolArray,
3943 ID3DXEffectCompilerImpl_GetBoolArray,
3944 ID3DXEffectCompilerImpl_SetInt,
3945 ID3DXEffectCompilerImpl_GetInt,
3946 ID3DXEffectCompilerImpl_SetIntArray,
3947 ID3DXEffectCompilerImpl_GetIntArray,
3948 ID3DXEffectCompilerImpl_SetFloat,
3949 ID3DXEffectCompilerImpl_GetFloat,
3950 ID3DXEffectCompilerImpl_SetFloatArray,
3951 ID3DXEffectCompilerImpl_GetFloatArray,
3952 ID3DXEffectCompilerImpl_SetVector,
3953 ID3DXEffectCompilerImpl_GetVector,
3954 ID3DXEffectCompilerImpl_SetVectorArray,
3955 ID3DXEffectCompilerImpl_GetVectorArray,
3956 ID3DXEffectCompilerImpl_SetMatrix,
3957 ID3DXEffectCompilerImpl_GetMatrix,
3958 ID3DXEffectCompilerImpl_SetMatrixArray,
3959 ID3DXEffectCompilerImpl_GetMatrixArray,
3960 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3961 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3962 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3963 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3964 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3965 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3966 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3967 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3968 ID3DXEffectCompilerImpl_SetString,
3969 ID3DXEffectCompilerImpl_GetString,
3970 ID3DXEffectCompilerImpl_SetTexture,
3971 ID3DXEffectCompilerImpl_GetTexture,
3972 ID3DXEffectCompilerImpl_GetPixelShader,
3973 ID3DXEffectCompilerImpl_GetVertexShader,
3974 ID3DXEffectCompilerImpl_SetArrayRange,
3975 /*** ID3DXEffectCompiler methods ***/
3976 ID3DXEffectCompilerImpl_SetLiteral,
3977 ID3DXEffectCompilerImpl_GetLiteral,
3978 ID3DXEffectCompilerImpl_CompileEffect,
3979 ID3DXEffectCompilerImpl_CompileShader,
3982 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
3986 struct d3dx_state *states;
3988 read_dword(ptr, &sampler->state_count);
3989 TRACE("Count: %u\n", sampler->state_count);
3991 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
3994 ERR("Out of memory\n");
3995 return E_OUTOFMEMORY;
3998 for (i = 0; i < sampler->state_count; ++i)
4000 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4003 WARN("Failed to parse state\n");
4008 sampler->states = states;
4014 for (i = 0; i < sampler->state_count; ++i)
4016 free_state(&states[i]);
4019 HeapFree(GetProcessHeap(), 0, states);
4024 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4031 if (param->element_count)
4033 param->data = value;
4035 for (i = 0; i < param->element_count; ++i)
4037 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4039 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4042 WARN("Failed to parse value\n");
4046 old_size += member->bytes;
4052 switch(param->class)
4056 case D3DXPC_MATRIX_ROWS:
4057 case D3DXPC_MATRIX_COLUMNS:
4058 param->data = value;
4062 param->data = value;
4064 for (i = 0; i < param->member_count; ++i)
4066 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4068 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4071 WARN("Failed to parse value\n");
4075 old_size += member->bytes;
4080 switch (param->type)
4083 case D3DXPT_TEXTURE:
4084 case D3DXPT_TEXTURE1D:
4085 case D3DXPT_TEXTURE2D:
4086 case D3DXPT_TEXTURE3D:
4087 case D3DXPT_TEXTURECUBE:
4088 case D3DXPT_PIXELSHADER:
4089 case D3DXPT_VERTEXSHADER:
4090 read_dword(ptr, &id);
4091 TRACE("Id: %u\n", id);
4092 objects[id] = get_parameter_handle(param);
4093 param->data = value;
4096 case D3DXPT_SAMPLER:
4097 case D3DXPT_SAMPLER1D:
4098 case D3DXPT_SAMPLER2D:
4099 case D3DXPT_SAMPLER3D:
4100 case D3DXPT_SAMPLERCUBE:
4102 struct d3dx_sampler *sampler;
4104 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4107 ERR("Out of memory\n");
4108 return E_OUTOFMEMORY;
4111 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4114 HeapFree(GetProcessHeap(), 0, sampler);
4115 WARN("Failed to parse sampler\n");
4119 param->data = sampler;
4124 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4130 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4137 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4139 UINT size = param->bytes;
4143 TRACE("param size: %u\n", size);
4147 value = HeapAlloc(GetProcessHeap(), 0, size);
4150 ERR("Failed to allocate data memory.\n");
4151 return E_OUTOFMEMORY;
4154 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4155 memcpy(value, ptr, size);
4158 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4161 WARN("Failed to parse value\n");
4162 HeapFree(GetProcessHeap(), 0, value);
4169 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4173 read_dword(&ptr, &size);
4174 TRACE("Name size: %#x\n", size);
4181 *name = HeapAlloc(GetProcessHeap(), 0, size);
4184 ERR("Failed to allocate name memory.\n");
4185 return E_OUTOFMEMORY;
4188 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4189 memcpy(*name, ptr, size);
4194 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4198 read_dword(ptr, &size);
4199 TRACE("Data size: %#x\n", size);
4201 *str = HeapAlloc(GetProcessHeap(), 0, size);
4204 ERR("Failed to allocate name memory.\n");
4205 return E_OUTOFMEMORY;
4208 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4209 memcpy(*str, *ptr, size);
4211 *ptr += ((size + 3) & ~3);
4216 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4221 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4223 read_dword(ptr, &size);
4224 TRACE("Data size: %#x\n", size);
4228 TRACE("Size is 0\n");
4229 *(void **)param->data = NULL;
4233 switch (param->type)
4236 /* re-read with size (sizeof(DWORD) = 4) */
4237 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4240 WARN("Failed to parse string data\n");
4245 case D3DXPT_VERTEXSHADER:
4246 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4249 WARN("Failed to create vertex shader\n");
4254 case D3DXPT_PIXELSHADER:
4255 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4258 WARN("Failed to create pixel shader\n");
4264 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4269 *ptr += ((size + 3) & ~3);
4274 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4275 struct d3dx_parameter *parent, UINT flags)
4279 D3DXHANDLE *member_handles = NULL;
4282 param->flags = flags;
4286 read_dword(ptr, ¶m->type);
4287 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4289 read_dword(ptr, ¶m->class);
4290 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4292 read_dword(ptr, &offset);
4293 TRACE("Type name offset: %#x\n", offset);
4294 hr = d3dx9_parse_name(¶m->name, data + offset);
4297 WARN("Failed to parse name\n");
4301 read_dword(ptr, &offset);
4302 TRACE("Type semantic offset: %#x\n", offset);
4303 hr = d3dx9_parse_name(¶m->semantic, data + offset);
4306 WARN("Failed to parse semantic\n");
4310 read_dword(ptr, ¶m->element_count);
4311 TRACE("Elements: %u\n", param->element_count);
4313 switch (param->class)
4316 read_dword(ptr, ¶m->columns);
4317 TRACE("Columns: %u\n", param->columns);
4319 read_dword(ptr, ¶m->rows);
4320 TRACE("Rows: %u\n", param->rows);
4322 /* sizeof(DWORD) * rows * columns */
4323 param->bytes = 4 * param->rows * param->columns;
4327 case D3DXPC_MATRIX_ROWS:
4328 case D3DXPC_MATRIX_COLUMNS:
4329 read_dword(ptr, ¶m->rows);
4330 TRACE("Rows: %u\n", param->rows);
4332 read_dword(ptr, ¶m->columns);
4333 TRACE("Columns: %u\n", param->columns);
4335 /* sizeof(DWORD) * rows * columns */
4336 param->bytes = 4 * param->rows * param->columns;
4340 read_dword(ptr, ¶m->member_count);
4341 TRACE("Members: %u\n", param->member_count);
4345 switch (param->type)
4348 param->bytes = sizeof(LPCSTR);
4351 case D3DXPT_PIXELSHADER:
4352 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4355 case D3DXPT_VERTEXSHADER:
4356 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4359 case D3DXPT_TEXTURE:
4360 case D3DXPT_TEXTURE1D:
4361 case D3DXPT_TEXTURE2D:
4362 case D3DXPT_TEXTURE3D:
4363 case D3DXPT_TEXTURECUBE:
4364 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4367 case D3DXPT_SAMPLER:
4368 case D3DXPT_SAMPLER1D:
4369 case D3DXPT_SAMPLER2D:
4370 case D3DXPT_SAMPLER3D:
4371 case D3DXPT_SAMPLERCUBE:
4376 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4382 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4389 param->type = parent->type;
4390 param->class = parent->class;
4391 param->name = parent->name;
4392 param->semantic = parent->semantic;
4393 param->element_count = 0;
4394 param->annotation_count = 0;
4395 param->member_count = parent->member_count;
4396 param->bytes = parent->bytes;
4397 param->rows = parent->rows;
4398 param->columns = parent->columns;
4401 if (param->element_count)
4403 unsigned int param_bytes = 0;
4404 const char *save_ptr = *ptr;
4406 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4407 if (!member_handles)
4409 ERR("Out of memory\n");
4414 for (i = 0; i < param->element_count; ++i)
4416 struct d3dx_parameter *member;
4419 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4422 ERR("Out of memory\n");
4427 member_handles[i] = get_parameter_handle(member);
4429 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4432 WARN("Failed to parse member\n");
4436 param_bytes += member->bytes;
4439 param->bytes = param_bytes;
4441 else if (param->member_count)
4443 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4444 if (!member_handles)
4446 ERR("Out of memory\n");
4451 for (i = 0; i < param->member_count; ++i)
4453 struct d3dx_parameter *member;
4455 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4458 ERR("Out of memory\n");
4463 member_handles[i] = get_parameter_handle(member);
4465 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4468 WARN("Failed to parse member\n");
4472 param->bytes += member->bytes;
4476 param->member_handles = member_handles;
4486 if (param->element_count) count = param->element_count;
4487 else count = param->member_count;
4489 for (i = 0; i < count; ++i)
4491 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4493 HeapFree(GetProcessHeap(), 0, member_handles);
4498 HeapFree(GetProcessHeap(), 0, param->name);
4499 HeapFree(GetProcessHeap(), 0, param->semantic);
4502 param->semantic = NULL;
4507 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4513 anno->flags = D3DX_PARAMETER_ANNOTATION;
4515 read_dword(ptr, &offset);
4516 TRACE("Typedef offset: %#x\n", offset);
4517 ptr2 = data + offset;
4518 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4521 WARN("Failed to parse type definition\n");
4525 read_dword(ptr, &offset);
4526 TRACE("Value offset: %#x\n", offset);
4527 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4530 WARN("Failed to parse value\n");
4537 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4542 struct d3dx_parameter *parameter;
4544 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4547 ERR("Out of memory\n");
4548 return E_OUTOFMEMORY;
4551 state->type = ST_CONSTANT;
4553 read_dword(ptr, &state->operation);
4554 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4556 read_dword(ptr, &state->index);
4557 TRACE("Index: %#x\n", state->index);
4559 read_dword(ptr, &offset);
4560 TRACE("Typedef offset: %#x\n", offset);
4561 ptr2 = data + offset;
4562 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4565 WARN("Failed to parse type definition\n");
4569 read_dword(ptr, &offset);
4570 TRACE("Value offset: %#x\n", offset);
4571 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4574 WARN("Failed to parse value\n");
4578 state->parameter = get_parameter_handle(parameter);
4584 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4589 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4594 D3DXHANDLE *annotation_handles = NULL;
4597 read_dword(ptr, &offset);
4598 TRACE("Typedef offset: %#x\n", offset);
4599 ptr2 = data + offset;
4601 read_dword(ptr, &offset);
4602 TRACE("Value offset: %#x\n", offset);
4604 read_dword(ptr, ¶m->flags);
4605 TRACE("Flags: %#x\n", param->flags);
4607 read_dword(ptr, ¶m->annotation_count);
4608 TRACE("Annotation count: %u\n", param->annotation_count);
4610 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4613 WARN("Failed to parse type definition\n");
4617 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4620 WARN("Failed to parse value\n");
4624 if (param->annotation_count)
4626 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4627 if (!annotation_handles)
4629 ERR("Out of memory\n");
4634 for (i = 0; i < param->annotation_count; ++i)
4636 struct d3dx_parameter *annotation;
4638 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4641 ERR("Out of memory\n");
4646 annotation_handles[i] = get_parameter_handle(annotation);
4648 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4651 WARN("Failed to parse annotation\n");
4657 param->annotation_handles = annotation_handles;
4663 if (annotation_handles)
4665 for (i = 0; i < param->annotation_count; ++i)
4667 free_parameter(annotation_handles[i], FALSE, FALSE);
4669 HeapFree(GetProcessHeap(), 0, annotation_handles);
4675 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4680 D3DXHANDLE *annotation_handles = NULL;
4681 struct d3dx_state *states = NULL;
4684 read_dword(ptr, &offset);
4685 TRACE("Pass name offset: %#x\n", offset);
4686 hr = d3dx9_parse_name(&name, data + offset);
4689 WARN("Failed to parse name\n");
4693 read_dword(ptr, &pass->annotation_count);
4694 TRACE("Annotation count: %u\n", pass->annotation_count);
4696 read_dword(ptr, &pass->state_count);
4697 TRACE("State count: %u\n", pass->state_count);
4699 if (pass->annotation_count)
4701 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4702 if (!annotation_handles)
4704 ERR("Out of memory\n");
4709 for (i = 0; i < pass->annotation_count; ++i)
4711 struct d3dx_parameter *annotation;
4713 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4716 ERR("Out of memory\n");
4721 annotation_handles[i] = get_parameter_handle(annotation);
4723 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4726 WARN("Failed to parse annotations\n");
4732 if (pass->state_count)
4734 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4737 ERR("Out of memory\n");
4742 for (i = 0; i < pass->state_count; ++i)
4744 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4747 WARN("Failed to parse annotations\n");
4754 pass->annotation_handles = annotation_handles;
4755 pass->states = states;
4761 if (annotation_handles)
4763 for (i = 0; i < pass->annotation_count; ++i)
4765 free_parameter(annotation_handles[i], FALSE, FALSE);
4767 HeapFree(GetProcessHeap(), 0, annotation_handles);
4772 for (i = 0; i < pass->state_count; ++i)
4774 free_state(&states[i]);
4776 HeapFree(GetProcessHeap(), 0, states);
4779 HeapFree(GetProcessHeap(), 0, name);
4784 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4789 D3DXHANDLE *annotation_handles = NULL;
4790 D3DXHANDLE *pass_handles = NULL;
4793 read_dword(ptr, &offset);
4794 TRACE("Technique name offset: %#x\n", offset);
4795 hr = d3dx9_parse_name(&name, data + offset);
4798 WARN("Failed to parse name\n");
4802 read_dword(ptr, &technique->annotation_count);
4803 TRACE("Annotation count: %u\n", technique->annotation_count);
4805 read_dword(ptr, &technique->pass_count);
4806 TRACE("Pass count: %u\n", technique->pass_count);
4808 if (technique->annotation_count)
4810 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4811 if (!annotation_handles)
4813 ERR("Out of memory\n");
4818 for (i = 0; i < technique->annotation_count; ++i)
4820 struct d3dx_parameter *annotation;
4822 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4825 ERR("Out of memory\n");
4830 annotation_handles[i] = get_parameter_handle(annotation);
4832 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4835 WARN("Failed to parse annotations\n");
4841 if (technique->pass_count)
4843 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4846 ERR("Out of memory\n");
4851 for (i = 0; i < technique->pass_count; ++i)
4853 struct d3dx_pass *pass;
4855 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4858 ERR("Out of memory\n");
4863 pass_handles[i] = get_pass_handle(pass);
4865 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
4868 WARN("Failed to parse passes\n");
4874 technique->name = name;
4875 technique->pass_handles = pass_handles;
4876 technique->annotation_handles = annotation_handles;
4884 for (i = 0; i < technique->pass_count; ++i)
4886 free_pass(pass_handles[i]);
4888 HeapFree(GetProcessHeap(), 0, pass_handles);
4891 if (annotation_handles)
4893 for (i = 0; i < technique->annotation_count; ++i)
4895 free_parameter(annotation_handles[i], FALSE, FALSE);
4897 HeapFree(GetProcessHeap(), 0, annotation_handles);
4900 HeapFree(GetProcessHeap(), 0, name);
4905 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
4907 DWORD technique_index;
4908 DWORD index, state_index, usage, element_index;
4909 struct d3dx_state *state;
4910 struct d3dx_parameter *param;
4911 HRESULT hr = E_FAIL;
4913 read_dword(ptr, &technique_index);
4914 TRACE("techn: %u\n", technique_index);
4916 read_dword(ptr, &index);
4917 TRACE("index: %u\n", index);
4919 read_dword(ptr, &element_index);
4920 TRACE("element_index: %u\n", element_index);
4922 read_dword(ptr, &state_index);
4923 TRACE("state_index: %u\n", state_index);
4925 read_dword(ptr, &usage);
4926 TRACE("usage: %u\n", usage);
4928 if (technique_index == 0xffffffff)
4930 struct d3dx_parameter *parameter;
4931 struct d3dx_sampler *sampler;
4933 if (index >= base->parameter_count)
4935 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
4939 parameter = get_parameter_struct(base->parameter_handles[index]);
4940 if (element_index != 0xffffffff)
4942 if (element_index >= parameter->element_count && parameter->element_count != 0)
4944 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
4948 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
4951 sampler = parameter->data;
4952 if (state_index >= sampler->state_count)
4954 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
4958 state = &sampler->states[state_index];
4962 struct d3dx_technique *technique;
4963 struct d3dx_pass *pass;
4965 if (technique_index >= base->technique_count)
4967 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
4971 technique = get_technique_struct(base->technique_handles[technique_index]);
4972 if (index >= technique->pass_count)
4974 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
4978 pass = get_pass_struct(technique->pass_handles[index]);
4979 if (state_index >= pass->state_count)
4981 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
4985 state = &pass->states[state_index];
4988 param = get_parameter_struct(state->parameter);
4993 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
4994 switch (param->type)
4996 case D3DXPT_VERTEXSHADER:
4997 case D3DXPT_PIXELSHADER:
4998 state->type = ST_CONSTANT;
4999 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5006 state->type = ST_FXLC;
5007 hr = d3dx9_copy_data(param->data, ptr);
5011 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5017 state->type = ST_PARAMETER;
5018 hr = d3dx9_copy_data(param->data, ptr);
5021 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5026 FIXME("Unknown usage %x\n", usage);
5033 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5035 const char *ptr = data + start;
5036 D3DXHANDLE *parameter_handles = NULL;
5037 D3DXHANDLE *technique_handles = NULL;
5038 D3DXHANDLE *objects = NULL;
5039 UINT stringcount, objectcount, resourcecount;
5043 read_dword(&ptr, &base->parameter_count);
5044 TRACE("Parameter count: %u\n", base->parameter_count);
5046 read_dword(&ptr, &base->technique_count);
5047 TRACE("Technique count: %u\n", base->technique_count);
5049 skip_dword_unknown(&ptr, 1);
5051 read_dword(&ptr, &objectcount);
5052 TRACE("Object count: %u\n", objectcount);
5054 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5057 ERR("Out of memory\n");
5062 if (base->parameter_count)
5064 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5065 if (!parameter_handles)
5067 ERR("Out of memory\n");
5072 for (i = 0; i < base->parameter_count; ++i)
5074 struct d3dx_parameter *parameter;
5076 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5079 ERR("Out of memory\n");
5084 parameter_handles[i] = get_parameter_handle(parameter);
5086 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5089 WARN("Failed to parse parameter\n");
5095 if (base->technique_count)
5097 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5098 if (!technique_handles)
5100 ERR("Out of memory\n");
5105 for (i = 0; i < base->technique_count; ++i)
5107 struct d3dx_technique *technique;
5109 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5112 ERR("Out of memory\n");
5117 technique_handles[i] = get_technique_handle(technique);
5119 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5122 WARN("Failed to parse technique\n");
5128 /* needed for further parsing */
5129 base->technique_handles = technique_handles;
5130 base->parameter_handles = parameter_handles;
5132 read_dword(&ptr, &stringcount);
5133 TRACE("String count: %u\n", stringcount);
5135 read_dword(&ptr, &resourcecount);
5136 TRACE("Resource count: %u\n", resourcecount);
5138 for (i = 0; i < stringcount; ++i)
5141 struct d3dx_parameter *param;
5143 read_dword(&ptr, &id);
5144 TRACE("Id: %u\n", id);
5146 param = get_parameter_struct(objects[id]);
5148 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5151 WARN("Failed to parse data\n");
5156 for (i = 0; i < resourcecount; ++i)
5158 TRACE("parse resource %u\n", i);
5160 hr = d3dx9_parse_resource(base, data, &ptr);
5163 WARN("Failed to parse data\n");
5168 HeapFree(GetProcessHeap(), 0, objects);
5174 if (technique_handles)
5176 for (i = 0; i < base->technique_count; ++i)
5178 free_technique(technique_handles[i]);
5180 HeapFree(GetProcessHeap(), 0, technique_handles);
5183 if (parameter_handles)
5185 for (i = 0; i < base->parameter_count; ++i)
5187 free_parameter(parameter_handles[i], FALSE, FALSE);
5189 HeapFree(GetProcessHeap(), 0, parameter_handles);
5192 base->technique_handles = NULL;
5193 base->parameter_handles = NULL;
5195 HeapFree(GetProcessHeap(), 0, objects);
5200 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5201 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5204 const char *ptr = data;
5207 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5209 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5211 base->effect = effect;
5213 read_dword(&ptr, &tag);
5214 TRACE("Tag: %x\n", tag);
5216 if (tag != d3dx9_effect_version(9, 1))
5218 /* todo: compile hlsl ascii code */
5219 FIXME("HLSL ascii effects not supported, yet\n");
5221 /* Show the start of the shader for debugging info. */
5222 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5226 read_dword(&ptr, &offset);
5227 TRACE("Offset: %x\n", offset);
5229 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5232 FIXME("Failed to parse effect.\n");
5240 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5241 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5244 struct ID3DXBaseEffectImpl *object = NULL;
5246 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5248 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5251 if (pool) pool->lpVtbl->AddRef(pool);
5252 effect->pool = pool;
5254 IDirect3DDevice9_AddRef(device);
5255 effect->device = device;
5257 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5260 ERR("Out of memory\n");
5265 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5268 FIXME("Failed to parse effect.\n");
5272 effect->base_effect = &object->ID3DXBaseEffect_iface;
5274 /* initialize defaults - check because of unsupported ascii effects */
5275 if (object->technique_handles)
5277 effect->active_technique = object->technique_handles[0];
5278 effect->active_pass = NULL;
5285 HeapFree(GetProcessHeap(), 0, object);
5286 free_effect(effect);
5291 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5294 CONST D3DXMACRO* defines,
5295 LPD3DXINCLUDE include,
5296 LPCSTR skip_constants,
5298 LPD3DXEFFECTPOOL pool,
5299 LPD3DXEFFECT* effect,
5300 LPD3DXBUFFER* compilation_errors)
5302 struct ID3DXEffectImpl *object;
5305 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5306 skip_constants, flags, pool, effect, compilation_errors);
5308 if (!device || !srcdata)
5309 return D3DERR_INVALIDCALL;
5314 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5318 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5321 ERR("Out of memory\n");
5322 return E_OUTOFMEMORY;
5325 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5328 WARN("Failed to initialize shader reflection\n");
5329 HeapFree(GetProcessHeap(), 0, object);
5333 *effect = &object->ID3DXEffect_iface;
5335 TRACE("Created ID3DXEffect %p\n", object);
5340 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5343 CONST D3DXMACRO* defines,
5344 LPD3DXINCLUDE include,
5346 LPD3DXEFFECTPOOL pool,
5347 LPD3DXEFFECT* effect,
5348 LPD3DXBUFFER* compilation_errors)
5350 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5351 include, flags, pool, effect, compilation_errors);
5353 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5356 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5359 struct ID3DXBaseEffectImpl *object = NULL;
5361 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5363 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5366 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5369 ERR("Out of memory\n");
5374 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5377 FIXME("Failed to parse effect.\n");
5381 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5387 HeapFree(GetProcessHeap(), 0, object);
5388 free_effect_compiler(compiler);
5393 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5395 CONST D3DXMACRO *defines,
5396 LPD3DXINCLUDE include,
5398 LPD3DXEFFECTCOMPILER *compiler,
5399 LPD3DXBUFFER *parse_errors)
5401 struct ID3DXEffectCompilerImpl *object;
5404 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5405 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5407 if (!srcdata || !compiler)
5409 WARN("Invalid arguments supplied\n");
5410 return D3DERR_INVALIDCALL;
5413 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5416 ERR("Out of memory\n");
5417 return E_OUTOFMEMORY;
5420 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5423 WARN("Failed to initialize effect compiler\n");
5424 HeapFree(GetProcessHeap(), 0, object);
5428 *compiler = &object->ID3DXEffectCompiler_iface;
5430 TRACE("Created ID3DXEffectCompiler %p\n", object);
5435 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5437 struct ID3DXEffectPoolImpl
5439 ID3DXEffectPool ID3DXEffectPool_iface;
5443 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5445 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5448 /*** IUnknown methods ***/
5449 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5451 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5453 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5455 if (IsEqualGUID(riid, &IID_IUnknown) ||
5456 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5458 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5463 WARN("Interface %s not found\n", debugstr_guid(riid));
5465 return E_NOINTERFACE;
5468 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5470 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5472 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5474 return InterlockedIncrement(&This->ref);
5477 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5479 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5480 ULONG ref = InterlockedDecrement(&This->ref);
5482 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5485 HeapFree(GetProcessHeap(), 0, This);
5490 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5492 /*** IUnknown methods ***/
5493 ID3DXEffectPoolImpl_QueryInterface,
5494 ID3DXEffectPoolImpl_AddRef,
5495 ID3DXEffectPoolImpl_Release
5498 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5500 struct ID3DXEffectPoolImpl *object;
5502 TRACE("(%p)\n", pool);
5505 return D3DERR_INVALIDCALL;
5507 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5510 ERR("Out of memory\n");
5511 return E_OUTOFMEMORY;
5514 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5517 *pool = &object->ID3DXEffectPool_iface;
5522 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5523 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5524 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5530 TRACE("(%s): relay\n", debugstr_w(srcfile));
5532 if (!device || !srcfile)
5533 return D3DERR_INVALIDCALL;
5535 ret = map_view_of_file(srcfile, &buffer, &size);
5538 return D3DXERR_INVALIDDATA;
5540 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5541 UnmapViewOfFile(buffer);
5546 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5547 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5548 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5554 TRACE("(void): relay\n");
5557 return D3DERR_INVALIDCALL;
5559 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5560 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5561 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5563 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5564 HeapFree(GetProcessHeap(), 0, srcfileW);
5569 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5570 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5571 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5573 TRACE("(void): relay\n");
5574 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5577 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5578 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5579 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5581 TRACE("(void): relay\n");
5582 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5585 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5586 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5587 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5591 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5594 return D3DERR_INVALIDCALL;
5596 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5604 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5607 return D3DXERR_INVALIDDATA;
5609 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5612 return D3DXERR_INVALIDDATA;
5615 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5616 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5617 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5621 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5624 return D3DERR_INVALIDCALL;
5626 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5634 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5637 return D3DXERR_INVALIDDATA;
5639 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5642 return D3DXERR_INVALIDDATA;
5645 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5646 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5647 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5649 TRACE("(void): relay\n");
5650 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5653 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5654 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5655 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5657 TRACE("(void): relay\n");
5658 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5661 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5662 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5668 TRACE("(%s): relay\n", debugstr_w(srcfile));
5671 return D3DERR_INVALIDCALL;
5673 ret = map_view_of_file(srcfile, &buffer, &size);
5676 return D3DXERR_INVALIDDATA;
5678 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5679 UnmapViewOfFile(buffer);
5684 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5685 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5691 TRACE("(void): relay\n");
5694 return D3DERR_INVALIDCALL;
5696 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5697 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5698 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5700 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5701 HeapFree(GetProcessHeap(), 0, srcfileW);
5706 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5707 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5711 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5713 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5721 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5724 return D3DXERR_INVALIDDATA;
5726 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5729 return D3DXERR_INVALIDDATA;
5732 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5733 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5737 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5739 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5747 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5750 return D3DXERR_INVALIDDATA;
5752 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5755 return D3DXERR_INVALIDDATA;