d3dx9: Implement ID3DXBaseEffect::SetMatrixTranspose().
[wine.git] / dlls / d3dx9_36 / effect.c
blob927e0675798f42c1999f83f35e162582ce1b44e0
1 /*
2 * Copyright 2010 Christian Costa
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
20 #include "wine/port.h"
21 #define NONAMELESSUNION
22 #include "wine/debug.h"
23 #include "wine/unicode.h"
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "d3dx9_36_private.h"
29 /* Constants for special INT/FLOAT conversation */
30 #define INT_FLOAT_MULTI 255.0f
31 #define INT_FLOAT_MULTI_INVERSE (1/INT_FLOAT_MULTI)
33 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
35 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
36 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
37 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
39 enum STATE_CLASS
41 SC_LIGHTENABLE,
42 SC_FVF,
43 SC_LIGHT,
44 SC_MATERIAL,
45 SC_NPATCHMODE,
46 SC_PIXELSHADER,
47 SC_RENDERSTATE,
48 SC_SETSAMPLER,
49 SC_SAMPLERSTATE,
50 SC_TEXTURE,
51 SC_TEXTURESTAGE,
52 SC_TRANSFORM,
53 SC_VERTEXSHADER,
54 SC_SHADERCONST,
55 SC_UNKNOWN,
58 enum MATERIAL_TYPE
60 MT_DIFFUSE,
61 MT_AMBIENT,
62 MT_SPECULAR,
63 MT_EMISSIVE,
64 MT_POWER,
67 enum LIGHT_TYPE
69 LT_TYPE,
70 LT_DIFFUSE,
71 LT_SPECULAR,
72 LT_AMBIENT,
73 LT_POSITION,
74 LT_DIRECTION,
75 LT_RANGE,
76 LT_FALLOFF,
77 LT_ATTENUATION0,
78 LT_ATTENUATION1,
79 LT_ATTENUATION2,
80 LT_THETA,
81 LT_PHI,
84 enum SHADER_CONSTANT_TYPE
86 SCT_VSFLOAT,
87 SCT_VSBOOL,
88 SCT_VSINT,
89 SCT_PSFLOAT,
90 SCT_PSBOOL,
91 SCT_PSINT,
94 enum STATE_TYPE
96 ST_CONSTANT,
97 ST_PARAMETER,
98 ST_FXLC,
101 struct d3dx_parameter
103 char *name;
104 char *semantic;
105 void *data;
106 D3DXPARAMETER_CLASS class;
107 D3DXPARAMETER_TYPE type;
108 UINT rows;
109 UINT columns;
110 UINT element_count;
111 UINT annotation_count;
112 UINT member_count;
113 DWORD flags;
114 UINT bytes;
116 D3DXHANDLE *annotation_handles;
117 D3DXHANDLE *member_handles;
120 struct d3dx_state
122 UINT operation;
123 UINT index;
124 enum STATE_TYPE type;
125 D3DXHANDLE parameter;
128 struct d3dx_sampler
130 UINT state_count;
131 struct d3dx_state *states;
134 struct d3dx_pass
136 char *name;
137 UINT state_count;
138 UINT annotation_count;
140 struct d3dx_state *states;
141 D3DXHANDLE *annotation_handles;
144 struct d3dx_technique
146 char *name;
147 UINT pass_count;
148 UINT annotation_count;
150 D3DXHANDLE *annotation_handles;
151 D3DXHANDLE *pass_handles;
154 struct ID3DXBaseEffectImpl
156 ID3DXBaseEffect ID3DXBaseEffect_iface;
157 LONG ref;
159 struct ID3DXEffectImpl *effect;
161 UINT parameter_count;
162 UINT technique_count;
164 D3DXHANDLE *parameter_handles;
165 D3DXHANDLE *technique_handles;
168 struct ID3DXEffectImpl
170 ID3DXEffect ID3DXEffect_iface;
171 LONG ref;
173 LPD3DXEFFECTSTATEMANAGER manager;
174 LPDIRECT3DDEVICE9 device;
175 LPD3DXEFFECTPOOL pool;
176 D3DXHANDLE active_technique;
177 D3DXHANDLE active_pass;
179 ID3DXBaseEffect *base_effect;
182 struct ID3DXEffectCompilerImpl
184 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
185 LONG ref;
187 ID3DXBaseEffect *base_effect;
190 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
191 struct d3dx_parameter *parameter, LPCSTR name);
192 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
193 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
194 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
196 static const struct
198 enum STATE_CLASS class;
199 UINT op;
200 LPCSTR name;
202 state_table[] =
204 /* Render sates */
205 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
206 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
207 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
208 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
209 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
210 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
211 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
212 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
213 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
214 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
215 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
216 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
217 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
218 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
219 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
220 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
221 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
222 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
223 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
224 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
225 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
226 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
227 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
228 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
229 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
230 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
231 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
232 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
233 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
234 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
235 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
236 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
237 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
238 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
239 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
240 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
241 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
242 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
243 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
244 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
245 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
246 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
247 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
248 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
249 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
250 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
251 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
252 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
253 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
254 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
255 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
256 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
257 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
258 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
259 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
260 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
261 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
262 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
263 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
264 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
265 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
266 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
267 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
268 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
269 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
270 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
271 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
272 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
273 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
274 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
275 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
276 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
277 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
278 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
279 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
280 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
281 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
282 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
283 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
284 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
285 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
286 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
287 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
288 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
289 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
290 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
291 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
292 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
293 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
294 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
295 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
296 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
297 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
298 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
299 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
300 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
301 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
302 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
303 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
304 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
305 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
306 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
307 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
308 /* Texture stages */
309 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
310 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
311 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
312 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
313 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
314 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
315 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
316 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
317 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
318 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
319 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
320 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
321 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
322 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
323 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
324 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
325 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
326 /* */
327 {SC_UNKNOWN, 0, "UNKNOWN"},
328 /* NPatchMode */
329 {SC_NPATCHMODE, 0, "NPatchMode"},
330 /* */
331 {SC_UNKNOWN, 0, "UNKNOWN"},
332 /* Transform */
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"},
337 /* Material */
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"},
343 /* Light */
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 */
357 /* Ligthenable */
358 {SC_LIGHTENABLE, 0, "LightEnable"},
359 /* Vertexshader */
360 {SC_VERTEXSHADER, 0, "Vertexshader"},
361 /* Pixelshader */
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"},
380 /* Texture */
381 {SC_TEXTURE, 0, "Texture"},
382 /* Sampler states */
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"},
396 /* Set sampler */
397 {SC_SETSAMPLER, 0, "Sampler"},
400 static inline void read_dword(const char **ptr, DWORD *d)
402 memcpy(d, *ptr, sizeof(*d));
403 *ptr += sizeof(*d);
406 static void skip_dword_unknown(const char **ptr, unsigned int count)
408 unsigned int i;
409 DWORD d;
411 FIXME("Skipping %u unknown DWORDs:\n", count);
412 for (i = 0; i < count; ++i)
414 read_dword(ptr, &d);
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 *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
451 unsigned int i;
453 for (i = 0; i < base->technique_count; ++i)
455 if (base->technique_handles[i] == technique)
457 return get_technique_struct(technique);
461 return NULL;
464 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
466 unsigned int i, k;
468 for (i = 0; i < base->technique_count; ++i)
470 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
472 for (k = 0; k < technique->pass_count; ++k)
474 if (technique->pass_handles[k] == pass)
476 return get_pass_struct(pass);
481 return NULL;
484 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
486 unsigned int i, count;
487 struct d3dx_parameter *p;
489 for (i = 0; i < param->annotation_count; ++i)
491 if (param->annotation_handles[i] == parameter)
493 return get_parameter_struct(parameter);
496 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
497 if (p) return p;
500 if (param->element_count) count = param->element_count;
501 else count = param->member_count;
503 for (i = 0; i < count; ++i)
505 if (param->member_handles[i] == parameter)
507 return get_parameter_struct(parameter);
510 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
511 if (p) return p;
514 return NULL;
517 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
519 unsigned int i, k, m;
520 struct d3dx_parameter *p;
522 for (i = 0; i < base->parameter_count; ++i)
524 if (base->parameter_handles[i] == parameter)
526 return get_parameter_struct(parameter);
529 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
530 if (p) return p;
533 for (i = 0; i < base->technique_count; ++i)
535 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
537 for (k = 0; k < technique->pass_count; ++k)
539 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
541 for (m = 0; m < pass->annotation_count; ++m)
543 if (pass->annotation_handles[i] == parameter)
545 return get_parameter_struct(parameter);
548 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
549 if (p) return p;
553 for (k = 0; k < technique->annotation_count; ++k)
555 if (technique->annotation_handles[k] == parameter)
557 return get_parameter_struct(parameter);
560 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
561 if (p) return p;
565 return NULL;
568 static inline struct d3dx_parameter *get_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
570 struct d3dx_parameter *param = is_valid_parameter(base, parameter);
572 if (!param) param = get_parameter_by_name(base, NULL, parameter);
574 return param;
577 static void free_state(struct d3dx_state *state)
579 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
582 static void free_sampler(struct d3dx_sampler *sampler)
584 UINT i;
586 for (i = 0; i < sampler->state_count; ++i)
588 free_state(&sampler->states[i]);
590 HeapFree(GetProcessHeap(), 0, sampler->states);
593 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
595 free_parameter_state(handle, element, child, ST_CONSTANT);
598 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
600 unsigned int i;
601 struct d3dx_parameter *param = get_parameter_struct(handle);
603 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
604 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
606 if (!param)
608 return;
611 if (param->annotation_handles)
613 for (i = 0; i < param->annotation_count; ++i)
615 free_parameter(param->annotation_handles[i], FALSE, FALSE);
617 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
620 if (param->member_handles)
622 unsigned int count;
624 if (param->element_count) count = param->element_count;
625 else count = param->member_count;
627 for (i = 0; i < count; ++i)
629 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
631 HeapFree(GetProcessHeap(), 0, param->member_handles);
634 if (param->class == D3DXPC_OBJECT && !param->element_count)
636 switch (param->type)
638 case D3DXPT_STRING:
639 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
640 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
641 break;
643 case D3DXPT_TEXTURE:
644 case D3DXPT_TEXTURE1D:
645 case D3DXPT_TEXTURE2D:
646 case D3DXPT_TEXTURE3D:
647 case D3DXPT_TEXTURECUBE:
648 case D3DXPT_PIXELSHADER:
649 case D3DXPT_VERTEXSHADER:
650 if (st == ST_CONSTANT)
652 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
654 else
656 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
658 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
659 break;
661 case D3DXPT_SAMPLER:
662 case D3DXPT_SAMPLER1D:
663 case D3DXPT_SAMPLER2D:
664 case D3DXPT_SAMPLER3D:
665 case D3DXPT_SAMPLERCUBE:
666 if (st == ST_CONSTANT)
668 free_sampler((struct d3dx_sampler *)param->data);
670 else
672 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
674 /* samplers have always own data, so free that */
675 HeapFree(GetProcessHeap(), 0, param->data);
676 break;
678 default:
679 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
680 break;
683 else
685 if (!child)
687 if (st != ST_CONSTANT)
689 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
691 HeapFree(GetProcessHeap(), 0, param->data);
695 /* only the parent has to release name and semantic */
696 if (!element)
698 HeapFree(GetProcessHeap(), 0, param->name);
699 HeapFree(GetProcessHeap(), 0, param->semantic);
702 HeapFree(GetProcessHeap(), 0, param);
705 static void free_pass(D3DXHANDLE handle)
707 unsigned int i;
708 struct d3dx_pass *pass = get_pass_struct(handle);
710 TRACE("Free pass %p\n", pass);
712 if (!pass)
714 return;
717 if (pass->annotation_handles)
719 for (i = 0; i < pass->annotation_count; ++i)
721 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
723 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
726 if (pass->states)
728 for (i = 0; i < pass->state_count; ++i)
730 free_state(&pass->states[i]);
732 HeapFree(GetProcessHeap(), 0, pass->states);
735 HeapFree(GetProcessHeap(), 0, pass->name);
736 HeapFree(GetProcessHeap(), 0, pass);
739 static void free_technique(D3DXHANDLE handle)
741 unsigned int i;
742 struct d3dx_technique *technique = get_technique_struct(handle);
744 TRACE("Free technique %p\n", technique);
746 if (!technique)
748 return;
751 if (technique->annotation_handles)
753 for (i = 0; i < technique->annotation_count; ++i)
755 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
757 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
760 if (technique->pass_handles)
762 for (i = 0; i < technique->pass_count; ++i)
764 free_pass(technique->pass_handles[i]);
766 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
769 HeapFree(GetProcessHeap(), 0, technique->name);
770 HeapFree(GetProcessHeap(), 0, technique);
773 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
775 unsigned int i;
777 TRACE("Free base effect %p\n", base);
779 if (base->parameter_handles)
781 for (i = 0; i < base->parameter_count; ++i)
783 free_parameter(base->parameter_handles[i], FALSE, FALSE);
785 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
788 if (base->technique_handles)
790 for (i = 0; i < base->technique_count; ++i)
792 free_technique(base->technique_handles[i]);
794 HeapFree(GetProcessHeap(), 0, base->technique_handles);
798 static void free_effect(struct ID3DXEffectImpl *effect)
800 TRACE("Free effect %p\n", effect);
802 if (effect->base_effect)
804 effect->base_effect->lpVtbl->Release(effect->base_effect);
807 if (effect->pool)
809 effect->pool->lpVtbl->Release(effect->pool);
812 if (effect->manager)
814 IUnknown_Release(effect->manager);
817 IDirect3DDevice9_Release(effect->device);
820 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
822 TRACE("Free effect compiler %p\n", compiler);
824 if (compiler->base_effect)
826 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
830 static INT get_int(D3DXPARAMETER_TYPE type, LPCVOID data)
832 INT i;
834 switch (type)
836 case D3DXPT_FLOAT:
837 i = *(FLOAT *)data;
838 break;
840 case D3DXPT_INT:
841 i = *(INT *)data;
842 break;
844 case D3DXPT_BOOL:
845 i = *(BOOL *)data;
846 break;
848 default:
849 i = 0;
850 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
851 break;
854 return i;
857 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, LPCVOID data)
859 FLOAT f;
861 switch (type)
863 case D3DXPT_FLOAT:
864 f = *(FLOAT *)data;
865 break;
867 case D3DXPT_INT:
868 f = *(INT *)data;
869 break;
871 case D3DXPT_BOOL:
872 f = *(BOOL *)data;
873 break;
875 default:
876 f = 0.0f;
877 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
878 break;
881 return f;
884 static inline BOOL get_bool(LPCVOID data)
886 return (*(DWORD *)data) ? TRUE : FALSE;
889 static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector)
891 vector->x = get_float(param->type, (float *)param->data);
892 vector->y = param->columns > 1 ? get_float(param->type, (float *)param->data + 1) : 0.0f;
893 vector->z = param->columns > 2 ? get_float(param->type, (float *)param->data + 2) : 0.0f;
894 vector->w = param->columns > 3 ? get_float(param->type, (float *)param->data + 3) : 0.0f;
897 static void set_number(LPVOID outdata, D3DXPARAMETER_TYPE outtype, LPCVOID indata, D3DXPARAMETER_TYPE intype)
899 TRACE("Changing from type %i to type %i\n", intype, outtype);
901 switch (outtype)
903 case D3DXPT_FLOAT:
904 *(FLOAT *)outdata = get_float(intype, indata);
905 break;
907 case D3DXPT_BOOL:
908 *(BOOL *)outdata = get_bool(indata);
909 break;
911 case D3DXPT_INT:
912 *(INT *)outdata = get_int(intype, indata);
913 break;
915 default:
916 FIXME("Error converting to type %i\n", outtype);
917 *(INT *)outdata = 0;
918 break;
922 static void get_matrix(struct d3dx_parameter *param, D3DXMATRIX *matrix)
924 unsigned int i, k;
926 for (i = 0; i < 4; ++i)
928 for (k = 0; k < 4; ++k)
930 if ((i < param->rows) && (k < param->columns))
931 matrix->u.m[i][k] = get_float(param->type, (float *)param->data + i * param->columns + k);
932 else
933 matrix->u.m[i][k] = 0.0f;
938 static void set_matrix(struct d3dx_parameter *param, CONST D3DXMATRIX *matrix)
940 unsigned int i, k;
942 for (i = 0; i < 4; ++i)
944 for (k = 0; k < 4; ++k)
946 if ((i < param->rows) && (k < param->columns))
947 set_number((float *)param->data + i * param->columns + k, param->type, &matrix->u.m[i][k], D3DXPT_FLOAT);
952 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
954 UINT element;
955 struct d3dx_parameter *temp_parameter;
956 LPCSTR part;
958 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
960 if (!name || !*name) return parameter;
962 element = atoi(name);
963 part = strchr(name, ']') + 1;
965 if (parameter->element_count > element)
967 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
969 switch (*part++)
971 case '.':
972 return get_parameter_by_name(NULL, temp_parameter, part);
974 case '@':
975 return get_parameter_annotation_by_name(temp_parameter, part);
977 case '\0':
978 TRACE("Returning parameter %p\n", temp_parameter);
979 return temp_parameter;
981 default:
982 FIXME("Unhandled case \"%c\"\n", *--part);
983 break;
987 TRACE("Parameter not found\n");
988 return NULL;
991 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
993 UINT i, length;
994 struct d3dx_parameter *temp_parameter;
995 LPCSTR part;
997 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
999 if (!name || !*name) return parameter;
1001 length = strcspn( name, "[.@" );
1002 part = name + length;
1004 for (i = 0; i < parameter->annotation_count; ++i)
1006 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
1008 if (!strcmp(temp_parameter->name, name))
1010 TRACE("Returning parameter %p\n", temp_parameter);
1011 return temp_parameter;
1013 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1015 switch (*part++)
1017 case '.':
1018 return get_parameter_by_name(NULL, temp_parameter, part);
1020 case '[':
1021 return get_parameter_element_by_name(temp_parameter, part);
1023 default:
1024 FIXME("Unhandled case \"%c\"\n", *--part);
1025 break;
1030 TRACE("Parameter not found\n");
1031 return NULL;
1034 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
1035 struct d3dx_parameter *parameter, LPCSTR name)
1037 UINT i, count, length;
1038 struct d3dx_parameter *temp_parameter;
1039 D3DXHANDLE *handles;
1040 LPCSTR part;
1042 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
1044 if (!name || !*name) return parameter;
1046 if (!parameter)
1048 count = base->parameter_count;
1049 handles = base->parameter_handles;
1051 else
1053 count = parameter->member_count;
1054 handles = parameter->member_handles;
1057 length = strcspn( name, "[.@" );
1058 part = name + length;
1060 for (i = 0; i < count; i++)
1062 temp_parameter = get_parameter_struct(handles[i]);
1064 if (!strcmp(temp_parameter->name, name))
1066 TRACE("Returning parameter %p\n", temp_parameter);
1067 return temp_parameter;
1069 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1071 switch (*part++)
1073 case '.':
1074 return get_parameter_by_name(NULL, temp_parameter, part);
1076 case '@':
1077 return get_parameter_annotation_by_name(temp_parameter, part);
1079 case '[':
1080 return get_parameter_element_by_name(temp_parameter, part);
1082 default:
1083 FIXME("Unhandled case \"%c\"\n", *--part);
1084 break;
1089 TRACE("Parameter not found\n");
1090 return NULL;
1093 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1095 return (0xfeff0000 | ((major) << 8) | (minor));
1098 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1100 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1103 /*** IUnknown methods ***/
1104 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1106 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1108 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1110 if (IsEqualGUID(riid, &IID_IUnknown) ||
1111 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1113 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1114 *object = This;
1115 return S_OK;
1118 ERR("Interface %s not found\n", debugstr_guid(riid));
1120 return E_NOINTERFACE;
1123 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1125 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1127 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1129 return InterlockedIncrement(&This->ref);
1132 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1134 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1135 ULONG ref = InterlockedDecrement(&This->ref);
1137 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1139 if (!ref)
1141 free_base_effect(This);
1142 HeapFree(GetProcessHeap(), 0, This);
1145 return ref;
1148 /*** ID3DXBaseEffect methods ***/
1149 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1151 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1153 FIXME("iface %p, desc %p partial stub\n", This, desc);
1155 if (!desc)
1157 WARN("Invalid argument specified.\n");
1158 return D3DERR_INVALIDCALL;
1161 /* Todo: add creator and function count */
1162 desc->Creator = NULL;
1163 desc->Functions = 0;
1164 desc->Parameters = This->parameter_count;
1165 desc->Techniques = This->technique_count;
1167 return D3D_OK;
1170 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1172 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1173 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1175 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1177 if (!desc || !param)
1179 WARN("Invalid argument specified.\n");
1180 return D3DERR_INVALIDCALL;
1183 desc->Name = param->name;
1184 desc->Semantic = param->semantic;
1185 desc->Class = param->class;
1186 desc->Type = param->type;
1187 desc->Rows = param->rows;
1188 desc->Columns = param->columns;
1189 desc->Elements = param->element_count;
1190 desc->Annotations = param->annotation_count;
1191 desc->StructMembers = param->member_count;
1192 desc->Flags = param->flags;
1193 desc->Bytes = param->bytes;
1195 return D3D_OK;
1198 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1200 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1201 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1203 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1205 if (!desc || !tech)
1207 WARN("Invalid argument specified.\n");
1208 return D3DERR_INVALIDCALL;
1211 desc->Name = tech->name;
1212 desc->Passes = tech->pass_count;
1213 desc->Annotations = tech->annotation_count;
1215 return D3D_OK;
1218 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1220 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1221 struct d3dx_pass *p = is_valid_pass(This, pass);
1223 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1225 if (!desc || !p)
1227 WARN("Invalid argument specified.\n");
1228 return D3DERR_INVALIDCALL;
1231 desc->Name = p->name;
1232 desc->Annotations = p->annotation_count;
1234 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1235 desc->pVertexShaderFunction = NULL;
1236 desc->pPixelShaderFunction = NULL;
1238 return D3D_OK;
1241 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1243 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1245 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1247 return E_NOTIMPL;
1250 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1252 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1253 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1255 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1257 if (!parameter)
1259 if (index < This->parameter_count)
1261 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1262 return This->parameter_handles[index];
1265 else
1267 if (param && !param->element_count && index < param->member_count)
1269 TRACE("Returning parameter %p\n", param->member_handles[index]);
1270 return param->member_handles[index];
1274 WARN("Invalid argument specified.\n");
1276 return NULL;
1279 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1281 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1282 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1283 D3DXHANDLE handle;
1285 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1287 if (!name)
1289 handle = get_parameter_handle(param);
1290 TRACE("Returning parameter %p\n", handle);
1291 return handle;
1294 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1295 TRACE("Returning parameter %p\n", handle);
1297 return handle;
1300 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1302 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1303 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1304 struct d3dx_parameter *temp_param;
1305 UINT i;
1307 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1309 if (!parameter)
1311 for (i = 0; i < This->parameter_count; ++i)
1313 temp_param = get_parameter_struct(This->parameter_handles[i]);
1315 if (!temp_param->semantic)
1317 if (!semantic)
1319 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1320 return This->parameter_handles[i];
1322 continue;
1325 if (!strcasecmp(temp_param->semantic, semantic))
1327 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1328 return This->parameter_handles[i];
1332 else if (param)
1334 for (i = 0; i < param->member_count; ++i)
1336 temp_param = get_parameter_struct(param->member_handles[i]);
1338 if (!temp_param->semantic)
1340 if (!semantic)
1342 TRACE("Returning parameter %p\n", param->member_handles[i]);
1343 return param->member_handles[i];
1345 continue;
1348 if (!strcasecmp(temp_param->semantic, semantic))
1350 TRACE("Returning parameter %p\n", param->member_handles[i]);
1351 return param->member_handles[i];
1356 WARN("Invalid argument specified\n");
1358 return NULL;
1361 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1363 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1364 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1366 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1368 if (!param)
1370 if (index < This->parameter_count)
1372 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1373 return This->parameter_handles[index];
1376 else
1378 if (index < param->element_count)
1380 TRACE("Returning parameter %p\n", param->member_handles[index]);
1381 return param->member_handles[index];
1385 WARN("Invalid argument specified\n");
1387 return NULL;
1390 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1392 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1394 TRACE("iface %p, index %u\n", This, index);
1396 if (index >= This->technique_count)
1398 WARN("Invalid argument specified.\n");
1399 return NULL;
1402 TRACE("Returning technique %p\n", This->technique_handles[index]);
1404 return This->technique_handles[index];
1407 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1409 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1410 unsigned int i;
1412 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1414 if (!name)
1416 WARN("Invalid argument specified.\n");
1417 return NULL;
1420 for (i = 0; i < This->technique_count; ++i)
1422 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1424 if (!strcmp(tech->name, name))
1426 TRACE("Returning technique %p\n", This->technique_handles[i]);
1427 return This->technique_handles[i];
1431 WARN("Invalid argument specified.\n");
1433 return NULL;
1436 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1438 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1439 struct d3dx_technique *tech = is_valid_technique(This, technique);
1441 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1443 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1445 if (tech && index < tech->pass_count)
1447 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1448 return tech->pass_handles[index];
1451 WARN("Invalid argument specified.\n");
1453 return NULL;
1456 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1458 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1459 struct d3dx_technique *tech = is_valid_technique(This, technique);
1461 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1463 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1465 if (tech && name)
1467 unsigned int i;
1469 for (i = 0; i < tech->pass_count; ++i)
1471 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1473 if (!strcmp(pass->name, name))
1475 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1476 return tech->pass_handles[i];
1481 WARN("Invalid argument specified.\n");
1483 return NULL;
1486 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1488 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1490 FIXME("iface %p, index %u stub\n", This, index);
1492 return NULL;
1495 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1497 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1499 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1501 return NULL;
1504 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1506 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1507 struct d3dx_parameter *param = get_valid_parameter(This, object);
1508 struct d3dx_pass *pass = is_valid_pass(This, object);
1509 struct d3dx_technique *technique = is_valid_technique(This, object);
1510 UINT annotation_count = 0;
1511 D3DXHANDLE *annotation_handles = NULL;
1513 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1515 if (pass)
1517 annotation_count = pass->annotation_count;
1518 annotation_handles = pass->annotation_handles;
1520 else if (technique)
1522 annotation_count = technique->annotation_count;
1523 annotation_handles = technique->annotation_handles;
1525 else if (param)
1527 annotation_count = param->annotation_count;
1528 annotation_handles = param->annotation_handles;
1530 /* Todo: add funcs */
1532 if (index < annotation_count)
1534 TRACE("Returning parameter %p\n", annotation_handles[index]);
1535 return annotation_handles[index];
1538 WARN("Invalid argument specified\n");
1540 return NULL;
1543 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1545 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1546 struct d3dx_parameter *param = get_valid_parameter(This, object);
1547 struct d3dx_pass *pass = is_valid_pass(This, object);
1548 struct d3dx_technique *technique = is_valid_technique(This, object);
1549 UINT annotation_count = 0, i;
1550 D3DXHANDLE *annotation_handles = NULL;
1552 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1554 if (!name)
1556 WARN("Invalid argument specified\n");
1557 return NULL;
1560 if (pass)
1562 annotation_count = pass->annotation_count;
1563 annotation_handles = pass->annotation_handles;
1565 else if (technique)
1567 annotation_count = technique->annotation_count;
1568 annotation_handles = technique->annotation_handles;
1570 else if (param)
1572 annotation_count = param->annotation_count;
1573 annotation_handles = param->annotation_handles;
1575 /* Todo: add funcs */
1577 for (i = 0; i < annotation_count; i++)
1579 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1581 if (!strcmp(anno->name, name))
1583 TRACE("Returning parameter %p\n", anno);
1584 return get_parameter_handle(anno);
1588 WARN("Invalid argument specified\n");
1590 return NULL;
1593 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1595 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1597 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1599 return E_NOTIMPL;
1602 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1604 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1605 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1607 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1609 if (!param)
1611 WARN("Invalid parameter %p specified\n", parameter);
1612 return D3DERR_INVALIDCALL;
1615 /* samplers don't touch data */
1616 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1617 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1618 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1620 TRACE("Sampler: returning E_FAIL\n");
1621 return E_FAIL;
1624 if (data && param->bytes <= bytes)
1626 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1628 switch (param->type)
1630 case D3DXPT_VOID:
1631 case D3DXPT_BOOL:
1632 case D3DXPT_INT:
1633 case D3DXPT_FLOAT:
1634 case D3DXPT_STRING:
1635 break;
1637 case D3DXPT_VERTEXSHADER:
1638 case D3DXPT_PIXELSHADER:
1639 case D3DXPT_TEXTURE:
1640 case D3DXPT_TEXTURE1D:
1641 case D3DXPT_TEXTURE2D:
1642 case D3DXPT_TEXTURE3D:
1643 case D3DXPT_TEXTURECUBE:
1645 UINT i;
1647 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1649 IUnknown *unk = ((IUnknown **)param->data)[i];
1650 if (unk) IUnknown_AddRef(unk);
1652 break;
1655 default:
1656 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1657 break;
1660 TRACE("Copy %u bytes\n", param->bytes);
1661 memcpy(data, param->data, param->bytes);
1662 return D3D_OK;
1665 WARN("Invalid argument specified\n");
1667 return D3DERR_INVALIDCALL;
1670 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1672 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1673 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1675 TRACE("iface %p, parameter %p, b %s\n", This, parameter, b ? "TRUE" : "FALSE");
1677 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1679 set_number(param->data, param->type, &b, D3DXPT_BOOL);
1680 return D3D_OK;
1683 WARN("Invalid argument specified\n");
1685 return D3DERR_INVALIDCALL;
1688 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1690 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1691 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1693 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1695 if (b && param && !param->element_count && param->rows == 1 && param->columns == 1)
1697 *b = get_bool(param->data);
1698 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1699 return D3D_OK;
1702 WARN("Invalid argument specified\n");
1704 return D3DERR_INVALIDCALL;
1707 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1709 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1710 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1712 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1714 if (param)
1716 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1718 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1720 switch (param->class)
1722 case D3DXPC_SCALAR:
1723 case D3DXPC_VECTOR:
1724 case D3DXPC_MATRIX_ROWS:
1725 for (i = 0; i < size; ++i)
1727 set_number((DWORD *)param->data + i, param->type, &b[i], D3DXPT_BOOL);
1729 return D3D_OK;
1731 case D3DXPC_OBJECT:
1732 case D3DXPC_STRUCT:
1733 break;
1735 default:
1736 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1737 break;
1741 WARN("Invalid argument specified\n");
1743 return D3DERR_INVALIDCALL;
1746 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1748 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1749 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1751 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1753 if (b && param && (param->class == D3DXPC_SCALAR
1754 || param->class == D3DXPC_VECTOR
1755 || param->class == D3DXPC_MATRIX_ROWS
1756 || param->class == D3DXPC_MATRIX_COLUMNS))
1758 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1760 for (i = 0; i < size; ++i)
1762 b[i] = get_bool((DWORD *)param->data + i);
1764 return D3D_OK;
1767 WARN("Invalid argument specified\n");
1769 return D3DERR_INVALIDCALL;
1772 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1774 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1775 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1777 TRACE("iface %p, parameter %p, n %i\n", This, parameter, n);
1779 if (param && !param->element_count)
1781 if (param->rows == 1 && param->columns == 1)
1783 set_number(param->data, param->type, &n, D3DXPT_INT);
1784 return D3D_OK;
1788 * Split the value, if parameter is a vector with dimension 3 or 4.
1790 if (param->type == D3DXPT_FLOAT &&
1791 ((param->class == D3DXPC_VECTOR && param->columns != 2) ||
1792 (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1794 FLOAT tmp = ((n & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
1795 set_number((DWORD *)param->data, param->type, &tmp, D3DXPT_FLOAT);
1797 tmp = ((n & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
1798 set_number((DWORD *)param->data + 1, param->type, &tmp, D3DXPT_FLOAT);
1800 tmp = (n & 0xff) * INT_FLOAT_MULTI_INVERSE;
1801 set_number((DWORD *)param->data + 2, param->type, &tmp, D3DXPT_FLOAT);
1803 if (param->rows * param->columns > 3)
1805 tmp = ((n & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
1806 set_number((DWORD *)param->data + 3, param->type, &tmp, D3DXPT_FLOAT);
1808 return D3D_OK;
1812 WARN("Invalid argument specified\n");
1814 return D3DERR_INVALIDCALL;
1817 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1819 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1820 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1822 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1824 if (n && param && !param->element_count)
1826 if (param->columns == 1 && param->rows == 1)
1828 *n = get_int(param->type, param->data);
1829 TRACE("Returning %i\n", *n);
1830 return D3D_OK;
1833 if (param->type == D3DXPT_FLOAT &&
1834 ((param->class == D3DXPC_VECTOR && param->columns != 2)
1835 || (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1837 /* all components (3,4) are clamped (0,255) and put in the INT */
1838 *n = (INT)(min(max(0.0f, *((FLOAT *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI);
1839 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
1840 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
1841 if (param->columns * param->rows > 3)
1843 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
1846 TRACE("Returning %i\n", *n);
1847 return D3D_OK;
1851 WARN("Invalid argument specified\n");
1853 return D3DERR_INVALIDCALL;
1856 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1858 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1859 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1861 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1863 if (param)
1865 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1867 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1869 switch (param->class)
1871 case D3DXPC_SCALAR:
1872 case D3DXPC_VECTOR:
1873 case D3DXPC_MATRIX_ROWS:
1874 for (i = 0; i < size; ++i)
1876 set_number((DWORD *)param->data + i, param->type, &n[i], D3DXPT_INT);
1878 return D3D_OK;
1880 case D3DXPC_OBJECT:
1881 case D3DXPC_STRUCT:
1882 break;
1884 default:
1885 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1886 break;
1890 WARN("Invalid argument specified\n");
1892 return D3DERR_INVALIDCALL;
1895 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1897 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1898 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1900 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1902 if (n && param && (param->class == D3DXPC_SCALAR
1903 || param->class == D3DXPC_VECTOR
1904 || param->class == D3DXPC_MATRIX_ROWS
1905 || param->class == D3DXPC_MATRIX_COLUMNS))
1907 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1909 for (i = 0; i < size; ++i)
1911 n[i] = get_int(param->type, (DWORD *)param->data + i);
1913 return D3D_OK;
1916 WARN("Invalid argument specified\n");
1918 return D3DERR_INVALIDCALL;
1921 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1923 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1924 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1926 TRACE("iface %p, parameter %p, f %f\n", This, parameter, f);
1928 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1930 set_number((DWORD *)param->data, param->type, &f, D3DXPT_FLOAT);
1931 return D3D_OK;
1934 WARN("Invalid argument specified\n");
1936 return D3DERR_INVALIDCALL;
1939 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1941 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1942 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1944 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1946 if (f && param && !param->element_count && param->columns == 1 && param->rows == 1)
1948 *f = get_float(param->type, (DWORD *)param->data);
1949 TRACE("Returning %f\n", *f);
1950 return D3D_OK;
1953 WARN("Invalid argument specified\n");
1955 return D3DERR_INVALIDCALL;
1958 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1960 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1961 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1963 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1965 if (param)
1967 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1969 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1971 switch (param->class)
1973 case D3DXPC_SCALAR:
1974 case D3DXPC_VECTOR:
1975 case D3DXPC_MATRIX_ROWS:
1976 for (i = 0; i < size; ++i)
1978 set_number((DWORD *)param->data + i, param->type, &f[i], D3DXPT_FLOAT);
1980 return D3D_OK;
1982 case D3DXPC_OBJECT:
1983 case D3DXPC_STRUCT:
1984 break;
1986 default:
1987 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1988 break;
1992 WARN("Invalid argument specified\n");
1994 return D3DERR_INVALIDCALL;
1997 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1999 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2000 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2002 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
2004 if (f && param && (param->class == D3DXPC_SCALAR
2005 || param->class == D3DXPC_VECTOR
2006 || param->class == D3DXPC_MATRIX_ROWS
2007 || param->class == D3DXPC_MATRIX_COLUMNS))
2009 UINT i, size = min(count, param->bytes / sizeof(DWORD));
2011 for (i = 0; i < size; ++i)
2013 f[i] = get_float(param->type, (DWORD *)param->data + i);
2015 return D3D_OK;
2018 WARN("Invalid argument specified\n");
2020 return D3DERR_INVALIDCALL;
2023 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
2025 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2027 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
2029 return E_NOTIMPL;
2032 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2034 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2036 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
2038 return E_NOTIMPL;
2041 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2043 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2045 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
2047 return E_NOTIMPL;
2050 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2052 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2053 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2055 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
2057 if (!count) return D3D_OK;
2059 if (vector && param && count <= param->element_count)
2061 UINT i;
2063 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2065 switch (param->class)
2067 case D3DXPC_VECTOR:
2068 for (i = 0; i < count; ++i)
2070 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2072 return D3D_OK;
2074 case D3DXPC_SCALAR:
2075 case D3DXPC_MATRIX_ROWS:
2076 case D3DXPC_OBJECT:
2077 case D3DXPC_STRUCT:
2078 break;
2080 default:
2081 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2082 break;
2086 WARN("Invalid argument specified\n");
2088 return D3DERR_INVALIDCALL;
2091 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2093 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2094 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2096 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2098 if (param && !param->element_count)
2100 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2102 switch (param->class)
2104 case D3DXPC_MATRIX_ROWS:
2105 set_matrix(param, matrix);
2106 return D3D_OK;
2108 case D3DXPC_SCALAR:
2109 case D3DXPC_VECTOR:
2110 case D3DXPC_OBJECT:
2111 case D3DXPC_STRUCT:
2112 break;
2114 default:
2115 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2116 break;
2120 WARN("Invalid argument specified\n");
2122 return D3DERR_INVALIDCALL;
2125 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2127 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2128 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2130 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2132 if (matrix && param && !param->element_count)
2134 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2136 switch (param->class)
2138 case D3DXPC_MATRIX_ROWS:
2139 get_matrix(param, matrix);
2140 return D3D_OK;
2142 case D3DXPC_SCALAR:
2143 case D3DXPC_VECTOR:
2144 case D3DXPC_OBJECT:
2145 case D3DXPC_STRUCT:
2146 break;
2148 default:
2149 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2150 break;
2154 WARN("Invalid argument specified\n");
2156 return D3DERR_INVALIDCALL;
2159 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2161 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2162 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2164 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2166 if (param && param->element_count >= count)
2168 UINT i;
2170 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2172 switch (param->class)
2174 case D3DXPC_MATRIX_ROWS:
2175 for (i = 0; i < count; ++i)
2177 set_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i]);
2179 return D3D_OK;
2181 case D3DXPC_SCALAR:
2182 case D3DXPC_VECTOR:
2183 case D3DXPC_OBJECT:
2184 case D3DXPC_STRUCT:
2185 break;
2187 default:
2188 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2189 break;
2193 WARN("Invalid argument specified\n");
2195 return D3DERR_INVALIDCALL;
2198 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2200 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2201 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2203 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2205 if (!count) return D3D_OK;
2207 if (matrix && param && count <= param->element_count)
2209 UINT i;
2211 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2213 switch (param->class)
2215 case D3DXPC_MATRIX_ROWS:
2216 for (i = 0; i < count; ++i)
2218 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i]);
2220 return D3D_OK;
2222 case D3DXPC_SCALAR:
2223 case D3DXPC_VECTOR:
2224 case D3DXPC_OBJECT:
2225 case D3DXPC_STRUCT:
2226 break;
2228 default:
2229 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2230 break;
2234 WARN("Invalid argument specified\n");
2236 return D3DERR_INVALIDCALL;
2239 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2241 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2243 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2245 return E_NOTIMPL;
2248 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2250 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2252 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2254 return E_NOTIMPL;
2257 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2259 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2260 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2261 D3DXMATRIX m;
2263 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2265 if (param && !param->element_count)
2267 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2269 switch (param->class)
2271 case D3DXPC_MATRIX_ROWS:
2272 set_matrix(param, D3DXMatrixTranspose(&m, matrix));
2273 return D3D_OK;
2275 case D3DXPC_SCALAR:
2276 case D3DXPC_VECTOR:
2277 case D3DXPC_OBJECT:
2278 case D3DXPC_STRUCT:
2279 break;
2281 default:
2282 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2283 break;
2287 WARN("Invalid argument specified\n");
2289 return D3DERR_INVALIDCALL;
2292 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2294 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2295 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2296 D3DXMATRIX m;
2298 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2300 if (matrix && param && !param->element_count)
2302 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2304 switch (param->class)
2306 case D3DXPC_SCALAR:
2307 case D3DXPC_VECTOR:
2308 get_matrix(param, matrix);
2309 return D3D_OK;
2311 case D3DXPC_MATRIX_ROWS:
2312 get_matrix(param, &m);
2313 D3DXMatrixTranspose(matrix, &m);
2314 return D3D_OK;
2316 case D3DXPC_OBJECT:
2317 case D3DXPC_STRUCT:
2318 break;
2320 default:
2321 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2322 break;
2326 WARN("Invalid argument specified\n");
2328 return D3DERR_INVALIDCALL;
2331 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2333 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2334 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2335 D3DXMATRIX m;
2337 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2339 if (param && param->element_count >= count)
2341 UINT i;
2343 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2345 switch (param->class)
2347 case D3DXPC_MATRIX_ROWS:
2348 for (i = 0; i < count; ++i)
2350 set_matrix(get_parameter_struct(param->member_handles[i]), D3DXMatrixTranspose(&m, &matrix[i]));
2352 return D3D_OK;
2354 case D3DXPC_SCALAR:
2355 case D3DXPC_VECTOR:
2356 case D3DXPC_OBJECT:
2357 case D3DXPC_STRUCT:
2358 break;
2360 default:
2361 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2362 break;
2366 WARN("Invalid argument specified\n");
2368 return D3DERR_INVALIDCALL;
2371 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2373 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2374 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2376 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2378 if (!count) return D3D_OK;
2380 if (matrix && param && count <= param->element_count)
2382 UINT i;
2384 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2386 switch (param->class)
2388 case D3DXPC_MATRIX_ROWS:
2389 for (i = 0; i < count; ++i)
2391 D3DXMATRIX m;
2393 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2394 D3DXMatrixTranspose(&matrix[i], &m);
2396 return D3D_OK;
2398 case D3DXPC_SCALAR:
2399 case D3DXPC_VECTOR:
2400 case D3DXPC_OBJECT:
2401 case D3DXPC_STRUCT:
2402 break;
2404 default:
2405 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2406 break;
2410 WARN("Invalid argument specified\n");
2412 return D3DERR_INVALIDCALL;
2415 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2417 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2419 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2421 return E_NOTIMPL;
2424 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2426 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2428 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2430 return E_NOTIMPL;
2433 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2435 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2437 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2439 return E_NOTIMPL;
2442 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2444 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2445 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2447 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2449 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2451 *string = *(LPCSTR *)param->data;
2452 TRACE("Returning %s\n", debugstr_a(*string));
2453 return D3D_OK;
2456 WARN("Invalid argument specified\n");
2458 return D3DERR_INVALIDCALL;
2461 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2463 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2464 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2466 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2468 if (param && !param->element_count &&
2469 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2470 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2471 || param->type == D3DXPT_TEXTURECUBE))
2473 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2475 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2476 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2478 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2480 return D3D_OK;
2483 WARN("Invalid argument specified\n");
2485 return D3DERR_INVALIDCALL;
2488 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2490 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2491 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2493 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2495 if (texture && param && !param->element_count &&
2496 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2497 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2498 || param->type == D3DXPT_TEXTURECUBE))
2500 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2501 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2502 TRACE("Returning %p\n", *texture);
2503 return D3D_OK;
2506 WARN("Invalid argument specified\n");
2508 return D3DERR_INVALIDCALL;
2511 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2513 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2514 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2516 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2518 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2520 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2521 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2522 TRACE("Returning %p\n", *pshader);
2523 return D3D_OK;
2526 WARN("Invalid argument specified\n");
2528 return D3DERR_INVALIDCALL;
2531 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2533 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2534 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2536 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2538 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2540 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2541 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2542 TRACE("Returning %p\n", *vshader);
2543 return D3D_OK;
2546 WARN("Invalid argument specified\n");
2548 return D3DERR_INVALIDCALL;
2551 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2553 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2555 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2557 return E_NOTIMPL;
2560 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2562 /*** IUnknown methods ***/
2563 ID3DXBaseEffectImpl_QueryInterface,
2564 ID3DXBaseEffectImpl_AddRef,
2565 ID3DXBaseEffectImpl_Release,
2566 /*** ID3DXBaseEffect methods ***/
2567 ID3DXBaseEffectImpl_GetDesc,
2568 ID3DXBaseEffectImpl_GetParameterDesc,
2569 ID3DXBaseEffectImpl_GetTechniqueDesc,
2570 ID3DXBaseEffectImpl_GetPassDesc,
2571 ID3DXBaseEffectImpl_GetFunctionDesc,
2572 ID3DXBaseEffectImpl_GetParameter,
2573 ID3DXBaseEffectImpl_GetParameterByName,
2574 ID3DXBaseEffectImpl_GetParameterBySemantic,
2575 ID3DXBaseEffectImpl_GetParameterElement,
2576 ID3DXBaseEffectImpl_GetTechnique,
2577 ID3DXBaseEffectImpl_GetTechniqueByName,
2578 ID3DXBaseEffectImpl_GetPass,
2579 ID3DXBaseEffectImpl_GetPassByName,
2580 ID3DXBaseEffectImpl_GetFunction,
2581 ID3DXBaseEffectImpl_GetFunctionByName,
2582 ID3DXBaseEffectImpl_GetAnnotation,
2583 ID3DXBaseEffectImpl_GetAnnotationByName,
2584 ID3DXBaseEffectImpl_SetValue,
2585 ID3DXBaseEffectImpl_GetValue,
2586 ID3DXBaseEffectImpl_SetBool,
2587 ID3DXBaseEffectImpl_GetBool,
2588 ID3DXBaseEffectImpl_SetBoolArray,
2589 ID3DXBaseEffectImpl_GetBoolArray,
2590 ID3DXBaseEffectImpl_SetInt,
2591 ID3DXBaseEffectImpl_GetInt,
2592 ID3DXBaseEffectImpl_SetIntArray,
2593 ID3DXBaseEffectImpl_GetIntArray,
2594 ID3DXBaseEffectImpl_SetFloat,
2595 ID3DXBaseEffectImpl_GetFloat,
2596 ID3DXBaseEffectImpl_SetFloatArray,
2597 ID3DXBaseEffectImpl_GetFloatArray,
2598 ID3DXBaseEffectImpl_SetVector,
2599 ID3DXBaseEffectImpl_GetVector,
2600 ID3DXBaseEffectImpl_SetVectorArray,
2601 ID3DXBaseEffectImpl_GetVectorArray,
2602 ID3DXBaseEffectImpl_SetMatrix,
2603 ID3DXBaseEffectImpl_GetMatrix,
2604 ID3DXBaseEffectImpl_SetMatrixArray,
2605 ID3DXBaseEffectImpl_GetMatrixArray,
2606 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2607 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2608 ID3DXBaseEffectImpl_SetMatrixTranspose,
2609 ID3DXBaseEffectImpl_GetMatrixTranspose,
2610 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2611 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2612 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2613 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2614 ID3DXBaseEffectImpl_SetString,
2615 ID3DXBaseEffectImpl_GetString,
2616 ID3DXBaseEffectImpl_SetTexture,
2617 ID3DXBaseEffectImpl_GetTexture,
2618 ID3DXBaseEffectImpl_GetPixelShader,
2619 ID3DXBaseEffectImpl_GetVertexShader,
2620 ID3DXBaseEffectImpl_SetArrayRange,
2623 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2625 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2628 /*** IUnknown methods ***/
2629 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2631 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2633 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2635 if (IsEqualGUID(riid, &IID_IUnknown) ||
2636 IsEqualGUID(riid, &IID_ID3DXEffect))
2638 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2639 *object = This;
2640 return S_OK;
2643 ERR("Interface %s not found\n", debugstr_guid(riid));
2645 return E_NOINTERFACE;
2648 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2650 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2652 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2654 return InterlockedIncrement(&This->ref);
2657 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2659 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2660 ULONG ref = InterlockedDecrement(&This->ref);
2662 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2664 if (!ref)
2666 free_effect(This);
2667 HeapFree(GetProcessHeap(), 0, This);
2670 return ref;
2673 /*** ID3DXBaseEffect methods ***/
2674 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2676 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2677 ID3DXBaseEffect *base = This->base_effect;
2679 TRACE("Forward iface %p, base %p\n", This, base);
2681 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2684 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2686 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2687 ID3DXBaseEffect *base = This->base_effect;
2689 TRACE("Forward iface %p, base %p\n", This, base);
2691 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2694 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2696 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2697 ID3DXBaseEffect *base = This->base_effect;
2699 TRACE("Forward iface %p, base %p\n", This, base);
2701 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2704 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2706 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2707 ID3DXBaseEffect *base = This->base_effect;
2709 TRACE("Forward iface %p, base %p\n", This, base);
2711 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2714 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2716 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2717 ID3DXBaseEffect *base = This->base_effect;
2719 TRACE("Forward iface %p, base %p\n", This, base);
2721 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2724 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2726 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2727 ID3DXBaseEffect *base = This->base_effect;
2729 TRACE("Forward iface %p, base %p\n", This, base);
2731 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2734 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2736 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2737 ID3DXBaseEffect *base = This->base_effect;
2739 TRACE("Forward iface %p, base %p\n", This, base);
2741 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2744 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2746 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2747 ID3DXBaseEffect *base = This->base_effect;
2749 TRACE("Forward iface %p, base %p\n", This, base);
2751 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2754 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2756 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2757 ID3DXBaseEffect *base = This->base_effect;
2759 TRACE("Forward iface %p, base %p\n", This, base);
2761 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2764 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2766 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2767 ID3DXBaseEffect *base = This->base_effect;
2769 TRACE("Forward iface %p, base %p\n", This, base);
2771 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2774 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2776 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2777 ID3DXBaseEffect *base = This->base_effect;
2779 TRACE("Forward iface %p, base %p\n", This, base);
2781 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2784 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2786 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2787 ID3DXBaseEffect *base = This->base_effect;
2789 TRACE("Forward iface %p, base %p\n", This, base);
2791 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2794 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2796 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2797 ID3DXBaseEffect *base = This->base_effect;
2799 TRACE("Forward iface %p, base %p\n", This, base);
2801 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2804 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2806 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2807 ID3DXBaseEffect *base = This->base_effect;
2809 TRACE("Forward iface %p, base %p\n", This, base);
2811 return ID3DXBaseEffectImpl_GetFunction(base, index);
2814 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2816 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2817 ID3DXBaseEffect *base = This->base_effect;
2819 TRACE("Forward iface %p, base %p\n", This, base);
2821 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2824 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2826 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2827 ID3DXBaseEffect *base = This->base_effect;
2829 TRACE("Forward iface %p, base %p\n", This, base);
2831 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2834 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2836 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2837 ID3DXBaseEffect *base = This->base_effect;
2839 TRACE("Forward iface %p, base %p\n", This, base);
2841 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2844 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2846 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2847 ID3DXBaseEffect *base = This->base_effect;
2849 TRACE("Forward iface %p, base %p\n", This, base);
2851 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2854 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2856 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2857 ID3DXBaseEffect *base = This->base_effect;
2859 TRACE("Forward iface %p, base %p\n", This, base);
2861 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2864 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2866 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2867 ID3DXBaseEffect *base = This->base_effect;
2869 TRACE("Forward iface %p, base %p\n", This, base);
2871 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2874 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2876 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2877 ID3DXBaseEffect *base = This->base_effect;
2879 TRACE("Forward iface %p, base %p\n", This, base);
2881 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2884 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2886 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2887 ID3DXBaseEffect *base = This->base_effect;
2889 TRACE("Forward iface %p, base %p\n", This, base);
2891 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2894 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2896 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2897 ID3DXBaseEffect *base = This->base_effect;
2899 TRACE("Forward iface %p, base %p\n", This, base);
2901 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2904 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2906 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2907 ID3DXBaseEffect *base = This->base_effect;
2909 TRACE("Forward iface %p, base %p\n", This, base);
2911 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2914 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2916 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2917 ID3DXBaseEffect *base = This->base_effect;
2919 TRACE("Forward iface %p, base %p\n", This, base);
2921 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2924 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2926 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2927 ID3DXBaseEffect *base = This->base_effect;
2929 TRACE("Forward iface %p, base %p\n", This, base);
2931 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2934 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2936 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2937 ID3DXBaseEffect *base = This->base_effect;
2939 TRACE("Forward iface %p, base %p\n", This, base);
2941 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2944 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2946 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2947 ID3DXBaseEffect *base = This->base_effect;
2949 TRACE("Forward iface %p, base %p\n", This, base);
2951 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2954 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2956 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2957 ID3DXBaseEffect *base = This->base_effect;
2959 TRACE("Forward iface %p, base %p\n", This, base);
2961 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2964 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2966 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2967 ID3DXBaseEffect *base = This->base_effect;
2969 TRACE("Forward iface %p, base %p\n", This, base);
2971 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2974 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2976 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2977 ID3DXBaseEffect *base = This->base_effect;
2979 TRACE("Forward iface %p, base %p\n", This, base);
2981 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2984 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2986 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2987 ID3DXBaseEffect *base = This->base_effect;
2989 TRACE("Forward iface %p, base %p\n", This, base);
2991 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2994 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2996 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2997 ID3DXBaseEffect *base = This->base_effect;
2999 TRACE("Forward iface %p, base %p\n", This, base);
3001 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3004 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3006 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3007 ID3DXBaseEffect *base = This->base_effect;
3009 TRACE("Forward iface %p, base %p\n", This, base);
3011 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3014 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3016 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3017 ID3DXBaseEffect *base = This->base_effect;
3019 TRACE("Forward iface %p, base %p\n", This, base);
3021 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3024 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3026 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3027 ID3DXBaseEffect *base = This->base_effect;
3029 TRACE("Forward iface %p, base %p\n", This, base);
3031 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3034 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3036 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3037 ID3DXBaseEffect *base = This->base_effect;
3039 TRACE("Forward iface %p, base %p\n", This, base);
3041 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3044 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3046 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3047 ID3DXBaseEffect *base = This->base_effect;
3049 TRACE("Forward iface %p, base %p\n", This, base);
3051 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3054 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3056 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3057 ID3DXBaseEffect *base = This->base_effect;
3059 TRACE("Forward iface %p, base %p\n", This, base);
3061 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3064 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3066 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3067 ID3DXBaseEffect *base = This->base_effect;
3069 TRACE("Forward iface %p, base %p\n", This, base);
3071 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3074 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3076 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3077 ID3DXBaseEffect *base = This->base_effect;
3079 TRACE("Forward iface %p, base %p\n", This, base);
3081 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3084 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3086 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3087 ID3DXBaseEffect *base = This->base_effect;
3089 TRACE("Forward iface %p, base %p\n", This, base);
3091 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3094 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3096 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3097 ID3DXBaseEffect *base = This->base_effect;
3099 TRACE("Forward iface %p, base %p\n", This, base);
3101 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3104 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3106 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3107 ID3DXBaseEffect *base = This->base_effect;
3109 TRACE("Forward iface %p, base %p\n", This, base);
3111 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3114 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3116 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3117 ID3DXBaseEffect *base = This->base_effect;
3119 TRACE("Forward iface %p, base %p\n", This, base);
3121 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3124 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3126 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3127 ID3DXBaseEffect *base = This->base_effect;
3129 TRACE("Forward iface %p, base %p\n", This, base);
3131 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3134 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3136 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3137 ID3DXBaseEffect *base = This->base_effect;
3139 TRACE("Forward iface %p, base %p\n", This, base);
3141 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3144 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
3146 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3147 ID3DXBaseEffect *base = This->base_effect;
3149 TRACE("Forward iface %p, base %p\n", This, base);
3151 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3154 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3156 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3157 ID3DXBaseEffect *base = This->base_effect;
3159 TRACE("Forward iface %p, base %p\n", This, base);
3161 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3164 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3166 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3167 ID3DXBaseEffect *base = This->base_effect;
3169 TRACE("Forward iface %p, base %p\n", This, base);
3171 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3174 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3176 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3177 ID3DXBaseEffect *base = This->base_effect;
3179 TRACE("Forward iface %p, base %p\n", This, base);
3181 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3184 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3186 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3187 ID3DXBaseEffect *base = This->base_effect;
3189 TRACE("Forward iface %p, base %p\n", This, base);
3191 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3194 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3196 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3197 ID3DXBaseEffect *base = This->base_effect;
3199 TRACE("Forward iface %p, base %p\n", This, base);
3201 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3204 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3206 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3207 ID3DXBaseEffect *base = This->base_effect;
3209 TRACE("Forward iface %p, base %p\n", This, base);
3211 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3214 /*** ID3DXEffect methods ***/
3215 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
3217 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3219 TRACE("iface %p, pool %p\n", This, pool);
3221 if (!pool)
3223 WARN("Invalid argument supplied.\n");
3224 return D3DERR_INVALIDCALL;
3227 if (This->pool)
3229 This->pool->lpVtbl->AddRef(This->pool);
3232 *pool = This->pool;
3234 TRACE("Returning pool %p\n", *pool);
3236 return S_OK;
3239 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3241 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3242 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3243 struct d3dx_technique *tech = is_valid_technique(base, technique);
3245 TRACE("iface %p, technique %p\n", This, technique);
3247 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
3249 if (tech)
3251 UINT i;
3253 for (i = 0; i < base->technique_count; ++i)
3255 struct d3dx_technique *t = get_technique_struct(base->technique_handles[i]);
3257 if (tech == t)
3259 This->active_technique = get_technique_handle(t);
3260 TRACE("Technique %u (%p)\n", i, tech);
3261 return D3D_OK;
3266 WARN("Invalid argument supplied.\n");
3268 return D3DERR_INVALIDCALL;
3271 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3273 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3275 TRACE("iface %p\n", This);
3277 return This->active_technique;
3280 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3282 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3284 FIXME("(%p)->(%p): stub\n", This, technique);
3286 return D3D_OK;
3289 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3291 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3293 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3295 return E_NOTIMPL;
3298 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3300 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3302 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3304 return FALSE;
3307 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3309 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3310 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3312 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3314 if (passes && technique)
3316 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3318 TRACE("State capturing disabled.\n");
3320 else
3322 FIXME("State capturing not supported, yet!\n");
3325 *passes = technique->pass_count;
3327 return D3D_OK;
3330 WARN("Invalid argument supplied.\n");
3332 return D3DERR_INVALIDCALL;
3335 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3337 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3338 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3340 TRACE("iface %p, pass %u\n", This, pass);
3342 if (technique && pass < technique->pass_count && !This->active_pass)
3344 This->active_pass = technique->pass_handles[pass];
3346 FIXME("No states applied, yet!\n");
3348 return D3D_OK;
3351 WARN("Invalid argument supplied.\n");
3353 return D3DERR_INVALIDCALL;
3356 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3358 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3360 FIXME("(%p)->(): stub\n", This);
3362 return E_NOTIMPL;
3365 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3367 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3369 TRACE("iface %p\n", This);
3371 if (This->active_pass)
3373 This->active_pass = NULL;
3374 return D3D_OK;
3377 WARN("Invalid call.\n");
3379 return D3DERR_INVALIDCALL;
3382 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3384 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3386 FIXME("(%p)->(): stub\n", This);
3388 return E_NOTIMPL;
3391 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3393 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3395 TRACE("iface %p, device %p\n", This, device);
3397 if (!device)
3399 WARN("Invalid argument supplied.\n");
3400 return D3DERR_INVALIDCALL;
3403 IDirect3DDevice9_AddRef(This->device);
3405 *device = This->device;
3407 TRACE("Returning device %p\n", *device);
3409 return S_OK;
3412 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3414 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3416 FIXME("(%p)->(): stub\n", This);
3418 return E_NOTIMPL;
3421 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3423 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3425 FIXME("(%p)->(): stub\n", This);
3427 return E_NOTIMPL;
3430 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3432 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3434 TRACE("iface %p, manager %p\n", This, manager);
3436 if (manager) IUnknown_AddRef(manager);
3437 if (This->manager) IUnknown_Release(This->manager);
3439 This->manager = manager;
3441 return D3D_OK;
3444 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3446 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3448 TRACE("iface %p, manager %p\n", This, manager);
3450 if (!manager)
3452 WARN("Invalid argument supplied.\n");
3453 return D3DERR_INVALIDCALL;
3456 if (This->manager) IUnknown_AddRef(This->manager);
3457 *manager = This->manager;
3459 return D3D_OK;
3462 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3464 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3466 FIXME("(%p)->(): stub\n", This);
3468 return E_NOTIMPL;
3471 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3473 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3475 FIXME("(%p)->(): stub\n", This);
3477 return NULL;
3480 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3482 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3484 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3486 return E_NOTIMPL;
3489 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3491 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3493 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3495 return E_NOTIMPL;
3498 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3500 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3502 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3504 return E_NOTIMPL;
3507 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3509 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3511 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3513 return E_NOTIMPL;
3516 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3518 /*** IUnknown methods ***/
3519 ID3DXEffectImpl_QueryInterface,
3520 ID3DXEffectImpl_AddRef,
3521 ID3DXEffectImpl_Release,
3522 /*** ID3DXBaseEffect methods ***/
3523 ID3DXEffectImpl_GetDesc,
3524 ID3DXEffectImpl_GetParameterDesc,
3525 ID3DXEffectImpl_GetTechniqueDesc,
3526 ID3DXEffectImpl_GetPassDesc,
3527 ID3DXEffectImpl_GetFunctionDesc,
3528 ID3DXEffectImpl_GetParameter,
3529 ID3DXEffectImpl_GetParameterByName,
3530 ID3DXEffectImpl_GetParameterBySemantic,
3531 ID3DXEffectImpl_GetParameterElement,
3532 ID3DXEffectImpl_GetTechnique,
3533 ID3DXEffectImpl_GetTechniqueByName,
3534 ID3DXEffectImpl_GetPass,
3535 ID3DXEffectImpl_GetPassByName,
3536 ID3DXEffectImpl_GetFunction,
3537 ID3DXEffectImpl_GetFunctionByName,
3538 ID3DXEffectImpl_GetAnnotation,
3539 ID3DXEffectImpl_GetAnnotationByName,
3540 ID3DXEffectImpl_SetValue,
3541 ID3DXEffectImpl_GetValue,
3542 ID3DXEffectImpl_SetBool,
3543 ID3DXEffectImpl_GetBool,
3544 ID3DXEffectImpl_SetBoolArray,
3545 ID3DXEffectImpl_GetBoolArray,
3546 ID3DXEffectImpl_SetInt,
3547 ID3DXEffectImpl_GetInt,
3548 ID3DXEffectImpl_SetIntArray,
3549 ID3DXEffectImpl_GetIntArray,
3550 ID3DXEffectImpl_SetFloat,
3551 ID3DXEffectImpl_GetFloat,
3552 ID3DXEffectImpl_SetFloatArray,
3553 ID3DXEffectImpl_GetFloatArray,
3554 ID3DXEffectImpl_SetVector,
3555 ID3DXEffectImpl_GetVector,
3556 ID3DXEffectImpl_SetVectorArray,
3557 ID3DXEffectImpl_GetVectorArray,
3558 ID3DXEffectImpl_SetMatrix,
3559 ID3DXEffectImpl_GetMatrix,
3560 ID3DXEffectImpl_SetMatrixArray,
3561 ID3DXEffectImpl_GetMatrixArray,
3562 ID3DXEffectImpl_SetMatrixPointerArray,
3563 ID3DXEffectImpl_GetMatrixPointerArray,
3564 ID3DXEffectImpl_SetMatrixTranspose,
3565 ID3DXEffectImpl_GetMatrixTranspose,
3566 ID3DXEffectImpl_SetMatrixTransposeArray,
3567 ID3DXEffectImpl_GetMatrixTransposeArray,
3568 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3569 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3570 ID3DXEffectImpl_SetString,
3571 ID3DXEffectImpl_GetString,
3572 ID3DXEffectImpl_SetTexture,
3573 ID3DXEffectImpl_GetTexture,
3574 ID3DXEffectImpl_GetPixelShader,
3575 ID3DXEffectImpl_GetVertexShader,
3576 ID3DXEffectImpl_SetArrayRange,
3577 /*** ID3DXEffect methods ***/
3578 ID3DXEffectImpl_GetPool,
3579 ID3DXEffectImpl_SetTechnique,
3580 ID3DXEffectImpl_GetCurrentTechnique,
3581 ID3DXEffectImpl_ValidateTechnique,
3582 ID3DXEffectImpl_FindNextValidTechnique,
3583 ID3DXEffectImpl_IsParameterUsed,
3584 ID3DXEffectImpl_Begin,
3585 ID3DXEffectImpl_BeginPass,
3586 ID3DXEffectImpl_CommitChanges,
3587 ID3DXEffectImpl_EndPass,
3588 ID3DXEffectImpl_End,
3589 ID3DXEffectImpl_GetDevice,
3590 ID3DXEffectImpl_OnLostDevice,
3591 ID3DXEffectImpl_OnResetDevice,
3592 ID3DXEffectImpl_SetStateManager,
3593 ID3DXEffectImpl_GetStateManager,
3594 ID3DXEffectImpl_BeginParameterBlock,
3595 ID3DXEffectImpl_EndParameterBlock,
3596 ID3DXEffectImpl_ApplyParameterBlock,
3597 ID3DXEffectImpl_DeleteParameterBlock,
3598 ID3DXEffectImpl_CloneEffect,
3599 ID3DXEffectImpl_SetRawValue
3602 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3604 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3607 /*** IUnknown methods ***/
3608 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3610 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3612 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3614 if (IsEqualGUID(riid, &IID_IUnknown) ||
3615 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3617 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3618 *object = This;
3619 return S_OK;
3622 ERR("Interface %s not found\n", debugstr_guid(riid));
3624 return E_NOINTERFACE;
3627 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3629 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3631 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3633 return InterlockedIncrement(&This->ref);
3636 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3638 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3639 ULONG ref = InterlockedDecrement(&This->ref);
3641 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3643 if (!ref)
3645 free_effect_compiler(This);
3646 HeapFree(GetProcessHeap(), 0, This);
3649 return ref;
3652 /*** ID3DXBaseEffect methods ***/
3653 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3655 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3656 ID3DXBaseEffect *base = This->base_effect;
3658 TRACE("Forward iface %p, base %p\n", This, base);
3660 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3663 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3665 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3666 ID3DXBaseEffect *base = This->base_effect;
3668 TRACE("Forward iface %p, base %p\n", This, base);
3670 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3673 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3675 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3676 ID3DXBaseEffect *base = This->base_effect;
3678 TRACE("Forward iface %p, base %p\n", This, base);
3680 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3683 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3685 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3686 ID3DXBaseEffect *base = This->base_effect;
3688 TRACE("Forward iface %p, base %p\n", This, base);
3690 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3693 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3695 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3696 ID3DXBaseEffect *base = This->base_effect;
3698 TRACE("Forward iface %p, base %p\n", This, base);
3700 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3703 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3705 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3706 ID3DXBaseEffect *base = This->base_effect;
3708 TRACE("Forward iface %p, base %p\n", This, base);
3710 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3713 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3715 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3716 ID3DXBaseEffect *base = This->base_effect;
3718 TRACE("Forward iface %p, base %p\n", This, base);
3720 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3723 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3725 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3726 ID3DXBaseEffect *base = This->base_effect;
3728 TRACE("Forward iface %p, base %p\n", This, base);
3730 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3733 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3735 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3736 ID3DXBaseEffect *base = This->base_effect;
3738 TRACE("Forward iface %p, base %p\n", This, base);
3740 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3743 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3745 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3746 ID3DXBaseEffect *base = This->base_effect;
3748 TRACE("Forward iface %p, base %p\n", This, base);
3750 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3753 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3755 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3756 ID3DXBaseEffect *base = This->base_effect;
3758 TRACE("Forward iface %p, base %p\n", This, base);
3760 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3763 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3765 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3766 ID3DXBaseEffect *base = This->base_effect;
3768 TRACE("Forward iface %p, base %p\n", This, base);
3770 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3773 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3775 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3776 ID3DXBaseEffect *base = This->base_effect;
3778 TRACE("Forward iface %p, base %p\n", This, base);
3780 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3783 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3785 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3786 ID3DXBaseEffect *base = This->base_effect;
3788 TRACE("Forward iface %p, base %p\n", This, base);
3790 return ID3DXBaseEffectImpl_GetFunction(base, index);
3793 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3795 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3796 ID3DXBaseEffect *base = This->base_effect;
3798 TRACE("Forward iface %p, base %p\n", This, base);
3800 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3803 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3805 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3806 ID3DXBaseEffect *base = This->base_effect;
3808 TRACE("Forward iface %p, base %p\n", This, base);
3810 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3813 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3815 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3816 ID3DXBaseEffect *base = This->base_effect;
3818 TRACE("Forward iface %p, base %p\n", This, base);
3820 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3823 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3825 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3826 ID3DXBaseEffect *base = This->base_effect;
3828 TRACE("Forward iface %p, base %p\n", This, base);
3830 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3833 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3835 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3836 ID3DXBaseEffect *base = This->base_effect;
3838 TRACE("Forward iface %p, base %p\n", This, base);
3840 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3843 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3845 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3846 ID3DXBaseEffect *base = This->base_effect;
3848 TRACE("Forward iface %p, base %p\n", This, base);
3850 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3853 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3855 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3856 ID3DXBaseEffect *base = This->base_effect;
3858 TRACE("Forward iface %p, base %p\n", This, base);
3860 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3863 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3865 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3866 ID3DXBaseEffect *base = This->base_effect;
3868 TRACE("Forward iface %p, base %p\n", This, base);
3870 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3873 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3875 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3876 ID3DXBaseEffect *base = This->base_effect;
3878 TRACE("Forward iface %p, base %p\n", This, base);
3880 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3883 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3885 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3886 ID3DXBaseEffect *base = This->base_effect;
3888 TRACE("Forward iface %p, base %p\n", This, base);
3890 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3893 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3895 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3896 ID3DXBaseEffect *base = This->base_effect;
3898 TRACE("Forward iface %p, base %p\n", This, base);
3900 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3903 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3905 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3906 ID3DXBaseEffect *base = This->base_effect;
3908 TRACE("Forward iface %p, base %p\n", This, base);
3910 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3913 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3915 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3916 ID3DXBaseEffect *base = This->base_effect;
3918 TRACE("Forward iface %p, base %p\n", This, base);
3920 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3923 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3925 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3926 ID3DXBaseEffect *base = This->base_effect;
3928 TRACE("Forward iface %p, base %p\n", This, base);
3930 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3933 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3935 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3936 ID3DXBaseEffect *base = This->base_effect;
3938 TRACE("Forward iface %p, base %p\n", This, base);
3940 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3943 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3945 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3946 ID3DXBaseEffect *base = This->base_effect;
3948 TRACE("Forward iface %p, base %p\n", This, base);
3950 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3953 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3955 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3956 ID3DXBaseEffect *base = This->base_effect;
3958 TRACE("Forward iface %p, base %p\n", This, base);
3960 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3963 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3965 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3966 ID3DXBaseEffect *base = This->base_effect;
3968 TRACE("Forward iface %p, base %p\n", This, base);
3970 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3973 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3975 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3976 ID3DXBaseEffect *base = This->base_effect;
3978 TRACE("Forward iface %p, base %p\n", This, base);
3980 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3983 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3985 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3986 ID3DXBaseEffect *base = This->base_effect;
3988 TRACE("Forward iface %p, base %p\n", This, base);
3990 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3993 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3995 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3996 ID3DXBaseEffect *base = This->base_effect;
3998 TRACE("Forward iface %p, base %p\n", This, base);
4000 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
4003 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4005 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4006 ID3DXBaseEffect *base = This->base_effect;
4008 TRACE("Forward iface %p, base %p\n", This, base);
4010 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
4013 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4015 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4016 ID3DXBaseEffect *base = This->base_effect;
4018 TRACE("Forward iface %p, base %p\n", This, base);
4020 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
4023 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4025 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4026 ID3DXBaseEffect *base = This->base_effect;
4028 TRACE("Forward iface %p, base %p\n", This, base);
4030 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
4033 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4035 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4036 ID3DXBaseEffect *base = This->base_effect;
4038 TRACE("Forward iface %p, base %p\n", This, base);
4040 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
4043 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4045 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4046 ID3DXBaseEffect *base = This->base_effect;
4048 TRACE("Forward iface %p, base %p\n", This, base);
4050 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
4053 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4055 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4056 ID3DXBaseEffect *base = This->base_effect;
4058 TRACE("Forward iface %p, base %p\n", This, base);
4060 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
4063 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4065 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4066 ID3DXBaseEffect *base = This->base_effect;
4068 TRACE("Forward iface %p, base %p\n", This, base);
4070 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
4073 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4075 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4076 ID3DXBaseEffect *base = This->base_effect;
4078 TRACE("Forward iface %p, base %p\n", This, base);
4080 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
4083 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4085 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4086 ID3DXBaseEffect *base = This->base_effect;
4088 TRACE("Forward iface %p, base %p\n", This, base);
4090 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
4093 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4095 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4096 ID3DXBaseEffect *base = This->base_effect;
4098 TRACE("Forward iface %p, base %p\n", This, base);
4100 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
4103 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4105 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4106 ID3DXBaseEffect *base = This->base_effect;
4108 TRACE("Forward iface %p, base %p\n", This, base);
4110 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
4113 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4115 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4116 ID3DXBaseEffect *base = This->base_effect;
4118 TRACE("Forward iface %p, base %p\n", This, base);
4120 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
4123 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
4125 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4126 ID3DXBaseEffect *base = This->base_effect;
4128 TRACE("Forward iface %p, base %p\n", This, base);
4130 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
4133 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
4135 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4136 ID3DXBaseEffect *base = This->base_effect;
4138 TRACE("Forward iface %p, base %p\n", This, base);
4140 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
4143 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
4145 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4146 ID3DXBaseEffect *base = This->base_effect;
4148 TRACE("Forward iface %p, base %p\n", This, base);
4150 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
4153 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
4155 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4156 ID3DXBaseEffect *base = This->base_effect;
4158 TRACE("Forward iface %p, base %p\n", This, base);
4160 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4163 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
4165 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4166 ID3DXBaseEffect *base = This->base_effect;
4168 TRACE("Forward iface %p, base %p\n", This, base);
4170 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
4173 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
4175 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4176 ID3DXBaseEffect *base = This->base_effect;
4178 TRACE("Forward iface %p, base %p\n", This, base);
4180 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
4183 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4185 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4186 ID3DXBaseEffect *base = This->base_effect;
4188 TRACE("Forward iface %p, base %p\n", This, base);
4190 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4193 /*** ID3DXEffectCompiler methods ***/
4194 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4196 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4198 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4200 return E_NOTIMPL;
4203 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4205 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4207 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4209 return E_NOTIMPL;
4212 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4213 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
4215 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4217 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4219 return E_NOTIMPL;
4222 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4223 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
4225 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4227 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4228 This, function, target, flags, shader, error_msgs, constant_table);
4230 return E_NOTIMPL;
4233 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4235 /*** IUnknown methods ***/
4236 ID3DXEffectCompilerImpl_QueryInterface,
4237 ID3DXEffectCompilerImpl_AddRef,
4238 ID3DXEffectCompilerImpl_Release,
4239 /*** ID3DXBaseEffect methods ***/
4240 ID3DXEffectCompilerImpl_GetDesc,
4241 ID3DXEffectCompilerImpl_GetParameterDesc,
4242 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4243 ID3DXEffectCompilerImpl_GetPassDesc,
4244 ID3DXEffectCompilerImpl_GetFunctionDesc,
4245 ID3DXEffectCompilerImpl_GetParameter,
4246 ID3DXEffectCompilerImpl_GetParameterByName,
4247 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4248 ID3DXEffectCompilerImpl_GetParameterElement,
4249 ID3DXEffectCompilerImpl_GetTechnique,
4250 ID3DXEffectCompilerImpl_GetTechniqueByName,
4251 ID3DXEffectCompilerImpl_GetPass,
4252 ID3DXEffectCompilerImpl_GetPassByName,
4253 ID3DXEffectCompilerImpl_GetFunction,
4254 ID3DXEffectCompilerImpl_GetFunctionByName,
4255 ID3DXEffectCompilerImpl_GetAnnotation,
4256 ID3DXEffectCompilerImpl_GetAnnotationByName,
4257 ID3DXEffectCompilerImpl_SetValue,
4258 ID3DXEffectCompilerImpl_GetValue,
4259 ID3DXEffectCompilerImpl_SetBool,
4260 ID3DXEffectCompilerImpl_GetBool,
4261 ID3DXEffectCompilerImpl_SetBoolArray,
4262 ID3DXEffectCompilerImpl_GetBoolArray,
4263 ID3DXEffectCompilerImpl_SetInt,
4264 ID3DXEffectCompilerImpl_GetInt,
4265 ID3DXEffectCompilerImpl_SetIntArray,
4266 ID3DXEffectCompilerImpl_GetIntArray,
4267 ID3DXEffectCompilerImpl_SetFloat,
4268 ID3DXEffectCompilerImpl_GetFloat,
4269 ID3DXEffectCompilerImpl_SetFloatArray,
4270 ID3DXEffectCompilerImpl_GetFloatArray,
4271 ID3DXEffectCompilerImpl_SetVector,
4272 ID3DXEffectCompilerImpl_GetVector,
4273 ID3DXEffectCompilerImpl_SetVectorArray,
4274 ID3DXEffectCompilerImpl_GetVectorArray,
4275 ID3DXEffectCompilerImpl_SetMatrix,
4276 ID3DXEffectCompilerImpl_GetMatrix,
4277 ID3DXEffectCompilerImpl_SetMatrixArray,
4278 ID3DXEffectCompilerImpl_GetMatrixArray,
4279 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4280 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4281 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4282 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4283 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4284 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4285 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4286 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4287 ID3DXEffectCompilerImpl_SetString,
4288 ID3DXEffectCompilerImpl_GetString,
4289 ID3DXEffectCompilerImpl_SetTexture,
4290 ID3DXEffectCompilerImpl_GetTexture,
4291 ID3DXEffectCompilerImpl_GetPixelShader,
4292 ID3DXEffectCompilerImpl_GetVertexShader,
4293 ID3DXEffectCompilerImpl_SetArrayRange,
4294 /*** ID3DXEffectCompiler methods ***/
4295 ID3DXEffectCompilerImpl_SetLiteral,
4296 ID3DXEffectCompilerImpl_GetLiteral,
4297 ID3DXEffectCompilerImpl_CompileEffect,
4298 ID3DXEffectCompilerImpl_CompileShader,
4301 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4303 HRESULT hr;
4304 UINT i;
4305 struct d3dx_state *states;
4307 read_dword(ptr, &sampler->state_count);
4308 TRACE("Count: %u\n", sampler->state_count);
4310 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4311 if (!states)
4313 ERR("Out of memory\n");
4314 return E_OUTOFMEMORY;
4317 for (i = 0; i < sampler->state_count; ++i)
4319 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4320 if (hr != D3D_OK)
4322 WARN("Failed to parse state\n");
4323 goto err_out;
4327 sampler->states = states;
4329 return D3D_OK;
4331 err_out:
4333 for (i = 0; i < sampler->state_count; ++i)
4335 free_state(&states[i]);
4338 HeapFree(GetProcessHeap(), 0, states);
4340 return hr;
4343 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4345 unsigned int i;
4346 HRESULT hr;
4347 UINT old_size = 0;
4348 DWORD id;
4350 if (param->element_count)
4352 param->data = value;
4354 for (i = 0; i < param->element_count; ++i)
4356 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4358 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4359 if (hr != D3D_OK)
4361 WARN("Failed to parse value\n");
4362 return hr;
4365 old_size += member->bytes;
4368 return D3D_OK;
4371 switch(param->class)
4373 case D3DXPC_SCALAR:
4374 case D3DXPC_VECTOR:
4375 case D3DXPC_MATRIX_ROWS:
4376 case D3DXPC_MATRIX_COLUMNS:
4377 param->data = value;
4378 break;
4380 case D3DXPC_STRUCT:
4381 param->data = value;
4383 for (i = 0; i < param->member_count; ++i)
4385 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4387 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4388 if (hr != D3D_OK)
4390 WARN("Failed to parse value\n");
4391 return hr;
4394 old_size += member->bytes;
4396 break;
4398 case D3DXPC_OBJECT:
4399 switch (param->type)
4401 case D3DXPT_STRING:
4402 case D3DXPT_TEXTURE:
4403 case D3DXPT_TEXTURE1D:
4404 case D3DXPT_TEXTURE2D:
4405 case D3DXPT_TEXTURE3D:
4406 case D3DXPT_TEXTURECUBE:
4407 case D3DXPT_PIXELSHADER:
4408 case D3DXPT_VERTEXSHADER:
4409 read_dword(ptr, &id);
4410 TRACE("Id: %u\n", id);
4411 objects[id] = get_parameter_handle(param);
4412 param->data = value;
4413 break;
4415 case D3DXPT_SAMPLER:
4416 case D3DXPT_SAMPLER1D:
4417 case D3DXPT_SAMPLER2D:
4418 case D3DXPT_SAMPLER3D:
4419 case D3DXPT_SAMPLERCUBE:
4421 struct d3dx_sampler *sampler;
4423 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4424 if (!sampler)
4426 ERR("Out of memory\n");
4427 return E_OUTOFMEMORY;
4430 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4431 if (hr != D3D_OK)
4433 HeapFree(GetProcessHeap(), 0, sampler);
4434 WARN("Failed to parse sampler\n");
4435 return hr;
4438 param->data = sampler;
4439 break;
4442 default:
4443 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4444 break;
4446 break;
4448 default:
4449 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4450 break;
4453 return D3D_OK;
4456 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4458 UINT size = param->bytes;
4459 HRESULT hr;
4460 void *value = NULL;
4462 TRACE("param size: %u\n", size);
4464 if (size)
4466 value = HeapAlloc(GetProcessHeap(), 0, size);
4467 if (!value)
4469 ERR("Failed to allocate data memory.\n");
4470 return E_OUTOFMEMORY;
4473 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4474 memcpy(value, ptr, size);
4477 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4478 if (hr != D3D_OK)
4480 WARN("Failed to parse value\n");
4481 HeapFree(GetProcessHeap(), 0, value);
4482 return hr;
4485 return D3D_OK;
4488 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4490 DWORD size;
4492 read_dword(&ptr, &size);
4493 TRACE("Name size: %#x\n", size);
4495 if (!size)
4497 return D3D_OK;
4500 *name = HeapAlloc(GetProcessHeap(), 0, size);
4501 if (!*name)
4503 ERR("Failed to allocate name memory.\n");
4504 return E_OUTOFMEMORY;
4507 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4508 memcpy(*name, ptr, size);
4510 return D3D_OK;
4513 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4515 DWORD size;
4517 read_dword(ptr, &size);
4518 TRACE("Data size: %#x\n", size);
4520 *str = HeapAlloc(GetProcessHeap(), 0, size);
4521 if (!*str)
4523 ERR("Failed to allocate name memory.\n");
4524 return E_OUTOFMEMORY;
4527 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4528 memcpy(*str, *ptr, size);
4530 *ptr += ((size + 3) & ~3);
4532 return D3D_OK;
4535 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4537 DWORD size;
4538 HRESULT hr;
4540 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4542 read_dword(ptr, &size);
4543 TRACE("Data size: %#x\n", size);
4545 if (!size)
4547 TRACE("Size is 0\n");
4548 *(void **)param->data = NULL;
4549 return D3D_OK;
4552 switch (param->type)
4554 case D3DXPT_STRING:
4555 /* re-read with size (sizeof(DWORD) = 4) */
4556 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4557 if (hr != D3D_OK)
4559 WARN("Failed to parse string data\n");
4560 return hr;
4562 break;
4564 case D3DXPT_VERTEXSHADER:
4565 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4566 if (hr != D3D_OK)
4568 WARN("Failed to create vertex shader\n");
4569 return hr;
4571 break;
4573 case D3DXPT_PIXELSHADER:
4574 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4575 if (hr != D3D_OK)
4577 WARN("Failed to create pixel shader\n");
4578 return hr;
4580 break;
4582 default:
4583 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4584 break;
4588 *ptr += ((size + 3) & ~3);
4590 return D3D_OK;
4593 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4594 struct d3dx_parameter *parent, UINT flags)
4596 DWORD offset;
4597 HRESULT hr;
4598 D3DXHANDLE *member_handles = NULL;
4599 UINT i;
4601 param->flags = flags;
4603 if (!parent)
4605 read_dword(ptr, &param->type);
4606 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4608 read_dword(ptr, &param->class);
4609 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4611 read_dword(ptr, &offset);
4612 TRACE("Type name offset: %#x\n", offset);
4613 hr = d3dx9_parse_name(&param->name, data + offset);
4614 if (hr != D3D_OK)
4616 WARN("Failed to parse name\n");
4617 goto err_out;
4620 read_dword(ptr, &offset);
4621 TRACE("Type semantic offset: %#x\n", offset);
4622 hr = d3dx9_parse_name(&param->semantic, data + offset);
4623 if (hr != D3D_OK)
4625 WARN("Failed to parse semantic\n");
4626 goto err_out;
4629 read_dword(ptr, &param->element_count);
4630 TRACE("Elements: %u\n", param->element_count);
4632 switch (param->class)
4634 case D3DXPC_VECTOR:
4635 read_dword(ptr, &param->columns);
4636 TRACE("Columns: %u\n", param->columns);
4638 read_dword(ptr, &param->rows);
4639 TRACE("Rows: %u\n", param->rows);
4641 /* sizeof(DWORD) * rows * columns */
4642 param->bytes = 4 * param->rows * param->columns;
4643 break;
4645 case D3DXPC_SCALAR:
4646 case D3DXPC_MATRIX_ROWS:
4647 case D3DXPC_MATRIX_COLUMNS:
4648 read_dword(ptr, &param->rows);
4649 TRACE("Rows: %u\n", param->rows);
4651 read_dword(ptr, &param->columns);
4652 TRACE("Columns: %u\n", param->columns);
4654 /* sizeof(DWORD) * rows * columns */
4655 param->bytes = 4 * param->rows * param->columns;
4656 break;
4658 case D3DXPC_STRUCT:
4659 read_dword(ptr, &param->member_count);
4660 TRACE("Members: %u\n", param->member_count);
4661 break;
4663 case D3DXPC_OBJECT:
4664 switch (param->type)
4666 case D3DXPT_STRING:
4667 param->bytes = sizeof(LPCSTR);
4668 break;
4670 case D3DXPT_PIXELSHADER:
4671 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4672 break;
4674 case D3DXPT_VERTEXSHADER:
4675 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4676 break;
4678 case D3DXPT_TEXTURE:
4679 case D3DXPT_TEXTURE1D:
4680 case D3DXPT_TEXTURE2D:
4681 case D3DXPT_TEXTURE3D:
4682 case D3DXPT_TEXTURECUBE:
4683 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4684 break;
4686 case D3DXPT_SAMPLER:
4687 case D3DXPT_SAMPLER1D:
4688 case D3DXPT_SAMPLER2D:
4689 case D3DXPT_SAMPLER3D:
4690 case D3DXPT_SAMPLERCUBE:
4691 param->bytes = 0;
4692 break;
4694 default:
4695 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4696 break;
4698 break;
4700 default:
4701 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4702 break;
4705 else
4707 /* elements */
4708 param->type = parent->type;
4709 param->class = parent->class;
4710 param->name = parent->name;
4711 param->semantic = parent->semantic;
4712 param->element_count = 0;
4713 param->annotation_count = 0;
4714 param->member_count = parent->member_count;
4715 param->bytes = parent->bytes;
4716 param->rows = parent->rows;
4717 param->columns = parent->columns;
4720 if (param->element_count)
4722 unsigned int param_bytes = 0;
4723 const char *save_ptr = *ptr;
4725 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4726 if (!member_handles)
4728 ERR("Out of memory\n");
4729 hr = E_OUTOFMEMORY;
4730 goto err_out;
4733 for (i = 0; i < param->element_count; ++i)
4735 struct d3dx_parameter *member;
4736 *ptr = save_ptr;
4738 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4739 if (!member)
4741 ERR("Out of memory\n");
4742 hr = E_OUTOFMEMORY;
4743 goto err_out;
4746 member_handles[i] = get_parameter_handle(member);
4748 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4749 if (hr != D3D_OK)
4751 WARN("Failed to parse member\n");
4752 goto err_out;
4755 param_bytes += member->bytes;
4758 param->bytes = param_bytes;
4760 else if (param->member_count)
4762 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4763 if (!member_handles)
4765 ERR("Out of memory\n");
4766 hr = E_OUTOFMEMORY;
4767 goto err_out;
4770 for (i = 0; i < param->member_count; ++i)
4772 struct d3dx_parameter *member;
4774 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4775 if (!member)
4777 ERR("Out of memory\n");
4778 hr = E_OUTOFMEMORY;
4779 goto err_out;
4782 member_handles[i] = get_parameter_handle(member);
4784 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4785 if (hr != D3D_OK)
4787 WARN("Failed to parse member\n");
4788 goto err_out;
4791 param->bytes += member->bytes;
4795 param->member_handles = member_handles;
4797 return D3D_OK;
4799 err_out:
4801 if (member_handles)
4803 unsigned int count;
4805 if (param->element_count) count = param->element_count;
4806 else count = param->member_count;
4808 for (i = 0; i < count; ++i)
4810 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4812 HeapFree(GetProcessHeap(), 0, member_handles);
4815 if (!parent)
4817 HeapFree(GetProcessHeap(), 0, param->name);
4818 HeapFree(GetProcessHeap(), 0, param->semantic);
4820 param->name = NULL;
4821 param->semantic = NULL;
4823 return hr;
4826 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4828 DWORD offset;
4829 const char *ptr2;
4830 HRESULT hr;
4832 anno->flags = D3DX_PARAMETER_ANNOTATION;
4834 read_dword(ptr, &offset);
4835 TRACE("Typedef offset: %#x\n", offset);
4836 ptr2 = data + offset;
4837 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4838 if (hr != D3D_OK)
4840 WARN("Failed to parse type definition\n");
4841 return hr;
4844 read_dword(ptr, &offset);
4845 TRACE("Value offset: %#x\n", offset);
4846 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4847 if (hr != D3D_OK)
4849 WARN("Failed to parse value\n");
4850 return hr;
4853 return D3D_OK;
4856 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4858 DWORD offset;
4859 const char *ptr2;
4860 HRESULT hr;
4861 struct d3dx_parameter *parameter;
4863 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4864 if (!parameter)
4866 ERR("Out of memory\n");
4867 return E_OUTOFMEMORY;
4870 state->type = ST_CONSTANT;
4872 read_dword(ptr, &state->operation);
4873 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4875 read_dword(ptr, &state->index);
4876 TRACE("Index: %#x\n", state->index);
4878 read_dword(ptr, &offset);
4879 TRACE("Typedef offset: %#x\n", offset);
4880 ptr2 = data + offset;
4881 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4882 if (hr != D3D_OK)
4884 WARN("Failed to parse type definition\n");
4885 goto err_out;
4888 read_dword(ptr, &offset);
4889 TRACE("Value offset: %#x\n", offset);
4890 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4891 if (hr != D3D_OK)
4893 WARN("Failed to parse value\n");
4894 goto err_out;
4897 state->parameter = get_parameter_handle(parameter);
4899 return D3D_OK;
4901 err_out:
4903 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4905 return hr;
4908 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4910 DWORD offset;
4911 HRESULT hr;
4912 unsigned int i;
4913 D3DXHANDLE *annotation_handles = NULL;
4914 const char *ptr2;
4916 read_dword(ptr, &offset);
4917 TRACE("Typedef offset: %#x\n", offset);
4918 ptr2 = data + offset;
4920 read_dword(ptr, &offset);
4921 TRACE("Value offset: %#x\n", offset);
4923 read_dword(ptr, &param->flags);
4924 TRACE("Flags: %#x\n", param->flags);
4926 read_dword(ptr, &param->annotation_count);
4927 TRACE("Annotation count: %u\n", param->annotation_count);
4929 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4930 if (hr != D3D_OK)
4932 WARN("Failed to parse type definition\n");
4933 return hr;
4936 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4937 if (hr != D3D_OK)
4939 WARN("Failed to parse value\n");
4940 return hr;
4943 if (param->annotation_count)
4945 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4946 if (!annotation_handles)
4948 ERR("Out of memory\n");
4949 hr = E_OUTOFMEMORY;
4950 goto err_out;
4953 for (i = 0; i < param->annotation_count; ++i)
4955 struct d3dx_parameter *annotation;
4957 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4958 if (!annotation)
4960 ERR("Out of memory\n");
4961 hr = E_OUTOFMEMORY;
4962 goto err_out;
4965 annotation_handles[i] = get_parameter_handle(annotation);
4967 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4968 if (hr != D3D_OK)
4970 WARN("Failed to parse annotation\n");
4971 goto err_out;
4976 param->annotation_handles = annotation_handles;
4978 return D3D_OK;
4980 err_out:
4982 if (annotation_handles)
4984 for (i = 0; i < param->annotation_count; ++i)
4986 free_parameter(annotation_handles[i], FALSE, FALSE);
4988 HeapFree(GetProcessHeap(), 0, annotation_handles);
4991 return hr;
4994 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4996 DWORD offset;
4997 HRESULT hr;
4998 unsigned int i;
4999 D3DXHANDLE *annotation_handles = NULL;
5000 struct d3dx_state *states = NULL;
5001 char *name = NULL;
5003 read_dword(ptr, &offset);
5004 TRACE("Pass name offset: %#x\n", offset);
5005 hr = d3dx9_parse_name(&name, data + offset);
5006 if (hr != D3D_OK)
5008 WARN("Failed to parse name\n");
5009 goto err_out;
5012 read_dword(ptr, &pass->annotation_count);
5013 TRACE("Annotation count: %u\n", pass->annotation_count);
5015 read_dword(ptr, &pass->state_count);
5016 TRACE("State count: %u\n", pass->state_count);
5018 if (pass->annotation_count)
5020 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
5021 if (!annotation_handles)
5023 ERR("Out of memory\n");
5024 hr = E_OUTOFMEMORY;
5025 goto err_out;
5028 for (i = 0; i < pass->annotation_count; ++i)
5030 struct d3dx_parameter *annotation;
5032 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5033 if (!annotation)
5035 ERR("Out of memory\n");
5036 hr = E_OUTOFMEMORY;
5037 goto err_out;
5040 annotation_handles[i] = get_parameter_handle(annotation);
5042 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5043 if (hr != D3D_OK)
5045 WARN("Failed to parse annotations\n");
5046 goto err_out;
5051 if (pass->state_count)
5053 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
5054 if (!states)
5056 ERR("Out of memory\n");
5057 hr = E_OUTOFMEMORY;
5058 goto err_out;
5061 for (i = 0; i < pass->state_count; ++i)
5063 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
5064 if (hr != D3D_OK)
5066 WARN("Failed to parse annotations\n");
5067 goto err_out;
5072 pass->name = name;
5073 pass->annotation_handles = annotation_handles;
5074 pass->states = states;
5076 return D3D_OK;
5078 err_out:
5080 if (annotation_handles)
5082 for (i = 0; i < pass->annotation_count; ++i)
5084 free_parameter(annotation_handles[i], FALSE, FALSE);
5086 HeapFree(GetProcessHeap(), 0, annotation_handles);
5089 if (states)
5091 for (i = 0; i < pass->state_count; ++i)
5093 free_state(&states[i]);
5095 HeapFree(GetProcessHeap(), 0, states);
5098 HeapFree(GetProcessHeap(), 0, name);
5100 return hr;
5103 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
5105 DWORD offset;
5106 HRESULT hr;
5107 unsigned int i;
5108 D3DXHANDLE *annotation_handles = NULL;
5109 D3DXHANDLE *pass_handles = NULL;
5110 char *name = NULL;
5112 read_dword(ptr, &offset);
5113 TRACE("Technique name offset: %#x\n", offset);
5114 hr = d3dx9_parse_name(&name, data + offset);
5115 if (hr != D3D_OK)
5117 WARN("Failed to parse name\n");
5118 goto err_out;
5121 read_dword(ptr, &technique->annotation_count);
5122 TRACE("Annotation count: %u\n", technique->annotation_count);
5124 read_dword(ptr, &technique->pass_count);
5125 TRACE("Pass count: %u\n", technique->pass_count);
5127 if (technique->annotation_count)
5129 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
5130 if (!annotation_handles)
5132 ERR("Out of memory\n");
5133 hr = E_OUTOFMEMORY;
5134 goto err_out;
5137 for (i = 0; i < technique->annotation_count; ++i)
5139 struct d3dx_parameter *annotation;
5141 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5142 if (!annotation)
5144 ERR("Out of memory\n");
5145 hr = E_OUTOFMEMORY;
5146 goto err_out;
5149 annotation_handles[i] = get_parameter_handle(annotation);
5151 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5152 if (hr != D3D_OK)
5154 WARN("Failed to parse annotations\n");
5155 goto err_out;
5160 if (technique->pass_count)
5162 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5163 if (!pass_handles)
5165 ERR("Out of memory\n");
5166 hr = E_OUTOFMEMORY;
5167 goto err_out;
5170 for (i = 0; i < technique->pass_count; ++i)
5172 struct d3dx_pass *pass;
5174 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5175 if (!pass)
5177 ERR("Out of memory\n");
5178 hr = E_OUTOFMEMORY;
5179 goto err_out;
5182 pass_handles[i] = get_pass_handle(pass);
5184 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5185 if (hr != D3D_OK)
5187 WARN("Failed to parse passes\n");
5188 goto err_out;
5193 technique->name = name;
5194 technique->pass_handles = pass_handles;
5195 technique->annotation_handles = annotation_handles;
5197 return D3D_OK;
5199 err_out:
5201 if (pass_handles)
5203 for (i = 0; i < technique->pass_count; ++i)
5205 free_pass(pass_handles[i]);
5207 HeapFree(GetProcessHeap(), 0, pass_handles);
5210 if (annotation_handles)
5212 for (i = 0; i < technique->annotation_count; ++i)
5214 free_parameter(annotation_handles[i], FALSE, FALSE);
5216 HeapFree(GetProcessHeap(), 0, annotation_handles);
5219 HeapFree(GetProcessHeap(), 0, name);
5221 return hr;
5224 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5226 DWORD technique_index;
5227 DWORD index, state_index, usage, element_index;
5228 struct d3dx_state *state;
5229 struct d3dx_parameter *param;
5230 HRESULT hr = E_FAIL;
5232 read_dword(ptr, &technique_index);
5233 TRACE("techn: %u\n", technique_index);
5235 read_dword(ptr, &index);
5236 TRACE("index: %u\n", index);
5238 read_dword(ptr, &element_index);
5239 TRACE("element_index: %u\n", element_index);
5241 read_dword(ptr, &state_index);
5242 TRACE("state_index: %u\n", state_index);
5244 read_dword(ptr, &usage);
5245 TRACE("usage: %u\n", usage);
5247 if (technique_index == 0xffffffff)
5249 struct d3dx_parameter *parameter;
5250 struct d3dx_sampler *sampler;
5252 if (index >= base->parameter_count)
5254 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5255 return E_FAIL;
5258 parameter = get_parameter_struct(base->parameter_handles[index]);
5259 if (element_index != 0xffffffff)
5261 if (element_index >= parameter->element_count && parameter->element_count != 0)
5263 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5264 return E_FAIL;
5267 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5270 sampler = parameter->data;
5271 if (state_index >= sampler->state_count)
5273 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5274 return E_FAIL;
5277 state = &sampler->states[state_index];
5279 else
5281 struct d3dx_technique *technique;
5282 struct d3dx_pass *pass;
5284 if (technique_index >= base->technique_count)
5286 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5287 return E_FAIL;
5290 technique = get_technique_struct(base->technique_handles[technique_index]);
5291 if (index >= technique->pass_count)
5293 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5294 return E_FAIL;
5297 pass = get_pass_struct(technique->pass_handles[index]);
5298 if (state_index >= pass->state_count)
5300 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5301 return E_FAIL;
5304 state = &pass->states[state_index];
5307 param = get_parameter_struct(state->parameter);
5309 switch (usage)
5311 case 0:
5312 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5313 switch (param->type)
5315 case D3DXPT_VERTEXSHADER:
5316 case D3DXPT_PIXELSHADER:
5317 state->type = ST_CONSTANT;
5318 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5319 break;
5321 case D3DXPT_BOOL:
5322 case D3DXPT_INT:
5323 case D3DXPT_FLOAT:
5324 case D3DXPT_STRING:
5325 state->type = ST_FXLC;
5326 hr = d3dx9_copy_data(param->data, ptr);
5327 break;
5329 default:
5330 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5331 break;
5333 break;
5335 case 1:
5336 state->type = ST_PARAMETER;
5337 hr = d3dx9_copy_data(param->data, ptr);
5338 if (hr == D3D_OK)
5340 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5342 break;
5344 default:
5345 FIXME("Unknown usage %x\n", usage);
5346 break;
5349 return hr;
5352 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5354 const char *ptr = data + start;
5355 D3DXHANDLE *parameter_handles = NULL;
5356 D3DXHANDLE *technique_handles = NULL;
5357 D3DXHANDLE *objects = NULL;
5358 UINT stringcount, objectcount, resourcecount;
5359 HRESULT hr;
5360 UINT i;
5362 read_dword(&ptr, &base->parameter_count);
5363 TRACE("Parameter count: %u\n", base->parameter_count);
5365 read_dword(&ptr, &base->technique_count);
5366 TRACE("Technique count: %u\n", base->technique_count);
5368 skip_dword_unknown(&ptr, 1);
5370 read_dword(&ptr, &objectcount);
5371 TRACE("Object count: %u\n", objectcount);
5373 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5374 if (!objects)
5376 ERR("Out of memory\n");
5377 hr = E_OUTOFMEMORY;
5378 goto err_out;
5381 if (base->parameter_count)
5383 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5384 if (!parameter_handles)
5386 ERR("Out of memory\n");
5387 hr = E_OUTOFMEMORY;
5388 goto err_out;
5391 for (i = 0; i < base->parameter_count; ++i)
5393 struct d3dx_parameter *parameter;
5395 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5396 if (!parameter)
5398 ERR("Out of memory\n");
5399 hr = E_OUTOFMEMORY;
5400 goto err_out;
5403 parameter_handles[i] = get_parameter_handle(parameter);
5405 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5406 if (hr != D3D_OK)
5408 WARN("Failed to parse parameter\n");
5409 goto err_out;
5414 if (base->technique_count)
5416 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5417 if (!technique_handles)
5419 ERR("Out of memory\n");
5420 hr = E_OUTOFMEMORY;
5421 goto err_out;
5424 for (i = 0; i < base->technique_count; ++i)
5426 struct d3dx_technique *technique;
5428 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5429 if (!technique)
5431 ERR("Out of memory\n");
5432 hr = E_OUTOFMEMORY;
5433 goto err_out;
5436 technique_handles[i] = get_technique_handle(technique);
5438 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5439 if (hr != D3D_OK)
5441 WARN("Failed to parse technique\n");
5442 goto err_out;
5447 /* needed for further parsing */
5448 base->technique_handles = technique_handles;
5449 base->parameter_handles = parameter_handles;
5451 read_dword(&ptr, &stringcount);
5452 TRACE("String count: %u\n", stringcount);
5454 read_dword(&ptr, &resourcecount);
5455 TRACE("Resource count: %u\n", resourcecount);
5457 for (i = 0; i < stringcount; ++i)
5459 DWORD id;
5460 struct d3dx_parameter *param;
5462 read_dword(&ptr, &id);
5463 TRACE("Id: %u\n", id);
5465 param = get_parameter_struct(objects[id]);
5467 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5468 if (hr != D3D_OK)
5470 WARN("Failed to parse data\n");
5471 goto err_out;
5475 for (i = 0; i < resourcecount; ++i)
5477 TRACE("parse resource %u\n", i);
5479 hr = d3dx9_parse_resource(base, data, &ptr);
5480 if (hr != D3D_OK)
5482 WARN("Failed to parse data\n");
5483 goto err_out;
5487 HeapFree(GetProcessHeap(), 0, objects);
5489 return D3D_OK;
5491 err_out:
5493 if (technique_handles)
5495 for (i = 0; i < base->technique_count; ++i)
5497 free_technique(technique_handles[i]);
5499 HeapFree(GetProcessHeap(), 0, technique_handles);
5502 if (parameter_handles)
5504 for (i = 0; i < base->parameter_count; ++i)
5506 free_parameter(parameter_handles[i], FALSE, FALSE);
5508 HeapFree(GetProcessHeap(), 0, parameter_handles);
5511 base->technique_handles = NULL;
5512 base->parameter_handles = NULL;
5514 HeapFree(GetProcessHeap(), 0, objects);
5516 return hr;
5519 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5520 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5522 DWORD tag, offset;
5523 const char *ptr = data;
5524 HRESULT hr;
5526 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5528 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5529 base->ref = 1;
5530 base->effect = effect;
5532 read_dword(&ptr, &tag);
5533 TRACE("Tag: %x\n", tag);
5535 if (tag != d3dx9_effect_version(9, 1))
5537 /* todo: compile hlsl ascii code */
5538 FIXME("HLSL ascii effects not supported, yet\n");
5540 /* Show the start of the shader for debugging info. */
5541 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5543 else
5545 read_dword(&ptr, &offset);
5546 TRACE("Offset: %x\n", offset);
5548 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5549 if (hr != D3D_OK)
5551 FIXME("Failed to parse effect.\n");
5552 return hr;
5556 return D3D_OK;
5559 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5560 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5562 HRESULT hr;
5563 struct ID3DXBaseEffectImpl *object = NULL;
5565 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5567 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5568 effect->ref = 1;
5570 if (pool) pool->lpVtbl->AddRef(pool);
5571 effect->pool = pool;
5573 IDirect3DDevice9_AddRef(device);
5574 effect->device = device;
5576 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5577 if (!object)
5579 ERR("Out of memory\n");
5580 hr = E_OUTOFMEMORY;
5581 goto err_out;
5584 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5585 if (hr != D3D_OK)
5587 FIXME("Failed to parse effect.\n");
5588 goto err_out;
5591 effect->base_effect = &object->ID3DXBaseEffect_iface;
5593 /* initialize defaults - check because of unsupported ascii effects */
5594 if (object->technique_handles)
5596 effect->active_technique = object->technique_handles[0];
5597 effect->active_pass = NULL;
5600 return D3D_OK;
5602 err_out:
5604 HeapFree(GetProcessHeap(), 0, object);
5605 free_effect(effect);
5607 return hr;
5610 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5611 LPCVOID srcdata,
5612 UINT srcdatalen,
5613 CONST D3DXMACRO* defines,
5614 LPD3DXINCLUDE include,
5615 LPCSTR skip_constants,
5616 DWORD flags,
5617 LPD3DXEFFECTPOOL pool,
5618 LPD3DXEFFECT* effect,
5619 LPD3DXBUFFER* compilation_errors)
5621 struct ID3DXEffectImpl *object;
5622 HRESULT hr;
5624 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5625 skip_constants, flags, pool, effect, compilation_errors);
5627 if (!device || !srcdata)
5628 return D3DERR_INVALIDCALL;
5630 if (!srcdatalen)
5631 return E_FAIL;
5633 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5634 if (!effect)
5635 return D3D_OK;
5637 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5638 if (!object)
5640 ERR("Out of memory\n");
5641 return E_OUTOFMEMORY;
5644 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5645 if (FAILED(hr))
5647 WARN("Failed to initialize shader reflection\n");
5648 HeapFree(GetProcessHeap(), 0, object);
5649 return hr;
5652 *effect = &object->ID3DXEffect_iface;
5654 TRACE("Created ID3DXEffect %p\n", object);
5656 return D3D_OK;
5659 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5660 LPCVOID srcdata,
5661 UINT srcdatalen,
5662 CONST D3DXMACRO* defines,
5663 LPD3DXINCLUDE include,
5664 DWORD flags,
5665 LPD3DXEFFECTPOOL pool,
5666 LPD3DXEFFECT* effect,
5667 LPD3DXBUFFER* compilation_errors)
5669 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5670 include, flags, pool, effect, compilation_errors);
5672 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5675 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5677 HRESULT hr;
5678 struct ID3DXBaseEffectImpl *object = NULL;
5680 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5682 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5683 compiler->ref = 1;
5685 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5686 if (!object)
5688 ERR("Out of memory\n");
5689 hr = E_OUTOFMEMORY;
5690 goto err_out;
5693 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5694 if (hr != D3D_OK)
5696 FIXME("Failed to parse effect.\n");
5697 goto err_out;
5700 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5702 return D3D_OK;
5704 err_out:
5706 HeapFree(GetProcessHeap(), 0, object);
5707 free_effect_compiler(compiler);
5709 return hr;
5712 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5713 UINT srcdatalen,
5714 CONST D3DXMACRO *defines,
5715 LPD3DXINCLUDE include,
5716 DWORD flags,
5717 LPD3DXEFFECTCOMPILER *compiler,
5718 LPD3DXBUFFER *parse_errors)
5720 struct ID3DXEffectCompilerImpl *object;
5721 HRESULT hr;
5723 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5724 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5726 if (!srcdata || !compiler)
5728 WARN("Invalid arguments supplied\n");
5729 return D3DERR_INVALIDCALL;
5732 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5733 if (!object)
5735 ERR("Out of memory\n");
5736 return E_OUTOFMEMORY;
5739 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5740 if (FAILED(hr))
5742 WARN("Failed to initialize effect compiler\n");
5743 HeapFree(GetProcessHeap(), 0, object);
5744 return hr;
5747 *compiler = &object->ID3DXEffectCompiler_iface;
5749 TRACE("Created ID3DXEffectCompiler %p\n", object);
5751 return D3D_OK;
5754 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5756 struct ID3DXEffectPoolImpl
5758 ID3DXEffectPool ID3DXEffectPool_iface;
5759 LONG ref;
5762 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5764 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5767 /*** IUnknown methods ***/
5768 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5770 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5772 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5774 if (IsEqualGUID(riid, &IID_IUnknown) ||
5775 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5777 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5778 *object = This;
5779 return S_OK;
5782 WARN("Interface %s not found\n", debugstr_guid(riid));
5784 return E_NOINTERFACE;
5787 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5789 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5791 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5793 return InterlockedIncrement(&This->ref);
5796 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5798 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5799 ULONG ref = InterlockedDecrement(&This->ref);
5801 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5803 if (!ref)
5804 HeapFree(GetProcessHeap(), 0, This);
5806 return ref;
5809 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5811 /*** IUnknown methods ***/
5812 ID3DXEffectPoolImpl_QueryInterface,
5813 ID3DXEffectPoolImpl_AddRef,
5814 ID3DXEffectPoolImpl_Release
5817 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5819 struct ID3DXEffectPoolImpl *object;
5821 TRACE("(%p)\n", pool);
5823 if (!pool)
5824 return D3DERR_INVALIDCALL;
5826 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5827 if (!object)
5829 ERR("Out of memory\n");
5830 return E_OUTOFMEMORY;
5833 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5834 object->ref = 1;
5836 *pool = &object->ID3DXEffectPool_iface;
5838 return S_OK;
5841 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5842 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5843 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5845 LPVOID buffer;
5846 HRESULT ret;
5847 DWORD size;
5849 TRACE("(%s): relay\n", debugstr_w(srcfile));
5851 if (!device || !srcfile)
5852 return D3DERR_INVALIDCALL;
5854 ret = map_view_of_file(srcfile, &buffer, &size);
5856 if (FAILED(ret))
5857 return D3DXERR_INVALIDDATA;
5859 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5860 UnmapViewOfFile(buffer);
5862 return ret;
5865 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5866 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5867 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5869 LPWSTR srcfileW;
5870 HRESULT ret;
5871 DWORD len;
5873 TRACE("(void): relay\n");
5875 if (!srcfile)
5876 return D3DERR_INVALIDCALL;
5878 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5879 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5880 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5882 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5883 HeapFree(GetProcessHeap(), 0, srcfileW);
5885 return ret;
5888 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5889 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5890 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5892 TRACE("(void): relay\n");
5893 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5896 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5897 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5898 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5900 TRACE("(void): relay\n");
5901 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5904 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5905 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5906 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5908 HRSRC resinfo;
5910 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5912 if (!device)
5913 return D3DERR_INVALIDCALL;
5915 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5917 if (resinfo)
5919 LPVOID buffer;
5920 HRESULT ret;
5921 DWORD size;
5923 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5925 if (FAILED(ret))
5926 return D3DXERR_INVALIDDATA;
5928 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5931 return D3DXERR_INVALIDDATA;
5934 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5935 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5936 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5938 HRSRC resinfo;
5940 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5942 if (!device)
5943 return D3DERR_INVALIDCALL;
5945 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5947 if (resinfo)
5949 LPVOID buffer;
5950 HRESULT ret;
5951 DWORD size;
5953 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5955 if (FAILED(ret))
5956 return D3DXERR_INVALIDDATA;
5958 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5961 return D3DXERR_INVALIDDATA;
5964 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5965 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5966 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5968 TRACE("(void): relay\n");
5969 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5972 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5973 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5974 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5976 TRACE("(void): relay\n");
5977 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5980 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5981 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5983 LPVOID buffer;
5984 HRESULT ret;
5985 DWORD size;
5987 TRACE("(%s): relay\n", debugstr_w(srcfile));
5989 if (!srcfile)
5990 return D3DERR_INVALIDCALL;
5992 ret = map_view_of_file(srcfile, &buffer, &size);
5994 if (FAILED(ret))
5995 return D3DXERR_INVALIDDATA;
5997 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5998 UnmapViewOfFile(buffer);
6000 return ret;
6003 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6004 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6006 LPWSTR srcfileW;
6007 HRESULT ret;
6008 DWORD len;
6010 TRACE("(void): relay\n");
6012 if (!srcfile)
6013 return D3DERR_INVALIDCALL;
6015 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6016 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6017 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6019 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
6020 HeapFree(GetProcessHeap(), 0, srcfileW);
6022 return ret;
6025 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
6026 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6028 HRSRC resinfo;
6030 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6032 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6034 if (resinfo)
6036 LPVOID buffer;
6037 HRESULT ret;
6038 DWORD size;
6040 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6042 if (FAILED(ret))
6043 return D3DXERR_INVALIDDATA;
6045 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6048 return D3DXERR_INVALIDDATA;
6051 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
6052 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6054 HRSRC resinfo;
6056 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6058 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6060 if (resinfo)
6062 LPVOID buffer;
6063 HRESULT ret;
6064 DWORD size;
6066 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6068 if (FAILED(ret))
6069 return D3DXERR_INVALIDDATA;
6071 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6074 return D3DXERR_INVALIDDATA;