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 INT get_int(D3DXPARAMETER_TYPE type, LPCVOID data)
870 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
877 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, LPCVOID data)
897 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
904 static inline BOOL get_bool(LPCVOID data)
906 return (*(DWORD *)data) != 0;
909 static void set_number(LPVOID outdata, D3DXPARAMETER_TYPE outtype, LPCVOID indata, D3DXPARAMETER_TYPE intype)
911 TRACE("Changing from type %s to type %s\n", debug_d3dxparameter_type(intype), debug_d3dxparameter_type(outtype));
916 *(FLOAT *)outdata = get_float(intype, indata);
920 *(BOOL *)outdata = get_bool(indata);
924 *(INT *)outdata = get_int(intype, indata);
928 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(outtype));
934 static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector)
938 for (i = 0; i < 4; ++i)
940 ((FLOAT *)vector)[i] = i < param->columns ? get_float(param->type, (DWORD *)param->data + i) : 0.0f;
944 static void set_vector(struct d3dx_parameter *param, CONST D3DXVECTOR4 *vector)
948 for (i = 0; i < param->columns; ++i)
950 set_number((FLOAT *)param->data + i, param->type, (FLOAT *)vector + i, D3DXPT_FLOAT);
954 static void get_matrix(struct d3dx_parameter *param, D3DXMATRIX *matrix)
958 for (i = 0; i < 4; ++i)
960 for (k = 0; k < 4; ++k)
962 if ((i < param->rows) && (k < param->columns))
963 matrix->u.m[i][k] = get_float(param->type, (FLOAT *)param->data + i * param->columns + k);
965 matrix->u.m[i][k] = 0.0f;
970 static void set_matrix(struct d3dx_parameter *param, CONST D3DXMATRIX *matrix)
974 for (i = 0; i < param->rows; ++i)
976 for (k = 0; k < param->columns; ++k)
978 set_number((FLOAT *)param->data + i * param->columns + k, param->type, &matrix->u.m[i][k], D3DXPT_FLOAT);
983 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
986 struct d3dx_parameter *temp_parameter;
989 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
991 if (!name || !*name) return NULL;
993 element = atoi(name);
994 part = strchr(name, ']') + 1;
996 /* check for empty [] && element range */
997 if ((part - name) > 1 && parameter->element_count > element)
999 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
1004 return get_parameter_by_name(NULL, temp_parameter, part);
1007 return get_annotation_by_name(temp_parameter->annotation_count, temp_parameter->annotation_handles, part);
1010 TRACE("Returning parameter %p\n", temp_parameter);
1011 return temp_parameter;
1014 FIXME("Unhandled case \"%c\"\n", *--part);
1019 TRACE("Parameter not found\n");
1023 static struct d3dx_parameter *get_annotation_by_name(UINT handlecount, D3DXHANDLE *handles, LPCSTR name)
1026 struct d3dx_parameter *temp_parameter;
1029 TRACE("handlecount %u, handles %p, name %s\n", handlecount, handles, debugstr_a(name));
1031 if (!name || !*name) return NULL;
1033 length = strcspn( name, "[.@" );
1034 part = name + length;
1036 for (i = 0; i < handlecount; ++i)
1038 temp_parameter = get_parameter_struct(handles[i]);
1040 if (!strcmp(temp_parameter->name, name))
1042 TRACE("Returning parameter %p\n", temp_parameter);
1043 return temp_parameter;
1045 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1050 return get_parameter_by_name(NULL, temp_parameter, part);
1053 return get_parameter_element_by_name(temp_parameter, part);
1056 FIXME("Unhandled case \"%c\"\n", *--part);
1062 TRACE("Parameter not found\n");
1066 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
1067 struct d3dx_parameter *parameter, LPCSTR name)
1069 UINT i, count, length;
1070 struct d3dx_parameter *temp_parameter;
1071 D3DXHANDLE *handles;
1074 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
1076 if (!name || !*name) return NULL;
1080 count = base->parameter_count;
1081 handles = base->parameter_handles;
1085 count = parameter->member_count;
1086 handles = parameter->member_handles;
1089 length = strcspn( name, "[.@" );
1090 part = name + length;
1092 for (i = 0; i < count; i++)
1094 temp_parameter = get_parameter_struct(handles[i]);
1096 if (!strcmp(temp_parameter->name, name))
1098 TRACE("Returning parameter %p\n", temp_parameter);
1099 return temp_parameter;
1101 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1106 return get_parameter_by_name(NULL, temp_parameter, part);
1109 return get_annotation_by_name(temp_parameter->annotation_count, temp_parameter->annotation_handles, part);
1112 return get_parameter_element_by_name(temp_parameter, part);
1115 FIXME("Unhandled case \"%c\"\n", *--part);
1121 TRACE("Parameter not found\n");
1125 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1127 return (0xfeff0000 | ((major) << 8) | (minor));
1130 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1132 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1135 /*** IUnknown methods ***/
1136 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1138 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
1140 if (IsEqualGUID(riid, &IID_IUnknown) ||
1141 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1143 iface->lpVtbl->AddRef(iface);
1148 ERR("Interface %s not found\n", debugstr_guid(riid));
1150 return E_NOINTERFACE;
1153 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1155 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1157 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1159 return InterlockedIncrement(&This->ref);
1162 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1164 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1165 ULONG ref = InterlockedDecrement(&This->ref);
1167 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1171 free_base_effect(This);
1172 HeapFree(GetProcessHeap(), 0, This);
1178 /*** ID3DXBaseEffect methods ***/
1179 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1181 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1183 FIXME("iface %p, desc %p partial stub\n", This, desc);
1187 WARN("Invalid argument specified.\n");
1188 return D3DERR_INVALIDCALL;
1191 /* Todo: add creator and function count */
1192 desc->Creator = NULL;
1193 desc->Functions = 0;
1194 desc->Parameters = This->parameter_count;
1195 desc->Techniques = This->technique_count;
1200 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1202 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1203 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1205 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1207 if (!desc || !param)
1209 WARN("Invalid argument specified.\n");
1210 return D3DERR_INVALIDCALL;
1213 desc->Name = param->name;
1214 desc->Semantic = param->semantic;
1215 desc->Class = param->class;
1216 desc->Type = param->type;
1217 desc->Rows = param->rows;
1218 desc->Columns = param->columns;
1219 desc->Elements = param->element_count;
1220 desc->Annotations = param->annotation_count;
1221 desc->StructMembers = param->member_count;
1222 desc->Flags = param->flags;
1223 desc->Bytes = param->bytes;
1228 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1230 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1231 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1233 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1237 WARN("Invalid argument specified.\n");
1238 return D3DERR_INVALIDCALL;
1241 desc->Name = tech->name;
1242 desc->Passes = tech->pass_count;
1243 desc->Annotations = tech->annotation_count;
1248 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1250 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1251 struct d3dx_pass *p = is_valid_pass(This, pass);
1253 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1257 WARN("Invalid argument specified.\n");
1258 return D3DERR_INVALIDCALL;
1261 desc->Name = p->name;
1262 desc->Annotations = p->annotation_count;
1264 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1265 desc->pVertexShaderFunction = NULL;
1266 desc->pPixelShaderFunction = NULL;
1271 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1273 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1275 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1280 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1282 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1283 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1285 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1289 if (index < This->parameter_count)
1291 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1292 return This->parameter_handles[index];
1297 if (param && !param->element_count && index < param->member_count)
1299 TRACE("Returning parameter %p\n", param->member_handles[index]);
1300 return param->member_handles[index];
1304 WARN("Invalid argument specified.\n");
1309 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1311 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1312 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1315 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1319 handle = get_parameter_handle(param);
1320 TRACE("Returning parameter %p\n", handle);
1324 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1325 TRACE("Returning parameter %p\n", handle);
1330 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1332 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1333 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1334 struct d3dx_parameter *temp_param;
1337 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1341 for (i = 0; i < This->parameter_count; ++i)
1343 temp_param = get_parameter_struct(This->parameter_handles[i]);
1345 if (!temp_param->semantic)
1349 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1350 return This->parameter_handles[i];
1355 if (!strcasecmp(temp_param->semantic, semantic))
1357 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1358 return This->parameter_handles[i];
1364 for (i = 0; i < param->member_count; ++i)
1366 temp_param = get_parameter_struct(param->member_handles[i]);
1368 if (!temp_param->semantic)
1372 TRACE("Returning parameter %p\n", param->member_handles[i]);
1373 return param->member_handles[i];
1378 if (!strcasecmp(temp_param->semantic, semantic))
1380 TRACE("Returning parameter %p\n", param->member_handles[i]);
1381 return param->member_handles[i];
1386 WARN("Invalid argument specified\n");
1391 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1393 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1394 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1396 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1400 if (index < This->parameter_count)
1402 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1403 return This->parameter_handles[index];
1408 if (index < param->element_count)
1410 TRACE("Returning parameter %p\n", param->member_handles[index]);
1411 return param->member_handles[index];
1415 WARN("Invalid argument specified\n");
1420 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1422 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1424 TRACE("iface %p, index %u\n", This, index);
1426 if (index >= This->technique_count)
1428 WARN("Invalid argument specified.\n");
1432 TRACE("Returning technique %p\n", This->technique_handles[index]);
1434 return This->technique_handles[index];
1437 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1439 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1440 struct d3dx_technique *tech = get_technique_by_name(This, name);
1442 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1446 D3DXHANDLE t = get_technique_handle(tech);
1447 TRACE("Returning technique %p\n", t);
1451 WARN("Invalid argument specified.\n");
1456 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1458 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1459 struct d3dx_technique *tech = is_valid_technique(This, technique);
1461 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1463 if (tech && index < tech->pass_count)
1465 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1466 return tech->pass_handles[index];
1469 WARN("Invalid argument specified.\n");
1474 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1476 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1477 struct d3dx_technique *tech = is_valid_technique(This, technique);
1479 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1485 for (i = 0; i < tech->pass_count; ++i)
1487 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1489 if (!strcmp(pass->name, name))
1491 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1492 return tech->pass_handles[i];
1497 WARN("Invalid argument specified.\n");
1502 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1504 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1506 FIXME("iface %p, index %u stub\n", This, index);
1511 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1513 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1515 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1520 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1522 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1523 struct d3dx_parameter *param = get_valid_parameter(This, object);
1524 struct d3dx_pass *pass = is_valid_pass(This, object);
1525 struct d3dx_technique *technique = is_valid_technique(This, object);
1526 UINT annotation_count = 0;
1527 D3DXHANDLE *annotation_handles = NULL;
1529 TRACE("iface %p, object %p, index %u\n", This, object, index);
1533 annotation_count = pass->annotation_count;
1534 annotation_handles = pass->annotation_handles;
1538 annotation_count = technique->annotation_count;
1539 annotation_handles = technique->annotation_handles;
1543 annotation_count = param->annotation_count;
1544 annotation_handles = param->annotation_handles;
1548 FIXME("Functions are not handled, yet!\n");
1551 if (index < annotation_count)
1553 TRACE("Returning parameter %p\n", annotation_handles[index]);
1554 return annotation_handles[index];
1557 WARN("Invalid argument specified\n");
1562 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1564 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1565 struct d3dx_parameter *param = get_valid_parameter(This, object);
1566 struct d3dx_pass *pass = is_valid_pass(This, object);
1567 struct d3dx_technique *technique = is_valid_technique(This, object);
1568 struct d3dx_parameter *anno = NULL;
1569 UINT annotation_count = 0;
1570 D3DXHANDLE *annotation_handles = NULL;
1572 TRACE("iface %p, object %p, name %s\n", This, object, debugstr_a(name));
1576 WARN("Invalid argument specified\n");
1582 annotation_count = pass->annotation_count;
1583 annotation_handles = pass->annotation_handles;
1587 annotation_count = technique->annotation_count;
1588 annotation_handles = technique->annotation_handles;
1592 annotation_count = param->annotation_count;
1593 annotation_handles = param->annotation_handles;
1597 FIXME("Functions are not handled, yet!\n");
1600 anno = get_annotation_by_name(annotation_count, annotation_handles, name);
1603 TRACE("Returning parameter %p\n", anno);
1604 return get_parameter_handle(anno);
1607 WARN("Invalid argument specified\n");
1612 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1614 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1615 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1617 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1621 WARN("Invalid parameter %p specified\n", parameter);
1622 return D3DERR_INVALIDCALL;
1625 /* samplers don't touch data */
1626 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1627 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1628 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1630 TRACE("Sampler: returning E_FAIL\n");
1634 if (data && param->bytes <= bytes)
1636 switch (param->type)
1642 TRACE("Copy %u bytes\n", param->bytes);
1643 memcpy(param->data, data, param->bytes);
1647 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1654 WARN("Invalid argument specified\n");
1656 return D3DERR_INVALIDCALL;
1659 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1661 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1662 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1664 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1668 WARN("Invalid parameter %p specified\n", parameter);
1669 return D3DERR_INVALIDCALL;
1672 /* samplers don't touch data */
1673 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1674 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1675 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1677 TRACE("Sampler: returning E_FAIL\n");
1681 if (data && param->bytes <= bytes)
1683 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1685 switch (param->type)
1694 case D3DXPT_VERTEXSHADER:
1695 case D3DXPT_PIXELSHADER:
1696 case D3DXPT_TEXTURE:
1697 case D3DXPT_TEXTURE1D:
1698 case D3DXPT_TEXTURE2D:
1699 case D3DXPT_TEXTURE3D:
1700 case D3DXPT_TEXTURECUBE:
1704 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1706 IUnknown *unk = ((IUnknown **)param->data)[i];
1707 if (unk) IUnknown_AddRef(unk);
1713 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1717 TRACE("Copy %u bytes\n", param->bytes);
1718 memcpy(data, param->data, param->bytes);
1722 WARN("Invalid argument specified\n");
1724 return D3DERR_INVALIDCALL;
1727 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1729 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1730 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1732 TRACE("iface %p, parameter %p, b %s\n", This, parameter, b ? "TRUE" : "FALSE");
1734 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1738 set_number(param->data, param->type, &b, D3DXPT_BOOL);
1742 WARN("Invalid argument specified\n");
1744 return D3DERR_INVALIDCALL;
1747 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1749 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1750 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1752 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1754 if (b && param && !param->element_count && param->rows == 1 && param->columns == 1)
1756 *b = get_bool(param->data);
1757 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1761 WARN("Invalid argument specified\n");
1763 return D3DERR_INVALIDCALL;
1766 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1768 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1769 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1771 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1775 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1777 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1779 switch (param->class)
1783 case D3DXPC_MATRIX_ROWS:
1784 for (i = 0; i < size; ++i)
1786 set_number((DWORD *)param->data + i, param->type, &b[i], D3DXPT_BOOL);
1795 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1800 WARN("Invalid argument specified\n");
1802 return D3DERR_INVALIDCALL;
1805 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1807 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1808 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1810 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1812 if (b && param && (param->class == D3DXPC_SCALAR
1813 || param->class == D3DXPC_VECTOR
1814 || param->class == D3DXPC_MATRIX_ROWS
1815 || param->class == D3DXPC_MATRIX_COLUMNS))
1817 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1819 for (i = 0; i < size; ++i)
1821 b[i] = get_bool((DWORD *)param->data + i);
1826 WARN("Invalid argument specified\n");
1828 return D3DERR_INVALIDCALL;
1831 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1833 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1834 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1836 TRACE("iface %p, parameter %p, n %i\n", This, parameter, n);
1838 if (param && !param->element_count)
1840 if (param->rows == 1 && param->columns == 1)
1842 set_number(param->data, param->type, &n, D3DXPT_INT);
1847 * Split the value, if parameter is a vector with dimension 3 or 4.
1849 if (param->type == D3DXPT_FLOAT &&
1850 ((param->class == D3DXPC_VECTOR && param->columns != 2) ||
1851 (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1853 TRACE("Vector fixup\n");
1855 *(FLOAT *)param->data = ((n & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
1856 ((FLOAT *)param->data)[1] = ((n & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
1857 ((FLOAT *)param->data)[2] = (n & 0xff) * INT_FLOAT_MULTI_INVERSE;
1858 if (param->rows * param->columns > 3)
1860 ((FLOAT *)param->data)[3] = ((n & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
1866 WARN("Invalid argument specified\n");
1868 return D3DERR_INVALIDCALL;
1871 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1873 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1874 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1876 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1878 if (n && param && !param->element_count)
1880 if (param->columns == 1 && param->rows == 1)
1882 *n = get_int(param->type, param->data);
1883 TRACE("Returning %i\n", *n);
1887 if (param->type == D3DXPT_FLOAT &&
1888 ((param->class == D3DXPC_VECTOR && param->columns != 2)
1889 || (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1891 TRACE("Vector fixup\n");
1893 /* all components (3,4) are clamped (0,255) and put in the INT */
1894 *n = (INT)(min(max(0.0f, *((FLOAT *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI);
1895 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
1896 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
1897 if (param->columns * param->rows > 3)
1899 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
1902 TRACE("Returning %i\n", *n);
1907 WARN("Invalid argument specified\n");
1909 return D3DERR_INVALIDCALL;
1912 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1914 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1915 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1917 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1921 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1923 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1925 switch (param->class)
1929 case D3DXPC_MATRIX_ROWS:
1930 for (i = 0; i < size; ++i)
1932 set_number((DWORD *)param->data + i, param->type, &n[i], D3DXPT_INT);
1941 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1946 WARN("Invalid argument specified\n");
1948 return D3DERR_INVALIDCALL;
1951 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1953 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1954 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1956 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1958 if (n && param && (param->class == D3DXPC_SCALAR
1959 || param->class == D3DXPC_VECTOR
1960 || param->class == D3DXPC_MATRIX_ROWS
1961 || param->class == D3DXPC_MATRIX_COLUMNS))
1963 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1965 for (i = 0; i < size; ++i)
1967 n[i] = get_int(param->type, (DWORD *)param->data + i);
1972 WARN("Invalid argument specified\n");
1974 return D3DERR_INVALIDCALL;
1977 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1979 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1980 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1982 TRACE("iface %p, parameter %p, f %f\n", This, parameter, f);
1984 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1986 set_number((DWORD *)param->data, param->type, &f, D3DXPT_FLOAT);
1990 WARN("Invalid argument specified\n");
1992 return D3DERR_INVALIDCALL;
1995 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1997 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1998 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2000 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
2002 if (f && param && !param->element_count && param->columns == 1 && param->rows == 1)
2004 *f = get_float(param->type, (DWORD *)param->data);
2005 TRACE("Returning %f\n", *f);
2009 WARN("Invalid argument specified\n");
2011 return D3DERR_INVALIDCALL;
2014 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2016 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2017 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2019 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
2023 UINT i, size = min(count, param->bytes / sizeof(DWORD));
2025 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2027 switch (param->class)
2031 case D3DXPC_MATRIX_ROWS:
2032 for (i = 0; i < size; ++i)
2034 set_number((DWORD *)param->data + i, param->type, &f[i], D3DXPT_FLOAT);
2043 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2048 WARN("Invalid argument specified\n");
2050 return D3DERR_INVALIDCALL;
2053 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2055 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2056 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2058 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
2060 if (f && param && (param->class == D3DXPC_SCALAR
2061 || param->class == D3DXPC_VECTOR
2062 || param->class == D3DXPC_MATRIX_ROWS
2063 || param->class == D3DXPC_MATRIX_COLUMNS))
2065 UINT i, size = min(count, param->bytes / sizeof(DWORD));
2067 for (i = 0; i < size; ++i)
2069 f[i] = get_float(param->type, (DWORD *)param->data + i);
2074 WARN("Invalid argument specified\n");
2076 return D3DERR_INVALIDCALL;
2079 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2081 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2082 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2084 TRACE("iface %p, parameter %p, vector %p\n", This, parameter, vector);
2086 if (param && !param->element_count)
2088 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2090 switch (param->class)
2094 if (param->type == D3DXPT_INT && param->bytes == 4)
2098 TRACE("INT fixup\n");
2099 tmp = (DWORD)(max(min(vector->z, 1.0f), 0.0f) * INT_FLOAT_MULTI);
2100 tmp += ((DWORD)(max(min(vector->y, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 8;
2101 tmp += ((DWORD)(max(min(vector->x, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 16;
2102 tmp += ((DWORD)(max(min(vector->w, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 24;
2104 *(INT *)param->data = tmp;
2107 set_vector(param, vector);
2110 case D3DXPC_MATRIX_ROWS:
2116 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2121 WARN("Invalid argument specified\n");
2123 return D3DERR_INVALIDCALL;
2126 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2128 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2129 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2131 TRACE("iface %p, parameter %p, vector %p\n", This, parameter, vector);
2133 if (vector && param && !param->element_count)
2135 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2137 switch (param->class)
2141 if (param->type == D3DXPT_INT && param->bytes == 4)
2143 TRACE("INT fixup\n");
2144 vector->x = (((*(INT *)param->data) & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
2145 vector->y = (((*(INT *)param->data) & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
2146 vector->z = ((*(INT *)param->data) & 0xff) * INT_FLOAT_MULTI_INVERSE;
2147 vector->w = (((*(INT *)param->data) & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
2150 get_vector(param, vector);
2153 case D3DXPC_MATRIX_ROWS:
2159 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2164 WARN("Invalid argument specified\n");
2166 return D3DERR_INVALIDCALL;
2169 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2171 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2172 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2174 TRACE("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
2176 if (param && param->element_count && param->element_count >= count)
2180 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2182 switch (param->class)
2185 for (i = 0; i < count; ++i)
2187 set_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2192 case D3DXPC_MATRIX_ROWS:
2198 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2203 WARN("Invalid argument specified\n");
2205 return D3DERR_INVALIDCALL;
2208 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2210 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2211 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2213 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
2215 if (!count) return D3D_OK;
2217 if (vector && param && count <= param->element_count)
2221 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2223 switch (param->class)
2226 for (i = 0; i < count; ++i)
2228 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2233 case D3DXPC_MATRIX_ROWS:
2239 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2244 WARN("Invalid argument specified\n");
2246 return D3DERR_INVALIDCALL;
2249 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2251 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2252 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2254 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2256 if (param && !param->element_count)
2258 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2260 switch (param->class)
2262 case D3DXPC_MATRIX_ROWS:
2263 set_matrix(param, matrix);
2273 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2278 WARN("Invalid argument specified\n");
2280 return D3DERR_INVALIDCALL;
2283 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2285 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2286 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2288 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2290 if (matrix && param && !param->element_count)
2292 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2294 switch (param->class)
2296 case D3DXPC_MATRIX_ROWS:
2297 get_matrix(param, matrix);
2307 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2312 WARN("Invalid argument specified\n");
2314 return D3DERR_INVALIDCALL;
2317 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2319 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2320 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2322 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2324 if (param && param->element_count >= count)
2328 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2330 switch (param->class)
2332 case D3DXPC_MATRIX_ROWS:
2333 for (i = 0; i < count; ++i)
2335 set_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i]);
2346 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2351 WARN("Invalid argument specified\n");
2353 return D3DERR_INVALIDCALL;
2356 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2358 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2359 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2361 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2363 if (!count) return D3D_OK;
2365 if (matrix && param && count <= param->element_count)
2369 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2371 switch (param->class)
2373 case D3DXPC_MATRIX_ROWS:
2374 for (i = 0; i < count; ++i)
2376 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i]);
2387 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2392 WARN("Invalid argument specified\n");
2394 return D3DERR_INVALIDCALL;
2397 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2399 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2400 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2402 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2404 if (param && count <= param->element_count)
2408 switch (param->class)
2410 case D3DXPC_MATRIX_ROWS:
2411 for (i = 0; i < count; ++i)
2413 set_matrix(get_parameter_struct(param->member_handles[i]), matrix[i]);
2423 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2428 WARN("Invalid argument specified\n");
2430 return D3DERR_INVALIDCALL;
2433 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2435 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2436 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2438 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2440 if (!count) return D3D_OK;
2442 if (param && matrix && count <= param->element_count)
2446 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2448 switch (param->class)
2450 case D3DXPC_MATRIX_ROWS:
2451 for (i = 0; i < count; ++i)
2453 get_matrix(get_parameter_struct(param->member_handles[i]), matrix[i]);
2463 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2468 WARN("Invalid argument specified\n");
2470 return D3DERR_INVALIDCALL;
2473 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2475 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2476 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2479 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2481 if (param && !param->element_count)
2483 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2485 switch (param->class)
2487 case D3DXPC_MATRIX_ROWS:
2488 set_matrix(param, D3DXMatrixTranspose(&m, matrix));
2498 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2503 WARN("Invalid argument specified\n");
2505 return D3DERR_INVALIDCALL;
2508 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2510 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2511 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2514 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2516 if (matrix && param && !param->element_count)
2518 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2520 switch (param->class)
2524 get_matrix(param, matrix);
2527 case D3DXPC_MATRIX_ROWS:
2528 get_matrix(param, &m);
2529 D3DXMatrixTranspose(matrix, &m);
2537 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2542 WARN("Invalid argument specified\n");
2544 return D3DERR_INVALIDCALL;
2547 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2549 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2550 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2553 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2555 if (param && param->element_count >= count)
2559 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2561 switch (param->class)
2563 case D3DXPC_MATRIX_ROWS:
2564 for (i = 0; i < count; ++i)
2566 set_matrix(get_parameter_struct(param->member_handles[i]), D3DXMatrixTranspose(&m, &matrix[i]));
2577 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2582 WARN("Invalid argument specified\n");
2584 return D3DERR_INVALIDCALL;
2587 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2589 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2590 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2592 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2594 if (!count) return D3D_OK;
2596 if (matrix && param && count <= param->element_count)
2600 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2602 switch (param->class)
2604 case D3DXPC_MATRIX_ROWS:
2605 for (i = 0; i < count; ++i)
2609 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2610 D3DXMatrixTranspose(&matrix[i], &m);
2621 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2626 WARN("Invalid argument specified\n");
2628 return D3DERR_INVALIDCALL;
2631 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2633 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2634 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2637 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2639 if (param && count <= param->element_count)
2643 switch (param->class)
2645 case D3DXPC_MATRIX_ROWS:
2646 for (i = 0; i < count; ++i)
2648 set_matrix(get_parameter_struct(param->member_handles[i]), D3DXMatrixTranspose(&m, matrix[i]));
2658 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2663 WARN("Invalid argument specified\n");
2665 return D3DERR_INVALIDCALL;
2668 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2670 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2671 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2673 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2675 if (!count) return D3D_OK;
2677 if (matrix && param && count <= param->element_count)
2682 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2684 switch (param->class)
2686 case D3DXPC_MATRIX_ROWS:
2687 for (i = 0; i < count; ++i)
2689 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2690 D3DXMatrixTranspose(matrix[i], &m);
2700 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2705 WARN("Invalid argument specified\n");
2707 return D3DERR_INVALIDCALL;
2710 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2712 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2714 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2719 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2721 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2722 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2724 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2726 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2728 *string = *(LPCSTR *)param->data;
2729 TRACE("Returning %s\n", debugstr_a(*string));
2733 WARN("Invalid argument specified\n");
2735 return D3DERR_INVALIDCALL;
2738 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2740 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2741 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2743 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2745 if (param && !param->element_count &&
2746 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2747 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2748 || param->type == D3DXPT_TEXTURECUBE))
2750 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2752 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2753 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2755 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2760 WARN("Invalid argument specified\n");
2762 return D3DERR_INVALIDCALL;
2765 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2767 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2768 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2770 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2772 if (texture && param && !param->element_count &&
2773 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2774 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2775 || param->type == D3DXPT_TEXTURECUBE))
2777 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2778 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2779 TRACE("Returning %p\n", *texture);
2783 WARN("Invalid argument specified\n");
2785 return D3DERR_INVALIDCALL;
2788 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2790 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2791 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2793 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2795 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2797 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2798 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2799 TRACE("Returning %p\n", *pshader);
2803 WARN("Invalid argument specified\n");
2805 return D3DERR_INVALIDCALL;
2808 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2810 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2811 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2813 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2815 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2817 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2818 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2819 TRACE("Returning %p\n", *vshader);
2823 WARN("Invalid argument specified\n");
2825 return D3DERR_INVALIDCALL;
2828 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2830 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2832 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2837 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2839 /*** IUnknown methods ***/
2840 ID3DXBaseEffectImpl_QueryInterface,
2841 ID3DXBaseEffectImpl_AddRef,
2842 ID3DXBaseEffectImpl_Release,
2843 /*** ID3DXBaseEffect methods ***/
2844 ID3DXBaseEffectImpl_GetDesc,
2845 ID3DXBaseEffectImpl_GetParameterDesc,
2846 ID3DXBaseEffectImpl_GetTechniqueDesc,
2847 ID3DXBaseEffectImpl_GetPassDesc,
2848 ID3DXBaseEffectImpl_GetFunctionDesc,
2849 ID3DXBaseEffectImpl_GetParameter,
2850 ID3DXBaseEffectImpl_GetParameterByName,
2851 ID3DXBaseEffectImpl_GetParameterBySemantic,
2852 ID3DXBaseEffectImpl_GetParameterElement,
2853 ID3DXBaseEffectImpl_GetTechnique,
2854 ID3DXBaseEffectImpl_GetTechniqueByName,
2855 ID3DXBaseEffectImpl_GetPass,
2856 ID3DXBaseEffectImpl_GetPassByName,
2857 ID3DXBaseEffectImpl_GetFunction,
2858 ID3DXBaseEffectImpl_GetFunctionByName,
2859 ID3DXBaseEffectImpl_GetAnnotation,
2860 ID3DXBaseEffectImpl_GetAnnotationByName,
2861 ID3DXBaseEffectImpl_SetValue,
2862 ID3DXBaseEffectImpl_GetValue,
2863 ID3DXBaseEffectImpl_SetBool,
2864 ID3DXBaseEffectImpl_GetBool,
2865 ID3DXBaseEffectImpl_SetBoolArray,
2866 ID3DXBaseEffectImpl_GetBoolArray,
2867 ID3DXBaseEffectImpl_SetInt,
2868 ID3DXBaseEffectImpl_GetInt,
2869 ID3DXBaseEffectImpl_SetIntArray,
2870 ID3DXBaseEffectImpl_GetIntArray,
2871 ID3DXBaseEffectImpl_SetFloat,
2872 ID3DXBaseEffectImpl_GetFloat,
2873 ID3DXBaseEffectImpl_SetFloatArray,
2874 ID3DXBaseEffectImpl_GetFloatArray,
2875 ID3DXBaseEffectImpl_SetVector,
2876 ID3DXBaseEffectImpl_GetVector,
2877 ID3DXBaseEffectImpl_SetVectorArray,
2878 ID3DXBaseEffectImpl_GetVectorArray,
2879 ID3DXBaseEffectImpl_SetMatrix,
2880 ID3DXBaseEffectImpl_GetMatrix,
2881 ID3DXBaseEffectImpl_SetMatrixArray,
2882 ID3DXBaseEffectImpl_GetMatrixArray,
2883 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2884 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2885 ID3DXBaseEffectImpl_SetMatrixTranspose,
2886 ID3DXBaseEffectImpl_GetMatrixTranspose,
2887 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2888 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2889 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2890 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2891 ID3DXBaseEffectImpl_SetString,
2892 ID3DXBaseEffectImpl_GetString,
2893 ID3DXBaseEffectImpl_SetTexture,
2894 ID3DXBaseEffectImpl_GetTexture,
2895 ID3DXBaseEffectImpl_GetPixelShader,
2896 ID3DXBaseEffectImpl_GetVertexShader,
2897 ID3DXBaseEffectImpl_SetArrayRange,
2900 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2902 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2905 /*** IUnknown methods ***/
2906 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2908 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
2910 if (IsEqualGUID(riid, &IID_IUnknown) ||
2911 IsEqualGUID(riid, &IID_ID3DXEffect))
2913 iface->lpVtbl->AddRef(iface);
2918 ERR("Interface %s not found\n", debugstr_guid(riid));
2920 return E_NOINTERFACE;
2923 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2925 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2927 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2929 return InterlockedIncrement(&This->ref);
2932 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2934 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2935 ULONG ref = InterlockedDecrement(&This->ref);
2937 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2942 HeapFree(GetProcessHeap(), 0, This);
2948 /*** ID3DXBaseEffect methods ***/
2949 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2951 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2952 ID3DXBaseEffect *base = This->base_effect;
2954 TRACE("Forward iface %p, base %p\n", This, base);
2956 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2959 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2961 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2962 ID3DXBaseEffect *base = This->base_effect;
2964 TRACE("Forward iface %p, base %p\n", This, base);
2966 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2969 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2971 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2972 ID3DXBaseEffect *base = This->base_effect;
2974 TRACE("Forward iface %p, base %p\n", This, base);
2976 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2979 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2981 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2982 ID3DXBaseEffect *base = This->base_effect;
2984 TRACE("Forward iface %p, base %p\n", This, base);
2986 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2989 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2991 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2992 ID3DXBaseEffect *base = This->base_effect;
2994 TRACE("Forward iface %p, base %p\n", This, base);
2996 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2999 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
3001 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3002 ID3DXBaseEffect *base = This->base_effect;
3004 TRACE("Forward iface %p, base %p\n", This, base);
3006 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3009 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
3011 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3012 ID3DXBaseEffect *base = This->base_effect;
3014 TRACE("Forward iface %p, base %p\n", This, base);
3016 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3019 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
3021 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3022 ID3DXBaseEffect *base = This->base_effect;
3024 TRACE("Forward iface %p, base %p\n", This, base);
3026 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3029 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
3031 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3032 ID3DXBaseEffect *base = This->base_effect;
3034 TRACE("Forward iface %p, base %p\n", This, base);
3036 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3039 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
3041 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3042 ID3DXBaseEffect *base = This->base_effect;
3044 TRACE("Forward iface %p, base %p\n", This, base);
3046 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3049 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
3051 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3052 ID3DXBaseEffect *base = This->base_effect;
3054 TRACE("Forward iface %p, base %p\n", This, base);
3056 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3059 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
3061 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3062 ID3DXBaseEffect *base = This->base_effect;
3064 TRACE("Forward iface %p, base %p\n", This, base);
3066 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3069 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
3071 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3072 ID3DXBaseEffect *base = This->base_effect;
3074 TRACE("Forward iface %p, base %p\n", This, base);
3076 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3079 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
3081 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3082 ID3DXBaseEffect *base = This->base_effect;
3084 TRACE("Forward iface %p, base %p\n", This, base);
3086 return ID3DXBaseEffectImpl_GetFunction(base, index);
3089 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
3091 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3092 ID3DXBaseEffect *base = This->base_effect;
3094 TRACE("Forward iface %p, base %p\n", This, base);
3096 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3099 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
3101 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3102 ID3DXBaseEffect *base = This->base_effect;
3104 TRACE("Forward iface %p, base %p\n", This, base);
3106 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3109 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
3111 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3112 ID3DXBaseEffect *base = This->base_effect;
3114 TRACE("Forward iface %p, base %p\n", This, base);
3116 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3119 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3121 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3122 ID3DXBaseEffect *base = This->base_effect;
3124 TRACE("Forward iface %p, base %p\n", This, base);
3126 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3129 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3131 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3132 ID3DXBaseEffect *base = This->base_effect;
3134 TRACE("Forward iface %p, base %p\n", This, base);
3136 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3139 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
3141 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3142 ID3DXBaseEffect *base = This->base_effect;
3144 TRACE("Forward iface %p, base %p\n", This, base);
3146 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3149 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
3151 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3152 ID3DXBaseEffect *base = This->base_effect;
3154 TRACE("Forward iface %p, base %p\n", This, base);
3156 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3159 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3161 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3162 ID3DXBaseEffect *base = This->base_effect;
3164 TRACE("Forward iface %p, base %p\n", This, base);
3166 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3169 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3171 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3172 ID3DXBaseEffect *base = This->base_effect;
3174 TRACE("Forward iface %p, base %p\n", This, base);
3176 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3179 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
3181 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3182 ID3DXBaseEffect *base = This->base_effect;
3184 TRACE("Forward iface %p, base %p\n", This, base);
3186 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3189 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
3191 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3192 ID3DXBaseEffect *base = This->base_effect;
3194 TRACE("Forward iface %p, base %p\n", This, base);
3196 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3199 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3201 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3202 ID3DXBaseEffect *base = This->base_effect;
3204 TRACE("Forward iface %p, base %p\n", This, base);
3206 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3209 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
3211 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3212 ID3DXBaseEffect *base = This->base_effect;
3214 TRACE("Forward iface %p, base %p\n", This, base);
3216 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3219 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
3221 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3222 ID3DXBaseEffect *base = This->base_effect;
3224 TRACE("Forward iface %p, base %p\n", This, base);
3226 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3229 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
3231 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3232 ID3DXBaseEffect *base = This->base_effect;
3234 TRACE("Forward iface %p, base %p\n", This, base);
3236 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3239 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3241 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3242 ID3DXBaseEffect *base = This->base_effect;
3244 TRACE("Forward iface %p, base %p\n", This, base);
3246 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3249 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3251 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3252 ID3DXBaseEffect *base = This->base_effect;
3254 TRACE("Forward iface %p, base %p\n", This, base);
3256 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3259 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3261 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3262 ID3DXBaseEffect *base = This->base_effect;
3264 TRACE("Forward iface %p, base %p\n", This, base);
3266 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3269 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3271 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3272 ID3DXBaseEffect *base = This->base_effect;
3274 TRACE("Forward iface %p, base %p\n", This, base);
3276 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3279 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3281 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3282 ID3DXBaseEffect *base = This->base_effect;
3284 TRACE("Forward iface %p, base %p\n", This, base);
3286 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3289 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3291 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3292 ID3DXBaseEffect *base = This->base_effect;
3294 TRACE("Forward iface %p, base %p\n", This, base);
3296 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3299 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3301 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3302 ID3DXBaseEffect *base = This->base_effect;
3304 TRACE("Forward iface %p, base %p\n", This, base);
3306 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3309 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3311 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3312 ID3DXBaseEffect *base = This->base_effect;
3314 TRACE("Forward iface %p, base %p\n", This, base);
3316 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3319 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3321 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3322 ID3DXBaseEffect *base = This->base_effect;
3324 TRACE("Forward iface %p, base %p\n", This, base);
3326 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3329 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3331 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3332 ID3DXBaseEffect *base = This->base_effect;
3334 TRACE("Forward iface %p, base %p\n", This, base);
3336 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3339 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3341 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3342 ID3DXBaseEffect *base = This->base_effect;
3344 TRACE("Forward iface %p, base %p\n", This, base);
3346 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3349 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3351 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3352 ID3DXBaseEffect *base = This->base_effect;
3354 TRACE("Forward iface %p, base %p\n", This, base);
3356 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3359 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3361 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3362 ID3DXBaseEffect *base = This->base_effect;
3364 TRACE("Forward iface %p, base %p\n", This, base);
3366 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3369 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3371 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3372 ID3DXBaseEffect *base = This->base_effect;
3374 TRACE("Forward iface %p, base %p\n", This, base);
3376 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3379 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3381 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3382 ID3DXBaseEffect *base = This->base_effect;
3384 TRACE("Forward iface %p, base %p\n", This, base);
3386 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3389 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3391 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3392 ID3DXBaseEffect *base = This->base_effect;
3394 TRACE("Forward iface %p, base %p\n", This, base);
3396 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3399 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3401 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3402 ID3DXBaseEffect *base = This->base_effect;
3404 TRACE("Forward iface %p, base %p\n", This, base);
3406 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3409 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3411 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3412 ID3DXBaseEffect *base = This->base_effect;
3414 TRACE("Forward iface %p, base %p\n", This, base);
3416 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3419 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
3421 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3422 ID3DXBaseEffect *base = This->base_effect;
3424 TRACE("Forward iface %p, base %p\n", This, base);
3426 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3429 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3431 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3432 ID3DXBaseEffect *base = This->base_effect;
3434 TRACE("Forward iface %p, base %p\n", This, base);
3436 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3439 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3441 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3442 ID3DXBaseEffect *base = This->base_effect;
3444 TRACE("Forward iface %p, base %p\n", This, base);
3446 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3449 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3451 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3452 ID3DXBaseEffect *base = This->base_effect;
3454 TRACE("Forward iface %p, base %p\n", This, base);
3456 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3459 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3461 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3462 ID3DXBaseEffect *base = This->base_effect;
3464 TRACE("Forward iface %p, base %p\n", This, base);
3466 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3469 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3471 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3472 ID3DXBaseEffect *base = This->base_effect;
3474 TRACE("Forward iface %p, base %p\n", This, base);
3476 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3479 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3481 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3482 ID3DXBaseEffect *base = This->base_effect;
3484 TRACE("Forward iface %p, base %p\n", This, base);
3486 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3489 /*** ID3DXEffect methods ***/
3490 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
3492 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3494 TRACE("iface %p, pool %p\n", This, pool);
3498 WARN("Invalid argument supplied.\n");
3499 return D3DERR_INVALIDCALL;
3504 This->pool->lpVtbl->AddRef(This->pool);
3509 TRACE("Returning pool %p\n", *pool);
3514 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3516 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3517 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3518 struct d3dx_technique *tech = is_valid_technique(base, technique);
3520 TRACE("iface %p, technique %p\n", This, technique);
3524 This->active_technique = get_technique_handle(tech);
3525 TRACE("Technique %p\n", tech);
3529 WARN("Invalid argument supplied.\n");
3531 return D3DERR_INVALIDCALL;
3534 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3536 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3538 TRACE("iface %p\n", This);
3540 return This->active_technique;
3543 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3545 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3547 FIXME("(%p)->(%p): stub\n", This, technique);
3552 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3554 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3556 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3561 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3563 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3565 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3570 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3572 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3573 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3575 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3577 if (passes && technique)
3579 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3581 TRACE("State capturing disabled.\n");
3585 FIXME("State capturing not supported, yet!\n");
3588 *passes = technique->pass_count;
3593 WARN("Invalid argument supplied.\n");
3595 return D3DERR_INVALIDCALL;
3598 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3600 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3601 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3603 TRACE("iface %p, pass %u\n", This, pass);
3605 if (technique && pass < technique->pass_count && !This->active_pass)
3607 This->active_pass = technique->pass_handles[pass];
3609 FIXME("No states applied, yet!\n");
3614 WARN("Invalid argument supplied.\n");
3616 return D3DERR_INVALIDCALL;
3619 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3621 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3623 FIXME("(%p)->(): stub\n", This);
3628 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3630 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3632 TRACE("iface %p\n", This);
3634 if (This->active_pass)
3636 This->active_pass = NULL;
3640 WARN("Invalid call.\n");
3642 return D3DERR_INVALIDCALL;
3645 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3647 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3649 FIXME("(%p)->(): stub\n", This);
3654 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3656 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3658 TRACE("iface %p, device %p\n", This, device);
3662 WARN("Invalid argument supplied.\n");
3663 return D3DERR_INVALIDCALL;
3666 IDirect3DDevice9_AddRef(This->device);
3668 *device = This->device;
3670 TRACE("Returning device %p\n", *device);
3675 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3677 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3679 FIXME("(%p)->(): stub\n", This);
3684 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3686 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3688 FIXME("(%p)->(): stub\n", This);
3693 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3695 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3697 TRACE("iface %p, manager %p\n", This, manager);
3699 if (manager) IUnknown_AddRef(manager);
3700 if (This->manager) IUnknown_Release(This->manager);
3702 This->manager = manager;
3707 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3709 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3711 TRACE("iface %p, manager %p\n", This, manager);
3715 WARN("Invalid argument supplied.\n");
3716 return D3DERR_INVALIDCALL;
3719 if (This->manager) IUnknown_AddRef(This->manager);
3720 *manager = This->manager;
3725 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3727 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3729 FIXME("(%p)->(): stub\n", This);
3734 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3736 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3738 FIXME("(%p)->(): stub\n", This);
3743 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3745 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3747 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3752 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3754 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3756 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3761 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3763 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3765 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3770 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3772 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3774 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3779 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3781 /*** IUnknown methods ***/
3782 ID3DXEffectImpl_QueryInterface,
3783 ID3DXEffectImpl_AddRef,
3784 ID3DXEffectImpl_Release,
3785 /*** ID3DXBaseEffect methods ***/
3786 ID3DXEffectImpl_GetDesc,
3787 ID3DXEffectImpl_GetParameterDesc,
3788 ID3DXEffectImpl_GetTechniqueDesc,
3789 ID3DXEffectImpl_GetPassDesc,
3790 ID3DXEffectImpl_GetFunctionDesc,
3791 ID3DXEffectImpl_GetParameter,
3792 ID3DXEffectImpl_GetParameterByName,
3793 ID3DXEffectImpl_GetParameterBySemantic,
3794 ID3DXEffectImpl_GetParameterElement,
3795 ID3DXEffectImpl_GetTechnique,
3796 ID3DXEffectImpl_GetTechniqueByName,
3797 ID3DXEffectImpl_GetPass,
3798 ID3DXEffectImpl_GetPassByName,
3799 ID3DXEffectImpl_GetFunction,
3800 ID3DXEffectImpl_GetFunctionByName,
3801 ID3DXEffectImpl_GetAnnotation,
3802 ID3DXEffectImpl_GetAnnotationByName,
3803 ID3DXEffectImpl_SetValue,
3804 ID3DXEffectImpl_GetValue,
3805 ID3DXEffectImpl_SetBool,
3806 ID3DXEffectImpl_GetBool,
3807 ID3DXEffectImpl_SetBoolArray,
3808 ID3DXEffectImpl_GetBoolArray,
3809 ID3DXEffectImpl_SetInt,
3810 ID3DXEffectImpl_GetInt,
3811 ID3DXEffectImpl_SetIntArray,
3812 ID3DXEffectImpl_GetIntArray,
3813 ID3DXEffectImpl_SetFloat,
3814 ID3DXEffectImpl_GetFloat,
3815 ID3DXEffectImpl_SetFloatArray,
3816 ID3DXEffectImpl_GetFloatArray,
3817 ID3DXEffectImpl_SetVector,
3818 ID3DXEffectImpl_GetVector,
3819 ID3DXEffectImpl_SetVectorArray,
3820 ID3DXEffectImpl_GetVectorArray,
3821 ID3DXEffectImpl_SetMatrix,
3822 ID3DXEffectImpl_GetMatrix,
3823 ID3DXEffectImpl_SetMatrixArray,
3824 ID3DXEffectImpl_GetMatrixArray,
3825 ID3DXEffectImpl_SetMatrixPointerArray,
3826 ID3DXEffectImpl_GetMatrixPointerArray,
3827 ID3DXEffectImpl_SetMatrixTranspose,
3828 ID3DXEffectImpl_GetMatrixTranspose,
3829 ID3DXEffectImpl_SetMatrixTransposeArray,
3830 ID3DXEffectImpl_GetMatrixTransposeArray,
3831 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3832 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3833 ID3DXEffectImpl_SetString,
3834 ID3DXEffectImpl_GetString,
3835 ID3DXEffectImpl_SetTexture,
3836 ID3DXEffectImpl_GetTexture,
3837 ID3DXEffectImpl_GetPixelShader,
3838 ID3DXEffectImpl_GetVertexShader,
3839 ID3DXEffectImpl_SetArrayRange,
3840 /*** ID3DXEffect methods ***/
3841 ID3DXEffectImpl_GetPool,
3842 ID3DXEffectImpl_SetTechnique,
3843 ID3DXEffectImpl_GetCurrentTechnique,
3844 ID3DXEffectImpl_ValidateTechnique,
3845 ID3DXEffectImpl_FindNextValidTechnique,
3846 ID3DXEffectImpl_IsParameterUsed,
3847 ID3DXEffectImpl_Begin,
3848 ID3DXEffectImpl_BeginPass,
3849 ID3DXEffectImpl_CommitChanges,
3850 ID3DXEffectImpl_EndPass,
3851 ID3DXEffectImpl_End,
3852 ID3DXEffectImpl_GetDevice,
3853 ID3DXEffectImpl_OnLostDevice,
3854 ID3DXEffectImpl_OnResetDevice,
3855 ID3DXEffectImpl_SetStateManager,
3856 ID3DXEffectImpl_GetStateManager,
3857 ID3DXEffectImpl_BeginParameterBlock,
3858 ID3DXEffectImpl_EndParameterBlock,
3859 ID3DXEffectImpl_ApplyParameterBlock,
3860 ID3DXEffectImpl_DeleteParameterBlock,
3861 ID3DXEffectImpl_CloneEffect,
3862 ID3DXEffectImpl_SetRawValue
3865 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3867 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3870 /*** IUnknown methods ***/
3871 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3873 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
3875 if (IsEqualGUID(riid, &IID_IUnknown) ||
3876 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3878 iface->lpVtbl->AddRef(iface);
3883 ERR("Interface %s not found\n", debugstr_guid(riid));
3885 return E_NOINTERFACE;
3888 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3890 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3892 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3894 return InterlockedIncrement(&This->ref);
3897 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3899 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3900 ULONG ref = InterlockedDecrement(&This->ref);
3902 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3906 free_effect_compiler(This);
3907 HeapFree(GetProcessHeap(), 0, This);
3913 /*** ID3DXBaseEffect methods ***/
3914 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3916 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3917 ID3DXBaseEffect *base = This->base_effect;
3919 TRACE("Forward iface %p, base %p\n", This, base);
3921 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3924 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3926 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3927 ID3DXBaseEffect *base = This->base_effect;
3929 TRACE("Forward iface %p, base %p\n", This, base);
3931 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3934 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3936 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3937 ID3DXBaseEffect *base = This->base_effect;
3939 TRACE("Forward iface %p, base %p\n", This, base);
3941 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3944 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3946 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3947 ID3DXBaseEffect *base = This->base_effect;
3949 TRACE("Forward iface %p, base %p\n", This, base);
3951 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3954 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3956 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3957 ID3DXBaseEffect *base = This->base_effect;
3959 TRACE("Forward iface %p, base %p\n", This, base);
3961 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3964 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3966 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3967 ID3DXBaseEffect *base = This->base_effect;
3969 TRACE("Forward iface %p, base %p\n", This, base);
3971 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3974 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3976 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3977 ID3DXBaseEffect *base = This->base_effect;
3979 TRACE("Forward iface %p, base %p\n", This, base);
3981 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3984 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3986 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3987 ID3DXBaseEffect *base = This->base_effect;
3989 TRACE("Forward iface %p, base %p\n", This, base);
3991 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3994 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3996 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3997 ID3DXBaseEffect *base = This->base_effect;
3999 TRACE("Forward iface %p, base %p\n", This, base);
4001 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
4004 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
4006 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4007 ID3DXBaseEffect *base = This->base_effect;
4009 TRACE("Forward iface %p, base %p\n", This, base);
4011 return ID3DXBaseEffectImpl_GetTechnique(base, index);
4014 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
4016 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4017 ID3DXBaseEffect *base = This->base_effect;
4019 TRACE("Forward iface %p, base %p\n", This, base);
4021 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
4024 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
4026 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4027 ID3DXBaseEffect *base = This->base_effect;
4029 TRACE("Forward iface %p, base %p\n", This, base);
4031 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
4034 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
4036 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4037 ID3DXBaseEffect *base = This->base_effect;
4039 TRACE("Forward iface %p, base %p\n", This, base);
4041 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
4044 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
4046 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4047 ID3DXBaseEffect *base = This->base_effect;
4049 TRACE("Forward iface %p, base %p\n", This, base);
4051 return ID3DXBaseEffectImpl_GetFunction(base, index);
4054 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
4056 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4057 ID3DXBaseEffect *base = This->base_effect;
4059 TRACE("Forward iface %p, base %p\n", This, base);
4061 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
4064 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
4066 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4067 ID3DXBaseEffect *base = This->base_effect;
4069 TRACE("Forward iface %p, base %p\n", This, base);
4071 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
4074 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
4076 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4077 ID3DXBaseEffect *base = This->base_effect;
4079 TRACE("Forward iface %p, base %p\n", This, base);
4081 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
4084 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
4086 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4087 ID3DXBaseEffect *base = This->base_effect;
4089 TRACE("Forward iface %p, base %p\n", This, base);
4091 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
4094 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
4096 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4097 ID3DXBaseEffect *base = This->base_effect;
4099 TRACE("Forward iface %p, base %p\n", This, base);
4101 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
4104 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
4106 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4107 ID3DXBaseEffect *base = This->base_effect;
4109 TRACE("Forward iface %p, base %p\n", This, base);
4111 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
4114 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
4116 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4117 ID3DXBaseEffect *base = This->base_effect;
4119 TRACE("Forward iface %p, base %p\n", This, base);
4121 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
4124 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
4126 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4127 ID3DXBaseEffect *base = This->base_effect;
4129 TRACE("Forward iface %p, base %p\n", This, base);
4131 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
4134 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
4136 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4137 ID3DXBaseEffect *base = This->base_effect;
4139 TRACE("Forward iface %p, base %p\n", This, base);
4141 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
4144 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
4146 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4147 ID3DXBaseEffect *base = This->base_effect;
4149 TRACE("Forward iface %p, base %p\n", This, base);
4151 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
4154 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
4156 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4157 ID3DXBaseEffect *base = This->base_effect;
4159 TRACE("Forward iface %p, base %p\n", This, base);
4161 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
4164 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
4166 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4167 ID3DXBaseEffect *base = This->base_effect;
4169 TRACE("Forward iface %p, base %p\n", This, base);
4171 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
4174 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
4176 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4177 ID3DXBaseEffect *base = This->base_effect;
4179 TRACE("Forward iface %p, base %p\n", This, base);
4181 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
4184 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
4186 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4187 ID3DXBaseEffect *base = This->base_effect;
4189 TRACE("Forward iface %p, base %p\n", This, base);
4191 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
4194 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
4196 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4197 ID3DXBaseEffect *base = This->base_effect;
4199 TRACE("Forward iface %p, base %p\n", This, base);
4201 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
4204 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
4206 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4207 ID3DXBaseEffect *base = This->base_effect;
4209 TRACE("Forward iface %p, base %p\n", This, base);
4211 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
4214 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
4216 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4217 ID3DXBaseEffect *base = This->base_effect;
4219 TRACE("Forward iface %p, base %p\n", This, base);
4221 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
4224 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
4226 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4227 ID3DXBaseEffect *base = This->base_effect;
4229 TRACE("Forward iface %p, base %p\n", This, base);
4231 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
4234 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
4236 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4237 ID3DXBaseEffect *base = This->base_effect;
4239 TRACE("Forward iface %p, base %p\n", This, base);
4241 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
4244 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
4246 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4247 ID3DXBaseEffect *base = This->base_effect;
4249 TRACE("Forward iface %p, base %p\n", This, base);
4251 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
4254 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
4256 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4257 ID3DXBaseEffect *base = This->base_effect;
4259 TRACE("Forward iface %p, base %p\n", This, base);
4261 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
4264 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4266 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4267 ID3DXBaseEffect *base = This->base_effect;
4269 TRACE("Forward iface %p, base %p\n", This, base);
4271 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
4274 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4276 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4277 ID3DXBaseEffect *base = This->base_effect;
4279 TRACE("Forward iface %p, base %p\n", This, base);
4281 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
4284 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4286 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4287 ID3DXBaseEffect *base = This->base_effect;
4289 TRACE("Forward iface %p, base %p\n", This, base);
4291 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
4294 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4296 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4297 ID3DXBaseEffect *base = This->base_effect;
4299 TRACE("Forward iface %p, base %p\n", This, base);
4301 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
4304 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4306 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4307 ID3DXBaseEffect *base = This->base_effect;
4309 TRACE("Forward iface %p, base %p\n", This, base);
4311 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
4314 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4316 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4317 ID3DXBaseEffect *base = This->base_effect;
4319 TRACE("Forward iface %p, base %p\n", This, base);
4321 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
4324 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4326 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4327 ID3DXBaseEffect *base = This->base_effect;
4329 TRACE("Forward iface %p, base %p\n", This, base);
4331 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
4334 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4336 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4337 ID3DXBaseEffect *base = This->base_effect;
4339 TRACE("Forward iface %p, base %p\n", This, base);
4341 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
4344 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4346 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4347 ID3DXBaseEffect *base = This->base_effect;
4349 TRACE("Forward iface %p, base %p\n", This, base);
4351 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
4354 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4356 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4357 ID3DXBaseEffect *base = This->base_effect;
4359 TRACE("Forward iface %p, base %p\n", This, base);
4361 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
4364 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4366 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4367 ID3DXBaseEffect *base = This->base_effect;
4369 TRACE("Forward iface %p, base %p\n", This, base);
4371 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
4374 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4376 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4377 ID3DXBaseEffect *base = This->base_effect;
4379 TRACE("Forward iface %p, base %p\n", This, base);
4381 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
4384 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
4386 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4387 ID3DXBaseEffect *base = This->base_effect;
4389 TRACE("Forward iface %p, base %p\n", This, base);
4391 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
4394 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
4396 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4397 ID3DXBaseEffect *base = This->base_effect;
4399 TRACE("Forward iface %p, base %p\n", This, base);
4401 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
4404 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
4406 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4407 ID3DXBaseEffect *base = This->base_effect;
4409 TRACE("Forward iface %p, base %p\n", This, base);
4411 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
4414 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
4416 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4417 ID3DXBaseEffect *base = This->base_effect;
4419 TRACE("Forward iface %p, base %p\n", This, base);
4421 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4424 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
4426 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4427 ID3DXBaseEffect *base = This->base_effect;
4429 TRACE("Forward iface %p, base %p\n", This, base);
4431 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
4434 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
4436 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4437 ID3DXBaseEffect *base = This->base_effect;
4439 TRACE("Forward iface %p, base %p\n", This, base);
4441 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
4444 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4446 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4447 ID3DXBaseEffect *base = This->base_effect;
4449 TRACE("Forward iface %p, base %p\n", This, base);
4451 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4454 /*** ID3DXEffectCompiler methods ***/
4455 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4457 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4459 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4464 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4466 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4468 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4473 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4474 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
4476 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4478 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4483 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4484 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
4486 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4488 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4489 This, function, target, flags, shader, error_msgs, constant_table);
4494 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4496 /*** IUnknown methods ***/
4497 ID3DXEffectCompilerImpl_QueryInterface,
4498 ID3DXEffectCompilerImpl_AddRef,
4499 ID3DXEffectCompilerImpl_Release,
4500 /*** ID3DXBaseEffect methods ***/
4501 ID3DXEffectCompilerImpl_GetDesc,
4502 ID3DXEffectCompilerImpl_GetParameterDesc,
4503 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4504 ID3DXEffectCompilerImpl_GetPassDesc,
4505 ID3DXEffectCompilerImpl_GetFunctionDesc,
4506 ID3DXEffectCompilerImpl_GetParameter,
4507 ID3DXEffectCompilerImpl_GetParameterByName,
4508 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4509 ID3DXEffectCompilerImpl_GetParameterElement,
4510 ID3DXEffectCompilerImpl_GetTechnique,
4511 ID3DXEffectCompilerImpl_GetTechniqueByName,
4512 ID3DXEffectCompilerImpl_GetPass,
4513 ID3DXEffectCompilerImpl_GetPassByName,
4514 ID3DXEffectCompilerImpl_GetFunction,
4515 ID3DXEffectCompilerImpl_GetFunctionByName,
4516 ID3DXEffectCompilerImpl_GetAnnotation,
4517 ID3DXEffectCompilerImpl_GetAnnotationByName,
4518 ID3DXEffectCompilerImpl_SetValue,
4519 ID3DXEffectCompilerImpl_GetValue,
4520 ID3DXEffectCompilerImpl_SetBool,
4521 ID3DXEffectCompilerImpl_GetBool,
4522 ID3DXEffectCompilerImpl_SetBoolArray,
4523 ID3DXEffectCompilerImpl_GetBoolArray,
4524 ID3DXEffectCompilerImpl_SetInt,
4525 ID3DXEffectCompilerImpl_GetInt,
4526 ID3DXEffectCompilerImpl_SetIntArray,
4527 ID3DXEffectCompilerImpl_GetIntArray,
4528 ID3DXEffectCompilerImpl_SetFloat,
4529 ID3DXEffectCompilerImpl_GetFloat,
4530 ID3DXEffectCompilerImpl_SetFloatArray,
4531 ID3DXEffectCompilerImpl_GetFloatArray,
4532 ID3DXEffectCompilerImpl_SetVector,
4533 ID3DXEffectCompilerImpl_GetVector,
4534 ID3DXEffectCompilerImpl_SetVectorArray,
4535 ID3DXEffectCompilerImpl_GetVectorArray,
4536 ID3DXEffectCompilerImpl_SetMatrix,
4537 ID3DXEffectCompilerImpl_GetMatrix,
4538 ID3DXEffectCompilerImpl_SetMatrixArray,
4539 ID3DXEffectCompilerImpl_GetMatrixArray,
4540 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4541 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4542 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4543 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4544 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4545 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4546 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4547 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4548 ID3DXEffectCompilerImpl_SetString,
4549 ID3DXEffectCompilerImpl_GetString,
4550 ID3DXEffectCompilerImpl_SetTexture,
4551 ID3DXEffectCompilerImpl_GetTexture,
4552 ID3DXEffectCompilerImpl_GetPixelShader,
4553 ID3DXEffectCompilerImpl_GetVertexShader,
4554 ID3DXEffectCompilerImpl_SetArrayRange,
4555 /*** ID3DXEffectCompiler methods ***/
4556 ID3DXEffectCompilerImpl_SetLiteral,
4557 ID3DXEffectCompilerImpl_GetLiteral,
4558 ID3DXEffectCompilerImpl_CompileEffect,
4559 ID3DXEffectCompilerImpl_CompileShader,
4562 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4566 struct d3dx_state *states;
4568 read_dword(ptr, &sampler->state_count);
4569 TRACE("Count: %u\n", sampler->state_count);
4571 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4574 ERR("Out of memory\n");
4575 return E_OUTOFMEMORY;
4578 for (i = 0; i < sampler->state_count; ++i)
4580 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4583 WARN("Failed to parse state\n");
4588 sampler->states = states;
4594 for (i = 0; i < sampler->state_count; ++i)
4596 free_state(&states[i]);
4599 HeapFree(GetProcessHeap(), 0, states);
4604 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4611 if (param->element_count)
4613 param->data = value;
4615 for (i = 0; i < param->element_count; ++i)
4617 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4619 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4622 WARN("Failed to parse value\n");
4626 old_size += member->bytes;
4632 switch(param->class)
4636 case D3DXPC_MATRIX_ROWS:
4637 case D3DXPC_MATRIX_COLUMNS:
4638 param->data = value;
4642 param->data = value;
4644 for (i = 0; i < param->member_count; ++i)
4646 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4648 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4651 WARN("Failed to parse value\n");
4655 old_size += member->bytes;
4660 switch (param->type)
4663 case D3DXPT_TEXTURE:
4664 case D3DXPT_TEXTURE1D:
4665 case D3DXPT_TEXTURE2D:
4666 case D3DXPT_TEXTURE3D:
4667 case D3DXPT_TEXTURECUBE:
4668 case D3DXPT_PIXELSHADER:
4669 case D3DXPT_VERTEXSHADER:
4670 read_dword(ptr, &id);
4671 TRACE("Id: %u\n", id);
4672 objects[id] = get_parameter_handle(param);
4673 param->data = value;
4676 case D3DXPT_SAMPLER:
4677 case D3DXPT_SAMPLER1D:
4678 case D3DXPT_SAMPLER2D:
4679 case D3DXPT_SAMPLER3D:
4680 case D3DXPT_SAMPLERCUBE:
4682 struct d3dx_sampler *sampler;
4684 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4687 ERR("Out of memory\n");
4688 return E_OUTOFMEMORY;
4691 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4694 HeapFree(GetProcessHeap(), 0, sampler);
4695 WARN("Failed to parse sampler\n");
4699 param->data = sampler;
4704 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4710 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4717 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4719 UINT size = param->bytes;
4723 TRACE("param size: %u\n", size);
4727 value = HeapAlloc(GetProcessHeap(), 0, size);
4730 ERR("Failed to allocate data memory.\n");
4731 return E_OUTOFMEMORY;
4734 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4735 memcpy(value, ptr, size);
4738 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4741 WARN("Failed to parse value\n");
4742 HeapFree(GetProcessHeap(), 0, value);
4749 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4753 read_dword(&ptr, &size);
4754 TRACE("Name size: %#x\n", size);
4761 *name = HeapAlloc(GetProcessHeap(), 0, size);
4764 ERR("Failed to allocate name memory.\n");
4765 return E_OUTOFMEMORY;
4768 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4769 memcpy(*name, ptr, size);
4774 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4778 read_dword(ptr, &size);
4779 TRACE("Data size: %#x\n", size);
4781 *str = HeapAlloc(GetProcessHeap(), 0, size);
4784 ERR("Failed to allocate name memory.\n");
4785 return E_OUTOFMEMORY;
4788 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4789 memcpy(*str, *ptr, size);
4791 *ptr += ((size + 3) & ~3);
4796 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4801 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4803 read_dword(ptr, &size);
4804 TRACE("Data size: %#x\n", size);
4808 TRACE("Size is 0\n");
4809 *(void **)param->data = NULL;
4813 switch (param->type)
4816 /* re-read with size (sizeof(DWORD) = 4) */
4817 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4820 WARN("Failed to parse string data\n");
4825 case D3DXPT_VERTEXSHADER:
4826 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4829 WARN("Failed to create vertex shader\n");
4834 case D3DXPT_PIXELSHADER:
4835 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4838 WARN("Failed to create pixel shader\n");
4844 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4849 *ptr += ((size + 3) & ~3);
4854 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4855 struct d3dx_parameter *parent, UINT flags)
4859 D3DXHANDLE *member_handles = NULL;
4862 param->flags = flags;
4866 read_dword(ptr, ¶m->type);
4867 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4869 read_dword(ptr, ¶m->class);
4870 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4872 read_dword(ptr, &offset);
4873 TRACE("Type name offset: %#x\n", offset);
4874 hr = d3dx9_parse_name(¶m->name, data + offset);
4877 WARN("Failed to parse name\n");
4881 read_dword(ptr, &offset);
4882 TRACE("Type semantic offset: %#x\n", offset);
4883 hr = d3dx9_parse_name(¶m->semantic, data + offset);
4886 WARN("Failed to parse semantic\n");
4890 read_dword(ptr, ¶m->element_count);
4891 TRACE("Elements: %u\n", param->element_count);
4893 switch (param->class)
4896 read_dword(ptr, ¶m->columns);
4897 TRACE("Columns: %u\n", param->columns);
4899 read_dword(ptr, ¶m->rows);
4900 TRACE("Rows: %u\n", param->rows);
4902 /* sizeof(DWORD) * rows * columns */
4903 param->bytes = 4 * param->rows * param->columns;
4907 case D3DXPC_MATRIX_ROWS:
4908 case D3DXPC_MATRIX_COLUMNS:
4909 read_dword(ptr, ¶m->rows);
4910 TRACE("Rows: %u\n", param->rows);
4912 read_dword(ptr, ¶m->columns);
4913 TRACE("Columns: %u\n", param->columns);
4915 /* sizeof(DWORD) * rows * columns */
4916 param->bytes = 4 * param->rows * param->columns;
4920 read_dword(ptr, ¶m->member_count);
4921 TRACE("Members: %u\n", param->member_count);
4925 switch (param->type)
4928 param->bytes = sizeof(LPCSTR);
4931 case D3DXPT_PIXELSHADER:
4932 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4935 case D3DXPT_VERTEXSHADER:
4936 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4939 case D3DXPT_TEXTURE:
4940 case D3DXPT_TEXTURE1D:
4941 case D3DXPT_TEXTURE2D:
4942 case D3DXPT_TEXTURE3D:
4943 case D3DXPT_TEXTURECUBE:
4944 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4947 case D3DXPT_SAMPLER:
4948 case D3DXPT_SAMPLER1D:
4949 case D3DXPT_SAMPLER2D:
4950 case D3DXPT_SAMPLER3D:
4951 case D3DXPT_SAMPLERCUBE:
4956 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4962 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4969 param->type = parent->type;
4970 param->class = parent->class;
4971 param->name = parent->name;
4972 param->semantic = parent->semantic;
4973 param->element_count = 0;
4974 param->annotation_count = 0;
4975 param->member_count = parent->member_count;
4976 param->bytes = parent->bytes;
4977 param->rows = parent->rows;
4978 param->columns = parent->columns;
4981 if (param->element_count)
4983 unsigned int param_bytes = 0;
4984 const char *save_ptr = *ptr;
4986 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4987 if (!member_handles)
4989 ERR("Out of memory\n");
4994 for (i = 0; i < param->element_count; ++i)
4996 struct d3dx_parameter *member;
4999 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
5002 ERR("Out of memory\n");
5007 member_handles[i] = get_parameter_handle(member);
5009 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
5012 WARN("Failed to parse member\n");
5016 param_bytes += member->bytes;
5019 param->bytes = param_bytes;
5021 else if (param->member_count)
5023 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
5024 if (!member_handles)
5026 ERR("Out of memory\n");
5031 for (i = 0; i < param->member_count; ++i)
5033 struct d3dx_parameter *member;
5035 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
5038 ERR("Out of memory\n");
5043 member_handles[i] = get_parameter_handle(member);
5045 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
5048 WARN("Failed to parse member\n");
5052 param->bytes += member->bytes;
5056 param->member_handles = member_handles;
5066 if (param->element_count) count = param->element_count;
5067 else count = param->member_count;
5069 for (i = 0; i < count; ++i)
5071 free_parameter(member_handles[i], param->element_count != 0, TRUE);
5073 HeapFree(GetProcessHeap(), 0, member_handles);
5078 HeapFree(GetProcessHeap(), 0, param->name);
5079 HeapFree(GetProcessHeap(), 0, param->semantic);
5082 param->semantic = NULL;
5087 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
5093 anno->flags = D3DX_PARAMETER_ANNOTATION;
5095 read_dword(ptr, &offset);
5096 TRACE("Typedef offset: %#x\n", offset);
5097 ptr2 = data + offset;
5098 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
5101 WARN("Failed to parse type definition\n");
5105 read_dword(ptr, &offset);
5106 TRACE("Value offset: %#x\n", offset);
5107 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
5110 WARN("Failed to parse value\n");
5117 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
5122 struct d3dx_parameter *parameter;
5124 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5127 ERR("Out of memory\n");
5128 return E_OUTOFMEMORY;
5131 state->type = ST_CONSTANT;
5133 read_dword(ptr, &state->operation);
5134 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
5136 read_dword(ptr, &state->index);
5137 TRACE("Index: %#x\n", state->index);
5139 read_dword(ptr, &offset);
5140 TRACE("Typedef offset: %#x\n", offset);
5141 ptr2 = data + offset;
5142 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
5145 WARN("Failed to parse type definition\n");
5149 read_dword(ptr, &offset);
5150 TRACE("Value offset: %#x\n", offset);
5151 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
5154 WARN("Failed to parse value\n");
5158 state->parameter = get_parameter_handle(parameter);
5164 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
5169 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
5174 D3DXHANDLE *annotation_handles = NULL;
5177 read_dword(ptr, &offset);
5178 TRACE("Typedef offset: %#x\n", offset);
5179 ptr2 = data + offset;
5181 read_dword(ptr, &offset);
5182 TRACE("Value offset: %#x\n", offset);
5184 read_dword(ptr, ¶m->flags);
5185 TRACE("Flags: %#x\n", param->flags);
5187 read_dword(ptr, ¶m->annotation_count);
5188 TRACE("Annotation count: %u\n", param->annotation_count);
5190 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
5193 WARN("Failed to parse type definition\n");
5197 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
5200 WARN("Failed to parse value\n");
5204 if (param->annotation_count)
5206 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
5207 if (!annotation_handles)
5209 ERR("Out of memory\n");
5214 for (i = 0; i < param->annotation_count; ++i)
5216 struct d3dx_parameter *annotation;
5218 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5221 ERR("Out of memory\n");
5226 annotation_handles[i] = get_parameter_handle(annotation);
5228 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5231 WARN("Failed to parse annotation\n");
5237 param->annotation_handles = annotation_handles;
5243 if (annotation_handles)
5245 for (i = 0; i < param->annotation_count; ++i)
5247 free_parameter(annotation_handles[i], FALSE, FALSE);
5249 HeapFree(GetProcessHeap(), 0, annotation_handles);
5255 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
5260 D3DXHANDLE *annotation_handles = NULL;
5261 struct d3dx_state *states = NULL;
5264 read_dword(ptr, &offset);
5265 TRACE("Pass name offset: %#x\n", offset);
5266 hr = d3dx9_parse_name(&name, data + offset);
5269 WARN("Failed to parse name\n");
5273 read_dword(ptr, &pass->annotation_count);
5274 TRACE("Annotation count: %u\n", pass->annotation_count);
5276 read_dword(ptr, &pass->state_count);
5277 TRACE("State count: %u\n", pass->state_count);
5279 if (pass->annotation_count)
5281 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
5282 if (!annotation_handles)
5284 ERR("Out of memory\n");
5289 for (i = 0; i < pass->annotation_count; ++i)
5291 struct d3dx_parameter *annotation;
5293 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5296 ERR("Out of memory\n");
5301 annotation_handles[i] = get_parameter_handle(annotation);
5303 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5306 WARN("Failed to parse annotations\n");
5312 if (pass->state_count)
5314 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
5317 ERR("Out of memory\n");
5322 for (i = 0; i < pass->state_count; ++i)
5324 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
5327 WARN("Failed to parse annotations\n");
5334 pass->annotation_handles = annotation_handles;
5335 pass->states = states;
5341 if (annotation_handles)
5343 for (i = 0; i < pass->annotation_count; ++i)
5345 free_parameter(annotation_handles[i], FALSE, FALSE);
5347 HeapFree(GetProcessHeap(), 0, annotation_handles);
5352 for (i = 0; i < pass->state_count; ++i)
5354 free_state(&states[i]);
5356 HeapFree(GetProcessHeap(), 0, states);
5359 HeapFree(GetProcessHeap(), 0, name);
5364 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
5369 D3DXHANDLE *annotation_handles = NULL;
5370 D3DXHANDLE *pass_handles = NULL;
5373 read_dword(ptr, &offset);
5374 TRACE("Technique name offset: %#x\n", offset);
5375 hr = d3dx9_parse_name(&name, data + offset);
5378 WARN("Failed to parse name\n");
5382 read_dword(ptr, &technique->annotation_count);
5383 TRACE("Annotation count: %u\n", technique->annotation_count);
5385 read_dword(ptr, &technique->pass_count);
5386 TRACE("Pass count: %u\n", technique->pass_count);
5388 if (technique->annotation_count)
5390 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
5391 if (!annotation_handles)
5393 ERR("Out of memory\n");
5398 for (i = 0; i < technique->annotation_count; ++i)
5400 struct d3dx_parameter *annotation;
5402 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5405 ERR("Out of memory\n");
5410 annotation_handles[i] = get_parameter_handle(annotation);
5412 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5415 WARN("Failed to parse annotations\n");
5421 if (technique->pass_count)
5423 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5426 ERR("Out of memory\n");
5431 for (i = 0; i < technique->pass_count; ++i)
5433 struct d3dx_pass *pass;
5435 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5438 ERR("Out of memory\n");
5443 pass_handles[i] = get_pass_handle(pass);
5445 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5448 WARN("Failed to parse passes\n");
5454 technique->name = name;
5455 technique->pass_handles = pass_handles;
5456 technique->annotation_handles = annotation_handles;
5464 for (i = 0; i < technique->pass_count; ++i)
5466 free_pass(pass_handles[i]);
5468 HeapFree(GetProcessHeap(), 0, pass_handles);
5471 if (annotation_handles)
5473 for (i = 0; i < technique->annotation_count; ++i)
5475 free_parameter(annotation_handles[i], FALSE, FALSE);
5477 HeapFree(GetProcessHeap(), 0, annotation_handles);
5480 HeapFree(GetProcessHeap(), 0, name);
5485 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5487 DWORD technique_index;
5488 DWORD index, state_index, usage, element_index;
5489 struct d3dx_state *state;
5490 struct d3dx_parameter *param;
5491 HRESULT hr = E_FAIL;
5493 read_dword(ptr, &technique_index);
5494 TRACE("techn: %u\n", technique_index);
5496 read_dword(ptr, &index);
5497 TRACE("index: %u\n", index);
5499 read_dword(ptr, &element_index);
5500 TRACE("element_index: %u\n", element_index);
5502 read_dword(ptr, &state_index);
5503 TRACE("state_index: %u\n", state_index);
5505 read_dword(ptr, &usage);
5506 TRACE("usage: %u\n", usage);
5508 if (technique_index == 0xffffffff)
5510 struct d3dx_parameter *parameter;
5511 struct d3dx_sampler *sampler;
5513 if (index >= base->parameter_count)
5515 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5519 parameter = get_parameter_struct(base->parameter_handles[index]);
5520 if (element_index != 0xffffffff)
5522 if (element_index >= parameter->element_count && parameter->element_count != 0)
5524 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5528 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5531 sampler = parameter->data;
5532 if (state_index >= sampler->state_count)
5534 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5538 state = &sampler->states[state_index];
5542 struct d3dx_technique *technique;
5543 struct d3dx_pass *pass;
5545 if (technique_index >= base->technique_count)
5547 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5551 technique = get_technique_struct(base->technique_handles[technique_index]);
5552 if (index >= technique->pass_count)
5554 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5558 pass = get_pass_struct(technique->pass_handles[index]);
5559 if (state_index >= pass->state_count)
5561 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5565 state = &pass->states[state_index];
5568 param = get_parameter_struct(state->parameter);
5573 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5574 switch (param->type)
5576 case D3DXPT_VERTEXSHADER:
5577 case D3DXPT_PIXELSHADER:
5578 state->type = ST_CONSTANT;
5579 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5586 state->type = ST_FXLC;
5587 hr = d3dx9_copy_data(param->data, ptr);
5591 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5597 state->type = ST_PARAMETER;
5598 hr = d3dx9_copy_data(param->data, ptr);
5601 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5606 FIXME("Unknown usage %x\n", usage);
5613 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5615 const char *ptr = data + start;
5616 D3DXHANDLE *parameter_handles = NULL;
5617 D3DXHANDLE *technique_handles = NULL;
5618 D3DXHANDLE *objects = NULL;
5619 UINT stringcount, objectcount, resourcecount;
5623 read_dword(&ptr, &base->parameter_count);
5624 TRACE("Parameter count: %u\n", base->parameter_count);
5626 read_dword(&ptr, &base->technique_count);
5627 TRACE("Technique count: %u\n", base->technique_count);
5629 skip_dword_unknown(&ptr, 1);
5631 read_dword(&ptr, &objectcount);
5632 TRACE("Object count: %u\n", objectcount);
5634 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5637 ERR("Out of memory\n");
5642 if (base->parameter_count)
5644 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5645 if (!parameter_handles)
5647 ERR("Out of memory\n");
5652 for (i = 0; i < base->parameter_count; ++i)
5654 struct d3dx_parameter *parameter;
5656 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5659 ERR("Out of memory\n");
5664 parameter_handles[i] = get_parameter_handle(parameter);
5666 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5669 WARN("Failed to parse parameter\n");
5675 if (base->technique_count)
5677 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5678 if (!technique_handles)
5680 ERR("Out of memory\n");
5685 for (i = 0; i < base->technique_count; ++i)
5687 struct d3dx_technique *technique;
5689 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5692 ERR("Out of memory\n");
5697 technique_handles[i] = get_technique_handle(technique);
5699 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5702 WARN("Failed to parse technique\n");
5708 /* needed for further parsing */
5709 base->technique_handles = technique_handles;
5710 base->parameter_handles = parameter_handles;
5712 read_dword(&ptr, &stringcount);
5713 TRACE("String count: %u\n", stringcount);
5715 read_dword(&ptr, &resourcecount);
5716 TRACE("Resource count: %u\n", resourcecount);
5718 for (i = 0; i < stringcount; ++i)
5721 struct d3dx_parameter *param;
5723 read_dword(&ptr, &id);
5724 TRACE("Id: %u\n", id);
5726 param = get_parameter_struct(objects[id]);
5728 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5731 WARN("Failed to parse data\n");
5736 for (i = 0; i < resourcecount; ++i)
5738 TRACE("parse resource %u\n", i);
5740 hr = d3dx9_parse_resource(base, data, &ptr);
5743 WARN("Failed to parse data\n");
5748 HeapFree(GetProcessHeap(), 0, objects);
5754 if (technique_handles)
5756 for (i = 0; i < base->technique_count; ++i)
5758 free_technique(technique_handles[i]);
5760 HeapFree(GetProcessHeap(), 0, technique_handles);
5763 if (parameter_handles)
5765 for (i = 0; i < base->parameter_count; ++i)
5767 free_parameter(parameter_handles[i], FALSE, FALSE);
5769 HeapFree(GetProcessHeap(), 0, parameter_handles);
5772 base->technique_handles = NULL;
5773 base->parameter_handles = NULL;
5775 HeapFree(GetProcessHeap(), 0, objects);
5780 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5781 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5784 const char *ptr = data;
5787 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5789 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5791 base->effect = effect;
5793 read_dword(&ptr, &tag);
5794 TRACE("Tag: %x\n", tag);
5796 if (tag != d3dx9_effect_version(9, 1))
5798 /* todo: compile hlsl ascii code */
5799 FIXME("HLSL ascii effects not supported, yet\n");
5801 /* Show the start of the shader for debugging info. */
5802 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5806 read_dword(&ptr, &offset);
5807 TRACE("Offset: %x\n", offset);
5809 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5812 FIXME("Failed to parse effect.\n");
5820 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5821 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5824 struct ID3DXBaseEffectImpl *object = NULL;
5826 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5828 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5831 if (pool) pool->lpVtbl->AddRef(pool);
5832 effect->pool = pool;
5834 IDirect3DDevice9_AddRef(device);
5835 effect->device = device;
5837 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5840 ERR("Out of memory\n");
5845 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5848 FIXME("Failed to parse effect.\n");
5852 effect->base_effect = &object->ID3DXBaseEffect_iface;
5854 /* initialize defaults - check because of unsupported ascii effects */
5855 if (object->technique_handles)
5857 effect->active_technique = object->technique_handles[0];
5858 effect->active_pass = NULL;
5865 HeapFree(GetProcessHeap(), 0, object);
5866 free_effect(effect);
5871 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5874 CONST D3DXMACRO* defines,
5875 LPD3DXINCLUDE include,
5876 LPCSTR skip_constants,
5878 LPD3DXEFFECTPOOL pool,
5879 LPD3DXEFFECT* effect,
5880 LPD3DXBUFFER* compilation_errors)
5882 struct ID3DXEffectImpl *object;
5885 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5886 skip_constants, flags, pool, effect, compilation_errors);
5888 if (!device || !srcdata)
5889 return D3DERR_INVALIDCALL;
5894 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5898 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5901 ERR("Out of memory\n");
5902 return E_OUTOFMEMORY;
5905 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5908 WARN("Failed to initialize shader reflection\n");
5909 HeapFree(GetProcessHeap(), 0, object);
5913 *effect = &object->ID3DXEffect_iface;
5915 TRACE("Created ID3DXEffect %p\n", object);
5920 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5923 CONST D3DXMACRO* defines,
5924 LPD3DXINCLUDE include,
5926 LPD3DXEFFECTPOOL pool,
5927 LPD3DXEFFECT* effect,
5928 LPD3DXBUFFER* compilation_errors)
5930 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5931 include, flags, pool, effect, compilation_errors);
5933 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5936 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5939 struct ID3DXBaseEffectImpl *object = NULL;
5941 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5943 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5946 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5949 ERR("Out of memory\n");
5954 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5957 FIXME("Failed to parse effect.\n");
5961 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5967 HeapFree(GetProcessHeap(), 0, object);
5968 free_effect_compiler(compiler);
5973 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5975 CONST D3DXMACRO *defines,
5976 LPD3DXINCLUDE include,
5978 LPD3DXEFFECTCOMPILER *compiler,
5979 LPD3DXBUFFER *parse_errors)
5981 struct ID3DXEffectCompilerImpl *object;
5984 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5985 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5987 if (!srcdata || !compiler)
5989 WARN("Invalid arguments supplied\n");
5990 return D3DERR_INVALIDCALL;
5993 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5996 ERR("Out of memory\n");
5997 return E_OUTOFMEMORY;
6000 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
6003 WARN("Failed to initialize effect compiler\n");
6004 HeapFree(GetProcessHeap(), 0, object);
6008 *compiler = &object->ID3DXEffectCompiler_iface;
6010 TRACE("Created ID3DXEffectCompiler %p\n", object);
6015 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
6017 struct ID3DXEffectPoolImpl
6019 ID3DXEffectPool ID3DXEffectPool_iface;
6023 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
6025 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
6028 /*** IUnknown methods ***/
6029 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
6031 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
6033 if (IsEqualGUID(riid, &IID_IUnknown) ||
6034 IsEqualGUID(riid, &IID_ID3DXEffectPool))
6036 iface->lpVtbl->AddRef(iface);
6041 WARN("Interface %s not found\n", debugstr_guid(riid));
6043 return E_NOINTERFACE;
6046 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
6048 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
6050 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
6052 return InterlockedIncrement(&This->ref);
6055 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
6057 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
6058 ULONG ref = InterlockedDecrement(&This->ref);
6060 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
6063 HeapFree(GetProcessHeap(), 0, This);
6068 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
6070 /*** IUnknown methods ***/
6071 ID3DXEffectPoolImpl_QueryInterface,
6072 ID3DXEffectPoolImpl_AddRef,
6073 ID3DXEffectPoolImpl_Release
6076 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
6078 struct ID3DXEffectPoolImpl *object;
6080 TRACE("(%p)\n", pool);
6083 return D3DERR_INVALIDCALL;
6085 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
6088 ERR("Out of memory\n");
6089 return E_OUTOFMEMORY;
6092 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
6095 *pool = &object->ID3DXEffectPool_iface;
6100 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
6101 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6102 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6108 TRACE("(%s): relay\n", debugstr_w(srcfile));
6110 if (!device || !srcfile)
6111 return D3DERR_INVALIDCALL;
6113 ret = map_view_of_file(srcfile, &buffer, &size);
6116 return D3DXERR_INVALIDDATA;
6118 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6119 UnmapViewOfFile(buffer);
6124 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
6125 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6126 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6132 TRACE("(void): relay\n");
6135 return D3DERR_INVALIDCALL;
6137 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6138 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6139 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6141 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6142 HeapFree(GetProcessHeap(), 0, srcfileW);
6147 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
6148 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6149 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6151 TRACE("(void): relay\n");
6152 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6155 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
6156 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6157 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6159 TRACE("(void): relay\n");
6160 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6163 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
6164 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6165 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6169 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6172 return D3DERR_INVALIDCALL;
6174 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6182 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6185 return D3DXERR_INVALIDDATA;
6187 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6190 return D3DXERR_INVALIDDATA;
6193 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
6194 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6195 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6199 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6202 return D3DERR_INVALIDCALL;
6204 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6212 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6215 return D3DXERR_INVALIDDATA;
6217 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6220 return D3DXERR_INVALIDDATA;
6223 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
6224 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6225 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6227 TRACE("(void): relay\n");
6228 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6231 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
6232 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6233 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6235 TRACE("(void): relay\n");
6236 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6239 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6240 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6246 TRACE("(%s): relay\n", debugstr_w(srcfile));
6249 return D3DERR_INVALIDCALL;
6251 ret = map_view_of_file(srcfile, &buffer, &size);
6254 return D3DXERR_INVALIDDATA;
6256 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6257 UnmapViewOfFile(buffer);
6262 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6263 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6269 TRACE("(void): relay\n");
6272 return D3DERR_INVALIDCALL;
6274 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6275 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6276 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6278 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
6279 HeapFree(GetProcessHeap(), 0, srcfileW);
6284 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
6285 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6289 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6291 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6299 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6302 return D3DXERR_INVALIDDATA;
6304 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6307 return D3DXERR_INVALIDDATA;
6310 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
6311 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6315 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6317 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6325 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6328 return D3DXERR_INVALIDDATA;
6330 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6333 return D3DXERR_INVALIDDATA;