2 * Copyright 2010 Christian Costa
3 * Copyright 2011 Rico Schüller
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
22 #define NONAMELESSUNION
23 #include "wine/debug.h"
24 #include "wine/unicode.h"
28 #include "d3dx9_36_private.h"
30 /* Constants for special INT/FLOAT conversation */
31 #define INT_FLOAT_MULTI 255.0f
32 #define INT_FLOAT_MULTI_INVERSE (1/INT_FLOAT_MULTI)
34 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
36 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
37 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
38 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
85 enum SHADER_CONSTANT_TYPE
102 struct d3dx_parameter
107 D3DXPARAMETER_CLASS class;
108 D3DXPARAMETER_TYPE type;
112 UINT annotation_count;
117 D3DXHANDLE *annotation_handles;
118 D3DXHANDLE *member_handles;
125 enum STATE_TYPE type;
126 D3DXHANDLE parameter;
132 struct d3dx_state *states;
139 UINT annotation_count;
141 struct d3dx_state *states;
142 D3DXHANDLE *annotation_handles;
145 struct d3dx_technique
149 UINT annotation_count;
151 D3DXHANDLE *annotation_handles;
152 D3DXHANDLE *pass_handles;
155 struct ID3DXBaseEffectImpl
157 ID3DXBaseEffect ID3DXBaseEffect_iface;
160 struct ID3DXEffectImpl *effect;
162 UINT parameter_count;
163 UINT technique_count;
165 D3DXHANDLE *parameter_handles;
166 D3DXHANDLE *technique_handles;
169 struct ID3DXEffectImpl
171 ID3DXEffect ID3DXEffect_iface;
174 LPD3DXEFFECTSTATEMANAGER manager;
175 LPDIRECT3DDEVICE9 device;
176 LPD3DXEFFECTPOOL pool;
177 D3DXHANDLE active_technique;
178 D3DXHANDLE active_pass;
180 ID3DXBaseEffect *base_effect;
183 struct ID3DXEffectCompilerImpl
185 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
188 ID3DXBaseEffect *base_effect;
191 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
192 struct d3dx_parameter *parameter, LPCSTR name);
193 static struct d3dx_parameter *get_annotation_by_name(UINT handlecount, D3DXHANDLE *handles, LPCSTR name);
194 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
195 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
199 enum STATE_CLASS class;
206 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
207 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
208 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
209 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
210 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
211 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
212 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
213 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
214 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
215 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
216 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
217 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
218 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
219 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
220 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
221 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
222 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
223 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
224 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
225 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
226 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
227 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
228 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
229 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
230 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
231 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
232 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
233 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
234 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
235 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
236 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
237 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
238 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
239 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
240 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
241 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
242 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
243 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
244 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
245 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
246 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
247 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
248 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
249 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
250 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
251 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
252 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
253 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
254 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
255 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
256 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
257 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
258 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
259 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
260 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
261 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
262 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
263 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
264 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
265 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
266 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
267 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
268 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
269 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
270 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
271 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
272 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
273 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
274 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
275 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
276 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
277 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
278 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
279 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
280 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
281 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
282 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
283 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
284 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
285 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
286 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
287 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
288 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
289 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
290 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
291 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
292 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
293 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
294 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
295 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
296 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
297 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
298 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
299 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
300 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
301 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
302 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
303 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
304 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
305 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
306 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
307 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
308 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
310 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
311 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
312 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
313 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
314 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
315 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
316 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
317 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
318 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
319 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
320 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
321 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
322 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
323 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
324 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
325 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
326 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
327 {SC_TEXTURESTAGE, D3DTSS_CONSTANT, "D3DTSS_CONSTANT"},
329 {SC_NPATCHMODE, 0, "NPatchMode"},
333 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
334 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
335 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
336 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
338 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
339 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
340 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
341 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
342 {SC_MATERIAL, MT_POWER, "MaterialPower"},
344 {SC_LIGHT, LT_TYPE, "LightType"},
345 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
346 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
347 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
348 {SC_LIGHT, LT_POSITION, "LightPosition"},
349 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
350 {SC_LIGHT, LT_RANGE, "LightRange"},
351 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
352 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
353 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
354 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
355 {SC_LIGHT, LT_THETA, "LightTheta"},
356 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
358 {SC_LIGHTENABLE, 0, "LightEnable"},
360 {SC_VERTEXSHADER, 0, "Vertexshader"},
362 {SC_PIXELSHADER, 0, "Pixelshader"},
363 /* Shader constants */
364 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
365 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
366 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
367 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
368 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
369 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
370 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
371 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
372 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
373 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
374 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
375 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
376 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
377 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
378 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
379 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
381 {SC_TEXTURE, 0, "Texture"},
383 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
384 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
385 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
386 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
387 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
388 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
389 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
390 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
391 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
392 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
393 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
394 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
395 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
397 {SC_SETSAMPLER, 0, "Sampler"},
400 static inline void read_dword(const char **ptr, DWORD *d)
402 memcpy(d, *ptr, sizeof(*d));
406 static void skip_dword_unknown(const char **ptr, unsigned int count)
411 FIXME("Skipping %u unknown DWORDs:\n", count);
412 for (i = 0; i < count; ++i)
415 FIXME("\t0x%08x\n", d);
419 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
421 return (struct d3dx_parameter *) handle;
424 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
426 return (struct d3dx_pass *) handle;
429 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
431 return (struct d3dx_technique *) handle;
434 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
436 return (D3DXHANDLE) parameter;
439 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
441 return (D3DXHANDLE) technique;
444 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
446 return (D3DXHANDLE) pass;
449 static struct d3dx_technique *get_technique_by_name(struct ID3DXBaseEffectImpl *base, LPCSTR name)
453 if (!name) return NULL;
455 for (i = 0; i < base->technique_count; ++i)
457 struct d3dx_technique *tech = get_technique_struct(base->technique_handles[i]);
459 if (!strcmp(tech->name, name)) return tech;
465 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
467 struct d3dx_technique *tech = NULL;
470 for (i = 0; i < base->technique_count; ++i)
472 if (base->technique_handles[i] == technique)
474 tech = get_technique_struct(technique);
479 if (!tech) tech = get_technique_by_name(base, technique);
484 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
488 for (i = 0; i < base->technique_count; ++i)
490 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
492 for (k = 0; k < technique->pass_count; ++k)
494 if (technique->pass_handles[k] == pass)
496 return get_pass_struct(pass);
504 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
506 unsigned int i, count;
507 struct d3dx_parameter *p;
509 for (i = 0; i < param->annotation_count; ++i)
511 if (param->annotation_handles[i] == parameter)
513 return get_parameter_struct(parameter);
516 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
520 if (param->element_count) count = param->element_count;
521 else count = param->member_count;
523 for (i = 0; i < count; ++i)
525 if (param->member_handles[i] == parameter)
527 return get_parameter_struct(parameter);
530 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
537 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
539 unsigned int i, k, m;
540 struct d3dx_parameter *p;
542 for (i = 0; i < base->parameter_count; ++i)
544 if (base->parameter_handles[i] == parameter)
546 return get_parameter_struct(parameter);
549 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
553 for (i = 0; i < base->technique_count; ++i)
555 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
557 for (k = 0; k < technique->pass_count; ++k)
559 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
561 for (m = 0; m < pass->annotation_count; ++m)
563 if (pass->annotation_handles[i] == parameter)
565 return get_parameter_struct(parameter);
568 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
573 for (k = 0; k < technique->annotation_count; ++k)
575 if (technique->annotation_handles[k] == parameter)
577 return get_parameter_struct(parameter);
580 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
588 static inline struct d3dx_parameter *get_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
590 struct d3dx_parameter *param = is_valid_parameter(base, parameter);
592 if (!param) param = get_parameter_by_name(base, NULL, parameter);
597 static void free_state(struct d3dx_state *state)
599 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
602 static void free_sampler(struct d3dx_sampler *sampler)
606 for (i = 0; i < sampler->state_count; ++i)
608 free_state(&sampler->states[i]);
610 HeapFree(GetProcessHeap(), 0, sampler->states);
613 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
615 free_parameter_state(handle, element, child, ST_CONSTANT);
618 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
621 struct d3dx_parameter *param = get_parameter_struct(handle);
623 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
624 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
631 if (param->annotation_handles)
633 for (i = 0; i < param->annotation_count; ++i)
635 free_parameter(param->annotation_handles[i], FALSE, FALSE);
637 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
640 if (param->member_handles)
644 if (param->element_count) count = param->element_count;
645 else count = param->member_count;
647 for (i = 0; i < count; ++i)
649 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
651 HeapFree(GetProcessHeap(), 0, param->member_handles);
654 if (param->class == D3DXPC_OBJECT && !param->element_count)
659 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
660 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
664 case D3DXPT_TEXTURE1D:
665 case D3DXPT_TEXTURE2D:
666 case D3DXPT_TEXTURE3D:
667 case D3DXPT_TEXTURECUBE:
668 case D3DXPT_PIXELSHADER:
669 case D3DXPT_VERTEXSHADER:
670 if (st == ST_CONSTANT)
672 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
676 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
678 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
682 case D3DXPT_SAMPLER1D:
683 case D3DXPT_SAMPLER2D:
684 case D3DXPT_SAMPLER3D:
685 case D3DXPT_SAMPLERCUBE:
686 if (st == ST_CONSTANT)
688 free_sampler((struct d3dx_sampler *)param->data);
692 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
694 /* samplers have always own data, so free that */
695 HeapFree(GetProcessHeap(), 0, param->data);
699 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
707 if (st != ST_CONSTANT)
709 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
711 HeapFree(GetProcessHeap(), 0, param->data);
715 /* only the parent has to release name and semantic */
718 HeapFree(GetProcessHeap(), 0, param->name);
719 HeapFree(GetProcessHeap(), 0, param->semantic);
722 HeapFree(GetProcessHeap(), 0, param);
725 static void free_pass(D3DXHANDLE handle)
728 struct d3dx_pass *pass = get_pass_struct(handle);
730 TRACE("Free pass %p\n", pass);
737 if (pass->annotation_handles)
739 for (i = 0; i < pass->annotation_count; ++i)
741 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
743 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
748 for (i = 0; i < pass->state_count; ++i)
750 free_state(&pass->states[i]);
752 HeapFree(GetProcessHeap(), 0, pass->states);
755 HeapFree(GetProcessHeap(), 0, pass->name);
756 HeapFree(GetProcessHeap(), 0, pass);
759 static void free_technique(D3DXHANDLE handle)
762 struct d3dx_technique *technique = get_technique_struct(handle);
764 TRACE("Free technique %p\n", technique);
771 if (technique->annotation_handles)
773 for (i = 0; i < technique->annotation_count; ++i)
775 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
777 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
780 if (technique->pass_handles)
782 for (i = 0; i < technique->pass_count; ++i)
784 free_pass(technique->pass_handles[i]);
786 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
789 HeapFree(GetProcessHeap(), 0, technique->name);
790 HeapFree(GetProcessHeap(), 0, technique);
793 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
797 TRACE("Free base effect %p\n", base);
799 if (base->parameter_handles)
801 for (i = 0; i < base->parameter_count; ++i)
803 free_parameter(base->parameter_handles[i], FALSE, FALSE);
805 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
808 if (base->technique_handles)
810 for (i = 0; i < base->technique_count; ++i)
812 free_technique(base->technique_handles[i]);
814 HeapFree(GetProcessHeap(), 0, base->technique_handles);
818 static void free_effect(struct ID3DXEffectImpl *effect)
820 TRACE("Free effect %p\n", effect);
822 if (effect->base_effect)
824 effect->base_effect->lpVtbl->Release(effect->base_effect);
829 effect->pool->lpVtbl->Release(effect->pool);
834 IUnknown_Release(effect->manager);
837 IDirect3DDevice9_Release(effect->device);
840 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
842 TRACE("Free effect compiler %p\n", compiler);
844 if (compiler->base_effect)
846 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
850 static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector)
854 for (i = 0; i < 4; ++i)
856 if (i < param->columns)
857 set_number((FLOAT *)vector + i, D3DXPT_FLOAT, (DWORD *)param->data + i, param->type);
859 ((FLOAT *)vector)[i] = 0.0f;
863 static void set_vector(struct d3dx_parameter *param, CONST D3DXVECTOR4 *vector)
867 for (i = 0; i < param->columns; ++i)
869 set_number((FLOAT *)param->data + i, param->type, (FLOAT *)vector + i, D3DXPT_FLOAT);
873 static void get_matrix(struct d3dx_parameter *param, D3DXMATRIX *matrix, BOOL transpose)
877 for (i = 0; i < 4; ++i)
879 for (k = 0; k < 4; ++k)
881 FLOAT *tmp = transpose ? (FLOAT *)&matrix->u.m[k][i] : (FLOAT *)&matrix->u.m[i][k];
883 if ((i < param->rows) && (k < param->columns))
884 set_number(tmp, D3DXPT_FLOAT, (DWORD *)param->data + i * param->columns + k, param->type);
891 static void set_matrix(struct d3dx_parameter *param, const D3DXMATRIX *matrix, BOOL transpose)
895 for (i = 0; i < param->rows; ++i)
897 for (k = 0; k < param->columns; ++k)
899 set_number((FLOAT *)param->data + i * param->columns + k, param->type,
900 transpose ? &matrix->u.m[k][i] : &matrix->u.m[i][k], D3DXPT_FLOAT);
905 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
908 struct d3dx_parameter *temp_parameter;
911 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
913 if (!name || !*name) return NULL;
915 element = atoi(name);
916 part = strchr(name, ']') + 1;
918 /* check for empty [] && element range */
919 if ((part - name) > 1 && parameter->element_count > element)
921 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
926 return get_parameter_by_name(NULL, temp_parameter, part);
929 return get_annotation_by_name(temp_parameter->annotation_count, temp_parameter->annotation_handles, part);
932 TRACE("Returning parameter %p\n", temp_parameter);
933 return temp_parameter;
936 FIXME("Unhandled case \"%c\"\n", *--part);
941 TRACE("Parameter not found\n");
945 static struct d3dx_parameter *get_annotation_by_name(UINT handlecount, D3DXHANDLE *handles, LPCSTR name)
948 struct d3dx_parameter *temp_parameter;
951 TRACE("handlecount %u, handles %p, name %s\n", handlecount, handles, debugstr_a(name));
953 if (!name || !*name) return NULL;
955 length = strcspn( name, "[.@" );
956 part = name + length;
958 for (i = 0; i < handlecount; ++i)
960 temp_parameter = get_parameter_struct(handles[i]);
962 if (!strcmp(temp_parameter->name, name))
964 TRACE("Returning parameter %p\n", temp_parameter);
965 return temp_parameter;
967 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
972 return get_parameter_by_name(NULL, temp_parameter, part);
975 return get_parameter_element_by_name(temp_parameter, part);
978 FIXME("Unhandled case \"%c\"\n", *--part);
984 TRACE("Parameter not found\n");
988 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
989 struct d3dx_parameter *parameter, LPCSTR name)
991 UINT i, count, length;
992 struct d3dx_parameter *temp_parameter;
996 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
998 if (!name || !*name) return NULL;
1002 count = base->parameter_count;
1003 handles = base->parameter_handles;
1007 count = parameter->member_count;
1008 handles = parameter->member_handles;
1011 length = strcspn( name, "[.@" );
1012 part = name + length;
1014 for (i = 0; i < count; i++)
1016 temp_parameter = get_parameter_struct(handles[i]);
1018 if (!strcmp(temp_parameter->name, name))
1020 TRACE("Returning parameter %p\n", temp_parameter);
1021 return temp_parameter;
1023 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1028 return get_parameter_by_name(NULL, temp_parameter, part);
1031 return get_annotation_by_name(temp_parameter->annotation_count, temp_parameter->annotation_handles, part);
1034 return get_parameter_element_by_name(temp_parameter, part);
1037 FIXME("Unhandled case \"%c\"\n", *--part);
1043 TRACE("Parameter not found\n");
1047 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1049 return (0xfeff0000 | ((major) << 8) | (minor));
1052 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1054 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1057 /*** IUnknown methods ***/
1058 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1060 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
1062 if (IsEqualGUID(riid, &IID_IUnknown) ||
1063 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1065 iface->lpVtbl->AddRef(iface);
1070 ERR("Interface %s not found\n", debugstr_guid(riid));
1072 return E_NOINTERFACE;
1075 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1077 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1079 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1081 return InterlockedIncrement(&This->ref);
1084 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1086 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1087 ULONG ref = InterlockedDecrement(&This->ref);
1089 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1093 free_base_effect(This);
1094 HeapFree(GetProcessHeap(), 0, This);
1100 /*** ID3DXBaseEffect methods ***/
1101 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1103 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1105 FIXME("iface %p, desc %p partial stub\n", This, desc);
1109 WARN("Invalid argument specified.\n");
1110 return D3DERR_INVALIDCALL;
1113 /* Todo: add creator and function count */
1114 desc->Creator = NULL;
1115 desc->Functions = 0;
1116 desc->Parameters = This->parameter_count;
1117 desc->Techniques = This->technique_count;
1122 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1124 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1125 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1127 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1129 if (!desc || !param)
1131 WARN("Invalid argument specified.\n");
1132 return D3DERR_INVALIDCALL;
1135 desc->Name = param->name;
1136 desc->Semantic = param->semantic;
1137 desc->Class = param->class;
1138 desc->Type = param->type;
1139 desc->Rows = param->rows;
1140 desc->Columns = param->columns;
1141 desc->Elements = param->element_count;
1142 desc->Annotations = param->annotation_count;
1143 desc->StructMembers = param->member_count;
1144 desc->Flags = param->flags;
1145 desc->Bytes = param->bytes;
1150 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1152 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1153 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1155 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1159 WARN("Invalid argument specified.\n");
1160 return D3DERR_INVALIDCALL;
1163 desc->Name = tech->name;
1164 desc->Passes = tech->pass_count;
1165 desc->Annotations = tech->annotation_count;
1170 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1172 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1173 struct d3dx_pass *p = is_valid_pass(This, pass);
1175 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1179 WARN("Invalid argument specified.\n");
1180 return D3DERR_INVALIDCALL;
1183 desc->Name = p->name;
1184 desc->Annotations = p->annotation_count;
1186 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1187 desc->pVertexShaderFunction = NULL;
1188 desc->pPixelShaderFunction = NULL;
1193 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1195 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1197 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1202 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1204 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1205 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1207 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1211 if (index < This->parameter_count)
1213 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1214 return This->parameter_handles[index];
1219 if (param && !param->element_count && index < param->member_count)
1221 TRACE("Returning parameter %p\n", param->member_handles[index]);
1222 return param->member_handles[index];
1226 WARN("Invalid argument specified.\n");
1231 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1233 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1234 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1237 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1241 handle = get_parameter_handle(param);
1242 TRACE("Returning parameter %p\n", handle);
1246 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1247 TRACE("Returning parameter %p\n", handle);
1252 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1254 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1255 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1256 struct d3dx_parameter *temp_param;
1259 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1263 for (i = 0; i < This->parameter_count; ++i)
1265 temp_param = get_parameter_struct(This->parameter_handles[i]);
1267 if (!temp_param->semantic)
1271 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1272 return This->parameter_handles[i];
1277 if (!strcasecmp(temp_param->semantic, semantic))
1279 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1280 return This->parameter_handles[i];
1286 for (i = 0; i < param->member_count; ++i)
1288 temp_param = get_parameter_struct(param->member_handles[i]);
1290 if (!temp_param->semantic)
1294 TRACE("Returning parameter %p\n", param->member_handles[i]);
1295 return param->member_handles[i];
1300 if (!strcasecmp(temp_param->semantic, semantic))
1302 TRACE("Returning parameter %p\n", param->member_handles[i]);
1303 return param->member_handles[i];
1308 WARN("Invalid argument specified\n");
1313 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1315 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1316 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1318 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1322 if (index < This->parameter_count)
1324 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1325 return This->parameter_handles[index];
1330 if (index < param->element_count)
1332 TRACE("Returning parameter %p\n", param->member_handles[index]);
1333 return param->member_handles[index];
1337 WARN("Invalid argument specified\n");
1342 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1344 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1346 TRACE("iface %p, index %u\n", This, index);
1348 if (index >= This->technique_count)
1350 WARN("Invalid argument specified.\n");
1354 TRACE("Returning technique %p\n", This->technique_handles[index]);
1356 return This->technique_handles[index];
1359 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1361 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1362 struct d3dx_technique *tech = get_technique_by_name(This, name);
1364 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1368 D3DXHANDLE t = get_technique_handle(tech);
1369 TRACE("Returning technique %p\n", t);
1373 WARN("Invalid argument specified.\n");
1378 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1380 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1381 struct d3dx_technique *tech = is_valid_technique(This, technique);
1383 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1385 if (tech && index < tech->pass_count)
1387 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1388 return tech->pass_handles[index];
1391 WARN("Invalid argument specified.\n");
1396 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1398 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1399 struct d3dx_technique *tech = is_valid_technique(This, technique);
1401 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1407 for (i = 0; i < tech->pass_count; ++i)
1409 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1411 if (!strcmp(pass->name, name))
1413 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1414 return tech->pass_handles[i];
1419 WARN("Invalid argument specified.\n");
1424 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1426 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1428 FIXME("iface %p, index %u stub\n", This, index);
1433 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1435 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1437 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1442 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1444 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1445 struct d3dx_parameter *param = get_valid_parameter(This, object);
1446 struct d3dx_pass *pass = is_valid_pass(This, object);
1447 struct d3dx_technique *technique = is_valid_technique(This, object);
1448 UINT annotation_count = 0;
1449 D3DXHANDLE *annotation_handles = NULL;
1451 TRACE("iface %p, object %p, index %u\n", This, object, index);
1455 annotation_count = pass->annotation_count;
1456 annotation_handles = pass->annotation_handles;
1460 annotation_count = technique->annotation_count;
1461 annotation_handles = technique->annotation_handles;
1465 annotation_count = param->annotation_count;
1466 annotation_handles = param->annotation_handles;
1470 FIXME("Functions are not handled, yet!\n");
1473 if (index < annotation_count)
1475 TRACE("Returning parameter %p\n", annotation_handles[index]);
1476 return annotation_handles[index];
1479 WARN("Invalid argument specified\n");
1484 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1486 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1487 struct d3dx_parameter *param = get_valid_parameter(This, object);
1488 struct d3dx_pass *pass = is_valid_pass(This, object);
1489 struct d3dx_technique *technique = is_valid_technique(This, object);
1490 struct d3dx_parameter *anno = NULL;
1491 UINT annotation_count = 0;
1492 D3DXHANDLE *annotation_handles = NULL;
1494 TRACE("iface %p, object %p, name %s\n", This, object, debugstr_a(name));
1498 WARN("Invalid argument specified\n");
1504 annotation_count = pass->annotation_count;
1505 annotation_handles = pass->annotation_handles;
1509 annotation_count = technique->annotation_count;
1510 annotation_handles = technique->annotation_handles;
1514 annotation_count = param->annotation_count;
1515 annotation_handles = param->annotation_handles;
1519 FIXME("Functions are not handled, yet!\n");
1522 anno = get_annotation_by_name(annotation_count, annotation_handles, name);
1525 TRACE("Returning parameter %p\n", anno);
1526 return get_parameter_handle(anno);
1529 WARN("Invalid argument specified\n");
1534 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1536 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1537 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1539 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1543 WARN("Invalid parameter %p specified\n", parameter);
1544 return D3DERR_INVALIDCALL;
1547 /* samplers don't touch data */
1548 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1549 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1550 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1552 TRACE("Sampler: returning E_FAIL\n");
1556 if (data && param->bytes <= bytes)
1558 switch (param->type)
1564 TRACE("Copy %u bytes\n", param->bytes);
1565 memcpy(param->data, data, param->bytes);
1569 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1576 WARN("Invalid argument specified\n");
1578 return D3DERR_INVALIDCALL;
1581 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1583 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1584 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1586 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1590 WARN("Invalid parameter %p specified\n", parameter);
1591 return D3DERR_INVALIDCALL;
1594 /* samplers don't touch data */
1595 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1596 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1597 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1599 TRACE("Sampler: returning E_FAIL\n");
1603 if (data && param->bytes <= bytes)
1605 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1607 switch (param->type)
1616 case D3DXPT_VERTEXSHADER:
1617 case D3DXPT_PIXELSHADER:
1618 case D3DXPT_TEXTURE:
1619 case D3DXPT_TEXTURE1D:
1620 case D3DXPT_TEXTURE2D:
1621 case D3DXPT_TEXTURE3D:
1622 case D3DXPT_TEXTURECUBE:
1626 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1628 IUnknown *unk = ((IUnknown **)param->data)[i];
1629 if (unk) IUnknown_AddRef(unk);
1635 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1639 TRACE("Copy %u bytes\n", param->bytes);
1640 memcpy(data, param->data, param->bytes);
1644 WARN("Invalid argument specified\n");
1646 return D3DERR_INVALIDCALL;
1649 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1651 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1652 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1654 TRACE("iface %p, parameter %p, b %s\n", This, parameter, b ? "TRUE" : "FALSE");
1656 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1658 set_number(param->data, param->type, &b, D3DXPT_BOOL);
1662 WARN("Invalid argument specified\n");
1664 return D3DERR_INVALIDCALL;
1667 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1669 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1670 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1672 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1674 if (b && param && !param->element_count && param->rows == 1 && param->columns == 1)
1676 set_number(b, D3DXPT_BOOL, param->data, param->type);
1677 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1681 WARN("Invalid argument specified\n");
1683 return D3DERR_INVALIDCALL;
1686 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1688 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1689 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1691 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1695 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1697 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1699 switch (param->class)
1703 case D3DXPC_MATRIX_ROWS:
1704 for (i = 0; i < size; ++i)
1706 /* don't crop the input, use D3DXPT_INT instead of D3DXPT_BOOL */
1707 set_number((DWORD *)param->data + i, param->type, &b[i], D3DXPT_INT);
1716 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1721 WARN("Invalid argument specified\n");
1723 return D3DERR_INVALIDCALL;
1726 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1728 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1729 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1731 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1733 if (b && param && (param->class == D3DXPC_SCALAR
1734 || param->class == D3DXPC_VECTOR
1735 || param->class == D3DXPC_MATRIX_ROWS
1736 || param->class == D3DXPC_MATRIX_COLUMNS))
1738 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1740 for (i = 0; i < size; ++i)
1742 set_number(&b[i], D3DXPT_BOOL, (DWORD *)param->data + i, param->type);
1747 WARN("Invalid argument specified\n");
1749 return D3DERR_INVALIDCALL;
1752 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1754 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1755 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1757 TRACE("iface %p, parameter %p, n %i\n", This, parameter, n);
1759 if (param && !param->element_count)
1761 if (param->rows == 1 && param->columns == 1)
1763 set_number(param->data, param->type, &n, D3DXPT_INT);
1768 * Split the value, if parameter is a vector with dimension 3 or 4.
1770 if (param->type == D3DXPT_FLOAT &&
1771 ((param->class == D3DXPC_VECTOR && param->columns != 2) ||
1772 (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1774 TRACE("Vector fixup\n");
1776 *(FLOAT *)param->data = ((n & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
1777 ((FLOAT *)param->data)[1] = ((n & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
1778 ((FLOAT *)param->data)[2] = (n & 0xff) * INT_FLOAT_MULTI_INVERSE;
1779 if (param->rows * param->columns > 3)
1781 ((FLOAT *)param->data)[3] = ((n & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
1787 WARN("Invalid argument specified\n");
1789 return D3DERR_INVALIDCALL;
1792 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1794 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1795 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1797 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1799 if (n && param && !param->element_count)
1801 if (param->columns == 1 && param->rows == 1)
1803 set_number(n, D3DXPT_INT, param->data, param->type);
1804 TRACE("Returning %i\n", *n);
1808 if (param->type == D3DXPT_FLOAT &&
1809 ((param->class == D3DXPC_VECTOR && param->columns != 2)
1810 || (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1812 TRACE("Vector fixup\n");
1814 /* all components (3,4) are clamped (0,255) and put in the INT */
1815 *n = (INT)(min(max(0.0f, *((FLOAT *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI);
1816 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
1817 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
1818 if (param->columns * param->rows > 3)
1820 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
1823 TRACE("Returning %i\n", *n);
1828 WARN("Invalid argument specified\n");
1830 return D3DERR_INVALIDCALL;
1833 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1835 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1836 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1838 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1842 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1844 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1846 switch (param->class)
1850 case D3DXPC_MATRIX_ROWS:
1851 for (i = 0; i < size; ++i)
1853 set_number((DWORD *)param->data + i, param->type, &n[i], D3DXPT_INT);
1862 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1867 WARN("Invalid argument specified\n");
1869 return D3DERR_INVALIDCALL;
1872 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1874 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1875 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1877 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1879 if (n && param && (param->class == D3DXPC_SCALAR
1880 || param->class == D3DXPC_VECTOR
1881 || param->class == D3DXPC_MATRIX_ROWS
1882 || param->class == D3DXPC_MATRIX_COLUMNS))
1884 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1886 for (i = 0; i < size; ++i)
1888 set_number(&n[i], D3DXPT_INT, (DWORD *)param->data + i, param->type);
1893 WARN("Invalid argument specified\n");
1895 return D3DERR_INVALIDCALL;
1898 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1900 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1901 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1903 TRACE("iface %p, parameter %p, f %f\n", This, parameter, f);
1905 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1907 set_number((DWORD *)param->data, param->type, &f, D3DXPT_FLOAT);
1911 WARN("Invalid argument specified\n");
1913 return D3DERR_INVALIDCALL;
1916 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1918 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1919 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1921 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1923 if (f && param && !param->element_count && param->columns == 1 && param->rows == 1)
1925 set_number(f, D3DXPT_FLOAT, (DWORD *)param->data, param->type);
1926 TRACE("Returning %f\n", *f);
1930 WARN("Invalid argument specified\n");
1932 return D3DERR_INVALIDCALL;
1935 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1937 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1938 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1940 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1944 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1946 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1948 switch (param->class)
1952 case D3DXPC_MATRIX_ROWS:
1953 for (i = 0; i < size; ++i)
1955 set_number((DWORD *)param->data + i, param->type, &f[i], D3DXPT_FLOAT);
1964 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1969 WARN("Invalid argument specified\n");
1971 return D3DERR_INVALIDCALL;
1974 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1976 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1977 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1979 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1981 if (f && param && (param->class == D3DXPC_SCALAR
1982 || param->class == D3DXPC_VECTOR
1983 || param->class == D3DXPC_MATRIX_ROWS
1984 || param->class == D3DXPC_MATRIX_COLUMNS))
1986 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1988 for (i = 0; i < size; ++i)
1990 set_number(&f[i], D3DXPT_FLOAT, (DWORD *)param->data + i, param->type);
1995 WARN("Invalid argument specified\n");
1997 return D3DERR_INVALIDCALL;
2000 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2002 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2003 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2005 TRACE("iface %p, parameter %p, vector %p\n", This, parameter, vector);
2007 if (param && !param->element_count)
2009 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2011 switch (param->class)
2015 if (param->type == D3DXPT_INT && param->bytes == 4)
2019 TRACE("INT fixup\n");
2020 tmp = (DWORD)(max(min(vector->z, 1.0f), 0.0f) * INT_FLOAT_MULTI);
2021 tmp += ((DWORD)(max(min(vector->y, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 8;
2022 tmp += ((DWORD)(max(min(vector->x, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 16;
2023 tmp += ((DWORD)(max(min(vector->w, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 24;
2025 *(INT *)param->data = tmp;
2028 set_vector(param, vector);
2031 case D3DXPC_MATRIX_ROWS:
2037 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2042 WARN("Invalid argument specified\n");
2044 return D3DERR_INVALIDCALL;
2047 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2049 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2050 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2052 TRACE("iface %p, parameter %p, vector %p\n", This, parameter, vector);
2054 if (vector && param && !param->element_count)
2056 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2058 switch (param->class)
2062 if (param->type == D3DXPT_INT && param->bytes == 4)
2064 TRACE("INT fixup\n");
2065 vector->x = (((*(INT *)param->data) & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
2066 vector->y = (((*(INT *)param->data) & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
2067 vector->z = ((*(INT *)param->data) & 0xff) * INT_FLOAT_MULTI_INVERSE;
2068 vector->w = (((*(INT *)param->data) & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
2071 get_vector(param, vector);
2074 case D3DXPC_MATRIX_ROWS:
2080 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2085 WARN("Invalid argument specified\n");
2087 return D3DERR_INVALIDCALL;
2090 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2092 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2093 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2095 TRACE("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
2097 if (param && param->element_count && param->element_count >= count)
2101 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2103 switch (param->class)
2106 for (i = 0; i < count; ++i)
2108 set_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2113 case D3DXPC_MATRIX_ROWS:
2119 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2124 WARN("Invalid argument specified\n");
2126 return D3DERR_INVALIDCALL;
2129 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2131 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2132 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2134 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
2136 if (!count) return D3D_OK;
2138 if (vector && param && count <= param->element_count)
2142 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2144 switch (param->class)
2147 for (i = 0; i < count; ++i)
2149 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2154 case D3DXPC_MATRIX_ROWS:
2160 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2165 WARN("Invalid argument specified\n");
2167 return D3DERR_INVALIDCALL;
2170 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2172 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2173 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2175 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2177 if (param && !param->element_count)
2179 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2181 switch (param->class)
2183 case D3DXPC_MATRIX_ROWS:
2184 set_matrix(param, matrix, FALSE);
2194 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2199 WARN("Invalid argument specified\n");
2201 return D3DERR_INVALIDCALL;
2204 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2206 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2207 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2209 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2211 if (matrix && param && !param->element_count)
2213 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2215 switch (param->class)
2217 case D3DXPC_MATRIX_ROWS:
2218 get_matrix(param, matrix, FALSE);
2228 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2233 WARN("Invalid argument specified\n");
2235 return D3DERR_INVALIDCALL;
2238 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2240 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2241 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2243 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2245 if (param && param->element_count >= count)
2249 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2251 switch (param->class)
2253 case D3DXPC_MATRIX_ROWS:
2254 for (i = 0; i < count; ++i)
2256 set_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], FALSE);
2267 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2272 WARN("Invalid argument specified\n");
2274 return D3DERR_INVALIDCALL;
2277 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2279 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2280 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2282 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2284 if (!count) return D3D_OK;
2286 if (matrix && param && count <= param->element_count)
2290 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2292 switch (param->class)
2294 case D3DXPC_MATRIX_ROWS:
2295 for (i = 0; i < count; ++i)
2297 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], FALSE);
2308 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2313 WARN("Invalid argument specified\n");
2315 return D3DERR_INVALIDCALL;
2318 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2320 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2321 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2323 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2325 if (param && count <= param->element_count)
2329 switch (param->class)
2331 case D3DXPC_MATRIX_ROWS:
2332 for (i = 0; i < count; ++i)
2334 set_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], FALSE);
2344 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2349 WARN("Invalid argument specified\n");
2351 return D3DERR_INVALIDCALL;
2354 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2356 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2357 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2359 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2361 if (!count) return D3D_OK;
2363 if (param && matrix && count <= param->element_count)
2367 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2369 switch (param->class)
2371 case D3DXPC_MATRIX_ROWS:
2372 for (i = 0; i < count; ++i)
2374 get_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], FALSE);
2384 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2389 WARN("Invalid argument specified\n");
2391 return D3DERR_INVALIDCALL;
2394 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2396 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2397 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2399 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2401 if (param && !param->element_count)
2403 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2405 switch (param->class)
2407 case D3DXPC_MATRIX_ROWS:
2408 set_matrix(param, matrix, TRUE);
2418 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2423 WARN("Invalid argument specified\n");
2425 return D3DERR_INVALIDCALL;
2428 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2430 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2431 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2433 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2435 if (matrix && param && !param->element_count)
2437 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2439 switch (param->class)
2443 get_matrix(param, matrix, FALSE);
2446 case D3DXPC_MATRIX_ROWS:
2447 get_matrix(param, matrix, TRUE);
2455 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2460 WARN("Invalid argument specified\n");
2462 return D3DERR_INVALIDCALL;
2465 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2467 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2468 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2470 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2472 if (param && param->element_count >= count)
2476 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2478 switch (param->class)
2480 case D3DXPC_MATRIX_ROWS:
2481 for (i = 0; i < count; ++i)
2483 set_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], TRUE);
2494 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2499 WARN("Invalid argument specified\n");
2501 return D3DERR_INVALIDCALL;
2504 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2506 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2507 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2509 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2511 if (!count) return D3D_OK;
2513 if (matrix && param && count <= param->element_count)
2517 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2519 switch (param->class)
2521 case D3DXPC_MATRIX_ROWS:
2522 for (i = 0; i < count; ++i)
2524 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], TRUE);
2535 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2540 WARN("Invalid argument specified\n");
2542 return D3DERR_INVALIDCALL;
2545 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2547 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2548 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2550 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2552 if (param && count <= param->element_count)
2556 switch (param->class)
2558 case D3DXPC_MATRIX_ROWS:
2559 for (i = 0; i < count; ++i)
2561 set_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], TRUE);
2571 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2576 WARN("Invalid argument specified\n");
2578 return D3DERR_INVALIDCALL;
2581 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2583 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2584 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2586 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2588 if (!count) return D3D_OK;
2590 if (matrix && param && count <= param->element_count)
2594 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2596 switch (param->class)
2598 case D3DXPC_MATRIX_ROWS:
2599 for (i = 0; i < count; ++i)
2601 get_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], TRUE);
2611 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2616 WARN("Invalid argument specified\n");
2618 return D3DERR_INVALIDCALL;
2621 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2623 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2625 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2630 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2632 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2633 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2635 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2637 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2639 *string = *(LPCSTR *)param->data;
2640 TRACE("Returning %s\n", debugstr_a(*string));
2644 WARN("Invalid argument specified\n");
2646 return D3DERR_INVALIDCALL;
2649 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(struct ID3DXBaseEffect *iface,
2650 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 *texture)
2652 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2653 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2655 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2657 if (param && !param->element_count &&
2658 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2659 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2660 || param->type == D3DXPT_TEXTURECUBE))
2662 struct IDirect3DBaseTexture9 *oltexture = *(struct IDirect3DBaseTexture9 **)param->data;
2664 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2665 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2667 *(struct IDirect3DBaseTexture9 **)param->data = texture;
2672 WARN("Invalid argument specified\n");
2674 return D3DERR_INVALIDCALL;
2677 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(struct ID3DXBaseEffect *iface,
2678 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 **texture)
2680 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2681 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2683 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2685 if (texture && param && !param->element_count &&
2686 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2687 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2688 || param->type == D3DXPT_TEXTURECUBE))
2690 *texture = *(struct IDirect3DBaseTexture9 **)param->data;
2691 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2692 TRACE("Returning %p\n", *texture);
2696 WARN("Invalid argument specified\n");
2698 return D3DERR_INVALIDCALL;
2701 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface,
2702 D3DXHANDLE parameter, struct IDirect3DPixelShader9 **shader)
2704 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2705 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2707 TRACE("iface %p, parameter %p, shader %p.\n", This, parameter, shader);
2709 if (shader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2711 if ((*shader = *(struct IDirect3DPixelShader9 **)param->data))
2712 IDirect3DPixelShader9_AddRef(*shader);
2713 TRACE("Returning %p.\n", *shader);
2717 WARN("Invalid argument specified\n");
2719 return D3DERR_INVALIDCALL;
2722 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(struct ID3DXBaseEffect *iface,
2723 D3DXHANDLE parameter, struct IDirect3DVertexShader9 **shader)
2725 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2726 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2728 TRACE("iface %p, parameter %p, shader %p.\n", This, parameter, shader);
2730 if (shader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2732 if ((*shader = *(struct IDirect3DVertexShader9 **)param->data))
2733 IDirect3DVertexShader9_AddRef(*shader);
2734 TRACE("Returning %p.\n", *shader);
2738 WARN("Invalid argument specified\n");
2740 return D3DERR_INVALIDCALL;
2743 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2745 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2747 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2752 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2754 /*** IUnknown methods ***/
2755 ID3DXBaseEffectImpl_QueryInterface,
2756 ID3DXBaseEffectImpl_AddRef,
2757 ID3DXBaseEffectImpl_Release,
2758 /*** ID3DXBaseEffect methods ***/
2759 ID3DXBaseEffectImpl_GetDesc,
2760 ID3DXBaseEffectImpl_GetParameterDesc,
2761 ID3DXBaseEffectImpl_GetTechniqueDesc,
2762 ID3DXBaseEffectImpl_GetPassDesc,
2763 ID3DXBaseEffectImpl_GetFunctionDesc,
2764 ID3DXBaseEffectImpl_GetParameter,
2765 ID3DXBaseEffectImpl_GetParameterByName,
2766 ID3DXBaseEffectImpl_GetParameterBySemantic,
2767 ID3DXBaseEffectImpl_GetParameterElement,
2768 ID3DXBaseEffectImpl_GetTechnique,
2769 ID3DXBaseEffectImpl_GetTechniqueByName,
2770 ID3DXBaseEffectImpl_GetPass,
2771 ID3DXBaseEffectImpl_GetPassByName,
2772 ID3DXBaseEffectImpl_GetFunction,
2773 ID3DXBaseEffectImpl_GetFunctionByName,
2774 ID3DXBaseEffectImpl_GetAnnotation,
2775 ID3DXBaseEffectImpl_GetAnnotationByName,
2776 ID3DXBaseEffectImpl_SetValue,
2777 ID3DXBaseEffectImpl_GetValue,
2778 ID3DXBaseEffectImpl_SetBool,
2779 ID3DXBaseEffectImpl_GetBool,
2780 ID3DXBaseEffectImpl_SetBoolArray,
2781 ID3DXBaseEffectImpl_GetBoolArray,
2782 ID3DXBaseEffectImpl_SetInt,
2783 ID3DXBaseEffectImpl_GetInt,
2784 ID3DXBaseEffectImpl_SetIntArray,
2785 ID3DXBaseEffectImpl_GetIntArray,
2786 ID3DXBaseEffectImpl_SetFloat,
2787 ID3DXBaseEffectImpl_GetFloat,
2788 ID3DXBaseEffectImpl_SetFloatArray,
2789 ID3DXBaseEffectImpl_GetFloatArray,
2790 ID3DXBaseEffectImpl_SetVector,
2791 ID3DXBaseEffectImpl_GetVector,
2792 ID3DXBaseEffectImpl_SetVectorArray,
2793 ID3DXBaseEffectImpl_GetVectorArray,
2794 ID3DXBaseEffectImpl_SetMatrix,
2795 ID3DXBaseEffectImpl_GetMatrix,
2796 ID3DXBaseEffectImpl_SetMatrixArray,
2797 ID3DXBaseEffectImpl_GetMatrixArray,
2798 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2799 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2800 ID3DXBaseEffectImpl_SetMatrixTranspose,
2801 ID3DXBaseEffectImpl_GetMatrixTranspose,
2802 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2803 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2804 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2805 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2806 ID3DXBaseEffectImpl_SetString,
2807 ID3DXBaseEffectImpl_GetString,
2808 ID3DXBaseEffectImpl_SetTexture,
2809 ID3DXBaseEffectImpl_GetTexture,
2810 ID3DXBaseEffectImpl_GetPixelShader,
2811 ID3DXBaseEffectImpl_GetVertexShader,
2812 ID3DXBaseEffectImpl_SetArrayRange,
2815 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2817 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2820 /*** IUnknown methods ***/
2821 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2823 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
2825 if (IsEqualGUID(riid, &IID_IUnknown) ||
2826 IsEqualGUID(riid, &IID_ID3DXEffect))
2828 iface->lpVtbl->AddRef(iface);
2833 ERR("Interface %s not found\n", debugstr_guid(riid));
2835 return E_NOINTERFACE;
2838 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2840 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2842 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2844 return InterlockedIncrement(&This->ref);
2847 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2849 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2850 ULONG ref = InterlockedDecrement(&This->ref);
2852 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2857 HeapFree(GetProcessHeap(), 0, This);
2863 /*** ID3DXBaseEffect methods ***/
2864 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2866 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2867 ID3DXBaseEffect *base = This->base_effect;
2869 TRACE("Forward iface %p, base %p\n", This, base);
2871 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2874 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2876 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2877 ID3DXBaseEffect *base = This->base_effect;
2879 TRACE("Forward iface %p, base %p\n", This, base);
2881 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2884 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2886 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2887 ID3DXBaseEffect *base = This->base_effect;
2889 TRACE("Forward iface %p, base %p\n", This, base);
2891 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2894 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2896 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2897 ID3DXBaseEffect *base = This->base_effect;
2899 TRACE("Forward iface %p, base %p\n", This, base);
2901 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2904 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2906 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2907 ID3DXBaseEffect *base = This->base_effect;
2909 TRACE("Forward iface %p, base %p\n", This, base);
2911 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2914 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2916 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2917 ID3DXBaseEffect *base = This->base_effect;
2919 TRACE("Forward iface %p, base %p\n", This, base);
2921 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2924 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2926 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2927 ID3DXBaseEffect *base = This->base_effect;
2929 TRACE("Forward iface %p, base %p\n", This, base);
2931 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2934 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2936 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2937 ID3DXBaseEffect *base = This->base_effect;
2939 TRACE("Forward iface %p, base %p\n", This, base);
2941 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2944 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2946 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2947 ID3DXBaseEffect *base = This->base_effect;
2949 TRACE("Forward iface %p, base %p\n", This, base);
2951 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2954 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2956 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2957 ID3DXBaseEffect *base = This->base_effect;
2959 TRACE("Forward iface %p, base %p\n", This, base);
2961 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2964 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2966 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2967 ID3DXBaseEffect *base = This->base_effect;
2969 TRACE("Forward iface %p, base %p\n", This, base);
2971 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2974 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2976 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2977 ID3DXBaseEffect *base = This->base_effect;
2979 TRACE("Forward iface %p, base %p\n", This, base);
2981 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2984 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2986 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2987 ID3DXBaseEffect *base = This->base_effect;
2989 TRACE("Forward iface %p, base %p\n", This, base);
2991 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2994 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2996 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2997 ID3DXBaseEffect *base = This->base_effect;
2999 TRACE("Forward iface %p, base %p\n", This, base);
3001 return ID3DXBaseEffectImpl_GetFunction(base, index);
3004 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
3006 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3007 ID3DXBaseEffect *base = This->base_effect;
3009 TRACE("Forward iface %p, base %p\n", This, base);
3011 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3014 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
3016 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3017 ID3DXBaseEffect *base = This->base_effect;
3019 TRACE("Forward iface %p, base %p\n", This, base);
3021 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3024 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
3026 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3027 ID3DXBaseEffect *base = This->base_effect;
3029 TRACE("Forward iface %p, base %p\n", This, base);
3031 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3034 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3036 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3037 ID3DXBaseEffect *base = This->base_effect;
3039 TRACE("Forward iface %p, base %p\n", This, base);
3041 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3044 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3046 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3047 ID3DXBaseEffect *base = This->base_effect;
3049 TRACE("Forward iface %p, base %p\n", This, base);
3051 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3054 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
3056 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3057 ID3DXBaseEffect *base = This->base_effect;
3059 TRACE("Forward iface %p, base %p\n", This, base);
3061 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3064 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
3066 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3067 ID3DXBaseEffect *base = This->base_effect;
3069 TRACE("Forward iface %p, base %p\n", This, base);
3071 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3074 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3076 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3077 ID3DXBaseEffect *base = This->base_effect;
3079 TRACE("Forward iface %p, base %p\n", This, base);
3081 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3084 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3086 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3087 ID3DXBaseEffect *base = This->base_effect;
3089 TRACE("Forward iface %p, base %p\n", This, base);
3091 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3094 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
3096 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3097 ID3DXBaseEffect *base = This->base_effect;
3099 TRACE("Forward iface %p, base %p\n", This, base);
3101 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3104 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
3106 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3107 ID3DXBaseEffect *base = This->base_effect;
3109 TRACE("Forward iface %p, base %p\n", This, base);
3111 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3114 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3116 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3117 ID3DXBaseEffect *base = This->base_effect;
3119 TRACE("Forward iface %p, base %p\n", This, base);
3121 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3124 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
3126 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3127 ID3DXBaseEffect *base = This->base_effect;
3129 TRACE("Forward iface %p, base %p\n", This, base);
3131 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3134 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
3136 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3137 ID3DXBaseEffect *base = This->base_effect;
3139 TRACE("Forward iface %p, base %p\n", This, base);
3141 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3144 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
3146 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3147 ID3DXBaseEffect *base = This->base_effect;
3149 TRACE("Forward iface %p, base %p\n", This, base);
3151 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3154 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3156 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3157 ID3DXBaseEffect *base = This->base_effect;
3159 TRACE("Forward iface %p, base %p\n", This, base);
3161 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3164 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3166 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3167 ID3DXBaseEffect *base = This->base_effect;
3169 TRACE("Forward iface %p, base %p\n", This, base);
3171 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3174 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3176 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3177 ID3DXBaseEffect *base = This->base_effect;
3179 TRACE("Forward iface %p, base %p\n", This, base);
3181 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3184 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3186 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3187 ID3DXBaseEffect *base = This->base_effect;
3189 TRACE("Forward iface %p, base %p\n", This, base);
3191 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3194 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3196 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3197 ID3DXBaseEffect *base = This->base_effect;
3199 TRACE("Forward iface %p, base %p\n", This, base);
3201 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3204 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3206 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3207 ID3DXBaseEffect *base = This->base_effect;
3209 TRACE("Forward iface %p, base %p\n", This, base);
3211 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3214 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3216 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3217 ID3DXBaseEffect *base = This->base_effect;
3219 TRACE("Forward iface %p, base %p\n", This, base);
3221 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3224 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3226 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3227 ID3DXBaseEffect *base = This->base_effect;
3229 TRACE("Forward iface %p, base %p\n", This, base);
3231 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3234 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3236 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3237 ID3DXBaseEffect *base = This->base_effect;
3239 TRACE("Forward iface %p, base %p\n", This, base);
3241 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3244 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3246 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3247 ID3DXBaseEffect *base = This->base_effect;
3249 TRACE("Forward iface %p, base %p\n", This, base);
3251 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3254 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3256 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3257 ID3DXBaseEffect *base = This->base_effect;
3259 TRACE("Forward iface %p, base %p\n", This, base);
3261 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3264 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3266 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3267 ID3DXBaseEffect *base = This->base_effect;
3269 TRACE("Forward iface %p, base %p\n", This, base);
3271 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3274 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3276 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3277 ID3DXBaseEffect *base = This->base_effect;
3279 TRACE("Forward iface %p, base %p\n", This, base);
3281 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3284 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3286 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3287 ID3DXBaseEffect *base = This->base_effect;
3289 TRACE("Forward iface %p, base %p\n", This, base);
3291 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3294 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3296 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3297 ID3DXBaseEffect *base = This->base_effect;
3299 TRACE("Forward iface %p, base %p\n", This, base);
3301 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3304 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3306 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3307 ID3DXBaseEffect *base = This->base_effect;
3309 TRACE("Forward iface %p, base %p\n", This, base);
3311 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3314 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3316 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3317 ID3DXBaseEffect *base = This->base_effect;
3319 TRACE("Forward iface %p, base %p\n", This, base);
3321 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3324 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3326 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3327 ID3DXBaseEffect *base = This->base_effect;
3329 TRACE("Forward iface %p, base %p\n", This, base);
3331 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3334 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
3336 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3337 ID3DXBaseEffect *base = This->base_effect;
3339 TRACE("Forward iface %p, base %p\n", This, base);
3341 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3344 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3346 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3347 ID3DXBaseEffect *base = This->base_effect;
3349 TRACE("Forward iface %p, base %p\n", This, base);
3351 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3354 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(struct ID3DXEffect *iface,
3355 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 *texture)
3357 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3358 ID3DXBaseEffect *base = This->base_effect;
3360 TRACE("Forward iface %p, base %p\n", This, base);
3362 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3365 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(struct ID3DXEffect *iface,
3366 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 **texture)
3368 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3369 ID3DXBaseEffect *base = This->base_effect;
3371 TRACE("Forward iface %p, base %p\n", This, base);
3373 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3376 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface,
3377 D3DXHANDLE parameter, struct IDirect3DPixelShader9 **shader)
3379 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3380 ID3DXBaseEffect *base = This->base_effect;
3382 TRACE("Forward iface %p, base %p\n", This, base);
3384 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, shader);
3387 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(struct ID3DXEffect *iface,
3388 D3DXHANDLE parameter, struct IDirect3DVertexShader9 **shader)
3390 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3391 ID3DXBaseEffect *base = This->base_effect;
3393 TRACE("Forward iface %p, base %p\n", This, base);
3395 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, shader);
3398 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3400 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3401 ID3DXBaseEffect *base = This->base_effect;
3403 TRACE("Forward iface %p, base %p\n", This, base);
3405 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3408 /*** ID3DXEffect methods ***/
3409 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
3411 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3413 TRACE("iface %p, pool %p\n", This, pool);
3417 WARN("Invalid argument supplied.\n");
3418 return D3DERR_INVALIDCALL;
3423 This->pool->lpVtbl->AddRef(This->pool);
3428 TRACE("Returning pool %p\n", *pool);
3433 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3435 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3436 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3437 struct d3dx_technique *tech = is_valid_technique(base, technique);
3439 TRACE("iface %p, technique %p\n", This, technique);
3443 This->active_technique = get_technique_handle(tech);
3444 TRACE("Technique %p\n", tech);
3448 WARN("Invalid argument supplied.\n");
3450 return D3DERR_INVALIDCALL;
3453 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3455 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3457 TRACE("iface %p\n", This);
3459 return This->active_technique;
3462 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3464 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3466 FIXME("(%p)->(%p): stub\n", This, technique);
3471 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3473 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3475 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3480 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3482 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3484 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3489 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3491 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3492 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3494 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3496 if (passes && technique)
3498 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3500 TRACE("State capturing disabled.\n");
3504 FIXME("State capturing not supported, yet!\n");
3507 *passes = technique->pass_count;
3512 WARN("Invalid argument supplied.\n");
3514 return D3DERR_INVALIDCALL;
3517 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3519 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3520 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3522 TRACE("iface %p, pass %u\n", This, pass);
3524 if (technique && pass < technique->pass_count && !This->active_pass)
3526 This->active_pass = technique->pass_handles[pass];
3528 FIXME("No states applied, yet!\n");
3533 WARN("Invalid argument supplied.\n");
3535 return D3DERR_INVALIDCALL;
3538 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3540 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3542 FIXME("(%p)->(): stub\n", This);
3547 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3549 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3551 TRACE("iface %p\n", This);
3553 if (This->active_pass)
3555 This->active_pass = NULL;
3559 WARN("Invalid call.\n");
3561 return D3DERR_INVALIDCALL;
3564 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3566 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3568 FIXME("(%p)->(): stub\n", This);
3573 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3575 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3577 TRACE("iface %p, device %p\n", This, device);
3581 WARN("Invalid argument supplied.\n");
3582 return D3DERR_INVALIDCALL;
3585 IDirect3DDevice9_AddRef(This->device);
3587 *device = This->device;
3589 TRACE("Returning device %p\n", *device);
3594 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3596 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3598 FIXME("(%p)->(): stub\n", This);
3603 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3605 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3607 FIXME("(%p)->(): stub\n", This);
3612 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3614 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3616 TRACE("iface %p, manager %p\n", This, manager);
3618 if (manager) IUnknown_AddRef(manager);
3619 if (This->manager) IUnknown_Release(This->manager);
3621 This->manager = manager;
3626 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3628 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3630 TRACE("iface %p, manager %p\n", This, manager);
3634 WARN("Invalid argument supplied.\n");
3635 return D3DERR_INVALIDCALL;
3638 if (This->manager) IUnknown_AddRef(This->manager);
3639 *manager = This->manager;
3644 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3646 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3648 FIXME("(%p)->(): stub\n", This);
3653 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3655 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3657 FIXME("(%p)->(): stub\n", This);
3662 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3664 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3666 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3671 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3673 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3675 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3680 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3682 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3684 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3689 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3691 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3693 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3698 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3700 /*** IUnknown methods ***/
3701 ID3DXEffectImpl_QueryInterface,
3702 ID3DXEffectImpl_AddRef,
3703 ID3DXEffectImpl_Release,
3704 /*** ID3DXBaseEffect methods ***/
3705 ID3DXEffectImpl_GetDesc,
3706 ID3DXEffectImpl_GetParameterDesc,
3707 ID3DXEffectImpl_GetTechniqueDesc,
3708 ID3DXEffectImpl_GetPassDesc,
3709 ID3DXEffectImpl_GetFunctionDesc,
3710 ID3DXEffectImpl_GetParameter,
3711 ID3DXEffectImpl_GetParameterByName,
3712 ID3DXEffectImpl_GetParameterBySemantic,
3713 ID3DXEffectImpl_GetParameterElement,
3714 ID3DXEffectImpl_GetTechnique,
3715 ID3DXEffectImpl_GetTechniqueByName,
3716 ID3DXEffectImpl_GetPass,
3717 ID3DXEffectImpl_GetPassByName,
3718 ID3DXEffectImpl_GetFunction,
3719 ID3DXEffectImpl_GetFunctionByName,
3720 ID3DXEffectImpl_GetAnnotation,
3721 ID3DXEffectImpl_GetAnnotationByName,
3722 ID3DXEffectImpl_SetValue,
3723 ID3DXEffectImpl_GetValue,
3724 ID3DXEffectImpl_SetBool,
3725 ID3DXEffectImpl_GetBool,
3726 ID3DXEffectImpl_SetBoolArray,
3727 ID3DXEffectImpl_GetBoolArray,
3728 ID3DXEffectImpl_SetInt,
3729 ID3DXEffectImpl_GetInt,
3730 ID3DXEffectImpl_SetIntArray,
3731 ID3DXEffectImpl_GetIntArray,
3732 ID3DXEffectImpl_SetFloat,
3733 ID3DXEffectImpl_GetFloat,
3734 ID3DXEffectImpl_SetFloatArray,
3735 ID3DXEffectImpl_GetFloatArray,
3736 ID3DXEffectImpl_SetVector,
3737 ID3DXEffectImpl_GetVector,
3738 ID3DXEffectImpl_SetVectorArray,
3739 ID3DXEffectImpl_GetVectorArray,
3740 ID3DXEffectImpl_SetMatrix,
3741 ID3DXEffectImpl_GetMatrix,
3742 ID3DXEffectImpl_SetMatrixArray,
3743 ID3DXEffectImpl_GetMatrixArray,
3744 ID3DXEffectImpl_SetMatrixPointerArray,
3745 ID3DXEffectImpl_GetMatrixPointerArray,
3746 ID3DXEffectImpl_SetMatrixTranspose,
3747 ID3DXEffectImpl_GetMatrixTranspose,
3748 ID3DXEffectImpl_SetMatrixTransposeArray,
3749 ID3DXEffectImpl_GetMatrixTransposeArray,
3750 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3751 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3752 ID3DXEffectImpl_SetString,
3753 ID3DXEffectImpl_GetString,
3754 ID3DXEffectImpl_SetTexture,
3755 ID3DXEffectImpl_GetTexture,
3756 ID3DXEffectImpl_GetPixelShader,
3757 ID3DXEffectImpl_GetVertexShader,
3758 ID3DXEffectImpl_SetArrayRange,
3759 /*** ID3DXEffect methods ***/
3760 ID3DXEffectImpl_GetPool,
3761 ID3DXEffectImpl_SetTechnique,
3762 ID3DXEffectImpl_GetCurrentTechnique,
3763 ID3DXEffectImpl_ValidateTechnique,
3764 ID3DXEffectImpl_FindNextValidTechnique,
3765 ID3DXEffectImpl_IsParameterUsed,
3766 ID3DXEffectImpl_Begin,
3767 ID3DXEffectImpl_BeginPass,
3768 ID3DXEffectImpl_CommitChanges,
3769 ID3DXEffectImpl_EndPass,
3770 ID3DXEffectImpl_End,
3771 ID3DXEffectImpl_GetDevice,
3772 ID3DXEffectImpl_OnLostDevice,
3773 ID3DXEffectImpl_OnResetDevice,
3774 ID3DXEffectImpl_SetStateManager,
3775 ID3DXEffectImpl_GetStateManager,
3776 ID3DXEffectImpl_BeginParameterBlock,
3777 ID3DXEffectImpl_EndParameterBlock,
3778 ID3DXEffectImpl_ApplyParameterBlock,
3779 ID3DXEffectImpl_DeleteParameterBlock,
3780 ID3DXEffectImpl_CloneEffect,
3781 ID3DXEffectImpl_SetRawValue
3784 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3786 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3789 /*** IUnknown methods ***/
3790 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3792 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
3794 if (IsEqualGUID(riid, &IID_IUnknown) ||
3795 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3797 iface->lpVtbl->AddRef(iface);
3802 ERR("Interface %s not found\n", debugstr_guid(riid));
3804 return E_NOINTERFACE;
3807 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3809 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3811 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3813 return InterlockedIncrement(&This->ref);
3816 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3818 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3819 ULONG ref = InterlockedDecrement(&This->ref);
3821 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3825 free_effect_compiler(This);
3826 HeapFree(GetProcessHeap(), 0, This);
3832 /*** ID3DXBaseEffect methods ***/
3833 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3835 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3836 ID3DXBaseEffect *base = This->base_effect;
3838 TRACE("Forward iface %p, base %p\n", This, base);
3840 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3843 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3845 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3846 ID3DXBaseEffect *base = This->base_effect;
3848 TRACE("Forward iface %p, base %p\n", This, base);
3850 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3853 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3855 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3856 ID3DXBaseEffect *base = This->base_effect;
3858 TRACE("Forward iface %p, base %p\n", This, base);
3860 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3863 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3865 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3866 ID3DXBaseEffect *base = This->base_effect;
3868 TRACE("Forward iface %p, base %p\n", This, base);
3870 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3873 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3875 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3876 ID3DXBaseEffect *base = This->base_effect;
3878 TRACE("Forward iface %p, base %p\n", This, base);
3880 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3883 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3885 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3886 ID3DXBaseEffect *base = This->base_effect;
3888 TRACE("Forward iface %p, base %p\n", This, base);
3890 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3893 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3895 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3896 ID3DXBaseEffect *base = This->base_effect;
3898 TRACE("Forward iface %p, base %p\n", This, base);
3900 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3903 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3905 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3906 ID3DXBaseEffect *base = This->base_effect;
3908 TRACE("Forward iface %p, base %p\n", This, base);
3910 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3913 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3915 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3916 ID3DXBaseEffect *base = This->base_effect;
3918 TRACE("Forward iface %p, base %p\n", This, base);
3920 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3923 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3925 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3926 ID3DXBaseEffect *base = This->base_effect;
3928 TRACE("Forward iface %p, base %p\n", This, base);
3930 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3933 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3935 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3936 ID3DXBaseEffect *base = This->base_effect;
3938 TRACE("Forward iface %p, base %p\n", This, base);
3940 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3943 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3945 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3946 ID3DXBaseEffect *base = This->base_effect;
3948 TRACE("Forward iface %p, base %p\n", This, base);
3950 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3953 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3955 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3956 ID3DXBaseEffect *base = This->base_effect;
3958 TRACE("Forward iface %p, base %p\n", This, base);
3960 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3963 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3965 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3966 ID3DXBaseEffect *base = This->base_effect;
3968 TRACE("Forward iface %p, base %p\n", This, base);
3970 return ID3DXBaseEffectImpl_GetFunction(base, index);
3973 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3975 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3976 ID3DXBaseEffect *base = This->base_effect;
3978 TRACE("Forward iface %p, base %p\n", This, base);
3980 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3983 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3985 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3986 ID3DXBaseEffect *base = This->base_effect;
3988 TRACE("Forward iface %p, base %p\n", This, base);
3990 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3993 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3995 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3996 ID3DXBaseEffect *base = This->base_effect;
3998 TRACE("Forward iface %p, base %p\n", This, base);
4000 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
4003 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
4005 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4006 ID3DXBaseEffect *base = This->base_effect;
4008 TRACE("Forward iface %p, base %p\n", This, base);
4010 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
4013 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
4015 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4016 ID3DXBaseEffect *base = This->base_effect;
4018 TRACE("Forward iface %p, base %p\n", This, base);
4020 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
4023 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
4025 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4026 ID3DXBaseEffect *base = This->base_effect;
4028 TRACE("Forward iface %p, base %p\n", This, base);
4030 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
4033 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
4035 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4036 ID3DXBaseEffect *base = This->base_effect;
4038 TRACE("Forward iface %p, base %p\n", This, base);
4040 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
4043 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
4045 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4046 ID3DXBaseEffect *base = This->base_effect;
4048 TRACE("Forward iface %p, base %p\n", This, base);
4050 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
4053 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
4055 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4056 ID3DXBaseEffect *base = This->base_effect;
4058 TRACE("Forward iface %p, base %p\n", This, base);
4060 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
4063 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
4065 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4066 ID3DXBaseEffect *base = This->base_effect;
4068 TRACE("Forward iface %p, base %p\n", This, base);
4070 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
4073 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
4075 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4076 ID3DXBaseEffect *base = This->base_effect;
4078 TRACE("Forward iface %p, base %p\n", This, base);
4080 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
4083 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
4085 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4086 ID3DXBaseEffect *base = This->base_effect;
4088 TRACE("Forward iface %p, base %p\n", This, base);
4090 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
4093 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
4095 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4096 ID3DXBaseEffect *base = This->base_effect;
4098 TRACE("Forward iface %p, base %p\n", This, base);
4100 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
4103 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
4105 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4106 ID3DXBaseEffect *base = This->base_effect;
4108 TRACE("Forward iface %p, base %p\n", This, base);
4110 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
4113 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
4115 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4116 ID3DXBaseEffect *base = This->base_effect;
4118 TRACE("Forward iface %p, base %p\n", This, base);
4120 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
4123 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
4125 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4126 ID3DXBaseEffect *base = This->base_effect;
4128 TRACE("Forward iface %p, base %p\n", This, base);
4130 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
4133 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
4135 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4136 ID3DXBaseEffect *base = This->base_effect;
4138 TRACE("Forward iface %p, base %p\n", This, base);
4140 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
4143 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
4145 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4146 ID3DXBaseEffect *base = This->base_effect;
4148 TRACE("Forward iface %p, base %p\n", This, base);
4150 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
4153 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
4155 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4156 ID3DXBaseEffect *base = This->base_effect;
4158 TRACE("Forward iface %p, base %p\n", This, base);
4160 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
4163 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
4165 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4166 ID3DXBaseEffect *base = This->base_effect;
4168 TRACE("Forward iface %p, base %p\n", This, base);
4170 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
4173 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
4175 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4176 ID3DXBaseEffect *base = This->base_effect;
4178 TRACE("Forward iface %p, base %p\n", This, base);
4180 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
4183 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4185 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4186 ID3DXBaseEffect *base = This->base_effect;
4188 TRACE("Forward iface %p, base %p\n", This, base);
4190 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
4193 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4195 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4196 ID3DXBaseEffect *base = This->base_effect;
4198 TRACE("Forward iface %p, base %p\n", This, base);
4200 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
4203 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4205 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4206 ID3DXBaseEffect *base = This->base_effect;
4208 TRACE("Forward iface %p, base %p\n", This, base);
4210 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
4213 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4215 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4216 ID3DXBaseEffect *base = This->base_effect;
4218 TRACE("Forward iface %p, base %p\n", This, base);
4220 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
4223 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4225 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4226 ID3DXBaseEffect *base = This->base_effect;
4228 TRACE("Forward iface %p, base %p\n", This, base);
4230 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
4233 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4235 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4236 ID3DXBaseEffect *base = This->base_effect;
4238 TRACE("Forward iface %p, base %p\n", This, base);
4240 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
4243 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4245 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4246 ID3DXBaseEffect *base = This->base_effect;
4248 TRACE("Forward iface %p, base %p\n", This, base);
4250 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
4253 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4255 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4256 ID3DXBaseEffect *base = This->base_effect;
4258 TRACE("Forward iface %p, base %p\n", This, base);
4260 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
4263 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4265 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4266 ID3DXBaseEffect *base = This->base_effect;
4268 TRACE("Forward iface %p, base %p\n", This, base);
4270 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
4273 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4275 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4276 ID3DXBaseEffect *base = This->base_effect;
4278 TRACE("Forward iface %p, base %p\n", This, base);
4280 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
4283 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4285 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4286 ID3DXBaseEffect *base = This->base_effect;
4288 TRACE("Forward iface %p, base %p\n", This, base);
4290 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
4293 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4295 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4296 ID3DXBaseEffect *base = This->base_effect;
4298 TRACE("Forward iface %p, base %p\n", This, base);
4300 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
4303 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
4305 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4306 ID3DXBaseEffect *base = This->base_effect;
4308 TRACE("Forward iface %p, base %p\n", This, base);
4310 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
4313 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
4315 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4316 ID3DXBaseEffect *base = This->base_effect;
4318 TRACE("Forward iface %p, base %p\n", This, base);
4320 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
4323 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(struct ID3DXEffectCompiler *iface,
4324 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 *texture)
4326 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4327 ID3DXBaseEffect *base = This->base_effect;
4329 TRACE("Forward iface %p, base %p\n", This, base);
4331 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
4334 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(struct ID3DXEffectCompiler *iface,
4335 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 **texture)
4337 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4338 ID3DXBaseEffect *base = This->base_effect;
4340 TRACE("Forward iface %p, base %p\n", This, base);
4342 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4345 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface,
4346 D3DXHANDLE parameter, struct IDirect3DPixelShader9 **shader)
4348 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4349 ID3DXBaseEffect *base = This->base_effect;
4351 TRACE("Forward iface %p, base %p\n", This, base);
4353 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, shader);
4356 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(struct ID3DXEffectCompiler *iface,
4357 D3DXHANDLE parameter, struct IDirect3DVertexShader9 **shader)
4359 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4360 ID3DXBaseEffect *base = This->base_effect;
4362 TRACE("Forward iface %p, base %p\n", This, base);
4364 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, shader);
4367 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4369 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4370 ID3DXBaseEffect *base = This->base_effect;
4372 TRACE("Forward iface %p, base %p\n", This, base);
4374 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4377 /*** ID3DXEffectCompiler methods ***/
4378 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4380 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4382 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4387 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4389 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4391 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4396 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4397 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
4399 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4401 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4406 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4407 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
4409 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4411 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4412 This, function, target, flags, shader, error_msgs, constant_table);
4417 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4419 /*** IUnknown methods ***/
4420 ID3DXEffectCompilerImpl_QueryInterface,
4421 ID3DXEffectCompilerImpl_AddRef,
4422 ID3DXEffectCompilerImpl_Release,
4423 /*** ID3DXBaseEffect methods ***/
4424 ID3DXEffectCompilerImpl_GetDesc,
4425 ID3DXEffectCompilerImpl_GetParameterDesc,
4426 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4427 ID3DXEffectCompilerImpl_GetPassDesc,
4428 ID3DXEffectCompilerImpl_GetFunctionDesc,
4429 ID3DXEffectCompilerImpl_GetParameter,
4430 ID3DXEffectCompilerImpl_GetParameterByName,
4431 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4432 ID3DXEffectCompilerImpl_GetParameterElement,
4433 ID3DXEffectCompilerImpl_GetTechnique,
4434 ID3DXEffectCompilerImpl_GetTechniqueByName,
4435 ID3DXEffectCompilerImpl_GetPass,
4436 ID3DXEffectCompilerImpl_GetPassByName,
4437 ID3DXEffectCompilerImpl_GetFunction,
4438 ID3DXEffectCompilerImpl_GetFunctionByName,
4439 ID3DXEffectCompilerImpl_GetAnnotation,
4440 ID3DXEffectCompilerImpl_GetAnnotationByName,
4441 ID3DXEffectCompilerImpl_SetValue,
4442 ID3DXEffectCompilerImpl_GetValue,
4443 ID3DXEffectCompilerImpl_SetBool,
4444 ID3DXEffectCompilerImpl_GetBool,
4445 ID3DXEffectCompilerImpl_SetBoolArray,
4446 ID3DXEffectCompilerImpl_GetBoolArray,
4447 ID3DXEffectCompilerImpl_SetInt,
4448 ID3DXEffectCompilerImpl_GetInt,
4449 ID3DXEffectCompilerImpl_SetIntArray,
4450 ID3DXEffectCompilerImpl_GetIntArray,
4451 ID3DXEffectCompilerImpl_SetFloat,
4452 ID3DXEffectCompilerImpl_GetFloat,
4453 ID3DXEffectCompilerImpl_SetFloatArray,
4454 ID3DXEffectCompilerImpl_GetFloatArray,
4455 ID3DXEffectCompilerImpl_SetVector,
4456 ID3DXEffectCompilerImpl_GetVector,
4457 ID3DXEffectCompilerImpl_SetVectorArray,
4458 ID3DXEffectCompilerImpl_GetVectorArray,
4459 ID3DXEffectCompilerImpl_SetMatrix,
4460 ID3DXEffectCompilerImpl_GetMatrix,
4461 ID3DXEffectCompilerImpl_SetMatrixArray,
4462 ID3DXEffectCompilerImpl_GetMatrixArray,
4463 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4464 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4465 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4466 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4467 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4468 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4469 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4470 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4471 ID3DXEffectCompilerImpl_SetString,
4472 ID3DXEffectCompilerImpl_GetString,
4473 ID3DXEffectCompilerImpl_SetTexture,
4474 ID3DXEffectCompilerImpl_GetTexture,
4475 ID3DXEffectCompilerImpl_GetPixelShader,
4476 ID3DXEffectCompilerImpl_GetVertexShader,
4477 ID3DXEffectCompilerImpl_SetArrayRange,
4478 /*** ID3DXEffectCompiler methods ***/
4479 ID3DXEffectCompilerImpl_SetLiteral,
4480 ID3DXEffectCompilerImpl_GetLiteral,
4481 ID3DXEffectCompilerImpl_CompileEffect,
4482 ID3DXEffectCompilerImpl_CompileShader,
4485 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4489 struct d3dx_state *states;
4491 read_dword(ptr, &sampler->state_count);
4492 TRACE("Count: %u\n", sampler->state_count);
4494 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4497 ERR("Out of memory\n");
4498 return E_OUTOFMEMORY;
4501 for (i = 0; i < sampler->state_count; ++i)
4503 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4506 WARN("Failed to parse state\n");
4511 sampler->states = states;
4517 for (i = 0; i < sampler->state_count; ++i)
4519 free_state(&states[i]);
4522 HeapFree(GetProcessHeap(), 0, states);
4527 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4534 if (param->element_count)
4536 param->data = value;
4538 for (i = 0; i < param->element_count; ++i)
4540 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4542 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4545 WARN("Failed to parse value\n");
4549 old_size += member->bytes;
4555 switch(param->class)
4559 case D3DXPC_MATRIX_ROWS:
4560 case D3DXPC_MATRIX_COLUMNS:
4561 param->data = value;
4565 param->data = value;
4567 for (i = 0; i < param->member_count; ++i)
4569 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4571 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4574 WARN("Failed to parse value\n");
4578 old_size += member->bytes;
4583 switch (param->type)
4586 case D3DXPT_TEXTURE:
4587 case D3DXPT_TEXTURE1D:
4588 case D3DXPT_TEXTURE2D:
4589 case D3DXPT_TEXTURE3D:
4590 case D3DXPT_TEXTURECUBE:
4591 case D3DXPT_PIXELSHADER:
4592 case D3DXPT_VERTEXSHADER:
4593 read_dword(ptr, &id);
4594 TRACE("Id: %u\n", id);
4595 objects[id] = get_parameter_handle(param);
4596 param->data = value;
4599 case D3DXPT_SAMPLER:
4600 case D3DXPT_SAMPLER1D:
4601 case D3DXPT_SAMPLER2D:
4602 case D3DXPT_SAMPLER3D:
4603 case D3DXPT_SAMPLERCUBE:
4605 struct d3dx_sampler *sampler;
4607 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4610 ERR("Out of memory\n");
4611 return E_OUTOFMEMORY;
4614 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4617 HeapFree(GetProcessHeap(), 0, sampler);
4618 WARN("Failed to parse sampler\n");
4622 param->data = sampler;
4627 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4633 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4640 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4642 UINT size = param->bytes;
4646 TRACE("param size: %u\n", size);
4650 value = HeapAlloc(GetProcessHeap(), 0, size);
4653 ERR("Failed to allocate data memory.\n");
4654 return E_OUTOFMEMORY;
4657 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4658 memcpy(value, ptr, size);
4661 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4664 WARN("Failed to parse value\n");
4665 HeapFree(GetProcessHeap(), 0, value);
4672 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4676 read_dword(&ptr, &size);
4677 TRACE("Name size: %#x\n", size);
4684 *name = HeapAlloc(GetProcessHeap(), 0, size);
4687 ERR("Failed to allocate name memory.\n");
4688 return E_OUTOFMEMORY;
4691 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4692 memcpy(*name, ptr, size);
4697 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4701 read_dword(ptr, &size);
4702 TRACE("Data size: %#x\n", size);
4704 *str = HeapAlloc(GetProcessHeap(), 0, size);
4707 ERR("Failed to allocate name memory.\n");
4708 return E_OUTOFMEMORY;
4711 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4712 memcpy(*str, *ptr, size);
4714 *ptr += ((size + 3) & ~3);
4719 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4724 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4726 read_dword(ptr, &size);
4727 TRACE("Data size: %#x\n", size);
4731 TRACE("Size is 0\n");
4732 *(void **)param->data = NULL;
4736 switch (param->type)
4739 /* re-read with size (sizeof(DWORD) = 4) */
4740 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4743 WARN("Failed to parse string data\n");
4748 case D3DXPT_VERTEXSHADER:
4749 if (FAILED(hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, param->data)))
4751 WARN("Failed to create vertex shader\n");
4756 case D3DXPT_PIXELSHADER:
4757 if (FAILED(hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, param->data)))
4759 WARN("Failed to create pixel shader\n");
4765 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4770 *ptr += ((size + 3) & ~3);
4775 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4776 struct d3dx_parameter *parent, UINT flags)
4780 D3DXHANDLE *member_handles = NULL;
4783 param->flags = flags;
4787 read_dword(ptr, ¶m->type);
4788 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4790 read_dword(ptr, ¶m->class);
4791 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4793 read_dword(ptr, &offset);
4794 TRACE("Type name offset: %#x\n", offset);
4795 hr = d3dx9_parse_name(¶m->name, data + offset);
4798 WARN("Failed to parse name\n");
4802 read_dword(ptr, &offset);
4803 TRACE("Type semantic offset: %#x\n", offset);
4804 hr = d3dx9_parse_name(¶m->semantic, data + offset);
4807 WARN("Failed to parse semantic\n");
4811 read_dword(ptr, ¶m->element_count);
4812 TRACE("Elements: %u\n", param->element_count);
4814 switch (param->class)
4817 read_dword(ptr, ¶m->columns);
4818 TRACE("Columns: %u\n", param->columns);
4820 read_dword(ptr, ¶m->rows);
4821 TRACE("Rows: %u\n", param->rows);
4823 /* sizeof(DWORD) * rows * columns */
4824 param->bytes = 4 * param->rows * param->columns;
4828 case D3DXPC_MATRIX_ROWS:
4829 case D3DXPC_MATRIX_COLUMNS:
4830 read_dword(ptr, ¶m->rows);
4831 TRACE("Rows: %u\n", param->rows);
4833 read_dword(ptr, ¶m->columns);
4834 TRACE("Columns: %u\n", param->columns);
4836 /* sizeof(DWORD) * rows * columns */
4837 param->bytes = 4 * param->rows * param->columns;
4841 read_dword(ptr, ¶m->member_count);
4842 TRACE("Members: %u\n", param->member_count);
4846 switch (param->type)
4849 case D3DXPT_PIXELSHADER:
4850 case D3DXPT_VERTEXSHADER:
4851 case D3DXPT_TEXTURE:
4852 case D3DXPT_TEXTURE1D:
4853 case D3DXPT_TEXTURE2D:
4854 case D3DXPT_TEXTURE3D:
4855 case D3DXPT_TEXTURECUBE:
4856 param->bytes = sizeof(void *);
4859 case D3DXPT_SAMPLER:
4860 case D3DXPT_SAMPLER1D:
4861 case D3DXPT_SAMPLER2D:
4862 case D3DXPT_SAMPLER3D:
4863 case D3DXPT_SAMPLERCUBE:
4868 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4874 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4881 param->type = parent->type;
4882 param->class = parent->class;
4883 param->name = parent->name;
4884 param->semantic = parent->semantic;
4885 param->element_count = 0;
4886 param->annotation_count = 0;
4887 param->member_count = parent->member_count;
4888 param->bytes = parent->bytes;
4889 param->rows = parent->rows;
4890 param->columns = parent->columns;
4893 if (param->element_count)
4895 unsigned int param_bytes = 0;
4896 const char *save_ptr = *ptr;
4898 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4899 if (!member_handles)
4901 ERR("Out of memory\n");
4906 for (i = 0; i < param->element_count; ++i)
4908 struct d3dx_parameter *member;
4911 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4914 ERR("Out of memory\n");
4919 member_handles[i] = get_parameter_handle(member);
4921 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4924 WARN("Failed to parse member\n");
4928 param_bytes += member->bytes;
4931 param->bytes = param_bytes;
4933 else if (param->member_count)
4935 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4936 if (!member_handles)
4938 ERR("Out of memory\n");
4943 for (i = 0; i < param->member_count; ++i)
4945 struct d3dx_parameter *member;
4947 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4950 ERR("Out of memory\n");
4955 member_handles[i] = get_parameter_handle(member);
4957 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4960 WARN("Failed to parse member\n");
4964 param->bytes += member->bytes;
4968 param->member_handles = member_handles;
4978 if (param->element_count) count = param->element_count;
4979 else count = param->member_count;
4981 for (i = 0; i < count; ++i)
4983 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4985 HeapFree(GetProcessHeap(), 0, member_handles);
4990 HeapFree(GetProcessHeap(), 0, param->name);
4991 HeapFree(GetProcessHeap(), 0, param->semantic);
4994 param->semantic = NULL;
4999 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
5005 anno->flags = D3DX_PARAMETER_ANNOTATION;
5007 read_dword(ptr, &offset);
5008 TRACE("Typedef offset: %#x\n", offset);
5009 ptr2 = data + offset;
5010 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
5013 WARN("Failed to parse type definition\n");
5017 read_dword(ptr, &offset);
5018 TRACE("Value offset: %#x\n", offset);
5019 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
5022 WARN("Failed to parse value\n");
5029 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
5034 struct d3dx_parameter *parameter;
5036 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5039 ERR("Out of memory\n");
5040 return E_OUTOFMEMORY;
5043 state->type = ST_CONSTANT;
5045 read_dword(ptr, &state->operation);
5046 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
5048 read_dword(ptr, &state->index);
5049 TRACE("Index: %#x\n", state->index);
5051 read_dword(ptr, &offset);
5052 TRACE("Typedef offset: %#x\n", offset);
5053 ptr2 = data + offset;
5054 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
5057 WARN("Failed to parse type definition\n");
5061 read_dword(ptr, &offset);
5062 TRACE("Value offset: %#x\n", offset);
5063 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
5066 WARN("Failed to parse value\n");
5070 state->parameter = get_parameter_handle(parameter);
5076 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
5081 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
5086 D3DXHANDLE *annotation_handles = NULL;
5089 read_dword(ptr, &offset);
5090 TRACE("Typedef offset: %#x\n", offset);
5091 ptr2 = data + offset;
5093 read_dword(ptr, &offset);
5094 TRACE("Value offset: %#x\n", offset);
5096 read_dword(ptr, ¶m->flags);
5097 TRACE("Flags: %#x\n", param->flags);
5099 read_dword(ptr, ¶m->annotation_count);
5100 TRACE("Annotation count: %u\n", param->annotation_count);
5102 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
5105 WARN("Failed to parse type definition\n");
5109 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
5112 WARN("Failed to parse value\n");
5116 if (param->annotation_count)
5118 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
5119 if (!annotation_handles)
5121 ERR("Out of memory\n");
5126 for (i = 0; i < param->annotation_count; ++i)
5128 struct d3dx_parameter *annotation;
5130 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5133 ERR("Out of memory\n");
5138 annotation_handles[i] = get_parameter_handle(annotation);
5140 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5143 WARN("Failed to parse annotation\n");
5149 param->annotation_handles = annotation_handles;
5155 if (annotation_handles)
5157 for (i = 0; i < param->annotation_count; ++i)
5159 free_parameter(annotation_handles[i], FALSE, FALSE);
5161 HeapFree(GetProcessHeap(), 0, annotation_handles);
5167 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
5172 D3DXHANDLE *annotation_handles = NULL;
5173 struct d3dx_state *states = NULL;
5176 read_dword(ptr, &offset);
5177 TRACE("Pass name offset: %#x\n", offset);
5178 hr = d3dx9_parse_name(&name, data + offset);
5181 WARN("Failed to parse name\n");
5185 read_dword(ptr, &pass->annotation_count);
5186 TRACE("Annotation count: %u\n", pass->annotation_count);
5188 read_dword(ptr, &pass->state_count);
5189 TRACE("State count: %u\n", pass->state_count);
5191 if (pass->annotation_count)
5193 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
5194 if (!annotation_handles)
5196 ERR("Out of memory\n");
5201 for (i = 0; i < pass->annotation_count; ++i)
5203 struct d3dx_parameter *annotation;
5205 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5208 ERR("Out of memory\n");
5213 annotation_handles[i] = get_parameter_handle(annotation);
5215 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5218 WARN("Failed to parse annotations\n");
5224 if (pass->state_count)
5226 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
5229 ERR("Out of memory\n");
5234 for (i = 0; i < pass->state_count; ++i)
5236 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
5239 WARN("Failed to parse annotations\n");
5246 pass->annotation_handles = annotation_handles;
5247 pass->states = states;
5253 if (annotation_handles)
5255 for (i = 0; i < pass->annotation_count; ++i)
5257 free_parameter(annotation_handles[i], FALSE, FALSE);
5259 HeapFree(GetProcessHeap(), 0, annotation_handles);
5264 for (i = 0; i < pass->state_count; ++i)
5266 free_state(&states[i]);
5268 HeapFree(GetProcessHeap(), 0, states);
5271 HeapFree(GetProcessHeap(), 0, name);
5276 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
5281 D3DXHANDLE *annotation_handles = NULL;
5282 D3DXHANDLE *pass_handles = NULL;
5285 read_dword(ptr, &offset);
5286 TRACE("Technique name offset: %#x\n", offset);
5287 hr = d3dx9_parse_name(&name, data + offset);
5290 WARN("Failed to parse name\n");
5294 read_dword(ptr, &technique->annotation_count);
5295 TRACE("Annotation count: %u\n", technique->annotation_count);
5297 read_dword(ptr, &technique->pass_count);
5298 TRACE("Pass count: %u\n", technique->pass_count);
5300 if (technique->annotation_count)
5302 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
5303 if (!annotation_handles)
5305 ERR("Out of memory\n");
5310 for (i = 0; i < technique->annotation_count; ++i)
5312 struct d3dx_parameter *annotation;
5314 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5317 ERR("Out of memory\n");
5322 annotation_handles[i] = get_parameter_handle(annotation);
5324 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5327 WARN("Failed to parse annotations\n");
5333 if (technique->pass_count)
5335 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5338 ERR("Out of memory\n");
5343 for (i = 0; i < technique->pass_count; ++i)
5345 struct d3dx_pass *pass;
5347 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5350 ERR("Out of memory\n");
5355 pass_handles[i] = get_pass_handle(pass);
5357 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5360 WARN("Failed to parse passes\n");
5366 technique->name = name;
5367 technique->pass_handles = pass_handles;
5368 technique->annotation_handles = annotation_handles;
5376 for (i = 0; i < technique->pass_count; ++i)
5378 free_pass(pass_handles[i]);
5380 HeapFree(GetProcessHeap(), 0, pass_handles);
5383 if (annotation_handles)
5385 for (i = 0; i < technique->annotation_count; ++i)
5387 free_parameter(annotation_handles[i], FALSE, FALSE);
5389 HeapFree(GetProcessHeap(), 0, annotation_handles);
5392 HeapFree(GetProcessHeap(), 0, name);
5397 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5399 DWORD technique_index;
5400 DWORD index, state_index, usage, element_index;
5401 struct d3dx_state *state;
5402 struct d3dx_parameter *param;
5403 HRESULT hr = E_FAIL;
5405 read_dword(ptr, &technique_index);
5406 TRACE("techn: %u\n", technique_index);
5408 read_dword(ptr, &index);
5409 TRACE("index: %u\n", index);
5411 read_dword(ptr, &element_index);
5412 TRACE("element_index: %u\n", element_index);
5414 read_dword(ptr, &state_index);
5415 TRACE("state_index: %u\n", state_index);
5417 read_dword(ptr, &usage);
5418 TRACE("usage: %u\n", usage);
5420 if (technique_index == 0xffffffff)
5422 struct d3dx_parameter *parameter;
5423 struct d3dx_sampler *sampler;
5425 if (index >= base->parameter_count)
5427 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5431 parameter = get_parameter_struct(base->parameter_handles[index]);
5432 if (element_index != 0xffffffff)
5434 if (element_index >= parameter->element_count && parameter->element_count != 0)
5436 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5440 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5443 sampler = parameter->data;
5444 if (state_index >= sampler->state_count)
5446 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5450 state = &sampler->states[state_index];
5454 struct d3dx_technique *technique;
5455 struct d3dx_pass *pass;
5457 if (technique_index >= base->technique_count)
5459 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5463 technique = get_technique_struct(base->technique_handles[technique_index]);
5464 if (index >= technique->pass_count)
5466 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5470 pass = get_pass_struct(technique->pass_handles[index]);
5471 if (state_index >= pass->state_count)
5473 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5477 state = &pass->states[state_index];
5480 param = get_parameter_struct(state->parameter);
5485 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5486 switch (param->type)
5488 case D3DXPT_VERTEXSHADER:
5489 case D3DXPT_PIXELSHADER:
5490 state->type = ST_CONSTANT;
5491 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5498 state->type = ST_FXLC;
5499 hr = d3dx9_copy_data(param->data, ptr);
5503 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5509 state->type = ST_PARAMETER;
5510 hr = d3dx9_copy_data(param->data, ptr);
5513 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5518 FIXME("Unknown usage %x\n", usage);
5525 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5527 const char *ptr = data + start;
5528 D3DXHANDLE *parameter_handles = NULL;
5529 D3DXHANDLE *technique_handles = NULL;
5530 D3DXHANDLE *objects = NULL;
5531 UINT stringcount, objectcount, resourcecount;
5535 read_dword(&ptr, &base->parameter_count);
5536 TRACE("Parameter count: %u\n", base->parameter_count);
5538 read_dword(&ptr, &base->technique_count);
5539 TRACE("Technique count: %u\n", base->technique_count);
5541 skip_dword_unknown(&ptr, 1);
5543 read_dword(&ptr, &objectcount);
5544 TRACE("Object count: %u\n", objectcount);
5546 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5549 ERR("Out of memory\n");
5554 if (base->parameter_count)
5556 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5557 if (!parameter_handles)
5559 ERR("Out of memory\n");
5564 for (i = 0; i < base->parameter_count; ++i)
5566 struct d3dx_parameter *parameter;
5568 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5571 ERR("Out of memory\n");
5576 parameter_handles[i] = get_parameter_handle(parameter);
5578 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5581 WARN("Failed to parse parameter\n");
5587 if (base->technique_count)
5589 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5590 if (!technique_handles)
5592 ERR("Out of memory\n");
5597 for (i = 0; i < base->technique_count; ++i)
5599 struct d3dx_technique *technique;
5601 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5604 ERR("Out of memory\n");
5609 technique_handles[i] = get_technique_handle(technique);
5611 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5614 WARN("Failed to parse technique\n");
5620 /* needed for further parsing */
5621 base->technique_handles = technique_handles;
5622 base->parameter_handles = parameter_handles;
5624 read_dword(&ptr, &stringcount);
5625 TRACE("String count: %u\n", stringcount);
5627 read_dword(&ptr, &resourcecount);
5628 TRACE("Resource count: %u\n", resourcecount);
5630 for (i = 0; i < stringcount; ++i)
5633 struct d3dx_parameter *param;
5635 read_dword(&ptr, &id);
5636 TRACE("Id: %u\n", id);
5638 param = get_parameter_struct(objects[id]);
5640 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5643 WARN("Failed to parse data\n");
5648 for (i = 0; i < resourcecount; ++i)
5650 TRACE("parse resource %u\n", i);
5652 hr = d3dx9_parse_resource(base, data, &ptr);
5655 WARN("Failed to parse data\n");
5660 HeapFree(GetProcessHeap(), 0, objects);
5666 if (technique_handles)
5668 for (i = 0; i < base->technique_count; ++i)
5670 free_technique(technique_handles[i]);
5672 HeapFree(GetProcessHeap(), 0, technique_handles);
5675 if (parameter_handles)
5677 for (i = 0; i < base->parameter_count; ++i)
5679 free_parameter(parameter_handles[i], FALSE, FALSE);
5681 HeapFree(GetProcessHeap(), 0, parameter_handles);
5684 base->technique_handles = NULL;
5685 base->parameter_handles = NULL;
5687 HeapFree(GetProcessHeap(), 0, objects);
5692 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5693 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5696 const char *ptr = data;
5699 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5701 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5703 base->effect = effect;
5705 read_dword(&ptr, &tag);
5706 TRACE("Tag: %x\n", tag);
5708 if (tag != d3dx9_effect_version(9, 1))
5710 /* todo: compile hlsl ascii code */
5711 FIXME("HLSL ascii effects not supported, yet\n");
5713 /* Show the start of the shader for debugging info. */
5714 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5718 read_dword(&ptr, &offset);
5719 TRACE("Offset: %x\n", offset);
5721 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5724 FIXME("Failed to parse effect.\n");
5732 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5733 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5736 struct ID3DXBaseEffectImpl *object = NULL;
5738 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5740 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5743 if (pool) pool->lpVtbl->AddRef(pool);
5744 effect->pool = pool;
5746 IDirect3DDevice9_AddRef(device);
5747 effect->device = device;
5749 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5752 ERR("Out of memory\n");
5757 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5760 FIXME("Failed to parse effect.\n");
5764 effect->base_effect = &object->ID3DXBaseEffect_iface;
5766 /* initialize defaults - check because of unsupported ascii effects */
5767 if (object->technique_handles)
5769 effect->active_technique = object->technique_handles[0];
5770 effect->active_pass = NULL;
5777 HeapFree(GetProcessHeap(), 0, object);
5778 free_effect(effect);
5783 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5786 CONST D3DXMACRO* defines,
5787 LPD3DXINCLUDE include,
5788 LPCSTR skip_constants,
5790 LPD3DXEFFECTPOOL pool,
5791 LPD3DXEFFECT* effect,
5792 LPD3DXBUFFER* compilation_errors)
5794 struct ID3DXEffectImpl *object;
5797 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5798 skip_constants, flags, pool, effect, compilation_errors);
5800 if (!device || !srcdata)
5801 return D3DERR_INVALIDCALL;
5806 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5810 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5813 ERR("Out of memory\n");
5814 return E_OUTOFMEMORY;
5817 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5820 WARN("Failed to initialize shader reflection\n");
5821 HeapFree(GetProcessHeap(), 0, object);
5825 *effect = &object->ID3DXEffect_iface;
5827 TRACE("Created ID3DXEffect %p\n", object);
5832 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5835 CONST D3DXMACRO* defines,
5836 LPD3DXINCLUDE include,
5838 LPD3DXEFFECTPOOL pool,
5839 LPD3DXEFFECT* effect,
5840 LPD3DXBUFFER* compilation_errors)
5842 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5843 include, flags, pool, effect, compilation_errors);
5845 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5848 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5851 struct ID3DXBaseEffectImpl *object = NULL;
5853 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5855 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5858 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5861 ERR("Out of memory\n");
5866 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5869 FIXME("Failed to parse effect.\n");
5873 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5879 HeapFree(GetProcessHeap(), 0, object);
5880 free_effect_compiler(compiler);
5885 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5887 CONST D3DXMACRO *defines,
5888 LPD3DXINCLUDE include,
5890 LPD3DXEFFECTCOMPILER *compiler,
5891 LPD3DXBUFFER *parse_errors)
5893 struct ID3DXEffectCompilerImpl *object;
5896 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5897 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5899 if (!srcdata || !compiler)
5901 WARN("Invalid arguments supplied\n");
5902 return D3DERR_INVALIDCALL;
5905 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5908 ERR("Out of memory\n");
5909 return E_OUTOFMEMORY;
5912 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5915 WARN("Failed to initialize effect compiler\n");
5916 HeapFree(GetProcessHeap(), 0, object);
5920 *compiler = &object->ID3DXEffectCompiler_iface;
5922 TRACE("Created ID3DXEffectCompiler %p\n", object);
5927 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5929 struct ID3DXEffectPoolImpl
5931 ID3DXEffectPool ID3DXEffectPool_iface;
5935 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5937 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5940 /*** IUnknown methods ***/
5941 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5943 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
5945 if (IsEqualGUID(riid, &IID_IUnknown) ||
5946 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5948 iface->lpVtbl->AddRef(iface);
5953 WARN("Interface %s not found\n", debugstr_guid(riid));
5955 return E_NOINTERFACE;
5958 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5960 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5962 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5964 return InterlockedIncrement(&This->ref);
5967 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5969 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5970 ULONG ref = InterlockedDecrement(&This->ref);
5972 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5975 HeapFree(GetProcessHeap(), 0, This);
5980 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5982 /*** IUnknown methods ***/
5983 ID3DXEffectPoolImpl_QueryInterface,
5984 ID3DXEffectPoolImpl_AddRef,
5985 ID3DXEffectPoolImpl_Release
5988 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5990 struct ID3DXEffectPoolImpl *object;
5992 TRACE("(%p)\n", pool);
5995 return D3DERR_INVALIDCALL;
5997 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
6000 ERR("Out of memory\n");
6001 return E_OUTOFMEMORY;
6004 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
6007 *pool = &object->ID3DXEffectPool_iface;
6012 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
6013 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6014 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6020 TRACE("(%s): relay\n", debugstr_w(srcfile));
6022 if (!device || !srcfile)
6023 return D3DERR_INVALIDCALL;
6025 ret = map_view_of_file(srcfile, &buffer, &size);
6028 return D3DXERR_INVALIDDATA;
6030 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6031 UnmapViewOfFile(buffer);
6036 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
6037 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6038 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6044 TRACE("(void): relay\n");
6047 return D3DERR_INVALIDCALL;
6049 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6050 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6051 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6053 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6054 HeapFree(GetProcessHeap(), 0, srcfileW);
6059 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
6060 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6061 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6063 TRACE("(void): relay\n");
6064 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6067 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
6068 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6069 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6071 TRACE("(void): relay\n");
6072 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6075 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
6076 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6077 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6081 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6084 return D3DERR_INVALIDCALL;
6086 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6094 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6097 return D3DXERR_INVALIDDATA;
6099 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6102 return D3DXERR_INVALIDDATA;
6105 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
6106 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6107 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6111 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6114 return D3DERR_INVALIDCALL;
6116 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6124 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6127 return D3DXERR_INVALIDDATA;
6129 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6132 return D3DXERR_INVALIDDATA;
6135 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
6136 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6137 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6139 TRACE("(void): relay\n");
6140 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6143 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
6144 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6145 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6147 TRACE("(void): relay\n");
6148 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6151 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6152 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6158 TRACE("(%s): relay\n", debugstr_w(srcfile));
6161 return D3DERR_INVALIDCALL;
6163 ret = map_view_of_file(srcfile, &buffer, &size);
6166 return D3DXERR_INVALIDDATA;
6168 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6169 UnmapViewOfFile(buffer);
6174 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6175 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6181 TRACE("(void): relay\n");
6184 return D3DERR_INVALIDCALL;
6186 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6187 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6188 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6190 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
6191 HeapFree(GetProcessHeap(), 0, srcfileW);
6196 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
6197 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6201 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6203 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6211 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6214 return D3DXERR_INVALIDDATA;
6216 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6219 return D3DXERR_INVALIDDATA;
6222 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
6223 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6227 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6229 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6237 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6240 return D3DXERR_INVALIDDATA;
6242 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6245 return D3DXERR_INVALIDDATA;