d3dx9: Implement ID3DXBaseEffect::SetBool().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blobc2be55839063ff73ac84d7fb58b2cb17c76f879a
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 struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
940 UINT element;
941 struct d3dx_parameter *temp_parameter;
942 LPCSTR part;
944 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
946 if (!name || !*name) return parameter;
948 element = atoi(name);
949 part = strchr(name, ']') + 1;
951 if (parameter->element_count > element)
953 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
955 switch (*part++)
957 case '.':
958 return get_parameter_by_name(NULL, temp_parameter, part);
960 case '@':
961 return get_parameter_annotation_by_name(temp_parameter, part);
963 case '\0':
964 TRACE("Returning parameter %p\n", temp_parameter);
965 return temp_parameter;
967 default:
968 FIXME("Unhandled case \"%c\"\n", *--part);
969 break;
973 TRACE("Parameter not found\n");
974 return NULL;
977 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
979 UINT i, length;
980 struct d3dx_parameter *temp_parameter;
981 LPCSTR part;
983 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
985 if (!name || !*name) return parameter;
987 length = strcspn( name, "[.@" );
988 part = name + length;
990 for (i = 0; i < parameter->annotation_count; ++i)
992 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
994 if (!strcmp(temp_parameter->name, name))
996 TRACE("Returning parameter %p\n", temp_parameter);
997 return temp_parameter;
999 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1001 switch (*part++)
1003 case '.':
1004 return get_parameter_by_name(NULL, temp_parameter, part);
1006 case '[':
1007 return get_parameter_element_by_name(temp_parameter, part);
1009 default:
1010 FIXME("Unhandled case \"%c\"\n", *--part);
1011 break;
1016 TRACE("Parameter not found\n");
1017 return NULL;
1020 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
1021 struct d3dx_parameter *parameter, LPCSTR name)
1023 UINT i, count, length;
1024 struct d3dx_parameter *temp_parameter;
1025 D3DXHANDLE *handles;
1026 LPCSTR part;
1028 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
1030 if (!name || !*name) return parameter;
1032 if (!parameter)
1034 count = base->parameter_count;
1035 handles = base->parameter_handles;
1037 else
1039 count = parameter->member_count;
1040 handles = parameter->member_handles;
1043 length = strcspn( name, "[.@" );
1044 part = name + length;
1046 for (i = 0; i < count; i++)
1048 temp_parameter = get_parameter_struct(handles[i]);
1050 if (!strcmp(temp_parameter->name, name))
1052 TRACE("Returning parameter %p\n", temp_parameter);
1053 return temp_parameter;
1055 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1057 switch (*part++)
1059 case '.':
1060 return get_parameter_by_name(NULL, temp_parameter, part);
1062 case '@':
1063 return get_parameter_annotation_by_name(temp_parameter, part);
1065 case '[':
1066 return get_parameter_element_by_name(temp_parameter, part);
1068 default:
1069 FIXME("Unhandled case \"%c\"\n", *--part);
1070 break;
1075 TRACE("Parameter not found\n");
1076 return NULL;
1079 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1081 return (0xfeff0000 | ((major) << 8) | (minor));
1084 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1086 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1089 /*** IUnknown methods ***/
1090 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1092 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1094 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1096 if (IsEqualGUID(riid, &IID_IUnknown) ||
1097 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1099 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1100 *object = This;
1101 return S_OK;
1104 ERR("Interface %s not found\n", debugstr_guid(riid));
1106 return E_NOINTERFACE;
1109 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1111 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1113 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1115 return InterlockedIncrement(&This->ref);
1118 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1120 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1121 ULONG ref = InterlockedDecrement(&This->ref);
1123 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1125 if (!ref)
1127 free_base_effect(This);
1128 HeapFree(GetProcessHeap(), 0, This);
1131 return ref;
1134 /*** ID3DXBaseEffect methods ***/
1135 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1137 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1139 FIXME("iface %p, desc %p partial stub\n", This, desc);
1141 if (!desc)
1143 WARN("Invalid argument specified.\n");
1144 return D3DERR_INVALIDCALL;
1147 /* Todo: add creator and function count */
1148 desc->Creator = NULL;
1149 desc->Functions = 0;
1150 desc->Parameters = This->parameter_count;
1151 desc->Techniques = This->technique_count;
1153 return D3D_OK;
1156 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1158 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1159 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1161 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1163 if (!desc || !param)
1165 WARN("Invalid argument specified.\n");
1166 return D3DERR_INVALIDCALL;
1169 desc->Name = param->name;
1170 desc->Semantic = param->semantic;
1171 desc->Class = param->class;
1172 desc->Type = param->type;
1173 desc->Rows = param->rows;
1174 desc->Columns = param->columns;
1175 desc->Elements = param->element_count;
1176 desc->Annotations = param->annotation_count;
1177 desc->StructMembers = param->member_count;
1178 desc->Flags = param->flags;
1179 desc->Bytes = param->bytes;
1181 return D3D_OK;
1184 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1186 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1187 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1189 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1191 if (!desc || !tech)
1193 WARN("Invalid argument specified.\n");
1194 return D3DERR_INVALIDCALL;
1197 desc->Name = tech->name;
1198 desc->Passes = tech->pass_count;
1199 desc->Annotations = tech->annotation_count;
1201 return D3D_OK;
1204 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1206 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1207 struct d3dx_pass *p = is_valid_pass(This, pass);
1209 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1211 if (!desc || !p)
1213 WARN("Invalid argument specified.\n");
1214 return D3DERR_INVALIDCALL;
1217 desc->Name = p->name;
1218 desc->Annotations = p->annotation_count;
1220 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1221 desc->pVertexShaderFunction = NULL;
1222 desc->pPixelShaderFunction = NULL;
1224 return D3D_OK;
1227 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1229 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1231 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1233 return E_NOTIMPL;
1236 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1238 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1239 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1241 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1243 if (!parameter)
1245 if (index < This->parameter_count)
1247 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1248 return This->parameter_handles[index];
1251 else
1253 if (param && !param->element_count && index < param->member_count)
1255 TRACE("Returning parameter %p\n", param->member_handles[index]);
1256 return param->member_handles[index];
1260 WARN("Invalid argument specified.\n");
1262 return NULL;
1265 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1267 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1268 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1269 D3DXHANDLE handle;
1271 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1273 if (!name)
1275 handle = get_parameter_handle(param);
1276 TRACE("Returning parameter %p\n", handle);
1277 return handle;
1280 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1281 TRACE("Returning parameter %p\n", handle);
1283 return handle;
1286 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1288 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1289 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1290 struct d3dx_parameter *temp_param;
1291 UINT i;
1293 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1295 if (!parameter)
1297 for (i = 0; i < This->parameter_count; ++i)
1299 temp_param = get_parameter_struct(This->parameter_handles[i]);
1301 if (!temp_param->semantic)
1303 if (!semantic)
1305 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1306 return This->parameter_handles[i];
1308 continue;
1311 if (!strcasecmp(temp_param->semantic, semantic))
1313 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1314 return This->parameter_handles[i];
1318 else if (param)
1320 for (i = 0; i < param->member_count; ++i)
1322 temp_param = get_parameter_struct(param->member_handles[i]);
1324 if (!temp_param->semantic)
1326 if (!semantic)
1328 TRACE("Returning parameter %p\n", param->member_handles[i]);
1329 return param->member_handles[i];
1331 continue;
1334 if (!strcasecmp(temp_param->semantic, semantic))
1336 TRACE("Returning parameter %p\n", param->member_handles[i]);
1337 return param->member_handles[i];
1342 WARN("Invalid argument specified\n");
1344 return NULL;
1347 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1349 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1350 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1352 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1354 if (!param)
1356 if (index < This->parameter_count)
1358 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1359 return This->parameter_handles[index];
1362 else
1364 if (index < param->element_count)
1366 TRACE("Returning parameter %p\n", param->member_handles[index]);
1367 return param->member_handles[index];
1371 WARN("Invalid argument specified\n");
1373 return NULL;
1376 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1378 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1380 TRACE("iface %p, index %u\n", This, index);
1382 if (index >= This->technique_count)
1384 WARN("Invalid argument specified.\n");
1385 return NULL;
1388 TRACE("Returning technique %p\n", This->technique_handles[index]);
1390 return This->technique_handles[index];
1393 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1395 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1396 unsigned int i;
1398 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1400 if (!name)
1402 WARN("Invalid argument specified.\n");
1403 return NULL;
1406 for (i = 0; i < This->technique_count; ++i)
1408 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1410 if (!strcmp(tech->name, name))
1412 TRACE("Returning technique %p\n", This->technique_handles[i]);
1413 return This->technique_handles[i];
1417 WARN("Invalid argument specified.\n");
1419 return NULL;
1422 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1424 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1425 struct d3dx_technique *tech = is_valid_technique(This, technique);
1427 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1429 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1431 if (tech && index < tech->pass_count)
1433 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1434 return tech->pass_handles[index];
1437 WARN("Invalid argument specified.\n");
1439 return NULL;
1442 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1444 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1445 struct d3dx_technique *tech = is_valid_technique(This, technique);
1447 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1449 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1451 if (tech && name)
1453 unsigned int i;
1455 for (i = 0; i < tech->pass_count; ++i)
1457 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1459 if (!strcmp(pass->name, name))
1461 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1462 return tech->pass_handles[i];
1467 WARN("Invalid argument specified.\n");
1469 return NULL;
1472 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1474 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1476 FIXME("iface %p, index %u stub\n", This, index);
1478 return NULL;
1481 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1483 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1485 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1487 return NULL;
1490 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1492 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1493 struct d3dx_parameter *param = get_valid_parameter(This, object);
1494 struct d3dx_pass *pass = is_valid_pass(This, object);
1495 struct d3dx_technique *technique = is_valid_technique(This, object);
1496 UINT annotation_count = 0;
1497 D3DXHANDLE *annotation_handles = NULL;
1499 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1501 if (pass)
1503 annotation_count = pass->annotation_count;
1504 annotation_handles = pass->annotation_handles;
1506 else if (technique)
1508 annotation_count = technique->annotation_count;
1509 annotation_handles = technique->annotation_handles;
1511 else if (param)
1513 annotation_count = param->annotation_count;
1514 annotation_handles = param->annotation_handles;
1516 /* Todo: add funcs */
1518 if (index < annotation_count)
1520 TRACE("Returning parameter %p\n", annotation_handles[index]);
1521 return annotation_handles[index];
1524 WARN("Invalid argument specified\n");
1526 return NULL;
1529 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1531 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1532 struct d3dx_parameter *param = get_valid_parameter(This, object);
1533 struct d3dx_pass *pass = is_valid_pass(This, object);
1534 struct d3dx_technique *technique = is_valid_technique(This, object);
1535 UINT annotation_count = 0, i;
1536 D3DXHANDLE *annotation_handles = NULL;
1538 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1540 if (!name)
1542 WARN("Invalid argument specified\n");
1543 return NULL;
1546 if (pass)
1548 annotation_count = pass->annotation_count;
1549 annotation_handles = pass->annotation_handles;
1551 else if (technique)
1553 annotation_count = technique->annotation_count;
1554 annotation_handles = technique->annotation_handles;
1556 else if (param)
1558 annotation_count = param->annotation_count;
1559 annotation_handles = param->annotation_handles;
1561 /* Todo: add funcs */
1563 for (i = 0; i < annotation_count; i++)
1565 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1567 if (!strcmp(anno->name, name))
1569 TRACE("Returning parameter %p\n", anno);
1570 return get_parameter_handle(anno);
1574 WARN("Invalid argument specified\n");
1576 return NULL;
1579 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1581 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1583 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1585 return E_NOTIMPL;
1588 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1590 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1591 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1593 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1595 if (!param)
1597 WARN("Invalid parameter %p specified\n", parameter);
1598 return D3DERR_INVALIDCALL;
1601 /* samplers don't touch data */
1602 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1603 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1604 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1606 TRACE("Sampler: returning E_FAIL\n");
1607 return E_FAIL;
1610 if (data && param->bytes <= bytes)
1612 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1614 switch (param->type)
1616 case D3DXPT_VOID:
1617 case D3DXPT_BOOL:
1618 case D3DXPT_INT:
1619 case D3DXPT_FLOAT:
1620 case D3DXPT_STRING:
1621 break;
1623 case D3DXPT_VERTEXSHADER:
1624 case D3DXPT_PIXELSHADER:
1625 case D3DXPT_TEXTURE:
1626 case D3DXPT_TEXTURE1D:
1627 case D3DXPT_TEXTURE2D:
1628 case D3DXPT_TEXTURE3D:
1629 case D3DXPT_TEXTURECUBE:
1631 UINT i;
1633 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1635 IUnknown *unk = ((IUnknown **)param->data)[i];
1636 if (unk) IUnknown_AddRef(unk);
1638 break;
1641 default:
1642 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1643 break;
1646 TRACE("Copy %u bytes\n", param->bytes);
1647 memcpy(data, param->data, param->bytes);
1648 return D3D_OK;
1651 WARN("Invalid argument specified\n");
1653 return D3DERR_INVALIDCALL;
1656 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1658 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1659 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1661 TRACE("iface %p, parameter %p, b %s\n", This, parameter, b ? "TRUE" : "FALSE");
1663 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1665 set_number(param->data, param->type, &b, D3DXPT_BOOL);
1666 return D3D_OK;
1669 WARN("Invalid argument specified\n");
1671 return D3DERR_INVALIDCALL;
1674 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1676 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1677 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1679 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1681 if (b && param && !param->element_count && param->rows == 1 && param->columns == 1)
1683 *b = get_bool(param->data);
1684 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1685 return D3D_OK;
1688 WARN("Invalid argument specified\n");
1690 return D3DERR_INVALIDCALL;
1693 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1695 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1697 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1699 return E_NOTIMPL;
1702 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1704 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1705 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1707 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1709 if (b && param && (param->class == D3DXPC_SCALAR
1710 || param->class == D3DXPC_VECTOR
1711 || param->class == D3DXPC_MATRIX_ROWS
1712 || param->class == D3DXPC_MATRIX_COLUMNS))
1714 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1716 for (i = 0; i < size; ++i)
1718 b[i] = get_bool((DWORD *)param->data + i);
1720 return D3D_OK;
1723 WARN("Invalid argument specified\n");
1725 return D3DERR_INVALIDCALL;
1728 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1730 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1731 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1733 TRACE("iface %p, parameter %p, n %i\n", This, parameter, n);
1735 if (param && !param->element_count)
1737 if (param->rows == 1 && param->columns == 1)
1739 set_number(param->data, param->type, &n, D3DXPT_INT);
1740 return D3D_OK;
1744 * Split the value, if parameter is a vector with dimension 3 or 4.
1746 if (param->type == D3DXPT_FLOAT &&
1747 ((param->class == D3DXPC_VECTOR && param->columns != 2) ||
1748 (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1750 FLOAT tmp = ((n & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
1751 set_number((DWORD *)param->data, param->type, &tmp, D3DXPT_FLOAT);
1753 tmp = ((n & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
1754 set_number((DWORD *)param->data + 1, param->type, &tmp, D3DXPT_FLOAT);
1756 tmp = (n & 0xff) * INT_FLOAT_MULTI_INVERSE;
1757 set_number((DWORD *)param->data + 2, param->type, &tmp, D3DXPT_FLOAT);
1759 if (param->rows * param->columns > 3)
1761 tmp = ((n & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
1762 set_number((DWORD *)param->data + 3, param->type, &tmp, D3DXPT_FLOAT);
1764 return D3D_OK;
1768 WARN("Invalid argument specified\n");
1770 return D3DERR_INVALIDCALL;
1773 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1775 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1776 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1778 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1780 if (n && param && !param->element_count)
1782 if (param->columns == 1 && param->rows == 1)
1784 *n = get_int(param->type, param->data);
1785 TRACE("Returning %i\n", *n);
1786 return D3D_OK;
1789 if (param->type == D3DXPT_FLOAT &&
1790 ((param->class == D3DXPC_VECTOR && param->columns != 2)
1791 || (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1793 /* all components (3,4) are clamped (0,255) and put in the INT */
1794 *n = (INT)(min(max(0.0f, *((FLOAT *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI);
1795 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
1796 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
1797 if (param->columns * param->rows > 3)
1799 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
1802 TRACE("Returning %i\n", *n);
1803 return D3D_OK;
1807 WARN("Invalid argument specified\n");
1809 return D3DERR_INVALIDCALL;
1812 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1814 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1815 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1817 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1819 if (param)
1821 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1823 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1825 switch (param->class)
1827 case D3DXPC_SCALAR:
1828 case D3DXPC_VECTOR:
1829 case D3DXPC_MATRIX_ROWS:
1830 for (i = 0; i < size; ++i)
1832 set_number((DWORD *)param->data + i, param->type, &n[i], D3DXPT_INT);
1834 return D3D_OK;
1836 case D3DXPC_OBJECT:
1837 case D3DXPC_STRUCT:
1838 break;
1840 default:
1841 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1842 break;
1846 WARN("Invalid argument specified\n");
1848 return D3DERR_INVALIDCALL;
1851 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1853 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1854 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1856 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1858 if (n && param && (param->class == D3DXPC_SCALAR
1859 || param->class == D3DXPC_VECTOR
1860 || param->class == D3DXPC_MATRIX_ROWS
1861 || param->class == D3DXPC_MATRIX_COLUMNS))
1863 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1865 for (i = 0; i < size; ++i)
1867 n[i] = get_int(param->type, (DWORD *)param->data + i);
1869 return D3D_OK;
1872 WARN("Invalid argument specified\n");
1874 return D3DERR_INVALIDCALL;
1877 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1879 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1880 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1882 TRACE("iface %p, parameter %p, f %f\n", This, parameter, f);
1884 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1886 set_number((DWORD *)param->data, param->type, &f, D3DXPT_FLOAT);
1887 return D3D_OK;
1890 WARN("Invalid argument specified\n");
1892 return D3DERR_INVALIDCALL;
1895 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1897 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1898 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1900 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1902 if (f && param && !param->element_count && param->columns == 1 && param->rows == 1)
1904 *f = get_float(param->type, (DWORD *)param->data);
1905 TRACE("Returning %f\n", *f);
1906 return D3D_OK;
1909 WARN("Invalid argument specified\n");
1911 return D3DERR_INVALIDCALL;
1914 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1916 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1917 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1919 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1921 if (param)
1923 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1925 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1927 switch (param->class)
1929 case D3DXPC_SCALAR:
1930 case D3DXPC_VECTOR:
1931 case D3DXPC_MATRIX_ROWS:
1932 for (i = 0; i < size; ++i)
1934 set_number((DWORD *)param->data + i, param->type, &f[i], D3DXPT_FLOAT);
1936 return D3D_OK;
1938 case D3DXPC_OBJECT:
1939 case D3DXPC_STRUCT:
1940 break;
1942 default:
1943 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1944 break;
1948 WARN("Invalid argument specified\n");
1950 return D3DERR_INVALIDCALL;
1953 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1955 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1956 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1958 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1960 if (f && param && (param->class == D3DXPC_SCALAR
1961 || param->class == D3DXPC_VECTOR
1962 || param->class == D3DXPC_MATRIX_ROWS
1963 || param->class == D3DXPC_MATRIX_COLUMNS))
1965 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1967 for (i = 0; i < size; ++i)
1969 f[i] = get_float(param->type, (DWORD *)param->data + i);
1971 return D3D_OK;
1974 WARN("Invalid argument specified\n");
1976 return D3DERR_INVALIDCALL;
1979 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1981 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1983 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1985 return E_NOTIMPL;
1988 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1990 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1992 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1994 return E_NOTIMPL;
1997 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1999 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2001 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
2003 return E_NOTIMPL;
2006 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2008 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2009 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2011 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
2013 if (!count) return D3D_OK;
2015 if (vector && param && count <= param->element_count)
2017 UINT i;
2019 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2021 switch (param->class)
2023 case D3DXPC_VECTOR:
2024 for (i = 0; i < count; ++i)
2026 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2028 return D3D_OK;
2030 case D3DXPC_SCALAR:
2031 case D3DXPC_MATRIX_ROWS:
2032 case D3DXPC_OBJECT:
2033 case D3DXPC_STRUCT:
2034 break;
2036 default:
2037 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2038 break;
2042 WARN("Invalid argument specified\n");
2044 return D3DERR_INVALIDCALL;
2047 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2049 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2051 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
2053 return E_NOTIMPL;
2056 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2058 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2059 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2061 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2063 if (matrix && param && !param->element_count)
2065 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2067 switch (param->class)
2069 case D3DXPC_MATRIX_ROWS:
2070 get_matrix(param, matrix);
2071 return D3D_OK;
2073 case D3DXPC_SCALAR:
2074 case D3DXPC_VECTOR:
2075 case D3DXPC_OBJECT:
2076 case D3DXPC_STRUCT:
2077 break;
2079 default:
2080 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2081 break;
2085 WARN("Invalid argument specified\n");
2087 return D3DERR_INVALIDCALL;
2090 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2092 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2094 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2096 return E_NOTIMPL;
2099 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2101 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2102 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2104 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2106 if (!count) return D3D_OK;
2108 if (matrix && param && count <= param->element_count)
2110 UINT i;
2112 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2114 switch (param->class)
2116 case D3DXPC_MATRIX_ROWS:
2117 for (i = 0; i < count; ++i)
2119 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i]);
2121 return D3D_OK;
2123 case D3DXPC_SCALAR:
2124 case D3DXPC_VECTOR:
2125 case D3DXPC_OBJECT:
2126 case D3DXPC_STRUCT:
2127 break;
2129 default:
2130 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2131 break;
2135 WARN("Invalid argument specified\n");
2137 return D3DERR_INVALIDCALL;
2140 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2142 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2144 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2146 return E_NOTIMPL;
2149 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2151 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2153 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2155 return E_NOTIMPL;
2158 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2160 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2162 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
2164 return E_NOTIMPL;
2167 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2169 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2170 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2171 D3DXMATRIX m;
2173 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2175 if (matrix && param && !param->element_count)
2177 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2179 switch (param->class)
2181 case D3DXPC_SCALAR:
2182 case D3DXPC_VECTOR:
2183 get_matrix(param, matrix);
2184 return D3D_OK;
2186 case D3DXPC_MATRIX_ROWS:
2187 get_matrix(param, &m);
2188 D3DXMatrixTranspose(matrix, &m);
2189 return D3D_OK;
2191 case D3DXPC_OBJECT:
2192 case D3DXPC_STRUCT:
2193 break;
2195 default:
2196 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2197 break;
2201 WARN("Invalid argument specified\n");
2203 return D3DERR_INVALIDCALL;
2206 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2208 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2210 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2212 return E_NOTIMPL;
2215 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2217 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2218 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2220 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2222 if (!count) return D3D_OK;
2224 if (matrix && param && count <= param->element_count)
2226 UINT i;
2228 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2230 switch (param->class)
2232 case D3DXPC_MATRIX_ROWS:
2233 for (i = 0; i < count; ++i)
2235 D3DXMATRIX m;
2237 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2238 D3DXMatrixTranspose(&matrix[i], &m);
2240 return D3D_OK;
2242 case D3DXPC_SCALAR:
2243 case D3DXPC_VECTOR:
2244 case D3DXPC_OBJECT:
2245 case D3DXPC_STRUCT:
2246 break;
2248 default:
2249 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2250 break;
2254 WARN("Invalid argument specified\n");
2256 return D3DERR_INVALIDCALL;
2259 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2261 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2263 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2265 return E_NOTIMPL;
2268 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2270 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2272 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2274 return E_NOTIMPL;
2277 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2279 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2281 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2283 return E_NOTIMPL;
2286 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2288 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2289 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2291 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2293 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2295 *string = *(LPCSTR *)param->data;
2296 TRACE("Returning %s\n", debugstr_a(*string));
2297 return D3D_OK;
2300 WARN("Invalid argument specified\n");
2302 return D3DERR_INVALIDCALL;
2305 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2307 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2308 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2310 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2312 if (param && !param->element_count &&
2313 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2314 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2315 || param->type == D3DXPT_TEXTURECUBE))
2317 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2319 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2320 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2322 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2324 return D3D_OK;
2327 WARN("Invalid argument specified\n");
2329 return D3DERR_INVALIDCALL;
2332 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2334 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2335 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2337 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2339 if (texture && param && !param->element_count &&
2340 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2341 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2342 || param->type == D3DXPT_TEXTURECUBE))
2344 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2345 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2346 TRACE("Returning %p\n", *texture);
2347 return D3D_OK;
2350 WARN("Invalid argument specified\n");
2352 return D3DERR_INVALIDCALL;
2355 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2357 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2358 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2360 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2362 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2364 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2365 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2366 TRACE("Returning %p\n", *pshader);
2367 return D3D_OK;
2370 WARN("Invalid argument specified\n");
2372 return D3DERR_INVALIDCALL;
2375 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2377 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2378 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2380 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2382 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2384 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2385 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2386 TRACE("Returning %p\n", *vshader);
2387 return D3D_OK;
2390 WARN("Invalid argument specified\n");
2392 return D3DERR_INVALIDCALL;
2395 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2397 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2399 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2401 return E_NOTIMPL;
2404 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2406 /*** IUnknown methods ***/
2407 ID3DXBaseEffectImpl_QueryInterface,
2408 ID3DXBaseEffectImpl_AddRef,
2409 ID3DXBaseEffectImpl_Release,
2410 /*** ID3DXBaseEffect methods ***/
2411 ID3DXBaseEffectImpl_GetDesc,
2412 ID3DXBaseEffectImpl_GetParameterDesc,
2413 ID3DXBaseEffectImpl_GetTechniqueDesc,
2414 ID3DXBaseEffectImpl_GetPassDesc,
2415 ID3DXBaseEffectImpl_GetFunctionDesc,
2416 ID3DXBaseEffectImpl_GetParameter,
2417 ID3DXBaseEffectImpl_GetParameterByName,
2418 ID3DXBaseEffectImpl_GetParameterBySemantic,
2419 ID3DXBaseEffectImpl_GetParameterElement,
2420 ID3DXBaseEffectImpl_GetTechnique,
2421 ID3DXBaseEffectImpl_GetTechniqueByName,
2422 ID3DXBaseEffectImpl_GetPass,
2423 ID3DXBaseEffectImpl_GetPassByName,
2424 ID3DXBaseEffectImpl_GetFunction,
2425 ID3DXBaseEffectImpl_GetFunctionByName,
2426 ID3DXBaseEffectImpl_GetAnnotation,
2427 ID3DXBaseEffectImpl_GetAnnotationByName,
2428 ID3DXBaseEffectImpl_SetValue,
2429 ID3DXBaseEffectImpl_GetValue,
2430 ID3DXBaseEffectImpl_SetBool,
2431 ID3DXBaseEffectImpl_GetBool,
2432 ID3DXBaseEffectImpl_SetBoolArray,
2433 ID3DXBaseEffectImpl_GetBoolArray,
2434 ID3DXBaseEffectImpl_SetInt,
2435 ID3DXBaseEffectImpl_GetInt,
2436 ID3DXBaseEffectImpl_SetIntArray,
2437 ID3DXBaseEffectImpl_GetIntArray,
2438 ID3DXBaseEffectImpl_SetFloat,
2439 ID3DXBaseEffectImpl_GetFloat,
2440 ID3DXBaseEffectImpl_SetFloatArray,
2441 ID3DXBaseEffectImpl_GetFloatArray,
2442 ID3DXBaseEffectImpl_SetVector,
2443 ID3DXBaseEffectImpl_GetVector,
2444 ID3DXBaseEffectImpl_SetVectorArray,
2445 ID3DXBaseEffectImpl_GetVectorArray,
2446 ID3DXBaseEffectImpl_SetMatrix,
2447 ID3DXBaseEffectImpl_GetMatrix,
2448 ID3DXBaseEffectImpl_SetMatrixArray,
2449 ID3DXBaseEffectImpl_GetMatrixArray,
2450 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2451 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2452 ID3DXBaseEffectImpl_SetMatrixTranspose,
2453 ID3DXBaseEffectImpl_GetMatrixTranspose,
2454 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2455 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2456 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2457 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2458 ID3DXBaseEffectImpl_SetString,
2459 ID3DXBaseEffectImpl_GetString,
2460 ID3DXBaseEffectImpl_SetTexture,
2461 ID3DXBaseEffectImpl_GetTexture,
2462 ID3DXBaseEffectImpl_GetPixelShader,
2463 ID3DXBaseEffectImpl_GetVertexShader,
2464 ID3DXBaseEffectImpl_SetArrayRange,
2467 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2469 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2472 /*** IUnknown methods ***/
2473 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2475 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2477 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2479 if (IsEqualGUID(riid, &IID_IUnknown) ||
2480 IsEqualGUID(riid, &IID_ID3DXEffect))
2482 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2483 *object = This;
2484 return S_OK;
2487 ERR("Interface %s not found\n", debugstr_guid(riid));
2489 return E_NOINTERFACE;
2492 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2494 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2496 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2498 return InterlockedIncrement(&This->ref);
2501 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2503 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2504 ULONG ref = InterlockedDecrement(&This->ref);
2506 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2508 if (!ref)
2510 free_effect(This);
2511 HeapFree(GetProcessHeap(), 0, This);
2514 return ref;
2517 /*** ID3DXBaseEffect methods ***/
2518 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2520 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2521 ID3DXBaseEffect *base = This->base_effect;
2523 TRACE("Forward iface %p, base %p\n", This, base);
2525 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2528 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2530 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2531 ID3DXBaseEffect *base = This->base_effect;
2533 TRACE("Forward iface %p, base %p\n", This, base);
2535 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2538 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2540 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2541 ID3DXBaseEffect *base = This->base_effect;
2543 TRACE("Forward iface %p, base %p\n", This, base);
2545 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2548 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2550 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2551 ID3DXBaseEffect *base = This->base_effect;
2553 TRACE("Forward iface %p, base %p\n", This, base);
2555 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2558 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2560 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2561 ID3DXBaseEffect *base = This->base_effect;
2563 TRACE("Forward iface %p, base %p\n", This, base);
2565 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2568 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2570 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2571 ID3DXBaseEffect *base = This->base_effect;
2573 TRACE("Forward iface %p, base %p\n", This, base);
2575 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2578 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2580 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2581 ID3DXBaseEffect *base = This->base_effect;
2583 TRACE("Forward iface %p, base %p\n", This, base);
2585 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2588 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2590 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2591 ID3DXBaseEffect *base = This->base_effect;
2593 TRACE("Forward iface %p, base %p\n", This, base);
2595 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2598 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2600 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2601 ID3DXBaseEffect *base = This->base_effect;
2603 TRACE("Forward iface %p, base %p\n", This, base);
2605 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2608 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2610 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2611 ID3DXBaseEffect *base = This->base_effect;
2613 TRACE("Forward iface %p, base %p\n", This, base);
2615 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2618 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2620 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2621 ID3DXBaseEffect *base = This->base_effect;
2623 TRACE("Forward iface %p, base %p\n", This, base);
2625 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2628 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2630 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2631 ID3DXBaseEffect *base = This->base_effect;
2633 TRACE("Forward iface %p, base %p\n", This, base);
2635 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2638 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2640 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2641 ID3DXBaseEffect *base = This->base_effect;
2643 TRACE("Forward iface %p, base %p\n", This, base);
2645 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2648 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2650 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2651 ID3DXBaseEffect *base = This->base_effect;
2653 TRACE("Forward iface %p, base %p\n", This, base);
2655 return ID3DXBaseEffectImpl_GetFunction(base, index);
2658 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2660 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2661 ID3DXBaseEffect *base = This->base_effect;
2663 TRACE("Forward iface %p, base %p\n", This, base);
2665 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2668 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2670 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2671 ID3DXBaseEffect *base = This->base_effect;
2673 TRACE("Forward iface %p, base %p\n", This, base);
2675 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2678 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2680 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2681 ID3DXBaseEffect *base = This->base_effect;
2683 TRACE("Forward iface %p, base %p\n", This, base);
2685 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2688 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2690 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2691 ID3DXBaseEffect *base = This->base_effect;
2693 TRACE("Forward iface %p, base %p\n", This, base);
2695 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2698 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2700 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2701 ID3DXBaseEffect *base = This->base_effect;
2703 TRACE("Forward iface %p, base %p\n", This, base);
2705 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2708 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2710 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2711 ID3DXBaseEffect *base = This->base_effect;
2713 TRACE("Forward iface %p, base %p\n", This, base);
2715 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2718 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2720 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2721 ID3DXBaseEffect *base = This->base_effect;
2723 TRACE("Forward iface %p, base %p\n", This, base);
2725 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2728 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2730 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2731 ID3DXBaseEffect *base = This->base_effect;
2733 TRACE("Forward iface %p, base %p\n", This, base);
2735 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2738 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2740 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2741 ID3DXBaseEffect *base = This->base_effect;
2743 TRACE("Forward iface %p, base %p\n", This, base);
2745 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2748 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2750 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2751 ID3DXBaseEffect *base = This->base_effect;
2753 TRACE("Forward iface %p, base %p\n", This, base);
2755 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2758 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2760 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2761 ID3DXBaseEffect *base = This->base_effect;
2763 TRACE("Forward iface %p, base %p\n", This, base);
2765 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2768 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2770 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2771 ID3DXBaseEffect *base = This->base_effect;
2773 TRACE("Forward iface %p, base %p\n", This, base);
2775 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2778 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2780 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2781 ID3DXBaseEffect *base = This->base_effect;
2783 TRACE("Forward iface %p, base %p\n", This, base);
2785 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2788 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2790 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2791 ID3DXBaseEffect *base = This->base_effect;
2793 TRACE("Forward iface %p, base %p\n", This, base);
2795 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2798 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2800 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2801 ID3DXBaseEffect *base = This->base_effect;
2803 TRACE("Forward iface %p, base %p\n", This, base);
2805 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2808 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2810 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2811 ID3DXBaseEffect *base = This->base_effect;
2813 TRACE("Forward iface %p, base %p\n", This, base);
2815 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2818 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2820 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2821 ID3DXBaseEffect *base = This->base_effect;
2823 TRACE("Forward iface %p, base %p\n", This, base);
2825 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2828 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2830 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2831 ID3DXBaseEffect *base = This->base_effect;
2833 TRACE("Forward iface %p, base %p\n", This, base);
2835 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2838 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2840 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2841 ID3DXBaseEffect *base = This->base_effect;
2843 TRACE("Forward iface %p, base %p\n", This, base);
2845 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2848 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2850 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2851 ID3DXBaseEffect *base = This->base_effect;
2853 TRACE("Forward iface %p, base %p\n", This, base);
2855 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2858 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2860 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2861 ID3DXBaseEffect *base = This->base_effect;
2863 TRACE("Forward iface %p, base %p\n", This, base);
2865 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2868 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2870 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2871 ID3DXBaseEffect *base = This->base_effect;
2873 TRACE("Forward iface %p, base %p\n", This, base);
2875 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2878 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2880 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2881 ID3DXBaseEffect *base = This->base_effect;
2883 TRACE("Forward iface %p, base %p\n", This, base);
2885 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2888 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2890 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2891 ID3DXBaseEffect *base = This->base_effect;
2893 TRACE("Forward iface %p, base %p\n", This, base);
2895 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2898 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2900 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2901 ID3DXBaseEffect *base = This->base_effect;
2903 TRACE("Forward iface %p, base %p\n", This, base);
2905 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2908 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2910 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2911 ID3DXBaseEffect *base = This->base_effect;
2913 TRACE("Forward iface %p, base %p\n", This, base);
2915 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2918 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2920 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2921 ID3DXBaseEffect *base = This->base_effect;
2923 TRACE("Forward iface %p, base %p\n", This, base);
2925 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2928 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2930 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2931 ID3DXBaseEffect *base = This->base_effect;
2933 TRACE("Forward iface %p, base %p\n", This, base);
2935 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2938 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2940 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2941 ID3DXBaseEffect *base = This->base_effect;
2943 TRACE("Forward iface %p, base %p\n", This, base);
2945 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2948 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2950 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2951 ID3DXBaseEffect *base = This->base_effect;
2953 TRACE("Forward iface %p, base %p\n", This, base);
2955 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2958 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2960 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2961 ID3DXBaseEffect *base = This->base_effect;
2963 TRACE("Forward iface %p, base %p\n", This, base);
2965 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2968 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2970 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2971 ID3DXBaseEffect *base = This->base_effect;
2973 TRACE("Forward iface %p, base %p\n", This, base);
2975 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2978 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2980 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2981 ID3DXBaseEffect *base = This->base_effect;
2983 TRACE("Forward iface %p, base %p\n", This, base);
2985 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2988 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2990 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2991 ID3DXBaseEffect *base = This->base_effect;
2993 TRACE("Forward iface %p, base %p\n", This, base);
2995 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2998 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3000 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3001 ID3DXBaseEffect *base = This->base_effect;
3003 TRACE("Forward iface %p, base %p\n", This, base);
3005 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3008 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3010 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3011 ID3DXBaseEffect *base = This->base_effect;
3013 TRACE("Forward iface %p, base %p\n", This, base);
3015 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3018 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3020 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3021 ID3DXBaseEffect *base = This->base_effect;
3023 TRACE("Forward iface %p, base %p\n", This, base);
3025 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3028 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3030 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3031 ID3DXBaseEffect *base = This->base_effect;
3033 TRACE("Forward iface %p, base %p\n", This, base);
3035 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3038 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3040 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3041 ID3DXBaseEffect *base = This->base_effect;
3043 TRACE("Forward iface %p, base %p\n", This, base);
3045 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3048 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3050 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3051 ID3DXBaseEffect *base = This->base_effect;
3053 TRACE("Forward iface %p, base %p\n", This, base);
3055 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3058 /*** ID3DXEffect methods ***/
3059 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
3061 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3063 TRACE("iface %p, pool %p\n", This, pool);
3065 if (!pool)
3067 WARN("Invalid argument supplied.\n");
3068 return D3DERR_INVALIDCALL;
3071 if (This->pool)
3073 This->pool->lpVtbl->AddRef(This->pool);
3076 *pool = This->pool;
3078 TRACE("Returning pool %p\n", *pool);
3080 return S_OK;
3083 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3085 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3086 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3087 struct d3dx_technique *tech = is_valid_technique(base, technique);
3089 TRACE("iface %p, technique %p\n", This, technique);
3091 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
3093 if (tech)
3095 UINT i;
3097 for (i = 0; i < base->technique_count; ++i)
3099 struct d3dx_technique *t = get_technique_struct(base->technique_handles[i]);
3101 if (tech == t)
3103 This->active_technique = get_technique_handle(t);
3104 TRACE("Technique %u (%p)\n", i, tech);
3105 return D3D_OK;
3110 WARN("Invalid argument supplied.\n");
3112 return D3DERR_INVALIDCALL;
3115 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3117 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3119 TRACE("iface %p\n", This);
3121 return This->active_technique;
3124 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3126 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3128 FIXME("(%p)->(%p): stub\n", This, technique);
3130 return D3D_OK;
3133 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3135 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3137 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3139 return E_NOTIMPL;
3142 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3144 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3146 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3148 return FALSE;
3151 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3153 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3154 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3156 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3158 if (passes && technique)
3160 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3162 TRACE("State capturing disabled.\n");
3164 else
3166 FIXME("State capturing not supported, yet!\n");
3169 *passes = technique->pass_count;
3171 return D3D_OK;
3174 WARN("Invalid argument supplied.\n");
3176 return D3DERR_INVALIDCALL;
3179 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3181 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3182 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3184 TRACE("iface %p, pass %u\n", This, pass);
3186 if (technique && pass < technique->pass_count && !This->active_pass)
3188 This->active_pass = technique->pass_handles[pass];
3190 FIXME("No states applied, yet!\n");
3192 return D3D_OK;
3195 WARN("Invalid argument supplied.\n");
3197 return D3DERR_INVALIDCALL;
3200 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3202 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3204 FIXME("(%p)->(): stub\n", This);
3206 return E_NOTIMPL;
3209 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3211 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3213 TRACE("iface %p\n", This);
3215 if (This->active_pass)
3217 This->active_pass = NULL;
3218 return D3D_OK;
3221 WARN("Invalid call.\n");
3223 return D3DERR_INVALIDCALL;
3226 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3228 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3230 FIXME("(%p)->(): stub\n", This);
3232 return E_NOTIMPL;
3235 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3237 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3239 TRACE("iface %p, device %p\n", This, device);
3241 if (!device)
3243 WARN("Invalid argument supplied.\n");
3244 return D3DERR_INVALIDCALL;
3247 IDirect3DDevice9_AddRef(This->device);
3249 *device = This->device;
3251 TRACE("Returning device %p\n", *device);
3253 return S_OK;
3256 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3258 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3260 FIXME("(%p)->(): stub\n", This);
3262 return E_NOTIMPL;
3265 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3267 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3269 FIXME("(%p)->(): stub\n", This);
3271 return E_NOTIMPL;
3274 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3276 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3278 TRACE("iface %p, manager %p\n", This, manager);
3280 if (manager) IUnknown_AddRef(manager);
3281 if (This->manager) IUnknown_Release(This->manager);
3283 This->manager = manager;
3285 return D3D_OK;
3288 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3290 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3292 TRACE("iface %p, manager %p\n", This, manager);
3294 if (!manager)
3296 WARN("Invalid argument supplied.\n");
3297 return D3DERR_INVALIDCALL;
3300 if (This->manager) IUnknown_AddRef(This->manager);
3301 *manager = This->manager;
3303 return D3D_OK;
3306 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3308 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3310 FIXME("(%p)->(): stub\n", This);
3312 return E_NOTIMPL;
3315 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3317 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3319 FIXME("(%p)->(): stub\n", This);
3321 return NULL;
3324 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3326 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3328 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3330 return E_NOTIMPL;
3333 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3335 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3337 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3339 return E_NOTIMPL;
3342 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3344 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3346 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3348 return E_NOTIMPL;
3351 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3353 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3355 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3357 return E_NOTIMPL;
3360 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3362 /*** IUnknown methods ***/
3363 ID3DXEffectImpl_QueryInterface,
3364 ID3DXEffectImpl_AddRef,
3365 ID3DXEffectImpl_Release,
3366 /*** ID3DXBaseEffect methods ***/
3367 ID3DXEffectImpl_GetDesc,
3368 ID3DXEffectImpl_GetParameterDesc,
3369 ID3DXEffectImpl_GetTechniqueDesc,
3370 ID3DXEffectImpl_GetPassDesc,
3371 ID3DXEffectImpl_GetFunctionDesc,
3372 ID3DXEffectImpl_GetParameter,
3373 ID3DXEffectImpl_GetParameterByName,
3374 ID3DXEffectImpl_GetParameterBySemantic,
3375 ID3DXEffectImpl_GetParameterElement,
3376 ID3DXEffectImpl_GetTechnique,
3377 ID3DXEffectImpl_GetTechniqueByName,
3378 ID3DXEffectImpl_GetPass,
3379 ID3DXEffectImpl_GetPassByName,
3380 ID3DXEffectImpl_GetFunction,
3381 ID3DXEffectImpl_GetFunctionByName,
3382 ID3DXEffectImpl_GetAnnotation,
3383 ID3DXEffectImpl_GetAnnotationByName,
3384 ID3DXEffectImpl_SetValue,
3385 ID3DXEffectImpl_GetValue,
3386 ID3DXEffectImpl_SetBool,
3387 ID3DXEffectImpl_GetBool,
3388 ID3DXEffectImpl_SetBoolArray,
3389 ID3DXEffectImpl_GetBoolArray,
3390 ID3DXEffectImpl_SetInt,
3391 ID3DXEffectImpl_GetInt,
3392 ID3DXEffectImpl_SetIntArray,
3393 ID3DXEffectImpl_GetIntArray,
3394 ID3DXEffectImpl_SetFloat,
3395 ID3DXEffectImpl_GetFloat,
3396 ID3DXEffectImpl_SetFloatArray,
3397 ID3DXEffectImpl_GetFloatArray,
3398 ID3DXEffectImpl_SetVector,
3399 ID3DXEffectImpl_GetVector,
3400 ID3DXEffectImpl_SetVectorArray,
3401 ID3DXEffectImpl_GetVectorArray,
3402 ID3DXEffectImpl_SetMatrix,
3403 ID3DXEffectImpl_GetMatrix,
3404 ID3DXEffectImpl_SetMatrixArray,
3405 ID3DXEffectImpl_GetMatrixArray,
3406 ID3DXEffectImpl_SetMatrixPointerArray,
3407 ID3DXEffectImpl_GetMatrixPointerArray,
3408 ID3DXEffectImpl_SetMatrixTranspose,
3409 ID3DXEffectImpl_GetMatrixTranspose,
3410 ID3DXEffectImpl_SetMatrixTransposeArray,
3411 ID3DXEffectImpl_GetMatrixTransposeArray,
3412 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3413 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3414 ID3DXEffectImpl_SetString,
3415 ID3DXEffectImpl_GetString,
3416 ID3DXEffectImpl_SetTexture,
3417 ID3DXEffectImpl_GetTexture,
3418 ID3DXEffectImpl_GetPixelShader,
3419 ID3DXEffectImpl_GetVertexShader,
3420 ID3DXEffectImpl_SetArrayRange,
3421 /*** ID3DXEffect methods ***/
3422 ID3DXEffectImpl_GetPool,
3423 ID3DXEffectImpl_SetTechnique,
3424 ID3DXEffectImpl_GetCurrentTechnique,
3425 ID3DXEffectImpl_ValidateTechnique,
3426 ID3DXEffectImpl_FindNextValidTechnique,
3427 ID3DXEffectImpl_IsParameterUsed,
3428 ID3DXEffectImpl_Begin,
3429 ID3DXEffectImpl_BeginPass,
3430 ID3DXEffectImpl_CommitChanges,
3431 ID3DXEffectImpl_EndPass,
3432 ID3DXEffectImpl_End,
3433 ID3DXEffectImpl_GetDevice,
3434 ID3DXEffectImpl_OnLostDevice,
3435 ID3DXEffectImpl_OnResetDevice,
3436 ID3DXEffectImpl_SetStateManager,
3437 ID3DXEffectImpl_GetStateManager,
3438 ID3DXEffectImpl_BeginParameterBlock,
3439 ID3DXEffectImpl_EndParameterBlock,
3440 ID3DXEffectImpl_ApplyParameterBlock,
3441 ID3DXEffectImpl_DeleteParameterBlock,
3442 ID3DXEffectImpl_CloneEffect,
3443 ID3DXEffectImpl_SetRawValue
3446 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3448 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3451 /*** IUnknown methods ***/
3452 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3454 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3456 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3458 if (IsEqualGUID(riid, &IID_IUnknown) ||
3459 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3461 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3462 *object = This;
3463 return S_OK;
3466 ERR("Interface %s not found\n", debugstr_guid(riid));
3468 return E_NOINTERFACE;
3471 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3473 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3475 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3477 return InterlockedIncrement(&This->ref);
3480 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3482 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3483 ULONG ref = InterlockedDecrement(&This->ref);
3485 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3487 if (!ref)
3489 free_effect_compiler(This);
3490 HeapFree(GetProcessHeap(), 0, This);
3493 return ref;
3496 /*** ID3DXBaseEffect methods ***/
3497 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3499 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3500 ID3DXBaseEffect *base = This->base_effect;
3502 TRACE("Forward iface %p, base %p\n", This, base);
3504 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3507 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3509 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3510 ID3DXBaseEffect *base = This->base_effect;
3512 TRACE("Forward iface %p, base %p\n", This, base);
3514 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3517 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3519 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3520 ID3DXBaseEffect *base = This->base_effect;
3522 TRACE("Forward iface %p, base %p\n", This, base);
3524 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3527 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3529 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3530 ID3DXBaseEffect *base = This->base_effect;
3532 TRACE("Forward iface %p, base %p\n", This, base);
3534 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3537 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3539 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3540 ID3DXBaseEffect *base = This->base_effect;
3542 TRACE("Forward iface %p, base %p\n", This, base);
3544 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3547 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3549 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3550 ID3DXBaseEffect *base = This->base_effect;
3552 TRACE("Forward iface %p, base %p\n", This, base);
3554 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3557 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3559 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3560 ID3DXBaseEffect *base = This->base_effect;
3562 TRACE("Forward iface %p, base %p\n", This, base);
3564 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3567 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3569 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3570 ID3DXBaseEffect *base = This->base_effect;
3572 TRACE("Forward iface %p, base %p\n", This, base);
3574 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3577 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3579 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3580 ID3DXBaseEffect *base = This->base_effect;
3582 TRACE("Forward iface %p, base %p\n", This, base);
3584 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3587 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3589 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3590 ID3DXBaseEffect *base = This->base_effect;
3592 TRACE("Forward iface %p, base %p\n", This, base);
3594 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3597 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3599 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3600 ID3DXBaseEffect *base = This->base_effect;
3602 TRACE("Forward iface %p, base %p\n", This, base);
3604 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3607 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3609 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3610 ID3DXBaseEffect *base = This->base_effect;
3612 TRACE("Forward iface %p, base %p\n", This, base);
3614 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3617 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3619 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3620 ID3DXBaseEffect *base = This->base_effect;
3622 TRACE("Forward iface %p, base %p\n", This, base);
3624 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3627 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3629 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3630 ID3DXBaseEffect *base = This->base_effect;
3632 TRACE("Forward iface %p, base %p\n", This, base);
3634 return ID3DXBaseEffectImpl_GetFunction(base, index);
3637 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3639 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3640 ID3DXBaseEffect *base = This->base_effect;
3642 TRACE("Forward iface %p, base %p\n", This, base);
3644 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3647 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3649 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3650 ID3DXBaseEffect *base = This->base_effect;
3652 TRACE("Forward iface %p, base %p\n", This, base);
3654 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3657 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3659 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3660 ID3DXBaseEffect *base = This->base_effect;
3662 TRACE("Forward iface %p, base %p\n", This, base);
3664 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3667 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3669 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3670 ID3DXBaseEffect *base = This->base_effect;
3672 TRACE("Forward iface %p, base %p\n", This, base);
3674 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3677 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3679 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3680 ID3DXBaseEffect *base = This->base_effect;
3682 TRACE("Forward iface %p, base %p\n", This, base);
3684 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3687 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3689 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3690 ID3DXBaseEffect *base = This->base_effect;
3692 TRACE("Forward iface %p, base %p\n", This, base);
3694 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3697 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3699 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3700 ID3DXBaseEffect *base = This->base_effect;
3702 TRACE("Forward iface %p, base %p\n", This, base);
3704 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3707 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3709 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3710 ID3DXBaseEffect *base = This->base_effect;
3712 TRACE("Forward iface %p, base %p\n", This, base);
3714 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3717 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3719 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3720 ID3DXBaseEffect *base = This->base_effect;
3722 TRACE("Forward iface %p, base %p\n", This, base);
3724 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3727 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3729 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3730 ID3DXBaseEffect *base = This->base_effect;
3732 TRACE("Forward iface %p, base %p\n", This, base);
3734 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3737 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3739 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3740 ID3DXBaseEffect *base = This->base_effect;
3742 TRACE("Forward iface %p, base %p\n", This, base);
3744 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3747 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3749 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3750 ID3DXBaseEffect *base = This->base_effect;
3752 TRACE("Forward iface %p, base %p\n", This, base);
3754 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3757 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3759 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3760 ID3DXBaseEffect *base = This->base_effect;
3762 TRACE("Forward iface %p, base %p\n", This, base);
3764 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3767 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3769 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3770 ID3DXBaseEffect *base = This->base_effect;
3772 TRACE("Forward iface %p, base %p\n", This, base);
3774 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3777 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3779 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3780 ID3DXBaseEffect *base = This->base_effect;
3782 TRACE("Forward iface %p, base %p\n", This, base);
3784 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3787 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3789 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3790 ID3DXBaseEffect *base = This->base_effect;
3792 TRACE("Forward iface %p, base %p\n", This, base);
3794 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3797 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3799 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3800 ID3DXBaseEffect *base = This->base_effect;
3802 TRACE("Forward iface %p, base %p\n", This, base);
3804 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3807 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3809 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3810 ID3DXBaseEffect *base = This->base_effect;
3812 TRACE("Forward iface %p, base %p\n", This, base);
3814 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3817 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3819 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3820 ID3DXBaseEffect *base = This->base_effect;
3822 TRACE("Forward iface %p, base %p\n", This, base);
3824 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3827 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3829 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3830 ID3DXBaseEffect *base = This->base_effect;
3832 TRACE("Forward iface %p, base %p\n", This, base);
3834 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3837 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3839 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3840 ID3DXBaseEffect *base = This->base_effect;
3842 TRACE("Forward iface %p, base %p\n", This, base);
3844 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3847 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3849 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3850 ID3DXBaseEffect *base = This->base_effect;
3852 TRACE("Forward iface %p, base %p\n", This, base);
3854 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3857 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3859 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3860 ID3DXBaseEffect *base = This->base_effect;
3862 TRACE("Forward iface %p, base %p\n", This, base);
3864 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3867 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3869 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3870 ID3DXBaseEffect *base = This->base_effect;
3872 TRACE("Forward iface %p, base %p\n", This, base);
3874 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3877 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3879 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3880 ID3DXBaseEffect *base = This->base_effect;
3882 TRACE("Forward iface %p, base %p\n", This, base);
3884 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3887 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3889 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3890 ID3DXBaseEffect *base = This->base_effect;
3892 TRACE("Forward iface %p, base %p\n", This, base);
3894 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3897 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3899 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3900 ID3DXBaseEffect *base = This->base_effect;
3902 TRACE("Forward iface %p, base %p\n", This, base);
3904 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3907 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3909 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3910 ID3DXBaseEffect *base = This->base_effect;
3912 TRACE("Forward iface %p, base %p\n", This, base);
3914 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3917 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3919 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3920 ID3DXBaseEffect *base = This->base_effect;
3922 TRACE("Forward iface %p, base %p\n", This, base);
3924 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3927 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3929 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3930 ID3DXBaseEffect *base = This->base_effect;
3932 TRACE("Forward iface %p, base %p\n", This, base);
3934 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3937 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3939 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3940 ID3DXBaseEffect *base = This->base_effect;
3942 TRACE("Forward iface %p, base %p\n", This, base);
3944 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3947 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3949 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3950 ID3DXBaseEffect *base = This->base_effect;
3952 TRACE("Forward iface %p, base %p\n", This, base);
3954 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3957 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3959 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3960 ID3DXBaseEffect *base = This->base_effect;
3962 TRACE("Forward iface %p, base %p\n", This, base);
3964 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3967 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3969 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3970 ID3DXBaseEffect *base = This->base_effect;
3972 TRACE("Forward iface %p, base %p\n", This, base);
3974 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3977 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3979 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3980 ID3DXBaseEffect *base = This->base_effect;
3982 TRACE("Forward iface %p, base %p\n", This, base);
3984 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3987 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3989 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3990 ID3DXBaseEffect *base = This->base_effect;
3992 TRACE("Forward iface %p, base %p\n", This, base);
3994 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3997 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3999 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4000 ID3DXBaseEffect *base = This->base_effect;
4002 TRACE("Forward iface %p, base %p\n", This, base);
4004 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4007 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
4009 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4010 ID3DXBaseEffect *base = This->base_effect;
4012 TRACE("Forward iface %p, base %p\n", This, base);
4014 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
4017 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
4019 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4020 ID3DXBaseEffect *base = This->base_effect;
4022 TRACE("Forward iface %p, base %p\n", This, base);
4024 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
4027 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4029 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4030 ID3DXBaseEffect *base = This->base_effect;
4032 TRACE("Forward iface %p, base %p\n", This, base);
4034 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4037 /*** ID3DXEffectCompiler methods ***/
4038 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4040 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4042 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4044 return E_NOTIMPL;
4047 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4049 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4051 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4053 return E_NOTIMPL;
4056 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4057 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
4059 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4061 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4063 return E_NOTIMPL;
4066 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4067 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
4069 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4071 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4072 This, function, target, flags, shader, error_msgs, constant_table);
4074 return E_NOTIMPL;
4077 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4079 /*** IUnknown methods ***/
4080 ID3DXEffectCompilerImpl_QueryInterface,
4081 ID3DXEffectCompilerImpl_AddRef,
4082 ID3DXEffectCompilerImpl_Release,
4083 /*** ID3DXBaseEffect methods ***/
4084 ID3DXEffectCompilerImpl_GetDesc,
4085 ID3DXEffectCompilerImpl_GetParameterDesc,
4086 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4087 ID3DXEffectCompilerImpl_GetPassDesc,
4088 ID3DXEffectCompilerImpl_GetFunctionDesc,
4089 ID3DXEffectCompilerImpl_GetParameter,
4090 ID3DXEffectCompilerImpl_GetParameterByName,
4091 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4092 ID3DXEffectCompilerImpl_GetParameterElement,
4093 ID3DXEffectCompilerImpl_GetTechnique,
4094 ID3DXEffectCompilerImpl_GetTechniqueByName,
4095 ID3DXEffectCompilerImpl_GetPass,
4096 ID3DXEffectCompilerImpl_GetPassByName,
4097 ID3DXEffectCompilerImpl_GetFunction,
4098 ID3DXEffectCompilerImpl_GetFunctionByName,
4099 ID3DXEffectCompilerImpl_GetAnnotation,
4100 ID3DXEffectCompilerImpl_GetAnnotationByName,
4101 ID3DXEffectCompilerImpl_SetValue,
4102 ID3DXEffectCompilerImpl_GetValue,
4103 ID3DXEffectCompilerImpl_SetBool,
4104 ID3DXEffectCompilerImpl_GetBool,
4105 ID3DXEffectCompilerImpl_SetBoolArray,
4106 ID3DXEffectCompilerImpl_GetBoolArray,
4107 ID3DXEffectCompilerImpl_SetInt,
4108 ID3DXEffectCompilerImpl_GetInt,
4109 ID3DXEffectCompilerImpl_SetIntArray,
4110 ID3DXEffectCompilerImpl_GetIntArray,
4111 ID3DXEffectCompilerImpl_SetFloat,
4112 ID3DXEffectCompilerImpl_GetFloat,
4113 ID3DXEffectCompilerImpl_SetFloatArray,
4114 ID3DXEffectCompilerImpl_GetFloatArray,
4115 ID3DXEffectCompilerImpl_SetVector,
4116 ID3DXEffectCompilerImpl_GetVector,
4117 ID3DXEffectCompilerImpl_SetVectorArray,
4118 ID3DXEffectCompilerImpl_GetVectorArray,
4119 ID3DXEffectCompilerImpl_SetMatrix,
4120 ID3DXEffectCompilerImpl_GetMatrix,
4121 ID3DXEffectCompilerImpl_SetMatrixArray,
4122 ID3DXEffectCompilerImpl_GetMatrixArray,
4123 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4124 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4125 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4126 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4127 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4128 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4129 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4130 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4131 ID3DXEffectCompilerImpl_SetString,
4132 ID3DXEffectCompilerImpl_GetString,
4133 ID3DXEffectCompilerImpl_SetTexture,
4134 ID3DXEffectCompilerImpl_GetTexture,
4135 ID3DXEffectCompilerImpl_GetPixelShader,
4136 ID3DXEffectCompilerImpl_GetVertexShader,
4137 ID3DXEffectCompilerImpl_SetArrayRange,
4138 /*** ID3DXEffectCompiler methods ***/
4139 ID3DXEffectCompilerImpl_SetLiteral,
4140 ID3DXEffectCompilerImpl_GetLiteral,
4141 ID3DXEffectCompilerImpl_CompileEffect,
4142 ID3DXEffectCompilerImpl_CompileShader,
4145 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4147 HRESULT hr;
4148 UINT i;
4149 struct d3dx_state *states;
4151 read_dword(ptr, &sampler->state_count);
4152 TRACE("Count: %u\n", sampler->state_count);
4154 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4155 if (!states)
4157 ERR("Out of memory\n");
4158 return E_OUTOFMEMORY;
4161 for (i = 0; i < sampler->state_count; ++i)
4163 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4164 if (hr != D3D_OK)
4166 WARN("Failed to parse state\n");
4167 goto err_out;
4171 sampler->states = states;
4173 return D3D_OK;
4175 err_out:
4177 for (i = 0; i < sampler->state_count; ++i)
4179 free_state(&states[i]);
4182 HeapFree(GetProcessHeap(), 0, states);
4184 return hr;
4187 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4189 unsigned int i;
4190 HRESULT hr;
4191 UINT old_size = 0;
4192 DWORD id;
4194 if (param->element_count)
4196 param->data = value;
4198 for (i = 0; i < param->element_count; ++i)
4200 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4202 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4203 if (hr != D3D_OK)
4205 WARN("Failed to parse value\n");
4206 return hr;
4209 old_size += member->bytes;
4212 return D3D_OK;
4215 switch(param->class)
4217 case D3DXPC_SCALAR:
4218 case D3DXPC_VECTOR:
4219 case D3DXPC_MATRIX_ROWS:
4220 case D3DXPC_MATRIX_COLUMNS:
4221 param->data = value;
4222 break;
4224 case D3DXPC_STRUCT:
4225 param->data = value;
4227 for (i = 0; i < param->member_count; ++i)
4229 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4231 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4232 if (hr != D3D_OK)
4234 WARN("Failed to parse value\n");
4235 return hr;
4238 old_size += member->bytes;
4240 break;
4242 case D3DXPC_OBJECT:
4243 switch (param->type)
4245 case D3DXPT_STRING:
4246 case D3DXPT_TEXTURE:
4247 case D3DXPT_TEXTURE1D:
4248 case D3DXPT_TEXTURE2D:
4249 case D3DXPT_TEXTURE3D:
4250 case D3DXPT_TEXTURECUBE:
4251 case D3DXPT_PIXELSHADER:
4252 case D3DXPT_VERTEXSHADER:
4253 read_dword(ptr, &id);
4254 TRACE("Id: %u\n", id);
4255 objects[id] = get_parameter_handle(param);
4256 param->data = value;
4257 break;
4259 case D3DXPT_SAMPLER:
4260 case D3DXPT_SAMPLER1D:
4261 case D3DXPT_SAMPLER2D:
4262 case D3DXPT_SAMPLER3D:
4263 case D3DXPT_SAMPLERCUBE:
4265 struct d3dx_sampler *sampler;
4267 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4268 if (!sampler)
4270 ERR("Out of memory\n");
4271 return E_OUTOFMEMORY;
4274 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4275 if (hr != D3D_OK)
4277 HeapFree(GetProcessHeap(), 0, sampler);
4278 WARN("Failed to parse sampler\n");
4279 return hr;
4282 param->data = sampler;
4283 break;
4286 default:
4287 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4288 break;
4290 break;
4292 default:
4293 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4294 break;
4297 return D3D_OK;
4300 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4302 UINT size = param->bytes;
4303 HRESULT hr;
4304 void *value = NULL;
4306 TRACE("param size: %u\n", size);
4308 if (size)
4310 value = HeapAlloc(GetProcessHeap(), 0, size);
4311 if (!value)
4313 ERR("Failed to allocate data memory.\n");
4314 return E_OUTOFMEMORY;
4317 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4318 memcpy(value, ptr, size);
4321 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4322 if (hr != D3D_OK)
4324 WARN("Failed to parse value\n");
4325 HeapFree(GetProcessHeap(), 0, value);
4326 return hr;
4329 return D3D_OK;
4332 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4334 DWORD size;
4336 read_dword(&ptr, &size);
4337 TRACE("Name size: %#x\n", size);
4339 if (!size)
4341 return D3D_OK;
4344 *name = HeapAlloc(GetProcessHeap(), 0, size);
4345 if (!*name)
4347 ERR("Failed to allocate name memory.\n");
4348 return E_OUTOFMEMORY;
4351 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4352 memcpy(*name, ptr, size);
4354 return D3D_OK;
4357 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4359 DWORD size;
4361 read_dword(ptr, &size);
4362 TRACE("Data size: %#x\n", size);
4364 *str = HeapAlloc(GetProcessHeap(), 0, size);
4365 if (!*str)
4367 ERR("Failed to allocate name memory.\n");
4368 return E_OUTOFMEMORY;
4371 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4372 memcpy(*str, *ptr, size);
4374 *ptr += ((size + 3) & ~3);
4376 return D3D_OK;
4379 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4381 DWORD size;
4382 HRESULT hr;
4384 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4386 read_dword(ptr, &size);
4387 TRACE("Data size: %#x\n", size);
4389 if (!size)
4391 TRACE("Size is 0\n");
4392 *(void **)param->data = NULL;
4393 return D3D_OK;
4396 switch (param->type)
4398 case D3DXPT_STRING:
4399 /* re-read with size (sizeof(DWORD) = 4) */
4400 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4401 if (hr != D3D_OK)
4403 WARN("Failed to parse string data\n");
4404 return hr;
4406 break;
4408 case D3DXPT_VERTEXSHADER:
4409 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4410 if (hr != D3D_OK)
4412 WARN("Failed to create vertex shader\n");
4413 return hr;
4415 break;
4417 case D3DXPT_PIXELSHADER:
4418 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4419 if (hr != D3D_OK)
4421 WARN("Failed to create pixel shader\n");
4422 return hr;
4424 break;
4426 default:
4427 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4428 break;
4432 *ptr += ((size + 3) & ~3);
4434 return D3D_OK;
4437 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4438 struct d3dx_parameter *parent, UINT flags)
4440 DWORD offset;
4441 HRESULT hr;
4442 D3DXHANDLE *member_handles = NULL;
4443 UINT i;
4445 param->flags = flags;
4447 if (!parent)
4449 read_dword(ptr, &param->type);
4450 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4452 read_dword(ptr, &param->class);
4453 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4455 read_dword(ptr, &offset);
4456 TRACE("Type name offset: %#x\n", offset);
4457 hr = d3dx9_parse_name(&param->name, data + offset);
4458 if (hr != D3D_OK)
4460 WARN("Failed to parse name\n");
4461 goto err_out;
4464 read_dword(ptr, &offset);
4465 TRACE("Type semantic offset: %#x\n", offset);
4466 hr = d3dx9_parse_name(&param->semantic, data + offset);
4467 if (hr != D3D_OK)
4469 WARN("Failed to parse semantic\n");
4470 goto err_out;
4473 read_dword(ptr, &param->element_count);
4474 TRACE("Elements: %u\n", param->element_count);
4476 switch (param->class)
4478 case D3DXPC_VECTOR:
4479 read_dword(ptr, &param->columns);
4480 TRACE("Columns: %u\n", param->columns);
4482 read_dword(ptr, &param->rows);
4483 TRACE("Rows: %u\n", param->rows);
4485 /* sizeof(DWORD) * rows * columns */
4486 param->bytes = 4 * param->rows * param->columns;
4487 break;
4489 case D3DXPC_SCALAR:
4490 case D3DXPC_MATRIX_ROWS:
4491 case D3DXPC_MATRIX_COLUMNS:
4492 read_dword(ptr, &param->rows);
4493 TRACE("Rows: %u\n", param->rows);
4495 read_dword(ptr, &param->columns);
4496 TRACE("Columns: %u\n", param->columns);
4498 /* sizeof(DWORD) * rows * columns */
4499 param->bytes = 4 * param->rows * param->columns;
4500 break;
4502 case D3DXPC_STRUCT:
4503 read_dword(ptr, &param->member_count);
4504 TRACE("Members: %u\n", param->member_count);
4505 break;
4507 case D3DXPC_OBJECT:
4508 switch (param->type)
4510 case D3DXPT_STRING:
4511 param->bytes = sizeof(LPCSTR);
4512 break;
4514 case D3DXPT_PIXELSHADER:
4515 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4516 break;
4518 case D3DXPT_VERTEXSHADER:
4519 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4520 break;
4522 case D3DXPT_TEXTURE:
4523 case D3DXPT_TEXTURE1D:
4524 case D3DXPT_TEXTURE2D:
4525 case D3DXPT_TEXTURE3D:
4526 case D3DXPT_TEXTURECUBE:
4527 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4528 break;
4530 case D3DXPT_SAMPLER:
4531 case D3DXPT_SAMPLER1D:
4532 case D3DXPT_SAMPLER2D:
4533 case D3DXPT_SAMPLER3D:
4534 case D3DXPT_SAMPLERCUBE:
4535 param->bytes = 0;
4536 break;
4538 default:
4539 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4540 break;
4542 break;
4544 default:
4545 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4546 break;
4549 else
4551 /* elements */
4552 param->type = parent->type;
4553 param->class = parent->class;
4554 param->name = parent->name;
4555 param->semantic = parent->semantic;
4556 param->element_count = 0;
4557 param->annotation_count = 0;
4558 param->member_count = parent->member_count;
4559 param->bytes = parent->bytes;
4560 param->rows = parent->rows;
4561 param->columns = parent->columns;
4564 if (param->element_count)
4566 unsigned int param_bytes = 0;
4567 const char *save_ptr = *ptr;
4569 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4570 if (!member_handles)
4572 ERR("Out of memory\n");
4573 hr = E_OUTOFMEMORY;
4574 goto err_out;
4577 for (i = 0; i < param->element_count; ++i)
4579 struct d3dx_parameter *member;
4580 *ptr = save_ptr;
4582 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4583 if (!member)
4585 ERR("Out of memory\n");
4586 hr = E_OUTOFMEMORY;
4587 goto err_out;
4590 member_handles[i] = get_parameter_handle(member);
4592 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4593 if (hr != D3D_OK)
4595 WARN("Failed to parse member\n");
4596 goto err_out;
4599 param_bytes += member->bytes;
4602 param->bytes = param_bytes;
4604 else if (param->member_count)
4606 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4607 if (!member_handles)
4609 ERR("Out of memory\n");
4610 hr = E_OUTOFMEMORY;
4611 goto err_out;
4614 for (i = 0; i < param->member_count; ++i)
4616 struct d3dx_parameter *member;
4618 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4619 if (!member)
4621 ERR("Out of memory\n");
4622 hr = E_OUTOFMEMORY;
4623 goto err_out;
4626 member_handles[i] = get_parameter_handle(member);
4628 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4629 if (hr != D3D_OK)
4631 WARN("Failed to parse member\n");
4632 goto err_out;
4635 param->bytes += member->bytes;
4639 param->member_handles = member_handles;
4641 return D3D_OK;
4643 err_out:
4645 if (member_handles)
4647 unsigned int count;
4649 if (param->element_count) count = param->element_count;
4650 else count = param->member_count;
4652 for (i = 0; i < count; ++i)
4654 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4656 HeapFree(GetProcessHeap(), 0, member_handles);
4659 if (!parent)
4661 HeapFree(GetProcessHeap(), 0, param->name);
4662 HeapFree(GetProcessHeap(), 0, param->semantic);
4664 param->name = NULL;
4665 param->semantic = NULL;
4667 return hr;
4670 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4672 DWORD offset;
4673 const char *ptr2;
4674 HRESULT hr;
4676 anno->flags = D3DX_PARAMETER_ANNOTATION;
4678 read_dword(ptr, &offset);
4679 TRACE("Typedef offset: %#x\n", offset);
4680 ptr2 = data + offset;
4681 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4682 if (hr != D3D_OK)
4684 WARN("Failed to parse type definition\n");
4685 return hr;
4688 read_dword(ptr, &offset);
4689 TRACE("Value offset: %#x\n", offset);
4690 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4691 if (hr != D3D_OK)
4693 WARN("Failed to parse value\n");
4694 return hr;
4697 return D3D_OK;
4700 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4702 DWORD offset;
4703 const char *ptr2;
4704 HRESULT hr;
4705 struct d3dx_parameter *parameter;
4707 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4708 if (!parameter)
4710 ERR("Out of memory\n");
4711 return E_OUTOFMEMORY;
4714 state->type = ST_CONSTANT;
4716 read_dword(ptr, &state->operation);
4717 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4719 read_dword(ptr, &state->index);
4720 TRACE("Index: %#x\n", state->index);
4722 read_dword(ptr, &offset);
4723 TRACE("Typedef offset: %#x\n", offset);
4724 ptr2 = data + offset;
4725 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4726 if (hr != D3D_OK)
4728 WARN("Failed to parse type definition\n");
4729 goto err_out;
4732 read_dword(ptr, &offset);
4733 TRACE("Value offset: %#x\n", offset);
4734 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4735 if (hr != D3D_OK)
4737 WARN("Failed to parse value\n");
4738 goto err_out;
4741 state->parameter = get_parameter_handle(parameter);
4743 return D3D_OK;
4745 err_out:
4747 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4749 return hr;
4752 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4754 DWORD offset;
4755 HRESULT hr;
4756 unsigned int i;
4757 D3DXHANDLE *annotation_handles = NULL;
4758 const char *ptr2;
4760 read_dword(ptr, &offset);
4761 TRACE("Typedef offset: %#x\n", offset);
4762 ptr2 = data + offset;
4764 read_dword(ptr, &offset);
4765 TRACE("Value offset: %#x\n", offset);
4767 read_dword(ptr, &param->flags);
4768 TRACE("Flags: %#x\n", param->flags);
4770 read_dword(ptr, &param->annotation_count);
4771 TRACE("Annotation count: %u\n", param->annotation_count);
4773 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4774 if (hr != D3D_OK)
4776 WARN("Failed to parse type definition\n");
4777 return hr;
4780 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4781 if (hr != D3D_OK)
4783 WARN("Failed to parse value\n");
4784 return hr;
4787 if (param->annotation_count)
4789 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4790 if (!annotation_handles)
4792 ERR("Out of memory\n");
4793 hr = E_OUTOFMEMORY;
4794 goto err_out;
4797 for (i = 0; i < param->annotation_count; ++i)
4799 struct d3dx_parameter *annotation;
4801 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4802 if (!annotation)
4804 ERR("Out of memory\n");
4805 hr = E_OUTOFMEMORY;
4806 goto err_out;
4809 annotation_handles[i] = get_parameter_handle(annotation);
4811 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4812 if (hr != D3D_OK)
4814 WARN("Failed to parse annotation\n");
4815 goto err_out;
4820 param->annotation_handles = annotation_handles;
4822 return D3D_OK;
4824 err_out:
4826 if (annotation_handles)
4828 for (i = 0; i < param->annotation_count; ++i)
4830 free_parameter(annotation_handles[i], FALSE, FALSE);
4832 HeapFree(GetProcessHeap(), 0, annotation_handles);
4835 return hr;
4838 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4840 DWORD offset;
4841 HRESULT hr;
4842 unsigned int i;
4843 D3DXHANDLE *annotation_handles = NULL;
4844 struct d3dx_state *states = NULL;
4845 char *name = NULL;
4847 read_dword(ptr, &offset);
4848 TRACE("Pass name offset: %#x\n", offset);
4849 hr = d3dx9_parse_name(&name, data + offset);
4850 if (hr != D3D_OK)
4852 WARN("Failed to parse name\n");
4853 goto err_out;
4856 read_dword(ptr, &pass->annotation_count);
4857 TRACE("Annotation count: %u\n", pass->annotation_count);
4859 read_dword(ptr, &pass->state_count);
4860 TRACE("State count: %u\n", pass->state_count);
4862 if (pass->annotation_count)
4864 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4865 if (!annotation_handles)
4867 ERR("Out of memory\n");
4868 hr = E_OUTOFMEMORY;
4869 goto err_out;
4872 for (i = 0; i < pass->annotation_count; ++i)
4874 struct d3dx_parameter *annotation;
4876 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4877 if (!annotation)
4879 ERR("Out of memory\n");
4880 hr = E_OUTOFMEMORY;
4881 goto err_out;
4884 annotation_handles[i] = get_parameter_handle(annotation);
4886 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4887 if (hr != D3D_OK)
4889 WARN("Failed to parse annotations\n");
4890 goto err_out;
4895 if (pass->state_count)
4897 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4898 if (!states)
4900 ERR("Out of memory\n");
4901 hr = E_OUTOFMEMORY;
4902 goto err_out;
4905 for (i = 0; i < pass->state_count; ++i)
4907 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4908 if (hr != D3D_OK)
4910 WARN("Failed to parse annotations\n");
4911 goto err_out;
4916 pass->name = name;
4917 pass->annotation_handles = annotation_handles;
4918 pass->states = states;
4920 return D3D_OK;
4922 err_out:
4924 if (annotation_handles)
4926 for (i = 0; i < pass->annotation_count; ++i)
4928 free_parameter(annotation_handles[i], FALSE, FALSE);
4930 HeapFree(GetProcessHeap(), 0, annotation_handles);
4933 if (states)
4935 for (i = 0; i < pass->state_count; ++i)
4937 free_state(&states[i]);
4939 HeapFree(GetProcessHeap(), 0, states);
4942 HeapFree(GetProcessHeap(), 0, name);
4944 return hr;
4947 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4949 DWORD offset;
4950 HRESULT hr;
4951 unsigned int i;
4952 D3DXHANDLE *annotation_handles = NULL;
4953 D3DXHANDLE *pass_handles = NULL;
4954 char *name = NULL;
4956 read_dword(ptr, &offset);
4957 TRACE("Technique name offset: %#x\n", offset);
4958 hr = d3dx9_parse_name(&name, data + offset);
4959 if (hr != D3D_OK)
4961 WARN("Failed to parse name\n");
4962 goto err_out;
4965 read_dword(ptr, &technique->annotation_count);
4966 TRACE("Annotation count: %u\n", technique->annotation_count);
4968 read_dword(ptr, &technique->pass_count);
4969 TRACE("Pass count: %u\n", technique->pass_count);
4971 if (technique->annotation_count)
4973 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4974 if (!annotation_handles)
4976 ERR("Out of memory\n");
4977 hr = E_OUTOFMEMORY;
4978 goto err_out;
4981 for (i = 0; i < technique->annotation_count; ++i)
4983 struct d3dx_parameter *annotation;
4985 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4986 if (!annotation)
4988 ERR("Out of memory\n");
4989 hr = E_OUTOFMEMORY;
4990 goto err_out;
4993 annotation_handles[i] = get_parameter_handle(annotation);
4995 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4996 if (hr != D3D_OK)
4998 WARN("Failed to parse annotations\n");
4999 goto err_out;
5004 if (technique->pass_count)
5006 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5007 if (!pass_handles)
5009 ERR("Out of memory\n");
5010 hr = E_OUTOFMEMORY;
5011 goto err_out;
5014 for (i = 0; i < technique->pass_count; ++i)
5016 struct d3dx_pass *pass;
5018 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5019 if (!pass)
5021 ERR("Out of memory\n");
5022 hr = E_OUTOFMEMORY;
5023 goto err_out;
5026 pass_handles[i] = get_pass_handle(pass);
5028 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5029 if (hr != D3D_OK)
5031 WARN("Failed to parse passes\n");
5032 goto err_out;
5037 technique->name = name;
5038 technique->pass_handles = pass_handles;
5039 technique->annotation_handles = annotation_handles;
5041 return D3D_OK;
5043 err_out:
5045 if (pass_handles)
5047 for (i = 0; i < technique->pass_count; ++i)
5049 free_pass(pass_handles[i]);
5051 HeapFree(GetProcessHeap(), 0, pass_handles);
5054 if (annotation_handles)
5056 for (i = 0; i < technique->annotation_count; ++i)
5058 free_parameter(annotation_handles[i], FALSE, FALSE);
5060 HeapFree(GetProcessHeap(), 0, annotation_handles);
5063 HeapFree(GetProcessHeap(), 0, name);
5065 return hr;
5068 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5070 DWORD technique_index;
5071 DWORD index, state_index, usage, element_index;
5072 struct d3dx_state *state;
5073 struct d3dx_parameter *param;
5074 HRESULT hr = E_FAIL;
5076 read_dword(ptr, &technique_index);
5077 TRACE("techn: %u\n", technique_index);
5079 read_dword(ptr, &index);
5080 TRACE("index: %u\n", index);
5082 read_dword(ptr, &element_index);
5083 TRACE("element_index: %u\n", element_index);
5085 read_dword(ptr, &state_index);
5086 TRACE("state_index: %u\n", state_index);
5088 read_dword(ptr, &usage);
5089 TRACE("usage: %u\n", usage);
5091 if (technique_index == 0xffffffff)
5093 struct d3dx_parameter *parameter;
5094 struct d3dx_sampler *sampler;
5096 if (index >= base->parameter_count)
5098 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5099 return E_FAIL;
5102 parameter = get_parameter_struct(base->parameter_handles[index]);
5103 if (element_index != 0xffffffff)
5105 if (element_index >= parameter->element_count && parameter->element_count != 0)
5107 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5108 return E_FAIL;
5111 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5114 sampler = parameter->data;
5115 if (state_index >= sampler->state_count)
5117 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5118 return E_FAIL;
5121 state = &sampler->states[state_index];
5123 else
5125 struct d3dx_technique *technique;
5126 struct d3dx_pass *pass;
5128 if (technique_index >= base->technique_count)
5130 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5131 return E_FAIL;
5134 technique = get_technique_struct(base->technique_handles[technique_index]);
5135 if (index >= technique->pass_count)
5137 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5138 return E_FAIL;
5141 pass = get_pass_struct(technique->pass_handles[index]);
5142 if (state_index >= pass->state_count)
5144 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5145 return E_FAIL;
5148 state = &pass->states[state_index];
5151 param = get_parameter_struct(state->parameter);
5153 switch (usage)
5155 case 0:
5156 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5157 switch (param->type)
5159 case D3DXPT_VERTEXSHADER:
5160 case D3DXPT_PIXELSHADER:
5161 state->type = ST_CONSTANT;
5162 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5163 break;
5165 case D3DXPT_BOOL:
5166 case D3DXPT_INT:
5167 case D3DXPT_FLOAT:
5168 case D3DXPT_STRING:
5169 state->type = ST_FXLC;
5170 hr = d3dx9_copy_data(param->data, ptr);
5171 break;
5173 default:
5174 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5175 break;
5177 break;
5179 case 1:
5180 state->type = ST_PARAMETER;
5181 hr = d3dx9_copy_data(param->data, ptr);
5182 if (hr == D3D_OK)
5184 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5186 break;
5188 default:
5189 FIXME("Unknown usage %x\n", usage);
5190 break;
5193 return hr;
5196 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5198 const char *ptr = data + start;
5199 D3DXHANDLE *parameter_handles = NULL;
5200 D3DXHANDLE *technique_handles = NULL;
5201 D3DXHANDLE *objects = NULL;
5202 UINT stringcount, objectcount, resourcecount;
5203 HRESULT hr;
5204 UINT i;
5206 read_dword(&ptr, &base->parameter_count);
5207 TRACE("Parameter count: %u\n", base->parameter_count);
5209 read_dword(&ptr, &base->technique_count);
5210 TRACE("Technique count: %u\n", base->technique_count);
5212 skip_dword_unknown(&ptr, 1);
5214 read_dword(&ptr, &objectcount);
5215 TRACE("Object count: %u\n", objectcount);
5217 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5218 if (!objects)
5220 ERR("Out of memory\n");
5221 hr = E_OUTOFMEMORY;
5222 goto err_out;
5225 if (base->parameter_count)
5227 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5228 if (!parameter_handles)
5230 ERR("Out of memory\n");
5231 hr = E_OUTOFMEMORY;
5232 goto err_out;
5235 for (i = 0; i < base->parameter_count; ++i)
5237 struct d3dx_parameter *parameter;
5239 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5240 if (!parameter)
5242 ERR("Out of memory\n");
5243 hr = E_OUTOFMEMORY;
5244 goto err_out;
5247 parameter_handles[i] = get_parameter_handle(parameter);
5249 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5250 if (hr != D3D_OK)
5252 WARN("Failed to parse parameter\n");
5253 goto err_out;
5258 if (base->technique_count)
5260 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5261 if (!technique_handles)
5263 ERR("Out of memory\n");
5264 hr = E_OUTOFMEMORY;
5265 goto err_out;
5268 for (i = 0; i < base->technique_count; ++i)
5270 struct d3dx_technique *technique;
5272 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5273 if (!technique)
5275 ERR("Out of memory\n");
5276 hr = E_OUTOFMEMORY;
5277 goto err_out;
5280 technique_handles[i] = get_technique_handle(technique);
5282 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5283 if (hr != D3D_OK)
5285 WARN("Failed to parse technique\n");
5286 goto err_out;
5291 /* needed for further parsing */
5292 base->technique_handles = technique_handles;
5293 base->parameter_handles = parameter_handles;
5295 read_dword(&ptr, &stringcount);
5296 TRACE("String count: %u\n", stringcount);
5298 read_dword(&ptr, &resourcecount);
5299 TRACE("Resource count: %u\n", resourcecount);
5301 for (i = 0; i < stringcount; ++i)
5303 DWORD id;
5304 struct d3dx_parameter *param;
5306 read_dword(&ptr, &id);
5307 TRACE("Id: %u\n", id);
5309 param = get_parameter_struct(objects[id]);
5311 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5312 if (hr != D3D_OK)
5314 WARN("Failed to parse data\n");
5315 goto err_out;
5319 for (i = 0; i < resourcecount; ++i)
5321 TRACE("parse resource %u\n", i);
5323 hr = d3dx9_parse_resource(base, data, &ptr);
5324 if (hr != D3D_OK)
5326 WARN("Failed to parse data\n");
5327 goto err_out;
5331 HeapFree(GetProcessHeap(), 0, objects);
5333 return D3D_OK;
5335 err_out:
5337 if (technique_handles)
5339 for (i = 0; i < base->technique_count; ++i)
5341 free_technique(technique_handles[i]);
5343 HeapFree(GetProcessHeap(), 0, technique_handles);
5346 if (parameter_handles)
5348 for (i = 0; i < base->parameter_count; ++i)
5350 free_parameter(parameter_handles[i], FALSE, FALSE);
5352 HeapFree(GetProcessHeap(), 0, parameter_handles);
5355 base->technique_handles = NULL;
5356 base->parameter_handles = NULL;
5358 HeapFree(GetProcessHeap(), 0, objects);
5360 return hr;
5363 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5364 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5366 DWORD tag, offset;
5367 const char *ptr = data;
5368 HRESULT hr;
5370 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5372 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5373 base->ref = 1;
5374 base->effect = effect;
5376 read_dword(&ptr, &tag);
5377 TRACE("Tag: %x\n", tag);
5379 if (tag != d3dx9_effect_version(9, 1))
5381 /* todo: compile hlsl ascii code */
5382 FIXME("HLSL ascii effects not supported, yet\n");
5384 /* Show the start of the shader for debugging info. */
5385 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5387 else
5389 read_dword(&ptr, &offset);
5390 TRACE("Offset: %x\n", offset);
5392 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5393 if (hr != D3D_OK)
5395 FIXME("Failed to parse effect.\n");
5396 return hr;
5400 return D3D_OK;
5403 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5404 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5406 HRESULT hr;
5407 struct ID3DXBaseEffectImpl *object = NULL;
5409 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5411 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5412 effect->ref = 1;
5414 if (pool) pool->lpVtbl->AddRef(pool);
5415 effect->pool = pool;
5417 IDirect3DDevice9_AddRef(device);
5418 effect->device = device;
5420 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5421 if (!object)
5423 ERR("Out of memory\n");
5424 hr = E_OUTOFMEMORY;
5425 goto err_out;
5428 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5429 if (hr != D3D_OK)
5431 FIXME("Failed to parse effect.\n");
5432 goto err_out;
5435 effect->base_effect = &object->ID3DXBaseEffect_iface;
5437 /* initialize defaults - check because of unsupported ascii effects */
5438 if (object->technique_handles)
5440 effect->active_technique = object->technique_handles[0];
5441 effect->active_pass = NULL;
5444 return D3D_OK;
5446 err_out:
5448 HeapFree(GetProcessHeap(), 0, object);
5449 free_effect(effect);
5451 return hr;
5454 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5455 LPCVOID srcdata,
5456 UINT srcdatalen,
5457 CONST D3DXMACRO* defines,
5458 LPD3DXINCLUDE include,
5459 LPCSTR skip_constants,
5460 DWORD flags,
5461 LPD3DXEFFECTPOOL pool,
5462 LPD3DXEFFECT* effect,
5463 LPD3DXBUFFER* compilation_errors)
5465 struct ID3DXEffectImpl *object;
5466 HRESULT hr;
5468 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5469 skip_constants, flags, pool, effect, compilation_errors);
5471 if (!device || !srcdata)
5472 return D3DERR_INVALIDCALL;
5474 if (!srcdatalen)
5475 return E_FAIL;
5477 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5478 if (!effect)
5479 return D3D_OK;
5481 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5482 if (!object)
5484 ERR("Out of memory\n");
5485 return E_OUTOFMEMORY;
5488 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5489 if (FAILED(hr))
5491 WARN("Failed to initialize shader reflection\n");
5492 HeapFree(GetProcessHeap(), 0, object);
5493 return hr;
5496 *effect = &object->ID3DXEffect_iface;
5498 TRACE("Created ID3DXEffect %p\n", object);
5500 return D3D_OK;
5503 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5504 LPCVOID srcdata,
5505 UINT srcdatalen,
5506 CONST D3DXMACRO* defines,
5507 LPD3DXINCLUDE include,
5508 DWORD flags,
5509 LPD3DXEFFECTPOOL pool,
5510 LPD3DXEFFECT* effect,
5511 LPD3DXBUFFER* compilation_errors)
5513 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5514 include, flags, pool, effect, compilation_errors);
5516 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5519 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5521 HRESULT hr;
5522 struct ID3DXBaseEffectImpl *object = NULL;
5524 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5526 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5527 compiler->ref = 1;
5529 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5530 if (!object)
5532 ERR("Out of memory\n");
5533 hr = E_OUTOFMEMORY;
5534 goto err_out;
5537 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5538 if (hr != D3D_OK)
5540 FIXME("Failed to parse effect.\n");
5541 goto err_out;
5544 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5546 return D3D_OK;
5548 err_out:
5550 HeapFree(GetProcessHeap(), 0, object);
5551 free_effect_compiler(compiler);
5553 return hr;
5556 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5557 UINT srcdatalen,
5558 CONST D3DXMACRO *defines,
5559 LPD3DXINCLUDE include,
5560 DWORD flags,
5561 LPD3DXEFFECTCOMPILER *compiler,
5562 LPD3DXBUFFER *parse_errors)
5564 struct ID3DXEffectCompilerImpl *object;
5565 HRESULT hr;
5567 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5568 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5570 if (!srcdata || !compiler)
5572 WARN("Invalid arguments supplied\n");
5573 return D3DERR_INVALIDCALL;
5576 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5577 if (!object)
5579 ERR("Out of memory\n");
5580 return E_OUTOFMEMORY;
5583 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5584 if (FAILED(hr))
5586 WARN("Failed to initialize effect compiler\n");
5587 HeapFree(GetProcessHeap(), 0, object);
5588 return hr;
5591 *compiler = &object->ID3DXEffectCompiler_iface;
5593 TRACE("Created ID3DXEffectCompiler %p\n", object);
5595 return D3D_OK;
5598 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5600 struct ID3DXEffectPoolImpl
5602 ID3DXEffectPool ID3DXEffectPool_iface;
5603 LONG ref;
5606 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5608 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5611 /*** IUnknown methods ***/
5612 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5614 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5616 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5618 if (IsEqualGUID(riid, &IID_IUnknown) ||
5619 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5621 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5622 *object = This;
5623 return S_OK;
5626 WARN("Interface %s not found\n", debugstr_guid(riid));
5628 return E_NOINTERFACE;
5631 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5633 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5635 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5637 return InterlockedIncrement(&This->ref);
5640 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5642 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5643 ULONG ref = InterlockedDecrement(&This->ref);
5645 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5647 if (!ref)
5648 HeapFree(GetProcessHeap(), 0, This);
5650 return ref;
5653 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5655 /*** IUnknown methods ***/
5656 ID3DXEffectPoolImpl_QueryInterface,
5657 ID3DXEffectPoolImpl_AddRef,
5658 ID3DXEffectPoolImpl_Release
5661 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5663 struct ID3DXEffectPoolImpl *object;
5665 TRACE("(%p)\n", pool);
5667 if (!pool)
5668 return D3DERR_INVALIDCALL;
5670 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5671 if (!object)
5673 ERR("Out of memory\n");
5674 return E_OUTOFMEMORY;
5677 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5678 object->ref = 1;
5680 *pool = &object->ID3DXEffectPool_iface;
5682 return S_OK;
5685 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5686 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5687 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5689 LPVOID buffer;
5690 HRESULT ret;
5691 DWORD size;
5693 TRACE("(%s): relay\n", debugstr_w(srcfile));
5695 if (!device || !srcfile)
5696 return D3DERR_INVALIDCALL;
5698 ret = map_view_of_file(srcfile, &buffer, &size);
5700 if (FAILED(ret))
5701 return D3DXERR_INVALIDDATA;
5703 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5704 UnmapViewOfFile(buffer);
5706 return ret;
5709 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5710 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5711 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5713 LPWSTR srcfileW;
5714 HRESULT ret;
5715 DWORD len;
5717 TRACE("(void): relay\n");
5719 if (!srcfile)
5720 return D3DERR_INVALIDCALL;
5722 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5723 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5724 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5726 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5727 HeapFree(GetProcessHeap(), 0, srcfileW);
5729 return ret;
5732 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5733 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5734 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5736 TRACE("(void): relay\n");
5737 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5740 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5741 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5742 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5744 TRACE("(void): relay\n");
5745 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5748 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5749 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5750 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5752 HRSRC resinfo;
5754 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5756 if (!device)
5757 return D3DERR_INVALIDCALL;
5759 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5761 if (resinfo)
5763 LPVOID buffer;
5764 HRESULT ret;
5765 DWORD size;
5767 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5769 if (FAILED(ret))
5770 return D3DXERR_INVALIDDATA;
5772 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5775 return D3DXERR_INVALIDDATA;
5778 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5779 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5780 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5782 HRSRC resinfo;
5784 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5786 if (!device)
5787 return D3DERR_INVALIDCALL;
5789 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5791 if (resinfo)
5793 LPVOID buffer;
5794 HRESULT ret;
5795 DWORD size;
5797 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5799 if (FAILED(ret))
5800 return D3DXERR_INVALIDDATA;
5802 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5805 return D3DXERR_INVALIDDATA;
5808 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5809 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5810 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5812 TRACE("(void): relay\n");
5813 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5816 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5817 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5818 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5820 TRACE("(void): relay\n");
5821 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5824 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5825 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5827 LPVOID buffer;
5828 HRESULT ret;
5829 DWORD size;
5831 TRACE("(%s): relay\n", debugstr_w(srcfile));
5833 if (!srcfile)
5834 return D3DERR_INVALIDCALL;
5836 ret = map_view_of_file(srcfile, &buffer, &size);
5838 if (FAILED(ret))
5839 return D3DXERR_INVALIDDATA;
5841 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5842 UnmapViewOfFile(buffer);
5844 return ret;
5847 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5848 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5850 LPWSTR srcfileW;
5851 HRESULT ret;
5852 DWORD len;
5854 TRACE("(void): relay\n");
5856 if (!srcfile)
5857 return D3DERR_INVALIDCALL;
5859 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5860 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5861 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5863 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5864 HeapFree(GetProcessHeap(), 0, srcfileW);
5866 return ret;
5869 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5870 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5872 HRSRC resinfo;
5874 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5876 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5878 if (resinfo)
5880 LPVOID buffer;
5881 HRESULT ret;
5882 DWORD size;
5884 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5886 if (FAILED(ret))
5887 return D3DXERR_INVALIDDATA;
5889 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5892 return D3DXERR_INVALIDDATA;
5895 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5896 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5898 HRSRC resinfo;
5900 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5902 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5904 if (resinfo)
5906 LPVOID buffer;
5907 HRESULT ret;
5908 DWORD size;
5910 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5912 if (FAILED(ret))
5913 return D3DXERR_INVALIDDATA;
5915 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5918 return D3DXERR_INVALIDDATA;