d3dx9: Implement ID3DXBaseEffect::GetIntArray().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blob137293cd6d9d763c816551b29570e1fa61989c2e
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 struct d3dx_parameter
90 char *name;
91 char *semantic;
92 void *data;
93 D3DXPARAMETER_CLASS class;
94 D3DXPARAMETER_TYPE type;
95 UINT rows;
96 UINT columns;
97 UINT element_count;
98 UINT annotation_count;
99 UINT member_count;
100 DWORD flags;
101 UINT bytes;
103 D3DXHANDLE *annotation_handles;
104 D3DXHANDLE *member_handles;
107 struct d3dx_state
109 UINT operation;
110 UINT index;
112 D3DXHANDLE parameter;
115 struct d3dx_sampler
117 UINT state_count;
118 struct d3dx_state *states;
121 struct d3dx_pass
123 char *name;
124 UINT state_count;
125 UINT annotation_count;
127 struct d3dx_state *states;
128 D3DXHANDLE *annotation_handles;
131 struct d3dx_technique
133 char *name;
134 UINT pass_count;
135 UINT annotation_count;
137 D3DXHANDLE *annotation_handles;
138 D3DXHANDLE *pass_handles;
141 struct ID3DXBaseEffectImpl
143 ID3DXBaseEffect ID3DXBaseEffect_iface;
144 LONG ref;
146 struct ID3DXEffectImpl *effect;
148 UINT parameter_count;
149 UINT technique_count;
151 D3DXHANDLE *parameter_handles;
152 D3DXHANDLE *technique_handles;
155 struct ID3DXEffectImpl
157 ID3DXEffect ID3DXEffect_iface;
158 LONG ref;
160 LPD3DXEFFECTSTATEMANAGER manager;
161 LPDIRECT3DDEVICE9 device;
162 LPD3DXEFFECTPOOL pool;
164 ID3DXBaseEffect *base_effect;
167 struct ID3DXEffectCompilerImpl
169 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
170 LONG ref;
172 ID3DXBaseEffect *base_effect;
175 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
176 struct d3dx_parameter *parameter, LPCSTR name);
177 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
178 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
179 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child);
181 static const struct
183 enum STATE_CLASS class;
184 UINT op;
185 LPCSTR name;
187 state_table[] =
189 /* Render sates */
190 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
191 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
192 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
193 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
194 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
195 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
196 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
197 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
198 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
199 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
200 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
201 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
202 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
203 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
204 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
205 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
206 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
207 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
208 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
209 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
210 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
211 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
212 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
213 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
214 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
215 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
216 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
217 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
218 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
219 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
220 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
221 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
222 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
223 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
224 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
225 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
226 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
227 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
228 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
229 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
230 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
231 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
232 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
233 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
234 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
235 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
236 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
237 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
238 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
239 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
240 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
241 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
242 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
243 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
244 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
245 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
246 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
247 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
248 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
249 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
250 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
251 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
252 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
253 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
254 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
255 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
256 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
257 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
258 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
259 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
260 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
261 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
262 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
263 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
264 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
265 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
266 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
267 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
268 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
269 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
270 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
271 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
272 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
273 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
274 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
275 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
276 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
277 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
278 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
279 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
280 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
281 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
282 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
283 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
284 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
285 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
286 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
287 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
288 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
289 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
290 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
291 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
292 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
293 /* Texture stages */
294 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
295 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
296 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
297 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
298 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
299 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
300 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
301 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
302 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
303 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
304 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
305 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
306 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
307 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
308 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
309 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
310 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
311 /* */
312 {SC_UNKNOWN, 0, "UNKNOWN"},
313 /* NPatchMode */
314 {SC_NPATCHMODE, 0, "NPatchMode"},
315 /* */
316 {SC_UNKNOWN, 0, "UNKNOWN"},
317 /* Transform */
318 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
319 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
320 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
321 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
322 /* Material */
323 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
324 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
325 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
326 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
327 {SC_MATERIAL, MT_POWER, "MaterialPower"},
328 /* Light */
329 {SC_LIGHT, LT_TYPE, "LightType"},
330 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
331 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
332 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
333 {SC_LIGHT, LT_POSITION, "LightPosition"},
334 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
335 {SC_LIGHT, LT_RANGE, "LighRange"},
336 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
337 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
338 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
339 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
340 {SC_LIGHT, LT_THETA, "LightTheta"},
341 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
342 /* Ligthenable */
343 {SC_LIGHTENABLE, 0, "LightEnable"},
344 /* Vertexshader */
345 {SC_VERTEXSHADER, 0, "Vertexshader"},
346 /* Pixelshader */
347 {SC_PIXELSHADER, 0, "Pixelshader"},
348 /* Shader constants */
349 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
350 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
351 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
352 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
353 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
354 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
355 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
356 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
357 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
358 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
359 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
360 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
361 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
362 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
363 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
364 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
365 /* Texture */
366 {SC_TEXTURE, 0, "Texture"},
367 /* Sampler states */
368 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
369 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
370 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
371 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
372 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
373 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
374 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
375 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
376 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
377 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
378 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
379 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
380 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
381 /* Set sampler */
382 {SC_SETSAMPLER, 0, "Sampler"},
385 static inline void read_dword(const char **ptr, DWORD *d)
387 memcpy(d, *ptr, sizeof(*d));
388 *ptr += sizeof(*d);
391 static void skip_dword_unknown(const char **ptr, unsigned int count)
393 unsigned int i;
394 DWORD d;
396 FIXME("Skipping %u unknown DWORDs:\n", count);
397 for (i = 0; i < count; ++i)
399 read_dword(ptr, &d);
400 FIXME("\t0x%08x\n", d);
404 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
406 return (struct d3dx_parameter *) handle;
409 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
411 return (struct d3dx_pass *) handle;
414 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
416 return (struct d3dx_technique *) handle;
419 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
421 return (D3DXHANDLE) parameter;
424 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
426 return (D3DXHANDLE) technique;
429 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
431 return (D3DXHANDLE) pass;
434 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
436 unsigned int i;
438 for (i = 0; i < base->technique_count; ++i)
440 if (base->technique_handles[i] == technique)
442 return get_technique_struct(technique);
446 return NULL;
449 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
451 unsigned int i, k;
453 for (i = 0; i < base->technique_count; ++i)
455 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
457 for (k = 0; k < technique->pass_count; ++k)
459 if (technique->pass_handles[k] == pass)
461 return get_pass_struct(pass);
466 return NULL;
469 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
471 unsigned int i, count;
472 struct d3dx_parameter *p;
474 for (i = 0; i < param->annotation_count; ++i)
476 if (param->annotation_handles[i] == parameter)
478 return get_parameter_struct(parameter);
481 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
482 if (p) return p;
485 if (param->element_count) count = param->element_count;
486 else count = param->member_count;
488 for (i = 0; i < count; ++i)
490 if (param->member_handles[i] == parameter)
492 return get_parameter_struct(parameter);
495 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
496 if (p) return p;
499 return NULL;
502 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
504 unsigned int i, k, m;
505 struct d3dx_parameter *p;
507 for (i = 0; i < base->parameter_count; ++i)
509 if (base->parameter_handles[i] == parameter)
511 return get_parameter_struct(parameter);
514 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
515 if (p) return p;
518 for (i = 0; i < base->technique_count; ++i)
520 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
522 for (k = 0; k < technique->pass_count; ++k)
524 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
526 for (m = 0; m < pass->annotation_count; ++m)
528 if (pass->annotation_handles[i] == parameter)
530 return get_parameter_struct(parameter);
533 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
534 if (p) return p;
538 for (k = 0; k < technique->annotation_count; ++k)
540 if (technique->annotation_handles[k] == parameter)
542 return get_parameter_struct(parameter);
545 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
546 if (p) return p;
550 return NULL;
553 static void free_state(struct d3dx_state *state)
555 free_parameter(state->parameter, FALSE, FALSE);
558 static void free_sampler(struct d3dx_sampler *sampler)
560 UINT i;
562 for (i = 0; i < sampler->state_count; ++i)
564 free_state(&sampler->states[i]);
566 HeapFree(GetProcessHeap(), 0, sampler->states);
569 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
571 unsigned int i;
572 struct d3dx_parameter *param = get_parameter_struct(handle);
574 TRACE("Free parameter %p, name %s, child %s\n", param, param->name, child ? "yes" : "no");
576 if (!param)
578 return;
581 if (param->annotation_handles)
583 for (i = 0; i < param->annotation_count; ++i)
585 free_parameter(param->annotation_handles[i], FALSE, FALSE);
587 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
590 if (param->member_handles)
592 unsigned int count;
594 if (param->element_count) count = param->element_count;
595 else count = param->member_count;
597 for (i = 0; i < count; ++i)
599 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
601 HeapFree(GetProcessHeap(), 0, param->member_handles);
604 if (param->class == D3DXPC_OBJECT && !param->element_count)
606 switch (param->type)
608 case D3DXPT_STRING:
609 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
610 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
611 break;
613 case D3DXPT_TEXTURE:
614 case D3DXPT_TEXTURE1D:
615 case D3DXPT_TEXTURE2D:
616 case D3DXPT_TEXTURE3D:
617 case D3DXPT_TEXTURECUBE:
618 case D3DXPT_PIXELSHADER:
619 case D3DXPT_VERTEXSHADER:
620 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
621 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
622 break;
624 case D3DXPT_SAMPLER:
625 case D3DXPT_SAMPLER1D:
626 case D3DXPT_SAMPLER2D:
627 case D3DXPT_SAMPLER3D:
628 case D3DXPT_SAMPLERCUBE:
629 free_sampler((struct d3dx_sampler *)param->data);
630 /* samplers have always own data, so free that */
631 HeapFree(GetProcessHeap(), 0, param->data);
632 break;
634 default:
635 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
636 break;
639 else
641 if (!child)
643 HeapFree(GetProcessHeap(), 0, param->data);
647 /* only the parent has to release name and semantic */
648 if (!element)
650 HeapFree(GetProcessHeap(), 0, param->name);
651 HeapFree(GetProcessHeap(), 0, param->semantic);
654 HeapFree(GetProcessHeap(), 0, param);
657 static void free_pass(D3DXHANDLE handle)
659 unsigned int i;
660 struct d3dx_pass *pass = get_pass_struct(handle);
662 TRACE("Free pass %p\n", pass);
664 if (!pass)
666 return;
669 if (pass->annotation_handles)
671 for (i = 0; i < pass->annotation_count; ++i)
673 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
675 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
678 if (pass->states)
680 for (i = 0; i < pass->state_count; ++i)
682 free_state(&pass->states[i]);
684 HeapFree(GetProcessHeap(), 0, pass->states);
687 HeapFree(GetProcessHeap(), 0, pass->name);
688 HeapFree(GetProcessHeap(), 0, pass);
691 static void free_technique(D3DXHANDLE handle)
693 unsigned int i;
694 struct d3dx_technique *technique = get_technique_struct(handle);
696 TRACE("Free technique %p\n", technique);
698 if (!technique)
700 return;
703 if (technique->annotation_handles)
705 for (i = 0; i < technique->annotation_count; ++i)
707 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
709 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
712 if (technique->pass_handles)
714 for (i = 0; i < technique->pass_count; ++i)
716 free_pass(technique->pass_handles[i]);
718 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
721 HeapFree(GetProcessHeap(), 0, technique->name);
722 HeapFree(GetProcessHeap(), 0, technique);
725 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
727 unsigned int i;
729 TRACE("Free base effect %p\n", base);
731 if (base->parameter_handles)
733 for (i = 0; i < base->parameter_count; ++i)
735 free_parameter(base->parameter_handles[i], FALSE, FALSE);
737 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
740 if (base->technique_handles)
742 for (i = 0; i < base->technique_count; ++i)
744 free_technique(base->technique_handles[i]);
746 HeapFree(GetProcessHeap(), 0, base->technique_handles);
750 static void free_effect(struct ID3DXEffectImpl *effect)
752 TRACE("Free effect %p\n", effect);
754 if (effect->base_effect)
756 effect->base_effect->lpVtbl->Release(effect->base_effect);
759 if (effect->pool)
761 effect->pool->lpVtbl->Release(effect->pool);
764 if (effect->manager)
766 IUnknown_Release(effect->manager);
769 IDirect3DDevice9_Release(effect->device);
772 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
774 TRACE("Free effect compiler %p\n", compiler);
776 if (compiler->base_effect)
778 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
782 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
784 INT i;
786 switch (type)
788 case D3DXPT_FLOAT:
789 i = *(FLOAT *)data;
790 break;
792 case D3DXPT_INT:
793 i = *(INT *)data;
794 break;
796 case D3DXPT_BOOL:
797 i = *(BOOL *)data;
798 break;
800 default:
801 i = 0;
802 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
803 break;
806 return i;
809 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
811 FLOAT f;
813 switch (type)
815 case D3DXPT_FLOAT:
816 f = *(FLOAT *)data;
817 break;
819 case D3DXPT_INT:
820 f = *(INT *)data;
821 break;
823 case D3DXPT_BOOL:
824 f = *(BOOL *)data;
825 break;
827 default:
828 f = 0.0f;
829 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
830 break;
833 return f;
836 static inline BOOL get_bool(void *data)
838 return (*(DWORD *)data) ? TRUE : FALSE;
841 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
843 UINT element;
844 struct d3dx_parameter *temp_parameter;
845 LPCSTR part;
847 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
849 if (!name || !*name) return parameter;
851 element = atoi(name);
852 part = strchr(name, ']') + 1;
854 if (parameter->element_count > element)
856 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
858 switch (*part++)
860 case '.':
861 return get_parameter_by_name(NULL, temp_parameter, part);
863 case '@':
864 return get_parameter_annotation_by_name(temp_parameter, part);
866 case '\0':
867 TRACE("Returning parameter %p\n", temp_parameter);
868 return temp_parameter;
870 default:
871 FIXME("Unhandled case \"%c\"\n", *--part);
872 break;
876 TRACE("Parameter not found\n");
877 return NULL;
880 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
882 UINT i, length;
883 struct d3dx_parameter *temp_parameter;
884 LPCSTR part;
886 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
888 if (!name || !*name) return parameter;
890 length = strcspn( name, "[.@" );
891 part = name + length;
893 for (i = 0; i < parameter->annotation_count; ++i)
895 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
897 if (!strcmp(temp_parameter->name, name))
899 TRACE("Returning parameter %p\n", temp_parameter);
900 return temp_parameter;
902 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
904 switch (*part++)
906 case '.':
907 return get_parameter_by_name(NULL, temp_parameter, part);
909 case '[':
910 return get_parameter_element_by_name(temp_parameter, part);
912 default:
913 FIXME("Unhandled case \"%c\"\n", *--part);
914 break;
919 TRACE("Parameter not found\n");
920 return NULL;
923 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
924 struct d3dx_parameter *parameter, LPCSTR name)
926 UINT i, count, length;
927 struct d3dx_parameter *temp_parameter;
928 D3DXHANDLE *handles;
929 LPCSTR part;
931 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
933 if (!name || !*name) return parameter;
935 if (!parameter)
937 count = base->parameter_count;
938 handles = base->parameter_handles;
940 else
942 count = parameter->member_count;
943 handles = parameter->member_handles;
946 length = strcspn( name, "[.@" );
947 part = name + length;
949 for (i = 0; i < count; i++)
951 temp_parameter = get_parameter_struct(handles[i]);
953 if (!strcmp(temp_parameter->name, name))
955 TRACE("Returning parameter %p\n", temp_parameter);
956 return temp_parameter;
958 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
960 switch (*part++)
962 case '.':
963 return get_parameter_by_name(NULL, temp_parameter, part);
965 case '@':
966 return get_parameter_annotation_by_name(temp_parameter, part);
968 case '[':
969 return get_parameter_element_by_name(temp_parameter, part);
971 default:
972 FIXME("Unhandled case \"%c\"\n", *--part);
973 break;
978 TRACE("Parameter not found\n");
979 return NULL;
982 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
984 return (0xfeff0000 | ((major) << 8) | (minor));
987 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
989 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
992 /*** IUnknown methods ***/
993 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
995 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
997 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
999 if (IsEqualGUID(riid, &IID_IUnknown) ||
1000 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1002 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1003 *object = This;
1004 return S_OK;
1007 ERR("Interface %s not found\n", debugstr_guid(riid));
1009 return E_NOINTERFACE;
1012 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1014 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1016 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1018 return InterlockedIncrement(&This->ref);
1021 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1023 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1024 ULONG ref = InterlockedDecrement(&This->ref);
1026 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1028 if (!ref)
1030 free_base_effect(This);
1031 HeapFree(GetProcessHeap(), 0, This);
1034 return ref;
1037 /*** ID3DXBaseEffect methods ***/
1038 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1040 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1042 FIXME("iface %p, desc %p partial stub\n", This, desc);
1044 if (!desc)
1046 WARN("Invalid argument specified.\n");
1047 return D3DERR_INVALIDCALL;
1050 /* Todo: add creator and function count */
1051 desc->Creator = NULL;
1052 desc->Functions = 0;
1053 desc->Parameters = This->parameter_count;
1054 desc->Techniques = This->technique_count;
1056 return D3D_OK;
1059 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1061 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1062 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1064 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1066 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
1068 if (!desc || !param)
1070 WARN("Invalid argument specified.\n");
1071 return D3DERR_INVALIDCALL;
1074 desc->Name = param->name;
1075 desc->Semantic = param->semantic;
1076 desc->Class = param->class;
1077 desc->Type = param->type;
1078 desc->Rows = param->rows;
1079 desc->Columns = param->columns;
1080 desc->Elements = param->element_count;
1081 desc->Annotations = param->annotation_count;
1082 desc->StructMembers = param->member_count;
1083 desc->Flags = param->flags;
1084 desc->Bytes = param->bytes;
1086 return D3D_OK;
1089 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1091 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1092 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1094 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1096 if (!desc || !tech)
1098 WARN("Invalid argument specified.\n");
1099 return D3DERR_INVALIDCALL;
1102 desc->Name = tech->name;
1103 desc->Passes = tech->pass_count;
1104 desc->Annotations = tech->annotation_count;
1106 return D3D_OK;
1109 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1111 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1112 struct d3dx_pass *p = is_valid_pass(This, pass);
1114 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1116 if (!desc || !p)
1118 WARN("Invalid argument specified.\n");
1119 return D3DERR_INVALIDCALL;
1122 desc->Name = p->name;
1123 desc->Annotations = p->annotation_count;
1125 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1126 desc->pVertexShaderFunction = NULL;
1127 desc->pPixelShaderFunction = NULL;
1129 return D3D_OK;
1132 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1134 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1136 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1138 return E_NOTIMPL;
1141 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1143 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1144 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1146 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1148 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1150 if (!parameter)
1152 if (index < This->parameter_count)
1154 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1155 return This->parameter_handles[index];
1158 else
1160 if (param && !param->element_count && index < param->member_count)
1162 TRACE("Returning parameter %p\n", param->member_handles[index]);
1163 return param->member_handles[index];
1167 WARN("Invalid argument specified.\n");
1169 return NULL;
1172 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1174 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1175 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1176 D3DXHANDLE handle;
1178 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1180 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1182 if (!name)
1184 handle = get_parameter_handle(param);
1185 TRACE("Returning parameter %p\n", handle);
1186 return handle;
1189 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1190 TRACE("Returning parameter %p\n", handle);
1192 return handle;
1195 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1197 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1198 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1199 struct d3dx_parameter *temp_param;
1200 UINT i;
1202 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1204 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1206 if (!parameter)
1208 for (i = 0; i < This->parameter_count; ++i)
1210 temp_param = get_parameter_struct(This->parameter_handles[i]);
1212 if (!temp_param->semantic)
1214 if (!semantic)
1216 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1217 return This->parameter_handles[i];
1219 continue;
1222 if (!strcasecmp(temp_param->semantic, semantic))
1224 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1225 return This->parameter_handles[i];
1229 else if (param)
1231 for (i = 0; i < param->member_count; ++i)
1233 temp_param = get_parameter_struct(param->member_handles[i]);
1235 if (!temp_param->semantic)
1237 if (!semantic)
1239 TRACE("Returning parameter %p\n", param->member_handles[i]);
1240 return param->member_handles[i];
1242 continue;
1245 if (!strcasecmp(temp_param->semantic, semantic))
1247 TRACE("Returning parameter %p\n", param->member_handles[i]);
1248 return param->member_handles[i];
1253 WARN("Invalid argument specified\n");
1255 return NULL;
1258 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1260 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1261 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1263 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1265 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1267 if (!param)
1269 if (index < This->parameter_count)
1271 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1272 return This->parameter_handles[index];
1275 else
1277 if (index < param->element_count)
1279 TRACE("Returning parameter %p\n", param->member_handles[index]);
1280 return param->member_handles[index];
1284 WARN("Invalid argument specified\n");
1286 return NULL;
1289 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1291 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1293 TRACE("iface %p, index %u\n", This, index);
1295 if (index >= This->technique_count)
1297 WARN("Invalid argument specified.\n");
1298 return NULL;
1301 TRACE("Returning technique %p\n", This->technique_handles[index]);
1303 return This->technique_handles[index];
1306 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1308 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1309 unsigned int i;
1311 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1313 if (!name)
1315 WARN("Invalid argument specified.\n");
1316 return NULL;
1319 for (i = 0; i < This->technique_count; ++i)
1321 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1323 if (!strcmp(tech->name, name))
1325 TRACE("Returning technique %p\n", This->technique_handles[i]);
1326 return This->technique_handles[i];
1330 WARN("Invalid argument specified.\n");
1332 return NULL;
1335 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1337 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1338 struct d3dx_technique *tech = is_valid_technique(This, technique);
1340 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1342 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1344 if (tech && index < tech->pass_count)
1346 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1347 return tech->pass_handles[index];
1350 WARN("Invalid argument specified.\n");
1352 return NULL;
1355 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1357 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1358 struct d3dx_technique *tech = is_valid_technique(This, technique);
1360 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1362 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1364 if (tech && name)
1366 unsigned int i;
1368 for (i = 0; i < tech->pass_count; ++i)
1370 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1372 if (!strcmp(pass->name, name))
1374 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1375 return tech->pass_handles[i];
1380 WARN("Invalid argument specified.\n");
1382 return NULL;
1385 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1387 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1389 FIXME("iface %p, index %u stub\n", This, index);
1391 return NULL;
1394 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1396 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1398 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1400 return NULL;
1403 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1405 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1406 struct d3dx_parameter *param = is_valid_parameter(This, object);
1407 struct d3dx_pass *pass = is_valid_pass(This, object);
1408 struct d3dx_technique *technique = is_valid_technique(This, object);
1409 UINT annotation_count = 0;
1410 D3DXHANDLE *annotation_handles = NULL;
1412 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1414 if (pass)
1416 annotation_count = pass->annotation_count;
1417 annotation_handles = pass->annotation_handles;
1419 else if (technique)
1421 annotation_count = technique->annotation_count;
1422 annotation_handles = technique->annotation_handles;
1424 else
1426 if (!param) param = get_parameter_by_name(This, NULL, object);
1428 if (param)
1430 annotation_count = param->annotation_count;
1431 annotation_handles = param->annotation_handles;
1434 /* Todo: add funcs */
1436 if (index < annotation_count)
1438 TRACE("Returning parameter %p\n", annotation_handles[index]);
1439 return annotation_handles[index];
1442 WARN("Invalid argument specified\n");
1444 return NULL;
1447 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1449 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1450 struct d3dx_parameter *param = is_valid_parameter(This, object);
1451 struct d3dx_pass *pass = is_valid_pass(This, object);
1452 struct d3dx_technique *technique = is_valid_technique(This, object);
1453 UINT annotation_count = 0, i;
1454 D3DXHANDLE *annotation_handles = NULL;
1456 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1458 if (!name)
1460 WARN("Invalid argument specified\n");
1461 return NULL;
1464 if (pass)
1466 annotation_count = pass->annotation_count;
1467 annotation_handles = pass->annotation_handles;
1469 else if (technique)
1471 annotation_count = technique->annotation_count;
1472 annotation_handles = technique->annotation_handles;
1474 else
1476 if (!param) param = get_parameter_by_name(This, NULL, object);
1478 if (param)
1480 annotation_count = param->annotation_count;
1481 annotation_handles = param->annotation_handles;
1484 /* Todo: add funcs */
1486 for (i = 0; i < annotation_count; i++)
1488 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1490 if (!strcmp(anno->name, name))
1492 TRACE("Returning parameter %p\n", anno);
1493 return get_parameter_handle(anno);
1497 WARN("Invalid argument specified\n");
1499 return NULL;
1502 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1504 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1506 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1508 return E_NOTIMPL;
1511 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1513 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1514 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1516 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1518 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1520 /* samplers don't touch data */
1521 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1522 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1523 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1525 TRACE("Sampler: returning E_FAIL\n");
1526 return E_FAIL;
1529 if (data && param && param->bytes <= bytes)
1531 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1533 switch (param->type)
1535 case D3DXPT_VOID:
1536 case D3DXPT_BOOL:
1537 case D3DXPT_INT:
1538 case D3DXPT_FLOAT:
1539 case D3DXPT_STRING:
1540 break;
1542 case D3DXPT_VERTEXSHADER:
1543 case D3DXPT_PIXELSHADER:
1544 case D3DXPT_TEXTURE:
1545 case D3DXPT_TEXTURE1D:
1546 case D3DXPT_TEXTURE2D:
1547 case D3DXPT_TEXTURE3D:
1548 case D3DXPT_TEXTURECUBE:
1550 UINT i;
1552 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1554 IUnknown *unk = ((IUnknown **)param->data)[i];
1555 if (unk) IUnknown_AddRef(unk);
1557 break;
1560 default:
1561 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1562 break;
1565 TRACE("Copy %u bytes\n", param->bytes);
1566 memcpy(data, param->data, param->bytes);
1567 return D3D_OK;
1570 WARN("Invalid argument specified\n");
1572 return D3DERR_INVALIDCALL;
1575 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1577 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1579 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1581 return E_NOTIMPL;
1584 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1586 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1587 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1589 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1591 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1593 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1595 *b = get_bool(param->data);
1596 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1597 return D3D_OK;
1600 WARN("Invalid argument specified\n");
1602 return D3DERR_INVALIDCALL;
1605 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1607 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1609 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1611 return E_NOTIMPL;
1614 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1616 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1618 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1620 return E_NOTIMPL;
1623 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1625 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1627 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1629 return E_NOTIMPL;
1632 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1634 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1635 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1637 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1639 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1641 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1643 *n = get_int(param->type, param->data);
1644 TRACE("Returning %i\n", *n);
1645 return D3D_OK;
1648 WARN("Invalid argument specified\n");
1650 return D3DERR_INVALIDCALL;
1653 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1655 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1657 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1659 return E_NOTIMPL;
1662 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1664 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1665 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1667 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1669 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1671 if (n && param && (param->class == D3DXPC_SCALAR
1672 || param->class == D3DXPC_VECTOR
1673 || param->class == D3DXPC_MATRIX_ROWS
1674 || param->class == D3DXPC_MATRIX_COLUMNS))
1676 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1678 for (i = 0; i < size; ++i)
1680 n[i] = get_int(param->type, (DWORD *)param->data + i);
1682 return D3D_OK;
1685 WARN("Invalid argument specified\n");
1687 return D3DERR_INVALIDCALL;
1690 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1692 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1694 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1696 return E_NOTIMPL;
1699 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1701 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1702 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1704 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1706 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1708 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1710 f = param->data;
1711 TRACE("Returning %f\n", *f);
1712 return D3D_OK;
1715 WARN("Invalid argument specified\n");
1717 return D3DERR_INVALIDCALL;
1720 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1722 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1724 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1726 return E_NOTIMPL;
1729 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1731 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1732 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1734 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1736 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1738 if (f && param && (param->class == D3DXPC_SCALAR
1739 || param->class == D3DXPC_VECTOR
1740 || param->class == D3DXPC_MATRIX_ROWS
1741 || param->class == D3DXPC_MATRIX_COLUMNS))
1743 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1745 for (i = 0; i < size; ++i)
1747 f[i] = get_float(param->type, (DWORD *)param->data + i);
1749 return D3D_OK;
1752 WARN("Invalid argument specified\n");
1754 return D3DERR_INVALIDCALL;
1757 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1759 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1761 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1763 return E_NOTIMPL;
1766 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1768 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1770 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1772 return E_NOTIMPL;
1775 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1777 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1779 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1781 return E_NOTIMPL;
1784 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1786 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1788 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1790 return E_NOTIMPL;
1793 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1795 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1797 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1799 return E_NOTIMPL;
1802 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1804 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1806 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1808 return E_NOTIMPL;
1811 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1813 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1815 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1817 return E_NOTIMPL;
1820 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1822 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1824 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1826 return E_NOTIMPL;
1829 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1831 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1833 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1835 return E_NOTIMPL;
1838 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1840 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1842 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1844 return E_NOTIMPL;
1847 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1849 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1851 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1853 return E_NOTIMPL;
1856 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1858 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1860 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1862 return E_NOTIMPL;
1865 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1867 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1869 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1871 return E_NOTIMPL;
1874 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1876 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1878 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1880 return E_NOTIMPL;
1883 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1885 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1887 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1889 return E_NOTIMPL;
1892 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1894 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1896 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1898 return E_NOTIMPL;
1901 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1903 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1905 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1907 return E_NOTIMPL;
1910 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1912 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1913 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1915 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1917 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1919 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1921 *string = *(LPCSTR *)param->data;
1922 TRACE("Returning %s\n", debugstr_a(*string));
1923 return D3D_OK;
1926 WARN("Invalid argument specified\n");
1928 return D3DERR_INVALIDCALL;
1931 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1933 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1935 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1937 return E_NOTIMPL;
1940 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
1942 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1943 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1945 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
1947 if (texture && param && !param->element_count &&
1948 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
1949 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
1950 || param->type == D3DXPT_TEXTURECUBE))
1952 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
1953 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
1954 TRACE("Returning %p\n", *texture);
1955 return D3D_OK;
1958 WARN("Invalid argument specified\n");
1960 return D3DERR_INVALIDCALL;
1963 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
1965 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1966 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1968 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
1970 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1972 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
1974 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
1975 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
1976 TRACE("Returning %p\n", *pshader);
1977 return D3D_OK;
1980 WARN("Invalid argument specified\n");
1982 return D3DERR_INVALIDCALL;
1985 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
1987 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1988 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1990 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
1992 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1994 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
1996 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
1997 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
1998 TRACE("Returning %p\n", *vshader);
1999 return D3D_OK;
2002 WARN("Invalid argument specified\n");
2004 return D3DERR_INVALIDCALL;
2007 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2009 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2011 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2013 return E_NOTIMPL;
2016 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2018 /*** IUnknown methods ***/
2019 ID3DXBaseEffectImpl_QueryInterface,
2020 ID3DXBaseEffectImpl_AddRef,
2021 ID3DXBaseEffectImpl_Release,
2022 /*** ID3DXBaseEffect methods ***/
2023 ID3DXBaseEffectImpl_GetDesc,
2024 ID3DXBaseEffectImpl_GetParameterDesc,
2025 ID3DXBaseEffectImpl_GetTechniqueDesc,
2026 ID3DXBaseEffectImpl_GetPassDesc,
2027 ID3DXBaseEffectImpl_GetFunctionDesc,
2028 ID3DXBaseEffectImpl_GetParameter,
2029 ID3DXBaseEffectImpl_GetParameterByName,
2030 ID3DXBaseEffectImpl_GetParameterBySemantic,
2031 ID3DXBaseEffectImpl_GetParameterElement,
2032 ID3DXBaseEffectImpl_GetTechnique,
2033 ID3DXBaseEffectImpl_GetTechniqueByName,
2034 ID3DXBaseEffectImpl_GetPass,
2035 ID3DXBaseEffectImpl_GetPassByName,
2036 ID3DXBaseEffectImpl_GetFunction,
2037 ID3DXBaseEffectImpl_GetFunctionByName,
2038 ID3DXBaseEffectImpl_GetAnnotation,
2039 ID3DXBaseEffectImpl_GetAnnotationByName,
2040 ID3DXBaseEffectImpl_SetValue,
2041 ID3DXBaseEffectImpl_GetValue,
2042 ID3DXBaseEffectImpl_SetBool,
2043 ID3DXBaseEffectImpl_GetBool,
2044 ID3DXBaseEffectImpl_SetBoolArray,
2045 ID3DXBaseEffectImpl_GetBoolArray,
2046 ID3DXBaseEffectImpl_SetInt,
2047 ID3DXBaseEffectImpl_GetInt,
2048 ID3DXBaseEffectImpl_SetIntArray,
2049 ID3DXBaseEffectImpl_GetIntArray,
2050 ID3DXBaseEffectImpl_SetFloat,
2051 ID3DXBaseEffectImpl_GetFloat,
2052 ID3DXBaseEffectImpl_SetFloatArray,
2053 ID3DXBaseEffectImpl_GetFloatArray,
2054 ID3DXBaseEffectImpl_SetVector,
2055 ID3DXBaseEffectImpl_GetVector,
2056 ID3DXBaseEffectImpl_SetVectorArray,
2057 ID3DXBaseEffectImpl_GetVectorArray,
2058 ID3DXBaseEffectImpl_SetMatrix,
2059 ID3DXBaseEffectImpl_GetMatrix,
2060 ID3DXBaseEffectImpl_SetMatrixArray,
2061 ID3DXBaseEffectImpl_GetMatrixArray,
2062 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2063 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2064 ID3DXBaseEffectImpl_SetMatrixTranspose,
2065 ID3DXBaseEffectImpl_GetMatrixTranspose,
2066 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2067 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2068 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2069 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2070 ID3DXBaseEffectImpl_SetString,
2071 ID3DXBaseEffectImpl_GetString,
2072 ID3DXBaseEffectImpl_SetTexture,
2073 ID3DXBaseEffectImpl_GetTexture,
2074 ID3DXBaseEffectImpl_GetPixelShader,
2075 ID3DXBaseEffectImpl_GetVertexShader,
2076 ID3DXBaseEffectImpl_SetArrayRange,
2079 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2081 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2084 /*** IUnknown methods ***/
2085 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2087 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2089 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2091 if (IsEqualGUID(riid, &IID_IUnknown) ||
2092 IsEqualGUID(riid, &IID_ID3DXEffect))
2094 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2095 *object = This;
2096 return S_OK;
2099 ERR("Interface %s not found\n", debugstr_guid(riid));
2101 return E_NOINTERFACE;
2104 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2106 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2108 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2110 return InterlockedIncrement(&This->ref);
2113 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2115 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2116 ULONG ref = InterlockedDecrement(&This->ref);
2118 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2120 if (!ref)
2122 free_effect(This);
2123 HeapFree(GetProcessHeap(), 0, This);
2126 return ref;
2129 /*** ID3DXBaseEffect methods ***/
2130 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2132 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2133 ID3DXBaseEffect *base = This->base_effect;
2135 TRACE("Forward iface %p, base %p\n", This, base);
2137 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2140 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2142 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2143 ID3DXBaseEffect *base = This->base_effect;
2145 TRACE("Forward iface %p, base %p\n", This, base);
2147 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2150 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2152 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2153 ID3DXBaseEffect *base = This->base_effect;
2155 TRACE("Forward iface %p, base %p\n", This, base);
2157 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2160 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2162 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2163 ID3DXBaseEffect *base = This->base_effect;
2165 TRACE("Forward iface %p, base %p\n", This, base);
2167 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2170 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2172 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2173 ID3DXBaseEffect *base = This->base_effect;
2175 TRACE("Forward iface %p, base %p\n", This, base);
2177 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2180 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2182 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2183 ID3DXBaseEffect *base = This->base_effect;
2185 TRACE("Forward iface %p, base %p\n", This, base);
2187 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2190 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2192 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2193 ID3DXBaseEffect *base = This->base_effect;
2195 TRACE("Forward iface %p, base %p\n", This, base);
2197 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2200 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2202 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2203 ID3DXBaseEffect *base = This->base_effect;
2205 TRACE("Forward iface %p, base %p\n", This, base);
2207 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2210 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2212 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2213 ID3DXBaseEffect *base = This->base_effect;
2215 TRACE("Forward iface %p, base %p\n", This, base);
2217 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2220 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2222 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2223 ID3DXBaseEffect *base = This->base_effect;
2225 TRACE("Forward iface %p, base %p\n", This, base);
2227 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2230 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2232 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2233 ID3DXBaseEffect *base = This->base_effect;
2235 TRACE("Forward iface %p, base %p\n", This, base);
2237 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2240 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2242 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2243 ID3DXBaseEffect *base = This->base_effect;
2245 TRACE("Forward iface %p, base %p\n", This, base);
2247 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2250 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2252 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2253 ID3DXBaseEffect *base = This->base_effect;
2255 TRACE("Forward iface %p, base %p\n", This, base);
2257 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2260 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2262 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2263 ID3DXBaseEffect *base = This->base_effect;
2265 TRACE("Forward iface %p, base %p\n", This, base);
2267 return ID3DXBaseEffectImpl_GetFunction(base, index);
2270 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2272 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2273 ID3DXBaseEffect *base = This->base_effect;
2275 TRACE("Forward iface %p, base %p\n", This, base);
2277 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2280 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2282 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2283 ID3DXBaseEffect *base = This->base_effect;
2285 TRACE("Forward iface %p, base %p\n", This, base);
2287 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2290 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2292 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2293 ID3DXBaseEffect *base = This->base_effect;
2295 TRACE("Forward iface %p, base %p\n", This, base);
2297 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2300 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2302 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2303 ID3DXBaseEffect *base = This->base_effect;
2305 TRACE("Forward iface %p, base %p\n", This, base);
2307 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2310 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2312 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2313 ID3DXBaseEffect *base = This->base_effect;
2315 TRACE("Forward iface %p, base %p\n", This, base);
2317 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2320 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2322 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2323 ID3DXBaseEffect *base = This->base_effect;
2325 TRACE("Forward iface %p, base %p\n", This, base);
2327 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2330 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2332 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2333 ID3DXBaseEffect *base = This->base_effect;
2335 TRACE("Forward iface %p, base %p\n", This, base);
2337 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2340 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2342 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2343 ID3DXBaseEffect *base = This->base_effect;
2345 TRACE("Forward iface %p, base %p\n", This, base);
2347 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2350 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2352 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2353 ID3DXBaseEffect *base = This->base_effect;
2355 TRACE("Forward iface %p, base %p\n", This, base);
2357 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2360 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2362 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2363 ID3DXBaseEffect *base = This->base_effect;
2365 TRACE("Forward iface %p, base %p\n", This, base);
2367 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2370 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2372 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2373 ID3DXBaseEffect *base = This->base_effect;
2375 TRACE("Forward iface %p, base %p\n", This, base);
2377 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2380 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2382 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2383 ID3DXBaseEffect *base = This->base_effect;
2385 TRACE("Forward iface %p, base %p\n", This, base);
2387 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2390 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2392 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2393 ID3DXBaseEffect *base = This->base_effect;
2395 TRACE("Forward iface %p, base %p\n", This, base);
2397 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2400 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2402 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2403 ID3DXBaseEffect *base = This->base_effect;
2405 TRACE("Forward iface %p, base %p\n", This, base);
2407 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2410 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2412 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2413 ID3DXBaseEffect *base = This->base_effect;
2415 TRACE("Forward iface %p, base %p\n", This, base);
2417 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2420 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2422 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2423 ID3DXBaseEffect *base = This->base_effect;
2425 TRACE("Forward iface %p, base %p\n", This, base);
2427 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2430 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2432 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2433 ID3DXBaseEffect *base = This->base_effect;
2435 TRACE("Forward iface %p, base %p\n", This, base);
2437 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2440 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2442 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2443 ID3DXBaseEffect *base = This->base_effect;
2445 TRACE("Forward iface %p, base %p\n", This, base);
2447 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2450 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2452 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2453 ID3DXBaseEffect *base = This->base_effect;
2455 TRACE("Forward iface %p, base %p\n", This, base);
2457 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2460 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2462 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2463 ID3DXBaseEffect *base = This->base_effect;
2465 TRACE("Forward iface %p, base %p\n", This, base);
2467 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2470 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2472 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2473 ID3DXBaseEffect *base = This->base_effect;
2475 TRACE("Forward iface %p, base %p\n", This, base);
2477 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2480 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2482 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2483 ID3DXBaseEffect *base = This->base_effect;
2485 TRACE("Forward iface %p, base %p\n", This, base);
2487 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2490 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2492 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2493 ID3DXBaseEffect *base = This->base_effect;
2495 TRACE("Forward iface %p, base %p\n", This, base);
2497 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2500 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2502 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2503 ID3DXBaseEffect *base = This->base_effect;
2505 TRACE("Forward iface %p, base %p\n", This, base);
2507 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2510 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2512 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2513 ID3DXBaseEffect *base = This->base_effect;
2515 TRACE("Forward iface %p, base %p\n", This, base);
2517 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2520 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2522 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2523 ID3DXBaseEffect *base = This->base_effect;
2525 TRACE("Forward iface %p, base %p\n", This, base);
2527 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2530 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2532 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2533 ID3DXBaseEffect *base = This->base_effect;
2535 TRACE("Forward iface %p, base %p\n", This, base);
2537 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2540 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2542 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2543 ID3DXBaseEffect *base = This->base_effect;
2545 TRACE("Forward iface %p, base %p\n", This, base);
2547 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2550 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2552 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2553 ID3DXBaseEffect *base = This->base_effect;
2555 TRACE("Forward iface %p, base %p\n", This, base);
2557 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2560 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2562 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2563 ID3DXBaseEffect *base = This->base_effect;
2565 TRACE("Forward iface %p, base %p\n", This, base);
2567 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2570 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2572 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2573 ID3DXBaseEffect *base = This->base_effect;
2575 TRACE("Forward iface %p, base %p\n", This, base);
2577 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2580 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2582 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2583 ID3DXBaseEffect *base = This->base_effect;
2585 TRACE("Forward iface %p, base %p\n", This, base);
2587 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2590 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2592 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2593 ID3DXBaseEffect *base = This->base_effect;
2595 TRACE("Forward iface %p, base %p\n", This, base);
2597 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2600 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2602 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2603 ID3DXBaseEffect *base = This->base_effect;
2605 TRACE("Forward iface %p, base %p\n", This, base);
2607 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2610 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2612 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2613 ID3DXBaseEffect *base = This->base_effect;
2615 TRACE("Forward iface %p, base %p\n", This, base);
2617 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2620 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2622 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2623 ID3DXBaseEffect *base = This->base_effect;
2625 TRACE("Forward iface %p, base %p\n", This, base);
2627 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2630 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2632 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2633 ID3DXBaseEffect *base = This->base_effect;
2635 TRACE("Forward iface %p, base %p\n", This, base);
2637 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2640 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2642 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2643 ID3DXBaseEffect *base = This->base_effect;
2645 TRACE("Forward iface %p, base %p\n", This, base);
2647 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2650 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2652 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2653 ID3DXBaseEffect *base = This->base_effect;
2655 TRACE("Forward iface %p, base %p\n", This, base);
2657 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2660 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2662 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2663 ID3DXBaseEffect *base = This->base_effect;
2665 TRACE("Forward iface %p, base %p\n", This, base);
2667 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2670 /*** ID3DXEffect methods ***/
2671 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2673 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2675 TRACE("iface %p, pool %p\n", This, pool);
2677 if (!pool)
2679 WARN("Invalid argument supplied.\n");
2680 return D3DERR_INVALIDCALL;
2683 if (This->pool)
2685 This->pool->lpVtbl->AddRef(This->pool);
2688 *pool = This->pool;
2690 TRACE("Returning pool %p\n", *pool);
2692 return S_OK;
2695 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2697 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2699 FIXME("(%p)->(%p): stub\n", This, technique);
2701 return E_NOTIMPL;
2704 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
2706 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2708 FIXME("(%p)->(): stub\n", This);
2710 return NULL;
2713 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2715 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2717 FIXME("(%p)->(%p): stub\n", This, technique);
2719 return D3D_OK;
2722 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2724 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2726 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2728 return E_NOTIMPL;
2731 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2733 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2735 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2737 return FALSE;
2740 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect* iface, UINT *passes, DWORD flags)
2742 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2744 FIXME("(%p)->(%p, %#x): stub\n", This, passes, flags);
2746 return E_NOTIMPL;
2749 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
2751 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2753 FIXME("(%p)->(%u): stub\n", This, pass);
2755 return E_NOTIMPL;
2758 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2760 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2762 FIXME("(%p)->(): stub\n", This);
2764 return E_NOTIMPL;
2767 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
2769 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2771 FIXME("(%p)->(): stub\n", This);
2773 return E_NOTIMPL;
2776 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2778 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2780 FIXME("(%p)->(): stub\n", This);
2782 return E_NOTIMPL;
2785 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2787 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2789 TRACE("iface %p, device %p\n", This, device);
2791 if (!device)
2793 WARN("Invalid argument supplied.\n");
2794 return D3DERR_INVALIDCALL;
2797 IDirect3DDevice9_AddRef(This->device);
2799 *device = This->device;
2801 TRACE("Returning device %p\n", *device);
2803 return S_OK;
2806 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2808 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2810 FIXME("(%p)->(): stub\n", This);
2812 return E_NOTIMPL;
2815 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2817 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2819 FIXME("(%p)->(): stub\n", This);
2821 return E_NOTIMPL;
2824 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2826 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2828 TRACE("iface %p, manager %p\n", This, manager);
2830 if (This->manager) IUnknown_Release(This->manager);
2831 if (manager) IUnknown_AddRef(manager);
2833 This->manager = manager;
2835 return D3D_OK;
2838 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2840 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2842 TRACE("iface %p, manager %p\n", This, manager);
2844 if (!manager)
2846 WARN("Invalid argument supplied.\n");
2847 return D3DERR_INVALIDCALL;
2850 if (This->manager) IUnknown_AddRef(This->manager);
2851 *manager = This->manager;
2853 return D3D_OK;
2856 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2858 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2860 FIXME("(%p)->(): stub\n", This);
2862 return E_NOTIMPL;
2865 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2867 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2869 FIXME("(%p)->(): stub\n", This);
2871 return NULL;
2874 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2876 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2878 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2880 return E_NOTIMPL;
2883 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2885 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2887 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2889 return E_NOTIMPL;
2892 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
2894 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2896 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
2898 return E_NOTIMPL;
2901 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
2903 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2905 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
2907 return E_NOTIMPL;
2910 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
2912 /*** IUnknown methods ***/
2913 ID3DXEffectImpl_QueryInterface,
2914 ID3DXEffectImpl_AddRef,
2915 ID3DXEffectImpl_Release,
2916 /*** ID3DXBaseEffect methods ***/
2917 ID3DXEffectImpl_GetDesc,
2918 ID3DXEffectImpl_GetParameterDesc,
2919 ID3DXEffectImpl_GetTechniqueDesc,
2920 ID3DXEffectImpl_GetPassDesc,
2921 ID3DXEffectImpl_GetFunctionDesc,
2922 ID3DXEffectImpl_GetParameter,
2923 ID3DXEffectImpl_GetParameterByName,
2924 ID3DXEffectImpl_GetParameterBySemantic,
2925 ID3DXEffectImpl_GetParameterElement,
2926 ID3DXEffectImpl_GetTechnique,
2927 ID3DXEffectImpl_GetTechniqueByName,
2928 ID3DXEffectImpl_GetPass,
2929 ID3DXEffectImpl_GetPassByName,
2930 ID3DXEffectImpl_GetFunction,
2931 ID3DXEffectImpl_GetFunctionByName,
2932 ID3DXEffectImpl_GetAnnotation,
2933 ID3DXEffectImpl_GetAnnotationByName,
2934 ID3DXEffectImpl_SetValue,
2935 ID3DXEffectImpl_GetValue,
2936 ID3DXEffectImpl_SetBool,
2937 ID3DXEffectImpl_GetBool,
2938 ID3DXEffectImpl_SetBoolArray,
2939 ID3DXEffectImpl_GetBoolArray,
2940 ID3DXEffectImpl_SetInt,
2941 ID3DXEffectImpl_GetInt,
2942 ID3DXEffectImpl_SetIntArray,
2943 ID3DXEffectImpl_GetIntArray,
2944 ID3DXEffectImpl_SetFloat,
2945 ID3DXEffectImpl_GetFloat,
2946 ID3DXEffectImpl_SetFloatArray,
2947 ID3DXEffectImpl_GetFloatArray,
2948 ID3DXEffectImpl_SetVector,
2949 ID3DXEffectImpl_GetVector,
2950 ID3DXEffectImpl_SetVectorArray,
2951 ID3DXEffectImpl_GetVectorArray,
2952 ID3DXEffectImpl_SetMatrix,
2953 ID3DXEffectImpl_GetMatrix,
2954 ID3DXEffectImpl_SetMatrixArray,
2955 ID3DXEffectImpl_GetMatrixArray,
2956 ID3DXEffectImpl_SetMatrixPointerArray,
2957 ID3DXEffectImpl_GetMatrixPointerArray,
2958 ID3DXEffectImpl_SetMatrixTranspose,
2959 ID3DXEffectImpl_GetMatrixTranspose,
2960 ID3DXEffectImpl_SetMatrixTransposeArray,
2961 ID3DXEffectImpl_GetMatrixTransposeArray,
2962 ID3DXEffectImpl_SetMatrixTransposePointerArray,
2963 ID3DXEffectImpl_GetMatrixTransposePointerArray,
2964 ID3DXEffectImpl_SetString,
2965 ID3DXEffectImpl_GetString,
2966 ID3DXEffectImpl_SetTexture,
2967 ID3DXEffectImpl_GetTexture,
2968 ID3DXEffectImpl_GetPixelShader,
2969 ID3DXEffectImpl_GetVertexShader,
2970 ID3DXEffectImpl_SetArrayRange,
2971 /*** ID3DXEffect methods ***/
2972 ID3DXEffectImpl_GetPool,
2973 ID3DXEffectImpl_SetTechnique,
2974 ID3DXEffectImpl_GetCurrentTechnique,
2975 ID3DXEffectImpl_ValidateTechnique,
2976 ID3DXEffectImpl_FindNextValidTechnique,
2977 ID3DXEffectImpl_IsParameterUsed,
2978 ID3DXEffectImpl_Begin,
2979 ID3DXEffectImpl_BeginPass,
2980 ID3DXEffectImpl_CommitChanges,
2981 ID3DXEffectImpl_EndPass,
2982 ID3DXEffectImpl_End,
2983 ID3DXEffectImpl_GetDevice,
2984 ID3DXEffectImpl_OnLostDevice,
2985 ID3DXEffectImpl_OnResetDevice,
2986 ID3DXEffectImpl_SetStateManager,
2987 ID3DXEffectImpl_GetStateManager,
2988 ID3DXEffectImpl_BeginParameterBlock,
2989 ID3DXEffectImpl_EndParameterBlock,
2990 ID3DXEffectImpl_ApplyParameterBlock,
2991 ID3DXEffectImpl_DeleteParameterBlock,
2992 ID3DXEffectImpl_CloneEffect,
2993 ID3DXEffectImpl_SetRawValue
2996 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
2998 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3001 /*** IUnknown methods ***/
3002 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3004 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3006 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3008 if (IsEqualGUID(riid, &IID_IUnknown) ||
3009 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3011 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3012 *object = This;
3013 return S_OK;
3016 ERR("Interface %s not found\n", debugstr_guid(riid));
3018 return E_NOINTERFACE;
3021 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3023 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3025 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3027 return InterlockedIncrement(&This->ref);
3030 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3032 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3033 ULONG ref = InterlockedDecrement(&This->ref);
3035 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3037 if (!ref)
3039 free_effect_compiler(This);
3040 HeapFree(GetProcessHeap(), 0, This);
3043 return ref;
3046 /*** ID3DXBaseEffect methods ***/
3047 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3049 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3050 ID3DXBaseEffect *base = This->base_effect;
3052 TRACE("Forward iface %p, base %p\n", This, base);
3054 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3057 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3059 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3060 ID3DXBaseEffect *base = This->base_effect;
3062 TRACE("Forward iface %p, base %p\n", This, base);
3064 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3067 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3069 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3070 ID3DXBaseEffect *base = This->base_effect;
3072 TRACE("Forward iface %p, base %p\n", This, base);
3074 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3077 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3079 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3080 ID3DXBaseEffect *base = This->base_effect;
3082 TRACE("Forward iface %p, base %p\n", This, base);
3084 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3087 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3089 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3090 ID3DXBaseEffect *base = This->base_effect;
3092 TRACE("Forward iface %p, base %p\n", This, base);
3094 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3097 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3099 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3100 ID3DXBaseEffect *base = This->base_effect;
3102 TRACE("Forward iface %p, base %p\n", This, base);
3104 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3107 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3109 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3110 ID3DXBaseEffect *base = This->base_effect;
3112 TRACE("Forward iface %p, base %p\n", This, base);
3114 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3117 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3119 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3120 ID3DXBaseEffect *base = This->base_effect;
3122 TRACE("Forward iface %p, base %p\n", This, base);
3124 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3127 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3129 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3130 ID3DXBaseEffect *base = This->base_effect;
3132 TRACE("Forward iface %p, base %p\n", This, base);
3134 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3137 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3139 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3140 ID3DXBaseEffect *base = This->base_effect;
3142 TRACE("Forward iface %p, base %p\n", This, base);
3144 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3147 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3149 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3150 ID3DXBaseEffect *base = This->base_effect;
3152 TRACE("Forward iface %p, base %p\n", This, base);
3154 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3157 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3159 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3160 ID3DXBaseEffect *base = This->base_effect;
3162 TRACE("Forward iface %p, base %p\n", This, base);
3164 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3167 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3169 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3170 ID3DXBaseEffect *base = This->base_effect;
3172 TRACE("Forward iface %p, base %p\n", This, base);
3174 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3177 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3179 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3180 ID3DXBaseEffect *base = This->base_effect;
3182 TRACE("Forward iface %p, base %p\n", This, base);
3184 return ID3DXBaseEffectImpl_GetFunction(base, index);
3187 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3189 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3190 ID3DXBaseEffect *base = This->base_effect;
3192 TRACE("Forward iface %p, base %p\n", This, base);
3194 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3197 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3199 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3200 ID3DXBaseEffect *base = This->base_effect;
3202 TRACE("Forward iface %p, base %p\n", This, base);
3204 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3207 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3209 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3210 ID3DXBaseEffect *base = This->base_effect;
3212 TRACE("Forward iface %p, base %p\n", This, base);
3214 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3217 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3219 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3220 ID3DXBaseEffect *base = This->base_effect;
3222 TRACE("Forward iface %p, base %p\n", This, base);
3224 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3227 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3229 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3230 ID3DXBaseEffect *base = This->base_effect;
3232 TRACE("Forward iface %p, base %p\n", This, base);
3234 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3237 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3239 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3240 ID3DXBaseEffect *base = This->base_effect;
3242 TRACE("Forward iface %p, base %p\n", This, base);
3244 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3247 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3249 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3250 ID3DXBaseEffect *base = This->base_effect;
3252 TRACE("Forward iface %p, base %p\n", This, base);
3254 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3257 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3259 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3260 ID3DXBaseEffect *base = This->base_effect;
3262 TRACE("Forward iface %p, base %p\n", This, base);
3264 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3267 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3269 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3270 ID3DXBaseEffect *base = This->base_effect;
3272 TRACE("Forward iface %p, base %p\n", This, base);
3274 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3277 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3279 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3280 ID3DXBaseEffect *base = This->base_effect;
3282 TRACE("Forward iface %p, base %p\n", This, base);
3284 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3287 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3289 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3290 ID3DXBaseEffect *base = This->base_effect;
3292 TRACE("Forward iface %p, base %p\n", This, base);
3294 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3297 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3299 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3300 ID3DXBaseEffect *base = This->base_effect;
3302 TRACE("Forward iface %p, base %p\n", This, base);
3304 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3307 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3309 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3310 ID3DXBaseEffect *base = This->base_effect;
3312 TRACE("Forward iface %p, base %p\n", This, base);
3314 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3317 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3319 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3320 ID3DXBaseEffect *base = This->base_effect;
3322 TRACE("Forward iface %p, base %p\n", This, base);
3324 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3327 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3329 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3330 ID3DXBaseEffect *base = This->base_effect;
3332 TRACE("Forward iface %p, base %p\n", This, base);
3334 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3337 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3339 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3340 ID3DXBaseEffect *base = This->base_effect;
3342 TRACE("Forward iface %p, base %p\n", This, base);
3344 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3347 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3349 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3350 ID3DXBaseEffect *base = This->base_effect;
3352 TRACE("Forward iface %p, base %p\n", This, base);
3354 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3357 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3359 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3360 ID3DXBaseEffect *base = This->base_effect;
3362 TRACE("Forward iface %p, base %p\n", This, base);
3364 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3367 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3369 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3370 ID3DXBaseEffect *base = This->base_effect;
3372 TRACE("Forward iface %p, base %p\n", This, base);
3374 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3377 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3379 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3380 ID3DXBaseEffect *base = This->base_effect;
3382 TRACE("Forward iface %p, base %p\n", This, base);
3384 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3387 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3389 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3390 ID3DXBaseEffect *base = This->base_effect;
3392 TRACE("Forward iface %p, base %p\n", This, base);
3394 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3397 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3399 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3400 ID3DXBaseEffect *base = This->base_effect;
3402 TRACE("Forward iface %p, base %p\n", This, base);
3404 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3407 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3409 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3410 ID3DXBaseEffect *base = This->base_effect;
3412 TRACE("Forward iface %p, base %p\n", This, base);
3414 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3417 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3419 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3420 ID3DXBaseEffect *base = This->base_effect;
3422 TRACE("Forward iface %p, base %p\n", This, base);
3424 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3427 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3429 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3430 ID3DXBaseEffect *base = This->base_effect;
3432 TRACE("Forward iface %p, base %p\n", This, base);
3434 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3437 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3439 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3440 ID3DXBaseEffect *base = This->base_effect;
3442 TRACE("Forward iface %p, base %p\n", This, base);
3444 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3447 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3449 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3450 ID3DXBaseEffect *base = This->base_effect;
3452 TRACE("Forward iface %p, base %p\n", This, base);
3454 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3457 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3459 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3460 ID3DXBaseEffect *base = This->base_effect;
3462 TRACE("Forward iface %p, base %p\n", This, base);
3464 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3467 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3469 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3470 ID3DXBaseEffect *base = This->base_effect;
3472 TRACE("Forward iface %p, base %p\n", This, base);
3474 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3477 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3479 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3480 ID3DXBaseEffect *base = This->base_effect;
3482 TRACE("Forward iface %p, base %p\n", This, base);
3484 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3487 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3489 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3490 ID3DXBaseEffect *base = This->base_effect;
3492 TRACE("Forward iface %p, base %p\n", This, base);
3494 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3497 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3499 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3500 ID3DXBaseEffect *base = This->base_effect;
3502 TRACE("Forward iface %p, base %p\n", This, base);
3504 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3507 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3509 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3510 ID3DXBaseEffect *base = This->base_effect;
3512 TRACE("Forward iface %p, base %p\n", This, base);
3514 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3517 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3519 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3520 ID3DXBaseEffect *base = This->base_effect;
3522 TRACE("Forward iface %p, base %p\n", This, base);
3524 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3527 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3529 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3530 ID3DXBaseEffect *base = This->base_effect;
3532 TRACE("Forward iface %p, base %p\n", This, base);
3534 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3537 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3539 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3540 ID3DXBaseEffect *base = This->base_effect;
3542 TRACE("Forward iface %p, base %p\n", This, base);
3544 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3547 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3549 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3550 ID3DXBaseEffect *base = This->base_effect;
3552 TRACE("Forward iface %p, base %p\n", This, base);
3554 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3557 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3559 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3560 ID3DXBaseEffect *base = This->base_effect;
3562 TRACE("Forward iface %p, base %p\n", This, base);
3564 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3567 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3569 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3570 ID3DXBaseEffect *base = This->base_effect;
3572 TRACE("Forward iface %p, base %p\n", This, base);
3574 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3577 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3579 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3580 ID3DXBaseEffect *base = This->base_effect;
3582 TRACE("Forward iface %p, base %p\n", This, base);
3584 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3587 /*** ID3DXEffectCompiler methods ***/
3588 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3590 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3592 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3594 return E_NOTIMPL;
3597 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3599 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3601 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3603 return E_NOTIMPL;
3606 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3607 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3609 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3611 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3613 return E_NOTIMPL;
3616 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3617 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3619 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3621 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3622 This, function, target, flags, shader, error_msgs, constant_table);
3624 return E_NOTIMPL;
3627 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3629 /*** IUnknown methods ***/
3630 ID3DXEffectCompilerImpl_QueryInterface,
3631 ID3DXEffectCompilerImpl_AddRef,
3632 ID3DXEffectCompilerImpl_Release,
3633 /*** ID3DXBaseEffect methods ***/
3634 ID3DXEffectCompilerImpl_GetDesc,
3635 ID3DXEffectCompilerImpl_GetParameterDesc,
3636 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3637 ID3DXEffectCompilerImpl_GetPassDesc,
3638 ID3DXEffectCompilerImpl_GetFunctionDesc,
3639 ID3DXEffectCompilerImpl_GetParameter,
3640 ID3DXEffectCompilerImpl_GetParameterByName,
3641 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3642 ID3DXEffectCompilerImpl_GetParameterElement,
3643 ID3DXEffectCompilerImpl_GetTechnique,
3644 ID3DXEffectCompilerImpl_GetTechniqueByName,
3645 ID3DXEffectCompilerImpl_GetPass,
3646 ID3DXEffectCompilerImpl_GetPassByName,
3647 ID3DXEffectCompilerImpl_GetFunction,
3648 ID3DXEffectCompilerImpl_GetFunctionByName,
3649 ID3DXEffectCompilerImpl_GetAnnotation,
3650 ID3DXEffectCompilerImpl_GetAnnotationByName,
3651 ID3DXEffectCompilerImpl_SetValue,
3652 ID3DXEffectCompilerImpl_GetValue,
3653 ID3DXEffectCompilerImpl_SetBool,
3654 ID3DXEffectCompilerImpl_GetBool,
3655 ID3DXEffectCompilerImpl_SetBoolArray,
3656 ID3DXEffectCompilerImpl_GetBoolArray,
3657 ID3DXEffectCompilerImpl_SetInt,
3658 ID3DXEffectCompilerImpl_GetInt,
3659 ID3DXEffectCompilerImpl_SetIntArray,
3660 ID3DXEffectCompilerImpl_GetIntArray,
3661 ID3DXEffectCompilerImpl_SetFloat,
3662 ID3DXEffectCompilerImpl_GetFloat,
3663 ID3DXEffectCompilerImpl_SetFloatArray,
3664 ID3DXEffectCompilerImpl_GetFloatArray,
3665 ID3DXEffectCompilerImpl_SetVector,
3666 ID3DXEffectCompilerImpl_GetVector,
3667 ID3DXEffectCompilerImpl_SetVectorArray,
3668 ID3DXEffectCompilerImpl_GetVectorArray,
3669 ID3DXEffectCompilerImpl_SetMatrix,
3670 ID3DXEffectCompilerImpl_GetMatrix,
3671 ID3DXEffectCompilerImpl_SetMatrixArray,
3672 ID3DXEffectCompilerImpl_GetMatrixArray,
3673 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3674 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3675 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3676 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3677 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3678 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3679 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3680 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3681 ID3DXEffectCompilerImpl_SetString,
3682 ID3DXEffectCompilerImpl_GetString,
3683 ID3DXEffectCompilerImpl_SetTexture,
3684 ID3DXEffectCompilerImpl_GetTexture,
3685 ID3DXEffectCompilerImpl_GetPixelShader,
3686 ID3DXEffectCompilerImpl_GetVertexShader,
3687 ID3DXEffectCompilerImpl_SetArrayRange,
3688 /*** ID3DXEffectCompiler methods ***/
3689 ID3DXEffectCompilerImpl_SetLiteral,
3690 ID3DXEffectCompilerImpl_GetLiteral,
3691 ID3DXEffectCompilerImpl_CompileEffect,
3692 ID3DXEffectCompilerImpl_CompileShader,
3695 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
3697 HRESULT hr;
3698 UINT i;
3699 struct d3dx_state *states;
3701 read_dword(ptr, &sampler->state_count);
3702 TRACE("Count: %u\n", sampler->state_count);
3704 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
3705 if (!states)
3707 ERR("Out of memory\n");
3708 return E_OUTOFMEMORY;
3711 for (i = 0; i < sampler->state_count; ++i)
3713 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
3714 if (hr != D3D_OK)
3716 WARN("Failed to parse state\n");
3717 goto err_out;
3721 sampler->states = states;
3723 return D3D_OK;
3725 err_out:
3727 for (i = 0; i < sampler->state_count; ++i)
3729 free_state(&states[i]);
3732 HeapFree(GetProcessHeap(), 0, states);
3734 return hr;
3737 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
3739 unsigned int i;
3740 HRESULT hr;
3741 UINT old_size = 0;
3742 DWORD id;
3744 if (param->element_count)
3746 param->data = value;
3748 for (i = 0; i < param->element_count; ++i)
3750 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3752 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
3753 if (hr != D3D_OK)
3755 WARN("Failed to parse value\n");
3756 return hr;
3759 old_size += member->bytes;
3762 return D3D_OK;
3765 switch(param->class)
3767 case D3DXPC_SCALAR:
3768 case D3DXPC_VECTOR:
3769 case D3DXPC_MATRIX_ROWS:
3770 case D3DXPC_MATRIX_COLUMNS:
3771 param->data = value;
3772 break;
3774 case D3DXPC_STRUCT:
3775 param->data = value;
3777 for (i = 0; i < param->member_count; ++i)
3779 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3781 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
3782 if (hr != D3D_OK)
3784 WARN("Failed to parse value\n");
3785 return hr;
3788 old_size += member->bytes;
3790 break;
3792 case D3DXPC_OBJECT:
3793 switch (param->type)
3795 case D3DXPT_STRING:
3796 case D3DXPT_TEXTURE:
3797 case D3DXPT_TEXTURE1D:
3798 case D3DXPT_TEXTURE2D:
3799 case D3DXPT_TEXTURE3D:
3800 case D3DXPT_TEXTURECUBE:
3801 case D3DXPT_PIXELSHADER:
3802 case D3DXPT_VERTEXSHADER:
3803 read_dword(ptr, &id);
3804 TRACE("Id: %u\n", id);
3805 objects[id] = get_parameter_handle(param);
3806 param->data = value;
3807 break;
3809 case D3DXPT_SAMPLER:
3810 case D3DXPT_SAMPLER1D:
3811 case D3DXPT_SAMPLER2D:
3812 case D3DXPT_SAMPLER3D:
3813 case D3DXPT_SAMPLERCUBE:
3815 struct d3dx_sampler *sampler;
3817 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
3818 if (!sampler)
3820 ERR("Out of memory\n");
3821 return E_OUTOFMEMORY;
3824 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
3825 if (hr != D3D_OK)
3827 HeapFree(GetProcessHeap(), 0, sampler);
3828 WARN("Failed to parse sampler\n");
3829 return hr;
3832 param->data = sampler;
3833 break;
3836 default:
3837 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3838 break;
3840 break;
3842 default:
3843 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3844 break;
3847 return D3D_OK;
3850 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
3852 UINT size = param->bytes;
3853 HRESULT hr;
3854 void *value = NULL;
3856 TRACE("param size: %u\n", size);
3858 if (size)
3860 value = HeapAlloc(GetProcessHeap(), 0, size);
3861 if (!value)
3863 ERR("Failed to allocate data memory.\n");
3864 return E_OUTOFMEMORY;
3867 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3868 memcpy(value, ptr, size);
3871 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
3872 if (hr != D3D_OK)
3874 WARN("Failed to parse value\n");
3875 HeapFree(GetProcessHeap(), 0, value);
3876 return hr;
3879 return D3D_OK;
3882 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
3884 DWORD size;
3886 read_dword(&ptr, &size);
3887 TRACE("Name size: %#x\n", size);
3889 if (!size)
3891 return D3D_OK;
3894 *name = HeapAlloc(GetProcessHeap(), 0, size);
3895 if (!*name)
3897 ERR("Failed to allocate name memory.\n");
3898 return E_OUTOFMEMORY;
3901 TRACE("Name: %s.\n", debugstr_an(ptr, size));
3902 memcpy(*name, ptr, size);
3904 return D3D_OK;
3907 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
3909 DWORD size;
3910 HRESULT hr;
3912 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
3914 read_dword(ptr, &size);
3915 TRACE("Data size: %#x\n", size);
3917 if (!size)
3919 TRACE("Size is 0\n");
3920 *(void **)param->data = NULL;
3921 return D3D_OK;
3924 switch (param->type)
3926 case D3DXPT_STRING:
3927 /* re-read with size (sizeof(DWORD) = 4) */
3928 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
3929 if (hr != D3D_OK)
3931 WARN("Failed to parse string data\n");
3932 return hr;
3934 break;
3936 case D3DXPT_VERTEXSHADER:
3937 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
3938 if (hr != D3D_OK)
3940 WARN("Failed to create vertex shader\n");
3941 return hr;
3943 break;
3945 case D3DXPT_PIXELSHADER:
3946 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
3947 if (hr != D3D_OK)
3949 WARN("Failed to create pixel shader\n");
3950 return hr;
3952 break;
3954 default:
3955 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3956 break;
3960 *ptr += ((size + 3) & ~3);
3962 return D3D_OK;
3965 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
3966 struct d3dx_parameter *parent, UINT flags)
3968 DWORD offset;
3969 HRESULT hr;
3970 D3DXHANDLE *member_handles = NULL;
3971 UINT i;
3973 param->flags = flags;
3975 if (!parent)
3977 read_dword(ptr, &param->type);
3978 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
3980 read_dword(ptr, &param->class);
3981 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
3983 read_dword(ptr, &offset);
3984 TRACE("Type name offset: %#x\n", offset);
3985 hr = d3dx9_parse_name(&param->name, data + offset);
3986 if (hr != D3D_OK)
3988 WARN("Failed to parse name\n");
3989 goto err_out;
3992 read_dword(ptr, &offset);
3993 TRACE("Type semantic offset: %#x\n", offset);
3994 hr = d3dx9_parse_name(&param->semantic, data + offset);
3995 if (hr != D3D_OK)
3997 WARN("Failed to parse semantic\n");
3998 goto err_out;
4001 read_dword(ptr, &param->element_count);
4002 TRACE("Elements: %u\n", param->element_count);
4004 switch (param->class)
4006 case D3DXPC_VECTOR:
4007 read_dword(ptr, &param->columns);
4008 TRACE("Columns: %u\n", param->columns);
4010 read_dword(ptr, &param->rows);
4011 TRACE("Rows: %u\n", param->rows);
4013 /* sizeof(DWORD) * rows * columns */
4014 param->bytes = 4 * param->rows * param->columns;
4015 break;
4017 case D3DXPC_SCALAR:
4018 case D3DXPC_MATRIX_ROWS:
4019 case D3DXPC_MATRIX_COLUMNS:
4020 read_dword(ptr, &param->rows);
4021 TRACE("Rows: %u\n", param->rows);
4023 read_dword(ptr, &param->columns);
4024 TRACE("Columns: %u\n", param->columns);
4026 /* sizeof(DWORD) * rows * columns */
4027 param->bytes = 4 * param->rows * param->columns;
4028 break;
4030 case D3DXPC_STRUCT:
4031 read_dword(ptr, &param->member_count);
4032 TRACE("Members: %u\n", param->member_count);
4033 break;
4035 case D3DXPC_OBJECT:
4036 switch (param->type)
4038 case D3DXPT_STRING:
4039 param->bytes = sizeof(LPCSTR);
4040 break;
4042 case D3DXPT_PIXELSHADER:
4043 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4044 break;
4046 case D3DXPT_VERTEXSHADER:
4047 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4048 break;
4050 case D3DXPT_TEXTURE:
4051 case D3DXPT_TEXTURE1D:
4052 case D3DXPT_TEXTURE2D:
4053 case D3DXPT_TEXTURE3D:
4054 case D3DXPT_TEXTURECUBE:
4055 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4056 break;
4058 case D3DXPT_SAMPLER:
4059 case D3DXPT_SAMPLER1D:
4060 case D3DXPT_SAMPLER2D:
4061 case D3DXPT_SAMPLER3D:
4062 case D3DXPT_SAMPLERCUBE:
4063 param->bytes = 0;
4064 break;
4066 default:
4067 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4068 break;
4070 break;
4072 default:
4073 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4074 break;
4077 else
4079 /* elements */
4080 param->type = parent->type;
4081 param->class = parent->class;
4082 param->name = parent->name;
4083 param->semantic = parent->semantic;
4084 param->element_count = 0;
4085 param->annotation_count = 0;
4086 param->member_count = parent->member_count;
4087 param->bytes = parent->bytes;
4088 param->rows = parent->rows;
4089 param->columns = parent->columns;
4092 if (param->element_count)
4094 unsigned int param_bytes = 0;
4095 const char *save_ptr = *ptr;
4097 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4098 if (!member_handles)
4100 ERR("Out of memory\n");
4101 hr = E_OUTOFMEMORY;
4102 goto err_out;
4105 for (i = 0; i < param->element_count; ++i)
4107 struct d3dx_parameter *member;
4108 *ptr = save_ptr;
4110 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4111 if (!member)
4113 ERR("Out of memory\n");
4114 hr = E_OUTOFMEMORY;
4115 goto err_out;
4118 member_handles[i] = get_parameter_handle(member);
4120 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4121 if (hr != D3D_OK)
4123 WARN("Failed to parse member\n");
4124 goto err_out;
4127 param_bytes += member->bytes;
4130 param->bytes = param_bytes;
4132 else if (param->member_count)
4134 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4135 if (!member_handles)
4137 ERR("Out of memory\n");
4138 hr = E_OUTOFMEMORY;
4139 goto err_out;
4142 for (i = 0; i < param->member_count; ++i)
4144 struct d3dx_parameter *member;
4146 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4147 if (!member)
4149 ERR("Out of memory\n");
4150 hr = E_OUTOFMEMORY;
4151 goto err_out;
4154 member_handles[i] = get_parameter_handle(member);
4156 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4157 if (hr != D3D_OK)
4159 WARN("Failed to parse member\n");
4160 goto err_out;
4163 param->bytes += member->bytes;
4167 param->member_handles = member_handles;
4169 return D3D_OK;
4171 err_out:
4173 if (member_handles)
4175 unsigned int count;
4177 if (param->element_count) count = param->element_count;
4178 else count = param->member_count;
4180 for (i = 0; i < count; ++i)
4182 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4184 HeapFree(GetProcessHeap(), 0, member_handles);
4187 if (!parent)
4189 HeapFree(GetProcessHeap(), 0, param->name);
4190 HeapFree(GetProcessHeap(), 0, param->semantic);
4192 param->name = NULL;
4193 param->semantic = NULL;
4195 return hr;
4198 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4200 DWORD offset;
4201 const char *ptr2;
4202 HRESULT hr;
4204 anno->flags = D3DX_PARAMETER_ANNOTATION;
4206 read_dword(ptr, &offset);
4207 TRACE("Typedef offset: %#x\n", offset);
4208 ptr2 = data + offset;
4209 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4210 if (hr != D3D_OK)
4212 WARN("Failed to parse type definition\n");
4213 return hr;
4216 read_dword(ptr, &offset);
4217 TRACE("Value offset: %#x\n", offset);
4218 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4219 if (hr != D3D_OK)
4221 WARN("Failed to parse value\n");
4222 return hr;
4225 return D3D_OK;
4228 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4230 DWORD offset;
4231 const char *ptr2;
4232 HRESULT hr;
4233 struct d3dx_parameter *parameter;
4235 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4236 if (!parameter)
4238 ERR("Out of memory\n");
4239 return E_OUTOFMEMORY;
4242 read_dword(ptr, &state->operation);
4243 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4245 read_dword(ptr, &state->index);
4246 TRACE("Index: %#x\n", state->index);
4248 read_dword(ptr, &offset);
4249 TRACE("Typedef offset: %#x\n", offset);
4250 ptr2 = data + offset;
4251 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4252 if (hr != D3D_OK)
4254 WARN("Failed to parse type definition\n");
4255 goto err_out;
4258 read_dword(ptr, &offset);
4259 TRACE("Value offset: %#x\n", offset);
4260 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4261 if (hr != D3D_OK)
4263 WARN("Failed to parse value\n");
4264 goto err_out;
4267 state->parameter = get_parameter_handle(parameter);
4269 return D3D_OK;
4271 err_out:
4273 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4275 return hr;
4278 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4280 DWORD offset;
4281 HRESULT hr;
4282 unsigned int i;
4283 D3DXHANDLE *annotation_handles = NULL;
4284 const char *ptr2;
4286 read_dword(ptr, &offset);
4287 TRACE("Typedef offset: %#x\n", offset);
4288 ptr2 = data + offset;
4290 read_dword(ptr, &offset);
4291 TRACE("Value offset: %#x\n", offset);
4293 read_dword(ptr, &param->flags);
4294 TRACE("Flags: %#x\n", param->flags);
4296 read_dword(ptr, &param->annotation_count);
4297 TRACE("Annotation count: %u\n", param->annotation_count);
4299 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4300 if (hr != D3D_OK)
4302 WARN("Failed to parse type definition\n");
4303 return hr;
4306 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4307 if (hr != D3D_OK)
4309 WARN("Failed to parse value\n");
4310 return hr;
4313 if (param->annotation_count)
4315 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4316 if (!annotation_handles)
4318 ERR("Out of memory\n");
4319 hr = E_OUTOFMEMORY;
4320 goto err_out;
4323 for (i = 0; i < param->annotation_count; ++i)
4325 struct d3dx_parameter *annotation;
4327 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4328 if (!annotation)
4330 ERR("Out of memory\n");
4331 hr = E_OUTOFMEMORY;
4332 goto err_out;
4335 annotation_handles[i] = get_parameter_handle(annotation);
4337 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4338 if (hr != D3D_OK)
4340 WARN("Failed to parse annotation\n");
4341 goto err_out;
4346 param->annotation_handles = annotation_handles;
4348 return D3D_OK;
4350 err_out:
4352 if (annotation_handles)
4354 for (i = 0; i < param->annotation_count; ++i)
4356 free_parameter(annotation_handles[i], FALSE, FALSE);
4358 HeapFree(GetProcessHeap(), 0, annotation_handles);
4361 return hr;
4364 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4366 DWORD offset;
4367 HRESULT hr;
4368 unsigned int i;
4369 D3DXHANDLE *annotation_handles = NULL;
4370 struct d3dx_state *states = NULL;
4371 char *name = NULL;
4373 read_dword(ptr, &offset);
4374 TRACE("Pass name offset: %#x\n", offset);
4375 hr = d3dx9_parse_name(&name, data + offset);
4376 if (hr != D3D_OK)
4378 WARN("Failed to parse name\n");
4379 goto err_out;
4382 read_dword(ptr, &pass->annotation_count);
4383 TRACE("Annotation count: %u\n", pass->annotation_count);
4385 read_dword(ptr, &pass->state_count);
4386 TRACE("State count: %u\n", pass->state_count);
4388 if (pass->annotation_count)
4390 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4391 if (!annotation_handles)
4393 ERR("Out of memory\n");
4394 hr = E_OUTOFMEMORY;
4395 goto err_out;
4398 for (i = 0; i < pass->annotation_count; ++i)
4400 struct d3dx_parameter *annotation;
4402 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4403 if (!annotation)
4405 ERR("Out of memory\n");
4406 hr = E_OUTOFMEMORY;
4407 goto err_out;
4410 annotation_handles[i] = get_parameter_handle(annotation);
4412 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4413 if (hr != D3D_OK)
4415 WARN("Failed to parse annotations\n");
4416 goto err_out;
4421 if (pass->state_count)
4423 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4424 if (!states)
4426 ERR("Out of memory\n");
4427 hr = E_OUTOFMEMORY;
4428 goto err_out;
4431 for (i = 0; i < pass->state_count; ++i)
4433 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4434 if (hr != D3D_OK)
4436 WARN("Failed to parse annotations\n");
4437 goto err_out;
4442 pass->name = name;
4443 pass->annotation_handles = annotation_handles;
4444 pass->states = states;
4446 return D3D_OK;
4448 err_out:
4450 if (annotation_handles)
4452 for (i = 0; i < pass->annotation_count; ++i)
4454 free_parameter(annotation_handles[i], FALSE, FALSE);
4456 HeapFree(GetProcessHeap(), 0, annotation_handles);
4459 if (states)
4461 for (i = 0; i < pass->state_count; ++i)
4463 free_state(&states[i]);
4465 HeapFree(GetProcessHeap(), 0, states);
4468 HeapFree(GetProcessHeap(), 0, name);
4470 return hr;
4473 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
4475 DWORD offset;
4476 HRESULT hr;
4477 unsigned int i;
4478 D3DXHANDLE *annotation_handles = NULL;
4479 D3DXHANDLE *pass_handles = NULL;
4480 char *name = NULL;
4482 read_dword(ptr, &offset);
4483 TRACE("Technique name offset: %#x\n", offset);
4484 hr = d3dx9_parse_name(&name, data + offset);
4485 if (hr != D3D_OK)
4487 WARN("Failed to parse name\n");
4488 goto err_out;
4491 read_dword(ptr, &technique->annotation_count);
4492 TRACE("Annotation count: %u\n", technique->annotation_count);
4494 read_dword(ptr, &technique->pass_count);
4495 TRACE("Pass count: %u\n", technique->pass_count);
4497 if (technique->annotation_count)
4499 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
4500 if (!annotation_handles)
4502 ERR("Out of memory\n");
4503 hr = E_OUTOFMEMORY;
4504 goto err_out;
4507 for (i = 0; i < technique->annotation_count; ++i)
4509 struct d3dx_parameter *annotation;
4511 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4512 if (!annotation)
4514 ERR("Out of memory\n");
4515 hr = E_OUTOFMEMORY;
4516 goto err_out;
4519 annotation_handles[i] = get_parameter_handle(annotation);
4521 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4522 if (hr != D3D_OK)
4524 WARN("Failed to parse annotations\n");
4525 goto err_out;
4530 if (technique->pass_count)
4532 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4533 if (!pass_handles)
4535 ERR("Out of memory\n");
4536 hr = E_OUTOFMEMORY;
4537 goto err_out;
4540 for (i = 0; i < technique->pass_count; ++i)
4542 struct d3dx_pass *pass;
4544 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4545 if (!pass)
4547 ERR("Out of memory\n");
4548 hr = E_OUTOFMEMORY;
4549 goto err_out;
4552 pass_handles[i] = get_pass_handle(pass);
4554 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
4555 if (hr != D3D_OK)
4557 WARN("Failed to parse passes\n");
4558 goto err_out;
4563 technique->name = name;
4564 technique->pass_handles = pass_handles;
4565 technique->annotation_handles = annotation_handles;
4567 return D3D_OK;
4569 err_out:
4571 if (pass_handles)
4573 for (i = 0; i < technique->pass_count; ++i)
4575 free_pass(pass_handles[i]);
4577 HeapFree(GetProcessHeap(), 0, pass_handles);
4580 if (annotation_handles)
4582 for (i = 0; i < technique->annotation_count; ++i)
4584 free_parameter(annotation_handles[i], FALSE, FALSE);
4586 HeapFree(GetProcessHeap(), 0, annotation_handles);
4589 HeapFree(GetProcessHeap(), 0, name);
4591 return hr;
4594 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4596 const char *ptr = data + start;
4597 D3DXHANDLE *parameter_handles = NULL;
4598 D3DXHANDLE *technique_handles = NULL;
4599 D3DXHANDLE *objects = NULL;
4600 UINT stringcount, objectcount;
4601 HRESULT hr;
4602 UINT i;
4604 read_dword(&ptr, &base->parameter_count);
4605 TRACE("Parameter count: %u\n", base->parameter_count);
4607 read_dword(&ptr, &base->technique_count);
4608 TRACE("Technique count: %u\n", base->technique_count);
4610 skip_dword_unknown(&ptr, 1);
4612 read_dword(&ptr, &objectcount);
4613 TRACE("Object count: %u\n", objectcount);
4615 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
4616 if (!objects)
4618 ERR("Out of memory\n");
4619 hr = E_OUTOFMEMORY;
4620 goto err_out;
4623 if (base->parameter_count)
4625 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4626 if (!parameter_handles)
4628 ERR("Out of memory\n");
4629 hr = E_OUTOFMEMORY;
4630 goto err_out;
4633 for (i = 0; i < base->parameter_count; ++i)
4635 struct d3dx_parameter *parameter;
4637 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4638 if (!parameter)
4640 ERR("Out of memory\n");
4641 hr = E_OUTOFMEMORY;
4642 goto err_out;
4645 parameter_handles[i] = get_parameter_handle(parameter);
4647 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
4648 if (hr != D3D_OK)
4650 WARN("Failed to parse parameter\n");
4651 goto err_out;
4656 if (base->technique_count)
4658 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4659 if (!technique_handles)
4661 ERR("Out of memory\n");
4662 hr = E_OUTOFMEMORY;
4663 goto err_out;
4666 for (i = 0; i < base->technique_count; ++i)
4668 struct d3dx_technique *technique;
4670 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4671 if (!technique)
4673 ERR("Out of memory\n");
4674 hr = E_OUTOFMEMORY;
4675 goto err_out;
4678 technique_handles[i] = get_technique_handle(technique);
4680 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
4681 if (hr != D3D_OK)
4683 WARN("Failed to parse technique\n");
4684 goto err_out;
4689 read_dword(&ptr, &stringcount);
4690 TRACE("String count: %u\n", stringcount);
4692 skip_dword_unknown(&ptr, 1);
4694 for (i = 0; i < stringcount; ++i)
4696 DWORD id;
4697 struct d3dx_parameter *param;
4699 read_dword(&ptr, &id);
4700 TRACE("Id: %u\n", id);
4702 param = get_parameter_struct(objects[id]);
4704 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
4705 if (hr != D3D_OK)
4707 WARN("Failed to parse data\n");
4708 goto err_out;
4712 HeapFree(GetProcessHeap(), 0, objects);
4714 base->technique_handles = technique_handles;
4715 base->parameter_handles = parameter_handles;
4717 return D3D_OK;
4719 err_out:
4721 if (technique_handles)
4723 for (i = 0; i < base->technique_count; ++i)
4725 free_technique(technique_handles[i]);
4727 HeapFree(GetProcessHeap(), 0, technique_handles);
4730 if (parameter_handles)
4732 for (i = 0; i < base->parameter_count; ++i)
4734 free_parameter(parameter_handles[i], FALSE, FALSE);
4736 HeapFree(GetProcessHeap(), 0, parameter_handles);
4739 HeapFree(GetProcessHeap(), 0, objects);
4741 return hr;
4744 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
4745 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
4747 DWORD tag, offset;
4748 const char *ptr = data;
4749 HRESULT hr;
4751 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
4753 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
4754 base->ref = 1;
4755 base->effect = effect;
4757 read_dword(&ptr, &tag);
4758 TRACE("Tag: %x\n", tag);
4760 if (tag != d3dx9_effect_version(9, 1))
4762 /* todo: compile hlsl ascii code */
4763 FIXME("HLSL ascii effects not supported, yet\n");
4765 /* Show the start of the shader for debugging info. */
4766 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
4768 else
4770 read_dword(&ptr, &offset);
4771 TRACE("Offset: %x\n", offset);
4773 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
4774 if (hr != D3D_OK)
4776 FIXME("Failed to parse effect.\n");
4777 return hr;
4781 return D3D_OK;
4784 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
4785 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
4787 HRESULT hr;
4788 struct ID3DXBaseEffectImpl *object = NULL;
4790 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
4792 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
4793 effect->ref = 1;
4795 if (pool) pool->lpVtbl->AddRef(pool);
4796 effect->pool = pool;
4798 IDirect3DDevice9_AddRef(device);
4799 effect->device = device;
4801 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4802 if (!object)
4804 ERR("Out of memory\n");
4805 hr = E_OUTOFMEMORY;
4806 goto err_out;
4809 hr = d3dx9_base_effect_init(object, data, data_size, effect);
4810 if (hr != D3D_OK)
4812 FIXME("Failed to parse effect.\n");
4813 goto err_out;
4816 effect->base_effect = &object->ID3DXBaseEffect_iface;
4818 return D3D_OK;
4820 err_out:
4822 HeapFree(GetProcessHeap(), 0, object);
4823 free_effect(effect);
4825 return hr;
4828 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
4829 LPCVOID srcdata,
4830 UINT srcdatalen,
4831 CONST D3DXMACRO* defines,
4832 LPD3DXINCLUDE include,
4833 LPCSTR skip_constants,
4834 DWORD flags,
4835 LPD3DXEFFECTPOOL pool,
4836 LPD3DXEFFECT* effect,
4837 LPD3DXBUFFER* compilation_errors)
4839 struct ID3DXEffectImpl *object;
4840 HRESULT hr;
4842 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
4843 skip_constants, flags, pool, effect, compilation_errors);
4845 if (!device || !srcdata)
4846 return D3DERR_INVALIDCALL;
4848 if (!srcdatalen)
4849 return E_FAIL;
4851 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
4852 if (!effect)
4853 return D3D_OK;
4855 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4856 if (!object)
4858 ERR("Out of memory\n");
4859 return E_OUTOFMEMORY;
4862 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
4863 if (FAILED(hr))
4865 WARN("Failed to initialize shader reflection\n");
4866 HeapFree(GetProcessHeap(), 0, object);
4867 return hr;
4870 *effect = &object->ID3DXEffect_iface;
4872 TRACE("Created ID3DXEffect %p\n", object);
4874 return D3D_OK;
4877 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
4878 LPCVOID srcdata,
4879 UINT srcdatalen,
4880 CONST D3DXMACRO* defines,
4881 LPD3DXINCLUDE include,
4882 DWORD flags,
4883 LPD3DXEFFECTPOOL pool,
4884 LPD3DXEFFECT* effect,
4885 LPD3DXBUFFER* compilation_errors)
4887 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
4888 include, flags, pool, effect, compilation_errors);
4890 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
4893 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
4895 HRESULT hr;
4896 struct ID3DXBaseEffectImpl *object = NULL;
4898 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
4900 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
4901 compiler->ref = 1;
4903 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4904 if (!object)
4906 ERR("Out of memory\n");
4907 hr = E_OUTOFMEMORY;
4908 goto err_out;
4911 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
4912 if (hr != D3D_OK)
4914 FIXME("Failed to parse effect.\n");
4915 goto err_out;
4918 compiler->base_effect = &object->ID3DXBaseEffect_iface;
4920 return D3D_OK;
4922 err_out:
4924 HeapFree(GetProcessHeap(), 0, object);
4925 free_effect_compiler(compiler);
4927 return hr;
4930 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
4931 UINT srcdatalen,
4932 CONST D3DXMACRO *defines,
4933 LPD3DXINCLUDE include,
4934 DWORD flags,
4935 LPD3DXEFFECTCOMPILER *compiler,
4936 LPD3DXBUFFER *parse_errors)
4938 struct ID3DXEffectCompilerImpl *object;
4939 HRESULT hr;
4941 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
4942 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
4944 if (!srcdata || !compiler)
4946 WARN("Invalid arguments supplied\n");
4947 return D3DERR_INVALIDCALL;
4950 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4951 if (!object)
4953 ERR("Out of memory\n");
4954 return E_OUTOFMEMORY;
4957 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
4958 if (FAILED(hr))
4960 WARN("Failed to initialize effect compiler\n");
4961 HeapFree(GetProcessHeap(), 0, object);
4962 return hr;
4965 *compiler = &object->ID3DXEffectCompiler_iface;
4967 TRACE("Created ID3DXEffectCompiler %p\n", object);
4969 return D3D_OK;
4972 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
4974 struct ID3DXEffectPoolImpl
4976 ID3DXEffectPool ID3DXEffectPool_iface;
4977 LONG ref;
4980 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
4982 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
4985 /*** IUnknown methods ***/
4986 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
4988 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4990 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
4992 if (IsEqualGUID(riid, &IID_IUnknown) ||
4993 IsEqualGUID(riid, &IID_ID3DXEffectPool))
4995 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
4996 *object = This;
4997 return S_OK;
5000 WARN("Interface %s not found\n", debugstr_guid(riid));
5002 return E_NOINTERFACE;
5005 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5007 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5009 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5011 return InterlockedIncrement(&This->ref);
5014 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5016 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5017 ULONG ref = InterlockedDecrement(&This->ref);
5019 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5021 if (!ref)
5022 HeapFree(GetProcessHeap(), 0, This);
5024 return ref;
5027 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5029 /*** IUnknown methods ***/
5030 ID3DXEffectPoolImpl_QueryInterface,
5031 ID3DXEffectPoolImpl_AddRef,
5032 ID3DXEffectPoolImpl_Release
5035 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5037 struct ID3DXEffectPoolImpl *object;
5039 TRACE("(%p)\n", pool);
5041 if (!pool)
5042 return D3DERR_INVALIDCALL;
5044 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5045 if (!object)
5047 ERR("Out of memory\n");
5048 return E_OUTOFMEMORY;
5051 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5052 object->ref = 1;
5054 *pool = &object->ID3DXEffectPool_iface;
5056 return S_OK;
5059 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5060 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5061 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5063 LPVOID buffer;
5064 HRESULT ret;
5065 DWORD size;
5067 TRACE("(%s): relay\n", debugstr_w(srcfile));
5069 if (!device || !srcfile)
5070 return D3DERR_INVALIDCALL;
5072 ret = map_view_of_file(srcfile, &buffer, &size);
5074 if (FAILED(ret))
5075 return D3DXERR_INVALIDDATA;
5077 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5078 UnmapViewOfFile(buffer);
5080 return ret;
5083 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5084 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5085 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5087 LPWSTR srcfileW;
5088 HRESULT ret;
5089 DWORD len;
5091 TRACE("(void): relay\n");
5093 if (!srcfile)
5094 return D3DERR_INVALIDCALL;
5096 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5097 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5098 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5100 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5101 HeapFree(GetProcessHeap(), 0, srcfileW);
5103 return ret;
5106 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5107 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5108 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5110 TRACE("(void): relay\n");
5111 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5114 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5115 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5116 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5118 TRACE("(void): relay\n");
5119 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5122 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5123 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5124 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5126 HRSRC resinfo;
5128 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5130 if (!device)
5131 return D3DERR_INVALIDCALL;
5133 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5135 if (resinfo)
5137 LPVOID buffer;
5138 HRESULT ret;
5139 DWORD size;
5141 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5143 if (FAILED(ret))
5144 return D3DXERR_INVALIDDATA;
5146 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5149 return D3DXERR_INVALIDDATA;
5152 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5153 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5154 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5156 HRSRC resinfo;
5158 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5160 if (!device)
5161 return D3DERR_INVALIDCALL;
5163 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5165 if (resinfo)
5167 LPVOID buffer;
5168 HRESULT ret;
5169 DWORD size;
5171 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5173 if (FAILED(ret))
5174 return D3DXERR_INVALIDDATA;
5176 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5179 return D3DXERR_INVALIDDATA;
5182 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5183 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5184 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5186 TRACE("(void): relay\n");
5187 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5190 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5191 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5192 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5194 TRACE("(void): relay\n");
5195 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5198 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5199 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5201 LPVOID buffer;
5202 HRESULT ret;
5203 DWORD size;
5205 TRACE("(%s): relay\n", debugstr_w(srcfile));
5207 if (!srcfile)
5208 return D3DERR_INVALIDCALL;
5210 ret = map_view_of_file(srcfile, &buffer, &size);
5212 if (FAILED(ret))
5213 return D3DXERR_INVALIDDATA;
5215 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5216 UnmapViewOfFile(buffer);
5218 return ret;
5221 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5222 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5224 LPWSTR srcfileW;
5225 HRESULT ret;
5226 DWORD len;
5228 TRACE("(void): relay\n");
5230 if (!srcfile)
5231 return D3DERR_INVALIDCALL;
5233 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5234 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5235 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5237 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5238 HeapFree(GetProcessHeap(), 0, srcfileW);
5240 return ret;
5243 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5244 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5246 HRSRC resinfo;
5248 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5250 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5252 if (resinfo)
5254 LPVOID buffer;
5255 HRESULT ret;
5256 DWORD size;
5258 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5260 if (FAILED(ret))
5261 return D3DXERR_INVALIDDATA;
5263 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5266 return D3DXERR_INVALIDDATA;
5269 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5270 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5272 HRSRC resinfo;
5274 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5276 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5278 if (resinfo)
5280 LPVOID buffer;
5281 HRESULT ret;
5282 DWORD size;
5284 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5286 if (FAILED(ret))
5287 return D3DXERR_INVALIDDATA;
5289 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5292 return D3DXERR_INVALIDDATA;