d3dx9: Handle ST_PARAMETER in d3dx9_parse resource().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blobb4f19323f91a61fe5ffc98b625bb56e935ecd91f
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 #include "wine/debug.h"
22 #include "wine/unicode.h"
23 #include "windef.h"
24 #include "wingdi.h"
25 #include "d3dx9_36_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
29 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
30 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
31 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
33 enum STATE_CLASS
35 SC_LIGHTENABLE,
36 SC_FVF,
37 SC_LIGHT,
38 SC_MATERIAL,
39 SC_NPATCHMODE,
40 SC_PIXELSHADER,
41 SC_RENDERSTATE,
42 SC_SETSAMPLER,
43 SC_SAMPLERSTATE,
44 SC_TEXTURE,
45 SC_TEXTURESTAGE,
46 SC_TRANSFORM,
47 SC_VERTEXSHADER,
48 SC_SHADERCONST,
49 SC_UNKNOWN,
52 enum MATERIAL_TYPE
54 MT_DIFFUSE,
55 MT_AMBIENT,
56 MT_SPECULAR,
57 MT_EMISSIVE,
58 MT_POWER,
61 enum LIGHT_TYPE
63 LT_TYPE,
64 LT_DIFFUSE,
65 LT_SPECULAR,
66 LT_AMBIENT,
67 LT_POSITION,
68 LT_DIRECTION,
69 LT_RANGE,
70 LT_FALLOFF,
71 LT_ATTENUATION0,
72 LT_ATTENUATION1,
73 LT_ATTENUATION2,
74 LT_THETA,
75 LT_PHI,
78 enum SHADER_CONSTANT_TYPE
80 SCT_VSFLOAT,
81 SCT_VSBOOL,
82 SCT_VSINT,
83 SCT_PSFLOAT,
84 SCT_PSBOOL,
85 SCT_PSINT,
88 enum STATE_TYPE
90 ST_CONSTANT,
91 ST_PARAMETER,
92 ST_FXLC,
95 struct d3dx_parameter
97 char *name;
98 char *semantic;
99 void *data;
100 D3DXPARAMETER_CLASS class;
101 D3DXPARAMETER_TYPE type;
102 UINT rows;
103 UINT columns;
104 UINT element_count;
105 UINT annotation_count;
106 UINT member_count;
107 DWORD flags;
108 UINT bytes;
110 D3DXHANDLE *annotation_handles;
111 D3DXHANDLE *member_handles;
114 struct d3dx_state
116 UINT operation;
117 UINT index;
118 enum STATE_TYPE type;
119 D3DXHANDLE parameter;
122 struct d3dx_sampler
124 UINT state_count;
125 struct d3dx_state *states;
128 struct d3dx_pass
130 char *name;
131 UINT state_count;
132 UINT annotation_count;
134 struct d3dx_state *states;
135 D3DXHANDLE *annotation_handles;
138 struct d3dx_technique
140 char *name;
141 UINT pass_count;
142 UINT annotation_count;
144 D3DXHANDLE *annotation_handles;
145 D3DXHANDLE *pass_handles;
148 struct ID3DXBaseEffectImpl
150 ID3DXBaseEffect ID3DXBaseEffect_iface;
151 LONG ref;
153 struct ID3DXEffectImpl *effect;
155 UINT parameter_count;
156 UINT technique_count;
158 D3DXHANDLE *parameter_handles;
159 D3DXHANDLE *technique_handles;
162 struct ID3DXEffectImpl
164 ID3DXEffect ID3DXEffect_iface;
165 LONG ref;
167 LPD3DXEFFECTSTATEMANAGER manager;
168 LPDIRECT3DDEVICE9 device;
169 LPD3DXEFFECTPOOL pool;
170 D3DXHANDLE active_technique;
171 D3DXHANDLE active_pass;
173 ID3DXBaseEffect *base_effect;
176 struct ID3DXEffectCompilerImpl
178 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
179 LONG ref;
181 ID3DXBaseEffect *base_effect;
184 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
185 struct d3dx_parameter *parameter, LPCSTR name);
186 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
187 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
188 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
190 static const struct
192 enum STATE_CLASS class;
193 UINT op;
194 LPCSTR name;
196 state_table[] =
198 /* Render sates */
199 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
200 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
201 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
202 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
203 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
204 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
205 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
206 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
207 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
208 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
209 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
210 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
211 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
212 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
213 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
214 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
215 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
216 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
217 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
218 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
219 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
220 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
221 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
222 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
223 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
224 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
225 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
226 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
227 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
228 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
229 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
230 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
231 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
232 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
233 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
234 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
235 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
236 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
237 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
238 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
239 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
240 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
241 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
242 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
243 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
244 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
245 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
246 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
247 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
248 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
249 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
250 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
251 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
252 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
253 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
254 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
255 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
256 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
257 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
258 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
259 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
260 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
261 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
262 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
263 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
264 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
265 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
266 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
267 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
268 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
269 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
270 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
271 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
272 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
273 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
274 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
275 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
276 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
277 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
278 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
279 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
280 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
281 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
282 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
283 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
284 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
285 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
286 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
287 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
288 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
289 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
290 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
291 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
292 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
293 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
294 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
295 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
296 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
297 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
298 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
299 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
300 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
301 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
302 /* Texture stages */
303 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
304 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
305 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
306 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
307 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
308 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
309 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
310 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
311 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
312 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
313 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
314 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
315 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
316 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
317 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
318 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
319 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
320 /* */
321 {SC_UNKNOWN, 0, "UNKNOWN"},
322 /* NPatchMode */
323 {SC_NPATCHMODE, 0, "NPatchMode"},
324 /* */
325 {SC_UNKNOWN, 0, "UNKNOWN"},
326 /* Transform */
327 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
328 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
329 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
330 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
331 /* Material */
332 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
333 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
334 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
335 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
336 {SC_MATERIAL, MT_POWER, "MaterialPower"},
337 /* Light */
338 {SC_LIGHT, LT_TYPE, "LightType"},
339 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
340 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
341 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
342 {SC_LIGHT, LT_POSITION, "LightPosition"},
343 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
344 {SC_LIGHT, LT_RANGE, "LightRange"},
345 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
346 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
347 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
348 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
349 {SC_LIGHT, LT_THETA, "LightTheta"},
350 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
351 /* Ligthenable */
352 {SC_LIGHTENABLE, 0, "LightEnable"},
353 /* Vertexshader */
354 {SC_VERTEXSHADER, 0, "Vertexshader"},
355 /* Pixelshader */
356 {SC_PIXELSHADER, 0, "Pixelshader"},
357 /* Shader constants */
358 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
359 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
360 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
361 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
362 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
363 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
364 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
365 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
366 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
367 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
368 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
369 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
370 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
371 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
372 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
373 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
374 /* Texture */
375 {SC_TEXTURE, 0, "Texture"},
376 /* Sampler states */
377 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
378 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
379 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
380 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
381 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
382 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
383 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
384 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
385 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
386 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
387 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
388 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
389 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
390 /* Set sampler */
391 {SC_SETSAMPLER, 0, "Sampler"},
394 static inline void read_dword(const char **ptr, DWORD *d)
396 memcpy(d, *ptr, sizeof(*d));
397 *ptr += sizeof(*d);
400 static void skip_dword_unknown(const char **ptr, unsigned int count)
402 unsigned int i;
403 DWORD d;
405 FIXME("Skipping %u unknown DWORDs:\n", count);
406 for (i = 0; i < count; ++i)
408 read_dword(ptr, &d);
409 FIXME("\t0x%08x\n", d);
413 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
415 return (struct d3dx_parameter *) handle;
418 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
420 return (struct d3dx_pass *) handle;
423 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
425 return (struct d3dx_technique *) handle;
428 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
430 return (D3DXHANDLE) parameter;
433 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
435 return (D3DXHANDLE) technique;
438 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
440 return (D3DXHANDLE) pass;
443 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
445 unsigned int i;
447 for (i = 0; i < base->technique_count; ++i)
449 if (base->technique_handles[i] == technique)
451 return get_technique_struct(technique);
455 return NULL;
458 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
460 unsigned int i, k;
462 for (i = 0; i < base->technique_count; ++i)
464 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
466 for (k = 0; k < technique->pass_count; ++k)
468 if (technique->pass_handles[k] == pass)
470 return get_pass_struct(pass);
475 return NULL;
478 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
480 unsigned int i, count;
481 struct d3dx_parameter *p;
483 for (i = 0; i < param->annotation_count; ++i)
485 if (param->annotation_handles[i] == parameter)
487 return get_parameter_struct(parameter);
490 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
491 if (p) return p;
494 if (param->element_count) count = param->element_count;
495 else count = param->member_count;
497 for (i = 0; i < count; ++i)
499 if (param->member_handles[i] == parameter)
501 return get_parameter_struct(parameter);
504 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
505 if (p) return p;
508 return NULL;
511 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
513 unsigned int i, k, m;
514 struct d3dx_parameter *p;
516 for (i = 0; i < base->parameter_count; ++i)
518 if (base->parameter_handles[i] == parameter)
520 return get_parameter_struct(parameter);
523 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
524 if (p) return p;
527 for (i = 0; i < base->technique_count; ++i)
529 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
531 for (k = 0; k < technique->pass_count; ++k)
533 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
535 for (m = 0; m < pass->annotation_count; ++m)
537 if (pass->annotation_handles[i] == parameter)
539 return get_parameter_struct(parameter);
542 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
543 if (p) return p;
547 for (k = 0; k < technique->annotation_count; ++k)
549 if (technique->annotation_handles[k] == parameter)
551 return get_parameter_struct(parameter);
554 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
555 if (p) return p;
559 return NULL;
562 static void free_state(struct d3dx_state *state)
564 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
567 static void free_sampler(struct d3dx_sampler *sampler)
569 UINT i;
571 for (i = 0; i < sampler->state_count; ++i)
573 free_state(&sampler->states[i]);
575 HeapFree(GetProcessHeap(), 0, sampler->states);
578 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
580 free_parameter_state(handle, element, child, ST_CONSTANT);
583 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
585 unsigned int i;
586 struct d3dx_parameter *param = get_parameter_struct(handle);
588 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
589 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
591 if (!param)
593 return;
596 if (param->annotation_handles)
598 for (i = 0; i < param->annotation_count; ++i)
600 free_parameter(param->annotation_handles[i], FALSE, FALSE);
602 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
605 if (param->member_handles)
607 unsigned int count;
609 if (param->element_count) count = param->element_count;
610 else count = param->member_count;
612 for (i = 0; i < count; ++i)
614 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
616 HeapFree(GetProcessHeap(), 0, param->member_handles);
619 if (param->class == D3DXPC_OBJECT && !param->element_count)
621 switch (param->type)
623 case D3DXPT_STRING:
624 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
625 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
626 break;
628 case D3DXPT_TEXTURE:
629 case D3DXPT_TEXTURE1D:
630 case D3DXPT_TEXTURE2D:
631 case D3DXPT_TEXTURE3D:
632 case D3DXPT_TEXTURECUBE:
633 case D3DXPT_PIXELSHADER:
634 case D3DXPT_VERTEXSHADER:
635 if (st == ST_CONSTANT)
637 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
639 else
641 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
643 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
644 break;
646 case D3DXPT_SAMPLER:
647 case D3DXPT_SAMPLER1D:
648 case D3DXPT_SAMPLER2D:
649 case D3DXPT_SAMPLER3D:
650 case D3DXPT_SAMPLERCUBE:
651 if (st == ST_CONSTANT)
653 free_sampler((struct d3dx_sampler *)param->data);
655 else
657 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
659 /* samplers have always own data, so free that */
660 HeapFree(GetProcessHeap(), 0, param->data);
661 break;
663 default:
664 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
665 break;
668 else
670 if (!child)
672 if (st != ST_CONSTANT)
674 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
676 HeapFree(GetProcessHeap(), 0, param->data);
680 /* only the parent has to release name and semantic */
681 if (!element)
683 HeapFree(GetProcessHeap(), 0, param->name);
684 HeapFree(GetProcessHeap(), 0, param->semantic);
687 HeapFree(GetProcessHeap(), 0, param);
690 static void free_pass(D3DXHANDLE handle)
692 unsigned int i;
693 struct d3dx_pass *pass = get_pass_struct(handle);
695 TRACE("Free pass %p\n", pass);
697 if (!pass)
699 return;
702 if (pass->annotation_handles)
704 for (i = 0; i < pass->annotation_count; ++i)
706 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
708 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
711 if (pass->states)
713 for (i = 0; i < pass->state_count; ++i)
715 free_state(&pass->states[i]);
717 HeapFree(GetProcessHeap(), 0, pass->states);
720 HeapFree(GetProcessHeap(), 0, pass->name);
721 HeapFree(GetProcessHeap(), 0, pass);
724 static void free_technique(D3DXHANDLE handle)
726 unsigned int i;
727 struct d3dx_technique *technique = get_technique_struct(handle);
729 TRACE("Free technique %p\n", technique);
731 if (!technique)
733 return;
736 if (technique->annotation_handles)
738 for (i = 0; i < technique->annotation_count; ++i)
740 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
742 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
745 if (technique->pass_handles)
747 for (i = 0; i < technique->pass_count; ++i)
749 free_pass(technique->pass_handles[i]);
751 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
754 HeapFree(GetProcessHeap(), 0, technique->name);
755 HeapFree(GetProcessHeap(), 0, technique);
758 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
760 unsigned int i;
762 TRACE("Free base effect %p\n", base);
764 if (base->parameter_handles)
766 for (i = 0; i < base->parameter_count; ++i)
768 free_parameter(base->parameter_handles[i], FALSE, FALSE);
770 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
773 if (base->technique_handles)
775 for (i = 0; i < base->technique_count; ++i)
777 free_technique(base->technique_handles[i]);
779 HeapFree(GetProcessHeap(), 0, base->technique_handles);
783 static void free_effect(struct ID3DXEffectImpl *effect)
785 TRACE("Free effect %p\n", effect);
787 if (effect->base_effect)
789 effect->base_effect->lpVtbl->Release(effect->base_effect);
792 if (effect->pool)
794 effect->pool->lpVtbl->Release(effect->pool);
797 if (effect->manager)
799 IUnknown_Release(effect->manager);
802 IDirect3DDevice9_Release(effect->device);
805 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
807 TRACE("Free effect compiler %p\n", compiler);
809 if (compiler->base_effect)
811 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
815 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
817 INT i;
819 switch (type)
821 case D3DXPT_FLOAT:
822 i = *(FLOAT *)data;
823 break;
825 case D3DXPT_INT:
826 i = *(INT *)data;
827 break;
829 case D3DXPT_BOOL:
830 i = *(BOOL *)data;
831 break;
833 default:
834 i = 0;
835 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
836 break;
839 return i;
842 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
844 FLOAT f;
846 switch (type)
848 case D3DXPT_FLOAT:
849 f = *(FLOAT *)data;
850 break;
852 case D3DXPT_INT:
853 f = *(INT *)data;
854 break;
856 case D3DXPT_BOOL:
857 f = *(BOOL *)data;
858 break;
860 default:
861 f = 0.0f;
862 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
863 break;
866 return f;
869 static inline BOOL get_bool(void *data)
871 return (*(DWORD *)data) ? TRUE : FALSE;
874 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
876 UINT element;
877 struct d3dx_parameter *temp_parameter;
878 LPCSTR part;
880 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
882 if (!name || !*name) return parameter;
884 element = atoi(name);
885 part = strchr(name, ']') + 1;
887 if (parameter->element_count > element)
889 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
891 switch (*part++)
893 case '.':
894 return get_parameter_by_name(NULL, temp_parameter, part);
896 case '@':
897 return get_parameter_annotation_by_name(temp_parameter, part);
899 case '\0':
900 TRACE("Returning parameter %p\n", temp_parameter);
901 return temp_parameter;
903 default:
904 FIXME("Unhandled case \"%c\"\n", *--part);
905 break;
909 TRACE("Parameter not found\n");
910 return NULL;
913 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
915 UINT i, length;
916 struct d3dx_parameter *temp_parameter;
917 LPCSTR part;
919 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
921 if (!name || !*name) return parameter;
923 length = strcspn( name, "[.@" );
924 part = name + length;
926 for (i = 0; i < parameter->annotation_count; ++i)
928 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
930 if (!strcmp(temp_parameter->name, name))
932 TRACE("Returning parameter %p\n", temp_parameter);
933 return temp_parameter;
935 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
937 switch (*part++)
939 case '.':
940 return get_parameter_by_name(NULL, temp_parameter, part);
942 case '[':
943 return get_parameter_element_by_name(temp_parameter, part);
945 default:
946 FIXME("Unhandled case \"%c\"\n", *--part);
947 break;
952 TRACE("Parameter not found\n");
953 return NULL;
956 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
957 struct d3dx_parameter *parameter, LPCSTR name)
959 UINT i, count, length;
960 struct d3dx_parameter *temp_parameter;
961 D3DXHANDLE *handles;
962 LPCSTR part;
964 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
966 if (!name || !*name) return parameter;
968 if (!parameter)
970 count = base->parameter_count;
971 handles = base->parameter_handles;
973 else
975 count = parameter->member_count;
976 handles = parameter->member_handles;
979 length = strcspn( name, "[.@" );
980 part = name + length;
982 for (i = 0; i < count; i++)
984 temp_parameter = get_parameter_struct(handles[i]);
986 if (!strcmp(temp_parameter->name, name))
988 TRACE("Returning parameter %p\n", temp_parameter);
989 return temp_parameter;
991 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
993 switch (*part++)
995 case '.':
996 return get_parameter_by_name(NULL, temp_parameter, part);
998 case '@':
999 return get_parameter_annotation_by_name(temp_parameter, part);
1001 case '[':
1002 return get_parameter_element_by_name(temp_parameter, part);
1004 default:
1005 FIXME("Unhandled case \"%c\"\n", *--part);
1006 break;
1011 TRACE("Parameter not found\n");
1012 return NULL;
1015 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1017 return (0xfeff0000 | ((major) << 8) | (minor));
1020 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1022 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1025 /*** IUnknown methods ***/
1026 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1028 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1030 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1032 if (IsEqualGUID(riid, &IID_IUnknown) ||
1033 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1035 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1036 *object = This;
1037 return S_OK;
1040 ERR("Interface %s not found\n", debugstr_guid(riid));
1042 return E_NOINTERFACE;
1045 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1047 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1049 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1051 return InterlockedIncrement(&This->ref);
1054 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1056 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1057 ULONG ref = InterlockedDecrement(&This->ref);
1059 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1061 if (!ref)
1063 free_base_effect(This);
1064 HeapFree(GetProcessHeap(), 0, This);
1067 return ref;
1070 /*** ID3DXBaseEffect methods ***/
1071 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1073 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1075 FIXME("iface %p, desc %p partial stub\n", This, desc);
1077 if (!desc)
1079 WARN("Invalid argument specified.\n");
1080 return D3DERR_INVALIDCALL;
1083 /* Todo: add creator and function count */
1084 desc->Creator = NULL;
1085 desc->Functions = 0;
1086 desc->Parameters = This->parameter_count;
1087 desc->Techniques = This->technique_count;
1089 return D3D_OK;
1092 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1094 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1095 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1097 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1099 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
1101 if (!desc || !param)
1103 WARN("Invalid argument specified.\n");
1104 return D3DERR_INVALIDCALL;
1107 desc->Name = param->name;
1108 desc->Semantic = param->semantic;
1109 desc->Class = param->class;
1110 desc->Type = param->type;
1111 desc->Rows = param->rows;
1112 desc->Columns = param->columns;
1113 desc->Elements = param->element_count;
1114 desc->Annotations = param->annotation_count;
1115 desc->StructMembers = param->member_count;
1116 desc->Flags = param->flags;
1117 desc->Bytes = param->bytes;
1119 return D3D_OK;
1122 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1124 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1125 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1127 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1129 if (!desc || !tech)
1131 WARN("Invalid argument specified.\n");
1132 return D3DERR_INVALIDCALL;
1135 desc->Name = tech->name;
1136 desc->Passes = tech->pass_count;
1137 desc->Annotations = tech->annotation_count;
1139 return D3D_OK;
1142 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1144 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1145 struct d3dx_pass *p = is_valid_pass(This, pass);
1147 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1149 if (!desc || !p)
1151 WARN("Invalid argument specified.\n");
1152 return D3DERR_INVALIDCALL;
1155 desc->Name = p->name;
1156 desc->Annotations = p->annotation_count;
1158 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1159 desc->pVertexShaderFunction = NULL;
1160 desc->pPixelShaderFunction = NULL;
1162 return D3D_OK;
1165 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1167 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1169 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1171 return E_NOTIMPL;
1174 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1176 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1177 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1179 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1181 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1183 if (!parameter)
1185 if (index < This->parameter_count)
1187 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1188 return This->parameter_handles[index];
1191 else
1193 if (param && !param->element_count && index < param->member_count)
1195 TRACE("Returning parameter %p\n", param->member_handles[index]);
1196 return param->member_handles[index];
1200 WARN("Invalid argument specified.\n");
1202 return NULL;
1205 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1207 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1208 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1209 D3DXHANDLE handle;
1211 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1213 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1215 if (!name)
1217 handle = get_parameter_handle(param);
1218 TRACE("Returning parameter %p\n", handle);
1219 return handle;
1222 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1223 TRACE("Returning parameter %p\n", handle);
1225 return handle;
1228 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1230 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1231 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1232 struct d3dx_parameter *temp_param;
1233 UINT i;
1235 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1237 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1239 if (!parameter)
1241 for (i = 0; i < This->parameter_count; ++i)
1243 temp_param = get_parameter_struct(This->parameter_handles[i]);
1245 if (!temp_param->semantic)
1247 if (!semantic)
1249 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1250 return This->parameter_handles[i];
1252 continue;
1255 if (!strcasecmp(temp_param->semantic, semantic))
1257 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1258 return This->parameter_handles[i];
1262 else if (param)
1264 for (i = 0; i < param->member_count; ++i)
1266 temp_param = get_parameter_struct(param->member_handles[i]);
1268 if (!temp_param->semantic)
1270 if (!semantic)
1272 TRACE("Returning parameter %p\n", param->member_handles[i]);
1273 return param->member_handles[i];
1275 continue;
1278 if (!strcasecmp(temp_param->semantic, semantic))
1280 TRACE("Returning parameter %p\n", param->member_handles[i]);
1281 return param->member_handles[i];
1286 WARN("Invalid argument specified\n");
1288 return NULL;
1291 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1293 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1294 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1296 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1298 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1300 if (!param)
1302 if (index < This->parameter_count)
1304 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1305 return This->parameter_handles[index];
1308 else
1310 if (index < param->element_count)
1312 TRACE("Returning parameter %p\n", param->member_handles[index]);
1313 return param->member_handles[index];
1317 WARN("Invalid argument specified\n");
1319 return NULL;
1322 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1324 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1326 TRACE("iface %p, index %u\n", This, index);
1328 if (index >= This->technique_count)
1330 WARN("Invalid argument specified.\n");
1331 return NULL;
1334 TRACE("Returning technique %p\n", This->technique_handles[index]);
1336 return This->technique_handles[index];
1339 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1341 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1342 unsigned int i;
1344 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1346 if (!name)
1348 WARN("Invalid argument specified.\n");
1349 return NULL;
1352 for (i = 0; i < This->technique_count; ++i)
1354 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1356 if (!strcmp(tech->name, name))
1358 TRACE("Returning technique %p\n", This->technique_handles[i]);
1359 return This->technique_handles[i];
1363 WARN("Invalid argument specified.\n");
1365 return NULL;
1368 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1370 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1371 struct d3dx_technique *tech = is_valid_technique(This, technique);
1373 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1375 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1377 if (tech && index < tech->pass_count)
1379 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1380 return tech->pass_handles[index];
1383 WARN("Invalid argument specified.\n");
1385 return NULL;
1388 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1390 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1391 struct d3dx_technique *tech = is_valid_technique(This, technique);
1393 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1395 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1397 if (tech && name)
1399 unsigned int i;
1401 for (i = 0; i < tech->pass_count; ++i)
1403 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1405 if (!strcmp(pass->name, name))
1407 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1408 return tech->pass_handles[i];
1413 WARN("Invalid argument specified.\n");
1415 return NULL;
1418 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1420 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1422 FIXME("iface %p, index %u stub\n", This, index);
1424 return NULL;
1427 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1429 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1431 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1433 return NULL;
1436 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1438 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1439 struct d3dx_parameter *param = is_valid_parameter(This, object);
1440 struct d3dx_pass *pass = is_valid_pass(This, object);
1441 struct d3dx_technique *technique = is_valid_technique(This, object);
1442 UINT annotation_count = 0;
1443 D3DXHANDLE *annotation_handles = NULL;
1445 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1447 if (pass)
1449 annotation_count = pass->annotation_count;
1450 annotation_handles = pass->annotation_handles;
1452 else if (technique)
1454 annotation_count = technique->annotation_count;
1455 annotation_handles = technique->annotation_handles;
1457 else
1459 if (!param) param = get_parameter_by_name(This, NULL, object);
1461 if (param)
1463 annotation_count = param->annotation_count;
1464 annotation_handles = param->annotation_handles;
1467 /* Todo: add funcs */
1469 if (index < annotation_count)
1471 TRACE("Returning parameter %p\n", annotation_handles[index]);
1472 return annotation_handles[index];
1475 WARN("Invalid argument specified\n");
1477 return NULL;
1480 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1482 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1483 struct d3dx_parameter *param = is_valid_parameter(This, object);
1484 struct d3dx_pass *pass = is_valid_pass(This, object);
1485 struct d3dx_technique *technique = is_valid_technique(This, object);
1486 UINT annotation_count = 0, i;
1487 D3DXHANDLE *annotation_handles = NULL;
1489 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1491 if (!name)
1493 WARN("Invalid argument specified\n");
1494 return NULL;
1497 if (pass)
1499 annotation_count = pass->annotation_count;
1500 annotation_handles = pass->annotation_handles;
1502 else if (technique)
1504 annotation_count = technique->annotation_count;
1505 annotation_handles = technique->annotation_handles;
1507 else
1509 if (!param) param = get_parameter_by_name(This, NULL, object);
1511 if (param)
1513 annotation_count = param->annotation_count;
1514 annotation_handles = param->annotation_handles;
1517 /* Todo: add funcs */
1519 for (i = 0; i < annotation_count; i++)
1521 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1523 if (!strcmp(anno->name, name))
1525 TRACE("Returning parameter %p\n", anno);
1526 return get_parameter_handle(anno);
1530 WARN("Invalid argument specified\n");
1532 return NULL;
1535 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1537 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1539 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1541 return E_NOTIMPL;
1544 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1546 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1547 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1549 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1551 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1552 if (!param)
1554 WARN("Invalid parameter %p specified\n", parameter);
1555 return D3DERR_INVALIDCALL;
1558 /* samplers don't touch data */
1559 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1560 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1561 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1563 TRACE("Sampler: returning E_FAIL\n");
1564 return E_FAIL;
1567 if (data && param->bytes <= bytes)
1569 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1571 switch (param->type)
1573 case D3DXPT_VOID:
1574 case D3DXPT_BOOL:
1575 case D3DXPT_INT:
1576 case D3DXPT_FLOAT:
1577 case D3DXPT_STRING:
1578 break;
1580 case D3DXPT_VERTEXSHADER:
1581 case D3DXPT_PIXELSHADER:
1582 case D3DXPT_TEXTURE:
1583 case D3DXPT_TEXTURE1D:
1584 case D3DXPT_TEXTURE2D:
1585 case D3DXPT_TEXTURE3D:
1586 case D3DXPT_TEXTURECUBE:
1588 UINT i;
1590 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1592 IUnknown *unk = ((IUnknown **)param->data)[i];
1593 if (unk) IUnknown_AddRef(unk);
1595 break;
1598 default:
1599 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1600 break;
1603 TRACE("Copy %u bytes\n", param->bytes);
1604 memcpy(data, param->data, param->bytes);
1605 return D3D_OK;
1608 WARN("Invalid argument specified\n");
1610 return D3DERR_INVALIDCALL;
1613 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1615 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1617 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1619 return E_NOTIMPL;
1622 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1624 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1625 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1627 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1629 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1631 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1633 *b = get_bool(param->data);
1634 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1635 return D3D_OK;
1638 WARN("Invalid argument specified\n");
1640 return D3DERR_INVALIDCALL;
1643 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1645 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1647 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1649 return E_NOTIMPL;
1652 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1654 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1655 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1657 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1659 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1661 if (b && param && (param->class == D3DXPC_SCALAR
1662 || param->class == D3DXPC_VECTOR
1663 || param->class == D3DXPC_MATRIX_ROWS
1664 || param->class == D3DXPC_MATRIX_COLUMNS))
1666 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1668 for (i = 0; i < size; ++i)
1670 b[i] = get_bool((DWORD *)param->data + i);
1672 return D3D_OK;
1675 WARN("Invalid argument specified\n");
1677 return D3DERR_INVALIDCALL;
1680 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1682 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1684 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1686 return E_NOTIMPL;
1689 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1691 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1692 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1694 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1696 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1698 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1700 *n = get_int(param->type, param->data);
1701 TRACE("Returning %i\n", *n);
1702 return D3D_OK;
1705 WARN("Invalid argument specified\n");
1707 return D3DERR_INVALIDCALL;
1710 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1712 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1714 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1716 return E_NOTIMPL;
1719 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1721 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1722 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1724 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1726 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1728 if (n && param && (param->class == D3DXPC_SCALAR
1729 || param->class == D3DXPC_VECTOR
1730 || param->class == D3DXPC_MATRIX_ROWS
1731 || param->class == D3DXPC_MATRIX_COLUMNS))
1733 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1735 for (i = 0; i < size; ++i)
1737 n[i] = get_int(param->type, (DWORD *)param->data + i);
1739 return D3D_OK;
1742 WARN("Invalid argument specified\n");
1744 return D3DERR_INVALIDCALL;
1747 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1749 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1751 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1753 return E_NOTIMPL;
1756 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1758 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1759 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1761 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1763 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1765 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1767 f = param->data;
1768 TRACE("Returning %f\n", *f);
1769 return D3D_OK;
1772 WARN("Invalid argument specified\n");
1774 return D3DERR_INVALIDCALL;
1777 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1779 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1781 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1783 return E_NOTIMPL;
1786 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1788 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1789 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1791 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1793 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1795 if (f && param && (param->class == D3DXPC_SCALAR
1796 || param->class == D3DXPC_VECTOR
1797 || param->class == D3DXPC_MATRIX_ROWS
1798 || param->class == D3DXPC_MATRIX_COLUMNS))
1800 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1802 for (i = 0; i < size; ++i)
1804 f[i] = get_float(param->type, (DWORD *)param->data + i);
1806 return D3D_OK;
1809 WARN("Invalid argument specified\n");
1811 return D3DERR_INVALIDCALL;
1814 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1816 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1818 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1820 return E_NOTIMPL;
1823 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1825 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1827 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1829 return E_NOTIMPL;
1832 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1834 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1836 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1838 return E_NOTIMPL;
1841 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1843 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1845 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1847 return E_NOTIMPL;
1850 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1852 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1854 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1856 return E_NOTIMPL;
1859 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1861 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1863 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1865 return E_NOTIMPL;
1868 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1870 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1872 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1874 return E_NOTIMPL;
1877 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1879 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1881 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1883 return E_NOTIMPL;
1886 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1888 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1890 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1892 return E_NOTIMPL;
1895 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1897 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1899 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1901 return E_NOTIMPL;
1904 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1906 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1908 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1910 return E_NOTIMPL;
1913 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1915 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1917 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1919 return E_NOTIMPL;
1922 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1924 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1926 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1928 return E_NOTIMPL;
1931 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1933 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1935 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1937 return E_NOTIMPL;
1940 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1942 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1944 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1946 return E_NOTIMPL;
1949 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1951 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1953 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1955 return E_NOTIMPL;
1958 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1960 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1962 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1964 return E_NOTIMPL;
1967 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1969 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1970 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1972 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1974 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1976 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1978 *string = *(LPCSTR *)param->data;
1979 TRACE("Returning %s\n", debugstr_a(*string));
1980 return D3D_OK;
1983 WARN("Invalid argument specified\n");
1985 return D3DERR_INVALIDCALL;
1988 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1990 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1992 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1994 return E_NOTIMPL;
1997 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
1999 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2000 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2002 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2004 if (texture && param && !param->element_count &&
2005 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2006 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2007 || param->type == D3DXPT_TEXTURECUBE))
2009 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2010 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2011 TRACE("Returning %p\n", *texture);
2012 return D3D_OK;
2015 WARN("Invalid argument specified\n");
2017 return D3DERR_INVALIDCALL;
2020 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2022 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2023 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2025 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2027 if (!param) param = get_parameter_by_name(This, NULL, parameter);
2029 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2031 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2032 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2033 TRACE("Returning %p\n", *pshader);
2034 return D3D_OK;
2037 WARN("Invalid argument specified\n");
2039 return D3DERR_INVALIDCALL;
2042 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2044 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2045 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
2047 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2049 if (!param) param = get_parameter_by_name(This, NULL, parameter);
2051 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2053 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2054 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2055 TRACE("Returning %p\n", *vshader);
2056 return D3D_OK;
2059 WARN("Invalid argument specified\n");
2061 return D3DERR_INVALIDCALL;
2064 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2066 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2068 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2070 return E_NOTIMPL;
2073 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2075 /*** IUnknown methods ***/
2076 ID3DXBaseEffectImpl_QueryInterface,
2077 ID3DXBaseEffectImpl_AddRef,
2078 ID3DXBaseEffectImpl_Release,
2079 /*** ID3DXBaseEffect methods ***/
2080 ID3DXBaseEffectImpl_GetDesc,
2081 ID3DXBaseEffectImpl_GetParameterDesc,
2082 ID3DXBaseEffectImpl_GetTechniqueDesc,
2083 ID3DXBaseEffectImpl_GetPassDesc,
2084 ID3DXBaseEffectImpl_GetFunctionDesc,
2085 ID3DXBaseEffectImpl_GetParameter,
2086 ID3DXBaseEffectImpl_GetParameterByName,
2087 ID3DXBaseEffectImpl_GetParameterBySemantic,
2088 ID3DXBaseEffectImpl_GetParameterElement,
2089 ID3DXBaseEffectImpl_GetTechnique,
2090 ID3DXBaseEffectImpl_GetTechniqueByName,
2091 ID3DXBaseEffectImpl_GetPass,
2092 ID3DXBaseEffectImpl_GetPassByName,
2093 ID3DXBaseEffectImpl_GetFunction,
2094 ID3DXBaseEffectImpl_GetFunctionByName,
2095 ID3DXBaseEffectImpl_GetAnnotation,
2096 ID3DXBaseEffectImpl_GetAnnotationByName,
2097 ID3DXBaseEffectImpl_SetValue,
2098 ID3DXBaseEffectImpl_GetValue,
2099 ID3DXBaseEffectImpl_SetBool,
2100 ID3DXBaseEffectImpl_GetBool,
2101 ID3DXBaseEffectImpl_SetBoolArray,
2102 ID3DXBaseEffectImpl_GetBoolArray,
2103 ID3DXBaseEffectImpl_SetInt,
2104 ID3DXBaseEffectImpl_GetInt,
2105 ID3DXBaseEffectImpl_SetIntArray,
2106 ID3DXBaseEffectImpl_GetIntArray,
2107 ID3DXBaseEffectImpl_SetFloat,
2108 ID3DXBaseEffectImpl_GetFloat,
2109 ID3DXBaseEffectImpl_SetFloatArray,
2110 ID3DXBaseEffectImpl_GetFloatArray,
2111 ID3DXBaseEffectImpl_SetVector,
2112 ID3DXBaseEffectImpl_GetVector,
2113 ID3DXBaseEffectImpl_SetVectorArray,
2114 ID3DXBaseEffectImpl_GetVectorArray,
2115 ID3DXBaseEffectImpl_SetMatrix,
2116 ID3DXBaseEffectImpl_GetMatrix,
2117 ID3DXBaseEffectImpl_SetMatrixArray,
2118 ID3DXBaseEffectImpl_GetMatrixArray,
2119 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2120 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2121 ID3DXBaseEffectImpl_SetMatrixTranspose,
2122 ID3DXBaseEffectImpl_GetMatrixTranspose,
2123 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2124 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2125 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2126 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2127 ID3DXBaseEffectImpl_SetString,
2128 ID3DXBaseEffectImpl_GetString,
2129 ID3DXBaseEffectImpl_SetTexture,
2130 ID3DXBaseEffectImpl_GetTexture,
2131 ID3DXBaseEffectImpl_GetPixelShader,
2132 ID3DXBaseEffectImpl_GetVertexShader,
2133 ID3DXBaseEffectImpl_SetArrayRange,
2136 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2138 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2141 /*** IUnknown methods ***/
2142 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2144 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2146 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2148 if (IsEqualGUID(riid, &IID_IUnknown) ||
2149 IsEqualGUID(riid, &IID_ID3DXEffect))
2151 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2152 *object = This;
2153 return S_OK;
2156 ERR("Interface %s not found\n", debugstr_guid(riid));
2158 return E_NOINTERFACE;
2161 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2163 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2165 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2167 return InterlockedIncrement(&This->ref);
2170 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2172 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2173 ULONG ref = InterlockedDecrement(&This->ref);
2175 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2177 if (!ref)
2179 free_effect(This);
2180 HeapFree(GetProcessHeap(), 0, This);
2183 return ref;
2186 /*** ID3DXBaseEffect methods ***/
2187 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2189 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2190 ID3DXBaseEffect *base = This->base_effect;
2192 TRACE("Forward iface %p, base %p\n", This, base);
2194 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2197 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2199 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2200 ID3DXBaseEffect *base = This->base_effect;
2202 TRACE("Forward iface %p, base %p\n", This, base);
2204 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2207 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2209 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2210 ID3DXBaseEffect *base = This->base_effect;
2212 TRACE("Forward iface %p, base %p\n", This, base);
2214 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2217 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2219 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2220 ID3DXBaseEffect *base = This->base_effect;
2222 TRACE("Forward iface %p, base %p\n", This, base);
2224 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2227 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2229 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2230 ID3DXBaseEffect *base = This->base_effect;
2232 TRACE("Forward iface %p, base %p\n", This, base);
2234 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2237 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2239 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2240 ID3DXBaseEffect *base = This->base_effect;
2242 TRACE("Forward iface %p, base %p\n", This, base);
2244 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2247 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2249 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2250 ID3DXBaseEffect *base = This->base_effect;
2252 TRACE("Forward iface %p, base %p\n", This, base);
2254 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2257 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2259 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2260 ID3DXBaseEffect *base = This->base_effect;
2262 TRACE("Forward iface %p, base %p\n", This, base);
2264 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2267 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2269 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2270 ID3DXBaseEffect *base = This->base_effect;
2272 TRACE("Forward iface %p, base %p\n", This, base);
2274 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2277 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2279 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2280 ID3DXBaseEffect *base = This->base_effect;
2282 TRACE("Forward iface %p, base %p\n", This, base);
2284 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2287 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2289 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2290 ID3DXBaseEffect *base = This->base_effect;
2292 TRACE("Forward iface %p, base %p\n", This, base);
2294 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2297 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2299 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2300 ID3DXBaseEffect *base = This->base_effect;
2302 TRACE("Forward iface %p, base %p\n", This, base);
2304 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2307 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2309 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2310 ID3DXBaseEffect *base = This->base_effect;
2312 TRACE("Forward iface %p, base %p\n", This, base);
2314 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2317 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2319 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2320 ID3DXBaseEffect *base = This->base_effect;
2322 TRACE("Forward iface %p, base %p\n", This, base);
2324 return ID3DXBaseEffectImpl_GetFunction(base, index);
2327 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2329 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2330 ID3DXBaseEffect *base = This->base_effect;
2332 TRACE("Forward iface %p, base %p\n", This, base);
2334 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2337 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2339 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2340 ID3DXBaseEffect *base = This->base_effect;
2342 TRACE("Forward iface %p, base %p\n", This, base);
2344 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2347 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2349 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2350 ID3DXBaseEffect *base = This->base_effect;
2352 TRACE("Forward iface %p, base %p\n", This, base);
2354 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2357 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2359 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2360 ID3DXBaseEffect *base = This->base_effect;
2362 TRACE("Forward iface %p, base %p\n", This, base);
2364 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2367 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2369 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2370 ID3DXBaseEffect *base = This->base_effect;
2372 TRACE("Forward iface %p, base %p\n", This, base);
2374 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2377 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2379 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2380 ID3DXBaseEffect *base = This->base_effect;
2382 TRACE("Forward iface %p, base %p\n", This, base);
2384 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2387 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2389 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2390 ID3DXBaseEffect *base = This->base_effect;
2392 TRACE("Forward iface %p, base %p\n", This, base);
2394 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2397 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2399 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2400 ID3DXBaseEffect *base = This->base_effect;
2402 TRACE("Forward iface %p, base %p\n", This, base);
2404 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2407 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2409 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2410 ID3DXBaseEffect *base = This->base_effect;
2412 TRACE("Forward iface %p, base %p\n", This, base);
2414 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2417 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2419 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2420 ID3DXBaseEffect *base = This->base_effect;
2422 TRACE("Forward iface %p, base %p\n", This, base);
2424 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2427 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2429 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2430 ID3DXBaseEffect *base = This->base_effect;
2432 TRACE("Forward iface %p, base %p\n", This, base);
2434 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2437 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2439 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2440 ID3DXBaseEffect *base = This->base_effect;
2442 TRACE("Forward iface %p, base %p\n", This, base);
2444 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2447 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2449 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2450 ID3DXBaseEffect *base = This->base_effect;
2452 TRACE("Forward iface %p, base %p\n", This, base);
2454 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2457 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2459 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2460 ID3DXBaseEffect *base = This->base_effect;
2462 TRACE("Forward iface %p, base %p\n", This, base);
2464 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2467 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2469 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2470 ID3DXBaseEffect *base = This->base_effect;
2472 TRACE("Forward iface %p, base %p\n", This, base);
2474 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2477 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2479 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2480 ID3DXBaseEffect *base = This->base_effect;
2482 TRACE("Forward iface %p, base %p\n", This, base);
2484 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2487 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2489 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2490 ID3DXBaseEffect *base = This->base_effect;
2492 TRACE("Forward iface %p, base %p\n", This, base);
2494 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2497 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2499 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2500 ID3DXBaseEffect *base = This->base_effect;
2502 TRACE("Forward iface %p, base %p\n", This, base);
2504 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2507 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2509 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2510 ID3DXBaseEffect *base = This->base_effect;
2512 TRACE("Forward iface %p, base %p\n", This, base);
2514 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2517 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2519 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2520 ID3DXBaseEffect *base = This->base_effect;
2522 TRACE("Forward iface %p, base %p\n", This, base);
2524 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2527 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2529 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2530 ID3DXBaseEffect *base = This->base_effect;
2532 TRACE("Forward iface %p, base %p\n", This, base);
2534 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2537 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2539 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2540 ID3DXBaseEffect *base = This->base_effect;
2542 TRACE("Forward iface %p, base %p\n", This, base);
2544 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2547 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2549 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2550 ID3DXBaseEffect *base = This->base_effect;
2552 TRACE("Forward iface %p, base %p\n", This, base);
2554 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2557 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2559 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2560 ID3DXBaseEffect *base = This->base_effect;
2562 TRACE("Forward iface %p, base %p\n", This, base);
2564 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2567 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2569 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2570 ID3DXBaseEffect *base = This->base_effect;
2572 TRACE("Forward iface %p, base %p\n", This, base);
2574 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2577 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2579 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2580 ID3DXBaseEffect *base = This->base_effect;
2582 TRACE("Forward iface %p, base %p\n", This, base);
2584 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2587 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2589 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2590 ID3DXBaseEffect *base = This->base_effect;
2592 TRACE("Forward iface %p, base %p\n", This, base);
2594 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2597 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2599 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2600 ID3DXBaseEffect *base = This->base_effect;
2602 TRACE("Forward iface %p, base %p\n", This, base);
2604 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2607 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2609 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2610 ID3DXBaseEffect *base = This->base_effect;
2612 TRACE("Forward iface %p, base %p\n", This, base);
2614 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2617 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2619 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2620 ID3DXBaseEffect *base = This->base_effect;
2622 TRACE("Forward iface %p, base %p\n", This, base);
2624 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2627 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2629 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2630 ID3DXBaseEffect *base = This->base_effect;
2632 TRACE("Forward iface %p, base %p\n", This, base);
2634 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2637 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2639 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2640 ID3DXBaseEffect *base = This->base_effect;
2642 TRACE("Forward iface %p, base %p\n", This, base);
2644 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2647 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2649 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2650 ID3DXBaseEffect *base = This->base_effect;
2652 TRACE("Forward iface %p, base %p\n", This, base);
2654 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2657 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2659 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2660 ID3DXBaseEffect *base = This->base_effect;
2662 TRACE("Forward iface %p, base %p\n", This, base);
2664 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2667 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2669 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2670 ID3DXBaseEffect *base = This->base_effect;
2672 TRACE("Forward iface %p, base %p\n", This, base);
2674 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2677 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2679 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2680 ID3DXBaseEffect *base = This->base_effect;
2682 TRACE("Forward iface %p, base %p\n", This, base);
2684 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2687 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2689 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2690 ID3DXBaseEffect *base = This->base_effect;
2692 TRACE("Forward iface %p, base %p\n", This, base);
2694 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2697 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2699 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2700 ID3DXBaseEffect *base = This->base_effect;
2702 TRACE("Forward iface %p, base %p\n", This, base);
2704 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2707 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2709 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2710 ID3DXBaseEffect *base = This->base_effect;
2712 TRACE("Forward iface %p, base %p\n", This, base);
2714 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2717 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2719 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2720 ID3DXBaseEffect *base = This->base_effect;
2722 TRACE("Forward iface %p, base %p\n", This, base);
2724 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2727 /*** ID3DXEffect methods ***/
2728 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2730 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2732 TRACE("iface %p, pool %p\n", This, pool);
2734 if (!pool)
2736 WARN("Invalid argument supplied.\n");
2737 return D3DERR_INVALIDCALL;
2740 if (This->pool)
2742 This->pool->lpVtbl->AddRef(This->pool);
2745 *pool = This->pool;
2747 TRACE("Returning pool %p\n", *pool);
2749 return S_OK;
2752 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
2754 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2755 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
2756 struct d3dx_technique *tech = is_valid_technique(base, technique);
2758 TRACE("iface %p, technique %p\n", This, technique);
2760 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
2762 if (tech)
2764 UINT i;
2766 for (i = 0; i < base->technique_count; ++i)
2768 struct d3dx_technique *t = get_technique_struct(base->technique_handles[i]);
2770 if (tech == t)
2772 This->active_technique = get_technique_handle(t);
2773 TRACE("Technique %u (%p)\n", i, tech);
2774 return D3D_OK;
2779 WARN("Invalid argument supplied.\n");
2781 return D3DERR_INVALIDCALL;
2784 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
2786 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2788 TRACE("iface %p\n", This);
2790 return This->active_technique;
2793 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2795 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2797 FIXME("(%p)->(%p): stub\n", This, technique);
2799 return D3D_OK;
2802 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2804 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2806 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2808 return E_NOTIMPL;
2811 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2813 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2815 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2817 return FALSE;
2820 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
2822 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2823 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2825 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
2827 if (passes && technique)
2829 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
2831 TRACE("State capturing disabled.\n");
2833 else
2835 FIXME("State capturing not supported, yet!\n");
2838 *passes = technique->pass_count;
2840 return D3D_OK;
2843 WARN("Invalid argument supplied.\n");
2845 return D3DERR_INVALIDCALL;
2848 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
2850 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2851 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
2853 TRACE("iface %p, pass %u\n", This, pass);
2855 if (technique && pass < technique->pass_count && !This->active_pass)
2857 This->active_pass = technique->pass_handles[pass];
2859 FIXME("No states applied, yet!\n");
2861 return D3D_OK;
2864 WARN("Invalid argument supplied.\n");
2866 return D3DERR_INVALIDCALL;
2869 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2871 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2873 FIXME("(%p)->(): stub\n", This);
2875 return E_NOTIMPL;
2878 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
2880 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2882 TRACE("iface %p\n", This);
2884 if (This->active_pass)
2886 This->active_pass = NULL;
2887 return D3D_OK;
2890 WARN("Invalid call.\n");
2892 return D3DERR_INVALIDCALL;
2895 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2897 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2899 FIXME("(%p)->(): stub\n", This);
2901 return E_NOTIMPL;
2904 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2906 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2908 TRACE("iface %p, device %p\n", This, device);
2910 if (!device)
2912 WARN("Invalid argument supplied.\n");
2913 return D3DERR_INVALIDCALL;
2916 IDirect3DDevice9_AddRef(This->device);
2918 *device = This->device;
2920 TRACE("Returning device %p\n", *device);
2922 return S_OK;
2925 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2927 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2929 FIXME("(%p)->(): stub\n", This);
2931 return E_NOTIMPL;
2934 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2936 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2938 FIXME("(%p)->(): stub\n", This);
2940 return E_NOTIMPL;
2943 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2945 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2947 TRACE("iface %p, manager %p\n", This, manager);
2949 if (manager) IUnknown_AddRef(manager);
2950 if (This->manager) IUnknown_Release(This->manager);
2952 This->manager = manager;
2954 return D3D_OK;
2957 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2959 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2961 TRACE("iface %p, manager %p\n", This, manager);
2963 if (!manager)
2965 WARN("Invalid argument supplied.\n");
2966 return D3DERR_INVALIDCALL;
2969 if (This->manager) IUnknown_AddRef(This->manager);
2970 *manager = This->manager;
2972 return D3D_OK;
2975 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2977 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2979 FIXME("(%p)->(): stub\n", This);
2981 return E_NOTIMPL;
2984 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2986 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2988 FIXME("(%p)->(): stub\n", This);
2990 return NULL;
2993 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2995 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2997 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2999 return E_NOTIMPL;
3002 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3004 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3006 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3008 return E_NOTIMPL;
3011 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3013 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3015 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3017 return E_NOTIMPL;
3020 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3022 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3024 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3026 return E_NOTIMPL;
3029 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3031 /*** IUnknown methods ***/
3032 ID3DXEffectImpl_QueryInterface,
3033 ID3DXEffectImpl_AddRef,
3034 ID3DXEffectImpl_Release,
3035 /*** ID3DXBaseEffect methods ***/
3036 ID3DXEffectImpl_GetDesc,
3037 ID3DXEffectImpl_GetParameterDesc,
3038 ID3DXEffectImpl_GetTechniqueDesc,
3039 ID3DXEffectImpl_GetPassDesc,
3040 ID3DXEffectImpl_GetFunctionDesc,
3041 ID3DXEffectImpl_GetParameter,
3042 ID3DXEffectImpl_GetParameterByName,
3043 ID3DXEffectImpl_GetParameterBySemantic,
3044 ID3DXEffectImpl_GetParameterElement,
3045 ID3DXEffectImpl_GetTechnique,
3046 ID3DXEffectImpl_GetTechniqueByName,
3047 ID3DXEffectImpl_GetPass,
3048 ID3DXEffectImpl_GetPassByName,
3049 ID3DXEffectImpl_GetFunction,
3050 ID3DXEffectImpl_GetFunctionByName,
3051 ID3DXEffectImpl_GetAnnotation,
3052 ID3DXEffectImpl_GetAnnotationByName,
3053 ID3DXEffectImpl_SetValue,
3054 ID3DXEffectImpl_GetValue,
3055 ID3DXEffectImpl_SetBool,
3056 ID3DXEffectImpl_GetBool,
3057 ID3DXEffectImpl_SetBoolArray,
3058 ID3DXEffectImpl_GetBoolArray,
3059 ID3DXEffectImpl_SetInt,
3060 ID3DXEffectImpl_GetInt,
3061 ID3DXEffectImpl_SetIntArray,
3062 ID3DXEffectImpl_GetIntArray,
3063 ID3DXEffectImpl_SetFloat,
3064 ID3DXEffectImpl_GetFloat,
3065 ID3DXEffectImpl_SetFloatArray,
3066 ID3DXEffectImpl_GetFloatArray,
3067 ID3DXEffectImpl_SetVector,
3068 ID3DXEffectImpl_GetVector,
3069 ID3DXEffectImpl_SetVectorArray,
3070 ID3DXEffectImpl_GetVectorArray,
3071 ID3DXEffectImpl_SetMatrix,
3072 ID3DXEffectImpl_GetMatrix,
3073 ID3DXEffectImpl_SetMatrixArray,
3074 ID3DXEffectImpl_GetMatrixArray,
3075 ID3DXEffectImpl_SetMatrixPointerArray,
3076 ID3DXEffectImpl_GetMatrixPointerArray,
3077 ID3DXEffectImpl_SetMatrixTranspose,
3078 ID3DXEffectImpl_GetMatrixTranspose,
3079 ID3DXEffectImpl_SetMatrixTransposeArray,
3080 ID3DXEffectImpl_GetMatrixTransposeArray,
3081 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3082 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3083 ID3DXEffectImpl_SetString,
3084 ID3DXEffectImpl_GetString,
3085 ID3DXEffectImpl_SetTexture,
3086 ID3DXEffectImpl_GetTexture,
3087 ID3DXEffectImpl_GetPixelShader,
3088 ID3DXEffectImpl_GetVertexShader,
3089 ID3DXEffectImpl_SetArrayRange,
3090 /*** ID3DXEffect methods ***/
3091 ID3DXEffectImpl_GetPool,
3092 ID3DXEffectImpl_SetTechnique,
3093 ID3DXEffectImpl_GetCurrentTechnique,
3094 ID3DXEffectImpl_ValidateTechnique,
3095 ID3DXEffectImpl_FindNextValidTechnique,
3096 ID3DXEffectImpl_IsParameterUsed,
3097 ID3DXEffectImpl_Begin,
3098 ID3DXEffectImpl_BeginPass,
3099 ID3DXEffectImpl_CommitChanges,
3100 ID3DXEffectImpl_EndPass,
3101 ID3DXEffectImpl_End,
3102 ID3DXEffectImpl_GetDevice,
3103 ID3DXEffectImpl_OnLostDevice,
3104 ID3DXEffectImpl_OnResetDevice,
3105 ID3DXEffectImpl_SetStateManager,
3106 ID3DXEffectImpl_GetStateManager,
3107 ID3DXEffectImpl_BeginParameterBlock,
3108 ID3DXEffectImpl_EndParameterBlock,
3109 ID3DXEffectImpl_ApplyParameterBlock,
3110 ID3DXEffectImpl_DeleteParameterBlock,
3111 ID3DXEffectImpl_CloneEffect,
3112 ID3DXEffectImpl_SetRawValue
3115 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3117 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3120 /*** IUnknown methods ***/
3121 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3123 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3125 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3127 if (IsEqualGUID(riid, &IID_IUnknown) ||
3128 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3130 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3131 *object = This;
3132 return S_OK;
3135 ERR("Interface %s not found\n", debugstr_guid(riid));
3137 return E_NOINTERFACE;
3140 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3142 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3144 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3146 return InterlockedIncrement(&This->ref);
3149 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3151 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3152 ULONG ref = InterlockedDecrement(&This->ref);
3154 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3156 if (!ref)
3158 free_effect_compiler(This);
3159 HeapFree(GetProcessHeap(), 0, This);
3162 return ref;
3165 /*** ID3DXBaseEffect methods ***/
3166 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3168 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3169 ID3DXBaseEffect *base = This->base_effect;
3171 TRACE("Forward iface %p, base %p\n", This, base);
3173 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3176 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3178 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3179 ID3DXBaseEffect *base = This->base_effect;
3181 TRACE("Forward iface %p, base %p\n", This, base);
3183 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3186 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3188 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3189 ID3DXBaseEffect *base = This->base_effect;
3191 TRACE("Forward iface %p, base %p\n", This, base);
3193 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3196 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3198 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3199 ID3DXBaseEffect *base = This->base_effect;
3201 TRACE("Forward iface %p, base %p\n", This, base);
3203 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3206 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3208 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3209 ID3DXBaseEffect *base = This->base_effect;
3211 TRACE("Forward iface %p, base %p\n", This, base);
3213 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3216 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3218 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3219 ID3DXBaseEffect *base = This->base_effect;
3221 TRACE("Forward iface %p, base %p\n", This, base);
3223 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3226 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3228 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3229 ID3DXBaseEffect *base = This->base_effect;
3231 TRACE("Forward iface %p, base %p\n", This, base);
3233 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3236 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3238 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3239 ID3DXBaseEffect *base = This->base_effect;
3241 TRACE("Forward iface %p, base %p\n", This, base);
3243 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3246 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3248 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3249 ID3DXBaseEffect *base = This->base_effect;
3251 TRACE("Forward iface %p, base %p\n", This, base);
3253 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3256 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3258 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3259 ID3DXBaseEffect *base = This->base_effect;
3261 TRACE("Forward iface %p, base %p\n", This, base);
3263 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3266 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3268 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3269 ID3DXBaseEffect *base = This->base_effect;
3271 TRACE("Forward iface %p, base %p\n", This, base);
3273 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3276 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3278 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3279 ID3DXBaseEffect *base = This->base_effect;
3281 TRACE("Forward iface %p, base %p\n", This, base);
3283 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3286 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3288 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3289 ID3DXBaseEffect *base = This->base_effect;
3291 TRACE("Forward iface %p, base %p\n", This, base);
3293 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3296 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3298 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3299 ID3DXBaseEffect *base = This->base_effect;
3301 TRACE("Forward iface %p, base %p\n", This, base);
3303 return ID3DXBaseEffectImpl_GetFunction(base, index);
3306 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3308 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3309 ID3DXBaseEffect *base = This->base_effect;
3311 TRACE("Forward iface %p, base %p\n", This, base);
3313 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3316 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3318 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3319 ID3DXBaseEffect *base = This->base_effect;
3321 TRACE("Forward iface %p, base %p\n", This, base);
3323 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3326 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3328 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3329 ID3DXBaseEffect *base = This->base_effect;
3331 TRACE("Forward iface %p, base %p\n", This, base);
3333 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3336 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3338 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3339 ID3DXBaseEffect *base = This->base_effect;
3341 TRACE("Forward iface %p, base %p\n", This, base);
3343 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3346 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3348 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3349 ID3DXBaseEffect *base = This->base_effect;
3351 TRACE("Forward iface %p, base %p\n", This, base);
3353 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3356 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3358 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3359 ID3DXBaseEffect *base = This->base_effect;
3361 TRACE("Forward iface %p, base %p\n", This, base);
3363 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3366 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3368 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3369 ID3DXBaseEffect *base = This->base_effect;
3371 TRACE("Forward iface %p, base %p\n", This, base);
3373 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3376 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3378 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3379 ID3DXBaseEffect *base = This->base_effect;
3381 TRACE("Forward iface %p, base %p\n", This, base);
3383 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3386 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3388 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3389 ID3DXBaseEffect *base = This->base_effect;
3391 TRACE("Forward iface %p, base %p\n", This, base);
3393 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3396 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3398 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3399 ID3DXBaseEffect *base = This->base_effect;
3401 TRACE("Forward iface %p, base %p\n", This, base);
3403 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3406 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3408 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3409 ID3DXBaseEffect *base = This->base_effect;
3411 TRACE("Forward iface %p, base %p\n", This, base);
3413 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3416 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3418 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3419 ID3DXBaseEffect *base = This->base_effect;
3421 TRACE("Forward iface %p, base %p\n", This, base);
3423 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3426 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3428 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3429 ID3DXBaseEffect *base = This->base_effect;
3431 TRACE("Forward iface %p, base %p\n", This, base);
3433 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3436 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3438 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3439 ID3DXBaseEffect *base = This->base_effect;
3441 TRACE("Forward iface %p, base %p\n", This, base);
3443 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3446 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3448 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3449 ID3DXBaseEffect *base = This->base_effect;
3451 TRACE("Forward iface %p, base %p\n", This, base);
3453 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3456 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3458 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3459 ID3DXBaseEffect *base = This->base_effect;
3461 TRACE("Forward iface %p, base %p\n", This, base);
3463 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3466 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3468 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3469 ID3DXBaseEffect *base = This->base_effect;
3471 TRACE("Forward iface %p, base %p\n", This, base);
3473 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3476 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3478 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3479 ID3DXBaseEffect *base = This->base_effect;
3481 TRACE("Forward iface %p, base %p\n", This, base);
3483 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3486 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3488 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3489 ID3DXBaseEffect *base = This->base_effect;
3491 TRACE("Forward iface %p, base %p\n", This, base);
3493 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3496 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3498 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3499 ID3DXBaseEffect *base = This->base_effect;
3501 TRACE("Forward iface %p, base %p\n", This, base);
3503 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3506 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3508 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3509 ID3DXBaseEffect *base = This->base_effect;
3511 TRACE("Forward iface %p, base %p\n", This, base);
3513 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3516 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3518 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3519 ID3DXBaseEffect *base = This->base_effect;
3521 TRACE("Forward iface %p, base %p\n", This, base);
3523 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3526 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3528 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3529 ID3DXBaseEffect *base = This->base_effect;
3531 TRACE("Forward iface %p, base %p\n", This, base);
3533 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3536 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3538 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3539 ID3DXBaseEffect *base = This->base_effect;
3541 TRACE("Forward iface %p, base %p\n", This, base);
3543 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3546 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3548 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3549 ID3DXBaseEffect *base = This->base_effect;
3551 TRACE("Forward iface %p, base %p\n", This, base);
3553 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3556 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3558 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3559 ID3DXBaseEffect *base = This->base_effect;
3561 TRACE("Forward iface %p, base %p\n", This, base);
3563 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3566 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3568 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3569 ID3DXBaseEffect *base = This->base_effect;
3571 TRACE("Forward iface %p, base %p\n", This, base);
3573 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3576 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3578 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3579 ID3DXBaseEffect *base = This->base_effect;
3581 TRACE("Forward iface %p, base %p\n", This, base);
3583 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3586 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3588 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3589 ID3DXBaseEffect *base = This->base_effect;
3591 TRACE("Forward iface %p, base %p\n", This, base);
3593 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3596 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3598 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3599 ID3DXBaseEffect *base = This->base_effect;
3601 TRACE("Forward iface %p, base %p\n", This, base);
3603 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3606 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3608 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3609 ID3DXBaseEffect *base = This->base_effect;
3611 TRACE("Forward iface %p, base %p\n", This, base);
3613 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3616 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3618 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3619 ID3DXBaseEffect *base = This->base_effect;
3621 TRACE("Forward iface %p, base %p\n", This, base);
3623 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3626 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3628 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3629 ID3DXBaseEffect *base = This->base_effect;
3631 TRACE("Forward iface %p, base %p\n", This, base);
3633 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3636 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3638 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3639 ID3DXBaseEffect *base = This->base_effect;
3641 TRACE("Forward iface %p, base %p\n", This, base);
3643 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3646 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3648 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3649 ID3DXBaseEffect *base = This->base_effect;
3651 TRACE("Forward iface %p, base %p\n", This, base);
3653 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3656 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3658 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3659 ID3DXBaseEffect *base = This->base_effect;
3661 TRACE("Forward iface %p, base %p\n", This, base);
3663 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3666 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3668 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3669 ID3DXBaseEffect *base = This->base_effect;
3671 TRACE("Forward iface %p, base %p\n", This, base);
3673 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3676 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3678 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3679 ID3DXBaseEffect *base = This->base_effect;
3681 TRACE("Forward iface %p, base %p\n", This, base);
3683 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3686 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3688 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3689 ID3DXBaseEffect *base = This->base_effect;
3691 TRACE("Forward iface %p, base %p\n", This, base);
3693 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3696 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3698 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3699 ID3DXBaseEffect *base = This->base_effect;
3701 TRACE("Forward iface %p, base %p\n", This, base);
3703 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3706 /*** ID3DXEffectCompiler methods ***/
3707 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3709 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3711 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3713 return E_NOTIMPL;
3716 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3718 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3720 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3722 return E_NOTIMPL;
3725 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3726 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3728 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3730 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3732 return E_NOTIMPL;
3735 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3736 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3738 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3740 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3741 This, function, target, flags, shader, error_msgs, constant_table);
3743 return E_NOTIMPL;
3746 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3748 /*** IUnknown methods ***/
3749 ID3DXEffectCompilerImpl_QueryInterface,
3750 ID3DXEffectCompilerImpl_AddRef,
3751 ID3DXEffectCompilerImpl_Release,
3752 /*** ID3DXBaseEffect methods ***/
3753 ID3DXEffectCompilerImpl_GetDesc,
3754 ID3DXEffectCompilerImpl_GetParameterDesc,
3755 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3756 ID3DXEffectCompilerImpl_GetPassDesc,
3757 ID3DXEffectCompilerImpl_GetFunctionDesc,
3758 ID3DXEffectCompilerImpl_GetParameter,
3759 ID3DXEffectCompilerImpl_GetParameterByName,
3760 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3761 ID3DXEffectCompilerImpl_GetParameterElement,
3762 ID3DXEffectCompilerImpl_GetTechnique,
3763 ID3DXEffectCompilerImpl_GetTechniqueByName,
3764 ID3DXEffectCompilerImpl_GetPass,
3765 ID3DXEffectCompilerImpl_GetPassByName,
3766 ID3DXEffectCompilerImpl_GetFunction,
3767 ID3DXEffectCompilerImpl_GetFunctionByName,
3768 ID3DXEffectCompilerImpl_GetAnnotation,
3769 ID3DXEffectCompilerImpl_GetAnnotationByName,
3770 ID3DXEffectCompilerImpl_SetValue,
3771 ID3DXEffectCompilerImpl_GetValue,
3772 ID3DXEffectCompilerImpl_SetBool,
3773 ID3DXEffectCompilerImpl_GetBool,
3774 ID3DXEffectCompilerImpl_SetBoolArray,
3775 ID3DXEffectCompilerImpl_GetBoolArray,
3776 ID3DXEffectCompilerImpl_SetInt,
3777 ID3DXEffectCompilerImpl_GetInt,
3778 ID3DXEffectCompilerImpl_SetIntArray,
3779 ID3DXEffectCompilerImpl_GetIntArray,
3780 ID3DXEffectCompilerImpl_SetFloat,
3781 ID3DXEffectCompilerImpl_GetFloat,
3782 ID3DXEffectCompilerImpl_SetFloatArray,
3783 ID3DXEffectCompilerImpl_GetFloatArray,
3784 ID3DXEffectCompilerImpl_SetVector,
3785 ID3DXEffectCompilerImpl_GetVector,
3786 ID3DXEffectCompilerImpl_SetVectorArray,
3787 ID3DXEffectCompilerImpl_GetVectorArray,
3788 ID3DXEffectCompilerImpl_SetMatrix,
3789 ID3DXEffectCompilerImpl_GetMatrix,
3790 ID3DXEffectCompilerImpl_SetMatrixArray,
3791 ID3DXEffectCompilerImpl_GetMatrixArray,
3792 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3793 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3794 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3795 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3796 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3797 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3798 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3799 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3800 ID3DXEffectCompilerImpl_SetString,
3801 ID3DXEffectCompilerImpl_GetString,
3802 ID3DXEffectCompilerImpl_SetTexture,
3803 ID3DXEffectCompilerImpl_GetTexture,
3804 ID3DXEffectCompilerImpl_GetPixelShader,
3805 ID3DXEffectCompilerImpl_GetVertexShader,
3806 ID3DXEffectCompilerImpl_SetArrayRange,
3807 /*** ID3DXEffectCompiler methods ***/
3808 ID3DXEffectCompilerImpl_SetLiteral,
3809 ID3DXEffectCompilerImpl_GetLiteral,
3810 ID3DXEffectCompilerImpl_CompileEffect,
3811 ID3DXEffectCompilerImpl_CompileShader,
3814 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
3816 HRESULT hr;
3817 UINT i;
3818 struct d3dx_state *states;
3820 read_dword(ptr, &sampler->state_count);
3821 TRACE("Count: %u\n", sampler->state_count);
3823 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
3824 if (!states)
3826 ERR("Out of memory\n");
3827 return E_OUTOFMEMORY;
3830 for (i = 0; i < sampler->state_count; ++i)
3832 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
3833 if (hr != D3D_OK)
3835 WARN("Failed to parse state\n");
3836 goto err_out;
3840 sampler->states = states;
3842 return D3D_OK;
3844 err_out:
3846 for (i = 0; i < sampler->state_count; ++i)
3848 free_state(&states[i]);
3851 HeapFree(GetProcessHeap(), 0, states);
3853 return hr;
3856 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
3858 unsigned int i;
3859 HRESULT hr;
3860 UINT old_size = 0;
3861 DWORD id;
3863 if (param->element_count)
3865 param->data = value;
3867 for (i = 0; i < param->element_count; ++i)
3869 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3871 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
3872 if (hr != D3D_OK)
3874 WARN("Failed to parse value\n");
3875 return hr;
3878 old_size += member->bytes;
3881 return D3D_OK;
3884 switch(param->class)
3886 case D3DXPC_SCALAR:
3887 case D3DXPC_VECTOR:
3888 case D3DXPC_MATRIX_ROWS:
3889 case D3DXPC_MATRIX_COLUMNS:
3890 param->data = value;
3891 break;
3893 case D3DXPC_STRUCT:
3894 param->data = value;
3896 for (i = 0; i < param->member_count; ++i)
3898 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3900 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
3901 if (hr != D3D_OK)
3903 WARN("Failed to parse value\n");
3904 return hr;
3907 old_size += member->bytes;
3909 break;
3911 case D3DXPC_OBJECT:
3912 switch (param->type)
3914 case D3DXPT_STRING:
3915 case D3DXPT_TEXTURE:
3916 case D3DXPT_TEXTURE1D:
3917 case D3DXPT_TEXTURE2D:
3918 case D3DXPT_TEXTURE3D:
3919 case D3DXPT_TEXTURECUBE:
3920 case D3DXPT_PIXELSHADER:
3921 case D3DXPT_VERTEXSHADER:
3922 read_dword(ptr, &id);
3923 TRACE("Id: %u\n", id);
3924 objects[id] = get_parameter_handle(param);
3925 param->data = value;
3926 break;
3928 case D3DXPT_SAMPLER:
3929 case D3DXPT_SAMPLER1D:
3930 case D3DXPT_SAMPLER2D:
3931 case D3DXPT_SAMPLER3D:
3932 case D3DXPT_SAMPLERCUBE:
3934 struct d3dx_sampler *sampler;
3936 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
3937 if (!sampler)
3939 ERR("Out of memory\n");
3940 return E_OUTOFMEMORY;
3943 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
3944 if (hr != D3D_OK)
3946 HeapFree(GetProcessHeap(), 0, sampler);
3947 WARN("Failed to parse sampler\n");
3948 return hr;
3951 param->data = sampler;
3952 break;
3955 default:
3956 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3957 break;
3959 break;
3961 default:
3962 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3963 break;
3966 return D3D_OK;
3969 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
3971 UINT size = param->bytes;
3972 HRESULT hr;
3973 void *value = NULL;
3975 TRACE("param size: %u\n", size);
3977 if (size)
3979 value = HeapAlloc(GetProcessHeap(), 0, size);
3980 if (!value)
3982 ERR("Failed to allocate data memory.\n");
3983 return E_OUTOFMEMORY;
3986 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3987 memcpy(value, ptr, size);
3990 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
3991 if (hr != D3D_OK)
3993 WARN("Failed to parse value\n");
3994 HeapFree(GetProcessHeap(), 0, value);
3995 return hr;
3998 return D3D_OK;
4001 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4003 DWORD size;
4005 read_dword(&ptr, &size);
4006 TRACE("Name size: %#x\n", size);
4008 if (!size)
4010 return D3D_OK;
4013 *name = HeapAlloc(GetProcessHeap(), 0, size);
4014 if (!*name)
4016 ERR("Failed to allocate name memory.\n");
4017 return E_OUTOFMEMORY;
4020 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4021 memcpy(*name, ptr, size);
4023 return D3D_OK;
4026 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4028 DWORD size;
4030 read_dword(ptr, &size);
4031 TRACE("Data size: %#x\n", size);
4033 *str = HeapAlloc(GetProcessHeap(), 0, size);
4034 if (!*str)
4036 ERR("Failed to allocate name memory.\n");
4037 return E_OUTOFMEMORY;
4040 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4041 memcpy(*str, *ptr, size);
4043 *ptr += ((size + 3) & ~3);
4045 return D3D_OK;
4048 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4050 DWORD size;
4051 HRESULT hr;
4053 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4055 read_dword(ptr, &size);
4056 TRACE("Data size: %#x\n", size);
4058 if (!size)
4060 TRACE("Size is 0\n");
4061 *(void **)param->data = NULL;
4062 return D3D_OK;
4065 switch (param->type)
4067 case D3DXPT_STRING:
4068 /* re-read with size (sizeof(DWORD) = 4) */
4069 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4070 if (hr != D3D_OK)
4072 WARN("Failed to parse string data\n");
4073 return hr;
4075 break;
4077 case D3DXPT_VERTEXSHADER:
4078 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4079 if (hr != D3D_OK)
4081 WARN("Failed to create vertex shader\n");
4082 return hr;
4084 break;
4086 case D3DXPT_PIXELSHADER:
4087 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4088 if (hr != D3D_OK)
4090 WARN("Failed to create pixel shader\n");
4091 return hr;
4093 break;
4095 default:
4096 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4097 break;
4101 *ptr += ((size + 3) & ~3);
4103 return D3D_OK;
4106 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4107 struct d3dx_parameter *parent, UINT flags)
4109 DWORD offset;
4110 HRESULT hr;
4111 D3DXHANDLE *member_handles = NULL;
4112 UINT i;
4114 param->flags = flags;
4116 if (!parent)
4118 read_dword(ptr, &param->type);
4119 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4121 read_dword(ptr, &param->class);
4122 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4124 read_dword(ptr, &offset);
4125 TRACE("Type name offset: %#x\n", offset);
4126 hr = d3dx9_parse_name(&param->name, data + offset);
4127 if (hr != D3D_OK)
4129 WARN("Failed to parse name\n");
4130 goto err_out;
4133 read_dword(ptr, &offset);
4134 TRACE("Type semantic offset: %#x\n", offset);
4135 hr = d3dx9_parse_name(&param->semantic, data + offset);
4136 if (hr != D3D_OK)
4138 WARN("Failed to parse semantic\n");
4139 goto err_out;
4142 read_dword(ptr, &param->element_count);
4143 TRACE("Elements: %u\n", param->element_count);
4145 switch (param->class)
4147 case D3DXPC_VECTOR:
4148 read_dword(ptr, &param->columns);
4149 TRACE("Columns: %u\n", param->columns);
4151 read_dword(ptr, &param->rows);
4152 TRACE("Rows: %u\n", param->rows);
4154 /* sizeof(DWORD) * rows * columns */
4155 param->bytes = 4 * param->rows * param->columns;
4156 break;
4158 case D3DXPC_SCALAR:
4159 case D3DXPC_MATRIX_ROWS:
4160 case D3DXPC_MATRIX_COLUMNS:
4161 read_dword(ptr, &param->rows);
4162 TRACE("Rows: %u\n", param->rows);
4164 read_dword(ptr, &param->columns);
4165 TRACE("Columns: %u\n", param->columns);
4167 /* sizeof(DWORD) * rows * columns */
4168 param->bytes = 4 * param->rows * param->columns;
4169 break;
4171 case D3DXPC_STRUCT:
4172 read_dword(ptr, &param->member_count);
4173 TRACE("Members: %u\n", param->member_count);
4174 break;
4176 case D3DXPC_OBJECT:
4177 switch (param->type)
4179 case D3DXPT_STRING:
4180 param->bytes = sizeof(LPCSTR);
4181 break;
4183 case D3DXPT_PIXELSHADER:
4184 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4185 break;
4187 case D3DXPT_VERTEXSHADER:
4188 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4189 break;
4191 case D3DXPT_TEXTURE:
4192 case D3DXPT_TEXTURE1D:
4193 case D3DXPT_TEXTURE2D:
4194 case D3DXPT_TEXTURE3D:
4195 case D3DXPT_TEXTURECUBE:
4196 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4197 break;
4199 case D3DXPT_SAMPLER:
4200 case D3DXPT_SAMPLER1D:
4201 case D3DXPT_SAMPLER2D:
4202 case D3DXPT_SAMPLER3D:
4203 case D3DXPT_SAMPLERCUBE:
4204 param->bytes = 0;
4205 break;
4207 default:
4208 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4209 break;
4211 break;
4213 default:
4214 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4215 break;
4218 else
4220 /* elements */
4221 param->type = parent->type;
4222 param->class = parent->class;
4223 param->name = parent->name;
4224 param->semantic = parent->semantic;
4225 param->element_count = 0;
4226 param->annotation_count = 0;
4227 param->member_count = parent->member_count;
4228 param->bytes = parent->bytes;
4229 param->rows = parent->rows;
4230 param->columns = parent->columns;
4233 if (param->element_count)
4235 unsigned int param_bytes = 0;
4236 const char *save_ptr = *ptr;
4238 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4239 if (!member_handles)
4241 ERR("Out of memory\n");
4242 hr = E_OUTOFMEMORY;
4243 goto err_out;
4246 for (i = 0; i < param->element_count; ++i)
4248 struct d3dx_parameter *member;
4249 *ptr = save_ptr;
4251 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4252 if (!member)
4254 ERR("Out of memory\n");
4255 hr = E_OUTOFMEMORY;
4256 goto err_out;
4259 member_handles[i] = get_parameter_handle(member);
4261 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4262 if (hr != D3D_OK)
4264 WARN("Failed to parse member\n");
4265 goto err_out;
4268 param_bytes += member->bytes;
4271 param->bytes = param_bytes;
4273 else if (param->member_count)
4275 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4276 if (!member_handles)
4278 ERR("Out of memory\n");
4279 hr = E_OUTOFMEMORY;
4280 goto err_out;
4283 for (i = 0; i < param->member_count; ++i)
4285 struct d3dx_parameter *member;
4287 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4288 if (!member)
4290 ERR("Out of memory\n");
4291 hr = E_OUTOFMEMORY;
4292 goto err_out;
4295 member_handles[i] = get_parameter_handle(member);
4297 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4298 if (hr != D3D_OK)
4300 WARN("Failed to parse member\n");
4301 goto err_out;
4304 param->bytes += member->bytes;
4308 param->member_handles = member_handles;
4310 return D3D_OK;
4312 err_out:
4314 if (member_handles)
4316 unsigned int count;
4318 if (param->element_count) count = param->element_count;
4319 else count = param->member_count;
4321 for (i = 0; i < count; ++i)
4323 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4325 HeapFree(GetProcessHeap(), 0, member_handles);
4328 if (!parent)
4330 HeapFree(GetProcessHeap(), 0, param->name);
4331 HeapFree(GetProcessHeap(), 0, param->semantic);
4333 param->name = NULL;
4334 param->semantic = NULL;
4336 return hr;
4339 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4341 DWORD offset;
4342 const char *ptr2;
4343 HRESULT hr;
4345 anno->flags = D3DX_PARAMETER_ANNOTATION;
4347 read_dword(ptr, &offset);
4348 TRACE("Typedef offset: %#x\n", offset);
4349 ptr2 = data + offset;
4350 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4351 if (hr != D3D_OK)
4353 WARN("Failed to parse type definition\n");
4354 return hr;
4357 read_dword(ptr, &offset);
4358 TRACE("Value offset: %#x\n", offset);
4359 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4360 if (hr != D3D_OK)
4362 WARN("Failed to parse value\n");
4363 return hr;
4366 return D3D_OK;
4369 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4371 DWORD offset;
4372 const char *ptr2;
4373 HRESULT hr;
4374 struct d3dx_parameter *parameter;
4376 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4377 if (!parameter)
4379 ERR("Out of memory\n");
4380 return E_OUTOFMEMORY;
4383 state->type = ST_CONSTANT;
4385 read_dword(ptr, &state->operation);
4386 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4388 read_dword(ptr, &state->index);
4389 TRACE("Index: %#x\n", state->index);
4391 read_dword(ptr, &offset);
4392 TRACE("Typedef offset: %#x\n", offset);
4393 ptr2 = data + offset;
4394 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4395 if (hr != D3D_OK)
4397 WARN("Failed to parse type definition\n");
4398 goto err_out;
4401 read_dword(ptr, &offset);
4402 TRACE("Value offset: %#x\n", offset);
4403 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4404 if (hr != D3D_OK)
4406 WARN("Failed to parse value\n");
4407 goto err_out;
4410 state->parameter = get_parameter_handle(parameter);
4412 return D3D_OK;
4414 err_out:
4416 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4418 return hr;
4421 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4423 DWORD offset;
4424 HRESULT hr;
4425 unsigned int i;
4426 D3DXHANDLE *annotation_handles = NULL;
4427 const char *ptr2;
4429 read_dword(ptr, &offset);
4430 TRACE("Typedef offset: %#x\n", offset);
4431 ptr2 = data + offset;
4433 read_dword(ptr, &offset);
4434 TRACE("Value offset: %#x\n", offset);
4436 read_dword(ptr, &param->flags);
4437 TRACE("Flags: %#x\n", param->flags);
4439 read_dword(ptr, &param->annotation_count);
4440 TRACE("Annotation count: %u\n", param->annotation_count);
4442 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4443 if (hr != D3D_OK)
4445 WARN("Failed to parse type definition\n");
4446 return hr;
4449 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4450 if (hr != D3D_OK)
4452 WARN("Failed to parse value\n");
4453 return hr;
4456 if (param->annotation_count)
4458 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4459 if (!annotation_handles)
4461 ERR("Out of memory\n");
4462 hr = E_OUTOFMEMORY;
4463 goto err_out;
4466 for (i = 0; i < param->annotation_count; ++i)
4468 struct d3dx_parameter *annotation;
4470 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4471 if (!annotation)
4473 ERR("Out of memory\n");
4474 hr = E_OUTOFMEMORY;
4475 goto err_out;
4478 annotation_handles[i] = get_parameter_handle(annotation);
4480 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4481 if (hr != D3D_OK)
4483 WARN("Failed to parse annotation\n");
4484 goto err_out;
4489 param->annotation_handles = annotation_handles;
4491 return D3D_OK;
4493 err_out:
4495 if (annotation_handles)
4497 for (i = 0; i < param->annotation_count; ++i)
4499 free_parameter(annotation_handles[i], FALSE, FALSE);
4501 HeapFree(GetProcessHeap(), 0, annotation_handles);
4504 return hr;
4507 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4509 DWORD offset;
4510 HRESULT hr;
4511 unsigned int i;
4512 D3DXHANDLE *annotation_handles = NULL;
4513 struct d3dx_state *states = NULL;
4514 char *name = NULL;
4516 read_dword(ptr, &offset);
4517 TRACE("Pass name offset: %#x\n", offset);
4518 hr = d3dx9_parse_name(&name, data + offset);
4519 if (hr != D3D_OK)
4521 WARN("Failed to parse name\n");
4522 goto err_out;
4525 read_dword(ptr, &pass->annotation_count);
4526 TRACE("Annotation count: %u\n", pass->annotation_count);
4528 read_dword(ptr, &pass->state_count);
4529 TRACE("State count: %u\n", pass->state_count);
4531 if (pass->annotation_count)
4533 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4534 if (!annotation_handles)
4536 ERR("Out of memory\n");
4537 hr = E_OUTOFMEMORY;
4538 goto err_out;
4541 for (i = 0; i < pass->annotation_count; ++i)
4543 struct d3dx_parameter *annotation;
4545 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4546 if (!annotation)
4548 ERR("Out of memory\n");
4549 hr = E_OUTOFMEMORY;
4550 goto err_out;
4553 annotation_handles[i] = get_parameter_handle(annotation);
4555 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4556 if (hr != D3D_OK)
4558 WARN("Failed to parse annotations\n");
4559 goto err_out;
4564 if (pass->state_count)
4566 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4567 if (!states)
4569 ERR("Out of memory\n");
4570 hr = E_OUTOFMEMORY;
4571 goto err_out;
4574 for (i = 0; i < pass->state_count; ++i)
4576 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4577 if (hr != D3D_OK)
4579 WARN("Failed to parse annotations\n");
4580 goto err_out;
4585 pass->name = name;
4586 pass->annotation_handles = annotation_handles;
4587 pass->states = states;
4589 return D3D_OK;
4591 err_out:
4593 if (annotation_handles)
4595 for (i = 0; i < pass->annotation_count; ++i)
4597 free_parameter(annotation_handles[i], FALSE, FALSE);
4599 HeapFree(GetProcessHeap(), 0, annotation_handles);
4602 if (states)
4604 for (i = 0; i < pass->state_count; ++i)
4606 free_state(&states[i]);
4608 HeapFree(GetProcessHeap(), 0, states);
4611 HeapFree(GetProcessHeap(), 0, name);
4613 return hr;
4616 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4618 DWORD offset;
4619 HRESULT hr;
4620 unsigned int i;
4621 D3DXHANDLE *annotation_handles = NULL;
4622 D3DXHANDLE *pass_handles = NULL;
4623 char *name = NULL;
4625 read_dword(ptr, &offset);
4626 TRACE("Technique name offset: %#x\n", offset);
4627 hr = d3dx9_parse_name(&name, data + offset);
4628 if (hr != D3D_OK)
4630 WARN("Failed to parse name\n");
4631 goto err_out;
4634 read_dword(ptr, &technique->annotation_count);
4635 TRACE("Annotation count: %u\n", technique->annotation_count);
4637 read_dword(ptr, &technique->pass_count);
4638 TRACE("Pass count: %u\n", technique->pass_count);
4640 if (technique->annotation_count)
4642 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4643 if (!annotation_handles)
4645 ERR("Out of memory\n");
4646 hr = E_OUTOFMEMORY;
4647 goto err_out;
4650 for (i = 0; i < technique->annotation_count; ++i)
4652 struct d3dx_parameter *annotation;
4654 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4655 if (!annotation)
4657 ERR("Out of memory\n");
4658 hr = E_OUTOFMEMORY;
4659 goto err_out;
4662 annotation_handles[i] = get_parameter_handle(annotation);
4664 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4665 if (hr != D3D_OK)
4667 WARN("Failed to parse annotations\n");
4668 goto err_out;
4673 if (technique->pass_count)
4675 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4676 if (!pass_handles)
4678 ERR("Out of memory\n");
4679 hr = E_OUTOFMEMORY;
4680 goto err_out;
4683 for (i = 0; i < technique->pass_count; ++i)
4685 struct d3dx_pass *pass;
4687 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4688 if (!pass)
4690 ERR("Out of memory\n");
4691 hr = E_OUTOFMEMORY;
4692 goto err_out;
4695 pass_handles[i] = get_pass_handle(pass);
4697 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
4698 if (hr != D3D_OK)
4700 WARN("Failed to parse passes\n");
4701 goto err_out;
4706 technique->name = name;
4707 technique->pass_handles = pass_handles;
4708 technique->annotation_handles = annotation_handles;
4710 return D3D_OK;
4712 err_out:
4714 if (pass_handles)
4716 for (i = 0; i < technique->pass_count; ++i)
4718 free_pass(pass_handles[i]);
4720 HeapFree(GetProcessHeap(), 0, pass_handles);
4723 if (annotation_handles)
4725 for (i = 0; i < technique->annotation_count; ++i)
4727 free_parameter(annotation_handles[i], FALSE, FALSE);
4729 HeapFree(GetProcessHeap(), 0, annotation_handles);
4732 HeapFree(GetProcessHeap(), 0, name);
4734 return hr;
4737 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
4739 DWORD technique_index;
4740 DWORD index, state_index, usage;
4741 struct d3dx_state *state;
4742 struct d3dx_parameter *param;
4743 HRESULT hr = E_FAIL;
4745 read_dword(ptr, &technique_index);
4746 TRACE("techn: %u\n", technique_index);
4748 read_dword(ptr, &index);
4749 TRACE("index: %u\n", index);
4751 skip_dword_unknown(ptr, 1);
4753 read_dword(ptr, &state_index);
4754 TRACE("state: %u\n", state_index);
4756 read_dword(ptr, &usage);
4757 TRACE("usage: %u\n", usage);
4759 if (technique_index == 0xffffffff)
4761 struct d3dx_parameter *parameter;
4762 struct d3dx_sampler *sampler;
4764 if (index >= base->parameter_count)
4766 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
4767 return E_FAIL;
4770 parameter = get_parameter_struct(base->parameter_handles[index]);
4771 sampler = parameter->data;
4772 if (state_index >= sampler->state_count)
4774 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
4775 return E_FAIL;
4778 state = &sampler->states[state_index];
4780 else
4782 struct d3dx_technique *technique;
4783 struct d3dx_pass *pass;
4785 if (technique_index >= base->technique_count)
4787 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
4788 return E_FAIL;
4791 technique = get_technique_struct(base->technique_handles[technique_index]);
4792 if (index >= technique->pass_count)
4794 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
4795 return E_FAIL;
4798 pass = get_pass_struct(technique->pass_handles[index]);
4799 if (state_index >= pass->state_count)
4801 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
4802 return E_FAIL;
4805 state = &pass->states[state_index];
4808 param = get_parameter_struct(state->parameter);
4810 switch (usage)
4812 case 0:
4813 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
4814 switch (param->type)
4816 case D3DXPT_VERTEXSHADER:
4817 case D3DXPT_PIXELSHADER:
4818 state->type = ST_CONSTANT;
4819 hr = d3dx9_parse_data(param, ptr, base->effect->device);
4820 break;
4822 case D3DXPT_BOOL:
4823 case D3DXPT_INT:
4824 case D3DXPT_FLOAT:
4825 case D3DXPT_STRING:
4826 state->type = ST_FXLC;
4827 hr = d3dx9_copy_data(param->data, ptr);
4828 break;
4830 default:
4831 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4832 break;
4834 break;
4836 case 1:
4837 state->type = ST_PARAMETER;
4838 hr = d3dx9_copy_data(param->data, ptr);
4839 if (hr == D3D_OK)
4841 TRACE("Mapping to parameter %s\n", *(char **)param->data);
4843 break;
4845 default:
4846 FIXME("Unknown usage %x\n", usage);
4847 break;
4850 return hr;
4853 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4855 const char *ptr = data + start;
4856 D3DXHANDLE *parameter_handles = NULL;
4857 D3DXHANDLE *technique_handles = NULL;
4858 D3DXHANDLE *objects = NULL;
4859 UINT stringcount, objectcount, resourcecount;
4860 HRESULT hr;
4861 UINT i;
4863 read_dword(&ptr, &base->parameter_count);
4864 TRACE("Parameter count: %u\n", base->parameter_count);
4866 read_dword(&ptr, &base->technique_count);
4867 TRACE("Technique count: %u\n", base->technique_count);
4869 skip_dword_unknown(&ptr, 1);
4871 read_dword(&ptr, &objectcount);
4872 TRACE("Object count: %u\n", objectcount);
4874 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
4875 if (!objects)
4877 ERR("Out of memory\n");
4878 hr = E_OUTOFMEMORY;
4879 goto err_out;
4882 if (base->parameter_count)
4884 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4885 if (!parameter_handles)
4887 ERR("Out of memory\n");
4888 hr = E_OUTOFMEMORY;
4889 goto err_out;
4892 for (i = 0; i < base->parameter_count; ++i)
4894 struct d3dx_parameter *parameter;
4896 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4897 if (!parameter)
4899 ERR("Out of memory\n");
4900 hr = E_OUTOFMEMORY;
4901 goto err_out;
4904 parameter_handles[i] = get_parameter_handle(parameter);
4906 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
4907 if (hr != D3D_OK)
4909 WARN("Failed to parse parameter\n");
4910 goto err_out;
4915 if (base->technique_count)
4917 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4918 if (!technique_handles)
4920 ERR("Out of memory\n");
4921 hr = E_OUTOFMEMORY;
4922 goto err_out;
4925 for (i = 0; i < base->technique_count; ++i)
4927 struct d3dx_technique *technique;
4929 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4930 if (!technique)
4932 ERR("Out of memory\n");
4933 hr = E_OUTOFMEMORY;
4934 goto err_out;
4937 technique_handles[i] = get_technique_handle(technique);
4939 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
4940 if (hr != D3D_OK)
4942 WARN("Failed to parse technique\n");
4943 goto err_out;
4948 /* needed for further parsing */
4949 base->technique_handles = technique_handles;
4950 base->parameter_handles = parameter_handles;
4952 read_dword(&ptr, &stringcount);
4953 TRACE("String count: %u\n", stringcount);
4955 read_dword(&ptr, &resourcecount);
4956 TRACE("Resource count: %u\n", resourcecount);
4958 for (i = 0; i < stringcount; ++i)
4960 DWORD id;
4961 struct d3dx_parameter *param;
4963 read_dword(&ptr, &id);
4964 TRACE("Id: %u\n", id);
4966 param = get_parameter_struct(objects[id]);
4968 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
4969 if (hr != D3D_OK)
4971 WARN("Failed to parse data\n");
4972 goto err_out;
4976 for (i = 0; i < resourcecount; ++i)
4978 TRACE("parse resource %u\n", i);
4980 hr = d3dx9_parse_resource(base, data, &ptr);
4981 if (hr != D3D_OK)
4983 WARN("Failed to parse data\n");
4984 goto err_out;
4988 HeapFree(GetProcessHeap(), 0, objects);
4990 return D3D_OK;
4992 err_out:
4994 if (technique_handles)
4996 for (i = 0; i < base->technique_count; ++i)
4998 free_technique(technique_handles[i]);
5000 HeapFree(GetProcessHeap(), 0, technique_handles);
5003 if (parameter_handles)
5005 for (i = 0; i < base->parameter_count; ++i)
5007 free_parameter(parameter_handles[i], FALSE, FALSE);
5009 HeapFree(GetProcessHeap(), 0, parameter_handles);
5012 base->technique_handles = NULL;
5013 base->parameter_handles = NULL;
5015 HeapFree(GetProcessHeap(), 0, objects);
5017 return hr;
5020 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5021 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5023 DWORD tag, offset;
5024 const char *ptr = data;
5025 HRESULT hr;
5027 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5029 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5030 base->ref = 1;
5031 base->effect = effect;
5033 read_dword(&ptr, &tag);
5034 TRACE("Tag: %x\n", tag);
5036 if (tag != d3dx9_effect_version(9, 1))
5038 /* todo: compile hlsl ascii code */
5039 FIXME("HLSL ascii effects not supported, yet\n");
5041 /* Show the start of the shader for debugging info. */
5042 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5044 else
5046 read_dword(&ptr, &offset);
5047 TRACE("Offset: %x\n", offset);
5049 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5050 if (hr != D3D_OK)
5052 FIXME("Failed to parse effect.\n");
5053 return hr;
5057 return D3D_OK;
5060 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5061 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5063 HRESULT hr;
5064 struct ID3DXBaseEffectImpl *object = NULL;
5066 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5068 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5069 effect->ref = 1;
5071 if (pool) pool->lpVtbl->AddRef(pool);
5072 effect->pool = pool;
5074 IDirect3DDevice9_AddRef(device);
5075 effect->device = device;
5077 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5078 if (!object)
5080 ERR("Out of memory\n");
5081 hr = E_OUTOFMEMORY;
5082 goto err_out;
5085 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5086 if (hr != D3D_OK)
5088 FIXME("Failed to parse effect.\n");
5089 goto err_out;
5092 effect->base_effect = &object->ID3DXBaseEffect_iface;
5094 /* initialize defaults - check because of unsupported ascii effects */
5095 if (object->technique_handles)
5097 effect->active_technique = object->technique_handles[0];
5098 effect->active_pass = NULL;
5101 return D3D_OK;
5103 err_out:
5105 HeapFree(GetProcessHeap(), 0, object);
5106 free_effect(effect);
5108 return hr;
5111 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5112 LPCVOID srcdata,
5113 UINT srcdatalen,
5114 CONST D3DXMACRO* defines,
5115 LPD3DXINCLUDE include,
5116 LPCSTR skip_constants,
5117 DWORD flags,
5118 LPD3DXEFFECTPOOL pool,
5119 LPD3DXEFFECT* effect,
5120 LPD3DXBUFFER* compilation_errors)
5122 struct ID3DXEffectImpl *object;
5123 HRESULT hr;
5125 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5126 skip_constants, flags, pool, effect, compilation_errors);
5128 if (!device || !srcdata)
5129 return D3DERR_INVALIDCALL;
5131 if (!srcdatalen)
5132 return E_FAIL;
5134 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5135 if (!effect)
5136 return D3D_OK;
5138 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5139 if (!object)
5141 ERR("Out of memory\n");
5142 return E_OUTOFMEMORY;
5145 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5146 if (FAILED(hr))
5148 WARN("Failed to initialize shader reflection\n");
5149 HeapFree(GetProcessHeap(), 0, object);
5150 return hr;
5153 *effect = &object->ID3DXEffect_iface;
5155 TRACE("Created ID3DXEffect %p\n", object);
5157 return D3D_OK;
5160 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5161 LPCVOID srcdata,
5162 UINT srcdatalen,
5163 CONST D3DXMACRO* defines,
5164 LPD3DXINCLUDE include,
5165 DWORD flags,
5166 LPD3DXEFFECTPOOL pool,
5167 LPD3DXEFFECT* effect,
5168 LPD3DXBUFFER* compilation_errors)
5170 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5171 include, flags, pool, effect, compilation_errors);
5173 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5176 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5178 HRESULT hr;
5179 struct ID3DXBaseEffectImpl *object = NULL;
5181 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5183 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5184 compiler->ref = 1;
5186 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5187 if (!object)
5189 ERR("Out of memory\n");
5190 hr = E_OUTOFMEMORY;
5191 goto err_out;
5194 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5195 if (hr != D3D_OK)
5197 FIXME("Failed to parse effect.\n");
5198 goto err_out;
5201 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5203 return D3D_OK;
5205 err_out:
5207 HeapFree(GetProcessHeap(), 0, object);
5208 free_effect_compiler(compiler);
5210 return hr;
5213 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5214 UINT srcdatalen,
5215 CONST D3DXMACRO *defines,
5216 LPD3DXINCLUDE include,
5217 DWORD flags,
5218 LPD3DXEFFECTCOMPILER *compiler,
5219 LPD3DXBUFFER *parse_errors)
5221 struct ID3DXEffectCompilerImpl *object;
5222 HRESULT hr;
5224 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5225 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5227 if (!srcdata || !compiler)
5229 WARN("Invalid arguments supplied\n");
5230 return D3DERR_INVALIDCALL;
5233 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5234 if (!object)
5236 ERR("Out of memory\n");
5237 return E_OUTOFMEMORY;
5240 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5241 if (FAILED(hr))
5243 WARN("Failed to initialize effect compiler\n");
5244 HeapFree(GetProcessHeap(), 0, object);
5245 return hr;
5248 *compiler = &object->ID3DXEffectCompiler_iface;
5250 TRACE("Created ID3DXEffectCompiler %p\n", object);
5252 return D3D_OK;
5255 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5257 struct ID3DXEffectPoolImpl
5259 ID3DXEffectPool ID3DXEffectPool_iface;
5260 LONG ref;
5263 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5265 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5268 /*** IUnknown methods ***/
5269 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5271 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5273 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5275 if (IsEqualGUID(riid, &IID_IUnknown) ||
5276 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5278 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5279 *object = This;
5280 return S_OK;
5283 WARN("Interface %s not found\n", debugstr_guid(riid));
5285 return E_NOINTERFACE;
5288 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5290 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5292 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5294 return InterlockedIncrement(&This->ref);
5297 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5299 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5300 ULONG ref = InterlockedDecrement(&This->ref);
5302 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5304 if (!ref)
5305 HeapFree(GetProcessHeap(), 0, This);
5307 return ref;
5310 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5312 /*** IUnknown methods ***/
5313 ID3DXEffectPoolImpl_QueryInterface,
5314 ID3DXEffectPoolImpl_AddRef,
5315 ID3DXEffectPoolImpl_Release
5318 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5320 struct ID3DXEffectPoolImpl *object;
5322 TRACE("(%p)\n", pool);
5324 if (!pool)
5325 return D3DERR_INVALIDCALL;
5327 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5328 if (!object)
5330 ERR("Out of memory\n");
5331 return E_OUTOFMEMORY;
5334 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5335 object->ref = 1;
5337 *pool = &object->ID3DXEffectPool_iface;
5339 return S_OK;
5342 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5343 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5344 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5346 LPVOID buffer;
5347 HRESULT ret;
5348 DWORD size;
5350 TRACE("(%s): relay\n", debugstr_w(srcfile));
5352 if (!device || !srcfile)
5353 return D3DERR_INVALIDCALL;
5355 ret = map_view_of_file(srcfile, &buffer, &size);
5357 if (FAILED(ret))
5358 return D3DXERR_INVALIDDATA;
5360 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5361 UnmapViewOfFile(buffer);
5363 return ret;
5366 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5367 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5368 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5370 LPWSTR srcfileW;
5371 HRESULT ret;
5372 DWORD len;
5374 TRACE("(void): relay\n");
5376 if (!srcfile)
5377 return D3DERR_INVALIDCALL;
5379 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5380 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5381 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5383 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5384 HeapFree(GetProcessHeap(), 0, srcfileW);
5386 return ret;
5389 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5390 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5391 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5393 TRACE("(void): relay\n");
5394 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5397 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5398 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5399 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5401 TRACE("(void): relay\n");
5402 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5405 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5406 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5407 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5409 HRSRC resinfo;
5411 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5413 if (!device)
5414 return D3DERR_INVALIDCALL;
5416 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5418 if (resinfo)
5420 LPVOID buffer;
5421 HRESULT ret;
5422 DWORD size;
5424 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5426 if (FAILED(ret))
5427 return D3DXERR_INVALIDDATA;
5429 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5432 return D3DXERR_INVALIDDATA;
5435 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5436 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5437 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5439 HRSRC resinfo;
5441 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5443 if (!device)
5444 return D3DERR_INVALIDCALL;
5446 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5448 if (resinfo)
5450 LPVOID buffer;
5451 HRESULT ret;
5452 DWORD size;
5454 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5456 if (FAILED(ret))
5457 return D3DXERR_INVALIDDATA;
5459 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5462 return D3DXERR_INVALIDDATA;
5465 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5466 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5467 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5469 TRACE("(void): relay\n");
5470 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5473 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5474 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5475 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5477 TRACE("(void): relay\n");
5478 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5481 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5482 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5484 LPVOID buffer;
5485 HRESULT ret;
5486 DWORD size;
5488 TRACE("(%s): relay\n", debugstr_w(srcfile));
5490 if (!srcfile)
5491 return D3DERR_INVALIDCALL;
5493 ret = map_view_of_file(srcfile, &buffer, &size);
5495 if (FAILED(ret))
5496 return D3DXERR_INVALIDDATA;
5498 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5499 UnmapViewOfFile(buffer);
5501 return ret;
5504 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5505 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5507 LPWSTR srcfileW;
5508 HRESULT ret;
5509 DWORD len;
5511 TRACE("(void): relay\n");
5513 if (!srcfile)
5514 return D3DERR_INVALIDCALL;
5516 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5517 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5518 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5520 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5521 HeapFree(GetProcessHeap(), 0, srcfileW);
5523 return ret;
5526 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5527 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5529 HRSRC resinfo;
5531 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5533 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5535 if (resinfo)
5537 LPVOID buffer;
5538 HRESULT ret;
5539 DWORD size;
5541 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5543 if (FAILED(ret))
5544 return D3DXERR_INVALIDDATA;
5546 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5549 return D3DXERR_INVALIDDATA;
5552 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5553 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5555 HRSRC resinfo;
5557 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5559 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5561 if (resinfo)
5563 LPVOID buffer;
5564 HRESULT ret;
5565 DWORD size;
5567 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5569 if (FAILED(ret))
5570 return D3DXERR_INVALIDDATA;
5572 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5575 return D3DXERR_INVALIDDATA;