d3dx9: Implement ID3DXBaseEffect::SetMatrix().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blob3079bc08f4fdc60e740a3cc922cbd3f07626f060
1 /*
2 * Copyright 2010 Christian Costa
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
20 #include "wine/port.h"
21 #define NONAMELESSUNION
22 #include "wine/debug.h"
23 #include "wine/unicode.h"
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "d3dx9_36_private.h"
29 /* Constants for special INT/FLOAT conversation */
30 #define INT_FLOAT_MULTI 255.0f
31 #define INT_FLOAT_MULTI_INVERSE (1/INT_FLOAT_MULTI)
33 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
35 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
36 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
37 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
39 enum STATE_CLASS
41 SC_LIGHTENABLE,
42 SC_FVF,
43 SC_LIGHT,
44 SC_MATERIAL,
45 SC_NPATCHMODE,
46 SC_PIXELSHADER,
47 SC_RENDERSTATE,
48 SC_SETSAMPLER,
49 SC_SAMPLERSTATE,
50 SC_TEXTURE,
51 SC_TEXTURESTAGE,
52 SC_TRANSFORM,
53 SC_VERTEXSHADER,
54 SC_SHADERCONST,
55 SC_UNKNOWN,
58 enum MATERIAL_TYPE
60 MT_DIFFUSE,
61 MT_AMBIENT,
62 MT_SPECULAR,
63 MT_EMISSIVE,
64 MT_POWER,
67 enum LIGHT_TYPE
69 LT_TYPE,
70 LT_DIFFUSE,
71 LT_SPECULAR,
72 LT_AMBIENT,
73 LT_POSITION,
74 LT_DIRECTION,
75 LT_RANGE,
76 LT_FALLOFF,
77 LT_ATTENUATION0,
78 LT_ATTENUATION1,
79 LT_ATTENUATION2,
80 LT_THETA,
81 LT_PHI,
84 enum SHADER_CONSTANT_TYPE
86 SCT_VSFLOAT,
87 SCT_VSBOOL,
88 SCT_VSINT,
89 SCT_PSFLOAT,
90 SCT_PSBOOL,
91 SCT_PSINT,
94 enum STATE_TYPE
96 ST_CONSTANT,
97 ST_PARAMETER,
98 ST_FXLC,
101 struct d3dx_parameter
103 char *name;
104 char *semantic;
105 void *data;
106 D3DXPARAMETER_CLASS class;
107 D3DXPARAMETER_TYPE type;
108 UINT rows;
109 UINT columns;
110 UINT element_count;
111 UINT annotation_count;
112 UINT member_count;
113 DWORD flags;
114 UINT bytes;
116 D3DXHANDLE *annotation_handles;
117 D3DXHANDLE *member_handles;
120 struct d3dx_state
122 UINT operation;
123 UINT index;
124 enum STATE_TYPE type;
125 D3DXHANDLE parameter;
128 struct d3dx_sampler
130 UINT state_count;
131 struct d3dx_state *states;
134 struct d3dx_pass
136 char *name;
137 UINT state_count;
138 UINT annotation_count;
140 struct d3dx_state *states;
141 D3DXHANDLE *annotation_handles;
144 struct d3dx_technique
146 char *name;
147 UINT pass_count;
148 UINT annotation_count;
150 D3DXHANDLE *annotation_handles;
151 D3DXHANDLE *pass_handles;
154 struct ID3DXBaseEffectImpl
156 ID3DXBaseEffect ID3DXBaseEffect_iface;
157 LONG ref;
159 struct ID3DXEffectImpl *effect;
161 UINT parameter_count;
162 UINT technique_count;
164 D3DXHANDLE *parameter_handles;
165 D3DXHANDLE *technique_handles;
168 struct ID3DXEffectImpl
170 ID3DXEffect ID3DXEffect_iface;
171 LONG ref;
173 LPD3DXEFFECTSTATEMANAGER manager;
174 LPDIRECT3DDEVICE9 device;
175 LPD3DXEFFECTPOOL pool;
176 D3DXHANDLE active_technique;
177 D3DXHANDLE active_pass;
179 ID3DXBaseEffect *base_effect;
182 struct ID3DXEffectCompilerImpl
184 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
185 LONG ref;
187 ID3DXBaseEffect *base_effect;
190 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
191 struct d3dx_parameter *parameter, LPCSTR name);
192 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
193 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
194 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
196 static const struct
198 enum STATE_CLASS class;
199 UINT op;
200 LPCSTR name;
202 state_table[] =
204 /* Render sates */
205 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
206 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
207 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
208 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
209 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
210 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
211 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
212 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
213 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
214 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
215 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
216 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
217 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
218 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
219 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
220 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
221 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
222 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
223 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
224 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
225 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
226 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
227 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
228 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
229 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
230 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
231 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
232 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
233 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
234 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
235 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
236 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
237 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
238 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
239 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
240 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
241 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
242 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
243 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
244 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
245 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
246 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
247 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
248 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
249 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
250 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
251 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
252 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
253 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
254 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
255 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
256 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
257 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
258 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
259 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
260 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
261 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
262 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
263 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
264 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
265 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
266 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
267 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
268 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
269 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
270 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
271 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
272 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
273 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
274 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
275 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
276 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
277 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
278 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
279 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
280 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
281 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
282 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
283 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
284 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
285 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
286 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
287 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
288 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
289 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
290 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
291 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
292 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
293 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
294 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
295 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
296 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
297 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
298 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
299 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
300 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
301 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
302 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
303 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
304 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
305 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
306 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
307 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
308 /* Texture stages */
309 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
310 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
311 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
312 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
313 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
314 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
315 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
316 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
317 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
318 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
319 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
320 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
321 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
322 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
323 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
324 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
325 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
326 /* */
327 {SC_UNKNOWN, 0, "UNKNOWN"},
328 /* NPatchMode */
329 {SC_NPATCHMODE, 0, "NPatchMode"},
330 /* */
331 {SC_UNKNOWN, 0, "UNKNOWN"},
332 /* Transform */
333 {SC_TRANSFORM, D3DTS_PROJECTION, "D3DTS_PROJECTION"},
334 {SC_TRANSFORM, D3DTS_VIEW, "D3DTS_VIEW"},
335 {SC_TRANSFORM, D3DTS_WORLD, "D3DTS_WORLD"},
336 {SC_TRANSFORM, D3DTS_TEXTURE0, "D3DTS_TEXTURE0"},
337 /* Material */
338 {SC_MATERIAL, MT_DIFFUSE, "MaterialDiffuse"},
339 {SC_MATERIAL, MT_AMBIENT, "MaterialAmbient"}, /* 0x80 */
340 {SC_MATERIAL, MT_SPECULAR, "MaterialSpecular"},
341 {SC_MATERIAL, MT_EMISSIVE, "MaterialEmissive"},
342 {SC_MATERIAL, MT_POWER, "MaterialPower"},
343 /* Light */
344 {SC_LIGHT, LT_TYPE, "LightType"},
345 {SC_LIGHT, LT_DIFFUSE, "LightDiffuse"},
346 {SC_LIGHT, LT_SPECULAR, "LightSpecular"},
347 {SC_LIGHT, LT_AMBIENT, "LightAmbient"},
348 {SC_LIGHT, LT_POSITION, "LightPosition"},
349 {SC_LIGHT, LT_DIRECTION, "LightDirection"},
350 {SC_LIGHT, LT_RANGE, "LightRange"},
351 {SC_LIGHT, LT_FALLOFF, "LightFallOff"},
352 {SC_LIGHT, LT_ATTENUATION0, "LightAttenuation0"},
353 {SC_LIGHT, LT_ATTENUATION1, "LightAttenuation1"},
354 {SC_LIGHT, LT_ATTENUATION2, "LightAttenuation2"},
355 {SC_LIGHT, LT_THETA, "LightTheta"},
356 {SC_LIGHT, LT_PHI, "LightPhi"}, /* 0x90 */
357 /* Ligthenable */
358 {SC_LIGHTENABLE, 0, "LightEnable"},
359 /* Vertexshader */
360 {SC_VERTEXSHADER, 0, "Vertexshader"},
361 /* Pixelshader */
362 {SC_PIXELSHADER, 0, "Pixelshader"},
363 /* Shader constants */
364 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstantF"},
365 {SC_SHADERCONST, SCT_VSBOOL, "VertexShaderConstantB"},
366 {SC_SHADERCONST, SCT_VSINT, "VertexShaderConstantI"},
367 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant"},
368 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant1"},
369 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant2"},
370 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant3"},
371 {SC_SHADERCONST, SCT_VSFLOAT, "VertexShaderConstant4"},
372 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstantF"},
373 {SC_SHADERCONST, SCT_PSBOOL, "PixelShaderConstantB"},
374 {SC_SHADERCONST, SCT_PSINT, "PixelShaderConstantI"},
375 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant"},
376 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant1"}, /* 0xa0 */
377 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant2"},
378 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant3"},
379 {SC_SHADERCONST, SCT_PSFLOAT, "PixelShaderConstant4"},
380 /* Texture */
381 {SC_TEXTURE, 0, "Texture"},
382 /* Sampler states */
383 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSU, "AddressU"},
384 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSV, "AddressV"},
385 {SC_SAMPLERSTATE, D3DSAMP_ADDRESSW, "AddressW"},
386 {SC_SAMPLERSTATE, D3DSAMP_BORDERCOLOR, "BorderColor"},
387 {SC_SAMPLERSTATE, D3DSAMP_MAGFILTER, "MagFilter"},
388 {SC_SAMPLERSTATE, D3DSAMP_MINFILTER, "MinFilter"},
389 {SC_SAMPLERSTATE, D3DSAMP_MIPFILTER, "MipFilter"},
390 {SC_SAMPLERSTATE, D3DSAMP_MIPMAPLODBIAS, "MipMapLodBias"},
391 {SC_SAMPLERSTATE, D3DSAMP_MAXMIPLEVEL, "MaxMipLevel"},
392 {SC_SAMPLERSTATE, D3DSAMP_MAXANISOTROPY, "MaxAnisotropy"},
393 {SC_SAMPLERSTATE, D3DSAMP_SRGBTEXTURE, "SRGBTexture"},
394 {SC_SAMPLERSTATE, D3DSAMP_ELEMENTINDEX, "ElementIndex"}, /* 0xb0 */
395 {SC_SAMPLERSTATE, D3DSAMP_DMAPOFFSET, "DMAPOffset"},
396 /* Set sampler */
397 {SC_SETSAMPLER, 0, "Sampler"},
400 static inline void read_dword(const char **ptr, DWORD *d)
402 memcpy(d, *ptr, sizeof(*d));
403 *ptr += sizeof(*d);
406 static void skip_dword_unknown(const char **ptr, unsigned int count)
408 unsigned int i;
409 DWORD d;
411 FIXME("Skipping %u unknown DWORDs:\n", count);
412 for (i = 0; i < count; ++i)
414 read_dword(ptr, &d);
415 FIXME("\t0x%08x\n", d);
419 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
421 return (struct d3dx_parameter *) handle;
424 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
426 return (struct d3dx_pass *) handle;
429 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
431 return (struct d3dx_technique *) handle;
434 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
436 return (D3DXHANDLE) parameter;
439 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
441 return (D3DXHANDLE) technique;
444 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
446 return (D3DXHANDLE) pass;
449 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
451 unsigned int i;
453 for (i = 0; i < base->technique_count; ++i)
455 if (base->technique_handles[i] == technique)
457 return get_technique_struct(technique);
461 return NULL;
464 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
466 unsigned int i, k;
468 for (i = 0; i < base->technique_count; ++i)
470 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
472 for (k = 0; k < technique->pass_count; ++k)
474 if (technique->pass_handles[k] == pass)
476 return get_pass_struct(pass);
481 return NULL;
484 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
486 unsigned int i, count;
487 struct d3dx_parameter *p;
489 for (i = 0; i < param->annotation_count; ++i)
491 if (param->annotation_handles[i] == parameter)
493 return get_parameter_struct(parameter);
496 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
497 if (p) return p;
500 if (param->element_count) count = param->element_count;
501 else count = param->member_count;
503 for (i = 0; i < count; ++i)
505 if (param->member_handles[i] == parameter)
507 return get_parameter_struct(parameter);
510 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
511 if (p) return p;
514 return NULL;
517 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
519 unsigned int i, k, m;
520 struct d3dx_parameter *p;
522 for (i = 0; i < base->parameter_count; ++i)
524 if (base->parameter_handles[i] == parameter)
526 return get_parameter_struct(parameter);
529 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
530 if (p) return p;
533 for (i = 0; i < base->technique_count; ++i)
535 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
537 for (k = 0; k < technique->pass_count; ++k)
539 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
541 for (m = 0; m < pass->annotation_count; ++m)
543 if (pass->annotation_handles[i] == parameter)
545 return get_parameter_struct(parameter);
548 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
549 if (p) return p;
553 for (k = 0; k < technique->annotation_count; ++k)
555 if (technique->annotation_handles[k] == parameter)
557 return get_parameter_struct(parameter);
560 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
561 if (p) return p;
565 return NULL;
568 static inline struct d3dx_parameter *get_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
570 struct d3dx_parameter *param = is_valid_parameter(base, parameter);
572 if (!param) param = get_parameter_by_name(base, NULL, parameter);
574 return param;
577 static void free_state(struct d3dx_state *state)
579 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
582 static void free_sampler(struct d3dx_sampler *sampler)
584 UINT i;
586 for (i = 0; i < sampler->state_count; ++i)
588 free_state(&sampler->states[i]);
590 HeapFree(GetProcessHeap(), 0, sampler->states);
593 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
595 free_parameter_state(handle, element, child, ST_CONSTANT);
598 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
600 unsigned int i;
601 struct d3dx_parameter *param = get_parameter_struct(handle);
603 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
604 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
606 if (!param)
608 return;
611 if (param->annotation_handles)
613 for (i = 0; i < param->annotation_count; ++i)
615 free_parameter(param->annotation_handles[i], FALSE, FALSE);
617 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
620 if (param->member_handles)
622 unsigned int count;
624 if (param->element_count) count = param->element_count;
625 else count = param->member_count;
627 for (i = 0; i < count; ++i)
629 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
631 HeapFree(GetProcessHeap(), 0, param->member_handles);
634 if (param->class == D3DXPC_OBJECT && !param->element_count)
636 switch (param->type)
638 case D3DXPT_STRING:
639 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
640 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
641 break;
643 case D3DXPT_TEXTURE:
644 case D3DXPT_TEXTURE1D:
645 case D3DXPT_TEXTURE2D:
646 case D3DXPT_TEXTURE3D:
647 case D3DXPT_TEXTURECUBE:
648 case D3DXPT_PIXELSHADER:
649 case D3DXPT_VERTEXSHADER:
650 if (st == ST_CONSTANT)
652 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
654 else
656 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
658 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
659 break;
661 case D3DXPT_SAMPLER:
662 case D3DXPT_SAMPLER1D:
663 case D3DXPT_SAMPLER2D:
664 case D3DXPT_SAMPLER3D:
665 case D3DXPT_SAMPLERCUBE:
666 if (st == ST_CONSTANT)
668 free_sampler((struct d3dx_sampler *)param->data);
670 else
672 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
674 /* samplers have always own data, so free that */
675 HeapFree(GetProcessHeap(), 0, param->data);
676 break;
678 default:
679 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
680 break;
683 else
685 if (!child)
687 if (st != ST_CONSTANT)
689 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
691 HeapFree(GetProcessHeap(), 0, param->data);
695 /* only the parent has to release name and semantic */
696 if (!element)
698 HeapFree(GetProcessHeap(), 0, param->name);
699 HeapFree(GetProcessHeap(), 0, param->semantic);
702 HeapFree(GetProcessHeap(), 0, param);
705 static void free_pass(D3DXHANDLE handle)
707 unsigned int i;
708 struct d3dx_pass *pass = get_pass_struct(handle);
710 TRACE("Free pass %p\n", pass);
712 if (!pass)
714 return;
717 if (pass->annotation_handles)
719 for (i = 0; i < pass->annotation_count; ++i)
721 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
723 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
726 if (pass->states)
728 for (i = 0; i < pass->state_count; ++i)
730 free_state(&pass->states[i]);
732 HeapFree(GetProcessHeap(), 0, pass->states);
735 HeapFree(GetProcessHeap(), 0, pass->name);
736 HeapFree(GetProcessHeap(), 0, pass);
739 static void free_technique(D3DXHANDLE handle)
741 unsigned int i;
742 struct d3dx_technique *technique = get_technique_struct(handle);
744 TRACE("Free technique %p\n", technique);
746 if (!technique)
748 return;
751 if (technique->annotation_handles)
753 for (i = 0; i < technique->annotation_count; ++i)
755 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
757 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
760 if (technique->pass_handles)
762 for (i = 0; i < technique->pass_count; ++i)
764 free_pass(technique->pass_handles[i]);
766 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
769 HeapFree(GetProcessHeap(), 0, technique->name);
770 HeapFree(GetProcessHeap(), 0, technique);
773 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
775 unsigned int i;
777 TRACE("Free base effect %p\n", base);
779 if (base->parameter_handles)
781 for (i = 0; i < base->parameter_count; ++i)
783 free_parameter(base->parameter_handles[i], FALSE, FALSE);
785 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
788 if (base->technique_handles)
790 for (i = 0; i < base->technique_count; ++i)
792 free_technique(base->technique_handles[i]);
794 HeapFree(GetProcessHeap(), 0, base->technique_handles);
798 static void free_effect(struct ID3DXEffectImpl *effect)
800 TRACE("Free effect %p\n", effect);
802 if (effect->base_effect)
804 effect->base_effect->lpVtbl->Release(effect->base_effect);
807 if (effect->pool)
809 effect->pool->lpVtbl->Release(effect->pool);
812 if (effect->manager)
814 IUnknown_Release(effect->manager);
817 IDirect3DDevice9_Release(effect->device);
820 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
822 TRACE("Free effect compiler %p\n", compiler);
824 if (compiler->base_effect)
826 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
830 static INT get_int(D3DXPARAMETER_TYPE type, LPCVOID data)
832 INT i;
834 switch (type)
836 case D3DXPT_FLOAT:
837 i = *(FLOAT *)data;
838 break;
840 case D3DXPT_INT:
841 i = *(INT *)data;
842 break;
844 case D3DXPT_BOOL:
845 i = *(BOOL *)data;
846 break;
848 default:
849 i = 0;
850 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
851 break;
854 return i;
857 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, LPCVOID data)
859 FLOAT f;
861 switch (type)
863 case D3DXPT_FLOAT:
864 f = *(FLOAT *)data;
865 break;
867 case D3DXPT_INT:
868 f = *(INT *)data;
869 break;
871 case D3DXPT_BOOL:
872 f = *(BOOL *)data;
873 break;
875 default:
876 f = 0.0f;
877 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
878 break;
881 return f;
884 static inline BOOL get_bool(LPCVOID data)
886 return (*(DWORD *)data) ? TRUE : FALSE;
889 static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector)
891 vector->x = get_float(param->type, (float *)param->data);
892 vector->y = param->columns > 1 ? get_float(param->type, (float *)param->data + 1) : 0.0f;
893 vector->z = param->columns > 2 ? get_float(param->type, (float *)param->data + 2) : 0.0f;
894 vector->w = param->columns > 3 ? get_float(param->type, (float *)param->data + 3) : 0.0f;
897 static void set_number(LPVOID outdata, D3DXPARAMETER_TYPE outtype, LPCVOID indata, D3DXPARAMETER_TYPE intype)
899 TRACE("Changing from type %i to type %i\n", intype, outtype);
901 switch (outtype)
903 case D3DXPT_FLOAT:
904 *(FLOAT *)outdata = get_float(intype, indata);
905 break;
907 case D3DXPT_BOOL:
908 *(BOOL *)outdata = get_bool(indata);
909 break;
911 case D3DXPT_INT:
912 *(INT *)outdata = get_int(intype, indata);
913 break;
915 default:
916 FIXME("Error converting to type %i\n", outtype);
917 *(INT *)outdata = 0;
918 break;
922 static void get_matrix(struct d3dx_parameter *param, D3DXMATRIX *matrix)
924 unsigned int i, k;
926 for (i = 0; i < 4; ++i)
928 for (k = 0; k < 4; ++k)
930 if ((i < param->rows) && (k < param->columns))
931 matrix->u.m[i][k] = get_float(param->type, (float *)param->data + i * param->columns + k);
932 else
933 matrix->u.m[i][k] = 0.0f;
938 static void set_matrix(struct d3dx_parameter *param, CONST D3DXMATRIX *matrix)
940 unsigned int i, k;
942 for (i = 0; i < 4; ++i)
944 for (k = 0; k < 4; ++k)
946 if ((i < param->rows) && (k < param->columns))
947 set_number((float *)param->data + i * param->columns + k, param->type, &matrix->u.m[i][k], D3DXPT_FLOAT);
952 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
954 UINT element;
955 struct d3dx_parameter *temp_parameter;
956 LPCSTR part;
958 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
960 if (!name || !*name) return parameter;
962 element = atoi(name);
963 part = strchr(name, ']') + 1;
965 if (parameter->element_count > element)
967 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
969 switch (*part++)
971 case '.':
972 return get_parameter_by_name(NULL, temp_parameter, part);
974 case '@':
975 return get_parameter_annotation_by_name(temp_parameter, part);
977 case '\0':
978 TRACE("Returning parameter %p\n", temp_parameter);
979 return temp_parameter;
981 default:
982 FIXME("Unhandled case \"%c\"\n", *--part);
983 break;
987 TRACE("Parameter not found\n");
988 return NULL;
991 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
993 UINT i, length;
994 struct d3dx_parameter *temp_parameter;
995 LPCSTR part;
997 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
999 if (!name || !*name) return parameter;
1001 length = strcspn( name, "[.@" );
1002 part = name + length;
1004 for (i = 0; i < parameter->annotation_count; ++i)
1006 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
1008 if (!strcmp(temp_parameter->name, name))
1010 TRACE("Returning parameter %p\n", temp_parameter);
1011 return temp_parameter;
1013 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1015 switch (*part++)
1017 case '.':
1018 return get_parameter_by_name(NULL, temp_parameter, part);
1020 case '[':
1021 return get_parameter_element_by_name(temp_parameter, part);
1023 default:
1024 FIXME("Unhandled case \"%c\"\n", *--part);
1025 break;
1030 TRACE("Parameter not found\n");
1031 return NULL;
1034 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
1035 struct d3dx_parameter *parameter, LPCSTR name)
1037 UINT i, count, length;
1038 struct d3dx_parameter *temp_parameter;
1039 D3DXHANDLE *handles;
1040 LPCSTR part;
1042 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
1044 if (!name || !*name) return parameter;
1046 if (!parameter)
1048 count = base->parameter_count;
1049 handles = base->parameter_handles;
1051 else
1053 count = parameter->member_count;
1054 handles = parameter->member_handles;
1057 length = strcspn( name, "[.@" );
1058 part = name + length;
1060 for (i = 0; i < count; i++)
1062 temp_parameter = get_parameter_struct(handles[i]);
1064 if (!strcmp(temp_parameter->name, name))
1066 TRACE("Returning parameter %p\n", temp_parameter);
1067 return temp_parameter;
1069 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1071 switch (*part++)
1073 case '.':
1074 return get_parameter_by_name(NULL, temp_parameter, part);
1076 case '@':
1077 return get_parameter_annotation_by_name(temp_parameter, part);
1079 case '[':
1080 return get_parameter_element_by_name(temp_parameter, part);
1082 default:
1083 FIXME("Unhandled case \"%c\"\n", *--part);
1084 break;
1089 TRACE("Parameter not found\n");
1090 return NULL;
1093 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1095 return (0xfeff0000 | ((major) << 8) | (minor));
1098 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1100 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1103 /*** IUnknown methods ***/
1104 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1106 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1108 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
1110 if (IsEqualGUID(riid, &IID_IUnknown) ||
1111 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1113 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
1114 *object = This;
1115 return S_OK;
1118 ERR("Interface %s not found\n", debugstr_guid(riid));
1120 return E_NOINTERFACE;
1123 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1125 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1127 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1129 return InterlockedIncrement(&This->ref);
1132 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1134 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1135 ULONG ref = InterlockedDecrement(&This->ref);
1137 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1139 if (!ref)
1141 free_base_effect(This);
1142 HeapFree(GetProcessHeap(), 0, This);
1145 return ref;
1148 /*** ID3DXBaseEffect methods ***/
1149 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1151 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1153 FIXME("iface %p, desc %p partial stub\n", This, desc);
1155 if (!desc)
1157 WARN("Invalid argument specified.\n");
1158 return D3DERR_INVALIDCALL;
1161 /* Todo: add creator and function count */
1162 desc->Creator = NULL;
1163 desc->Functions = 0;
1164 desc->Parameters = This->parameter_count;
1165 desc->Techniques = This->technique_count;
1167 return D3D_OK;
1170 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1172 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1173 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1175 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1177 if (!desc || !param)
1179 WARN("Invalid argument specified.\n");
1180 return D3DERR_INVALIDCALL;
1183 desc->Name = param->name;
1184 desc->Semantic = param->semantic;
1185 desc->Class = param->class;
1186 desc->Type = param->type;
1187 desc->Rows = param->rows;
1188 desc->Columns = param->columns;
1189 desc->Elements = param->element_count;
1190 desc->Annotations = param->annotation_count;
1191 desc->StructMembers = param->member_count;
1192 desc->Flags = param->flags;
1193 desc->Bytes = param->bytes;
1195 return D3D_OK;
1198 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1200 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1201 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1203 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1205 if (!desc || !tech)
1207 WARN("Invalid argument specified.\n");
1208 return D3DERR_INVALIDCALL;
1211 desc->Name = tech->name;
1212 desc->Passes = tech->pass_count;
1213 desc->Annotations = tech->annotation_count;
1215 return D3D_OK;
1218 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1220 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1221 struct d3dx_pass *p = is_valid_pass(This, pass);
1223 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1225 if (!desc || !p)
1227 WARN("Invalid argument specified.\n");
1228 return D3DERR_INVALIDCALL;
1231 desc->Name = p->name;
1232 desc->Annotations = p->annotation_count;
1234 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1235 desc->pVertexShaderFunction = NULL;
1236 desc->pPixelShaderFunction = NULL;
1238 return D3D_OK;
1241 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1243 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1245 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1247 return E_NOTIMPL;
1250 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1252 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1253 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1255 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1257 if (!parameter)
1259 if (index < This->parameter_count)
1261 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1262 return This->parameter_handles[index];
1265 else
1267 if (param && !param->element_count && index < param->member_count)
1269 TRACE("Returning parameter %p\n", param->member_handles[index]);
1270 return param->member_handles[index];
1274 WARN("Invalid argument specified.\n");
1276 return NULL;
1279 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1281 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1282 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1283 D3DXHANDLE handle;
1285 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1287 if (!name)
1289 handle = get_parameter_handle(param);
1290 TRACE("Returning parameter %p\n", handle);
1291 return handle;
1294 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1295 TRACE("Returning parameter %p\n", handle);
1297 return handle;
1300 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1302 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1303 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1304 struct d3dx_parameter *temp_param;
1305 UINT i;
1307 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1309 if (!parameter)
1311 for (i = 0; i < This->parameter_count; ++i)
1313 temp_param = get_parameter_struct(This->parameter_handles[i]);
1315 if (!temp_param->semantic)
1317 if (!semantic)
1319 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1320 return This->parameter_handles[i];
1322 continue;
1325 if (!strcasecmp(temp_param->semantic, semantic))
1327 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1328 return This->parameter_handles[i];
1332 else if (param)
1334 for (i = 0; i < param->member_count; ++i)
1336 temp_param = get_parameter_struct(param->member_handles[i]);
1338 if (!temp_param->semantic)
1340 if (!semantic)
1342 TRACE("Returning parameter %p\n", param->member_handles[i]);
1343 return param->member_handles[i];
1345 continue;
1348 if (!strcasecmp(temp_param->semantic, semantic))
1350 TRACE("Returning parameter %p\n", param->member_handles[i]);
1351 return param->member_handles[i];
1356 WARN("Invalid argument specified\n");
1358 return NULL;
1361 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1363 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1364 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1366 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1368 if (!param)
1370 if (index < This->parameter_count)
1372 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1373 return This->parameter_handles[index];
1376 else
1378 if (index < param->element_count)
1380 TRACE("Returning parameter %p\n", param->member_handles[index]);
1381 return param->member_handles[index];
1385 WARN("Invalid argument specified\n");
1387 return NULL;
1390 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1392 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1394 TRACE("iface %p, index %u\n", This, index);
1396 if (index >= This->technique_count)
1398 WARN("Invalid argument specified.\n");
1399 return NULL;
1402 TRACE("Returning technique %p\n", This->technique_handles[index]);
1404 return This->technique_handles[index];
1407 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1409 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1410 unsigned int i;
1412 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1414 if (!name)
1416 WARN("Invalid argument specified.\n");
1417 return NULL;
1420 for (i = 0; i < This->technique_count; ++i)
1422 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1424 if (!strcmp(tech->name, name))
1426 TRACE("Returning technique %p\n", This->technique_handles[i]);
1427 return This->technique_handles[i];
1431 WARN("Invalid argument specified.\n");
1433 return NULL;
1436 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1438 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1439 struct d3dx_technique *tech = is_valid_technique(This, technique);
1441 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1443 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1445 if (tech && index < tech->pass_count)
1447 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1448 return tech->pass_handles[index];
1451 WARN("Invalid argument specified.\n");
1453 return NULL;
1456 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1458 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1459 struct d3dx_technique *tech = is_valid_technique(This, technique);
1461 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1463 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1465 if (tech && name)
1467 unsigned int i;
1469 for (i = 0; i < tech->pass_count; ++i)
1471 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1473 if (!strcmp(pass->name, name))
1475 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1476 return tech->pass_handles[i];
1481 WARN("Invalid argument specified.\n");
1483 return NULL;
1486 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1488 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1490 FIXME("iface %p, index %u stub\n", This, index);
1492 return NULL;
1495 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1497 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1499 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1501 return NULL;
1504 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1506 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1507 struct d3dx_parameter *param = get_valid_parameter(This, object);
1508 struct d3dx_pass *pass = is_valid_pass(This, object);
1509 struct d3dx_technique *technique = is_valid_technique(This, object);
1510 UINT annotation_count = 0;
1511 D3DXHANDLE *annotation_handles = NULL;
1513 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1515 if (pass)
1517 annotation_count = pass->annotation_count;
1518 annotation_handles = pass->annotation_handles;
1520 else if (technique)
1522 annotation_count = technique->annotation_count;
1523 annotation_handles = technique->annotation_handles;
1525 else if (param)
1527 annotation_count = param->annotation_count;
1528 annotation_handles = param->annotation_handles;
1530 /* Todo: add funcs */
1532 if (index < annotation_count)
1534 TRACE("Returning parameter %p\n", annotation_handles[index]);
1535 return annotation_handles[index];
1538 WARN("Invalid argument specified\n");
1540 return NULL;
1543 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1545 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1546 struct d3dx_parameter *param = get_valid_parameter(This, object);
1547 struct d3dx_pass *pass = is_valid_pass(This, object);
1548 struct d3dx_technique *technique = is_valid_technique(This, object);
1549 UINT annotation_count = 0, i;
1550 D3DXHANDLE *annotation_handles = NULL;
1552 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1554 if (!name)
1556 WARN("Invalid argument specified\n");
1557 return NULL;
1560 if (pass)
1562 annotation_count = pass->annotation_count;
1563 annotation_handles = pass->annotation_handles;
1565 else if (technique)
1567 annotation_count = technique->annotation_count;
1568 annotation_handles = technique->annotation_handles;
1570 else if (param)
1572 annotation_count = param->annotation_count;
1573 annotation_handles = param->annotation_handles;
1575 /* Todo: add funcs */
1577 for (i = 0; i < annotation_count; i++)
1579 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1581 if (!strcmp(anno->name, name))
1583 TRACE("Returning parameter %p\n", anno);
1584 return get_parameter_handle(anno);
1588 WARN("Invalid argument specified\n");
1590 return NULL;
1593 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1595 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1597 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1599 return E_NOTIMPL;
1602 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1604 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1605 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1607 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1609 if (!param)
1611 WARN("Invalid parameter %p specified\n", parameter);
1612 return D3DERR_INVALIDCALL;
1615 /* samplers don't touch data */
1616 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1617 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1618 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1620 TRACE("Sampler: returning E_FAIL\n");
1621 return E_FAIL;
1624 if (data && param->bytes <= bytes)
1626 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1628 switch (param->type)
1630 case D3DXPT_VOID:
1631 case D3DXPT_BOOL:
1632 case D3DXPT_INT:
1633 case D3DXPT_FLOAT:
1634 case D3DXPT_STRING:
1635 break;
1637 case D3DXPT_VERTEXSHADER:
1638 case D3DXPT_PIXELSHADER:
1639 case D3DXPT_TEXTURE:
1640 case D3DXPT_TEXTURE1D:
1641 case D3DXPT_TEXTURE2D:
1642 case D3DXPT_TEXTURE3D:
1643 case D3DXPT_TEXTURECUBE:
1645 UINT i;
1647 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1649 IUnknown *unk = ((IUnknown **)param->data)[i];
1650 if (unk) IUnknown_AddRef(unk);
1652 break;
1655 default:
1656 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1657 break;
1660 TRACE("Copy %u bytes\n", param->bytes);
1661 memcpy(data, param->data, param->bytes);
1662 return D3D_OK;
1665 WARN("Invalid argument specified\n");
1667 return D3DERR_INVALIDCALL;
1670 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1672 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1673 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1675 TRACE("iface %p, parameter %p, b %s\n", This, parameter, b ? "TRUE" : "FALSE");
1677 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1679 set_number(param->data, param->type, &b, D3DXPT_BOOL);
1680 return D3D_OK;
1683 WARN("Invalid argument specified\n");
1685 return D3DERR_INVALIDCALL;
1688 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1690 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1691 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1693 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1695 if (b && param && !param->element_count && param->rows == 1 && param->columns == 1)
1697 *b = get_bool(param->data);
1698 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1699 return D3D_OK;
1702 WARN("Invalid argument specified\n");
1704 return D3DERR_INVALIDCALL;
1707 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1709 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1710 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1712 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1714 if (param)
1716 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1718 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1720 switch (param->class)
1722 case D3DXPC_SCALAR:
1723 case D3DXPC_VECTOR:
1724 case D3DXPC_MATRIX_ROWS:
1725 for (i = 0; i < size; ++i)
1727 set_number((DWORD *)param->data + i, param->type, &b[i], D3DXPT_BOOL);
1729 return D3D_OK;
1731 case D3DXPC_OBJECT:
1732 case D3DXPC_STRUCT:
1733 break;
1735 default:
1736 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1737 break;
1741 WARN("Invalid argument specified\n");
1743 return D3DERR_INVALIDCALL;
1746 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1748 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1749 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1751 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1753 if (b && param && (param->class == D3DXPC_SCALAR
1754 || param->class == D3DXPC_VECTOR
1755 || param->class == D3DXPC_MATRIX_ROWS
1756 || param->class == D3DXPC_MATRIX_COLUMNS))
1758 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1760 for (i = 0; i < size; ++i)
1762 b[i] = get_bool((DWORD *)param->data + i);
1764 return D3D_OK;
1767 WARN("Invalid argument specified\n");
1769 return D3DERR_INVALIDCALL;
1772 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1774 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1775 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1777 TRACE("iface %p, parameter %p, n %i\n", This, parameter, n);
1779 if (param && !param->element_count)
1781 if (param->rows == 1 && param->columns == 1)
1783 set_number(param->data, param->type, &n, D3DXPT_INT);
1784 return D3D_OK;
1788 * Split the value, if parameter is a vector with dimension 3 or 4.
1790 if (param->type == D3DXPT_FLOAT &&
1791 ((param->class == D3DXPC_VECTOR && param->columns != 2) ||
1792 (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1794 FLOAT tmp = ((n & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
1795 set_number((DWORD *)param->data, param->type, &tmp, D3DXPT_FLOAT);
1797 tmp = ((n & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
1798 set_number((DWORD *)param->data + 1, param->type, &tmp, D3DXPT_FLOAT);
1800 tmp = (n & 0xff) * INT_FLOAT_MULTI_INVERSE;
1801 set_number((DWORD *)param->data + 2, param->type, &tmp, D3DXPT_FLOAT);
1803 if (param->rows * param->columns > 3)
1805 tmp = ((n & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
1806 set_number((DWORD *)param->data + 3, param->type, &tmp, D3DXPT_FLOAT);
1808 return D3D_OK;
1812 WARN("Invalid argument specified\n");
1814 return D3DERR_INVALIDCALL;
1817 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1819 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1820 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1822 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1824 if (n && param && !param->element_count)
1826 if (param->columns == 1 && param->rows == 1)
1828 *n = get_int(param->type, param->data);
1829 TRACE("Returning %i\n", *n);
1830 return D3D_OK;
1833 if (param->type == D3DXPT_FLOAT &&
1834 ((param->class == D3DXPC_VECTOR && param->columns != 2)
1835 || (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1837 /* all components (3,4) are clamped (0,255) and put in the INT */
1838 *n = (INT)(min(max(0.0f, *((FLOAT *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI);
1839 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
1840 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
1841 if (param->columns * param->rows > 3)
1843 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
1846 TRACE("Returning %i\n", *n);
1847 return D3D_OK;
1851 WARN("Invalid argument specified\n");
1853 return D3DERR_INVALIDCALL;
1856 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1858 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1859 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1861 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1863 if (param)
1865 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1867 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1869 switch (param->class)
1871 case D3DXPC_SCALAR:
1872 case D3DXPC_VECTOR:
1873 case D3DXPC_MATRIX_ROWS:
1874 for (i = 0; i < size; ++i)
1876 set_number((DWORD *)param->data + i, param->type, &n[i], D3DXPT_INT);
1878 return D3D_OK;
1880 case D3DXPC_OBJECT:
1881 case D3DXPC_STRUCT:
1882 break;
1884 default:
1885 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1886 break;
1890 WARN("Invalid argument specified\n");
1892 return D3DERR_INVALIDCALL;
1895 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1897 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1898 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1900 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1902 if (n && param && (param->class == D3DXPC_SCALAR
1903 || param->class == D3DXPC_VECTOR
1904 || param->class == D3DXPC_MATRIX_ROWS
1905 || param->class == D3DXPC_MATRIX_COLUMNS))
1907 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1909 for (i = 0; i < size; ++i)
1911 n[i] = get_int(param->type, (DWORD *)param->data + i);
1913 return D3D_OK;
1916 WARN("Invalid argument specified\n");
1918 return D3DERR_INVALIDCALL;
1921 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1923 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1924 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1926 TRACE("iface %p, parameter %p, f %f\n", This, parameter, f);
1928 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1930 set_number((DWORD *)param->data, param->type, &f, D3DXPT_FLOAT);
1931 return D3D_OK;
1934 WARN("Invalid argument specified\n");
1936 return D3DERR_INVALIDCALL;
1939 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1941 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1942 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1944 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1946 if (f && param && !param->element_count && param->columns == 1 && param->rows == 1)
1948 *f = get_float(param->type, (DWORD *)param->data);
1949 TRACE("Returning %f\n", *f);
1950 return D3D_OK;
1953 WARN("Invalid argument specified\n");
1955 return D3DERR_INVALIDCALL;
1958 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1960 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1961 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1963 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1965 if (param)
1967 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1969 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1971 switch (param->class)
1973 case D3DXPC_SCALAR:
1974 case D3DXPC_VECTOR:
1975 case D3DXPC_MATRIX_ROWS:
1976 for (i = 0; i < size; ++i)
1978 set_number((DWORD *)param->data + i, param->type, &f[i], D3DXPT_FLOAT);
1980 return D3D_OK;
1982 case D3DXPC_OBJECT:
1983 case D3DXPC_STRUCT:
1984 break;
1986 default:
1987 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1988 break;
1992 WARN("Invalid argument specified\n");
1994 return D3DERR_INVALIDCALL;
1997 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1999 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2000 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2002 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
2004 if (f && param && (param->class == D3DXPC_SCALAR
2005 || param->class == D3DXPC_VECTOR
2006 || param->class == D3DXPC_MATRIX_ROWS
2007 || param->class == D3DXPC_MATRIX_COLUMNS))
2009 UINT i, size = min(count, param->bytes / sizeof(DWORD));
2011 for (i = 0; i < size; ++i)
2013 f[i] = get_float(param->type, (DWORD *)param->data + i);
2015 return D3D_OK;
2018 WARN("Invalid argument specified\n");
2020 return D3DERR_INVALIDCALL;
2023 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
2025 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2027 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
2029 return E_NOTIMPL;
2032 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2034 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2036 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
2038 return E_NOTIMPL;
2041 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2043 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2045 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
2047 return E_NOTIMPL;
2050 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2052 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2053 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2055 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
2057 if (!count) return D3D_OK;
2059 if (vector && param && count <= param->element_count)
2061 UINT i;
2063 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2065 switch (param->class)
2067 case D3DXPC_VECTOR:
2068 for (i = 0; i < count; ++i)
2070 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2072 return D3D_OK;
2074 case D3DXPC_SCALAR:
2075 case D3DXPC_MATRIX_ROWS:
2076 case D3DXPC_OBJECT:
2077 case D3DXPC_STRUCT:
2078 break;
2080 default:
2081 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2082 break;
2086 WARN("Invalid argument specified\n");
2088 return D3DERR_INVALIDCALL;
2091 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2093 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2094 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2096 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2098 if (param && !param->element_count)
2100 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2102 switch (param->class)
2104 case D3DXPC_MATRIX_ROWS:
2105 set_matrix(param, matrix);
2106 return D3D_OK;
2108 case D3DXPC_SCALAR:
2109 case D3DXPC_VECTOR:
2110 case D3DXPC_OBJECT:
2111 case D3DXPC_STRUCT:
2112 break;
2114 default:
2115 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2116 break;
2120 WARN("Invalid argument specified\n");
2122 return D3DERR_INVALIDCALL;
2125 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2127 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2128 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2130 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2132 if (matrix && param && !param->element_count)
2134 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2136 switch (param->class)
2138 case D3DXPC_MATRIX_ROWS:
2139 get_matrix(param, matrix);
2140 return D3D_OK;
2142 case D3DXPC_SCALAR:
2143 case D3DXPC_VECTOR:
2144 case D3DXPC_OBJECT:
2145 case D3DXPC_STRUCT:
2146 break;
2148 default:
2149 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2150 break;
2154 WARN("Invalid argument specified\n");
2156 return D3DERR_INVALIDCALL;
2159 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2161 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2163 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2165 return E_NOTIMPL;
2168 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2170 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2171 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2173 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2175 if (!count) return D3D_OK;
2177 if (matrix && param && count <= param->element_count)
2179 UINT i;
2181 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2183 switch (param->class)
2185 case D3DXPC_MATRIX_ROWS:
2186 for (i = 0; i < count; ++i)
2188 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i]);
2190 return D3D_OK;
2192 case D3DXPC_SCALAR:
2193 case D3DXPC_VECTOR:
2194 case D3DXPC_OBJECT:
2195 case D3DXPC_STRUCT:
2196 break;
2198 default:
2199 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2200 break;
2204 WARN("Invalid argument specified\n");
2206 return D3DERR_INVALIDCALL;
2209 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2211 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2213 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2215 return E_NOTIMPL;
2218 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2220 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2222 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2224 return E_NOTIMPL;
2227 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2229 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2231 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
2233 return E_NOTIMPL;
2236 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2238 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2239 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2240 D3DXMATRIX m;
2242 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2244 if (matrix && param && !param->element_count)
2246 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2248 switch (param->class)
2250 case D3DXPC_SCALAR:
2251 case D3DXPC_VECTOR:
2252 get_matrix(param, matrix);
2253 return D3D_OK;
2255 case D3DXPC_MATRIX_ROWS:
2256 get_matrix(param, &m);
2257 D3DXMatrixTranspose(matrix, &m);
2258 return D3D_OK;
2260 case D3DXPC_OBJECT:
2261 case D3DXPC_STRUCT:
2262 break;
2264 default:
2265 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2266 break;
2270 WARN("Invalid argument specified\n");
2272 return D3DERR_INVALIDCALL;
2275 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2277 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2279 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2281 return E_NOTIMPL;
2284 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2286 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2287 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2289 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2291 if (!count) return D3D_OK;
2293 if (matrix && param && count <= param->element_count)
2295 UINT i;
2297 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2299 switch (param->class)
2301 case D3DXPC_MATRIX_ROWS:
2302 for (i = 0; i < count; ++i)
2304 D3DXMATRIX m;
2306 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2307 D3DXMatrixTranspose(&matrix[i], &m);
2309 return D3D_OK;
2311 case D3DXPC_SCALAR:
2312 case D3DXPC_VECTOR:
2313 case D3DXPC_OBJECT:
2314 case D3DXPC_STRUCT:
2315 break;
2317 default:
2318 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2319 break;
2323 WARN("Invalid argument specified\n");
2325 return D3DERR_INVALIDCALL;
2328 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2330 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2332 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2334 return E_NOTIMPL;
2337 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2339 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2341 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
2343 return E_NOTIMPL;
2346 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2348 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2350 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2352 return E_NOTIMPL;
2355 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2357 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2358 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2360 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2362 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2364 *string = *(LPCSTR *)param->data;
2365 TRACE("Returning %s\n", debugstr_a(*string));
2366 return D3D_OK;
2369 WARN("Invalid argument specified\n");
2371 return D3DERR_INVALIDCALL;
2374 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2376 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2377 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2379 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2381 if (param && !param->element_count &&
2382 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2383 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2384 || param->type == D3DXPT_TEXTURECUBE))
2386 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2388 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2389 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2391 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2393 return D3D_OK;
2396 WARN("Invalid argument specified\n");
2398 return D3DERR_INVALIDCALL;
2401 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2403 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2404 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2406 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2408 if (texture && param && !param->element_count &&
2409 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2410 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2411 || param->type == D3DXPT_TEXTURECUBE))
2413 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2414 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2415 TRACE("Returning %p\n", *texture);
2416 return D3D_OK;
2419 WARN("Invalid argument specified\n");
2421 return D3DERR_INVALIDCALL;
2424 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2426 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2427 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2429 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2431 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2433 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2434 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2435 TRACE("Returning %p\n", *pshader);
2436 return D3D_OK;
2439 WARN("Invalid argument specified\n");
2441 return D3DERR_INVALIDCALL;
2444 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2446 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2447 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2449 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2451 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2453 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2454 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2455 TRACE("Returning %p\n", *vshader);
2456 return D3D_OK;
2459 WARN("Invalid argument specified\n");
2461 return D3DERR_INVALIDCALL;
2464 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2466 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2468 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2470 return E_NOTIMPL;
2473 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2475 /*** IUnknown methods ***/
2476 ID3DXBaseEffectImpl_QueryInterface,
2477 ID3DXBaseEffectImpl_AddRef,
2478 ID3DXBaseEffectImpl_Release,
2479 /*** ID3DXBaseEffect methods ***/
2480 ID3DXBaseEffectImpl_GetDesc,
2481 ID3DXBaseEffectImpl_GetParameterDesc,
2482 ID3DXBaseEffectImpl_GetTechniqueDesc,
2483 ID3DXBaseEffectImpl_GetPassDesc,
2484 ID3DXBaseEffectImpl_GetFunctionDesc,
2485 ID3DXBaseEffectImpl_GetParameter,
2486 ID3DXBaseEffectImpl_GetParameterByName,
2487 ID3DXBaseEffectImpl_GetParameterBySemantic,
2488 ID3DXBaseEffectImpl_GetParameterElement,
2489 ID3DXBaseEffectImpl_GetTechnique,
2490 ID3DXBaseEffectImpl_GetTechniqueByName,
2491 ID3DXBaseEffectImpl_GetPass,
2492 ID3DXBaseEffectImpl_GetPassByName,
2493 ID3DXBaseEffectImpl_GetFunction,
2494 ID3DXBaseEffectImpl_GetFunctionByName,
2495 ID3DXBaseEffectImpl_GetAnnotation,
2496 ID3DXBaseEffectImpl_GetAnnotationByName,
2497 ID3DXBaseEffectImpl_SetValue,
2498 ID3DXBaseEffectImpl_GetValue,
2499 ID3DXBaseEffectImpl_SetBool,
2500 ID3DXBaseEffectImpl_GetBool,
2501 ID3DXBaseEffectImpl_SetBoolArray,
2502 ID3DXBaseEffectImpl_GetBoolArray,
2503 ID3DXBaseEffectImpl_SetInt,
2504 ID3DXBaseEffectImpl_GetInt,
2505 ID3DXBaseEffectImpl_SetIntArray,
2506 ID3DXBaseEffectImpl_GetIntArray,
2507 ID3DXBaseEffectImpl_SetFloat,
2508 ID3DXBaseEffectImpl_GetFloat,
2509 ID3DXBaseEffectImpl_SetFloatArray,
2510 ID3DXBaseEffectImpl_GetFloatArray,
2511 ID3DXBaseEffectImpl_SetVector,
2512 ID3DXBaseEffectImpl_GetVector,
2513 ID3DXBaseEffectImpl_SetVectorArray,
2514 ID3DXBaseEffectImpl_GetVectorArray,
2515 ID3DXBaseEffectImpl_SetMatrix,
2516 ID3DXBaseEffectImpl_GetMatrix,
2517 ID3DXBaseEffectImpl_SetMatrixArray,
2518 ID3DXBaseEffectImpl_GetMatrixArray,
2519 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2520 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2521 ID3DXBaseEffectImpl_SetMatrixTranspose,
2522 ID3DXBaseEffectImpl_GetMatrixTranspose,
2523 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2524 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2525 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2526 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2527 ID3DXBaseEffectImpl_SetString,
2528 ID3DXBaseEffectImpl_GetString,
2529 ID3DXBaseEffectImpl_SetTexture,
2530 ID3DXBaseEffectImpl_GetTexture,
2531 ID3DXBaseEffectImpl_GetPixelShader,
2532 ID3DXBaseEffectImpl_GetVertexShader,
2533 ID3DXBaseEffectImpl_SetArrayRange,
2536 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2538 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2541 /*** IUnknown methods ***/
2542 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2544 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2546 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
2548 if (IsEqualGUID(riid, &IID_IUnknown) ||
2549 IsEqualGUID(riid, &IID_ID3DXEffect))
2551 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
2552 *object = This;
2553 return S_OK;
2556 ERR("Interface %s not found\n", debugstr_guid(riid));
2558 return E_NOINTERFACE;
2561 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2563 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2565 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2567 return InterlockedIncrement(&This->ref);
2570 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2572 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2573 ULONG ref = InterlockedDecrement(&This->ref);
2575 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2577 if (!ref)
2579 free_effect(This);
2580 HeapFree(GetProcessHeap(), 0, This);
2583 return ref;
2586 /*** ID3DXBaseEffect methods ***/
2587 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2589 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2590 ID3DXBaseEffect *base = This->base_effect;
2592 TRACE("Forward iface %p, base %p\n", This, base);
2594 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2597 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2599 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2600 ID3DXBaseEffect *base = This->base_effect;
2602 TRACE("Forward iface %p, base %p\n", This, base);
2604 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2607 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2609 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2610 ID3DXBaseEffect *base = This->base_effect;
2612 TRACE("Forward iface %p, base %p\n", This, base);
2614 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2617 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2619 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2620 ID3DXBaseEffect *base = This->base_effect;
2622 TRACE("Forward iface %p, base %p\n", This, base);
2624 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2627 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2629 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2630 ID3DXBaseEffect *base = This->base_effect;
2632 TRACE("Forward iface %p, base %p\n", This, base);
2634 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2637 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2639 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2640 ID3DXBaseEffect *base = This->base_effect;
2642 TRACE("Forward iface %p, base %p\n", This, base);
2644 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2647 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2649 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2650 ID3DXBaseEffect *base = This->base_effect;
2652 TRACE("Forward iface %p, base %p\n", This, base);
2654 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2657 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2659 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2660 ID3DXBaseEffect *base = This->base_effect;
2662 TRACE("Forward iface %p, base %p\n", This, base);
2664 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2667 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2669 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2670 ID3DXBaseEffect *base = This->base_effect;
2672 TRACE("Forward iface %p, base %p\n", This, base);
2674 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2677 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2679 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2680 ID3DXBaseEffect *base = This->base_effect;
2682 TRACE("Forward iface %p, base %p\n", This, base);
2684 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2687 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2689 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2690 ID3DXBaseEffect *base = This->base_effect;
2692 TRACE("Forward iface %p, base %p\n", This, base);
2694 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2697 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2699 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2700 ID3DXBaseEffect *base = This->base_effect;
2702 TRACE("Forward iface %p, base %p\n", This, base);
2704 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2707 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2709 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2710 ID3DXBaseEffect *base = This->base_effect;
2712 TRACE("Forward iface %p, base %p\n", This, base);
2714 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2717 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2719 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2720 ID3DXBaseEffect *base = This->base_effect;
2722 TRACE("Forward iface %p, base %p\n", This, base);
2724 return ID3DXBaseEffectImpl_GetFunction(base, index);
2727 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
2729 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2730 ID3DXBaseEffect *base = This->base_effect;
2732 TRACE("Forward iface %p, base %p\n", This, base);
2734 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2737 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
2739 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2740 ID3DXBaseEffect *base = This->base_effect;
2742 TRACE("Forward iface %p, base %p\n", This, base);
2744 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2747 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
2749 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2750 ID3DXBaseEffect *base = This->base_effect;
2752 TRACE("Forward iface %p, base %p\n", This, base);
2754 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2757 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2759 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2760 ID3DXBaseEffect *base = This->base_effect;
2762 TRACE("Forward iface %p, base %p\n", This, base);
2764 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2767 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2769 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2770 ID3DXBaseEffect *base = This->base_effect;
2772 TRACE("Forward iface %p, base %p\n", This, base);
2774 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2777 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
2779 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2780 ID3DXBaseEffect *base = This->base_effect;
2782 TRACE("Forward iface %p, base %p\n", This, base);
2784 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2787 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
2789 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2790 ID3DXBaseEffect *base = This->base_effect;
2792 TRACE("Forward iface %p, base %p\n", This, base);
2794 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2797 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2799 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2800 ID3DXBaseEffect *base = This->base_effect;
2802 TRACE("Forward iface %p, base %p\n", This, base);
2804 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2807 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2809 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2810 ID3DXBaseEffect *base = This->base_effect;
2812 TRACE("Forward iface %p, base %p\n", This, base);
2814 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2817 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
2819 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2820 ID3DXBaseEffect *base = This->base_effect;
2822 TRACE("Forward iface %p, base %p\n", This, base);
2824 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2827 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2829 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2830 ID3DXBaseEffect *base = This->base_effect;
2832 TRACE("Forward iface %p, base %p\n", This, base);
2834 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2837 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2839 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2840 ID3DXBaseEffect *base = This->base_effect;
2842 TRACE("Forward iface %p, base %p\n", This, base);
2844 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2847 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2849 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2850 ID3DXBaseEffect *base = This->base_effect;
2852 TRACE("Forward iface %p, base %p\n", This, base);
2854 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2857 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2859 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2860 ID3DXBaseEffect *base = This->base_effect;
2862 TRACE("Forward iface %p, base %p\n", This, base);
2864 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2867 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2869 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2870 ID3DXBaseEffect *base = This->base_effect;
2872 TRACE("Forward iface %p, base %p\n", This, base);
2874 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2877 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2879 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2880 ID3DXBaseEffect *base = This->base_effect;
2882 TRACE("Forward iface %p, base %p\n", This, base);
2884 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2887 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2889 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2890 ID3DXBaseEffect *base = This->base_effect;
2892 TRACE("Forward iface %p, base %p\n", This, base);
2894 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2897 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2899 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2900 ID3DXBaseEffect *base = This->base_effect;
2902 TRACE("Forward iface %p, base %p\n", This, base);
2904 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2907 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2909 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2910 ID3DXBaseEffect *base = This->base_effect;
2912 TRACE("Forward iface %p, base %p\n", This, base);
2914 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2917 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2919 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2920 ID3DXBaseEffect *base = This->base_effect;
2922 TRACE("Forward iface %p, base %p\n", This, base);
2924 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2927 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2929 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2930 ID3DXBaseEffect *base = This->base_effect;
2932 TRACE("Forward iface %p, base %p\n", This, base);
2934 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2937 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2939 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2940 ID3DXBaseEffect *base = This->base_effect;
2942 TRACE("Forward iface %p, base %p\n", This, base);
2944 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2947 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2949 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2950 ID3DXBaseEffect *base = This->base_effect;
2952 TRACE("Forward iface %p, base %p\n", This, base);
2954 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2957 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2959 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2960 ID3DXBaseEffect *base = This->base_effect;
2962 TRACE("Forward iface %p, base %p\n", This, base);
2964 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2967 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2969 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2970 ID3DXBaseEffect *base = This->base_effect;
2972 TRACE("Forward iface %p, base %p\n", This, base);
2974 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2977 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2979 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2980 ID3DXBaseEffect *base = This->base_effect;
2982 TRACE("Forward iface %p, base %p\n", This, base);
2984 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2987 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2989 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2990 ID3DXBaseEffect *base = This->base_effect;
2992 TRACE("Forward iface %p, base %p\n", This, base);
2994 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2997 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2999 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3000 ID3DXBaseEffect *base = This->base_effect;
3002 TRACE("Forward iface %p, base %p\n", This, base);
3004 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3007 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3009 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3010 ID3DXBaseEffect *base = This->base_effect;
3012 TRACE("Forward iface %p, base %p\n", This, base);
3014 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3017 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3019 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3020 ID3DXBaseEffect *base = This->base_effect;
3022 TRACE("Forward iface %p, base %p\n", This, base);
3024 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3027 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3029 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3030 ID3DXBaseEffect *base = This->base_effect;
3032 TRACE("Forward iface %p, base %p\n", This, base);
3034 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3037 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3039 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3040 ID3DXBaseEffect *base = This->base_effect;
3042 TRACE("Forward iface %p, base %p\n", This, base);
3044 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3047 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3049 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3050 ID3DXBaseEffect *base = This->base_effect;
3052 TRACE("Forward iface %p, base %p\n", This, base);
3054 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3057 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
3059 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3060 ID3DXBaseEffect *base = This->base_effect;
3062 TRACE("Forward iface %p, base %p\n", This, base);
3064 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3067 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3069 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3070 ID3DXBaseEffect *base = This->base_effect;
3072 TRACE("Forward iface %p, base %p\n", This, base);
3074 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3077 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3079 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3080 ID3DXBaseEffect *base = This->base_effect;
3082 TRACE("Forward iface %p, base %p\n", This, base);
3084 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3087 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3089 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3090 ID3DXBaseEffect *base = This->base_effect;
3092 TRACE("Forward iface %p, base %p\n", This, base);
3094 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3097 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3099 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3100 ID3DXBaseEffect *base = This->base_effect;
3102 TRACE("Forward iface %p, base %p\n", This, base);
3104 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3107 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3109 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3110 ID3DXBaseEffect *base = This->base_effect;
3112 TRACE("Forward iface %p, base %p\n", This, base);
3114 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3117 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3119 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3120 ID3DXBaseEffect *base = This->base_effect;
3122 TRACE("Forward iface %p, base %p\n", This, base);
3124 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3127 /*** ID3DXEffect methods ***/
3128 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
3130 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3132 TRACE("iface %p, pool %p\n", This, pool);
3134 if (!pool)
3136 WARN("Invalid argument supplied.\n");
3137 return D3DERR_INVALIDCALL;
3140 if (This->pool)
3142 This->pool->lpVtbl->AddRef(This->pool);
3145 *pool = This->pool;
3147 TRACE("Returning pool %p\n", *pool);
3149 return S_OK;
3152 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3154 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3155 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3156 struct d3dx_technique *tech = is_valid_technique(base, technique);
3158 TRACE("iface %p, technique %p\n", This, technique);
3160 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
3162 if (tech)
3164 UINT i;
3166 for (i = 0; i < base->technique_count; ++i)
3168 struct d3dx_technique *t = get_technique_struct(base->technique_handles[i]);
3170 if (tech == t)
3172 This->active_technique = get_technique_handle(t);
3173 TRACE("Technique %u (%p)\n", i, tech);
3174 return D3D_OK;
3179 WARN("Invalid argument supplied.\n");
3181 return D3DERR_INVALIDCALL;
3184 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3186 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3188 TRACE("iface %p\n", This);
3190 return This->active_technique;
3193 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3195 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3197 FIXME("(%p)->(%p): stub\n", This, technique);
3199 return D3D_OK;
3202 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3204 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3206 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3208 return E_NOTIMPL;
3211 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3213 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3215 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3217 return FALSE;
3220 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3222 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3223 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3225 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3227 if (passes && technique)
3229 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3231 TRACE("State capturing disabled.\n");
3233 else
3235 FIXME("State capturing not supported, yet!\n");
3238 *passes = technique->pass_count;
3240 return D3D_OK;
3243 WARN("Invalid argument supplied.\n");
3245 return D3DERR_INVALIDCALL;
3248 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3250 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3251 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3253 TRACE("iface %p, pass %u\n", This, pass);
3255 if (technique && pass < technique->pass_count && !This->active_pass)
3257 This->active_pass = technique->pass_handles[pass];
3259 FIXME("No states applied, yet!\n");
3261 return D3D_OK;
3264 WARN("Invalid argument supplied.\n");
3266 return D3DERR_INVALIDCALL;
3269 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3271 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3273 FIXME("(%p)->(): stub\n", This);
3275 return E_NOTIMPL;
3278 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3280 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3282 TRACE("iface %p\n", This);
3284 if (This->active_pass)
3286 This->active_pass = NULL;
3287 return D3D_OK;
3290 WARN("Invalid call.\n");
3292 return D3DERR_INVALIDCALL;
3295 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3297 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3299 FIXME("(%p)->(): stub\n", This);
3301 return E_NOTIMPL;
3304 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3306 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3308 TRACE("iface %p, device %p\n", This, device);
3310 if (!device)
3312 WARN("Invalid argument supplied.\n");
3313 return D3DERR_INVALIDCALL;
3316 IDirect3DDevice9_AddRef(This->device);
3318 *device = This->device;
3320 TRACE("Returning device %p\n", *device);
3322 return S_OK;
3325 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3327 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3329 FIXME("(%p)->(): stub\n", This);
3331 return E_NOTIMPL;
3334 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3336 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3338 FIXME("(%p)->(): stub\n", This);
3340 return E_NOTIMPL;
3343 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3345 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3347 TRACE("iface %p, manager %p\n", This, manager);
3349 if (manager) IUnknown_AddRef(manager);
3350 if (This->manager) IUnknown_Release(This->manager);
3352 This->manager = manager;
3354 return D3D_OK;
3357 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3359 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3361 TRACE("iface %p, manager %p\n", This, manager);
3363 if (!manager)
3365 WARN("Invalid argument supplied.\n");
3366 return D3DERR_INVALIDCALL;
3369 if (This->manager) IUnknown_AddRef(This->manager);
3370 *manager = This->manager;
3372 return D3D_OK;
3375 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3377 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3379 FIXME("(%p)->(): stub\n", This);
3381 return E_NOTIMPL;
3384 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3386 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3388 FIXME("(%p)->(): stub\n", This);
3390 return NULL;
3393 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3395 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3397 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3399 return E_NOTIMPL;
3402 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3404 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3406 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3408 return E_NOTIMPL;
3411 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3413 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3415 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3417 return E_NOTIMPL;
3420 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3422 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3424 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3426 return E_NOTIMPL;
3429 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3431 /*** IUnknown methods ***/
3432 ID3DXEffectImpl_QueryInterface,
3433 ID3DXEffectImpl_AddRef,
3434 ID3DXEffectImpl_Release,
3435 /*** ID3DXBaseEffect methods ***/
3436 ID3DXEffectImpl_GetDesc,
3437 ID3DXEffectImpl_GetParameterDesc,
3438 ID3DXEffectImpl_GetTechniqueDesc,
3439 ID3DXEffectImpl_GetPassDesc,
3440 ID3DXEffectImpl_GetFunctionDesc,
3441 ID3DXEffectImpl_GetParameter,
3442 ID3DXEffectImpl_GetParameterByName,
3443 ID3DXEffectImpl_GetParameterBySemantic,
3444 ID3DXEffectImpl_GetParameterElement,
3445 ID3DXEffectImpl_GetTechnique,
3446 ID3DXEffectImpl_GetTechniqueByName,
3447 ID3DXEffectImpl_GetPass,
3448 ID3DXEffectImpl_GetPassByName,
3449 ID3DXEffectImpl_GetFunction,
3450 ID3DXEffectImpl_GetFunctionByName,
3451 ID3DXEffectImpl_GetAnnotation,
3452 ID3DXEffectImpl_GetAnnotationByName,
3453 ID3DXEffectImpl_SetValue,
3454 ID3DXEffectImpl_GetValue,
3455 ID3DXEffectImpl_SetBool,
3456 ID3DXEffectImpl_GetBool,
3457 ID3DXEffectImpl_SetBoolArray,
3458 ID3DXEffectImpl_GetBoolArray,
3459 ID3DXEffectImpl_SetInt,
3460 ID3DXEffectImpl_GetInt,
3461 ID3DXEffectImpl_SetIntArray,
3462 ID3DXEffectImpl_GetIntArray,
3463 ID3DXEffectImpl_SetFloat,
3464 ID3DXEffectImpl_GetFloat,
3465 ID3DXEffectImpl_SetFloatArray,
3466 ID3DXEffectImpl_GetFloatArray,
3467 ID3DXEffectImpl_SetVector,
3468 ID3DXEffectImpl_GetVector,
3469 ID3DXEffectImpl_SetVectorArray,
3470 ID3DXEffectImpl_GetVectorArray,
3471 ID3DXEffectImpl_SetMatrix,
3472 ID3DXEffectImpl_GetMatrix,
3473 ID3DXEffectImpl_SetMatrixArray,
3474 ID3DXEffectImpl_GetMatrixArray,
3475 ID3DXEffectImpl_SetMatrixPointerArray,
3476 ID3DXEffectImpl_GetMatrixPointerArray,
3477 ID3DXEffectImpl_SetMatrixTranspose,
3478 ID3DXEffectImpl_GetMatrixTranspose,
3479 ID3DXEffectImpl_SetMatrixTransposeArray,
3480 ID3DXEffectImpl_GetMatrixTransposeArray,
3481 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3482 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3483 ID3DXEffectImpl_SetString,
3484 ID3DXEffectImpl_GetString,
3485 ID3DXEffectImpl_SetTexture,
3486 ID3DXEffectImpl_GetTexture,
3487 ID3DXEffectImpl_GetPixelShader,
3488 ID3DXEffectImpl_GetVertexShader,
3489 ID3DXEffectImpl_SetArrayRange,
3490 /*** ID3DXEffect methods ***/
3491 ID3DXEffectImpl_GetPool,
3492 ID3DXEffectImpl_SetTechnique,
3493 ID3DXEffectImpl_GetCurrentTechnique,
3494 ID3DXEffectImpl_ValidateTechnique,
3495 ID3DXEffectImpl_FindNextValidTechnique,
3496 ID3DXEffectImpl_IsParameterUsed,
3497 ID3DXEffectImpl_Begin,
3498 ID3DXEffectImpl_BeginPass,
3499 ID3DXEffectImpl_CommitChanges,
3500 ID3DXEffectImpl_EndPass,
3501 ID3DXEffectImpl_End,
3502 ID3DXEffectImpl_GetDevice,
3503 ID3DXEffectImpl_OnLostDevice,
3504 ID3DXEffectImpl_OnResetDevice,
3505 ID3DXEffectImpl_SetStateManager,
3506 ID3DXEffectImpl_GetStateManager,
3507 ID3DXEffectImpl_BeginParameterBlock,
3508 ID3DXEffectImpl_EndParameterBlock,
3509 ID3DXEffectImpl_ApplyParameterBlock,
3510 ID3DXEffectImpl_DeleteParameterBlock,
3511 ID3DXEffectImpl_CloneEffect,
3512 ID3DXEffectImpl_SetRawValue
3515 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3517 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3520 /*** IUnknown methods ***/
3521 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3523 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3525 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
3527 if (IsEqualGUID(riid, &IID_IUnknown) ||
3528 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3530 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
3531 *object = This;
3532 return S_OK;
3535 ERR("Interface %s not found\n", debugstr_guid(riid));
3537 return E_NOINTERFACE;
3540 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3542 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3544 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3546 return InterlockedIncrement(&This->ref);
3549 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3551 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3552 ULONG ref = InterlockedDecrement(&This->ref);
3554 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3556 if (!ref)
3558 free_effect_compiler(This);
3559 HeapFree(GetProcessHeap(), 0, This);
3562 return ref;
3565 /*** ID3DXBaseEffect methods ***/
3566 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3568 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3569 ID3DXBaseEffect *base = This->base_effect;
3571 TRACE("Forward iface %p, base %p\n", This, base);
3573 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3576 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3578 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3579 ID3DXBaseEffect *base = This->base_effect;
3581 TRACE("Forward iface %p, base %p\n", This, base);
3583 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3586 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3588 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3589 ID3DXBaseEffect *base = This->base_effect;
3591 TRACE("Forward iface %p, base %p\n", This, base);
3593 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3596 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3598 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3599 ID3DXBaseEffect *base = This->base_effect;
3601 TRACE("Forward iface %p, base %p\n", This, base);
3603 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3606 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3608 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3609 ID3DXBaseEffect *base = This->base_effect;
3611 TRACE("Forward iface %p, base %p\n", This, base);
3613 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3616 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3618 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3619 ID3DXBaseEffect *base = This->base_effect;
3621 TRACE("Forward iface %p, base %p\n", This, base);
3623 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3626 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3628 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3629 ID3DXBaseEffect *base = This->base_effect;
3631 TRACE("Forward iface %p, base %p\n", This, base);
3633 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3636 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3638 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3639 ID3DXBaseEffect *base = This->base_effect;
3641 TRACE("Forward iface %p, base %p\n", This, base);
3643 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3646 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3648 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3649 ID3DXBaseEffect *base = This->base_effect;
3651 TRACE("Forward iface %p, base %p\n", This, base);
3653 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3656 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3658 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3659 ID3DXBaseEffect *base = This->base_effect;
3661 TRACE("Forward iface %p, base %p\n", This, base);
3663 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3666 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3668 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3669 ID3DXBaseEffect *base = This->base_effect;
3671 TRACE("Forward iface %p, base %p\n", This, base);
3673 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3676 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3678 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3679 ID3DXBaseEffect *base = This->base_effect;
3681 TRACE("Forward iface %p, base %p\n", This, base);
3683 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3686 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3688 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3689 ID3DXBaseEffect *base = This->base_effect;
3691 TRACE("Forward iface %p, base %p\n", This, base);
3693 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3696 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3698 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3699 ID3DXBaseEffect *base = This->base_effect;
3701 TRACE("Forward iface %p, base %p\n", This, base);
3703 return ID3DXBaseEffectImpl_GetFunction(base, index);
3706 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3708 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3709 ID3DXBaseEffect *base = This->base_effect;
3711 TRACE("Forward iface %p, base %p\n", This, base);
3713 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3716 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3718 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3719 ID3DXBaseEffect *base = This->base_effect;
3721 TRACE("Forward iface %p, base %p\n", This, base);
3723 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3726 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3728 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3729 ID3DXBaseEffect *base = This->base_effect;
3731 TRACE("Forward iface %p, base %p\n", This, base);
3733 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3736 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3738 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3739 ID3DXBaseEffect *base = This->base_effect;
3741 TRACE("Forward iface %p, base %p\n", This, base);
3743 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3746 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3748 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3749 ID3DXBaseEffect *base = This->base_effect;
3751 TRACE("Forward iface %p, base %p\n", This, base);
3753 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3756 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
3758 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3759 ID3DXBaseEffect *base = This->base_effect;
3761 TRACE("Forward iface %p, base %p\n", This, base);
3763 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3766 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
3768 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3769 ID3DXBaseEffect *base = This->base_effect;
3771 TRACE("Forward iface %p, base %p\n", This, base);
3773 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3776 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3778 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3779 ID3DXBaseEffect *base = This->base_effect;
3781 TRACE("Forward iface %p, base %p\n", This, base);
3783 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3786 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3788 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3789 ID3DXBaseEffect *base = This->base_effect;
3791 TRACE("Forward iface %p, base %p\n", This, base);
3793 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3796 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
3798 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3799 ID3DXBaseEffect *base = This->base_effect;
3801 TRACE("Forward iface %p, base %p\n", This, base);
3803 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3806 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
3808 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3809 ID3DXBaseEffect *base = This->base_effect;
3811 TRACE("Forward iface %p, base %p\n", This, base);
3813 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3816 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3818 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3819 ID3DXBaseEffect *base = This->base_effect;
3821 TRACE("Forward iface %p, base %p\n", This, base);
3823 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3826 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
3828 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3829 ID3DXBaseEffect *base = This->base_effect;
3831 TRACE("Forward iface %p, base %p\n", This, base);
3833 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3836 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
3838 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3839 ID3DXBaseEffect *base = This->base_effect;
3841 TRACE("Forward iface %p, base %p\n", This, base);
3843 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3846 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
3848 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3849 ID3DXBaseEffect *base = This->base_effect;
3851 TRACE("Forward iface %p, base %p\n", This, base);
3853 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3856 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3858 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3859 ID3DXBaseEffect *base = This->base_effect;
3861 TRACE("Forward iface %p, base %p\n", This, base);
3863 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3866 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3868 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3869 ID3DXBaseEffect *base = This->base_effect;
3871 TRACE("Forward iface %p, base %p\n", This, base);
3873 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3876 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3878 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3879 ID3DXBaseEffect *base = This->base_effect;
3881 TRACE("Forward iface %p, base %p\n", This, base);
3883 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3886 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3888 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3889 ID3DXBaseEffect *base = This->base_effect;
3891 TRACE("Forward iface %p, base %p\n", This, base);
3893 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3896 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3898 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3899 ID3DXBaseEffect *base = This->base_effect;
3901 TRACE("Forward iface %p, base %p\n", This, base);
3903 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3906 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3908 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3909 ID3DXBaseEffect *base = This->base_effect;
3911 TRACE("Forward iface %p, base %p\n", This, base);
3913 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3916 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3918 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3919 ID3DXBaseEffect *base = This->base_effect;
3921 TRACE("Forward iface %p, base %p\n", This, base);
3923 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3926 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3928 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3929 ID3DXBaseEffect *base = This->base_effect;
3931 TRACE("Forward iface %p, base %p\n", This, base);
3933 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3936 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3938 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3939 ID3DXBaseEffect *base = This->base_effect;
3941 TRACE("Forward iface %p, base %p\n", This, base);
3943 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3946 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3948 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3949 ID3DXBaseEffect *base = This->base_effect;
3951 TRACE("Forward iface %p, base %p\n", This, base);
3953 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3956 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3958 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3959 ID3DXBaseEffect *base = This->base_effect;
3961 TRACE("Forward iface %p, base %p\n", This, base);
3963 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3966 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3968 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3969 ID3DXBaseEffect *base = This->base_effect;
3971 TRACE("Forward iface %p, base %p\n", This, base);
3973 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3976 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3978 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3979 ID3DXBaseEffect *base = This->base_effect;
3981 TRACE("Forward iface %p, base %p\n", This, base);
3983 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3986 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3988 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3989 ID3DXBaseEffect *base = This->base_effect;
3991 TRACE("Forward iface %p, base %p\n", This, base);
3993 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3996 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3998 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3999 ID3DXBaseEffect *base = This->base_effect;
4001 TRACE("Forward iface %p, base %p\n", This, base);
4003 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
4006 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4008 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4009 ID3DXBaseEffect *base = This->base_effect;
4011 TRACE("Forward iface %p, base %p\n", This, base);
4013 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
4016 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4018 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4019 ID3DXBaseEffect *base = This->base_effect;
4021 TRACE("Forward iface %p, base %p\n", This, base);
4023 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
4026 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4028 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4029 ID3DXBaseEffect *base = This->base_effect;
4031 TRACE("Forward iface %p, base %p\n", This, base);
4033 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
4036 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
4038 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4039 ID3DXBaseEffect *base = This->base_effect;
4041 TRACE("Forward iface %p, base %p\n", This, base);
4043 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
4046 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
4048 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4049 ID3DXBaseEffect *base = This->base_effect;
4051 TRACE("Forward iface %p, base %p\n", This, base);
4053 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
4056 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
4058 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4059 ID3DXBaseEffect *base = This->base_effect;
4061 TRACE("Forward iface %p, base %p\n", This, base);
4063 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
4066 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
4068 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4069 ID3DXBaseEffect *base = This->base_effect;
4071 TRACE("Forward iface %p, base %p\n", This, base);
4073 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4076 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
4078 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4079 ID3DXBaseEffect *base = This->base_effect;
4081 TRACE("Forward iface %p, base %p\n", This, base);
4083 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
4086 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
4088 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4089 ID3DXBaseEffect *base = This->base_effect;
4091 TRACE("Forward iface %p, base %p\n", This, base);
4093 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
4096 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4098 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4099 ID3DXBaseEffect *base = This->base_effect;
4101 TRACE("Forward iface %p, base %p\n", This, base);
4103 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4106 /*** ID3DXEffectCompiler methods ***/
4107 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4109 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4111 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4113 return E_NOTIMPL;
4116 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4118 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4120 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4122 return E_NOTIMPL;
4125 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4126 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
4128 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4130 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4132 return E_NOTIMPL;
4135 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4136 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
4138 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4140 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4141 This, function, target, flags, shader, error_msgs, constant_table);
4143 return E_NOTIMPL;
4146 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4148 /*** IUnknown methods ***/
4149 ID3DXEffectCompilerImpl_QueryInterface,
4150 ID3DXEffectCompilerImpl_AddRef,
4151 ID3DXEffectCompilerImpl_Release,
4152 /*** ID3DXBaseEffect methods ***/
4153 ID3DXEffectCompilerImpl_GetDesc,
4154 ID3DXEffectCompilerImpl_GetParameterDesc,
4155 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4156 ID3DXEffectCompilerImpl_GetPassDesc,
4157 ID3DXEffectCompilerImpl_GetFunctionDesc,
4158 ID3DXEffectCompilerImpl_GetParameter,
4159 ID3DXEffectCompilerImpl_GetParameterByName,
4160 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4161 ID3DXEffectCompilerImpl_GetParameterElement,
4162 ID3DXEffectCompilerImpl_GetTechnique,
4163 ID3DXEffectCompilerImpl_GetTechniqueByName,
4164 ID3DXEffectCompilerImpl_GetPass,
4165 ID3DXEffectCompilerImpl_GetPassByName,
4166 ID3DXEffectCompilerImpl_GetFunction,
4167 ID3DXEffectCompilerImpl_GetFunctionByName,
4168 ID3DXEffectCompilerImpl_GetAnnotation,
4169 ID3DXEffectCompilerImpl_GetAnnotationByName,
4170 ID3DXEffectCompilerImpl_SetValue,
4171 ID3DXEffectCompilerImpl_GetValue,
4172 ID3DXEffectCompilerImpl_SetBool,
4173 ID3DXEffectCompilerImpl_GetBool,
4174 ID3DXEffectCompilerImpl_SetBoolArray,
4175 ID3DXEffectCompilerImpl_GetBoolArray,
4176 ID3DXEffectCompilerImpl_SetInt,
4177 ID3DXEffectCompilerImpl_GetInt,
4178 ID3DXEffectCompilerImpl_SetIntArray,
4179 ID3DXEffectCompilerImpl_GetIntArray,
4180 ID3DXEffectCompilerImpl_SetFloat,
4181 ID3DXEffectCompilerImpl_GetFloat,
4182 ID3DXEffectCompilerImpl_SetFloatArray,
4183 ID3DXEffectCompilerImpl_GetFloatArray,
4184 ID3DXEffectCompilerImpl_SetVector,
4185 ID3DXEffectCompilerImpl_GetVector,
4186 ID3DXEffectCompilerImpl_SetVectorArray,
4187 ID3DXEffectCompilerImpl_GetVectorArray,
4188 ID3DXEffectCompilerImpl_SetMatrix,
4189 ID3DXEffectCompilerImpl_GetMatrix,
4190 ID3DXEffectCompilerImpl_SetMatrixArray,
4191 ID3DXEffectCompilerImpl_GetMatrixArray,
4192 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4193 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4194 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4195 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4196 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4197 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4198 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4199 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4200 ID3DXEffectCompilerImpl_SetString,
4201 ID3DXEffectCompilerImpl_GetString,
4202 ID3DXEffectCompilerImpl_SetTexture,
4203 ID3DXEffectCompilerImpl_GetTexture,
4204 ID3DXEffectCompilerImpl_GetPixelShader,
4205 ID3DXEffectCompilerImpl_GetVertexShader,
4206 ID3DXEffectCompilerImpl_SetArrayRange,
4207 /*** ID3DXEffectCompiler methods ***/
4208 ID3DXEffectCompilerImpl_SetLiteral,
4209 ID3DXEffectCompilerImpl_GetLiteral,
4210 ID3DXEffectCompilerImpl_CompileEffect,
4211 ID3DXEffectCompilerImpl_CompileShader,
4214 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4216 HRESULT hr;
4217 UINT i;
4218 struct d3dx_state *states;
4220 read_dword(ptr, &sampler->state_count);
4221 TRACE("Count: %u\n", sampler->state_count);
4223 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4224 if (!states)
4226 ERR("Out of memory\n");
4227 return E_OUTOFMEMORY;
4230 for (i = 0; i < sampler->state_count; ++i)
4232 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4233 if (hr != D3D_OK)
4235 WARN("Failed to parse state\n");
4236 goto err_out;
4240 sampler->states = states;
4242 return D3D_OK;
4244 err_out:
4246 for (i = 0; i < sampler->state_count; ++i)
4248 free_state(&states[i]);
4251 HeapFree(GetProcessHeap(), 0, states);
4253 return hr;
4256 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4258 unsigned int i;
4259 HRESULT hr;
4260 UINT old_size = 0;
4261 DWORD id;
4263 if (param->element_count)
4265 param->data = value;
4267 for (i = 0; i < param->element_count; ++i)
4269 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4271 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4272 if (hr != D3D_OK)
4274 WARN("Failed to parse value\n");
4275 return hr;
4278 old_size += member->bytes;
4281 return D3D_OK;
4284 switch(param->class)
4286 case D3DXPC_SCALAR:
4287 case D3DXPC_VECTOR:
4288 case D3DXPC_MATRIX_ROWS:
4289 case D3DXPC_MATRIX_COLUMNS:
4290 param->data = value;
4291 break;
4293 case D3DXPC_STRUCT:
4294 param->data = value;
4296 for (i = 0; i < param->member_count; ++i)
4298 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4300 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4301 if (hr != D3D_OK)
4303 WARN("Failed to parse value\n");
4304 return hr;
4307 old_size += member->bytes;
4309 break;
4311 case D3DXPC_OBJECT:
4312 switch (param->type)
4314 case D3DXPT_STRING:
4315 case D3DXPT_TEXTURE:
4316 case D3DXPT_TEXTURE1D:
4317 case D3DXPT_TEXTURE2D:
4318 case D3DXPT_TEXTURE3D:
4319 case D3DXPT_TEXTURECUBE:
4320 case D3DXPT_PIXELSHADER:
4321 case D3DXPT_VERTEXSHADER:
4322 read_dword(ptr, &id);
4323 TRACE("Id: %u\n", id);
4324 objects[id] = get_parameter_handle(param);
4325 param->data = value;
4326 break;
4328 case D3DXPT_SAMPLER:
4329 case D3DXPT_SAMPLER1D:
4330 case D3DXPT_SAMPLER2D:
4331 case D3DXPT_SAMPLER3D:
4332 case D3DXPT_SAMPLERCUBE:
4334 struct d3dx_sampler *sampler;
4336 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4337 if (!sampler)
4339 ERR("Out of memory\n");
4340 return E_OUTOFMEMORY;
4343 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4344 if (hr != D3D_OK)
4346 HeapFree(GetProcessHeap(), 0, sampler);
4347 WARN("Failed to parse sampler\n");
4348 return hr;
4351 param->data = sampler;
4352 break;
4355 default:
4356 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4357 break;
4359 break;
4361 default:
4362 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4363 break;
4366 return D3D_OK;
4369 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4371 UINT size = param->bytes;
4372 HRESULT hr;
4373 void *value = NULL;
4375 TRACE("param size: %u\n", size);
4377 if (size)
4379 value = HeapAlloc(GetProcessHeap(), 0, size);
4380 if (!value)
4382 ERR("Failed to allocate data memory.\n");
4383 return E_OUTOFMEMORY;
4386 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4387 memcpy(value, ptr, size);
4390 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4391 if (hr != D3D_OK)
4393 WARN("Failed to parse value\n");
4394 HeapFree(GetProcessHeap(), 0, value);
4395 return hr;
4398 return D3D_OK;
4401 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4403 DWORD size;
4405 read_dword(&ptr, &size);
4406 TRACE("Name size: %#x\n", size);
4408 if (!size)
4410 return D3D_OK;
4413 *name = HeapAlloc(GetProcessHeap(), 0, size);
4414 if (!*name)
4416 ERR("Failed to allocate name memory.\n");
4417 return E_OUTOFMEMORY;
4420 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4421 memcpy(*name, ptr, size);
4423 return D3D_OK;
4426 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4428 DWORD size;
4430 read_dword(ptr, &size);
4431 TRACE("Data size: %#x\n", size);
4433 *str = HeapAlloc(GetProcessHeap(), 0, size);
4434 if (!*str)
4436 ERR("Failed to allocate name memory.\n");
4437 return E_OUTOFMEMORY;
4440 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4441 memcpy(*str, *ptr, size);
4443 *ptr += ((size + 3) & ~3);
4445 return D3D_OK;
4448 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4450 DWORD size;
4451 HRESULT hr;
4453 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4455 read_dword(ptr, &size);
4456 TRACE("Data size: %#x\n", size);
4458 if (!size)
4460 TRACE("Size is 0\n");
4461 *(void **)param->data = NULL;
4462 return D3D_OK;
4465 switch (param->type)
4467 case D3DXPT_STRING:
4468 /* re-read with size (sizeof(DWORD) = 4) */
4469 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4470 if (hr != D3D_OK)
4472 WARN("Failed to parse string data\n");
4473 return hr;
4475 break;
4477 case D3DXPT_VERTEXSHADER:
4478 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4479 if (hr != D3D_OK)
4481 WARN("Failed to create vertex shader\n");
4482 return hr;
4484 break;
4486 case D3DXPT_PIXELSHADER:
4487 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4488 if (hr != D3D_OK)
4490 WARN("Failed to create pixel shader\n");
4491 return hr;
4493 break;
4495 default:
4496 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4497 break;
4501 *ptr += ((size + 3) & ~3);
4503 return D3D_OK;
4506 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4507 struct d3dx_parameter *parent, UINT flags)
4509 DWORD offset;
4510 HRESULT hr;
4511 D3DXHANDLE *member_handles = NULL;
4512 UINT i;
4514 param->flags = flags;
4516 if (!parent)
4518 read_dword(ptr, &param->type);
4519 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4521 read_dword(ptr, &param->class);
4522 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4524 read_dword(ptr, &offset);
4525 TRACE("Type name offset: %#x\n", offset);
4526 hr = d3dx9_parse_name(&param->name, data + offset);
4527 if (hr != D3D_OK)
4529 WARN("Failed to parse name\n");
4530 goto err_out;
4533 read_dword(ptr, &offset);
4534 TRACE("Type semantic offset: %#x\n", offset);
4535 hr = d3dx9_parse_name(&param->semantic, data + offset);
4536 if (hr != D3D_OK)
4538 WARN("Failed to parse semantic\n");
4539 goto err_out;
4542 read_dword(ptr, &param->element_count);
4543 TRACE("Elements: %u\n", param->element_count);
4545 switch (param->class)
4547 case D3DXPC_VECTOR:
4548 read_dword(ptr, &param->columns);
4549 TRACE("Columns: %u\n", param->columns);
4551 read_dword(ptr, &param->rows);
4552 TRACE("Rows: %u\n", param->rows);
4554 /* sizeof(DWORD) * rows * columns */
4555 param->bytes = 4 * param->rows * param->columns;
4556 break;
4558 case D3DXPC_SCALAR:
4559 case D3DXPC_MATRIX_ROWS:
4560 case D3DXPC_MATRIX_COLUMNS:
4561 read_dword(ptr, &param->rows);
4562 TRACE("Rows: %u\n", param->rows);
4564 read_dword(ptr, &param->columns);
4565 TRACE("Columns: %u\n", param->columns);
4567 /* sizeof(DWORD) * rows * columns */
4568 param->bytes = 4 * param->rows * param->columns;
4569 break;
4571 case D3DXPC_STRUCT:
4572 read_dword(ptr, &param->member_count);
4573 TRACE("Members: %u\n", param->member_count);
4574 break;
4576 case D3DXPC_OBJECT:
4577 switch (param->type)
4579 case D3DXPT_STRING:
4580 param->bytes = sizeof(LPCSTR);
4581 break;
4583 case D3DXPT_PIXELSHADER:
4584 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4585 break;
4587 case D3DXPT_VERTEXSHADER:
4588 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4589 break;
4591 case D3DXPT_TEXTURE:
4592 case D3DXPT_TEXTURE1D:
4593 case D3DXPT_TEXTURE2D:
4594 case D3DXPT_TEXTURE3D:
4595 case D3DXPT_TEXTURECUBE:
4596 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4597 break;
4599 case D3DXPT_SAMPLER:
4600 case D3DXPT_SAMPLER1D:
4601 case D3DXPT_SAMPLER2D:
4602 case D3DXPT_SAMPLER3D:
4603 case D3DXPT_SAMPLERCUBE:
4604 param->bytes = 0;
4605 break;
4607 default:
4608 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4609 break;
4611 break;
4613 default:
4614 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4615 break;
4618 else
4620 /* elements */
4621 param->type = parent->type;
4622 param->class = parent->class;
4623 param->name = parent->name;
4624 param->semantic = parent->semantic;
4625 param->element_count = 0;
4626 param->annotation_count = 0;
4627 param->member_count = parent->member_count;
4628 param->bytes = parent->bytes;
4629 param->rows = parent->rows;
4630 param->columns = parent->columns;
4633 if (param->element_count)
4635 unsigned int param_bytes = 0;
4636 const char *save_ptr = *ptr;
4638 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4639 if (!member_handles)
4641 ERR("Out of memory\n");
4642 hr = E_OUTOFMEMORY;
4643 goto err_out;
4646 for (i = 0; i < param->element_count; ++i)
4648 struct d3dx_parameter *member;
4649 *ptr = save_ptr;
4651 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4652 if (!member)
4654 ERR("Out of memory\n");
4655 hr = E_OUTOFMEMORY;
4656 goto err_out;
4659 member_handles[i] = get_parameter_handle(member);
4661 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4662 if (hr != D3D_OK)
4664 WARN("Failed to parse member\n");
4665 goto err_out;
4668 param_bytes += member->bytes;
4671 param->bytes = param_bytes;
4673 else if (param->member_count)
4675 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4676 if (!member_handles)
4678 ERR("Out of memory\n");
4679 hr = E_OUTOFMEMORY;
4680 goto err_out;
4683 for (i = 0; i < param->member_count; ++i)
4685 struct d3dx_parameter *member;
4687 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4688 if (!member)
4690 ERR("Out of memory\n");
4691 hr = E_OUTOFMEMORY;
4692 goto err_out;
4695 member_handles[i] = get_parameter_handle(member);
4697 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4698 if (hr != D3D_OK)
4700 WARN("Failed to parse member\n");
4701 goto err_out;
4704 param->bytes += member->bytes;
4708 param->member_handles = member_handles;
4710 return D3D_OK;
4712 err_out:
4714 if (member_handles)
4716 unsigned int count;
4718 if (param->element_count) count = param->element_count;
4719 else count = param->member_count;
4721 for (i = 0; i < count; ++i)
4723 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4725 HeapFree(GetProcessHeap(), 0, member_handles);
4728 if (!parent)
4730 HeapFree(GetProcessHeap(), 0, param->name);
4731 HeapFree(GetProcessHeap(), 0, param->semantic);
4733 param->name = NULL;
4734 param->semantic = NULL;
4736 return hr;
4739 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4741 DWORD offset;
4742 const char *ptr2;
4743 HRESULT hr;
4745 anno->flags = D3DX_PARAMETER_ANNOTATION;
4747 read_dword(ptr, &offset);
4748 TRACE("Typedef offset: %#x\n", offset);
4749 ptr2 = data + offset;
4750 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
4751 if (hr != D3D_OK)
4753 WARN("Failed to parse type definition\n");
4754 return hr;
4757 read_dword(ptr, &offset);
4758 TRACE("Value offset: %#x\n", offset);
4759 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
4760 if (hr != D3D_OK)
4762 WARN("Failed to parse value\n");
4763 return hr;
4766 return D3D_OK;
4769 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
4771 DWORD offset;
4772 const char *ptr2;
4773 HRESULT hr;
4774 struct d3dx_parameter *parameter;
4776 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4777 if (!parameter)
4779 ERR("Out of memory\n");
4780 return E_OUTOFMEMORY;
4783 state->type = ST_CONSTANT;
4785 read_dword(ptr, &state->operation);
4786 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
4788 read_dword(ptr, &state->index);
4789 TRACE("Index: %#x\n", state->index);
4791 read_dword(ptr, &offset);
4792 TRACE("Typedef offset: %#x\n", offset);
4793 ptr2 = data + offset;
4794 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
4795 if (hr != D3D_OK)
4797 WARN("Failed to parse type definition\n");
4798 goto err_out;
4801 read_dword(ptr, &offset);
4802 TRACE("Value offset: %#x\n", offset);
4803 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
4804 if (hr != D3D_OK)
4806 WARN("Failed to parse value\n");
4807 goto err_out;
4810 state->parameter = get_parameter_handle(parameter);
4812 return D3D_OK;
4814 err_out:
4816 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
4818 return hr;
4821 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
4823 DWORD offset;
4824 HRESULT hr;
4825 unsigned int i;
4826 D3DXHANDLE *annotation_handles = NULL;
4827 const char *ptr2;
4829 read_dword(ptr, &offset);
4830 TRACE("Typedef offset: %#x\n", offset);
4831 ptr2 = data + offset;
4833 read_dword(ptr, &offset);
4834 TRACE("Value offset: %#x\n", offset);
4836 read_dword(ptr, &param->flags);
4837 TRACE("Flags: %#x\n", param->flags);
4839 read_dword(ptr, &param->annotation_count);
4840 TRACE("Annotation count: %u\n", param->annotation_count);
4842 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
4843 if (hr != D3D_OK)
4845 WARN("Failed to parse type definition\n");
4846 return hr;
4849 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
4850 if (hr != D3D_OK)
4852 WARN("Failed to parse value\n");
4853 return hr;
4856 if (param->annotation_count)
4858 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
4859 if (!annotation_handles)
4861 ERR("Out of memory\n");
4862 hr = E_OUTOFMEMORY;
4863 goto err_out;
4866 for (i = 0; i < param->annotation_count; ++i)
4868 struct d3dx_parameter *annotation;
4870 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4871 if (!annotation)
4873 ERR("Out of memory\n");
4874 hr = E_OUTOFMEMORY;
4875 goto err_out;
4878 annotation_handles[i] = get_parameter_handle(annotation);
4880 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4881 if (hr != D3D_OK)
4883 WARN("Failed to parse annotation\n");
4884 goto err_out;
4889 param->annotation_handles = annotation_handles;
4891 return D3D_OK;
4893 err_out:
4895 if (annotation_handles)
4897 for (i = 0; i < param->annotation_count; ++i)
4899 free_parameter(annotation_handles[i], FALSE, FALSE);
4901 HeapFree(GetProcessHeap(), 0, annotation_handles);
4904 return hr;
4907 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
4909 DWORD offset;
4910 HRESULT hr;
4911 unsigned int i;
4912 D3DXHANDLE *annotation_handles = NULL;
4913 struct d3dx_state *states = NULL;
4914 char *name = NULL;
4916 read_dword(ptr, &offset);
4917 TRACE("Pass name offset: %#x\n", offset);
4918 hr = d3dx9_parse_name(&name, data + offset);
4919 if (hr != D3D_OK)
4921 WARN("Failed to parse name\n");
4922 goto err_out;
4925 read_dword(ptr, &pass->annotation_count);
4926 TRACE("Annotation count: %u\n", pass->annotation_count);
4928 read_dword(ptr, &pass->state_count);
4929 TRACE("State count: %u\n", pass->state_count);
4931 if (pass->annotation_count)
4933 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
4934 if (!annotation_handles)
4936 ERR("Out of memory\n");
4937 hr = E_OUTOFMEMORY;
4938 goto err_out;
4941 for (i = 0; i < pass->annotation_count; ++i)
4943 struct d3dx_parameter *annotation;
4945 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
4946 if (!annotation)
4948 ERR("Out of memory\n");
4949 hr = E_OUTOFMEMORY;
4950 goto err_out;
4953 annotation_handles[i] = get_parameter_handle(annotation);
4955 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
4956 if (hr != D3D_OK)
4958 WARN("Failed to parse annotations\n");
4959 goto err_out;
4964 if (pass->state_count)
4966 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
4967 if (!states)
4969 ERR("Out of memory\n");
4970 hr = E_OUTOFMEMORY;
4971 goto err_out;
4974 for (i = 0; i < pass->state_count; ++i)
4976 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4977 if (hr != D3D_OK)
4979 WARN("Failed to parse annotations\n");
4980 goto err_out;
4985 pass->name = name;
4986 pass->annotation_handles = annotation_handles;
4987 pass->states = states;
4989 return D3D_OK;
4991 err_out:
4993 if (annotation_handles)
4995 for (i = 0; i < pass->annotation_count; ++i)
4997 free_parameter(annotation_handles[i], FALSE, FALSE);
4999 HeapFree(GetProcessHeap(), 0, annotation_handles);
5002 if (states)
5004 for (i = 0; i < pass->state_count; ++i)
5006 free_state(&states[i]);
5008 HeapFree(GetProcessHeap(), 0, states);
5011 HeapFree(GetProcessHeap(), 0, name);
5013 return hr;
5016 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
5018 DWORD offset;
5019 HRESULT hr;
5020 unsigned int i;
5021 D3DXHANDLE *annotation_handles = NULL;
5022 D3DXHANDLE *pass_handles = NULL;
5023 char *name = NULL;
5025 read_dword(ptr, &offset);
5026 TRACE("Technique name offset: %#x\n", offset);
5027 hr = d3dx9_parse_name(&name, data + offset);
5028 if (hr != D3D_OK)
5030 WARN("Failed to parse name\n");
5031 goto err_out;
5034 read_dword(ptr, &technique->annotation_count);
5035 TRACE("Annotation count: %u\n", technique->annotation_count);
5037 read_dword(ptr, &technique->pass_count);
5038 TRACE("Pass count: %u\n", technique->pass_count);
5040 if (technique->annotation_count)
5042 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
5043 if (!annotation_handles)
5045 ERR("Out of memory\n");
5046 hr = E_OUTOFMEMORY;
5047 goto err_out;
5050 for (i = 0; i < technique->annotation_count; ++i)
5052 struct d3dx_parameter *annotation;
5054 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5055 if (!annotation)
5057 ERR("Out of memory\n");
5058 hr = E_OUTOFMEMORY;
5059 goto err_out;
5062 annotation_handles[i] = get_parameter_handle(annotation);
5064 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5065 if (hr != D3D_OK)
5067 WARN("Failed to parse annotations\n");
5068 goto err_out;
5073 if (technique->pass_count)
5075 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5076 if (!pass_handles)
5078 ERR("Out of memory\n");
5079 hr = E_OUTOFMEMORY;
5080 goto err_out;
5083 for (i = 0; i < technique->pass_count; ++i)
5085 struct d3dx_pass *pass;
5087 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5088 if (!pass)
5090 ERR("Out of memory\n");
5091 hr = E_OUTOFMEMORY;
5092 goto err_out;
5095 pass_handles[i] = get_pass_handle(pass);
5097 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5098 if (hr != D3D_OK)
5100 WARN("Failed to parse passes\n");
5101 goto err_out;
5106 technique->name = name;
5107 technique->pass_handles = pass_handles;
5108 technique->annotation_handles = annotation_handles;
5110 return D3D_OK;
5112 err_out:
5114 if (pass_handles)
5116 for (i = 0; i < technique->pass_count; ++i)
5118 free_pass(pass_handles[i]);
5120 HeapFree(GetProcessHeap(), 0, pass_handles);
5123 if (annotation_handles)
5125 for (i = 0; i < technique->annotation_count; ++i)
5127 free_parameter(annotation_handles[i], FALSE, FALSE);
5129 HeapFree(GetProcessHeap(), 0, annotation_handles);
5132 HeapFree(GetProcessHeap(), 0, name);
5134 return hr;
5137 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5139 DWORD technique_index;
5140 DWORD index, state_index, usage, element_index;
5141 struct d3dx_state *state;
5142 struct d3dx_parameter *param;
5143 HRESULT hr = E_FAIL;
5145 read_dword(ptr, &technique_index);
5146 TRACE("techn: %u\n", technique_index);
5148 read_dword(ptr, &index);
5149 TRACE("index: %u\n", index);
5151 read_dword(ptr, &element_index);
5152 TRACE("element_index: %u\n", element_index);
5154 read_dword(ptr, &state_index);
5155 TRACE("state_index: %u\n", state_index);
5157 read_dword(ptr, &usage);
5158 TRACE("usage: %u\n", usage);
5160 if (technique_index == 0xffffffff)
5162 struct d3dx_parameter *parameter;
5163 struct d3dx_sampler *sampler;
5165 if (index >= base->parameter_count)
5167 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5168 return E_FAIL;
5171 parameter = get_parameter_struct(base->parameter_handles[index]);
5172 if (element_index != 0xffffffff)
5174 if (element_index >= parameter->element_count && parameter->element_count != 0)
5176 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5177 return E_FAIL;
5180 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5183 sampler = parameter->data;
5184 if (state_index >= sampler->state_count)
5186 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5187 return E_FAIL;
5190 state = &sampler->states[state_index];
5192 else
5194 struct d3dx_technique *technique;
5195 struct d3dx_pass *pass;
5197 if (technique_index >= base->technique_count)
5199 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5200 return E_FAIL;
5203 technique = get_technique_struct(base->technique_handles[technique_index]);
5204 if (index >= technique->pass_count)
5206 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5207 return E_FAIL;
5210 pass = get_pass_struct(technique->pass_handles[index]);
5211 if (state_index >= pass->state_count)
5213 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5214 return E_FAIL;
5217 state = &pass->states[state_index];
5220 param = get_parameter_struct(state->parameter);
5222 switch (usage)
5224 case 0:
5225 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5226 switch (param->type)
5228 case D3DXPT_VERTEXSHADER:
5229 case D3DXPT_PIXELSHADER:
5230 state->type = ST_CONSTANT;
5231 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5232 break;
5234 case D3DXPT_BOOL:
5235 case D3DXPT_INT:
5236 case D3DXPT_FLOAT:
5237 case D3DXPT_STRING:
5238 state->type = ST_FXLC;
5239 hr = d3dx9_copy_data(param->data, ptr);
5240 break;
5242 default:
5243 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5244 break;
5246 break;
5248 case 1:
5249 state->type = ST_PARAMETER;
5250 hr = d3dx9_copy_data(param->data, ptr);
5251 if (hr == D3D_OK)
5253 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5255 break;
5257 default:
5258 FIXME("Unknown usage %x\n", usage);
5259 break;
5262 return hr;
5265 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5267 const char *ptr = data + start;
5268 D3DXHANDLE *parameter_handles = NULL;
5269 D3DXHANDLE *technique_handles = NULL;
5270 D3DXHANDLE *objects = NULL;
5271 UINT stringcount, objectcount, resourcecount;
5272 HRESULT hr;
5273 UINT i;
5275 read_dword(&ptr, &base->parameter_count);
5276 TRACE("Parameter count: %u\n", base->parameter_count);
5278 read_dword(&ptr, &base->technique_count);
5279 TRACE("Technique count: %u\n", base->technique_count);
5281 skip_dword_unknown(&ptr, 1);
5283 read_dword(&ptr, &objectcount);
5284 TRACE("Object count: %u\n", objectcount);
5286 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5287 if (!objects)
5289 ERR("Out of memory\n");
5290 hr = E_OUTOFMEMORY;
5291 goto err_out;
5294 if (base->parameter_count)
5296 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5297 if (!parameter_handles)
5299 ERR("Out of memory\n");
5300 hr = E_OUTOFMEMORY;
5301 goto err_out;
5304 for (i = 0; i < base->parameter_count; ++i)
5306 struct d3dx_parameter *parameter;
5308 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5309 if (!parameter)
5311 ERR("Out of memory\n");
5312 hr = E_OUTOFMEMORY;
5313 goto err_out;
5316 parameter_handles[i] = get_parameter_handle(parameter);
5318 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5319 if (hr != D3D_OK)
5321 WARN("Failed to parse parameter\n");
5322 goto err_out;
5327 if (base->technique_count)
5329 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5330 if (!technique_handles)
5332 ERR("Out of memory\n");
5333 hr = E_OUTOFMEMORY;
5334 goto err_out;
5337 for (i = 0; i < base->technique_count; ++i)
5339 struct d3dx_technique *technique;
5341 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5342 if (!technique)
5344 ERR("Out of memory\n");
5345 hr = E_OUTOFMEMORY;
5346 goto err_out;
5349 technique_handles[i] = get_technique_handle(technique);
5351 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5352 if (hr != D3D_OK)
5354 WARN("Failed to parse technique\n");
5355 goto err_out;
5360 /* needed for further parsing */
5361 base->technique_handles = technique_handles;
5362 base->parameter_handles = parameter_handles;
5364 read_dword(&ptr, &stringcount);
5365 TRACE("String count: %u\n", stringcount);
5367 read_dword(&ptr, &resourcecount);
5368 TRACE("Resource count: %u\n", resourcecount);
5370 for (i = 0; i < stringcount; ++i)
5372 DWORD id;
5373 struct d3dx_parameter *param;
5375 read_dword(&ptr, &id);
5376 TRACE("Id: %u\n", id);
5378 param = get_parameter_struct(objects[id]);
5380 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5381 if (hr != D3D_OK)
5383 WARN("Failed to parse data\n");
5384 goto err_out;
5388 for (i = 0; i < resourcecount; ++i)
5390 TRACE("parse resource %u\n", i);
5392 hr = d3dx9_parse_resource(base, data, &ptr);
5393 if (hr != D3D_OK)
5395 WARN("Failed to parse data\n");
5396 goto err_out;
5400 HeapFree(GetProcessHeap(), 0, objects);
5402 return D3D_OK;
5404 err_out:
5406 if (technique_handles)
5408 for (i = 0; i < base->technique_count; ++i)
5410 free_technique(technique_handles[i]);
5412 HeapFree(GetProcessHeap(), 0, technique_handles);
5415 if (parameter_handles)
5417 for (i = 0; i < base->parameter_count; ++i)
5419 free_parameter(parameter_handles[i], FALSE, FALSE);
5421 HeapFree(GetProcessHeap(), 0, parameter_handles);
5424 base->technique_handles = NULL;
5425 base->parameter_handles = NULL;
5427 HeapFree(GetProcessHeap(), 0, objects);
5429 return hr;
5432 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5433 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5435 DWORD tag, offset;
5436 const char *ptr = data;
5437 HRESULT hr;
5439 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5441 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5442 base->ref = 1;
5443 base->effect = effect;
5445 read_dword(&ptr, &tag);
5446 TRACE("Tag: %x\n", tag);
5448 if (tag != d3dx9_effect_version(9, 1))
5450 /* todo: compile hlsl ascii code */
5451 FIXME("HLSL ascii effects not supported, yet\n");
5453 /* Show the start of the shader for debugging info. */
5454 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5456 else
5458 read_dword(&ptr, &offset);
5459 TRACE("Offset: %x\n", offset);
5461 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5462 if (hr != D3D_OK)
5464 FIXME("Failed to parse effect.\n");
5465 return hr;
5469 return D3D_OK;
5472 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5473 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5475 HRESULT hr;
5476 struct ID3DXBaseEffectImpl *object = NULL;
5478 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5480 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5481 effect->ref = 1;
5483 if (pool) pool->lpVtbl->AddRef(pool);
5484 effect->pool = pool;
5486 IDirect3DDevice9_AddRef(device);
5487 effect->device = device;
5489 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5490 if (!object)
5492 ERR("Out of memory\n");
5493 hr = E_OUTOFMEMORY;
5494 goto err_out;
5497 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5498 if (hr != D3D_OK)
5500 FIXME("Failed to parse effect.\n");
5501 goto err_out;
5504 effect->base_effect = &object->ID3DXBaseEffect_iface;
5506 /* initialize defaults - check because of unsupported ascii effects */
5507 if (object->technique_handles)
5509 effect->active_technique = object->technique_handles[0];
5510 effect->active_pass = NULL;
5513 return D3D_OK;
5515 err_out:
5517 HeapFree(GetProcessHeap(), 0, object);
5518 free_effect(effect);
5520 return hr;
5523 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5524 LPCVOID srcdata,
5525 UINT srcdatalen,
5526 CONST D3DXMACRO* defines,
5527 LPD3DXINCLUDE include,
5528 LPCSTR skip_constants,
5529 DWORD flags,
5530 LPD3DXEFFECTPOOL pool,
5531 LPD3DXEFFECT* effect,
5532 LPD3DXBUFFER* compilation_errors)
5534 struct ID3DXEffectImpl *object;
5535 HRESULT hr;
5537 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5538 skip_constants, flags, pool, effect, compilation_errors);
5540 if (!device || !srcdata)
5541 return D3DERR_INVALIDCALL;
5543 if (!srcdatalen)
5544 return E_FAIL;
5546 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5547 if (!effect)
5548 return D3D_OK;
5550 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5551 if (!object)
5553 ERR("Out of memory\n");
5554 return E_OUTOFMEMORY;
5557 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5558 if (FAILED(hr))
5560 WARN("Failed to initialize shader reflection\n");
5561 HeapFree(GetProcessHeap(), 0, object);
5562 return hr;
5565 *effect = &object->ID3DXEffect_iface;
5567 TRACE("Created ID3DXEffect %p\n", object);
5569 return D3D_OK;
5572 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5573 LPCVOID srcdata,
5574 UINT srcdatalen,
5575 CONST D3DXMACRO* defines,
5576 LPD3DXINCLUDE include,
5577 DWORD flags,
5578 LPD3DXEFFECTPOOL pool,
5579 LPD3DXEFFECT* effect,
5580 LPD3DXBUFFER* compilation_errors)
5582 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5583 include, flags, pool, effect, compilation_errors);
5585 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5588 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5590 HRESULT hr;
5591 struct ID3DXBaseEffectImpl *object = NULL;
5593 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5595 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5596 compiler->ref = 1;
5598 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5599 if (!object)
5601 ERR("Out of memory\n");
5602 hr = E_OUTOFMEMORY;
5603 goto err_out;
5606 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5607 if (hr != D3D_OK)
5609 FIXME("Failed to parse effect.\n");
5610 goto err_out;
5613 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5615 return D3D_OK;
5617 err_out:
5619 HeapFree(GetProcessHeap(), 0, object);
5620 free_effect_compiler(compiler);
5622 return hr;
5625 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5626 UINT srcdatalen,
5627 CONST D3DXMACRO *defines,
5628 LPD3DXINCLUDE include,
5629 DWORD flags,
5630 LPD3DXEFFECTCOMPILER *compiler,
5631 LPD3DXBUFFER *parse_errors)
5633 struct ID3DXEffectCompilerImpl *object;
5634 HRESULT hr;
5636 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5637 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5639 if (!srcdata || !compiler)
5641 WARN("Invalid arguments supplied\n");
5642 return D3DERR_INVALIDCALL;
5645 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5646 if (!object)
5648 ERR("Out of memory\n");
5649 return E_OUTOFMEMORY;
5652 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5653 if (FAILED(hr))
5655 WARN("Failed to initialize effect compiler\n");
5656 HeapFree(GetProcessHeap(), 0, object);
5657 return hr;
5660 *compiler = &object->ID3DXEffectCompiler_iface;
5662 TRACE("Created ID3DXEffectCompiler %p\n", object);
5664 return D3D_OK;
5667 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5669 struct ID3DXEffectPoolImpl
5671 ID3DXEffectPool ID3DXEffectPool_iface;
5672 LONG ref;
5675 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5677 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5680 /*** IUnknown methods ***/
5681 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5683 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5685 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
5687 if (IsEqualGUID(riid, &IID_IUnknown) ||
5688 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5690 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
5691 *object = This;
5692 return S_OK;
5695 WARN("Interface %s not found\n", debugstr_guid(riid));
5697 return E_NOINTERFACE;
5700 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5702 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5704 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5706 return InterlockedIncrement(&This->ref);
5709 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5711 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5712 ULONG ref = InterlockedDecrement(&This->ref);
5714 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5716 if (!ref)
5717 HeapFree(GetProcessHeap(), 0, This);
5719 return ref;
5722 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5724 /*** IUnknown methods ***/
5725 ID3DXEffectPoolImpl_QueryInterface,
5726 ID3DXEffectPoolImpl_AddRef,
5727 ID3DXEffectPoolImpl_Release
5730 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5732 struct ID3DXEffectPoolImpl *object;
5734 TRACE("(%p)\n", pool);
5736 if (!pool)
5737 return D3DERR_INVALIDCALL;
5739 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5740 if (!object)
5742 ERR("Out of memory\n");
5743 return E_OUTOFMEMORY;
5746 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5747 object->ref = 1;
5749 *pool = &object->ID3DXEffectPool_iface;
5751 return S_OK;
5754 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5755 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5756 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5758 LPVOID buffer;
5759 HRESULT ret;
5760 DWORD size;
5762 TRACE("(%s): relay\n", debugstr_w(srcfile));
5764 if (!device || !srcfile)
5765 return D3DERR_INVALIDCALL;
5767 ret = map_view_of_file(srcfile, &buffer, &size);
5769 if (FAILED(ret))
5770 return D3DXERR_INVALIDDATA;
5772 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5773 UnmapViewOfFile(buffer);
5775 return ret;
5778 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5779 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5780 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5782 LPWSTR srcfileW;
5783 HRESULT ret;
5784 DWORD len;
5786 TRACE("(void): relay\n");
5788 if (!srcfile)
5789 return D3DERR_INVALIDCALL;
5791 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5792 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5793 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5795 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5796 HeapFree(GetProcessHeap(), 0, srcfileW);
5798 return ret;
5801 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
5802 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5803 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5805 TRACE("(void): relay\n");
5806 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5809 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
5810 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5811 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5813 TRACE("(void): relay\n");
5814 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
5817 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5818 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5819 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5821 HRSRC resinfo;
5823 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5825 if (!device)
5826 return D3DERR_INVALIDCALL;
5828 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5830 if (resinfo)
5832 LPVOID buffer;
5833 HRESULT ret;
5834 DWORD size;
5836 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5838 if (FAILED(ret))
5839 return D3DXERR_INVALIDDATA;
5841 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5844 return D3DXERR_INVALIDDATA;
5847 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5848 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
5849 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5851 HRSRC resinfo;
5853 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5855 if (!device)
5856 return D3DERR_INVALIDCALL;
5858 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5860 if (resinfo)
5862 LPVOID buffer;
5863 HRESULT ret;
5864 DWORD size;
5866 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5868 if (FAILED(ret))
5869 return D3DXERR_INVALIDDATA;
5871 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5874 return D3DXERR_INVALIDDATA;
5877 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
5878 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5879 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5881 TRACE("(void): relay\n");
5882 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5885 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
5886 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
5887 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
5889 TRACE("(void): relay\n");
5890 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
5893 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5894 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5896 LPVOID buffer;
5897 HRESULT ret;
5898 DWORD size;
5900 TRACE("(%s): relay\n", debugstr_w(srcfile));
5902 if (!srcfile)
5903 return D3DERR_INVALIDCALL;
5905 ret = map_view_of_file(srcfile, &buffer, &size);
5907 if (FAILED(ret))
5908 return D3DXERR_INVALIDDATA;
5910 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5911 UnmapViewOfFile(buffer);
5913 return ret;
5916 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
5917 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5919 LPWSTR srcfileW;
5920 HRESULT ret;
5921 DWORD len;
5923 TRACE("(void): relay\n");
5925 if (!srcfile)
5926 return D3DERR_INVALIDCALL;
5928 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
5929 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
5930 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
5932 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
5933 HeapFree(GetProcessHeap(), 0, srcfileW);
5935 return ret;
5938 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
5939 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5941 HRSRC resinfo;
5943 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
5945 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
5947 if (resinfo)
5949 LPVOID buffer;
5950 HRESULT ret;
5951 DWORD size;
5953 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5955 if (FAILED(ret))
5956 return D3DXERR_INVALIDDATA;
5958 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5961 return D3DXERR_INVALIDDATA;
5964 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
5965 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
5967 HRSRC resinfo;
5969 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
5971 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
5973 if (resinfo)
5975 LPVOID buffer;
5976 HRESULT ret;
5977 DWORD size;
5979 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
5981 if (FAILED(ret))
5982 return D3DXERR_INVALIDDATA;
5984 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
5987 return D3DXERR_INVALIDDATA;