d3dx9: Implement ID3DXBaseEffect::SetMatrixArray().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blob4d0818008b47be62a96c23a8a7e4c1889922cfd7
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);
2261 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
2263 return E_NOTIMPL;
2266 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2268 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2269 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2270 D3DXMATRIX m;
2272 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2274 if (matrix && param && !param->element_count)
2276 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2278 switch (param->class)
2280 case D3DXPC_SCALAR:
2281 case D3DXPC_VECTOR:
2282 get_matrix(param, matrix);
2283 return D3D_OK;
2285 case D3DXPC_MATRIX_ROWS:
2286 get_matrix(param, &m);
2287 D3DXMatrixTranspose(matrix, &m);
2288 return D3D_OK;
2290 case D3DXPC_OBJECT:
2291 case D3DXPC_STRUCT:
2292 break;
2294 default:
2295 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2296 break;
2300 WARN("Invalid argument specified\n");
2302 return D3DERR_INVALIDCALL;
2305 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2307 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2309 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2311 return E_NOTIMPL;
2314 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2316 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2317 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2319 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2321 if (!count) return D3D_OK;
2323 if (matrix && param && count <= param->element_count)
2325 UINT i;
2327 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2329 switch (param->class)
2331 case D3DXPC_MATRIX_ROWS:
2332 for (i = 0; i < count; ++i)
2334 D3DXMATRIX m;
2336 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2337 D3DXMatrixTranspose(&matrix[i], &m);
2339 return D3D_OK;
2341 case D3DXPC_SCALAR:
2342 case D3DXPC_VECTOR:
2343 case D3DXPC_OBJECT:
2344 case D3DXPC_STRUCT:
2345 break;
2347 default:
2348 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2349 break;
2353 WARN("Invalid argument specified\n");
2355 return D3DERR_INVALIDCALL;
2358 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2360 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2362 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2364 return E_NOTIMPL;
2367 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2369 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2371 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2373 return E_NOTIMPL;
2376 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2378 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2380 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2382 return E_NOTIMPL;
2385 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2387 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2388 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2390 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2392 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2394 *string = *(LPCSTR *)param->data;
2395 TRACE("Returning %s\n", debugstr_a(*string));
2396 return D3D_OK;
2399 WARN("Invalid argument specified\n");
2401 return D3DERR_INVALIDCALL;
2404 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2406 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2407 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2409 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2411 if (param && !param->element_count &&
2412 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2413 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2414 || param->type == D3DXPT_TEXTURECUBE))
2416 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2418 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2419 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2421 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2423 return D3D_OK;
2426 WARN("Invalid argument specified\n");
2428 return D3DERR_INVALIDCALL;
2431 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2433 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2434 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2436 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2438 if (texture && param && !param->element_count &&
2439 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2440 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2441 || param->type == D3DXPT_TEXTURECUBE))
2443 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2444 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2445 TRACE("Returning %p\n", *texture);
2446 return D3D_OK;
2449 WARN("Invalid argument specified\n");
2451 return D3DERR_INVALIDCALL;
2454 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2456 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2457 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2459 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2461 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2463 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2464 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2465 TRACE("Returning %p\n", *pshader);
2466 return D3D_OK;
2469 WARN("Invalid argument specified\n");
2471 return D3DERR_INVALIDCALL;
2474 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2476 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2477 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2479 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2481 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2483 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2484 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2485 TRACE("Returning %p\n", *vshader);
2486 return D3D_OK;
2489 WARN("Invalid argument specified\n");
2491 return D3DERR_INVALIDCALL;
2494 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2496 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2498 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2500 return E_NOTIMPL;
2503 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2505 /*** IUnknown methods ***/
2506 ID3DXBaseEffectImpl_QueryInterface,
2507 ID3DXBaseEffectImpl_AddRef,
2508 ID3DXBaseEffectImpl_Release,
2509 /*** ID3DXBaseEffect methods ***/
2510 ID3DXBaseEffectImpl_GetDesc,
2511 ID3DXBaseEffectImpl_GetParameterDesc,
2512 ID3DXBaseEffectImpl_GetTechniqueDesc,
2513 ID3DXBaseEffectImpl_GetPassDesc,
2514 ID3DXBaseEffectImpl_GetFunctionDesc,
2515 ID3DXBaseEffectImpl_GetParameter,
2516 ID3DXBaseEffectImpl_GetParameterByName,
2517 ID3DXBaseEffectImpl_GetParameterBySemantic,
2518 ID3DXBaseEffectImpl_GetParameterElement,
2519 ID3DXBaseEffectImpl_GetTechnique,
2520 ID3DXBaseEffectImpl_GetTechniqueByName,
2521 ID3DXBaseEffectImpl_GetPass,
2522 ID3DXBaseEffectImpl_GetPassByName,
2523 ID3DXBaseEffectImpl_GetFunction,
2524 ID3DXBaseEffectImpl_GetFunctionByName,
2525 ID3DXBaseEffectImpl_GetAnnotation,
2526 ID3DXBaseEffectImpl_GetAnnotationByName,
2527 ID3DXBaseEffectImpl_SetValue,
2528 ID3DXBaseEffectImpl_GetValue,
2529 ID3DXBaseEffectImpl_SetBool,
2530 ID3DXBaseEffectImpl_GetBool,
2531 ID3DXBaseEffectImpl_SetBoolArray,
2532 ID3DXBaseEffectImpl_GetBoolArray,
2533 ID3DXBaseEffectImpl_SetInt,
2534 ID3DXBaseEffectImpl_GetInt,
2535 ID3DXBaseEffectImpl_SetIntArray,
2536 ID3DXBaseEffectImpl_GetIntArray,
2537 ID3DXBaseEffectImpl_SetFloat,
2538 ID3DXBaseEffectImpl_GetFloat,
2539 ID3DXBaseEffectImpl_SetFloatArray,
2540 ID3DXBaseEffectImpl_GetFloatArray,
2541 ID3DXBaseEffectImpl_SetVector,
2542 ID3DXBaseEffectImpl_GetVector,
2543 ID3DXBaseEffectImpl_SetVectorArray,
2544 ID3DXBaseEffectImpl_GetVectorArray,
2545 ID3DXBaseEffectImpl_SetMatrix,
2546 ID3DXBaseEffectImpl_GetMatrix,
2547 ID3DXBaseEffectImpl_SetMatrixArray,
2548 ID3DXBaseEffectImpl_GetMatrixArray,
2549 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2550 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2551 ID3DXBaseEffectImpl_SetMatrixTranspose,
2552 ID3DXBaseEffectImpl_GetMatrixTranspose,
2553 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2554 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2555 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2556 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2557 ID3DXBaseEffectImpl_SetString,
2558 ID3DXBaseEffectImpl_GetString,
2559 ID3DXBaseEffectImpl_SetTexture,
2560 ID3DXBaseEffectImpl_GetTexture,
2561 ID3DXBaseEffectImpl_GetPixelShader,
2562 ID3DXBaseEffectImpl_GetVertexShader,
2563 ID3DXBaseEffectImpl_SetArrayRange,
2566 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2568 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2571 /*** IUnknown methods ***/
2572 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2574 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2576 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2578 if (IsEqualGUID(riid, &IID_IUnknown) ||
2579 IsEqualGUID(riid, &IID_ID3DXEffect))
2581 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2582 *object = This;
2583 return S_OK;
2586 ERR("Interface %s not found\n", debugstr_guid(riid));
2588 return E_NOINTERFACE;
2591 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2593 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2595 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2597 return InterlockedIncrement(&This->ref);
2600 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2602 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2603 ULONG ref = InterlockedDecrement(&This->ref);
2605 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2607 if (!ref)
2609 free_effect(This);
2610 HeapFree(GetProcessHeap(), 0, This);
2613 return ref;
2616 /*** ID3DXBaseEffect methods ***/
2617 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2619 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2620 ID3DXBaseEffect *base = This->base_effect;
2622 TRACE("Forward iface %p, base %p\n", This, base);
2624 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2627 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2629 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2630 ID3DXBaseEffect *base = This->base_effect;
2632 TRACE("Forward iface %p, base %p\n", This, base);
2634 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2637 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2639 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2640 ID3DXBaseEffect *base = This->base_effect;
2642 TRACE("Forward iface %p, base %p\n", This, base);
2644 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2647 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2649 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2650 ID3DXBaseEffect *base = This->base_effect;
2652 TRACE("Forward iface %p, base %p\n", This, base);
2654 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2657 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2659 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2660 ID3DXBaseEffect *base = This->base_effect;
2662 TRACE("Forward iface %p, base %p\n", This, base);
2664 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2667 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2669 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2670 ID3DXBaseEffect *base = This->base_effect;
2672 TRACE("Forward iface %p, base %p\n", This, base);
2674 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2677 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2679 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2680 ID3DXBaseEffect *base = This->base_effect;
2682 TRACE("Forward iface %p, base %p\n", This, base);
2684 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2687 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2689 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2690 ID3DXBaseEffect *base = This->base_effect;
2692 TRACE("Forward iface %p, base %p\n", This, base);
2694 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2697 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2699 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2700 ID3DXBaseEffect *base = This->base_effect;
2702 TRACE("Forward iface %p, base %p\n", This, base);
2704 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2707 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2709 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2710 ID3DXBaseEffect *base = This->base_effect;
2712 TRACE("Forward iface %p, base %p\n", This, base);
2714 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2717 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2719 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2720 ID3DXBaseEffect *base = This->base_effect;
2722 TRACE("Forward iface %p, base %p\n", This, base);
2724 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2727 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2729 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2730 ID3DXBaseEffect *base = This->base_effect;
2732 TRACE("Forward iface %p, base %p\n", This, base);
2734 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2737 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2739 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2740 ID3DXBaseEffect *base = This->base_effect;
2742 TRACE("Forward iface %p, base %p\n", This, base);
2744 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2747 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2749 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2750 ID3DXBaseEffect *base = This->base_effect;
2752 TRACE("Forward iface %p, base %p\n", This, base);
2754 return ID3DXBaseEffectImpl_GetFunction(base, index);
2757 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2759 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2760 ID3DXBaseEffect *base = This->base_effect;
2762 TRACE("Forward iface %p, base %p\n", This, base);
2764 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2767 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2769 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2770 ID3DXBaseEffect *base = This->base_effect;
2772 TRACE("Forward iface %p, base %p\n", This, base);
2774 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2777 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2779 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2780 ID3DXBaseEffect *base = This->base_effect;
2782 TRACE("Forward iface %p, base %p\n", This, base);
2784 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2787 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2789 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2790 ID3DXBaseEffect *base = This->base_effect;
2792 TRACE("Forward iface %p, base %p\n", This, base);
2794 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2797 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2799 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2800 ID3DXBaseEffect *base = This->base_effect;
2802 TRACE("Forward iface %p, base %p\n", This, base);
2804 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2807 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2809 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2810 ID3DXBaseEffect *base = This->base_effect;
2812 TRACE("Forward iface %p, base %p\n", This, base);
2814 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2817 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2819 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2820 ID3DXBaseEffect *base = This->base_effect;
2822 TRACE("Forward iface %p, base %p\n", This, base);
2824 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2827 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2829 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2830 ID3DXBaseEffect *base = This->base_effect;
2832 TRACE("Forward iface %p, base %p\n", This, base);
2834 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2837 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2839 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2840 ID3DXBaseEffect *base = This->base_effect;
2842 TRACE("Forward iface %p, base %p\n", This, base);
2844 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2847 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2849 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2850 ID3DXBaseEffect *base = This->base_effect;
2852 TRACE("Forward iface %p, base %p\n", This, base);
2854 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2857 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2859 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2860 ID3DXBaseEffect *base = This->base_effect;
2862 TRACE("Forward iface %p, base %p\n", This, base);
2864 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2867 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2869 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2870 ID3DXBaseEffect *base = This->base_effect;
2872 TRACE("Forward iface %p, base %p\n", This, base);
2874 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2877 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2879 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2880 ID3DXBaseEffect *base = This->base_effect;
2882 TRACE("Forward iface %p, base %p\n", This, base);
2884 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2887 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2889 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2890 ID3DXBaseEffect *base = This->base_effect;
2892 TRACE("Forward iface %p, base %p\n", This, base);
2894 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2897 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2899 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2900 ID3DXBaseEffect *base = This->base_effect;
2902 TRACE("Forward iface %p, base %p\n", This, base);
2904 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2907 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2909 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2910 ID3DXBaseEffect *base = This->base_effect;
2912 TRACE("Forward iface %p, base %p\n", This, base);
2914 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2917 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2919 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2920 ID3DXBaseEffect *base = This->base_effect;
2922 TRACE("Forward iface %p, base %p\n", This, base);
2924 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2927 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2929 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2930 ID3DXBaseEffect *base = This->base_effect;
2932 TRACE("Forward iface %p, base %p\n", This, base);
2934 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2937 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2939 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2940 ID3DXBaseEffect *base = This->base_effect;
2942 TRACE("Forward iface %p, base %p\n", This, base);
2944 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2947 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2949 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2950 ID3DXBaseEffect *base = This->base_effect;
2952 TRACE("Forward iface %p, base %p\n", This, base);
2954 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2957 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2959 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2960 ID3DXBaseEffect *base = This->base_effect;
2962 TRACE("Forward iface %p, base %p\n", This, base);
2964 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2967 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2969 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2970 ID3DXBaseEffect *base = This->base_effect;
2972 TRACE("Forward iface %p, base %p\n", This, base);
2974 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2977 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2979 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2980 ID3DXBaseEffect *base = This->base_effect;
2982 TRACE("Forward iface %p, base %p\n", This, base);
2984 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2987 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2989 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2990 ID3DXBaseEffect *base = This->base_effect;
2992 TRACE("Forward iface %p, base %p\n", This, base);
2994 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2997 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2999 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3000 ID3DXBaseEffect *base = This->base_effect;
3002 TRACE("Forward iface %p, base %p\n", This, base);
3004 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3007 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3009 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3010 ID3DXBaseEffect *base = This->base_effect;
3012 TRACE("Forward iface %p, base %p\n", This, base);
3014 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3017 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3019 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3020 ID3DXBaseEffect *base = This->base_effect;
3022 TRACE("Forward iface %p, base %p\n", This, base);
3024 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3027 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3029 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3030 ID3DXBaseEffect *base = This->base_effect;
3032 TRACE("Forward iface %p, base %p\n", This, base);
3034 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3037 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3039 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3040 ID3DXBaseEffect *base = This->base_effect;
3042 TRACE("Forward iface %p, base %p\n", This, base);
3044 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3047 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3049 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3050 ID3DXBaseEffect *base = This->base_effect;
3052 TRACE("Forward iface %p, base %p\n", This, base);
3054 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3057 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3059 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3060 ID3DXBaseEffect *base = This->base_effect;
3062 TRACE("Forward iface %p, base %p\n", This, base);
3064 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3067 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3069 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3070 ID3DXBaseEffect *base = This->base_effect;
3072 TRACE("Forward iface %p, base %p\n", This, base);
3074 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3077 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3079 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3080 ID3DXBaseEffect *base = This->base_effect;
3082 TRACE("Forward iface %p, base %p\n", This, base);
3084 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3087 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
3089 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3090 ID3DXBaseEffect *base = This->base_effect;
3092 TRACE("Forward iface %p, base %p\n", This, base);
3094 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3097 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3099 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3100 ID3DXBaseEffect *base = This->base_effect;
3102 TRACE("Forward iface %p, base %p\n", This, base);
3104 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3107 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3109 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3110 ID3DXBaseEffect *base = This->base_effect;
3112 TRACE("Forward iface %p, base %p\n", This, base);
3114 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3117 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3119 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3120 ID3DXBaseEffect *base = This->base_effect;
3122 TRACE("Forward iface %p, base %p\n", This, base);
3124 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3127 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3129 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3130 ID3DXBaseEffect *base = This->base_effect;
3132 TRACE("Forward iface %p, base %p\n", This, base);
3134 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3137 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3139 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3140 ID3DXBaseEffect *base = This->base_effect;
3142 TRACE("Forward iface %p, base %p\n", This, base);
3144 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3147 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3149 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3150 ID3DXBaseEffect *base = This->base_effect;
3152 TRACE("Forward iface %p, base %p\n", This, base);
3154 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3157 /*** ID3DXEffect methods ***/
3158 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
3160 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3162 TRACE("iface %p, pool %p\n", This, pool);
3164 if (!pool)
3166 WARN("Invalid argument supplied.\n");
3167 return D3DERR_INVALIDCALL;
3170 if (This->pool)
3172 This->pool->lpVtbl->AddRef(This->pool);
3175 *pool = This->pool;
3177 TRACE("Returning pool %p\n", *pool);
3179 return S_OK;
3182 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3184 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3185 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3186 struct d3dx_technique *tech = is_valid_technique(base, technique);
3188 TRACE("iface %p, technique %p\n", This, technique);
3190 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
3192 if (tech)
3194 UINT i;
3196 for (i = 0; i < base->technique_count; ++i)
3198 struct d3dx_technique *t = get_technique_struct(base->technique_handles[i]);
3200 if (tech == t)
3202 This->active_technique = get_technique_handle(t);
3203 TRACE("Technique %u (%p)\n", i, tech);
3204 return D3D_OK;
3209 WARN("Invalid argument supplied.\n");
3211 return D3DERR_INVALIDCALL;
3214 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3216 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3218 TRACE("iface %p\n", This);
3220 return This->active_technique;
3223 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3225 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3227 FIXME("(%p)->(%p): stub\n", This, technique);
3229 return D3D_OK;
3232 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3234 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3236 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3238 return E_NOTIMPL;
3241 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3243 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3245 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3247 return FALSE;
3250 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3252 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3253 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3255 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3257 if (passes && technique)
3259 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3261 TRACE("State capturing disabled.\n");
3263 else
3265 FIXME("State capturing not supported, yet!\n");
3268 *passes = technique->pass_count;
3270 return D3D_OK;
3273 WARN("Invalid argument supplied.\n");
3275 return D3DERR_INVALIDCALL;
3278 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3280 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3281 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3283 TRACE("iface %p, pass %u\n", This, pass);
3285 if (technique && pass < technique->pass_count && !This->active_pass)
3287 This->active_pass = technique->pass_handles[pass];
3289 FIXME("No states applied, yet!\n");
3291 return D3D_OK;
3294 WARN("Invalid argument supplied.\n");
3296 return D3DERR_INVALIDCALL;
3299 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3301 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3303 FIXME("(%p)->(): stub\n", This);
3305 return E_NOTIMPL;
3308 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3310 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3312 TRACE("iface %p\n", This);
3314 if (This->active_pass)
3316 This->active_pass = NULL;
3317 return D3D_OK;
3320 WARN("Invalid call.\n");
3322 return D3DERR_INVALIDCALL;
3325 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3327 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3329 FIXME("(%p)->(): stub\n", This);
3331 return E_NOTIMPL;
3334 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3336 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3338 TRACE("iface %p, device %p\n", This, device);
3340 if (!device)
3342 WARN("Invalid argument supplied.\n");
3343 return D3DERR_INVALIDCALL;
3346 IDirect3DDevice9_AddRef(This->device);
3348 *device = This->device;
3350 TRACE("Returning device %p\n", *device);
3352 return S_OK;
3355 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3357 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3359 FIXME("(%p)->(): stub\n", This);
3361 return E_NOTIMPL;
3364 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3366 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3368 FIXME("(%p)->(): stub\n", This);
3370 return E_NOTIMPL;
3373 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3375 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3377 TRACE("iface %p, manager %p\n", This, manager);
3379 if (manager) IUnknown_AddRef(manager);
3380 if (This->manager) IUnknown_Release(This->manager);
3382 This->manager = manager;
3384 return D3D_OK;
3387 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3389 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3391 TRACE("iface %p, manager %p\n", This, manager);
3393 if (!manager)
3395 WARN("Invalid argument supplied.\n");
3396 return D3DERR_INVALIDCALL;
3399 if (This->manager) IUnknown_AddRef(This->manager);
3400 *manager = This->manager;
3402 return D3D_OK;
3405 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3407 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3409 FIXME("(%p)->(): stub\n", This);
3411 return E_NOTIMPL;
3414 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3416 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3418 FIXME("(%p)->(): stub\n", This);
3420 return NULL;
3423 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3425 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3427 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3429 return E_NOTIMPL;
3432 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3434 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3436 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3438 return E_NOTIMPL;
3441 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3443 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3445 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3447 return E_NOTIMPL;
3450 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3452 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3454 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3456 return E_NOTIMPL;
3459 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3461 /*** IUnknown methods ***/
3462 ID3DXEffectImpl_QueryInterface,
3463 ID3DXEffectImpl_AddRef,
3464 ID3DXEffectImpl_Release,
3465 /*** ID3DXBaseEffect methods ***/
3466 ID3DXEffectImpl_GetDesc,
3467 ID3DXEffectImpl_GetParameterDesc,
3468 ID3DXEffectImpl_GetTechniqueDesc,
3469 ID3DXEffectImpl_GetPassDesc,
3470 ID3DXEffectImpl_GetFunctionDesc,
3471 ID3DXEffectImpl_GetParameter,
3472 ID3DXEffectImpl_GetParameterByName,
3473 ID3DXEffectImpl_GetParameterBySemantic,
3474 ID3DXEffectImpl_GetParameterElement,
3475 ID3DXEffectImpl_GetTechnique,
3476 ID3DXEffectImpl_GetTechniqueByName,
3477 ID3DXEffectImpl_GetPass,
3478 ID3DXEffectImpl_GetPassByName,
3479 ID3DXEffectImpl_GetFunction,
3480 ID3DXEffectImpl_GetFunctionByName,
3481 ID3DXEffectImpl_GetAnnotation,
3482 ID3DXEffectImpl_GetAnnotationByName,
3483 ID3DXEffectImpl_SetValue,
3484 ID3DXEffectImpl_GetValue,
3485 ID3DXEffectImpl_SetBool,
3486 ID3DXEffectImpl_GetBool,
3487 ID3DXEffectImpl_SetBoolArray,
3488 ID3DXEffectImpl_GetBoolArray,
3489 ID3DXEffectImpl_SetInt,
3490 ID3DXEffectImpl_GetInt,
3491 ID3DXEffectImpl_SetIntArray,
3492 ID3DXEffectImpl_GetIntArray,
3493 ID3DXEffectImpl_SetFloat,
3494 ID3DXEffectImpl_GetFloat,
3495 ID3DXEffectImpl_SetFloatArray,
3496 ID3DXEffectImpl_GetFloatArray,
3497 ID3DXEffectImpl_SetVector,
3498 ID3DXEffectImpl_GetVector,
3499 ID3DXEffectImpl_SetVectorArray,
3500 ID3DXEffectImpl_GetVectorArray,
3501 ID3DXEffectImpl_SetMatrix,
3502 ID3DXEffectImpl_GetMatrix,
3503 ID3DXEffectImpl_SetMatrixArray,
3504 ID3DXEffectImpl_GetMatrixArray,
3505 ID3DXEffectImpl_SetMatrixPointerArray,
3506 ID3DXEffectImpl_GetMatrixPointerArray,
3507 ID3DXEffectImpl_SetMatrixTranspose,
3508 ID3DXEffectImpl_GetMatrixTranspose,
3509 ID3DXEffectImpl_SetMatrixTransposeArray,
3510 ID3DXEffectImpl_GetMatrixTransposeArray,
3511 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3512 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3513 ID3DXEffectImpl_SetString,
3514 ID3DXEffectImpl_GetString,
3515 ID3DXEffectImpl_SetTexture,
3516 ID3DXEffectImpl_GetTexture,
3517 ID3DXEffectImpl_GetPixelShader,
3518 ID3DXEffectImpl_GetVertexShader,
3519 ID3DXEffectImpl_SetArrayRange,
3520 /*** ID3DXEffect methods ***/
3521 ID3DXEffectImpl_GetPool,
3522 ID3DXEffectImpl_SetTechnique,
3523 ID3DXEffectImpl_GetCurrentTechnique,
3524 ID3DXEffectImpl_ValidateTechnique,
3525 ID3DXEffectImpl_FindNextValidTechnique,
3526 ID3DXEffectImpl_IsParameterUsed,
3527 ID3DXEffectImpl_Begin,
3528 ID3DXEffectImpl_BeginPass,
3529 ID3DXEffectImpl_CommitChanges,
3530 ID3DXEffectImpl_EndPass,
3531 ID3DXEffectImpl_End,
3532 ID3DXEffectImpl_GetDevice,
3533 ID3DXEffectImpl_OnLostDevice,
3534 ID3DXEffectImpl_OnResetDevice,
3535 ID3DXEffectImpl_SetStateManager,
3536 ID3DXEffectImpl_GetStateManager,
3537 ID3DXEffectImpl_BeginParameterBlock,
3538 ID3DXEffectImpl_EndParameterBlock,
3539 ID3DXEffectImpl_ApplyParameterBlock,
3540 ID3DXEffectImpl_DeleteParameterBlock,
3541 ID3DXEffectImpl_CloneEffect,
3542 ID3DXEffectImpl_SetRawValue
3545 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3547 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3550 /*** IUnknown methods ***/
3551 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3553 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3555 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3557 if (IsEqualGUID(riid, &IID_IUnknown) ||
3558 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3560 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3561 *object = This;
3562 return S_OK;
3565 ERR("Interface %s not found\n", debugstr_guid(riid));
3567 return E_NOINTERFACE;
3570 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3572 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3574 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3576 return InterlockedIncrement(&This->ref);
3579 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3581 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3582 ULONG ref = InterlockedDecrement(&This->ref);
3584 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3586 if (!ref)
3588 free_effect_compiler(This);
3589 HeapFree(GetProcessHeap(), 0, This);
3592 return ref;
3595 /*** ID3DXBaseEffect methods ***/
3596 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3598 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3599 ID3DXBaseEffect *base = This->base_effect;
3601 TRACE("Forward iface %p, base %p\n", This, base);
3603 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3606 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3608 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3609 ID3DXBaseEffect *base = This->base_effect;
3611 TRACE("Forward iface %p, base %p\n", This, base);
3613 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3616 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3618 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3619 ID3DXBaseEffect *base = This->base_effect;
3621 TRACE("Forward iface %p, base %p\n", This, base);
3623 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3626 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3628 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3629 ID3DXBaseEffect *base = This->base_effect;
3631 TRACE("Forward iface %p, base %p\n", This, base);
3633 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3636 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3638 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3639 ID3DXBaseEffect *base = This->base_effect;
3641 TRACE("Forward iface %p, base %p\n", This, base);
3643 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3646 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3648 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3649 ID3DXBaseEffect *base = This->base_effect;
3651 TRACE("Forward iface %p, base %p\n", This, base);
3653 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3656 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3658 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3659 ID3DXBaseEffect *base = This->base_effect;
3661 TRACE("Forward iface %p, base %p\n", This, base);
3663 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3666 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3668 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3669 ID3DXBaseEffect *base = This->base_effect;
3671 TRACE("Forward iface %p, base %p\n", This, base);
3673 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3676 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3678 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3679 ID3DXBaseEffect *base = This->base_effect;
3681 TRACE("Forward iface %p, base %p\n", This, base);
3683 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3686 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3688 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3689 ID3DXBaseEffect *base = This->base_effect;
3691 TRACE("Forward iface %p, base %p\n", This, base);
3693 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3696 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3698 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3699 ID3DXBaseEffect *base = This->base_effect;
3701 TRACE("Forward iface %p, base %p\n", This, base);
3703 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3706 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3708 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3709 ID3DXBaseEffect *base = This->base_effect;
3711 TRACE("Forward iface %p, base %p\n", This, base);
3713 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3716 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3718 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3719 ID3DXBaseEffect *base = This->base_effect;
3721 TRACE("Forward iface %p, base %p\n", This, base);
3723 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3726 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3728 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3729 ID3DXBaseEffect *base = This->base_effect;
3731 TRACE("Forward iface %p, base %p\n", This, base);
3733 return ID3DXBaseEffectImpl_GetFunction(base, index);
3736 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3738 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3739 ID3DXBaseEffect *base = This->base_effect;
3741 TRACE("Forward iface %p, base %p\n", This, base);
3743 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3746 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3748 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3749 ID3DXBaseEffect *base = This->base_effect;
3751 TRACE("Forward iface %p, base %p\n", This, base);
3753 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3756 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3758 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3759 ID3DXBaseEffect *base = This->base_effect;
3761 TRACE("Forward iface %p, base %p\n", This, base);
3763 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3766 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3768 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3769 ID3DXBaseEffect *base = This->base_effect;
3771 TRACE("Forward iface %p, base %p\n", This, base);
3773 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3776 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3778 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3779 ID3DXBaseEffect *base = This->base_effect;
3781 TRACE("Forward iface %p, base %p\n", This, base);
3783 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3786 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3788 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3789 ID3DXBaseEffect *base = This->base_effect;
3791 TRACE("Forward iface %p, base %p\n", This, base);
3793 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3796 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3798 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3799 ID3DXBaseEffect *base = This->base_effect;
3801 TRACE("Forward iface %p, base %p\n", This, base);
3803 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3806 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3808 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3809 ID3DXBaseEffect *base = This->base_effect;
3811 TRACE("Forward iface %p, base %p\n", This, base);
3813 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3816 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3818 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3819 ID3DXBaseEffect *base = This->base_effect;
3821 TRACE("Forward iface %p, base %p\n", This, base);
3823 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3826 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3828 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3829 ID3DXBaseEffect *base = This->base_effect;
3831 TRACE("Forward iface %p, base %p\n", This, base);
3833 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3836 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3838 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3839 ID3DXBaseEffect *base = This->base_effect;
3841 TRACE("Forward iface %p, base %p\n", This, base);
3843 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3846 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3848 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3849 ID3DXBaseEffect *base = This->base_effect;
3851 TRACE("Forward iface %p, base %p\n", This, base);
3853 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3856 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3858 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3859 ID3DXBaseEffect *base = This->base_effect;
3861 TRACE("Forward iface %p, base %p\n", This, base);
3863 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3866 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3868 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3869 ID3DXBaseEffect *base = This->base_effect;
3871 TRACE("Forward iface %p, base %p\n", This, base);
3873 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3876 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3878 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3879 ID3DXBaseEffect *base = This->base_effect;
3881 TRACE("Forward iface %p, base %p\n", This, base);
3883 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3886 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3888 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3889 ID3DXBaseEffect *base = This->base_effect;
3891 TRACE("Forward iface %p, base %p\n", This, base);
3893 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3896 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3898 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3899 ID3DXBaseEffect *base = This->base_effect;
3901 TRACE("Forward iface %p, base %p\n", This, base);
3903 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3906 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3908 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3909 ID3DXBaseEffect *base = This->base_effect;
3911 TRACE("Forward iface %p, base %p\n", This, base);
3913 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3916 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3918 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3919 ID3DXBaseEffect *base = This->base_effect;
3921 TRACE("Forward iface %p, base %p\n", This, base);
3923 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3926 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3928 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3929 ID3DXBaseEffect *base = This->base_effect;
3931 TRACE("Forward iface %p, base %p\n", This, base);
3933 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3936 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3938 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3939 ID3DXBaseEffect *base = This->base_effect;
3941 TRACE("Forward iface %p, base %p\n", This, base);
3943 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3946 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3948 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3949 ID3DXBaseEffect *base = This->base_effect;
3951 TRACE("Forward iface %p, base %p\n", This, base);
3953 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3956 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3958 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3959 ID3DXBaseEffect *base = This->base_effect;
3961 TRACE("Forward iface %p, base %p\n", This, base);
3963 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3966 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3968 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3969 ID3DXBaseEffect *base = This->base_effect;
3971 TRACE("Forward iface %p, base %p\n", This, base);
3973 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3976 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3978 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3979 ID3DXBaseEffect *base = This->base_effect;
3981 TRACE("Forward iface %p, base %p\n", This, base);
3983 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3986 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3988 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3989 ID3DXBaseEffect *base = This->base_effect;
3991 TRACE("Forward iface %p, base %p\n", This, base);
3993 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3996 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3998 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3999 ID3DXBaseEffect *base = This->base_effect;
4001 TRACE("Forward iface %p, base %p\n", This, base);
4003 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
4006 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4008 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4009 ID3DXBaseEffect *base = This->base_effect;
4011 TRACE("Forward iface %p, base %p\n", This, base);
4013 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
4016 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4018 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4019 ID3DXBaseEffect *base = This->base_effect;
4021 TRACE("Forward iface %p, base %p\n", This, base);
4023 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
4026 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4028 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4029 ID3DXBaseEffect *base = This->base_effect;
4031 TRACE("Forward iface %p, base %p\n", This, base);
4033 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
4036 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4038 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4039 ID3DXBaseEffect *base = This->base_effect;
4041 TRACE("Forward iface %p, base %p\n", This, base);
4043 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
4046 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4048 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4049 ID3DXBaseEffect *base = This->base_effect;
4051 TRACE("Forward iface %p, base %p\n", This, base);
4053 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
4056 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4058 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4059 ID3DXBaseEffect *base = This->base_effect;
4061 TRACE("Forward iface %p, base %p\n", This, base);
4063 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
4066 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
4068 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4069 ID3DXBaseEffect *base = This->base_effect;
4071 TRACE("Forward iface %p, base %p\n", This, base);
4073 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
4076 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
4078 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4079 ID3DXBaseEffect *base = This->base_effect;
4081 TRACE("Forward iface %p, base %p\n", This, base);
4083 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
4086 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
4088 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4089 ID3DXBaseEffect *base = This->base_effect;
4091 TRACE("Forward iface %p, base %p\n", This, base);
4093 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
4096 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
4098 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4099 ID3DXBaseEffect *base = This->base_effect;
4101 TRACE("Forward iface %p, base %p\n", This, base);
4103 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4106 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
4108 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4109 ID3DXBaseEffect *base = This->base_effect;
4111 TRACE("Forward iface %p, base %p\n", This, base);
4113 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
4116 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
4118 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4119 ID3DXBaseEffect *base = This->base_effect;
4121 TRACE("Forward iface %p, base %p\n", This, base);
4123 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
4126 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4128 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4129 ID3DXBaseEffect *base = This->base_effect;
4131 TRACE("Forward iface %p, base %p\n", This, base);
4133 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4136 /*** ID3DXEffectCompiler methods ***/
4137 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4139 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4141 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4143 return E_NOTIMPL;
4146 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4148 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4150 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4152 return E_NOTIMPL;
4155 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4156 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
4158 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4160 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4162 return E_NOTIMPL;
4165 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4166 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
4168 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4170 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4171 This, function, target, flags, shader, error_msgs, constant_table);
4173 return E_NOTIMPL;
4176 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4178 /*** IUnknown methods ***/
4179 ID3DXEffectCompilerImpl_QueryInterface,
4180 ID3DXEffectCompilerImpl_AddRef,
4181 ID3DXEffectCompilerImpl_Release,
4182 /*** ID3DXBaseEffect methods ***/
4183 ID3DXEffectCompilerImpl_GetDesc,
4184 ID3DXEffectCompilerImpl_GetParameterDesc,
4185 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4186 ID3DXEffectCompilerImpl_GetPassDesc,
4187 ID3DXEffectCompilerImpl_GetFunctionDesc,
4188 ID3DXEffectCompilerImpl_GetParameter,
4189 ID3DXEffectCompilerImpl_GetParameterByName,
4190 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4191 ID3DXEffectCompilerImpl_GetParameterElement,
4192 ID3DXEffectCompilerImpl_GetTechnique,
4193 ID3DXEffectCompilerImpl_GetTechniqueByName,
4194 ID3DXEffectCompilerImpl_GetPass,
4195 ID3DXEffectCompilerImpl_GetPassByName,
4196 ID3DXEffectCompilerImpl_GetFunction,
4197 ID3DXEffectCompilerImpl_GetFunctionByName,
4198 ID3DXEffectCompilerImpl_GetAnnotation,
4199 ID3DXEffectCompilerImpl_GetAnnotationByName,
4200 ID3DXEffectCompilerImpl_SetValue,
4201 ID3DXEffectCompilerImpl_GetValue,
4202 ID3DXEffectCompilerImpl_SetBool,
4203 ID3DXEffectCompilerImpl_GetBool,
4204 ID3DXEffectCompilerImpl_SetBoolArray,
4205 ID3DXEffectCompilerImpl_GetBoolArray,
4206 ID3DXEffectCompilerImpl_SetInt,
4207 ID3DXEffectCompilerImpl_GetInt,
4208 ID3DXEffectCompilerImpl_SetIntArray,
4209 ID3DXEffectCompilerImpl_GetIntArray,
4210 ID3DXEffectCompilerImpl_SetFloat,
4211 ID3DXEffectCompilerImpl_GetFloat,
4212 ID3DXEffectCompilerImpl_SetFloatArray,
4213 ID3DXEffectCompilerImpl_GetFloatArray,
4214 ID3DXEffectCompilerImpl_SetVector,
4215 ID3DXEffectCompilerImpl_GetVector,
4216 ID3DXEffectCompilerImpl_SetVectorArray,
4217 ID3DXEffectCompilerImpl_GetVectorArray,
4218 ID3DXEffectCompilerImpl_SetMatrix,
4219 ID3DXEffectCompilerImpl_GetMatrix,
4220 ID3DXEffectCompilerImpl_SetMatrixArray,
4221 ID3DXEffectCompilerImpl_GetMatrixArray,
4222 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4223 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4224 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4225 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4226 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4227 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4228 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4229 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4230 ID3DXEffectCompilerImpl_SetString,
4231 ID3DXEffectCompilerImpl_GetString,
4232 ID3DXEffectCompilerImpl_SetTexture,
4233 ID3DXEffectCompilerImpl_GetTexture,
4234 ID3DXEffectCompilerImpl_GetPixelShader,
4235 ID3DXEffectCompilerImpl_GetVertexShader,
4236 ID3DXEffectCompilerImpl_SetArrayRange,
4237 /*** ID3DXEffectCompiler methods ***/
4238 ID3DXEffectCompilerImpl_SetLiteral,
4239 ID3DXEffectCompilerImpl_GetLiteral,
4240 ID3DXEffectCompilerImpl_CompileEffect,
4241 ID3DXEffectCompilerImpl_CompileShader,
4244 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4246 HRESULT hr;
4247 UINT i;
4248 struct d3dx_state *states;
4250 read_dword(ptr, &sampler->state_count);
4251 TRACE("Count: %u\n", sampler->state_count);
4253 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4254 if (!states)
4256 ERR("Out of memory\n");
4257 return E_OUTOFMEMORY;
4260 for (i = 0; i < sampler->state_count; ++i)
4262 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4263 if (hr != D3D_OK)
4265 WARN("Failed to parse state\n");
4266 goto err_out;
4270 sampler->states = states;
4272 return D3D_OK;
4274 err_out:
4276 for (i = 0; i < sampler->state_count; ++i)
4278 free_state(&states[i]);
4281 HeapFree(GetProcessHeap(), 0, states);
4283 return hr;
4286 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4288 unsigned int i;
4289 HRESULT hr;
4290 UINT old_size = 0;
4291 DWORD id;
4293 if (param->element_count)
4295 param->data = value;
4297 for (i = 0; i < param->element_count; ++i)
4299 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4301 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4302 if (hr != D3D_OK)
4304 WARN("Failed to parse value\n");
4305 return hr;
4308 old_size += member->bytes;
4311 return D3D_OK;
4314 switch(param->class)
4316 case D3DXPC_SCALAR:
4317 case D3DXPC_VECTOR:
4318 case D3DXPC_MATRIX_ROWS:
4319 case D3DXPC_MATRIX_COLUMNS:
4320 param->data = value;
4321 break;
4323 case D3DXPC_STRUCT:
4324 param->data = value;
4326 for (i = 0; i < param->member_count; ++i)
4328 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4330 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4331 if (hr != D3D_OK)
4333 WARN("Failed to parse value\n");
4334 return hr;
4337 old_size += member->bytes;
4339 break;
4341 case D3DXPC_OBJECT:
4342 switch (param->type)
4344 case D3DXPT_STRING:
4345 case D3DXPT_TEXTURE:
4346 case D3DXPT_TEXTURE1D:
4347 case D3DXPT_TEXTURE2D:
4348 case D3DXPT_TEXTURE3D:
4349 case D3DXPT_TEXTURECUBE:
4350 case D3DXPT_PIXELSHADER:
4351 case D3DXPT_VERTEXSHADER:
4352 read_dword(ptr, &id);
4353 TRACE("Id: %u\n", id);
4354 objects[id] = get_parameter_handle(param);
4355 param->data = value;
4356 break;
4358 case D3DXPT_SAMPLER:
4359 case D3DXPT_SAMPLER1D:
4360 case D3DXPT_SAMPLER2D:
4361 case D3DXPT_SAMPLER3D:
4362 case D3DXPT_SAMPLERCUBE:
4364 struct d3dx_sampler *sampler;
4366 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4367 if (!sampler)
4369 ERR("Out of memory\n");
4370 return E_OUTOFMEMORY;
4373 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4374 if (hr != D3D_OK)
4376 HeapFree(GetProcessHeap(), 0, sampler);
4377 WARN("Failed to parse sampler\n");
4378 return hr;
4381 param->data = sampler;
4382 break;
4385 default:
4386 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4387 break;
4389 break;
4391 default:
4392 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4393 break;
4396 return D3D_OK;
4399 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4401 UINT size = param->bytes;
4402 HRESULT hr;
4403 void *value = NULL;
4405 TRACE("param size: %u\n", size);
4407 if (size)
4409 value = HeapAlloc(GetProcessHeap(), 0, size);
4410 if (!value)
4412 ERR("Failed to allocate data memory.\n");
4413 return E_OUTOFMEMORY;
4416 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4417 memcpy(value, ptr, size);
4420 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4421 if (hr != D3D_OK)
4423 WARN("Failed to parse value\n");
4424 HeapFree(GetProcessHeap(), 0, value);
4425 return hr;
4428 return D3D_OK;
4431 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4433 DWORD size;
4435 read_dword(&ptr, &size);
4436 TRACE("Name size: %#x\n", size);
4438 if (!size)
4440 return D3D_OK;
4443 *name = HeapAlloc(GetProcessHeap(), 0, size);
4444 if (!*name)
4446 ERR("Failed to allocate name memory.\n");
4447 return E_OUTOFMEMORY;
4450 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4451 memcpy(*name, ptr, size);
4453 return D3D_OK;
4456 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4458 DWORD size;
4460 read_dword(ptr, &size);
4461 TRACE("Data size: %#x\n", size);
4463 *str = HeapAlloc(GetProcessHeap(), 0, size);
4464 if (!*str)
4466 ERR("Failed to allocate name memory.\n");
4467 return E_OUTOFMEMORY;
4470 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4471 memcpy(*str, *ptr, size);
4473 *ptr += ((size + 3) & ~3);
4475 return D3D_OK;
4478 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4480 DWORD size;
4481 HRESULT hr;
4483 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4485 read_dword(ptr, &size);
4486 TRACE("Data size: %#x\n", size);
4488 if (!size)
4490 TRACE("Size is 0\n");
4491 *(void **)param->data = NULL;
4492 return D3D_OK;
4495 switch (param->type)
4497 case D3DXPT_STRING:
4498 /* re-read with size (sizeof(DWORD) = 4) */
4499 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4500 if (hr != D3D_OK)
4502 WARN("Failed to parse string data\n");
4503 return hr;
4505 break;
4507 case D3DXPT_VERTEXSHADER:
4508 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4509 if (hr != D3D_OK)
4511 WARN("Failed to create vertex shader\n");
4512 return hr;
4514 break;
4516 case D3DXPT_PIXELSHADER:
4517 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4518 if (hr != D3D_OK)
4520 WARN("Failed to create pixel shader\n");
4521 return hr;
4523 break;
4525 default:
4526 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4527 break;
4531 *ptr += ((size + 3) & ~3);
4533 return D3D_OK;
4536 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4537 struct d3dx_parameter *parent, UINT flags)
4539 DWORD offset;
4540 HRESULT hr;
4541 D3DXHANDLE *member_handles = NULL;
4542 UINT i;
4544 param->flags = flags;
4546 if (!parent)
4548 read_dword(ptr, &param->type);
4549 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4551 read_dword(ptr, &param->class);
4552 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4554 read_dword(ptr, &offset);
4555 TRACE("Type name offset: %#x\n", offset);
4556 hr = d3dx9_parse_name(&param->name, data + offset);
4557 if (hr != D3D_OK)
4559 WARN("Failed to parse name\n");
4560 goto err_out;
4563 read_dword(ptr, &offset);
4564 TRACE("Type semantic offset: %#x\n", offset);
4565 hr = d3dx9_parse_name(&param->semantic, data + offset);
4566 if (hr != D3D_OK)
4568 WARN("Failed to parse semantic\n");
4569 goto err_out;
4572 read_dword(ptr, &param->element_count);
4573 TRACE("Elements: %u\n", param->element_count);
4575 switch (param->class)
4577 case D3DXPC_VECTOR:
4578 read_dword(ptr, &param->columns);
4579 TRACE("Columns: %u\n", param->columns);
4581 read_dword(ptr, &param->rows);
4582 TRACE("Rows: %u\n", param->rows);
4584 /* sizeof(DWORD) * rows * columns */
4585 param->bytes = 4 * param->rows * param->columns;
4586 break;
4588 case D3DXPC_SCALAR:
4589 case D3DXPC_MATRIX_ROWS:
4590 case D3DXPC_MATRIX_COLUMNS:
4591 read_dword(ptr, &param->rows);
4592 TRACE("Rows: %u\n", param->rows);
4594 read_dword(ptr, &param->columns);
4595 TRACE("Columns: %u\n", param->columns);
4597 /* sizeof(DWORD) * rows * columns */
4598 param->bytes = 4 * param->rows * param->columns;
4599 break;
4601 case D3DXPC_STRUCT:
4602 read_dword(ptr, &param->member_count);
4603 TRACE("Members: %u\n", param->member_count);
4604 break;
4606 case D3DXPC_OBJECT:
4607 switch (param->type)
4609 case D3DXPT_STRING:
4610 param->bytes = sizeof(LPCSTR);
4611 break;
4613 case D3DXPT_PIXELSHADER:
4614 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4615 break;
4617 case D3DXPT_VERTEXSHADER:
4618 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4619 break;
4621 case D3DXPT_TEXTURE:
4622 case D3DXPT_TEXTURE1D:
4623 case D3DXPT_TEXTURE2D:
4624 case D3DXPT_TEXTURE3D:
4625 case D3DXPT_TEXTURECUBE:
4626 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4627 break;
4629 case D3DXPT_SAMPLER:
4630 case D3DXPT_SAMPLER1D:
4631 case D3DXPT_SAMPLER2D:
4632 case D3DXPT_SAMPLER3D:
4633 case D3DXPT_SAMPLERCUBE:
4634 param->bytes = 0;
4635 break;
4637 default:
4638 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4639 break;
4641 break;
4643 default:
4644 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4645 break;
4648 else
4650 /* elements */
4651 param->type = parent->type;
4652 param->class = parent->class;
4653 param->name = parent->name;
4654 param->semantic = parent->semantic;
4655 param->element_count = 0;
4656 param->annotation_count = 0;
4657 param->member_count = parent->member_count;
4658 param->bytes = parent->bytes;
4659 param->rows = parent->rows;
4660 param->columns = parent->columns;
4663 if (param->element_count)
4665 unsigned int param_bytes = 0;
4666 const char *save_ptr = *ptr;
4668 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4669 if (!member_handles)
4671 ERR("Out of memory\n");
4672 hr = E_OUTOFMEMORY;
4673 goto err_out;
4676 for (i = 0; i < param->element_count; ++i)
4678 struct d3dx_parameter *member;
4679 *ptr = save_ptr;
4681 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4682 if (!member)
4684 ERR("Out of memory\n");
4685 hr = E_OUTOFMEMORY;
4686 goto err_out;
4689 member_handles[i] = get_parameter_handle(member);
4691 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4692 if (hr != D3D_OK)
4694 WARN("Failed to parse member\n");
4695 goto err_out;
4698 param_bytes += member->bytes;
4701 param->bytes = param_bytes;
4703 else if (param->member_count)
4705 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4706 if (!member_handles)
4708 ERR("Out of memory\n");
4709 hr = E_OUTOFMEMORY;
4710 goto err_out;
4713 for (i = 0; i < param->member_count; ++i)
4715 struct d3dx_parameter *member;
4717 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4718 if (!member)
4720 ERR("Out of memory\n");
4721 hr = E_OUTOFMEMORY;
4722 goto err_out;
4725 member_handles[i] = get_parameter_handle(member);
4727 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4728 if (hr != D3D_OK)
4730 WARN("Failed to parse member\n");
4731 goto err_out;
4734 param->bytes += member->bytes;
4738 param->member_handles = member_handles;
4740 return D3D_OK;
4742 err_out:
4744 if (member_handles)
4746 unsigned int count;
4748 if (param->element_count) count = param->element_count;
4749 else count = param->member_count;
4751 for (i = 0; i < count; ++i)
4753 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4755 HeapFree(GetProcessHeap(), 0, member_handles);
4758 if (!parent)
4760 HeapFree(GetProcessHeap(), 0, param->name);
4761 HeapFree(GetProcessHeap(), 0, param->semantic);
4763 param->name = NULL;
4764 param->semantic = NULL;
4766 return hr;
4769 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4771 DWORD offset;
4772 const char *ptr2;
4773 HRESULT hr;
4775 anno->flags = D3DX_PARAMETER_ANNOTATION;
4777 read_dword(ptr, &offset);
4778 TRACE("Typedef offset: %#x\n", offset);
4779 ptr2 = data + offset;
4780 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4781 if (hr != D3D_OK)
4783 WARN("Failed to parse type definition\n");
4784 return hr;
4787 read_dword(ptr, &offset);
4788 TRACE("Value offset: %#x\n", offset);
4789 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4790 if (hr != D3D_OK)
4792 WARN("Failed to parse value\n");
4793 return hr;
4796 return D3D_OK;
4799 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4801 DWORD offset;
4802 const char *ptr2;
4803 HRESULT hr;
4804 struct d3dx_parameter *parameter;
4806 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4807 if (!parameter)
4809 ERR("Out of memory\n");
4810 return E_OUTOFMEMORY;
4813 state->type = ST_CONSTANT;
4815 read_dword(ptr, &state->operation);
4816 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4818 read_dword(ptr, &state->index);
4819 TRACE("Index: %#x\n", state->index);
4821 read_dword(ptr, &offset);
4822 TRACE("Typedef offset: %#x\n", offset);
4823 ptr2 = data + offset;
4824 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4825 if (hr != D3D_OK)
4827 WARN("Failed to parse type definition\n");
4828 goto err_out;
4831 read_dword(ptr, &offset);
4832 TRACE("Value offset: %#x\n", offset);
4833 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4834 if (hr != D3D_OK)
4836 WARN("Failed to parse value\n");
4837 goto err_out;
4840 state->parameter = get_parameter_handle(parameter);
4842 return D3D_OK;
4844 err_out:
4846 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4848 return hr;
4851 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4853 DWORD offset;
4854 HRESULT hr;
4855 unsigned int i;
4856 D3DXHANDLE *annotation_handles = NULL;
4857 const char *ptr2;
4859 read_dword(ptr, &offset);
4860 TRACE("Typedef offset: %#x\n", offset);
4861 ptr2 = data + offset;
4863 read_dword(ptr, &offset);
4864 TRACE("Value offset: %#x\n", offset);
4866 read_dword(ptr, &param->flags);
4867 TRACE("Flags: %#x\n", param->flags);
4869 read_dword(ptr, &param->annotation_count);
4870 TRACE("Annotation count: %u\n", param->annotation_count);
4872 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4873 if (hr != D3D_OK)
4875 WARN("Failed to parse type definition\n");
4876 return hr;
4879 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4880 if (hr != D3D_OK)
4882 WARN("Failed to parse value\n");
4883 return hr;
4886 if (param->annotation_count)
4888 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4889 if (!annotation_handles)
4891 ERR("Out of memory\n");
4892 hr = E_OUTOFMEMORY;
4893 goto err_out;
4896 for (i = 0; i < param->annotation_count; ++i)
4898 struct d3dx_parameter *annotation;
4900 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4901 if (!annotation)
4903 ERR("Out of memory\n");
4904 hr = E_OUTOFMEMORY;
4905 goto err_out;
4908 annotation_handles[i] = get_parameter_handle(annotation);
4910 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4911 if (hr != D3D_OK)
4913 WARN("Failed to parse annotation\n");
4914 goto err_out;
4919 param->annotation_handles = annotation_handles;
4921 return D3D_OK;
4923 err_out:
4925 if (annotation_handles)
4927 for (i = 0; i < param->annotation_count; ++i)
4929 free_parameter(annotation_handles[i], FALSE, FALSE);
4931 HeapFree(GetProcessHeap(), 0, annotation_handles);
4934 return hr;
4937 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4939 DWORD offset;
4940 HRESULT hr;
4941 unsigned int i;
4942 D3DXHANDLE *annotation_handles = NULL;
4943 struct d3dx_state *states = NULL;
4944 char *name = NULL;
4946 read_dword(ptr, &offset);
4947 TRACE("Pass name offset: %#x\n", offset);
4948 hr = d3dx9_parse_name(&name, data + offset);
4949 if (hr != D3D_OK)
4951 WARN("Failed to parse name\n");
4952 goto err_out;
4955 read_dword(ptr, &pass->annotation_count);
4956 TRACE("Annotation count: %u\n", pass->annotation_count);
4958 read_dword(ptr, &pass->state_count);
4959 TRACE("State count: %u\n", pass->state_count);
4961 if (pass->annotation_count)
4963 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4964 if (!annotation_handles)
4966 ERR("Out of memory\n");
4967 hr = E_OUTOFMEMORY;
4968 goto err_out;
4971 for (i = 0; i < pass->annotation_count; ++i)
4973 struct d3dx_parameter *annotation;
4975 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4976 if (!annotation)
4978 ERR("Out of memory\n");
4979 hr = E_OUTOFMEMORY;
4980 goto err_out;
4983 annotation_handles[i] = get_parameter_handle(annotation);
4985 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4986 if (hr != D3D_OK)
4988 WARN("Failed to parse annotations\n");
4989 goto err_out;
4994 if (pass->state_count)
4996 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4997 if (!states)
4999 ERR("Out of memory\n");
5000 hr = E_OUTOFMEMORY;
5001 goto err_out;
5004 for (i = 0; i < pass->state_count; ++i)
5006 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
5007 if (hr != D3D_OK)
5009 WARN("Failed to parse annotations\n");
5010 goto err_out;
5015 pass->name = name;
5016 pass->annotation_handles = annotation_handles;
5017 pass->states = states;
5019 return D3D_OK;
5021 err_out:
5023 if (annotation_handles)
5025 for (i = 0; i < pass->annotation_count; ++i)
5027 free_parameter(annotation_handles[i], FALSE, FALSE);
5029 HeapFree(GetProcessHeap(), 0, annotation_handles);
5032 if (states)
5034 for (i = 0; i < pass->state_count; ++i)
5036 free_state(&states[i]);
5038 HeapFree(GetProcessHeap(), 0, states);
5041 HeapFree(GetProcessHeap(), 0, name);
5043 return hr;
5046 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
5048 DWORD offset;
5049 HRESULT hr;
5050 unsigned int i;
5051 D3DXHANDLE *annotation_handles = NULL;
5052 D3DXHANDLE *pass_handles = NULL;
5053 char *name = NULL;
5055 read_dword(ptr, &offset);
5056 TRACE("Technique name offset: %#x\n", offset);
5057 hr = d3dx9_parse_name(&name, data + offset);
5058 if (hr != D3D_OK)
5060 WARN("Failed to parse name\n");
5061 goto err_out;
5064 read_dword(ptr, &technique->annotation_count);
5065 TRACE("Annotation count: %u\n", technique->annotation_count);
5067 read_dword(ptr, &technique->pass_count);
5068 TRACE("Pass count: %u\n", technique->pass_count);
5070 if (technique->annotation_count)
5072 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
5073 if (!annotation_handles)
5075 ERR("Out of memory\n");
5076 hr = E_OUTOFMEMORY;
5077 goto err_out;
5080 for (i = 0; i < technique->annotation_count; ++i)
5082 struct d3dx_parameter *annotation;
5084 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5085 if (!annotation)
5087 ERR("Out of memory\n");
5088 hr = E_OUTOFMEMORY;
5089 goto err_out;
5092 annotation_handles[i] = get_parameter_handle(annotation);
5094 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5095 if (hr != D3D_OK)
5097 WARN("Failed to parse annotations\n");
5098 goto err_out;
5103 if (technique->pass_count)
5105 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5106 if (!pass_handles)
5108 ERR("Out of memory\n");
5109 hr = E_OUTOFMEMORY;
5110 goto err_out;
5113 for (i = 0; i < technique->pass_count; ++i)
5115 struct d3dx_pass *pass;
5117 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5118 if (!pass)
5120 ERR("Out of memory\n");
5121 hr = E_OUTOFMEMORY;
5122 goto err_out;
5125 pass_handles[i] = get_pass_handle(pass);
5127 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5128 if (hr != D3D_OK)
5130 WARN("Failed to parse passes\n");
5131 goto err_out;
5136 technique->name = name;
5137 technique->pass_handles = pass_handles;
5138 technique->annotation_handles = annotation_handles;
5140 return D3D_OK;
5142 err_out:
5144 if (pass_handles)
5146 for (i = 0; i < technique->pass_count; ++i)
5148 free_pass(pass_handles[i]);
5150 HeapFree(GetProcessHeap(), 0, pass_handles);
5153 if (annotation_handles)
5155 for (i = 0; i < technique->annotation_count; ++i)
5157 free_parameter(annotation_handles[i], FALSE, FALSE);
5159 HeapFree(GetProcessHeap(), 0, annotation_handles);
5162 HeapFree(GetProcessHeap(), 0, name);
5164 return hr;
5167 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5169 DWORD technique_index;
5170 DWORD index, state_index, usage, element_index;
5171 struct d3dx_state *state;
5172 struct d3dx_parameter *param;
5173 HRESULT hr = E_FAIL;
5175 read_dword(ptr, &technique_index);
5176 TRACE("techn: %u\n", technique_index);
5178 read_dword(ptr, &index);
5179 TRACE("index: %u\n", index);
5181 read_dword(ptr, &element_index);
5182 TRACE("element_index: %u\n", element_index);
5184 read_dword(ptr, &state_index);
5185 TRACE("state_index: %u\n", state_index);
5187 read_dword(ptr, &usage);
5188 TRACE("usage: %u\n", usage);
5190 if (technique_index == 0xffffffff)
5192 struct d3dx_parameter *parameter;
5193 struct d3dx_sampler *sampler;
5195 if (index >= base->parameter_count)
5197 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5198 return E_FAIL;
5201 parameter = get_parameter_struct(base->parameter_handles[index]);
5202 if (element_index != 0xffffffff)
5204 if (element_index >= parameter->element_count && parameter->element_count != 0)
5206 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5207 return E_FAIL;
5210 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5213 sampler = parameter->data;
5214 if (state_index >= sampler->state_count)
5216 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5217 return E_FAIL;
5220 state = &sampler->states[state_index];
5222 else
5224 struct d3dx_technique *technique;
5225 struct d3dx_pass *pass;
5227 if (technique_index >= base->technique_count)
5229 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5230 return E_FAIL;
5233 technique = get_technique_struct(base->technique_handles[technique_index]);
5234 if (index >= technique->pass_count)
5236 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5237 return E_FAIL;
5240 pass = get_pass_struct(technique->pass_handles[index]);
5241 if (state_index >= pass->state_count)
5243 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5244 return E_FAIL;
5247 state = &pass->states[state_index];
5250 param = get_parameter_struct(state->parameter);
5252 switch (usage)
5254 case 0:
5255 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5256 switch (param->type)
5258 case D3DXPT_VERTEXSHADER:
5259 case D3DXPT_PIXELSHADER:
5260 state->type = ST_CONSTANT;
5261 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5262 break;
5264 case D3DXPT_BOOL:
5265 case D3DXPT_INT:
5266 case D3DXPT_FLOAT:
5267 case D3DXPT_STRING:
5268 state->type = ST_FXLC;
5269 hr = d3dx9_copy_data(param->data, ptr);
5270 break;
5272 default:
5273 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5274 break;
5276 break;
5278 case 1:
5279 state->type = ST_PARAMETER;
5280 hr = d3dx9_copy_data(param->data, ptr);
5281 if (hr == D3D_OK)
5283 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5285 break;
5287 default:
5288 FIXME("Unknown usage %x\n", usage);
5289 break;
5292 return hr;
5295 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5297 const char *ptr = data + start;
5298 D3DXHANDLE *parameter_handles = NULL;
5299 D3DXHANDLE *technique_handles = NULL;
5300 D3DXHANDLE *objects = NULL;
5301 UINT stringcount, objectcount, resourcecount;
5302 HRESULT hr;
5303 UINT i;
5305 read_dword(&ptr, &base->parameter_count);
5306 TRACE("Parameter count: %u\n", base->parameter_count);
5308 read_dword(&ptr, &base->technique_count);
5309 TRACE("Technique count: %u\n", base->technique_count);
5311 skip_dword_unknown(&ptr, 1);
5313 read_dword(&ptr, &objectcount);
5314 TRACE("Object count: %u\n", objectcount);
5316 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5317 if (!objects)
5319 ERR("Out of memory\n");
5320 hr = E_OUTOFMEMORY;
5321 goto err_out;
5324 if (base->parameter_count)
5326 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5327 if (!parameter_handles)
5329 ERR("Out of memory\n");
5330 hr = E_OUTOFMEMORY;
5331 goto err_out;
5334 for (i = 0; i < base->parameter_count; ++i)
5336 struct d3dx_parameter *parameter;
5338 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5339 if (!parameter)
5341 ERR("Out of memory\n");
5342 hr = E_OUTOFMEMORY;
5343 goto err_out;
5346 parameter_handles[i] = get_parameter_handle(parameter);
5348 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5349 if (hr != D3D_OK)
5351 WARN("Failed to parse parameter\n");
5352 goto err_out;
5357 if (base->technique_count)
5359 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5360 if (!technique_handles)
5362 ERR("Out of memory\n");
5363 hr = E_OUTOFMEMORY;
5364 goto err_out;
5367 for (i = 0; i < base->technique_count; ++i)
5369 struct d3dx_technique *technique;
5371 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5372 if (!technique)
5374 ERR("Out of memory\n");
5375 hr = E_OUTOFMEMORY;
5376 goto err_out;
5379 technique_handles[i] = get_technique_handle(technique);
5381 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5382 if (hr != D3D_OK)
5384 WARN("Failed to parse technique\n");
5385 goto err_out;
5390 /* needed for further parsing */
5391 base->technique_handles = technique_handles;
5392 base->parameter_handles = parameter_handles;
5394 read_dword(&ptr, &stringcount);
5395 TRACE("String count: %u\n", stringcount);
5397 read_dword(&ptr, &resourcecount);
5398 TRACE("Resource count: %u\n", resourcecount);
5400 for (i = 0; i < stringcount; ++i)
5402 DWORD id;
5403 struct d3dx_parameter *param;
5405 read_dword(&ptr, &id);
5406 TRACE("Id: %u\n", id);
5408 param = get_parameter_struct(objects[id]);
5410 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5411 if (hr != D3D_OK)
5413 WARN("Failed to parse data\n");
5414 goto err_out;
5418 for (i = 0; i < resourcecount; ++i)
5420 TRACE("parse resource %u\n", i);
5422 hr = d3dx9_parse_resource(base, data, &ptr);
5423 if (hr != D3D_OK)
5425 WARN("Failed to parse data\n");
5426 goto err_out;
5430 HeapFree(GetProcessHeap(), 0, objects);
5432 return D3D_OK;
5434 err_out:
5436 if (technique_handles)
5438 for (i = 0; i < base->technique_count; ++i)
5440 free_technique(technique_handles[i]);
5442 HeapFree(GetProcessHeap(), 0, technique_handles);
5445 if (parameter_handles)
5447 for (i = 0; i < base->parameter_count; ++i)
5449 free_parameter(parameter_handles[i], FALSE, FALSE);
5451 HeapFree(GetProcessHeap(), 0, parameter_handles);
5454 base->technique_handles = NULL;
5455 base->parameter_handles = NULL;
5457 HeapFree(GetProcessHeap(), 0, objects);
5459 return hr;
5462 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5463 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5465 DWORD tag, offset;
5466 const char *ptr = data;
5467 HRESULT hr;
5469 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5471 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5472 base->ref = 1;
5473 base->effect = effect;
5475 read_dword(&ptr, &tag);
5476 TRACE("Tag: %x\n", tag);
5478 if (tag != d3dx9_effect_version(9, 1))
5480 /* todo: compile hlsl ascii code */
5481 FIXME("HLSL ascii effects not supported, yet\n");
5483 /* Show the start of the shader for debugging info. */
5484 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5486 else
5488 read_dword(&ptr, &offset);
5489 TRACE("Offset: %x\n", offset);
5491 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5492 if (hr != D3D_OK)
5494 FIXME("Failed to parse effect.\n");
5495 return hr;
5499 return D3D_OK;
5502 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5503 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5505 HRESULT hr;
5506 struct ID3DXBaseEffectImpl *object = NULL;
5508 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5510 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5511 effect->ref = 1;
5513 if (pool) pool->lpVtbl->AddRef(pool);
5514 effect->pool = pool;
5516 IDirect3DDevice9_AddRef(device);
5517 effect->device = device;
5519 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5520 if (!object)
5522 ERR("Out of memory\n");
5523 hr = E_OUTOFMEMORY;
5524 goto err_out;
5527 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5528 if (hr != D3D_OK)
5530 FIXME("Failed to parse effect.\n");
5531 goto err_out;
5534 effect->base_effect = &object->ID3DXBaseEffect_iface;
5536 /* initialize defaults - check because of unsupported ascii effects */
5537 if (object->technique_handles)
5539 effect->active_technique = object->technique_handles[0];
5540 effect->active_pass = NULL;
5543 return D3D_OK;
5545 err_out:
5547 HeapFree(GetProcessHeap(), 0, object);
5548 free_effect(effect);
5550 return hr;
5553 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5554 LPCVOID srcdata,
5555 UINT srcdatalen,
5556 CONST D3DXMACRO* defines,
5557 LPD3DXINCLUDE include,
5558 LPCSTR skip_constants,
5559 DWORD flags,
5560 LPD3DXEFFECTPOOL pool,
5561 LPD3DXEFFECT* effect,
5562 LPD3DXBUFFER* compilation_errors)
5564 struct ID3DXEffectImpl *object;
5565 HRESULT hr;
5567 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5568 skip_constants, flags, pool, effect, compilation_errors);
5570 if (!device || !srcdata)
5571 return D3DERR_INVALIDCALL;
5573 if (!srcdatalen)
5574 return E_FAIL;
5576 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5577 if (!effect)
5578 return D3D_OK;
5580 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5581 if (!object)
5583 ERR("Out of memory\n");
5584 return E_OUTOFMEMORY;
5587 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5588 if (FAILED(hr))
5590 WARN("Failed to initialize shader reflection\n");
5591 HeapFree(GetProcessHeap(), 0, object);
5592 return hr;
5595 *effect = &object->ID3DXEffect_iface;
5597 TRACE("Created ID3DXEffect %p\n", object);
5599 return D3D_OK;
5602 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5603 LPCVOID srcdata,
5604 UINT srcdatalen,
5605 CONST D3DXMACRO* defines,
5606 LPD3DXINCLUDE include,
5607 DWORD flags,
5608 LPD3DXEFFECTPOOL pool,
5609 LPD3DXEFFECT* effect,
5610 LPD3DXBUFFER* compilation_errors)
5612 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5613 include, flags, pool, effect, compilation_errors);
5615 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5618 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5620 HRESULT hr;
5621 struct ID3DXBaseEffectImpl *object = NULL;
5623 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5625 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5626 compiler->ref = 1;
5628 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5629 if (!object)
5631 ERR("Out of memory\n");
5632 hr = E_OUTOFMEMORY;
5633 goto err_out;
5636 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5637 if (hr != D3D_OK)
5639 FIXME("Failed to parse effect.\n");
5640 goto err_out;
5643 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5645 return D3D_OK;
5647 err_out:
5649 HeapFree(GetProcessHeap(), 0, object);
5650 free_effect_compiler(compiler);
5652 return hr;
5655 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5656 UINT srcdatalen,
5657 CONST D3DXMACRO *defines,
5658 LPD3DXINCLUDE include,
5659 DWORD flags,
5660 LPD3DXEFFECTCOMPILER *compiler,
5661 LPD3DXBUFFER *parse_errors)
5663 struct ID3DXEffectCompilerImpl *object;
5664 HRESULT hr;
5666 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5667 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5669 if (!srcdata || !compiler)
5671 WARN("Invalid arguments supplied\n");
5672 return D3DERR_INVALIDCALL;
5675 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5676 if (!object)
5678 ERR("Out of memory\n");
5679 return E_OUTOFMEMORY;
5682 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5683 if (FAILED(hr))
5685 WARN("Failed to initialize effect compiler\n");
5686 HeapFree(GetProcessHeap(), 0, object);
5687 return hr;
5690 *compiler = &object->ID3DXEffectCompiler_iface;
5692 TRACE("Created ID3DXEffectCompiler %p\n", object);
5694 return D3D_OK;
5697 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5699 struct ID3DXEffectPoolImpl
5701 ID3DXEffectPool ID3DXEffectPool_iface;
5702 LONG ref;
5705 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5707 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5710 /*** IUnknown methods ***/
5711 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5713 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5715 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5717 if (IsEqualGUID(riid, &IID_IUnknown) ||
5718 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5720 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5721 *object = This;
5722 return S_OK;
5725 WARN("Interface %s not found\n", debugstr_guid(riid));
5727 return E_NOINTERFACE;
5730 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5732 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5734 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5736 return InterlockedIncrement(&This->ref);
5739 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5741 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5742 ULONG ref = InterlockedDecrement(&This->ref);
5744 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5746 if (!ref)
5747 HeapFree(GetProcessHeap(), 0, This);
5749 return ref;
5752 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5754 /*** IUnknown methods ***/
5755 ID3DXEffectPoolImpl_QueryInterface,
5756 ID3DXEffectPoolImpl_AddRef,
5757 ID3DXEffectPoolImpl_Release
5760 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5762 struct ID3DXEffectPoolImpl *object;
5764 TRACE("(%p)\n", pool);
5766 if (!pool)
5767 return D3DERR_INVALIDCALL;
5769 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5770 if (!object)
5772 ERR("Out of memory\n");
5773 return E_OUTOFMEMORY;
5776 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5777 object->ref = 1;
5779 *pool = &object->ID3DXEffectPool_iface;
5781 return S_OK;
5784 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5785 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5786 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5788 LPVOID buffer;
5789 HRESULT ret;
5790 DWORD size;
5792 TRACE("(%s): relay\n", debugstr_w(srcfile));
5794 if (!device || !srcfile)
5795 return D3DERR_INVALIDCALL;
5797 ret = map_view_of_file(srcfile, &buffer, &size);
5799 if (FAILED(ret))
5800 return D3DXERR_INVALIDDATA;
5802 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5803 UnmapViewOfFile(buffer);
5805 return ret;
5808 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5809 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5810 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5812 LPWSTR srcfileW;
5813 HRESULT ret;
5814 DWORD len;
5816 TRACE("(void): relay\n");
5818 if (!srcfile)
5819 return D3DERR_INVALIDCALL;
5821 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5822 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5823 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5825 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5826 HeapFree(GetProcessHeap(), 0, srcfileW);
5828 return ret;
5831 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5832 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5833 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5835 TRACE("(void): relay\n");
5836 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5839 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5840 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5841 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5843 TRACE("(void): relay\n");
5844 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5847 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5848 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5849 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5851 HRSRC resinfo;
5853 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5855 if (!device)
5856 return D3DERR_INVALIDCALL;
5858 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5860 if (resinfo)
5862 LPVOID buffer;
5863 HRESULT ret;
5864 DWORD size;
5866 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5868 if (FAILED(ret))
5869 return D3DXERR_INVALIDDATA;
5871 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5874 return D3DXERR_INVALIDDATA;
5877 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5878 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5879 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5881 HRSRC resinfo;
5883 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5885 if (!device)
5886 return D3DERR_INVALIDCALL;
5888 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5890 if (resinfo)
5892 LPVOID buffer;
5893 HRESULT ret;
5894 DWORD size;
5896 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5898 if (FAILED(ret))
5899 return D3DXERR_INVALIDDATA;
5901 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5904 return D3DXERR_INVALIDDATA;
5907 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5908 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5909 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5911 TRACE("(void): relay\n");
5912 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5915 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5916 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5917 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5919 TRACE("(void): relay\n");
5920 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5923 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5924 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5926 LPVOID buffer;
5927 HRESULT ret;
5928 DWORD size;
5930 TRACE("(%s): relay\n", debugstr_w(srcfile));
5932 if (!srcfile)
5933 return D3DERR_INVALIDCALL;
5935 ret = map_view_of_file(srcfile, &buffer, &size);
5937 if (FAILED(ret))
5938 return D3DXERR_INVALIDDATA;
5940 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5941 UnmapViewOfFile(buffer);
5943 return ret;
5946 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5947 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5949 LPWSTR srcfileW;
5950 HRESULT ret;
5951 DWORD len;
5953 TRACE("(void): relay\n");
5955 if (!srcfile)
5956 return D3DERR_INVALIDCALL;
5958 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5959 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5960 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5962 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5963 HeapFree(GetProcessHeap(), 0, srcfileW);
5965 return ret;
5968 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5969 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5971 HRSRC resinfo;
5973 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5975 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5977 if (resinfo)
5979 LPVOID buffer;
5980 HRESULT ret;
5981 DWORD size;
5983 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5985 if (FAILED(ret))
5986 return D3DXERR_INVALIDDATA;
5988 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5991 return D3DXERR_INVALIDDATA;
5994 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5995 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5997 HRSRC resinfo;
5999 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6001 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6003 if (resinfo)
6005 LPVOID buffer;
6006 HRESULT ret;
6007 DWORD size;
6009 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6011 if (FAILED(ret))
6012 return D3DXERR_INVALIDDATA;
6014 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6017 return D3DXERR_INVALIDDATA;