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(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2651 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2652 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2654 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2656 if (param && !param->element_count &&
2657 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2658 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2659 || param->type == D3DXPT_TEXTURECUBE))
2661 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2663 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2664 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2666 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2671 WARN("Invalid argument specified\n");
2673 return D3DERR_INVALIDCALL;
2676 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2678 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2679 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2681 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2683 if (texture && param && !param->element_count &&
2684 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2685 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2686 || param->type == D3DXPT_TEXTURECUBE))
2688 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2689 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2690 TRACE("Returning %p\n", *texture);
2694 WARN("Invalid argument specified\n");
2696 return D3DERR_INVALIDCALL;
2699 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2701 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2702 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2704 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2706 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2708 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2709 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2710 TRACE("Returning %p\n", *pshader);
2714 WARN("Invalid argument specified\n");
2716 return D3DERR_INVALIDCALL;
2719 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2721 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2722 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2724 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2726 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2728 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2729 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2730 TRACE("Returning %p\n", *vshader);
2734 WARN("Invalid argument specified\n");
2736 return D3DERR_INVALIDCALL;
2739 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2741 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2743 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2748 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2750 /*** IUnknown methods ***/
2751 ID3DXBaseEffectImpl_QueryInterface,
2752 ID3DXBaseEffectImpl_AddRef,
2753 ID3DXBaseEffectImpl_Release,
2754 /*** ID3DXBaseEffect methods ***/
2755 ID3DXBaseEffectImpl_GetDesc,
2756 ID3DXBaseEffectImpl_GetParameterDesc,
2757 ID3DXBaseEffectImpl_GetTechniqueDesc,
2758 ID3DXBaseEffectImpl_GetPassDesc,
2759 ID3DXBaseEffectImpl_GetFunctionDesc,
2760 ID3DXBaseEffectImpl_GetParameter,
2761 ID3DXBaseEffectImpl_GetParameterByName,
2762 ID3DXBaseEffectImpl_GetParameterBySemantic,
2763 ID3DXBaseEffectImpl_GetParameterElement,
2764 ID3DXBaseEffectImpl_GetTechnique,
2765 ID3DXBaseEffectImpl_GetTechniqueByName,
2766 ID3DXBaseEffectImpl_GetPass,
2767 ID3DXBaseEffectImpl_GetPassByName,
2768 ID3DXBaseEffectImpl_GetFunction,
2769 ID3DXBaseEffectImpl_GetFunctionByName,
2770 ID3DXBaseEffectImpl_GetAnnotation,
2771 ID3DXBaseEffectImpl_GetAnnotationByName,
2772 ID3DXBaseEffectImpl_SetValue,
2773 ID3DXBaseEffectImpl_GetValue,
2774 ID3DXBaseEffectImpl_SetBool,
2775 ID3DXBaseEffectImpl_GetBool,
2776 ID3DXBaseEffectImpl_SetBoolArray,
2777 ID3DXBaseEffectImpl_GetBoolArray,
2778 ID3DXBaseEffectImpl_SetInt,
2779 ID3DXBaseEffectImpl_GetInt,
2780 ID3DXBaseEffectImpl_SetIntArray,
2781 ID3DXBaseEffectImpl_GetIntArray,
2782 ID3DXBaseEffectImpl_SetFloat,
2783 ID3DXBaseEffectImpl_GetFloat,
2784 ID3DXBaseEffectImpl_SetFloatArray,
2785 ID3DXBaseEffectImpl_GetFloatArray,
2786 ID3DXBaseEffectImpl_SetVector,
2787 ID3DXBaseEffectImpl_GetVector,
2788 ID3DXBaseEffectImpl_SetVectorArray,
2789 ID3DXBaseEffectImpl_GetVectorArray,
2790 ID3DXBaseEffectImpl_SetMatrix,
2791 ID3DXBaseEffectImpl_GetMatrix,
2792 ID3DXBaseEffectImpl_SetMatrixArray,
2793 ID3DXBaseEffectImpl_GetMatrixArray,
2794 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2795 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2796 ID3DXBaseEffectImpl_SetMatrixTranspose,
2797 ID3DXBaseEffectImpl_GetMatrixTranspose,
2798 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2799 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2800 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2801 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2802 ID3DXBaseEffectImpl_SetString,
2803 ID3DXBaseEffectImpl_GetString,
2804 ID3DXBaseEffectImpl_SetTexture,
2805 ID3DXBaseEffectImpl_GetTexture,
2806 ID3DXBaseEffectImpl_GetPixelShader,
2807 ID3DXBaseEffectImpl_GetVertexShader,
2808 ID3DXBaseEffectImpl_SetArrayRange,
2811 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2813 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2816 /*** IUnknown methods ***/
2817 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2819 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
2821 if (IsEqualGUID(riid, &IID_IUnknown) ||
2822 IsEqualGUID(riid, &IID_ID3DXEffect))
2824 iface->lpVtbl->AddRef(iface);
2829 ERR("Interface %s not found\n", debugstr_guid(riid));
2831 return E_NOINTERFACE;
2834 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2836 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2838 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2840 return InterlockedIncrement(&This->ref);
2843 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2845 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2846 ULONG ref = InterlockedDecrement(&This->ref);
2848 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2853 HeapFree(GetProcessHeap(), 0, This);
2859 /*** ID3DXBaseEffect methods ***/
2860 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2862 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2863 ID3DXBaseEffect *base = This->base_effect;
2865 TRACE("Forward iface %p, base %p\n", This, base);
2867 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2870 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2872 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2873 ID3DXBaseEffect *base = This->base_effect;
2875 TRACE("Forward iface %p, base %p\n", This, base);
2877 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2880 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2882 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2883 ID3DXBaseEffect *base = This->base_effect;
2885 TRACE("Forward iface %p, base %p\n", This, base);
2887 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2890 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2892 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2893 ID3DXBaseEffect *base = This->base_effect;
2895 TRACE("Forward iface %p, base %p\n", This, base);
2897 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2900 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2902 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2903 ID3DXBaseEffect *base = This->base_effect;
2905 TRACE("Forward iface %p, base %p\n", This, base);
2907 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2910 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2912 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2913 ID3DXBaseEffect *base = This->base_effect;
2915 TRACE("Forward iface %p, base %p\n", This, base);
2917 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2920 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2922 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2923 ID3DXBaseEffect *base = This->base_effect;
2925 TRACE("Forward iface %p, base %p\n", This, base);
2927 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2930 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2932 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2933 ID3DXBaseEffect *base = This->base_effect;
2935 TRACE("Forward iface %p, base %p\n", This, base);
2937 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2940 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2942 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2943 ID3DXBaseEffect *base = This->base_effect;
2945 TRACE("Forward iface %p, base %p\n", This, base);
2947 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2950 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2952 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2953 ID3DXBaseEffect *base = This->base_effect;
2955 TRACE("Forward iface %p, base %p\n", This, base);
2957 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2960 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2962 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2963 ID3DXBaseEffect *base = This->base_effect;
2965 TRACE("Forward iface %p, base %p\n", This, base);
2967 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2970 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2972 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2973 ID3DXBaseEffect *base = This->base_effect;
2975 TRACE("Forward iface %p, base %p\n", This, base);
2977 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2980 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2982 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2983 ID3DXBaseEffect *base = This->base_effect;
2985 TRACE("Forward iface %p, base %p\n", This, base);
2987 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2990 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2992 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2993 ID3DXBaseEffect *base = This->base_effect;
2995 TRACE("Forward iface %p, base %p\n", This, base);
2997 return ID3DXBaseEffectImpl_GetFunction(base, index);
3000 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
3002 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3003 ID3DXBaseEffect *base = This->base_effect;
3005 TRACE("Forward iface %p, base %p\n", This, base);
3007 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3010 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
3012 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3013 ID3DXBaseEffect *base = This->base_effect;
3015 TRACE("Forward iface %p, base %p\n", This, base);
3017 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3020 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
3022 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3023 ID3DXBaseEffect *base = This->base_effect;
3025 TRACE("Forward iface %p, base %p\n", This, base);
3027 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3030 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3032 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3033 ID3DXBaseEffect *base = This->base_effect;
3035 TRACE("Forward iface %p, base %p\n", This, base);
3037 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3040 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3042 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3043 ID3DXBaseEffect *base = This->base_effect;
3045 TRACE("Forward iface %p, base %p\n", This, base);
3047 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3050 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
3052 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3053 ID3DXBaseEffect *base = This->base_effect;
3055 TRACE("Forward iface %p, base %p\n", This, base);
3057 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3060 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
3062 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3063 ID3DXBaseEffect *base = This->base_effect;
3065 TRACE("Forward iface %p, base %p\n", This, base);
3067 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3070 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3072 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3073 ID3DXBaseEffect *base = This->base_effect;
3075 TRACE("Forward iface %p, base %p\n", This, base);
3077 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3080 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3082 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3083 ID3DXBaseEffect *base = This->base_effect;
3085 TRACE("Forward iface %p, base %p\n", This, base);
3087 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3090 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
3092 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3093 ID3DXBaseEffect *base = This->base_effect;
3095 TRACE("Forward iface %p, base %p\n", This, base);
3097 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3100 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
3102 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3103 ID3DXBaseEffect *base = This->base_effect;
3105 TRACE("Forward iface %p, base %p\n", This, base);
3107 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3110 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3112 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3113 ID3DXBaseEffect *base = This->base_effect;
3115 TRACE("Forward iface %p, base %p\n", This, base);
3117 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3120 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
3122 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3123 ID3DXBaseEffect *base = This->base_effect;
3125 TRACE("Forward iface %p, base %p\n", This, base);
3127 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3130 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
3132 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3133 ID3DXBaseEffect *base = This->base_effect;
3135 TRACE("Forward iface %p, base %p\n", This, base);
3137 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3140 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
3142 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3143 ID3DXBaseEffect *base = This->base_effect;
3145 TRACE("Forward iface %p, base %p\n", This, base);
3147 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3150 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3152 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3153 ID3DXBaseEffect *base = This->base_effect;
3155 TRACE("Forward iface %p, base %p\n", This, base);
3157 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3160 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3162 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3163 ID3DXBaseEffect *base = This->base_effect;
3165 TRACE("Forward iface %p, base %p\n", This, base);
3167 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3170 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3172 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3173 ID3DXBaseEffect *base = This->base_effect;
3175 TRACE("Forward iface %p, base %p\n", This, base);
3177 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3180 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3182 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3183 ID3DXBaseEffect *base = This->base_effect;
3185 TRACE("Forward iface %p, base %p\n", This, base);
3187 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3190 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3192 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3193 ID3DXBaseEffect *base = This->base_effect;
3195 TRACE("Forward iface %p, base %p\n", This, base);
3197 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3200 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3202 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3203 ID3DXBaseEffect *base = This->base_effect;
3205 TRACE("Forward iface %p, base %p\n", This, base);
3207 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3210 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3212 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3213 ID3DXBaseEffect *base = This->base_effect;
3215 TRACE("Forward iface %p, base %p\n", This, base);
3217 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3220 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3222 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3223 ID3DXBaseEffect *base = This->base_effect;
3225 TRACE("Forward iface %p, base %p\n", This, base);
3227 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3230 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3232 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3233 ID3DXBaseEffect *base = This->base_effect;
3235 TRACE("Forward iface %p, base %p\n", This, base);
3237 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3240 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3242 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3243 ID3DXBaseEffect *base = This->base_effect;
3245 TRACE("Forward iface %p, base %p\n", This, base);
3247 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3250 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3252 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3253 ID3DXBaseEffect *base = This->base_effect;
3255 TRACE("Forward iface %p, base %p\n", This, base);
3257 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3260 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3262 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3263 ID3DXBaseEffect *base = This->base_effect;
3265 TRACE("Forward iface %p, base %p\n", This, base);
3267 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3270 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3272 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3273 ID3DXBaseEffect *base = This->base_effect;
3275 TRACE("Forward iface %p, base %p\n", This, base);
3277 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3280 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3282 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3283 ID3DXBaseEffect *base = This->base_effect;
3285 TRACE("Forward iface %p, base %p\n", This, base);
3287 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3290 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3292 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3293 ID3DXBaseEffect *base = This->base_effect;
3295 TRACE("Forward iface %p, base %p\n", This, base);
3297 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3300 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3302 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3303 ID3DXBaseEffect *base = This->base_effect;
3305 TRACE("Forward iface %p, base %p\n", This, base);
3307 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3310 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3312 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3313 ID3DXBaseEffect *base = This->base_effect;
3315 TRACE("Forward iface %p, base %p\n", This, base);
3317 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3320 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3322 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3323 ID3DXBaseEffect *base = This->base_effect;
3325 TRACE("Forward iface %p, base %p\n", This, base);
3327 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3330 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
3332 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3333 ID3DXBaseEffect *base = This->base_effect;
3335 TRACE("Forward iface %p, base %p\n", This, base);
3337 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3340 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3342 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3343 ID3DXBaseEffect *base = This->base_effect;
3345 TRACE("Forward iface %p, base %p\n", This, base);
3347 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3350 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3352 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3353 ID3DXBaseEffect *base = This->base_effect;
3355 TRACE("Forward iface %p, base %p\n", This, base);
3357 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3360 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3362 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3363 ID3DXBaseEffect *base = This->base_effect;
3365 TRACE("Forward iface %p, base %p\n", This, base);
3367 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3370 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3372 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3373 ID3DXBaseEffect *base = This->base_effect;
3375 TRACE("Forward iface %p, base %p\n", This, base);
3377 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3380 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3382 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3383 ID3DXBaseEffect *base = This->base_effect;
3385 TRACE("Forward iface %p, base %p\n", This, base);
3387 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3390 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3392 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3393 ID3DXBaseEffect *base = This->base_effect;
3395 TRACE("Forward iface %p, base %p\n", This, base);
3397 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3400 /*** ID3DXEffect methods ***/
3401 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
3403 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3405 TRACE("iface %p, pool %p\n", This, pool);
3409 WARN("Invalid argument supplied.\n");
3410 return D3DERR_INVALIDCALL;
3415 This->pool->lpVtbl->AddRef(This->pool);
3420 TRACE("Returning pool %p\n", *pool);
3425 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3427 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3428 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3429 struct d3dx_technique *tech = is_valid_technique(base, technique);
3431 TRACE("iface %p, technique %p\n", This, technique);
3435 This->active_technique = get_technique_handle(tech);
3436 TRACE("Technique %p\n", tech);
3440 WARN("Invalid argument supplied.\n");
3442 return D3DERR_INVALIDCALL;
3445 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3447 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3449 TRACE("iface %p\n", This);
3451 return This->active_technique;
3454 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3456 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3458 FIXME("(%p)->(%p): stub\n", This, technique);
3463 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3465 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3467 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3472 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3474 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3476 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3481 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3483 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3484 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3486 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3488 if (passes && technique)
3490 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3492 TRACE("State capturing disabled.\n");
3496 FIXME("State capturing not supported, yet!\n");
3499 *passes = technique->pass_count;
3504 WARN("Invalid argument supplied.\n");
3506 return D3DERR_INVALIDCALL;
3509 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3511 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3512 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3514 TRACE("iface %p, pass %u\n", This, pass);
3516 if (technique && pass < technique->pass_count && !This->active_pass)
3518 This->active_pass = technique->pass_handles[pass];
3520 FIXME("No states applied, yet!\n");
3525 WARN("Invalid argument supplied.\n");
3527 return D3DERR_INVALIDCALL;
3530 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3532 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3534 FIXME("(%p)->(): stub\n", This);
3539 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3541 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3543 TRACE("iface %p\n", This);
3545 if (This->active_pass)
3547 This->active_pass = NULL;
3551 WARN("Invalid call.\n");
3553 return D3DERR_INVALIDCALL;
3556 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3558 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3560 FIXME("(%p)->(): stub\n", This);
3565 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3567 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3569 TRACE("iface %p, device %p\n", This, device);
3573 WARN("Invalid argument supplied.\n");
3574 return D3DERR_INVALIDCALL;
3577 IDirect3DDevice9_AddRef(This->device);
3579 *device = This->device;
3581 TRACE("Returning device %p\n", *device);
3586 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3588 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3590 FIXME("(%p)->(): stub\n", This);
3595 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3597 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3599 FIXME("(%p)->(): stub\n", This);
3604 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3606 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3608 TRACE("iface %p, manager %p\n", This, manager);
3610 if (manager) IUnknown_AddRef(manager);
3611 if (This->manager) IUnknown_Release(This->manager);
3613 This->manager = manager;
3618 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3620 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3622 TRACE("iface %p, manager %p\n", This, manager);
3626 WARN("Invalid argument supplied.\n");
3627 return D3DERR_INVALIDCALL;
3630 if (This->manager) IUnknown_AddRef(This->manager);
3631 *manager = This->manager;
3636 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3638 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3640 FIXME("(%p)->(): stub\n", This);
3645 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3647 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3649 FIXME("(%p)->(): stub\n", This);
3654 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3656 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3658 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3663 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3665 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3667 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3672 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3674 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3676 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3681 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3683 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3685 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3690 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3692 /*** IUnknown methods ***/
3693 ID3DXEffectImpl_QueryInterface,
3694 ID3DXEffectImpl_AddRef,
3695 ID3DXEffectImpl_Release,
3696 /*** ID3DXBaseEffect methods ***/
3697 ID3DXEffectImpl_GetDesc,
3698 ID3DXEffectImpl_GetParameterDesc,
3699 ID3DXEffectImpl_GetTechniqueDesc,
3700 ID3DXEffectImpl_GetPassDesc,
3701 ID3DXEffectImpl_GetFunctionDesc,
3702 ID3DXEffectImpl_GetParameter,
3703 ID3DXEffectImpl_GetParameterByName,
3704 ID3DXEffectImpl_GetParameterBySemantic,
3705 ID3DXEffectImpl_GetParameterElement,
3706 ID3DXEffectImpl_GetTechnique,
3707 ID3DXEffectImpl_GetTechniqueByName,
3708 ID3DXEffectImpl_GetPass,
3709 ID3DXEffectImpl_GetPassByName,
3710 ID3DXEffectImpl_GetFunction,
3711 ID3DXEffectImpl_GetFunctionByName,
3712 ID3DXEffectImpl_GetAnnotation,
3713 ID3DXEffectImpl_GetAnnotationByName,
3714 ID3DXEffectImpl_SetValue,
3715 ID3DXEffectImpl_GetValue,
3716 ID3DXEffectImpl_SetBool,
3717 ID3DXEffectImpl_GetBool,
3718 ID3DXEffectImpl_SetBoolArray,
3719 ID3DXEffectImpl_GetBoolArray,
3720 ID3DXEffectImpl_SetInt,
3721 ID3DXEffectImpl_GetInt,
3722 ID3DXEffectImpl_SetIntArray,
3723 ID3DXEffectImpl_GetIntArray,
3724 ID3DXEffectImpl_SetFloat,
3725 ID3DXEffectImpl_GetFloat,
3726 ID3DXEffectImpl_SetFloatArray,
3727 ID3DXEffectImpl_GetFloatArray,
3728 ID3DXEffectImpl_SetVector,
3729 ID3DXEffectImpl_GetVector,
3730 ID3DXEffectImpl_SetVectorArray,
3731 ID3DXEffectImpl_GetVectorArray,
3732 ID3DXEffectImpl_SetMatrix,
3733 ID3DXEffectImpl_GetMatrix,
3734 ID3DXEffectImpl_SetMatrixArray,
3735 ID3DXEffectImpl_GetMatrixArray,
3736 ID3DXEffectImpl_SetMatrixPointerArray,
3737 ID3DXEffectImpl_GetMatrixPointerArray,
3738 ID3DXEffectImpl_SetMatrixTranspose,
3739 ID3DXEffectImpl_GetMatrixTranspose,
3740 ID3DXEffectImpl_SetMatrixTransposeArray,
3741 ID3DXEffectImpl_GetMatrixTransposeArray,
3742 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3743 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3744 ID3DXEffectImpl_SetString,
3745 ID3DXEffectImpl_GetString,
3746 ID3DXEffectImpl_SetTexture,
3747 ID3DXEffectImpl_GetTexture,
3748 ID3DXEffectImpl_GetPixelShader,
3749 ID3DXEffectImpl_GetVertexShader,
3750 ID3DXEffectImpl_SetArrayRange,
3751 /*** ID3DXEffect methods ***/
3752 ID3DXEffectImpl_GetPool,
3753 ID3DXEffectImpl_SetTechnique,
3754 ID3DXEffectImpl_GetCurrentTechnique,
3755 ID3DXEffectImpl_ValidateTechnique,
3756 ID3DXEffectImpl_FindNextValidTechnique,
3757 ID3DXEffectImpl_IsParameterUsed,
3758 ID3DXEffectImpl_Begin,
3759 ID3DXEffectImpl_BeginPass,
3760 ID3DXEffectImpl_CommitChanges,
3761 ID3DXEffectImpl_EndPass,
3762 ID3DXEffectImpl_End,
3763 ID3DXEffectImpl_GetDevice,
3764 ID3DXEffectImpl_OnLostDevice,
3765 ID3DXEffectImpl_OnResetDevice,
3766 ID3DXEffectImpl_SetStateManager,
3767 ID3DXEffectImpl_GetStateManager,
3768 ID3DXEffectImpl_BeginParameterBlock,
3769 ID3DXEffectImpl_EndParameterBlock,
3770 ID3DXEffectImpl_ApplyParameterBlock,
3771 ID3DXEffectImpl_DeleteParameterBlock,
3772 ID3DXEffectImpl_CloneEffect,
3773 ID3DXEffectImpl_SetRawValue
3776 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3778 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3781 /*** IUnknown methods ***/
3782 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3784 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
3786 if (IsEqualGUID(riid, &IID_IUnknown) ||
3787 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3789 iface->lpVtbl->AddRef(iface);
3794 ERR("Interface %s not found\n", debugstr_guid(riid));
3796 return E_NOINTERFACE;
3799 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3801 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3803 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3805 return InterlockedIncrement(&This->ref);
3808 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3810 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3811 ULONG ref = InterlockedDecrement(&This->ref);
3813 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3817 free_effect_compiler(This);
3818 HeapFree(GetProcessHeap(), 0, This);
3824 /*** ID3DXBaseEffect methods ***/
3825 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3827 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3828 ID3DXBaseEffect *base = This->base_effect;
3830 TRACE("Forward iface %p, base %p\n", This, base);
3832 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3835 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3837 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3838 ID3DXBaseEffect *base = This->base_effect;
3840 TRACE("Forward iface %p, base %p\n", This, base);
3842 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3845 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3847 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3848 ID3DXBaseEffect *base = This->base_effect;
3850 TRACE("Forward iface %p, base %p\n", This, base);
3852 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3855 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3857 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3858 ID3DXBaseEffect *base = This->base_effect;
3860 TRACE("Forward iface %p, base %p\n", This, base);
3862 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3865 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3867 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3868 ID3DXBaseEffect *base = This->base_effect;
3870 TRACE("Forward iface %p, base %p\n", This, base);
3872 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3875 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3877 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3878 ID3DXBaseEffect *base = This->base_effect;
3880 TRACE("Forward iface %p, base %p\n", This, base);
3882 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3885 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3887 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3888 ID3DXBaseEffect *base = This->base_effect;
3890 TRACE("Forward iface %p, base %p\n", This, base);
3892 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3895 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3897 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3898 ID3DXBaseEffect *base = This->base_effect;
3900 TRACE("Forward iface %p, base %p\n", This, base);
3902 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3905 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3907 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3908 ID3DXBaseEffect *base = This->base_effect;
3910 TRACE("Forward iface %p, base %p\n", This, base);
3912 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3915 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3917 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3918 ID3DXBaseEffect *base = This->base_effect;
3920 TRACE("Forward iface %p, base %p\n", This, base);
3922 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3925 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3927 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3928 ID3DXBaseEffect *base = This->base_effect;
3930 TRACE("Forward iface %p, base %p\n", This, base);
3932 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3935 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3937 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3938 ID3DXBaseEffect *base = This->base_effect;
3940 TRACE("Forward iface %p, base %p\n", This, base);
3942 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3945 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3947 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3948 ID3DXBaseEffect *base = This->base_effect;
3950 TRACE("Forward iface %p, base %p\n", This, base);
3952 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3955 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3957 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3958 ID3DXBaseEffect *base = This->base_effect;
3960 TRACE("Forward iface %p, base %p\n", This, base);
3962 return ID3DXBaseEffectImpl_GetFunction(base, index);
3965 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3967 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3968 ID3DXBaseEffect *base = This->base_effect;
3970 TRACE("Forward iface %p, base %p\n", This, base);
3972 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3975 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3977 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3978 ID3DXBaseEffect *base = This->base_effect;
3980 TRACE("Forward iface %p, base %p\n", This, base);
3982 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3985 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3987 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3988 ID3DXBaseEffect *base = This->base_effect;
3990 TRACE("Forward iface %p, base %p\n", This, base);
3992 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3995 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3997 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3998 ID3DXBaseEffect *base = This->base_effect;
4000 TRACE("Forward iface %p, base %p\n", This, base);
4002 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
4005 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
4007 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4008 ID3DXBaseEffect *base = This->base_effect;
4010 TRACE("Forward iface %p, base %p\n", This, base);
4012 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
4015 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
4017 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4018 ID3DXBaseEffect *base = This->base_effect;
4020 TRACE("Forward iface %p, base %p\n", This, base);
4022 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
4025 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
4027 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4028 ID3DXBaseEffect *base = This->base_effect;
4030 TRACE("Forward iface %p, base %p\n", This, base);
4032 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
4035 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
4037 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4038 ID3DXBaseEffect *base = This->base_effect;
4040 TRACE("Forward iface %p, base %p\n", This, base);
4042 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
4045 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
4047 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4048 ID3DXBaseEffect *base = This->base_effect;
4050 TRACE("Forward iface %p, base %p\n", This, base);
4052 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
4055 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
4057 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4058 ID3DXBaseEffect *base = This->base_effect;
4060 TRACE("Forward iface %p, base %p\n", This, base);
4062 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
4065 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
4067 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4068 ID3DXBaseEffect *base = This->base_effect;
4070 TRACE("Forward iface %p, base %p\n", This, base);
4072 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
4075 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
4077 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4078 ID3DXBaseEffect *base = This->base_effect;
4080 TRACE("Forward iface %p, base %p\n", This, base);
4082 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
4085 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
4087 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4088 ID3DXBaseEffect *base = This->base_effect;
4090 TRACE("Forward iface %p, base %p\n", This, base);
4092 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
4095 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
4097 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4098 ID3DXBaseEffect *base = This->base_effect;
4100 TRACE("Forward iface %p, base %p\n", This, base);
4102 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
4105 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
4107 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4108 ID3DXBaseEffect *base = This->base_effect;
4110 TRACE("Forward iface %p, base %p\n", This, base);
4112 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
4115 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
4117 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4118 ID3DXBaseEffect *base = This->base_effect;
4120 TRACE("Forward iface %p, base %p\n", This, base);
4122 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
4125 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
4127 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4128 ID3DXBaseEffect *base = This->base_effect;
4130 TRACE("Forward iface %p, base %p\n", This, base);
4132 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
4135 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
4137 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4138 ID3DXBaseEffect *base = This->base_effect;
4140 TRACE("Forward iface %p, base %p\n", This, base);
4142 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
4145 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
4147 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4148 ID3DXBaseEffect *base = This->base_effect;
4150 TRACE("Forward iface %p, base %p\n", This, base);
4152 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
4155 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
4157 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4158 ID3DXBaseEffect *base = This->base_effect;
4160 TRACE("Forward iface %p, base %p\n", This, base);
4162 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
4165 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
4167 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4168 ID3DXBaseEffect *base = This->base_effect;
4170 TRACE("Forward iface %p, base %p\n", This, base);
4172 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
4175 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4177 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4178 ID3DXBaseEffect *base = This->base_effect;
4180 TRACE("Forward iface %p, base %p\n", This, base);
4182 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
4185 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4187 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4188 ID3DXBaseEffect *base = This->base_effect;
4190 TRACE("Forward iface %p, base %p\n", This, base);
4192 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
4195 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4197 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4198 ID3DXBaseEffect *base = This->base_effect;
4200 TRACE("Forward iface %p, base %p\n", This, base);
4202 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
4205 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4207 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4208 ID3DXBaseEffect *base = This->base_effect;
4210 TRACE("Forward iface %p, base %p\n", This, base);
4212 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
4215 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4217 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4218 ID3DXBaseEffect *base = This->base_effect;
4220 TRACE("Forward iface %p, base %p\n", This, base);
4222 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
4225 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4227 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4228 ID3DXBaseEffect *base = This->base_effect;
4230 TRACE("Forward iface %p, base %p\n", This, base);
4232 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
4235 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4237 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4238 ID3DXBaseEffect *base = This->base_effect;
4240 TRACE("Forward iface %p, base %p\n", This, base);
4242 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
4245 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4247 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4248 ID3DXBaseEffect *base = This->base_effect;
4250 TRACE("Forward iface %p, base %p\n", This, base);
4252 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
4255 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4257 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4258 ID3DXBaseEffect *base = This->base_effect;
4260 TRACE("Forward iface %p, base %p\n", This, base);
4262 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
4265 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4267 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4268 ID3DXBaseEffect *base = This->base_effect;
4270 TRACE("Forward iface %p, base %p\n", This, base);
4272 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
4275 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4277 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4278 ID3DXBaseEffect *base = This->base_effect;
4280 TRACE("Forward iface %p, base %p\n", This, base);
4282 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
4285 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4287 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4288 ID3DXBaseEffect *base = This->base_effect;
4290 TRACE("Forward iface %p, base %p\n", This, base);
4292 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
4295 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
4297 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4298 ID3DXBaseEffect *base = This->base_effect;
4300 TRACE("Forward iface %p, base %p\n", This, base);
4302 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
4305 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
4307 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4308 ID3DXBaseEffect *base = This->base_effect;
4310 TRACE("Forward iface %p, base %p\n", This, base);
4312 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
4315 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
4317 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4318 ID3DXBaseEffect *base = This->base_effect;
4320 TRACE("Forward iface %p, base %p\n", This, base);
4322 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
4325 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
4327 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4328 ID3DXBaseEffect *base = This->base_effect;
4330 TRACE("Forward iface %p, base %p\n", This, base);
4332 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4335 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
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_GetPixelShader(base, parameter, pshader);
4345 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
4347 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4348 ID3DXBaseEffect *base = This->base_effect;
4350 TRACE("Forward iface %p, base %p\n", This, base);
4352 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
4355 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4357 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4358 ID3DXBaseEffect *base = This->base_effect;
4360 TRACE("Forward iface %p, base %p\n", This, base);
4362 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4365 /*** ID3DXEffectCompiler methods ***/
4366 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4368 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4370 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4375 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4377 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4379 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4384 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4385 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
4387 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4389 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4394 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4395 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
4397 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4399 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4400 This, function, target, flags, shader, error_msgs, constant_table);
4405 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4407 /*** IUnknown methods ***/
4408 ID3DXEffectCompilerImpl_QueryInterface,
4409 ID3DXEffectCompilerImpl_AddRef,
4410 ID3DXEffectCompilerImpl_Release,
4411 /*** ID3DXBaseEffect methods ***/
4412 ID3DXEffectCompilerImpl_GetDesc,
4413 ID3DXEffectCompilerImpl_GetParameterDesc,
4414 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4415 ID3DXEffectCompilerImpl_GetPassDesc,
4416 ID3DXEffectCompilerImpl_GetFunctionDesc,
4417 ID3DXEffectCompilerImpl_GetParameter,
4418 ID3DXEffectCompilerImpl_GetParameterByName,
4419 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4420 ID3DXEffectCompilerImpl_GetParameterElement,
4421 ID3DXEffectCompilerImpl_GetTechnique,
4422 ID3DXEffectCompilerImpl_GetTechniqueByName,
4423 ID3DXEffectCompilerImpl_GetPass,
4424 ID3DXEffectCompilerImpl_GetPassByName,
4425 ID3DXEffectCompilerImpl_GetFunction,
4426 ID3DXEffectCompilerImpl_GetFunctionByName,
4427 ID3DXEffectCompilerImpl_GetAnnotation,
4428 ID3DXEffectCompilerImpl_GetAnnotationByName,
4429 ID3DXEffectCompilerImpl_SetValue,
4430 ID3DXEffectCompilerImpl_GetValue,
4431 ID3DXEffectCompilerImpl_SetBool,
4432 ID3DXEffectCompilerImpl_GetBool,
4433 ID3DXEffectCompilerImpl_SetBoolArray,
4434 ID3DXEffectCompilerImpl_GetBoolArray,
4435 ID3DXEffectCompilerImpl_SetInt,
4436 ID3DXEffectCompilerImpl_GetInt,
4437 ID3DXEffectCompilerImpl_SetIntArray,
4438 ID3DXEffectCompilerImpl_GetIntArray,
4439 ID3DXEffectCompilerImpl_SetFloat,
4440 ID3DXEffectCompilerImpl_GetFloat,
4441 ID3DXEffectCompilerImpl_SetFloatArray,
4442 ID3DXEffectCompilerImpl_GetFloatArray,
4443 ID3DXEffectCompilerImpl_SetVector,
4444 ID3DXEffectCompilerImpl_GetVector,
4445 ID3DXEffectCompilerImpl_SetVectorArray,
4446 ID3DXEffectCompilerImpl_GetVectorArray,
4447 ID3DXEffectCompilerImpl_SetMatrix,
4448 ID3DXEffectCompilerImpl_GetMatrix,
4449 ID3DXEffectCompilerImpl_SetMatrixArray,
4450 ID3DXEffectCompilerImpl_GetMatrixArray,
4451 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4452 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4453 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4454 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4455 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4456 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4457 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4458 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4459 ID3DXEffectCompilerImpl_SetString,
4460 ID3DXEffectCompilerImpl_GetString,
4461 ID3DXEffectCompilerImpl_SetTexture,
4462 ID3DXEffectCompilerImpl_GetTexture,
4463 ID3DXEffectCompilerImpl_GetPixelShader,
4464 ID3DXEffectCompilerImpl_GetVertexShader,
4465 ID3DXEffectCompilerImpl_SetArrayRange,
4466 /*** ID3DXEffectCompiler methods ***/
4467 ID3DXEffectCompilerImpl_SetLiteral,
4468 ID3DXEffectCompilerImpl_GetLiteral,
4469 ID3DXEffectCompilerImpl_CompileEffect,
4470 ID3DXEffectCompilerImpl_CompileShader,
4473 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4477 struct d3dx_state *states;
4479 read_dword(ptr, &sampler->state_count);
4480 TRACE("Count: %u\n", sampler->state_count);
4482 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4485 ERR("Out of memory\n");
4486 return E_OUTOFMEMORY;
4489 for (i = 0; i < sampler->state_count; ++i)
4491 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4494 WARN("Failed to parse state\n");
4499 sampler->states = states;
4505 for (i = 0; i < sampler->state_count; ++i)
4507 free_state(&states[i]);
4510 HeapFree(GetProcessHeap(), 0, states);
4515 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4522 if (param->element_count)
4524 param->data = value;
4526 for (i = 0; i < param->element_count; ++i)
4528 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4530 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4533 WARN("Failed to parse value\n");
4537 old_size += member->bytes;
4543 switch(param->class)
4547 case D3DXPC_MATRIX_ROWS:
4548 case D3DXPC_MATRIX_COLUMNS:
4549 param->data = value;
4553 param->data = value;
4555 for (i = 0; i < param->member_count; ++i)
4557 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4559 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4562 WARN("Failed to parse value\n");
4566 old_size += member->bytes;
4571 switch (param->type)
4574 case D3DXPT_TEXTURE:
4575 case D3DXPT_TEXTURE1D:
4576 case D3DXPT_TEXTURE2D:
4577 case D3DXPT_TEXTURE3D:
4578 case D3DXPT_TEXTURECUBE:
4579 case D3DXPT_PIXELSHADER:
4580 case D3DXPT_VERTEXSHADER:
4581 read_dword(ptr, &id);
4582 TRACE("Id: %u\n", id);
4583 objects[id] = get_parameter_handle(param);
4584 param->data = value;
4587 case D3DXPT_SAMPLER:
4588 case D3DXPT_SAMPLER1D:
4589 case D3DXPT_SAMPLER2D:
4590 case D3DXPT_SAMPLER3D:
4591 case D3DXPT_SAMPLERCUBE:
4593 struct d3dx_sampler *sampler;
4595 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4598 ERR("Out of memory\n");
4599 return E_OUTOFMEMORY;
4602 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4605 HeapFree(GetProcessHeap(), 0, sampler);
4606 WARN("Failed to parse sampler\n");
4610 param->data = sampler;
4615 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4621 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4628 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4630 UINT size = param->bytes;
4634 TRACE("param size: %u\n", size);
4638 value = HeapAlloc(GetProcessHeap(), 0, size);
4641 ERR("Failed to allocate data memory.\n");
4642 return E_OUTOFMEMORY;
4645 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4646 memcpy(value, ptr, size);
4649 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4652 WARN("Failed to parse value\n");
4653 HeapFree(GetProcessHeap(), 0, value);
4660 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4664 read_dword(&ptr, &size);
4665 TRACE("Name size: %#x\n", size);
4672 *name = HeapAlloc(GetProcessHeap(), 0, size);
4675 ERR("Failed to allocate name memory.\n");
4676 return E_OUTOFMEMORY;
4679 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4680 memcpy(*name, ptr, size);
4685 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4689 read_dword(ptr, &size);
4690 TRACE("Data size: %#x\n", size);
4692 *str = HeapAlloc(GetProcessHeap(), 0, size);
4695 ERR("Failed to allocate name memory.\n");
4696 return E_OUTOFMEMORY;
4699 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4700 memcpy(*str, *ptr, size);
4702 *ptr += ((size + 3) & ~3);
4707 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4712 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4714 read_dword(ptr, &size);
4715 TRACE("Data size: %#x\n", size);
4719 TRACE("Size is 0\n");
4720 *(void **)param->data = NULL;
4724 switch (param->type)
4727 /* re-read with size (sizeof(DWORD) = 4) */
4728 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4731 WARN("Failed to parse string data\n");
4736 case D3DXPT_VERTEXSHADER:
4737 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4740 WARN("Failed to create vertex shader\n");
4745 case D3DXPT_PIXELSHADER:
4746 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4749 WARN("Failed to create pixel shader\n");
4755 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4760 *ptr += ((size + 3) & ~3);
4765 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4766 struct d3dx_parameter *parent, UINT flags)
4770 D3DXHANDLE *member_handles = NULL;
4773 param->flags = flags;
4777 read_dword(ptr, ¶m->type);
4778 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4780 read_dword(ptr, ¶m->class);
4781 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4783 read_dword(ptr, &offset);
4784 TRACE("Type name offset: %#x\n", offset);
4785 hr = d3dx9_parse_name(¶m->name, data + offset);
4788 WARN("Failed to parse name\n");
4792 read_dword(ptr, &offset);
4793 TRACE("Type semantic offset: %#x\n", offset);
4794 hr = d3dx9_parse_name(¶m->semantic, data + offset);
4797 WARN("Failed to parse semantic\n");
4801 read_dword(ptr, ¶m->element_count);
4802 TRACE("Elements: %u\n", param->element_count);
4804 switch (param->class)
4807 read_dword(ptr, ¶m->columns);
4808 TRACE("Columns: %u\n", param->columns);
4810 read_dword(ptr, ¶m->rows);
4811 TRACE("Rows: %u\n", param->rows);
4813 /* sizeof(DWORD) * rows * columns */
4814 param->bytes = 4 * param->rows * param->columns;
4818 case D3DXPC_MATRIX_ROWS:
4819 case D3DXPC_MATRIX_COLUMNS:
4820 read_dword(ptr, ¶m->rows);
4821 TRACE("Rows: %u\n", param->rows);
4823 read_dword(ptr, ¶m->columns);
4824 TRACE("Columns: %u\n", param->columns);
4826 /* sizeof(DWORD) * rows * columns */
4827 param->bytes = 4 * param->rows * param->columns;
4831 read_dword(ptr, ¶m->member_count);
4832 TRACE("Members: %u\n", param->member_count);
4836 switch (param->type)
4839 param->bytes = sizeof(LPCSTR);
4842 case D3DXPT_PIXELSHADER:
4843 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4846 case D3DXPT_VERTEXSHADER:
4847 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4850 case D3DXPT_TEXTURE:
4851 case D3DXPT_TEXTURE1D:
4852 case D3DXPT_TEXTURE2D:
4853 case D3DXPT_TEXTURE3D:
4854 case D3DXPT_TEXTURECUBE:
4855 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4858 case D3DXPT_SAMPLER:
4859 case D3DXPT_SAMPLER1D:
4860 case D3DXPT_SAMPLER2D:
4861 case D3DXPT_SAMPLER3D:
4862 case D3DXPT_SAMPLERCUBE:
4867 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4873 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4880 param->type = parent->type;
4881 param->class = parent->class;
4882 param->name = parent->name;
4883 param->semantic = parent->semantic;
4884 param->element_count = 0;
4885 param->annotation_count = 0;
4886 param->member_count = parent->member_count;
4887 param->bytes = parent->bytes;
4888 param->rows = parent->rows;
4889 param->columns = parent->columns;
4892 if (param->element_count)
4894 unsigned int param_bytes = 0;
4895 const char *save_ptr = *ptr;
4897 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4898 if (!member_handles)
4900 ERR("Out of memory\n");
4905 for (i = 0; i < param->element_count; ++i)
4907 struct d3dx_parameter *member;
4910 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4913 ERR("Out of memory\n");
4918 member_handles[i] = get_parameter_handle(member);
4920 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4923 WARN("Failed to parse member\n");
4927 param_bytes += member->bytes;
4930 param->bytes = param_bytes;
4932 else if (param->member_count)
4934 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4935 if (!member_handles)
4937 ERR("Out of memory\n");
4942 for (i = 0; i < param->member_count; ++i)
4944 struct d3dx_parameter *member;
4946 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4949 ERR("Out of memory\n");
4954 member_handles[i] = get_parameter_handle(member);
4956 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4959 WARN("Failed to parse member\n");
4963 param->bytes += member->bytes;
4967 param->member_handles = member_handles;
4977 if (param->element_count) count = param->element_count;
4978 else count = param->member_count;
4980 for (i = 0; i < count; ++i)
4982 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4984 HeapFree(GetProcessHeap(), 0, member_handles);
4989 HeapFree(GetProcessHeap(), 0, param->name);
4990 HeapFree(GetProcessHeap(), 0, param->semantic);
4993 param->semantic = NULL;
4998 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
5004 anno->flags = D3DX_PARAMETER_ANNOTATION;
5006 read_dword(ptr, &offset);
5007 TRACE("Typedef offset: %#x\n", offset);
5008 ptr2 = data + offset;
5009 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
5012 WARN("Failed to parse type definition\n");
5016 read_dword(ptr, &offset);
5017 TRACE("Value offset: %#x\n", offset);
5018 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
5021 WARN("Failed to parse value\n");
5028 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
5033 struct d3dx_parameter *parameter;
5035 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5038 ERR("Out of memory\n");
5039 return E_OUTOFMEMORY;
5042 state->type = ST_CONSTANT;
5044 read_dword(ptr, &state->operation);
5045 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
5047 read_dword(ptr, &state->index);
5048 TRACE("Index: %#x\n", state->index);
5050 read_dword(ptr, &offset);
5051 TRACE("Typedef offset: %#x\n", offset);
5052 ptr2 = data + offset;
5053 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
5056 WARN("Failed to parse type definition\n");
5060 read_dword(ptr, &offset);
5061 TRACE("Value offset: %#x\n", offset);
5062 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
5065 WARN("Failed to parse value\n");
5069 state->parameter = get_parameter_handle(parameter);
5075 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
5080 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
5085 D3DXHANDLE *annotation_handles = NULL;
5088 read_dword(ptr, &offset);
5089 TRACE("Typedef offset: %#x\n", offset);
5090 ptr2 = data + offset;
5092 read_dword(ptr, &offset);
5093 TRACE("Value offset: %#x\n", offset);
5095 read_dword(ptr, ¶m->flags);
5096 TRACE("Flags: %#x\n", param->flags);
5098 read_dword(ptr, ¶m->annotation_count);
5099 TRACE("Annotation count: %u\n", param->annotation_count);
5101 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
5104 WARN("Failed to parse type definition\n");
5108 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
5111 WARN("Failed to parse value\n");
5115 if (param->annotation_count)
5117 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
5118 if (!annotation_handles)
5120 ERR("Out of memory\n");
5125 for (i = 0; i < param->annotation_count; ++i)
5127 struct d3dx_parameter *annotation;
5129 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5132 ERR("Out of memory\n");
5137 annotation_handles[i] = get_parameter_handle(annotation);
5139 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5142 WARN("Failed to parse annotation\n");
5148 param->annotation_handles = annotation_handles;
5154 if (annotation_handles)
5156 for (i = 0; i < param->annotation_count; ++i)
5158 free_parameter(annotation_handles[i], FALSE, FALSE);
5160 HeapFree(GetProcessHeap(), 0, annotation_handles);
5166 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
5171 D3DXHANDLE *annotation_handles = NULL;
5172 struct d3dx_state *states = NULL;
5175 read_dword(ptr, &offset);
5176 TRACE("Pass name offset: %#x\n", offset);
5177 hr = d3dx9_parse_name(&name, data + offset);
5180 WARN("Failed to parse name\n");
5184 read_dword(ptr, &pass->annotation_count);
5185 TRACE("Annotation count: %u\n", pass->annotation_count);
5187 read_dword(ptr, &pass->state_count);
5188 TRACE("State count: %u\n", pass->state_count);
5190 if (pass->annotation_count)
5192 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
5193 if (!annotation_handles)
5195 ERR("Out of memory\n");
5200 for (i = 0; i < pass->annotation_count; ++i)
5202 struct d3dx_parameter *annotation;
5204 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5207 ERR("Out of memory\n");
5212 annotation_handles[i] = get_parameter_handle(annotation);
5214 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5217 WARN("Failed to parse annotations\n");
5223 if (pass->state_count)
5225 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
5228 ERR("Out of memory\n");
5233 for (i = 0; i < pass->state_count; ++i)
5235 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
5238 WARN("Failed to parse annotations\n");
5245 pass->annotation_handles = annotation_handles;
5246 pass->states = states;
5252 if (annotation_handles)
5254 for (i = 0; i < pass->annotation_count; ++i)
5256 free_parameter(annotation_handles[i], FALSE, FALSE);
5258 HeapFree(GetProcessHeap(), 0, annotation_handles);
5263 for (i = 0; i < pass->state_count; ++i)
5265 free_state(&states[i]);
5267 HeapFree(GetProcessHeap(), 0, states);
5270 HeapFree(GetProcessHeap(), 0, name);
5275 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
5280 D3DXHANDLE *annotation_handles = NULL;
5281 D3DXHANDLE *pass_handles = NULL;
5284 read_dword(ptr, &offset);
5285 TRACE("Technique name offset: %#x\n", offset);
5286 hr = d3dx9_parse_name(&name, data + offset);
5289 WARN("Failed to parse name\n");
5293 read_dword(ptr, &technique->annotation_count);
5294 TRACE("Annotation count: %u\n", technique->annotation_count);
5296 read_dword(ptr, &technique->pass_count);
5297 TRACE("Pass count: %u\n", technique->pass_count);
5299 if (technique->annotation_count)
5301 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
5302 if (!annotation_handles)
5304 ERR("Out of memory\n");
5309 for (i = 0; i < technique->annotation_count; ++i)
5311 struct d3dx_parameter *annotation;
5313 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5316 ERR("Out of memory\n");
5321 annotation_handles[i] = get_parameter_handle(annotation);
5323 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5326 WARN("Failed to parse annotations\n");
5332 if (technique->pass_count)
5334 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5337 ERR("Out of memory\n");
5342 for (i = 0; i < technique->pass_count; ++i)
5344 struct d3dx_pass *pass;
5346 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5349 ERR("Out of memory\n");
5354 pass_handles[i] = get_pass_handle(pass);
5356 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5359 WARN("Failed to parse passes\n");
5365 technique->name = name;
5366 technique->pass_handles = pass_handles;
5367 technique->annotation_handles = annotation_handles;
5375 for (i = 0; i < technique->pass_count; ++i)
5377 free_pass(pass_handles[i]);
5379 HeapFree(GetProcessHeap(), 0, pass_handles);
5382 if (annotation_handles)
5384 for (i = 0; i < technique->annotation_count; ++i)
5386 free_parameter(annotation_handles[i], FALSE, FALSE);
5388 HeapFree(GetProcessHeap(), 0, annotation_handles);
5391 HeapFree(GetProcessHeap(), 0, name);
5396 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5398 DWORD technique_index;
5399 DWORD index, state_index, usage, element_index;
5400 struct d3dx_state *state;
5401 struct d3dx_parameter *param;
5402 HRESULT hr = E_FAIL;
5404 read_dword(ptr, &technique_index);
5405 TRACE("techn: %u\n", technique_index);
5407 read_dword(ptr, &index);
5408 TRACE("index: %u\n", index);
5410 read_dword(ptr, &element_index);
5411 TRACE("element_index: %u\n", element_index);
5413 read_dword(ptr, &state_index);
5414 TRACE("state_index: %u\n", state_index);
5416 read_dword(ptr, &usage);
5417 TRACE("usage: %u\n", usage);
5419 if (technique_index == 0xffffffff)
5421 struct d3dx_parameter *parameter;
5422 struct d3dx_sampler *sampler;
5424 if (index >= base->parameter_count)
5426 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5430 parameter = get_parameter_struct(base->parameter_handles[index]);
5431 if (element_index != 0xffffffff)
5433 if (element_index >= parameter->element_count && parameter->element_count != 0)
5435 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5439 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5442 sampler = parameter->data;
5443 if (state_index >= sampler->state_count)
5445 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5449 state = &sampler->states[state_index];
5453 struct d3dx_technique *technique;
5454 struct d3dx_pass *pass;
5456 if (technique_index >= base->technique_count)
5458 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5462 technique = get_technique_struct(base->technique_handles[technique_index]);
5463 if (index >= technique->pass_count)
5465 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5469 pass = get_pass_struct(technique->pass_handles[index]);
5470 if (state_index >= pass->state_count)
5472 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5476 state = &pass->states[state_index];
5479 param = get_parameter_struct(state->parameter);
5484 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5485 switch (param->type)
5487 case D3DXPT_VERTEXSHADER:
5488 case D3DXPT_PIXELSHADER:
5489 state->type = ST_CONSTANT;
5490 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5497 state->type = ST_FXLC;
5498 hr = d3dx9_copy_data(param->data, ptr);
5502 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5508 state->type = ST_PARAMETER;
5509 hr = d3dx9_copy_data(param->data, ptr);
5512 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5517 FIXME("Unknown usage %x\n", usage);
5524 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5526 const char *ptr = data + start;
5527 D3DXHANDLE *parameter_handles = NULL;
5528 D3DXHANDLE *technique_handles = NULL;
5529 D3DXHANDLE *objects = NULL;
5530 UINT stringcount, objectcount, resourcecount;
5534 read_dword(&ptr, &base->parameter_count);
5535 TRACE("Parameter count: %u\n", base->parameter_count);
5537 read_dword(&ptr, &base->technique_count);
5538 TRACE("Technique count: %u\n", base->technique_count);
5540 skip_dword_unknown(&ptr, 1);
5542 read_dword(&ptr, &objectcount);
5543 TRACE("Object count: %u\n", objectcount);
5545 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5548 ERR("Out of memory\n");
5553 if (base->parameter_count)
5555 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5556 if (!parameter_handles)
5558 ERR("Out of memory\n");
5563 for (i = 0; i < base->parameter_count; ++i)
5565 struct d3dx_parameter *parameter;
5567 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5570 ERR("Out of memory\n");
5575 parameter_handles[i] = get_parameter_handle(parameter);
5577 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5580 WARN("Failed to parse parameter\n");
5586 if (base->technique_count)
5588 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5589 if (!technique_handles)
5591 ERR("Out of memory\n");
5596 for (i = 0; i < base->technique_count; ++i)
5598 struct d3dx_technique *technique;
5600 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5603 ERR("Out of memory\n");
5608 technique_handles[i] = get_technique_handle(technique);
5610 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5613 WARN("Failed to parse technique\n");
5619 /* needed for further parsing */
5620 base->technique_handles = technique_handles;
5621 base->parameter_handles = parameter_handles;
5623 read_dword(&ptr, &stringcount);
5624 TRACE("String count: %u\n", stringcount);
5626 read_dword(&ptr, &resourcecount);
5627 TRACE("Resource count: %u\n", resourcecount);
5629 for (i = 0; i < stringcount; ++i)
5632 struct d3dx_parameter *param;
5634 read_dword(&ptr, &id);
5635 TRACE("Id: %u\n", id);
5637 param = get_parameter_struct(objects[id]);
5639 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5642 WARN("Failed to parse data\n");
5647 for (i = 0; i < resourcecount; ++i)
5649 TRACE("parse resource %u\n", i);
5651 hr = d3dx9_parse_resource(base, data, &ptr);
5654 WARN("Failed to parse data\n");
5659 HeapFree(GetProcessHeap(), 0, objects);
5665 if (technique_handles)
5667 for (i = 0; i < base->technique_count; ++i)
5669 free_technique(technique_handles[i]);
5671 HeapFree(GetProcessHeap(), 0, technique_handles);
5674 if (parameter_handles)
5676 for (i = 0; i < base->parameter_count; ++i)
5678 free_parameter(parameter_handles[i], FALSE, FALSE);
5680 HeapFree(GetProcessHeap(), 0, parameter_handles);
5683 base->technique_handles = NULL;
5684 base->parameter_handles = NULL;
5686 HeapFree(GetProcessHeap(), 0, objects);
5691 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5692 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5695 const char *ptr = data;
5698 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5700 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5702 base->effect = effect;
5704 read_dword(&ptr, &tag);
5705 TRACE("Tag: %x\n", tag);
5707 if (tag != d3dx9_effect_version(9, 1))
5709 /* todo: compile hlsl ascii code */
5710 FIXME("HLSL ascii effects not supported, yet\n");
5712 /* Show the start of the shader for debugging info. */
5713 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5717 read_dword(&ptr, &offset);
5718 TRACE("Offset: %x\n", offset);
5720 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5723 FIXME("Failed to parse effect.\n");
5731 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5732 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5735 struct ID3DXBaseEffectImpl *object = NULL;
5737 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5739 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5742 if (pool) pool->lpVtbl->AddRef(pool);
5743 effect->pool = pool;
5745 IDirect3DDevice9_AddRef(device);
5746 effect->device = device;
5748 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5751 ERR("Out of memory\n");
5756 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5759 FIXME("Failed to parse effect.\n");
5763 effect->base_effect = &object->ID3DXBaseEffect_iface;
5765 /* initialize defaults - check because of unsupported ascii effects */
5766 if (object->technique_handles)
5768 effect->active_technique = object->technique_handles[0];
5769 effect->active_pass = NULL;
5776 HeapFree(GetProcessHeap(), 0, object);
5777 free_effect(effect);
5782 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5785 CONST D3DXMACRO* defines,
5786 LPD3DXINCLUDE include,
5787 LPCSTR skip_constants,
5789 LPD3DXEFFECTPOOL pool,
5790 LPD3DXEFFECT* effect,
5791 LPD3DXBUFFER* compilation_errors)
5793 struct ID3DXEffectImpl *object;
5796 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5797 skip_constants, flags, pool, effect, compilation_errors);
5799 if (!device || !srcdata)
5800 return D3DERR_INVALIDCALL;
5805 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5809 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5812 ERR("Out of memory\n");
5813 return E_OUTOFMEMORY;
5816 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5819 WARN("Failed to initialize shader reflection\n");
5820 HeapFree(GetProcessHeap(), 0, object);
5824 *effect = &object->ID3DXEffect_iface;
5826 TRACE("Created ID3DXEffect %p\n", object);
5831 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5834 CONST D3DXMACRO* defines,
5835 LPD3DXINCLUDE include,
5837 LPD3DXEFFECTPOOL pool,
5838 LPD3DXEFFECT* effect,
5839 LPD3DXBUFFER* compilation_errors)
5841 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5842 include, flags, pool, effect, compilation_errors);
5844 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5847 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5850 struct ID3DXBaseEffectImpl *object = NULL;
5852 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5854 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5857 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5860 ERR("Out of memory\n");
5865 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5868 FIXME("Failed to parse effect.\n");
5872 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5878 HeapFree(GetProcessHeap(), 0, object);
5879 free_effect_compiler(compiler);
5884 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5886 CONST D3DXMACRO *defines,
5887 LPD3DXINCLUDE include,
5889 LPD3DXEFFECTCOMPILER *compiler,
5890 LPD3DXBUFFER *parse_errors)
5892 struct ID3DXEffectCompilerImpl *object;
5895 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5896 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5898 if (!srcdata || !compiler)
5900 WARN("Invalid arguments supplied\n");
5901 return D3DERR_INVALIDCALL;
5904 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5907 ERR("Out of memory\n");
5908 return E_OUTOFMEMORY;
5911 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5914 WARN("Failed to initialize effect compiler\n");
5915 HeapFree(GetProcessHeap(), 0, object);
5919 *compiler = &object->ID3DXEffectCompiler_iface;
5921 TRACE("Created ID3DXEffectCompiler %p\n", object);
5926 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5928 struct ID3DXEffectPoolImpl
5930 ID3DXEffectPool ID3DXEffectPool_iface;
5934 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5936 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5939 /*** IUnknown methods ***/
5940 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5942 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
5944 if (IsEqualGUID(riid, &IID_IUnknown) ||
5945 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5947 iface->lpVtbl->AddRef(iface);
5952 WARN("Interface %s not found\n", debugstr_guid(riid));
5954 return E_NOINTERFACE;
5957 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5959 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5961 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5963 return InterlockedIncrement(&This->ref);
5966 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5968 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5969 ULONG ref = InterlockedDecrement(&This->ref);
5971 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5974 HeapFree(GetProcessHeap(), 0, This);
5979 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5981 /*** IUnknown methods ***/
5982 ID3DXEffectPoolImpl_QueryInterface,
5983 ID3DXEffectPoolImpl_AddRef,
5984 ID3DXEffectPoolImpl_Release
5987 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5989 struct ID3DXEffectPoolImpl *object;
5991 TRACE("(%p)\n", pool);
5994 return D3DERR_INVALIDCALL;
5996 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5999 ERR("Out of memory\n");
6000 return E_OUTOFMEMORY;
6003 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
6006 *pool = &object->ID3DXEffectPool_iface;
6011 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
6012 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6013 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6019 TRACE("(%s): relay\n", debugstr_w(srcfile));
6021 if (!device || !srcfile)
6022 return D3DERR_INVALIDCALL;
6024 ret = map_view_of_file(srcfile, &buffer, &size);
6027 return D3DXERR_INVALIDDATA;
6029 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6030 UnmapViewOfFile(buffer);
6035 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
6036 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6037 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6043 TRACE("(void): relay\n");
6046 return D3DERR_INVALIDCALL;
6048 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6049 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6050 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6052 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6053 HeapFree(GetProcessHeap(), 0, srcfileW);
6058 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
6059 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6060 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6062 TRACE("(void): relay\n");
6063 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6066 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
6067 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6068 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6070 TRACE("(void): relay\n");
6071 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6074 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
6075 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6076 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6080 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6083 return D3DERR_INVALIDCALL;
6085 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6093 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6096 return D3DXERR_INVALIDDATA;
6098 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6101 return D3DXERR_INVALIDDATA;
6104 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
6105 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6106 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6110 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6113 return D3DERR_INVALIDCALL;
6115 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6123 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6126 return D3DXERR_INVALIDDATA;
6128 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6131 return D3DXERR_INVALIDDATA;
6134 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
6135 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6136 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6138 TRACE("(void): relay\n");
6139 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6142 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
6143 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6144 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6146 TRACE("(void): relay\n");
6147 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6150 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6151 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6157 TRACE("(%s): relay\n", debugstr_w(srcfile));
6160 return D3DERR_INVALIDCALL;
6162 ret = map_view_of_file(srcfile, &buffer, &size);
6165 return D3DXERR_INVALIDDATA;
6167 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6168 UnmapViewOfFile(buffer);
6173 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6174 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6180 TRACE("(void): relay\n");
6183 return D3DERR_INVALIDCALL;
6185 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6186 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6187 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6189 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
6190 HeapFree(GetProcessHeap(), 0, srcfileW);
6195 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
6196 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6200 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6202 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6210 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6213 return D3DXERR_INVALIDDATA;
6215 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6218 return D3DXERR_INVALIDDATA;
6221 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
6222 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6226 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6228 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6236 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6239 return D3DXERR_INVALIDDATA;
6241 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6244 return D3DXERR_INVALIDDATA;