d3dx9: Move transpose matrix into set_matrix().
[wine/testsucceed.git] / dlls / d3dx9_36 / effect.c
blob0a7012818f3d7ed0f930b072191288b2df504b5b
1 /*
2 * Copyright 2010 Christian Costa
3 * Copyright 2011 Rico Schüller
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
21 #include "wine/port.h"
22 #define NONAMELESSUNION
23 #include "wine/debug.h"
24 #include "wine/unicode.h"
26 #include "windef.h"
27 #include "wingdi.h"
28 #include "d3dx9_36_private.h"
30 /* Constants for special INT/FLOAT conversation */
31 #define INT_FLOAT_MULTI 255.0f
32 #define INT_FLOAT_MULTI_INVERSE (1/INT_FLOAT_MULTI)
34 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
36 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
37 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
38 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
40 enum STATE_CLASS
42 SC_LIGHTENABLE,
43 SC_FVF,
44 SC_LIGHT,
45 SC_MATERIAL,
46 SC_NPATCHMODE,
47 SC_PIXELSHADER,
48 SC_RENDERSTATE,
49 SC_SETSAMPLER,
50 SC_SAMPLERSTATE,
51 SC_TEXTURE,
52 SC_TEXTURESTAGE,
53 SC_TRANSFORM,
54 SC_VERTEXSHADER,
55 SC_SHADERCONST,
56 SC_UNKNOWN,
59 enum MATERIAL_TYPE
61 MT_DIFFUSE,
62 MT_AMBIENT,
63 MT_SPECULAR,
64 MT_EMISSIVE,
65 MT_POWER,
68 enum LIGHT_TYPE
70 LT_TYPE,
71 LT_DIFFUSE,
72 LT_SPECULAR,
73 LT_AMBIENT,
74 LT_POSITION,
75 LT_DIRECTION,
76 LT_RANGE,
77 LT_FALLOFF,
78 LT_ATTENUATION0,
79 LT_ATTENUATION1,
80 LT_ATTENUATION2,
81 LT_THETA,
82 LT_PHI,
85 enum SHADER_CONSTANT_TYPE
87 SCT_VSFLOAT,
88 SCT_VSBOOL,
89 SCT_VSINT,
90 SCT_PSFLOAT,
91 SCT_PSBOOL,
92 SCT_PSINT,
95 enum STATE_TYPE
97 ST_CONSTANT,
98 ST_PARAMETER,
99 ST_FXLC,
102 struct d3dx_parameter
104 char *name;
105 char *semantic;
106 void *data;
107 D3DXPARAMETER_CLASS class;
108 D3DXPARAMETER_TYPE type;
109 UINT rows;
110 UINT columns;
111 UINT element_count;
112 UINT annotation_count;
113 UINT member_count;
114 DWORD flags;
115 UINT bytes;
117 D3DXHANDLE *annotation_handles;
118 D3DXHANDLE *member_handles;
121 struct d3dx_state
123 UINT operation;
124 UINT index;
125 enum STATE_TYPE type;
126 D3DXHANDLE parameter;
129 struct d3dx_sampler
131 UINT state_count;
132 struct d3dx_state *states;
135 struct d3dx_pass
137 char *name;
138 UINT state_count;
139 UINT annotation_count;
141 struct d3dx_state *states;
142 D3DXHANDLE *annotation_handles;
145 struct d3dx_technique
147 char *name;
148 UINT pass_count;
149 UINT annotation_count;
151 D3DXHANDLE *annotation_handles;
152 D3DXHANDLE *pass_handles;
155 struct ID3DXBaseEffectImpl
157 ID3DXBaseEffect ID3DXBaseEffect_iface;
158 LONG ref;
160 struct ID3DXEffectImpl *effect;
162 UINT parameter_count;
163 UINT technique_count;
165 D3DXHANDLE *parameter_handles;
166 D3DXHANDLE *technique_handles;
169 struct ID3DXEffectImpl
171 ID3DXEffect ID3DXEffect_iface;
172 LONG ref;
174 LPD3DXEFFECTSTATEMANAGER manager;
175 LPDIRECT3DDEVICE9 device;
176 LPD3DXEFFECTPOOL pool;
177 D3DXHANDLE active_technique;
178 D3DXHANDLE active_pass;
180 ID3DXBaseEffect *base_effect;
183 struct ID3DXEffectCompilerImpl
185 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
186 LONG ref;
188 ID3DXBaseEffect *base_effect;
191 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
192 struct d3dx_parameter *parameter, LPCSTR name);
193 static struct d3dx_parameter *get_annotation_by_name(UINT handlecount, D3DXHANDLE *handles, LPCSTR name);
194 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects);
195 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st);
197 static const struct
199 enum STATE_CLASS class;
200 UINT op;
201 LPCSTR name;
203 state_table[] =
205 /* Render sates */
206 {SC_RENDERSTATE, D3DRS_ZENABLE, "D3DRS_ZENABLE"}, /* 0x0 */
207 {SC_RENDERSTATE, D3DRS_FILLMODE, "D3DRS_FILLMODE"},
208 {SC_RENDERSTATE, D3DRS_SHADEMODE, "D3DRS_SHADEMODE"},
209 {SC_RENDERSTATE, D3DRS_ZWRITEENABLE, "D3DRS_ZWRITEENABLE"},
210 {SC_RENDERSTATE, D3DRS_ALPHATESTENABLE, "D3DRS_ALPHATESTENABLE"},
211 {SC_RENDERSTATE, D3DRS_LASTPIXEL, "D3DRS_LASTPIXEL"},
212 {SC_RENDERSTATE, D3DRS_SRCBLEND, "D3DRS_SRCBLEND"},
213 {SC_RENDERSTATE, D3DRS_DESTBLEND, "D3DRS_DESTBLEND"},
214 {SC_RENDERSTATE, D3DRS_CULLMODE, "D3DRS_CULLMODE"},
215 {SC_RENDERSTATE, D3DRS_ZFUNC, "D3DRS_ZFUNC"},
216 {SC_RENDERSTATE, D3DRS_ALPHAREF, "D3DRS_ALPHAREF"},
217 {SC_RENDERSTATE, D3DRS_ALPHAFUNC, "D3DRS_ALPHAFUNC"},
218 {SC_RENDERSTATE, D3DRS_DITHERENABLE, "D3DRS_DITHERENABLE"},
219 {SC_RENDERSTATE, D3DRS_ALPHABLENDENABLE, "D3DRS_ALPHABLENDENABLE"},
220 {SC_RENDERSTATE, D3DRS_FOGENABLE, "D3DRS_FOGENABLE"},
221 {SC_RENDERSTATE, D3DRS_SPECULARENABLE, "D3DRS_SPECULARENABLE"},
222 {SC_RENDERSTATE, D3DRS_FOGCOLOR, "D3DRS_FOGCOLOR"}, /* 0x10 */
223 {SC_RENDERSTATE, D3DRS_FOGTABLEMODE, "D3DRS_FOGTABLEMODE"},
224 {SC_RENDERSTATE, D3DRS_FOGSTART, "D3DRS_FOGSTART"},
225 {SC_RENDERSTATE, D3DRS_FOGEND, "D3DRS_FOGEND"},
226 {SC_RENDERSTATE, D3DRS_FOGDENSITY, "D3DRS_FOGDENSITY"},
227 {SC_RENDERSTATE, D3DRS_RANGEFOGENABLE, "D3DRS_RANGEFOGENABLE"},
228 {SC_RENDERSTATE, D3DRS_STENCILENABLE, "D3DRS_STENCILENABLE"},
229 {SC_RENDERSTATE, D3DRS_STENCILFAIL, "D3DRS_STENCILFAIL"},
230 {SC_RENDERSTATE, D3DRS_STENCILZFAIL, "D3DRS_STENCILZFAIL"},
231 {SC_RENDERSTATE, D3DRS_STENCILPASS, "D3DRS_STENCILPASS"},
232 {SC_RENDERSTATE, D3DRS_STENCILFUNC, "D3DRS_STENCILFUNC"},
233 {SC_RENDERSTATE, D3DRS_STENCILREF, "D3DRS_STENCILREF"},
234 {SC_RENDERSTATE, D3DRS_STENCILMASK, "D3DRS_STENCILMASK"},
235 {SC_RENDERSTATE, D3DRS_STENCILWRITEMASK, "D3DRS_STENCILWRITEMASK"},
236 {SC_RENDERSTATE, D3DRS_TEXTUREFACTOR, "D3DRS_TEXTUREFACTOR"},
237 {SC_RENDERSTATE, D3DRS_WRAP0, "D3DRS_WRAP0"},
238 {SC_RENDERSTATE, D3DRS_WRAP1, "D3DRS_WRAP1"}, /* 0x20 */
239 {SC_RENDERSTATE, D3DRS_WRAP2, "D3DRS_WRAP2"},
240 {SC_RENDERSTATE, D3DRS_WRAP3, "D3DRS_WRAP3"},
241 {SC_RENDERSTATE, D3DRS_WRAP4, "D3DRS_WRAP4"},
242 {SC_RENDERSTATE, D3DRS_WRAP5, "D3DRS_WRAP5"},
243 {SC_RENDERSTATE, D3DRS_WRAP6, "D3DRS_WRAP6"},
244 {SC_RENDERSTATE, D3DRS_WRAP7, "D3DRS_WRAP7"},
245 {SC_RENDERSTATE, D3DRS_WRAP8, "D3DRS_WRAP8"},
246 {SC_RENDERSTATE, D3DRS_WRAP9, "D3DRS_WRAP9"},
247 {SC_RENDERSTATE, D3DRS_WRAP10, "D3DRS_WRAP10"},
248 {SC_RENDERSTATE, D3DRS_WRAP11, "D3DRS_WRAP11"},
249 {SC_RENDERSTATE, D3DRS_WRAP12, "D3DRS_WRAP12"},
250 {SC_RENDERSTATE, D3DRS_WRAP13, "D3DRS_WRAP13"},
251 {SC_RENDERSTATE, D3DRS_WRAP14, "D3DRS_WRAP14"},
252 {SC_RENDERSTATE, D3DRS_WRAP15, "D3DRS_WRAP15"},
253 {SC_RENDERSTATE, D3DRS_CLIPPING, "D3DRS_CLIPPING"},
254 {SC_RENDERSTATE, D3DRS_LIGHTING, "D3DRS_LIGHTING"}, /* 0x30 */
255 {SC_RENDERSTATE, D3DRS_AMBIENT, "D3DRS_AMBIENT"},
256 {SC_RENDERSTATE, D3DRS_FOGVERTEXMODE, "D3DRS_FOGVERTEXMODE"},
257 {SC_RENDERSTATE, D3DRS_COLORVERTEX, "D3DRS_COLORVERTEX"},
258 {SC_RENDERSTATE, D3DRS_LOCALVIEWER, "D3DRS_LOCALVIEWER"},
259 {SC_RENDERSTATE, D3DRS_NORMALIZENORMALS, "D3DRS_NORMALIZENORMALS"},
260 {SC_RENDERSTATE, D3DRS_DIFFUSEMATERIALSOURCE, "D3DRS_DIFFUSEMATERIALSOURCE"},
261 {SC_RENDERSTATE, D3DRS_SPECULARMATERIALSOURCE, "D3DRS_SPECULARMATERIALSOURCE"},
262 {SC_RENDERSTATE, D3DRS_AMBIENTMATERIALSOURCE, "D3DRS_AMBIENTMATERIALSOURCE"},
263 {SC_RENDERSTATE, D3DRS_EMISSIVEMATERIALSOURCE, "D3DRS_EMISSIVEMATERIALSOURCE"},
264 {SC_RENDERSTATE, D3DRS_VERTEXBLEND, "D3DRS_VERTEXBLEND"},
265 {SC_RENDERSTATE, D3DRS_CLIPPLANEENABLE, "D3DRS_CLIPPLANEENABLE"},
266 {SC_RENDERSTATE, D3DRS_POINTSIZE, "D3DRS_POINTSIZE"},
267 {SC_RENDERSTATE, D3DRS_POINTSIZE_MIN, "D3DRS_POINTSIZE_MIN"},
268 {SC_RENDERSTATE, D3DRS_POINTSIZE_MAX, "D3DRS_POINTSIZE_MAX"},
269 {SC_RENDERSTATE, D3DRS_POINTSPRITEENABLE, "D3DRS_POINTSPRITEENABLE"},
270 {SC_RENDERSTATE, D3DRS_POINTSCALEENABLE, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
271 {SC_RENDERSTATE, D3DRS_POINTSCALE_A, "D3DRS_POINTSCALE_A"},
272 {SC_RENDERSTATE, D3DRS_POINTSCALE_B, "D3DRS_POINTSCALE_B"},
273 {SC_RENDERSTATE, D3DRS_POINTSCALE_C, "D3DRS_POINTSCALE_C"},
274 {SC_RENDERSTATE, D3DRS_MULTISAMPLEANTIALIAS, "D3DRS_MULTISAMPLEANTIALIAS"},
275 {SC_RENDERSTATE, D3DRS_MULTISAMPLEMASK, "D3DRS_MULTISAMPLEMASK"},
276 {SC_RENDERSTATE, D3DRS_PATCHEDGESTYLE, "D3DRS_PATCHEDGESTYLE"},
277 {SC_RENDERSTATE, D3DRS_DEBUGMONITORTOKEN, "D3DRS_DEBUGMONITORTOKEN"},
278 {SC_RENDERSTATE, D3DRS_INDEXEDVERTEXBLENDENABLE, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
279 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE, "D3DRS_COLORWRITEENABLE"},
280 {SC_RENDERSTATE, D3DRS_TWEENFACTOR, "D3DRS_TWEENFACTOR"},
281 {SC_RENDERSTATE, D3DRS_BLENDOP, "D3DRS_BLENDOP"},
282 {SC_RENDERSTATE, D3DRS_POSITIONDEGREE, "D3DRS_POSITIONDEGREE"},
283 {SC_RENDERSTATE, D3DRS_NORMALDEGREE, "D3DRS_NORMALDEGREE"},
284 {SC_RENDERSTATE, D3DRS_SCISSORTESTENABLE, "D3DRS_SCISSORTESTENABLE"},
285 {SC_RENDERSTATE, D3DRS_SLOPESCALEDEPTHBIAS, "D3DRS_SLOPESCALEDEPTHBIAS"},
286 {SC_RENDERSTATE, D3DRS_ANTIALIASEDLINEENABLE, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
287 {SC_RENDERSTATE, D3DRS_MINTESSELLATIONLEVEL, "D3DRS_MINTESSELLATIONLEVEL"},
288 {SC_RENDERSTATE, D3DRS_MAXTESSELLATIONLEVEL, "D3DRS_MAXTESSELLATIONLEVEL"},
289 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_X, "D3DRS_ADAPTIVETESS_X"},
290 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Y, "D3DRS_ADAPTIVETESS_Y"},
291 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_Z, "D3DRS_ADAPTIVETESS_Z"},
292 {SC_RENDERSTATE, D3DRS_ADAPTIVETESS_W, "D3DRS_ADAPTIVETESS_W"},
293 {SC_RENDERSTATE, D3DRS_ENABLEADAPTIVETESSELLATION, "D3DRS_ENABLEADAPTIVETESSELLATION"},
294 {SC_RENDERSTATE, D3DRS_TWOSIDEDSTENCILMODE, "D3DRS_TWOSIDEDSTENCILMODE"},
295 {SC_RENDERSTATE, D3DRS_CCW_STENCILFAIL, "D3DRS_CCW_STENCILFAIL"},
296 {SC_RENDERSTATE, D3DRS_CCW_STENCILZFAIL, "D3DRS_CCW_STENCILZFAIL"},
297 {SC_RENDERSTATE, D3DRS_CCW_STENCILPASS, "D3DRS_CCW_STENCILPASS"},
298 {SC_RENDERSTATE, D3DRS_CCW_STENCILFUNC, "D3DRS_CCW_STENCILFUNC"},
299 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE1, "D3DRS_COLORWRITEENABLE1"},
300 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE2, "D3DRS_COLORWRITEENABLE2"},
301 {SC_RENDERSTATE, D3DRS_COLORWRITEENABLE3, "D3DRS_COLORWRITEENABLE3"},
302 {SC_RENDERSTATE, D3DRS_BLENDFACTOR, "D3DRS_BLENDFACTOR"}, /* 0x60 */
303 {SC_RENDERSTATE, D3DRS_SRGBWRITEENABLE, "D3DRS_SRGBWRITEENABLE"},
304 {SC_RENDERSTATE, D3DRS_DEPTHBIAS, "D3DRS_DEPTHBIAS"},
305 {SC_RENDERSTATE, D3DRS_SEPARATEALPHABLENDENABLE, "D3DRS_SEPARATEALPHABLENDENABLE"},
306 {SC_RENDERSTATE, D3DRS_SRCBLENDALPHA, "D3DRS_SRCBLENDALPHA"},
307 {SC_RENDERSTATE, D3DRS_DESTBLENDALPHA, "D3DRS_DESTBLENDALPHA"},
308 {SC_RENDERSTATE, D3DRS_BLENDOPALPHA, "D3DRS_BLENDOPALPHA"},
309 /* Texture stages */
310 {SC_TEXTURESTAGE, D3DTSS_COLOROP, "D3DTSS_COLOROP"},
311 {SC_TEXTURESTAGE, D3DTSS_COLORARG0, "D3DTSS_COLORARG0"},
312 {SC_TEXTURESTAGE, D3DTSS_COLORARG1, "D3DTSS_COLORARG1"},
313 {SC_TEXTURESTAGE, D3DTSS_COLORARG2, "D3DTSS_COLORARG2"},
314 {SC_TEXTURESTAGE, D3DTSS_ALPHAOP, "D3DTSS_ALPHAOP"},
315 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG0, "D3DTSS_ALPHAARG0"},
316 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG1, "D3DTSS_ALPHAARG1"},
317 {SC_TEXTURESTAGE, D3DTSS_ALPHAARG2, "D3DTSS_ALPHAARG2"},
318 {SC_TEXTURESTAGE, D3DTSS_RESULTARG, "D3DTSS_RESULTARG"},
319 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT00, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
320 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT01, "D3DTSS_BUMPENVMAT01"},
321 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT10, "D3DTSS_BUMPENVMAT10"},
322 {SC_TEXTURESTAGE, D3DTSS_BUMPENVMAT11, "D3DTSS_BUMPENVMAT11"},
323 {SC_TEXTURESTAGE, D3DTSS_TEXCOORDINDEX, "D3DTSS_TEXCOORDINDEX"},
324 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLSCALE, "D3DTSS_BUMPENVLSCALE"},
325 {SC_TEXTURESTAGE, D3DTSS_BUMPENVLOFFSET, "D3DTSS_BUMPENVLOFFSET"},
326 {SC_TEXTURESTAGE, D3DTSS_TEXTURETRANSFORMFLAGS, "D3DTSS_TEXTURETRANSFORMFLAGS"},
327 {SC_TEXTURESTAGE, D3DTSS_CONSTANT, "D3DTSS_CONSTANT"},
328 /* NPatchMode */
329 {SC_NPATCHMODE, 0, "NPatchMode"},
330 /* FVF */
331 {SC_FVF, 0, "FVF"},
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 *get_technique_by_name(struct ID3DXBaseEffectImpl *base, LPCSTR name)
451 UINT i;
453 if (!name) return NULL;
455 for (i = 0; i < base->technique_count; ++i)
457 struct d3dx_technique *tech = get_technique_struct(base->technique_handles[i]);
459 if (!strcmp(tech->name, name)) return tech;
462 return NULL;
465 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
467 struct d3dx_technique *tech = NULL;
468 unsigned int i;
470 for (i = 0; i < base->technique_count; ++i)
472 if (base->technique_handles[i] == technique)
474 tech = get_technique_struct(technique);
475 break;
479 if (!tech) tech = get_technique_by_name(base, technique);
481 return tech;
484 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
486 unsigned int i, k;
488 for (i = 0; i < base->technique_count; ++i)
490 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
492 for (k = 0; k < technique->pass_count; ++k)
494 if (technique->pass_handles[k] == pass)
496 return get_pass_struct(pass);
501 return NULL;
504 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
506 unsigned int i, count;
507 struct d3dx_parameter *p;
509 for (i = 0; i < param->annotation_count; ++i)
511 if (param->annotation_handles[i] == parameter)
513 return get_parameter_struct(parameter);
516 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
517 if (p) return p;
520 if (param->element_count) count = param->element_count;
521 else count = param->member_count;
523 for (i = 0; i < count; ++i)
525 if (param->member_handles[i] == parameter)
527 return get_parameter_struct(parameter);
530 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
531 if (p) return p;
534 return NULL;
537 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
539 unsigned int i, k, m;
540 struct d3dx_parameter *p;
542 for (i = 0; i < base->parameter_count; ++i)
544 if (base->parameter_handles[i] == parameter)
546 return get_parameter_struct(parameter);
549 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
550 if (p) return p;
553 for (i = 0; i < base->technique_count; ++i)
555 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
557 for (k = 0; k < technique->pass_count; ++k)
559 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
561 for (m = 0; m < pass->annotation_count; ++m)
563 if (pass->annotation_handles[i] == parameter)
565 return get_parameter_struct(parameter);
568 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
569 if (p) return p;
573 for (k = 0; k < technique->annotation_count; ++k)
575 if (technique->annotation_handles[k] == parameter)
577 return get_parameter_struct(parameter);
580 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
581 if (p) return p;
585 return NULL;
588 static inline struct d3dx_parameter *get_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
590 struct d3dx_parameter *param = is_valid_parameter(base, parameter);
592 if (!param) param = get_parameter_by_name(base, NULL, parameter);
594 return param;
597 static void free_state(struct d3dx_state *state)
599 free_parameter_state(state->parameter, FALSE, FALSE, state->type);
602 static void free_sampler(struct d3dx_sampler *sampler)
604 UINT i;
606 for (i = 0; i < sampler->state_count; ++i)
608 free_state(&sampler->states[i]);
610 HeapFree(GetProcessHeap(), 0, sampler->states);
613 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
615 free_parameter_state(handle, element, child, ST_CONSTANT);
618 static void free_parameter_state(D3DXHANDLE handle, BOOL element, BOOL child, enum STATE_TYPE st)
620 unsigned int i;
621 struct d3dx_parameter *param = get_parameter_struct(handle);
623 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param, param->name,
624 debug_d3dxparameter_type(param->type), child ? "yes" : "no", st);
626 if (!param)
628 return;
631 if (param->annotation_handles)
633 for (i = 0; i < param->annotation_count; ++i)
635 free_parameter(param->annotation_handles[i], FALSE, FALSE);
637 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
640 if (param->member_handles)
642 unsigned int count;
644 if (param->element_count) count = param->element_count;
645 else count = param->member_count;
647 for (i = 0; i < count; ++i)
649 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
651 HeapFree(GetProcessHeap(), 0, param->member_handles);
654 if (param->class == D3DXPC_OBJECT && !param->element_count)
656 switch (param->type)
658 case D3DXPT_STRING:
659 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
660 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
661 break;
663 case D3DXPT_TEXTURE:
664 case D3DXPT_TEXTURE1D:
665 case D3DXPT_TEXTURE2D:
666 case D3DXPT_TEXTURE3D:
667 case D3DXPT_TEXTURECUBE:
668 case D3DXPT_PIXELSHADER:
669 case D3DXPT_VERTEXSHADER:
670 if (st == ST_CONSTANT)
672 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
674 else
676 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
678 if (!child) HeapFree(GetProcessHeap(), 0, param->data);
679 break;
681 case D3DXPT_SAMPLER:
682 case D3DXPT_SAMPLER1D:
683 case D3DXPT_SAMPLER2D:
684 case D3DXPT_SAMPLER3D:
685 case D3DXPT_SAMPLERCUBE:
686 if (st == ST_CONSTANT)
688 free_sampler((struct d3dx_sampler *)param->data);
690 else
692 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
694 /* samplers have always own data, so free that */
695 HeapFree(GetProcessHeap(), 0, param->data);
696 break;
698 default:
699 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
700 break;
703 else
705 if (!child)
707 if (st != ST_CONSTANT)
709 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
711 HeapFree(GetProcessHeap(), 0, param->data);
715 /* only the parent has to release name and semantic */
716 if (!element)
718 HeapFree(GetProcessHeap(), 0, param->name);
719 HeapFree(GetProcessHeap(), 0, param->semantic);
722 HeapFree(GetProcessHeap(), 0, param);
725 static void free_pass(D3DXHANDLE handle)
727 unsigned int i;
728 struct d3dx_pass *pass = get_pass_struct(handle);
730 TRACE("Free pass %p\n", pass);
732 if (!pass)
734 return;
737 if (pass->annotation_handles)
739 for (i = 0; i < pass->annotation_count; ++i)
741 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
743 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
746 if (pass->states)
748 for (i = 0; i < pass->state_count; ++i)
750 free_state(&pass->states[i]);
752 HeapFree(GetProcessHeap(), 0, pass->states);
755 HeapFree(GetProcessHeap(), 0, pass->name);
756 HeapFree(GetProcessHeap(), 0, pass);
759 static void free_technique(D3DXHANDLE handle)
761 unsigned int i;
762 struct d3dx_technique *technique = get_technique_struct(handle);
764 TRACE("Free technique %p\n", technique);
766 if (!technique)
768 return;
771 if (technique->annotation_handles)
773 for (i = 0; i < technique->annotation_count; ++i)
775 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
777 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
780 if (technique->pass_handles)
782 for (i = 0; i < technique->pass_count; ++i)
784 free_pass(technique->pass_handles[i]);
786 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
789 HeapFree(GetProcessHeap(), 0, technique->name);
790 HeapFree(GetProcessHeap(), 0, technique);
793 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
795 unsigned int i;
797 TRACE("Free base effect %p\n", base);
799 if (base->parameter_handles)
801 for (i = 0; i < base->parameter_count; ++i)
803 free_parameter(base->parameter_handles[i], FALSE, FALSE);
805 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
808 if (base->technique_handles)
810 for (i = 0; i < base->technique_count; ++i)
812 free_technique(base->technique_handles[i]);
814 HeapFree(GetProcessHeap(), 0, base->technique_handles);
818 static void free_effect(struct ID3DXEffectImpl *effect)
820 TRACE("Free effect %p\n", effect);
822 if (effect->base_effect)
824 effect->base_effect->lpVtbl->Release(effect->base_effect);
827 if (effect->pool)
829 effect->pool->lpVtbl->Release(effect->pool);
832 if (effect->manager)
834 IUnknown_Release(effect->manager);
837 IDirect3DDevice9_Release(effect->device);
840 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
842 TRACE("Free effect compiler %p\n", compiler);
844 if (compiler->base_effect)
846 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
850 static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector)
852 UINT i;
854 for (i = 0; i < 4; ++i)
856 if (i < param->columns)
857 set_number((FLOAT *)vector + i, D3DXPT_FLOAT, (DWORD *)param->data + i, param->type);
858 else
859 ((FLOAT *)vector)[i] = 0.0f;
863 static void set_vector(struct d3dx_parameter *param, CONST D3DXVECTOR4 *vector)
865 UINT i;
867 for (i = 0; i < param->columns; ++i)
869 set_number((FLOAT *)param->data + i, param->type, (FLOAT *)vector + i, D3DXPT_FLOAT);
873 static void get_matrix(struct d3dx_parameter *param, D3DXMATRIX *matrix)
875 UINT i, k;
877 for (i = 0; i < 4; ++i)
879 for (k = 0; k < 4; ++k)
881 if ((i < param->rows) && (k < param->columns))
882 set_number((FLOAT *)&matrix->u.m[i][k], D3DXPT_FLOAT, (DWORD *)param->data + i * param->columns + k, param->type);
883 else
884 matrix->u.m[i][k] = 0.0f;
889 static void set_matrix(struct d3dx_parameter *param, const D3DXMATRIX *matrix, BOOL transpose)
891 UINT i, k;
893 for (i = 0; i < param->rows; ++i)
895 for (k = 0; k < param->columns; ++k)
897 set_number((FLOAT *)param->data + i * param->columns + k, param->type,
898 transpose ? &matrix->u.m[k][i] : &matrix->u.m[i][k], D3DXPT_FLOAT);
903 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
905 UINT element;
906 struct d3dx_parameter *temp_parameter;
907 LPCSTR part;
909 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
911 if (!name || !*name) return NULL;
913 element = atoi(name);
914 part = strchr(name, ']') + 1;
916 /* check for empty [] && element range */
917 if ((part - name) > 1 && parameter->element_count > element)
919 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
921 switch (*part++)
923 case '.':
924 return get_parameter_by_name(NULL, temp_parameter, part);
926 case '@':
927 return get_annotation_by_name(temp_parameter->annotation_count, temp_parameter->annotation_handles, part);
929 case '\0':
930 TRACE("Returning parameter %p\n", temp_parameter);
931 return temp_parameter;
933 default:
934 FIXME("Unhandled case \"%c\"\n", *--part);
935 break;
939 TRACE("Parameter not found\n");
940 return NULL;
943 static struct d3dx_parameter *get_annotation_by_name(UINT handlecount, D3DXHANDLE *handles, LPCSTR name)
945 UINT i, length;
946 struct d3dx_parameter *temp_parameter;
947 LPCSTR part;
949 TRACE("handlecount %u, handles %p, name %s\n", handlecount, handles, debugstr_a(name));
951 if (!name || !*name) return NULL;
953 length = strcspn( name, "[.@" );
954 part = name + length;
956 for (i = 0; i < handlecount; ++i)
958 temp_parameter = get_parameter_struct(handles[i]);
960 if (!strcmp(temp_parameter->name, name))
962 TRACE("Returning parameter %p\n", temp_parameter);
963 return temp_parameter;
965 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
967 switch (*part++)
969 case '.':
970 return get_parameter_by_name(NULL, temp_parameter, part);
972 case '[':
973 return get_parameter_element_by_name(temp_parameter, part);
975 default:
976 FIXME("Unhandled case \"%c\"\n", *--part);
977 break;
982 TRACE("Parameter not found\n");
983 return NULL;
986 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
987 struct d3dx_parameter *parameter, LPCSTR name)
989 UINT i, count, length;
990 struct d3dx_parameter *temp_parameter;
991 D3DXHANDLE *handles;
992 LPCSTR part;
994 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
996 if (!name || !*name) return NULL;
998 if (!parameter)
1000 count = base->parameter_count;
1001 handles = base->parameter_handles;
1003 else
1005 count = parameter->member_count;
1006 handles = parameter->member_handles;
1009 length = strcspn( name, "[.@" );
1010 part = name + length;
1012 for (i = 0; i < count; i++)
1014 temp_parameter = get_parameter_struct(handles[i]);
1016 if (!strcmp(temp_parameter->name, name))
1018 TRACE("Returning parameter %p\n", temp_parameter);
1019 return temp_parameter;
1021 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1023 switch (*part++)
1025 case '.':
1026 return get_parameter_by_name(NULL, temp_parameter, part);
1028 case '@':
1029 return get_annotation_by_name(temp_parameter->annotation_count, temp_parameter->annotation_handles, part);
1031 case '[':
1032 return get_parameter_element_by_name(temp_parameter, part);
1034 default:
1035 FIXME("Unhandled case \"%c\"\n", *--part);
1036 break;
1041 TRACE("Parameter not found\n");
1042 return NULL;
1045 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1047 return (0xfeff0000 | ((major) << 8) | (minor));
1050 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1052 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1055 /*** IUnknown methods ***/
1056 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1058 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
1060 if (IsEqualGUID(riid, &IID_IUnknown) ||
1061 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1063 iface->lpVtbl->AddRef(iface);
1064 *object = iface;
1065 return S_OK;
1068 ERR("Interface %s not found\n", debugstr_guid(riid));
1070 return E_NOINTERFACE;
1073 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1075 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1077 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1079 return InterlockedIncrement(&This->ref);
1082 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1084 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1085 ULONG ref = InterlockedDecrement(&This->ref);
1087 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1089 if (!ref)
1091 free_base_effect(This);
1092 HeapFree(GetProcessHeap(), 0, This);
1095 return ref;
1098 /*** ID3DXBaseEffect methods ***/
1099 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1101 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1103 FIXME("iface %p, desc %p partial stub\n", This, desc);
1105 if (!desc)
1107 WARN("Invalid argument specified.\n");
1108 return D3DERR_INVALIDCALL;
1111 /* Todo: add creator and function count */
1112 desc->Creator = NULL;
1113 desc->Functions = 0;
1114 desc->Parameters = This->parameter_count;
1115 desc->Techniques = This->technique_count;
1117 return D3D_OK;
1120 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1122 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1123 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1125 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1127 if (!desc || !param)
1129 WARN("Invalid argument specified.\n");
1130 return D3DERR_INVALIDCALL;
1133 desc->Name = param->name;
1134 desc->Semantic = param->semantic;
1135 desc->Class = param->class;
1136 desc->Type = param->type;
1137 desc->Rows = param->rows;
1138 desc->Columns = param->columns;
1139 desc->Elements = param->element_count;
1140 desc->Annotations = param->annotation_count;
1141 desc->StructMembers = param->member_count;
1142 desc->Flags = param->flags;
1143 desc->Bytes = param->bytes;
1145 return D3D_OK;
1148 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1150 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1151 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1153 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1155 if (!desc || !tech)
1157 WARN("Invalid argument specified.\n");
1158 return D3DERR_INVALIDCALL;
1161 desc->Name = tech->name;
1162 desc->Passes = tech->pass_count;
1163 desc->Annotations = tech->annotation_count;
1165 return D3D_OK;
1168 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1170 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1171 struct d3dx_pass *p = is_valid_pass(This, pass);
1173 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1175 if (!desc || !p)
1177 WARN("Invalid argument specified.\n");
1178 return D3DERR_INVALIDCALL;
1181 desc->Name = p->name;
1182 desc->Annotations = p->annotation_count;
1184 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1185 desc->pVertexShaderFunction = NULL;
1186 desc->pPixelShaderFunction = NULL;
1188 return D3D_OK;
1191 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1193 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1195 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1197 return E_NOTIMPL;
1200 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1202 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1203 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1205 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1207 if (!parameter)
1209 if (index < This->parameter_count)
1211 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1212 return This->parameter_handles[index];
1215 else
1217 if (param && !param->element_count && index < param->member_count)
1219 TRACE("Returning parameter %p\n", param->member_handles[index]);
1220 return param->member_handles[index];
1224 WARN("Invalid argument specified.\n");
1226 return NULL;
1229 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1231 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1232 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1233 D3DXHANDLE handle;
1235 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1237 if (!name)
1239 handle = get_parameter_handle(param);
1240 TRACE("Returning parameter %p\n", handle);
1241 return handle;
1244 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1245 TRACE("Returning parameter %p\n", handle);
1247 return handle;
1250 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1252 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1253 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1254 struct d3dx_parameter *temp_param;
1255 UINT i;
1257 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1259 if (!parameter)
1261 for (i = 0; i < This->parameter_count; ++i)
1263 temp_param = get_parameter_struct(This->parameter_handles[i]);
1265 if (!temp_param->semantic)
1267 if (!semantic)
1269 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1270 return This->parameter_handles[i];
1272 continue;
1275 if (!strcasecmp(temp_param->semantic, semantic))
1277 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1278 return This->parameter_handles[i];
1282 else if (param)
1284 for (i = 0; i < param->member_count; ++i)
1286 temp_param = get_parameter_struct(param->member_handles[i]);
1288 if (!temp_param->semantic)
1290 if (!semantic)
1292 TRACE("Returning parameter %p\n", param->member_handles[i]);
1293 return param->member_handles[i];
1295 continue;
1298 if (!strcasecmp(temp_param->semantic, semantic))
1300 TRACE("Returning parameter %p\n", param->member_handles[i]);
1301 return param->member_handles[i];
1306 WARN("Invalid argument specified\n");
1308 return NULL;
1311 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1313 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1314 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1316 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1318 if (!param)
1320 if (index < This->parameter_count)
1322 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1323 return This->parameter_handles[index];
1326 else
1328 if (index < param->element_count)
1330 TRACE("Returning parameter %p\n", param->member_handles[index]);
1331 return param->member_handles[index];
1335 WARN("Invalid argument specified\n");
1337 return NULL;
1340 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1342 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1344 TRACE("iface %p, index %u\n", This, index);
1346 if (index >= This->technique_count)
1348 WARN("Invalid argument specified.\n");
1349 return NULL;
1352 TRACE("Returning technique %p\n", This->technique_handles[index]);
1354 return This->technique_handles[index];
1357 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1359 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1360 struct d3dx_technique *tech = get_technique_by_name(This, name);
1362 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1364 if (tech)
1366 D3DXHANDLE t = get_technique_handle(tech);
1367 TRACE("Returning technique %p\n", t);
1368 return t;
1371 WARN("Invalid argument specified.\n");
1373 return NULL;
1376 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1378 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1379 struct d3dx_technique *tech = is_valid_technique(This, technique);
1381 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1383 if (tech && index < tech->pass_count)
1385 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1386 return tech->pass_handles[index];
1389 WARN("Invalid argument specified.\n");
1391 return NULL;
1394 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1396 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1397 struct d3dx_technique *tech = is_valid_technique(This, technique);
1399 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1401 if (tech && name)
1403 unsigned int i;
1405 for (i = 0; i < tech->pass_count; ++i)
1407 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1409 if (!strcmp(pass->name, name))
1411 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1412 return tech->pass_handles[i];
1417 WARN("Invalid argument specified.\n");
1419 return NULL;
1422 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1424 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1426 FIXME("iface %p, index %u stub\n", This, index);
1428 return NULL;
1431 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1433 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1435 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1437 return NULL;
1440 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1442 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1443 struct d3dx_parameter *param = get_valid_parameter(This, object);
1444 struct d3dx_pass *pass = is_valid_pass(This, object);
1445 struct d3dx_technique *technique = is_valid_technique(This, object);
1446 UINT annotation_count = 0;
1447 D3DXHANDLE *annotation_handles = NULL;
1449 TRACE("iface %p, object %p, index %u\n", This, object, index);
1451 if (pass)
1453 annotation_count = pass->annotation_count;
1454 annotation_handles = pass->annotation_handles;
1456 else if (technique)
1458 annotation_count = technique->annotation_count;
1459 annotation_handles = technique->annotation_handles;
1461 else if (param)
1463 annotation_count = param->annotation_count;
1464 annotation_handles = param->annotation_handles;
1466 else
1468 FIXME("Functions are not handled, yet!\n");
1471 if (index < annotation_count)
1473 TRACE("Returning parameter %p\n", annotation_handles[index]);
1474 return annotation_handles[index];
1477 WARN("Invalid argument specified\n");
1479 return NULL;
1482 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1484 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1485 struct d3dx_parameter *param = get_valid_parameter(This, object);
1486 struct d3dx_pass *pass = is_valid_pass(This, object);
1487 struct d3dx_technique *technique = is_valid_technique(This, object);
1488 struct d3dx_parameter *anno = NULL;
1489 UINT annotation_count = 0;
1490 D3DXHANDLE *annotation_handles = NULL;
1492 TRACE("iface %p, object %p, name %s\n", This, object, debugstr_a(name));
1494 if (!name)
1496 WARN("Invalid argument specified\n");
1497 return NULL;
1500 if (pass)
1502 annotation_count = pass->annotation_count;
1503 annotation_handles = pass->annotation_handles;
1505 else if (technique)
1507 annotation_count = technique->annotation_count;
1508 annotation_handles = technique->annotation_handles;
1510 else if (param)
1512 annotation_count = param->annotation_count;
1513 annotation_handles = param->annotation_handles;
1515 else
1517 FIXME("Functions are not handled, yet!\n");
1520 anno = get_annotation_by_name(annotation_count, annotation_handles, name);
1521 if (anno)
1523 TRACE("Returning parameter %p\n", anno);
1524 return get_parameter_handle(anno);
1527 WARN("Invalid argument specified\n");
1529 return NULL;
1532 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1534 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1535 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1537 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1539 if (!param)
1541 WARN("Invalid parameter %p specified\n", parameter);
1542 return D3DERR_INVALIDCALL;
1545 /* samplers don't touch data */
1546 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1547 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1548 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1550 TRACE("Sampler: returning E_FAIL\n");
1551 return E_FAIL;
1554 if (data && param->bytes <= bytes)
1556 switch (param->type)
1558 case D3DXPT_VOID:
1559 case D3DXPT_BOOL:
1560 case D3DXPT_INT:
1561 case D3DXPT_FLOAT:
1562 TRACE("Copy %u bytes\n", param->bytes);
1563 memcpy(param->data, data, param->bytes);
1564 break;
1566 default:
1567 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1568 break;
1571 return D3D_OK;
1574 WARN("Invalid argument specified\n");
1576 return D3DERR_INVALIDCALL;
1579 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1581 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1582 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1584 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1586 if (!param)
1588 WARN("Invalid parameter %p specified\n", parameter);
1589 return D3DERR_INVALIDCALL;
1592 /* samplers don't touch data */
1593 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1594 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1595 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1597 TRACE("Sampler: returning E_FAIL\n");
1598 return E_FAIL;
1601 if (data && param->bytes <= bytes)
1603 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1605 switch (param->type)
1607 case D3DXPT_VOID:
1608 case D3DXPT_BOOL:
1609 case D3DXPT_INT:
1610 case D3DXPT_FLOAT:
1611 case D3DXPT_STRING:
1612 break;
1614 case D3DXPT_VERTEXSHADER:
1615 case D3DXPT_PIXELSHADER:
1616 case D3DXPT_TEXTURE:
1617 case D3DXPT_TEXTURE1D:
1618 case D3DXPT_TEXTURE2D:
1619 case D3DXPT_TEXTURE3D:
1620 case D3DXPT_TEXTURECUBE:
1622 UINT i;
1624 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1626 IUnknown *unk = ((IUnknown **)param->data)[i];
1627 if (unk) IUnknown_AddRef(unk);
1629 break;
1632 default:
1633 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1634 break;
1637 TRACE("Copy %u bytes\n", param->bytes);
1638 memcpy(data, param->data, param->bytes);
1639 return D3D_OK;
1642 WARN("Invalid argument specified\n");
1644 return D3DERR_INVALIDCALL;
1647 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1649 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1650 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1652 TRACE("iface %p, parameter %p, b %s\n", This, parameter, b ? "TRUE" : "FALSE");
1654 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1656 set_number(param->data, param->type, &b, D3DXPT_BOOL);
1657 return D3D_OK;
1660 WARN("Invalid argument specified\n");
1662 return D3DERR_INVALIDCALL;
1665 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1667 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1668 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1670 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1672 if (b && param && !param->element_count && param->rows == 1 && param->columns == 1)
1674 set_number(b, D3DXPT_BOOL, param->data, param->type);
1675 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1676 return D3D_OK;
1679 WARN("Invalid argument specified\n");
1681 return D3DERR_INVALIDCALL;
1684 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1686 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1687 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1689 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1691 if (param)
1693 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1695 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1697 switch (param->class)
1699 case D3DXPC_SCALAR:
1700 case D3DXPC_VECTOR:
1701 case D3DXPC_MATRIX_ROWS:
1702 for (i = 0; i < size; ++i)
1704 /* don't crop the input, use D3DXPT_INT instead of D3DXPT_BOOL */
1705 set_number((DWORD *)param->data + i, param->type, &b[i], D3DXPT_INT);
1707 return D3D_OK;
1709 case D3DXPC_OBJECT:
1710 case D3DXPC_STRUCT:
1711 break;
1713 default:
1714 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1715 break;
1719 WARN("Invalid argument specified\n");
1721 return D3DERR_INVALIDCALL;
1724 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1726 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1727 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1729 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1731 if (b && param && (param->class == D3DXPC_SCALAR
1732 || param->class == D3DXPC_VECTOR
1733 || param->class == D3DXPC_MATRIX_ROWS
1734 || param->class == D3DXPC_MATRIX_COLUMNS))
1736 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1738 for (i = 0; i < size; ++i)
1740 set_number(&b[i], D3DXPT_BOOL, (DWORD *)param->data + i, param->type);
1742 return D3D_OK;
1745 WARN("Invalid argument specified\n");
1747 return D3DERR_INVALIDCALL;
1750 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1752 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1753 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1755 TRACE("iface %p, parameter %p, n %i\n", This, parameter, n);
1757 if (param && !param->element_count)
1759 if (param->rows == 1 && param->columns == 1)
1761 set_number(param->data, param->type, &n, D3DXPT_INT);
1762 return D3D_OK;
1766 * Split the value, if parameter is a vector with dimension 3 or 4.
1768 if (param->type == D3DXPT_FLOAT &&
1769 ((param->class == D3DXPC_VECTOR && param->columns != 2) ||
1770 (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1772 TRACE("Vector fixup\n");
1774 *(FLOAT *)param->data = ((n & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
1775 ((FLOAT *)param->data)[1] = ((n & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
1776 ((FLOAT *)param->data)[2] = (n & 0xff) * INT_FLOAT_MULTI_INVERSE;
1777 if (param->rows * param->columns > 3)
1779 ((FLOAT *)param->data)[3] = ((n & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
1781 return D3D_OK;
1785 WARN("Invalid argument specified\n");
1787 return D3DERR_INVALIDCALL;
1790 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1792 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1793 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1795 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1797 if (n && param && !param->element_count)
1799 if (param->columns == 1 && param->rows == 1)
1801 set_number(n, D3DXPT_INT, param->data, param->type);
1802 TRACE("Returning %i\n", *n);
1803 return D3D_OK;
1806 if (param->type == D3DXPT_FLOAT &&
1807 ((param->class == D3DXPC_VECTOR && param->columns != 2)
1808 || (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1810 TRACE("Vector fixup\n");
1812 /* all components (3,4) are clamped (0,255) and put in the INT */
1813 *n = (INT)(min(max(0.0f, *((FLOAT *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI);
1814 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
1815 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
1816 if (param->columns * param->rows > 3)
1818 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
1821 TRACE("Returning %i\n", *n);
1822 return D3D_OK;
1826 WARN("Invalid argument specified\n");
1828 return D3DERR_INVALIDCALL;
1831 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1833 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1834 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1836 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1838 if (param)
1840 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1842 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1844 switch (param->class)
1846 case D3DXPC_SCALAR:
1847 case D3DXPC_VECTOR:
1848 case D3DXPC_MATRIX_ROWS:
1849 for (i = 0; i < size; ++i)
1851 set_number((DWORD *)param->data + i, param->type, &n[i], D3DXPT_INT);
1853 return D3D_OK;
1855 case D3DXPC_OBJECT:
1856 case D3DXPC_STRUCT:
1857 break;
1859 default:
1860 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1861 break;
1865 WARN("Invalid argument specified\n");
1867 return D3DERR_INVALIDCALL;
1870 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1872 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1873 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1875 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1877 if (n && param && (param->class == D3DXPC_SCALAR
1878 || param->class == D3DXPC_VECTOR
1879 || param->class == D3DXPC_MATRIX_ROWS
1880 || param->class == D3DXPC_MATRIX_COLUMNS))
1882 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1884 for (i = 0; i < size; ++i)
1886 set_number(&n[i], D3DXPT_INT, (DWORD *)param->data + i, param->type);
1888 return D3D_OK;
1891 WARN("Invalid argument specified\n");
1893 return D3DERR_INVALIDCALL;
1896 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1898 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1899 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1901 TRACE("iface %p, parameter %p, f %f\n", This, parameter, f);
1903 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1905 set_number((DWORD *)param->data, param->type, &f, D3DXPT_FLOAT);
1906 return D3D_OK;
1909 WARN("Invalid argument specified\n");
1911 return D3DERR_INVALIDCALL;
1914 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1916 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1917 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1919 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1921 if (f && param && !param->element_count && param->columns == 1 && param->rows == 1)
1923 set_number(f, D3DXPT_FLOAT, (DWORD *)param->data, param->type);
1924 TRACE("Returning %f\n", *f);
1925 return D3D_OK;
1928 WARN("Invalid argument specified\n");
1930 return D3DERR_INVALIDCALL;
1933 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1935 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1936 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1938 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1940 if (param)
1942 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1944 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1946 switch (param->class)
1948 case D3DXPC_SCALAR:
1949 case D3DXPC_VECTOR:
1950 case D3DXPC_MATRIX_ROWS:
1951 for (i = 0; i < size; ++i)
1953 set_number((DWORD *)param->data + i, param->type, &f[i], D3DXPT_FLOAT);
1955 return D3D_OK;
1957 case D3DXPC_OBJECT:
1958 case D3DXPC_STRUCT:
1959 break;
1961 default:
1962 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1963 break;
1967 WARN("Invalid argument specified\n");
1969 return D3DERR_INVALIDCALL;
1972 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1974 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1975 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1977 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1979 if (f && param && (param->class == D3DXPC_SCALAR
1980 || param->class == D3DXPC_VECTOR
1981 || param->class == D3DXPC_MATRIX_ROWS
1982 || param->class == D3DXPC_MATRIX_COLUMNS))
1984 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1986 for (i = 0; i < size; ++i)
1988 set_number(&f[i], D3DXPT_FLOAT, (DWORD *)param->data + i, param->type);
1990 return D3D_OK;
1993 WARN("Invalid argument specified\n");
1995 return D3DERR_INVALIDCALL;
1998 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2000 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2001 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2003 TRACE("iface %p, parameter %p, vector %p\n", This, parameter, vector);
2005 if (param && !param->element_count)
2007 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2009 switch (param->class)
2011 case D3DXPC_SCALAR:
2012 case D3DXPC_VECTOR:
2013 if (param->type == D3DXPT_INT && param->bytes == 4)
2015 DWORD tmp;
2017 TRACE("INT fixup\n");
2018 tmp = (DWORD)(max(min(vector->z, 1.0f), 0.0f) * INT_FLOAT_MULTI);
2019 tmp += ((DWORD)(max(min(vector->y, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 8;
2020 tmp += ((DWORD)(max(min(vector->x, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 16;
2021 tmp += ((DWORD)(max(min(vector->w, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 24;
2023 *(INT *)param->data = tmp;
2024 return D3D_OK;
2026 set_vector(param, vector);
2027 return D3D_OK;
2029 case D3DXPC_MATRIX_ROWS:
2030 case D3DXPC_OBJECT:
2031 case D3DXPC_STRUCT:
2032 break;
2034 default:
2035 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2036 break;
2040 WARN("Invalid argument specified\n");
2042 return D3DERR_INVALIDCALL;
2045 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2047 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2048 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2050 TRACE("iface %p, parameter %p, vector %p\n", This, parameter, vector);
2052 if (vector && param && !param->element_count)
2054 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2056 switch (param->class)
2058 case D3DXPC_SCALAR:
2059 case D3DXPC_VECTOR:
2060 if (param->type == D3DXPT_INT && param->bytes == 4)
2062 TRACE("INT fixup\n");
2063 vector->x = (((*(INT *)param->data) & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
2064 vector->y = (((*(INT *)param->data) & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
2065 vector->z = ((*(INT *)param->data) & 0xff) * INT_FLOAT_MULTI_INVERSE;
2066 vector->w = (((*(INT *)param->data) & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
2067 return D3D_OK;
2069 get_vector(param, vector);
2070 return D3D_OK;
2072 case D3DXPC_MATRIX_ROWS:
2073 case D3DXPC_OBJECT:
2074 case D3DXPC_STRUCT:
2075 break;
2077 default:
2078 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2079 break;
2083 WARN("Invalid argument specified\n");
2085 return D3DERR_INVALIDCALL;
2088 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2090 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2091 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2093 TRACE("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
2095 if (param && param->element_count && param->element_count >= count)
2097 UINT i;
2099 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2101 switch (param->class)
2103 case D3DXPC_VECTOR:
2104 for (i = 0; i < count; ++i)
2106 set_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2108 return D3D_OK;
2110 case D3DXPC_SCALAR:
2111 case D3DXPC_MATRIX_ROWS:
2112 case D3DXPC_OBJECT:
2113 case D3DXPC_STRUCT:
2114 break;
2116 default:
2117 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2118 break;
2122 WARN("Invalid argument specified\n");
2124 return D3DERR_INVALIDCALL;
2127 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2129 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2130 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2132 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
2134 if (!count) return D3D_OK;
2136 if (vector && param && count <= param->element_count)
2138 UINT i;
2140 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2142 switch (param->class)
2144 case D3DXPC_VECTOR:
2145 for (i = 0; i < count; ++i)
2147 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2149 return D3D_OK;
2151 case D3DXPC_SCALAR:
2152 case D3DXPC_MATRIX_ROWS:
2153 case D3DXPC_OBJECT:
2154 case D3DXPC_STRUCT:
2155 break;
2157 default:
2158 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2159 break;
2163 WARN("Invalid argument specified\n");
2165 return D3DERR_INVALIDCALL;
2168 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
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\n", This, parameter, matrix);
2175 if (param && !param->element_count)
2177 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2179 switch (param->class)
2181 case D3DXPC_MATRIX_ROWS:
2182 set_matrix(param, matrix, FALSE);
2183 return D3D_OK;
2185 case D3DXPC_SCALAR:
2186 case D3DXPC_VECTOR:
2187 case D3DXPC_OBJECT:
2188 case D3DXPC_STRUCT:
2189 break;
2191 default:
2192 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2193 break;
2197 WARN("Invalid argument specified\n");
2199 return D3DERR_INVALIDCALL;
2202 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2204 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2205 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2207 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2209 if (matrix && param && !param->element_count)
2211 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2213 switch (param->class)
2215 case D3DXPC_MATRIX_ROWS:
2216 get_matrix(param, matrix);
2217 return D3D_OK;
2219 case D3DXPC_SCALAR:
2220 case D3DXPC_VECTOR:
2221 case D3DXPC_OBJECT:
2222 case D3DXPC_STRUCT:
2223 break;
2225 default:
2226 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2227 break;
2231 WARN("Invalid argument specified\n");
2233 return D3DERR_INVALIDCALL;
2236 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2238 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2239 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2241 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2243 if (param && param->element_count >= count)
2245 UINT i;
2247 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2249 switch (param->class)
2251 case D3DXPC_MATRIX_ROWS:
2252 for (i = 0; i < count; ++i)
2254 set_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], FALSE);
2256 return D3D_OK;
2258 case D3DXPC_SCALAR:
2259 case D3DXPC_VECTOR:
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_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2277 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2278 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2280 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2282 if (!count) return D3D_OK;
2284 if (matrix && param && count <= param->element_count)
2286 UINT i;
2288 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2290 switch (param->class)
2292 case D3DXPC_MATRIX_ROWS:
2293 for (i = 0; i < count; ++i)
2295 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i]);
2297 return D3D_OK;
2299 case D3DXPC_SCALAR:
2300 case D3DXPC_VECTOR:
2301 case D3DXPC_OBJECT:
2302 case D3DXPC_STRUCT:
2303 break;
2305 default:
2306 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2307 break;
2311 WARN("Invalid argument specified\n");
2313 return D3DERR_INVALIDCALL;
2316 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2318 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2319 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2321 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2323 if (param && count <= param->element_count)
2325 UINT i;
2327 switch (param->class)
2329 case D3DXPC_MATRIX_ROWS:
2330 for (i = 0; i < count; ++i)
2332 set_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], FALSE);
2334 return D3D_OK;
2336 case D3DXPC_SCALAR:
2337 case D3DXPC_VECTOR:
2338 case D3DXPC_OBJECT:
2339 break;
2341 default:
2342 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2343 break;
2347 WARN("Invalid argument specified\n");
2349 return D3DERR_INVALIDCALL;
2352 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2354 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2355 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2357 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2359 if (!count) return D3D_OK;
2361 if (param && matrix && count <= param->element_count)
2363 UINT i;
2365 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2367 switch (param->class)
2369 case D3DXPC_MATRIX_ROWS:
2370 for (i = 0; i < count; ++i)
2372 get_matrix(get_parameter_struct(param->member_handles[i]), matrix[i]);
2374 return D3D_OK;
2376 case D3DXPC_SCALAR:
2377 case D3DXPC_VECTOR:
2378 case D3DXPC_OBJECT:
2379 break;
2381 default:
2382 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2383 break;
2387 WARN("Invalid argument specified\n");
2389 return D3DERR_INVALIDCALL;
2392 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2394 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2395 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2397 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2399 if (param && !param->element_count)
2401 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2403 switch (param->class)
2405 case D3DXPC_MATRIX_ROWS:
2406 set_matrix(param, matrix, TRUE);
2407 return D3D_OK;
2409 case D3DXPC_SCALAR:
2410 case D3DXPC_VECTOR:
2411 case D3DXPC_OBJECT:
2412 case D3DXPC_STRUCT:
2413 break;
2415 default:
2416 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2417 break;
2421 WARN("Invalid argument specified\n");
2423 return D3DERR_INVALIDCALL;
2426 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2428 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2429 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2430 D3DXMATRIX m;
2432 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2434 if (matrix && param && !param->element_count)
2436 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2438 switch (param->class)
2440 case D3DXPC_SCALAR:
2441 case D3DXPC_VECTOR:
2442 get_matrix(param, matrix);
2443 return D3D_OK;
2445 case D3DXPC_MATRIX_ROWS:
2446 get_matrix(param, &m);
2447 D3DXMatrixTranspose(matrix, &m);
2448 return D3D_OK;
2450 case D3DXPC_OBJECT:
2451 case D3DXPC_STRUCT:
2452 break;
2454 default:
2455 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2456 break;
2460 WARN("Invalid argument specified\n");
2462 return D3DERR_INVALIDCALL;
2465 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2467 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2468 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2470 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2472 if (param && param->element_count >= count)
2474 UINT i;
2476 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2478 switch (param->class)
2480 case D3DXPC_MATRIX_ROWS:
2481 for (i = 0; i < count; ++i)
2483 set_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], TRUE);
2485 return D3D_OK;
2487 case D3DXPC_SCALAR:
2488 case D3DXPC_VECTOR:
2489 case D3DXPC_OBJECT:
2490 case D3DXPC_STRUCT:
2491 break;
2493 default:
2494 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2495 break;
2499 WARN("Invalid argument specified\n");
2501 return D3DERR_INVALIDCALL;
2504 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2506 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2507 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2509 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2511 if (!count) return D3D_OK;
2513 if (matrix && param && count <= param->element_count)
2515 UINT i;
2517 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2519 switch (param->class)
2521 case D3DXPC_MATRIX_ROWS:
2522 for (i = 0; i < count; ++i)
2524 D3DXMATRIX m;
2526 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2527 D3DXMatrixTranspose(&matrix[i], &m);
2529 return D3D_OK;
2531 case D3DXPC_SCALAR:
2532 case D3DXPC_VECTOR:
2533 case D3DXPC_OBJECT:
2534 case D3DXPC_STRUCT:
2535 break;
2537 default:
2538 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2539 break;
2543 WARN("Invalid argument specified\n");
2545 return D3DERR_INVALIDCALL;
2548 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2550 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2551 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2553 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2555 if (param && count <= param->element_count)
2557 UINT i;
2559 switch (param->class)
2561 case D3DXPC_MATRIX_ROWS:
2562 for (i = 0; i < count; ++i)
2564 set_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], TRUE);
2566 return D3D_OK;
2568 case D3DXPC_SCALAR:
2569 case D3DXPC_VECTOR:
2570 case D3DXPC_OBJECT:
2571 break;
2573 default:
2574 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2575 break;
2579 WARN("Invalid argument specified\n");
2581 return D3DERR_INVALIDCALL;
2584 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2586 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2587 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2589 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2591 if (!count) return D3D_OK;
2593 if (matrix && param && count <= param->element_count)
2595 UINT i;
2596 D3DXMATRIX m;
2598 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2600 switch (param->class)
2602 case D3DXPC_MATRIX_ROWS:
2603 for (i = 0; i < count; ++i)
2605 get_matrix(get_parameter_struct(param->member_handles[i]), &m);
2606 D3DXMatrixTranspose(matrix[i], &m);
2608 return D3D_OK;
2610 case D3DXPC_SCALAR:
2611 case D3DXPC_VECTOR:
2612 case D3DXPC_OBJECT:
2613 break;
2615 default:
2616 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2617 break;
2621 WARN("Invalid argument specified\n");
2623 return D3DERR_INVALIDCALL;
2626 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2628 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2630 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2632 return E_NOTIMPL;
2635 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2637 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2638 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2640 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2642 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2644 *string = *(LPCSTR *)param->data;
2645 TRACE("Returning %s\n", debugstr_a(*string));
2646 return D3D_OK;
2649 WARN("Invalid argument specified\n");
2651 return D3DERR_INVALIDCALL;
2654 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2656 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2657 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2659 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2661 if (param && !param->element_count &&
2662 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2663 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2664 || param->type == D3DXPT_TEXTURECUBE))
2666 LPDIRECT3DBASETEXTURE9 oltexture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2668 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2669 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2671 *(LPDIRECT3DBASETEXTURE9 *)param->data = texture;
2673 return D3D_OK;
2676 WARN("Invalid argument specified\n");
2678 return D3DERR_INVALIDCALL;
2681 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2683 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2684 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2686 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2688 if (texture && param && !param->element_count &&
2689 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2690 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2691 || param->type == D3DXPT_TEXTURECUBE))
2693 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
2694 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2695 TRACE("Returning %p\n", *texture);
2696 return D3D_OK;
2699 WARN("Invalid argument specified\n");
2701 return D3DERR_INVALIDCALL;
2704 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2706 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2707 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2709 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
2711 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2713 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
2714 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
2715 TRACE("Returning %p\n", *pshader);
2716 return D3D_OK;
2719 WARN("Invalid argument specified\n");
2721 return D3DERR_INVALIDCALL;
2724 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2726 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2727 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2729 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
2731 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2733 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
2734 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
2735 TRACE("Returning %p\n", *vshader);
2736 return D3D_OK;
2739 WARN("Invalid argument specified\n");
2741 return D3DERR_INVALIDCALL;
2744 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2746 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2748 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2750 return E_NOTIMPL;
2753 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2755 /*** IUnknown methods ***/
2756 ID3DXBaseEffectImpl_QueryInterface,
2757 ID3DXBaseEffectImpl_AddRef,
2758 ID3DXBaseEffectImpl_Release,
2759 /*** ID3DXBaseEffect methods ***/
2760 ID3DXBaseEffectImpl_GetDesc,
2761 ID3DXBaseEffectImpl_GetParameterDesc,
2762 ID3DXBaseEffectImpl_GetTechniqueDesc,
2763 ID3DXBaseEffectImpl_GetPassDesc,
2764 ID3DXBaseEffectImpl_GetFunctionDesc,
2765 ID3DXBaseEffectImpl_GetParameter,
2766 ID3DXBaseEffectImpl_GetParameterByName,
2767 ID3DXBaseEffectImpl_GetParameterBySemantic,
2768 ID3DXBaseEffectImpl_GetParameterElement,
2769 ID3DXBaseEffectImpl_GetTechnique,
2770 ID3DXBaseEffectImpl_GetTechniqueByName,
2771 ID3DXBaseEffectImpl_GetPass,
2772 ID3DXBaseEffectImpl_GetPassByName,
2773 ID3DXBaseEffectImpl_GetFunction,
2774 ID3DXBaseEffectImpl_GetFunctionByName,
2775 ID3DXBaseEffectImpl_GetAnnotation,
2776 ID3DXBaseEffectImpl_GetAnnotationByName,
2777 ID3DXBaseEffectImpl_SetValue,
2778 ID3DXBaseEffectImpl_GetValue,
2779 ID3DXBaseEffectImpl_SetBool,
2780 ID3DXBaseEffectImpl_GetBool,
2781 ID3DXBaseEffectImpl_SetBoolArray,
2782 ID3DXBaseEffectImpl_GetBoolArray,
2783 ID3DXBaseEffectImpl_SetInt,
2784 ID3DXBaseEffectImpl_GetInt,
2785 ID3DXBaseEffectImpl_SetIntArray,
2786 ID3DXBaseEffectImpl_GetIntArray,
2787 ID3DXBaseEffectImpl_SetFloat,
2788 ID3DXBaseEffectImpl_GetFloat,
2789 ID3DXBaseEffectImpl_SetFloatArray,
2790 ID3DXBaseEffectImpl_GetFloatArray,
2791 ID3DXBaseEffectImpl_SetVector,
2792 ID3DXBaseEffectImpl_GetVector,
2793 ID3DXBaseEffectImpl_SetVectorArray,
2794 ID3DXBaseEffectImpl_GetVectorArray,
2795 ID3DXBaseEffectImpl_SetMatrix,
2796 ID3DXBaseEffectImpl_GetMatrix,
2797 ID3DXBaseEffectImpl_SetMatrixArray,
2798 ID3DXBaseEffectImpl_GetMatrixArray,
2799 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2800 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2801 ID3DXBaseEffectImpl_SetMatrixTranspose,
2802 ID3DXBaseEffectImpl_GetMatrixTranspose,
2803 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2804 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2805 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2806 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2807 ID3DXBaseEffectImpl_SetString,
2808 ID3DXBaseEffectImpl_GetString,
2809 ID3DXBaseEffectImpl_SetTexture,
2810 ID3DXBaseEffectImpl_GetTexture,
2811 ID3DXBaseEffectImpl_GetPixelShader,
2812 ID3DXBaseEffectImpl_GetVertexShader,
2813 ID3DXBaseEffectImpl_SetArrayRange,
2816 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2818 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2821 /*** IUnknown methods ***/
2822 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2824 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
2826 if (IsEqualGUID(riid, &IID_IUnknown) ||
2827 IsEqualGUID(riid, &IID_ID3DXEffect))
2829 iface->lpVtbl->AddRef(iface);
2830 *object = iface;
2831 return S_OK;
2834 ERR("Interface %s not found\n", debugstr_guid(riid));
2836 return E_NOINTERFACE;
2839 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2841 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2843 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2845 return InterlockedIncrement(&This->ref);
2848 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2850 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2851 ULONG ref = InterlockedDecrement(&This->ref);
2853 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2855 if (!ref)
2857 free_effect(This);
2858 HeapFree(GetProcessHeap(), 0, This);
2861 return ref;
2864 /*** ID3DXBaseEffect methods ***/
2865 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2867 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2868 ID3DXBaseEffect *base = This->base_effect;
2870 TRACE("Forward iface %p, base %p\n", This, base);
2872 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2875 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2877 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2878 ID3DXBaseEffect *base = This->base_effect;
2880 TRACE("Forward iface %p, base %p\n", This, base);
2882 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2885 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2887 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2888 ID3DXBaseEffect *base = This->base_effect;
2890 TRACE("Forward iface %p, base %p\n", This, base);
2892 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2895 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2897 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2898 ID3DXBaseEffect *base = This->base_effect;
2900 TRACE("Forward iface %p, base %p\n", This, base);
2902 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2905 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2907 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2908 ID3DXBaseEffect *base = This->base_effect;
2910 TRACE("Forward iface %p, base %p\n", This, base);
2912 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2915 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2917 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2918 ID3DXBaseEffect *base = This->base_effect;
2920 TRACE("Forward iface %p, base %p\n", This, base);
2922 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2925 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2927 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2928 ID3DXBaseEffect *base = This->base_effect;
2930 TRACE("Forward iface %p, base %p\n", This, base);
2932 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2935 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2937 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2938 ID3DXBaseEffect *base = This->base_effect;
2940 TRACE("Forward iface %p, base %p\n", This, base);
2942 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2945 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2947 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2948 ID3DXBaseEffect *base = This->base_effect;
2950 TRACE("Forward iface %p, base %p\n", This, base);
2952 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2955 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2957 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2958 ID3DXBaseEffect *base = This->base_effect;
2960 TRACE("Forward iface %p, base %p\n", This, base);
2962 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2965 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2967 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2968 ID3DXBaseEffect *base = This->base_effect;
2970 TRACE("Forward iface %p, base %p\n", This, base);
2972 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2975 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2977 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2978 ID3DXBaseEffect *base = This->base_effect;
2980 TRACE("Forward iface %p, base %p\n", This, base);
2982 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2985 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2987 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2988 ID3DXBaseEffect *base = This->base_effect;
2990 TRACE("Forward iface %p, base %p\n", This, base);
2992 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2995 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2997 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2998 ID3DXBaseEffect *base = This->base_effect;
3000 TRACE("Forward iface %p, base %p\n", This, base);
3002 return ID3DXBaseEffectImpl_GetFunction(base, index);
3005 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
3007 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3008 ID3DXBaseEffect *base = This->base_effect;
3010 TRACE("Forward iface %p, base %p\n", This, base);
3012 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3015 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
3017 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3018 ID3DXBaseEffect *base = This->base_effect;
3020 TRACE("Forward iface %p, base %p\n", This, base);
3022 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3025 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
3027 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3028 ID3DXBaseEffect *base = This->base_effect;
3030 TRACE("Forward iface %p, base %p\n", This, base);
3032 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3035 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3037 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3038 ID3DXBaseEffect *base = This->base_effect;
3040 TRACE("Forward iface %p, base %p\n", This, base);
3042 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3045 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3047 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3048 ID3DXBaseEffect *base = This->base_effect;
3050 TRACE("Forward iface %p, base %p\n", This, base);
3052 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3055 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
3057 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3058 ID3DXBaseEffect *base = This->base_effect;
3060 TRACE("Forward iface %p, base %p\n", This, base);
3062 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3065 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
3067 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3068 ID3DXBaseEffect *base = This->base_effect;
3070 TRACE("Forward iface %p, base %p\n", This, base);
3072 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3075 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3077 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3078 ID3DXBaseEffect *base = This->base_effect;
3080 TRACE("Forward iface %p, base %p\n", This, base);
3082 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3085 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3087 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3088 ID3DXBaseEffect *base = This->base_effect;
3090 TRACE("Forward iface %p, base %p\n", This, base);
3092 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3095 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
3097 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3098 ID3DXBaseEffect *base = This->base_effect;
3100 TRACE("Forward iface %p, base %p\n", This, base);
3102 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3105 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
3107 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3108 ID3DXBaseEffect *base = This->base_effect;
3110 TRACE("Forward iface %p, base %p\n", This, base);
3112 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3115 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3117 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3118 ID3DXBaseEffect *base = This->base_effect;
3120 TRACE("Forward iface %p, base %p\n", This, base);
3122 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3125 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
3127 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3128 ID3DXBaseEffect *base = This->base_effect;
3130 TRACE("Forward iface %p, base %p\n", This, base);
3132 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3135 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
3137 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3138 ID3DXBaseEffect *base = This->base_effect;
3140 TRACE("Forward iface %p, base %p\n", This, base);
3142 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3145 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
3147 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3148 ID3DXBaseEffect *base = This->base_effect;
3150 TRACE("Forward iface %p, base %p\n", This, base);
3152 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3155 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3157 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3158 ID3DXBaseEffect *base = This->base_effect;
3160 TRACE("Forward iface %p, base %p\n", This, base);
3162 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3165 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3167 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3168 ID3DXBaseEffect *base = This->base_effect;
3170 TRACE("Forward iface %p, base %p\n", This, base);
3172 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3175 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3177 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3178 ID3DXBaseEffect *base = This->base_effect;
3180 TRACE("Forward iface %p, base %p\n", This, base);
3182 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3185 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3187 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3188 ID3DXBaseEffect *base = This->base_effect;
3190 TRACE("Forward iface %p, base %p\n", This, base);
3192 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3195 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3197 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3198 ID3DXBaseEffect *base = This->base_effect;
3200 TRACE("Forward iface %p, base %p\n", This, base);
3202 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3205 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3207 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3208 ID3DXBaseEffect *base = This->base_effect;
3210 TRACE("Forward iface %p, base %p\n", This, base);
3212 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3215 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3217 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3218 ID3DXBaseEffect *base = This->base_effect;
3220 TRACE("Forward iface %p, base %p\n", This, base);
3222 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3225 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3227 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3228 ID3DXBaseEffect *base = This->base_effect;
3230 TRACE("Forward iface %p, base %p\n", This, base);
3232 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3235 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3237 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3238 ID3DXBaseEffect *base = This->base_effect;
3240 TRACE("Forward iface %p, base %p\n", This, base);
3242 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3245 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3247 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3248 ID3DXBaseEffect *base = This->base_effect;
3250 TRACE("Forward iface %p, base %p\n", This, base);
3252 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3255 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3257 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3258 ID3DXBaseEffect *base = This->base_effect;
3260 TRACE("Forward iface %p, base %p\n", This, base);
3262 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3265 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3267 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3268 ID3DXBaseEffect *base = This->base_effect;
3270 TRACE("Forward iface %p, base %p\n", This, base);
3272 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3275 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3277 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3278 ID3DXBaseEffect *base = This->base_effect;
3280 TRACE("Forward iface %p, base %p\n", This, base);
3282 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3285 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3287 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3288 ID3DXBaseEffect *base = This->base_effect;
3290 TRACE("Forward iface %p, base %p\n", This, base);
3292 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3295 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3297 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3298 ID3DXBaseEffect *base = This->base_effect;
3300 TRACE("Forward iface %p, base %p\n", This, base);
3302 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3305 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3307 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3308 ID3DXBaseEffect *base = This->base_effect;
3310 TRACE("Forward iface %p, base %p\n", This, base);
3312 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3315 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3317 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3318 ID3DXBaseEffect *base = This->base_effect;
3320 TRACE("Forward iface %p, base %p\n", This, base);
3322 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3325 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3327 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3328 ID3DXBaseEffect *base = This->base_effect;
3330 TRACE("Forward iface %p, base %p\n", This, base);
3332 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3335 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
3337 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3338 ID3DXBaseEffect *base = This->base_effect;
3340 TRACE("Forward iface %p, base %p\n", This, base);
3342 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3345 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3347 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3348 ID3DXBaseEffect *base = This->base_effect;
3350 TRACE("Forward iface %p, base %p\n", This, base);
3352 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3355 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3357 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3358 ID3DXBaseEffect *base = This->base_effect;
3360 TRACE("Forward iface %p, base %p\n", This, base);
3362 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3365 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3367 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3368 ID3DXBaseEffect *base = This->base_effect;
3370 TRACE("Forward iface %p, base %p\n", This, base);
3372 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3375 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3377 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3378 ID3DXBaseEffect *base = This->base_effect;
3380 TRACE("Forward iface %p, base %p\n", This, base);
3382 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3385 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3387 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3388 ID3DXBaseEffect *base = This->base_effect;
3390 TRACE("Forward iface %p, base %p\n", This, base);
3392 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3395 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3397 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3398 ID3DXBaseEffect *base = This->base_effect;
3400 TRACE("Forward iface %p, base %p\n", This, base);
3402 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3405 /*** ID3DXEffect methods ***/
3406 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
3408 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3410 TRACE("iface %p, pool %p\n", This, pool);
3412 if (!pool)
3414 WARN("Invalid argument supplied.\n");
3415 return D3DERR_INVALIDCALL;
3418 if (This->pool)
3420 This->pool->lpVtbl->AddRef(This->pool);
3423 *pool = This->pool;
3425 TRACE("Returning pool %p\n", *pool);
3427 return S_OK;
3430 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3432 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3433 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3434 struct d3dx_technique *tech = is_valid_technique(base, technique);
3436 TRACE("iface %p, technique %p\n", This, technique);
3438 if (tech)
3440 This->active_technique = get_technique_handle(tech);
3441 TRACE("Technique %p\n", tech);
3442 return D3D_OK;
3445 WARN("Invalid argument supplied.\n");
3447 return D3DERR_INVALIDCALL;
3450 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3452 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3454 TRACE("iface %p\n", This);
3456 return This->active_technique;
3459 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3461 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3463 FIXME("(%p)->(%p): stub\n", This, technique);
3465 return D3D_OK;
3468 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3470 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3472 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3474 return E_NOTIMPL;
3477 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3479 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3481 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3483 return FALSE;
3486 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3488 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3489 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3491 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3493 if (passes && technique)
3495 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3497 TRACE("State capturing disabled.\n");
3499 else
3501 FIXME("State capturing not supported, yet!\n");
3504 *passes = technique->pass_count;
3506 return D3D_OK;
3509 WARN("Invalid argument supplied.\n");
3511 return D3DERR_INVALIDCALL;
3514 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3516 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3517 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3519 TRACE("iface %p, pass %u\n", This, pass);
3521 if (technique && pass < technique->pass_count && !This->active_pass)
3523 This->active_pass = technique->pass_handles[pass];
3525 FIXME("No states applied, yet!\n");
3527 return D3D_OK;
3530 WARN("Invalid argument supplied.\n");
3532 return D3DERR_INVALIDCALL;
3535 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3537 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3539 FIXME("(%p)->(): stub\n", This);
3541 return E_NOTIMPL;
3544 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3546 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3548 TRACE("iface %p\n", This);
3550 if (This->active_pass)
3552 This->active_pass = NULL;
3553 return D3D_OK;
3556 WARN("Invalid call.\n");
3558 return D3DERR_INVALIDCALL;
3561 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3563 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3565 FIXME("(%p)->(): stub\n", This);
3567 return E_NOTIMPL;
3570 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
3572 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3574 TRACE("iface %p, device %p\n", This, device);
3576 if (!device)
3578 WARN("Invalid argument supplied.\n");
3579 return D3DERR_INVALIDCALL;
3582 IDirect3DDevice9_AddRef(This->device);
3584 *device = This->device;
3586 TRACE("Returning device %p\n", *device);
3588 return S_OK;
3591 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3593 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3595 FIXME("(%p)->(): stub\n", This);
3597 return E_NOTIMPL;
3600 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3602 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3604 FIXME("(%p)->(): stub\n", This);
3606 return E_NOTIMPL;
3609 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
3611 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3613 TRACE("iface %p, manager %p\n", This, manager);
3615 if (manager) IUnknown_AddRef(manager);
3616 if (This->manager) IUnknown_Release(This->manager);
3618 This->manager = manager;
3620 return D3D_OK;
3623 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
3625 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3627 TRACE("iface %p, manager %p\n", This, manager);
3629 if (!manager)
3631 WARN("Invalid argument supplied.\n");
3632 return D3DERR_INVALIDCALL;
3635 if (This->manager) IUnknown_AddRef(This->manager);
3636 *manager = This->manager;
3638 return D3D_OK;
3641 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3643 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3645 FIXME("(%p)->(): stub\n", This);
3647 return E_NOTIMPL;
3650 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3652 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3654 FIXME("(%p)->(): stub\n", This);
3656 return NULL;
3659 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3661 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3663 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3665 return E_NOTIMPL;
3668 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3670 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3672 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3674 return E_NOTIMPL;
3677 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
3679 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3681 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3683 return E_NOTIMPL;
3686 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3688 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3690 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3692 return E_NOTIMPL;
3695 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3697 /*** IUnknown methods ***/
3698 ID3DXEffectImpl_QueryInterface,
3699 ID3DXEffectImpl_AddRef,
3700 ID3DXEffectImpl_Release,
3701 /*** ID3DXBaseEffect methods ***/
3702 ID3DXEffectImpl_GetDesc,
3703 ID3DXEffectImpl_GetParameterDesc,
3704 ID3DXEffectImpl_GetTechniqueDesc,
3705 ID3DXEffectImpl_GetPassDesc,
3706 ID3DXEffectImpl_GetFunctionDesc,
3707 ID3DXEffectImpl_GetParameter,
3708 ID3DXEffectImpl_GetParameterByName,
3709 ID3DXEffectImpl_GetParameterBySemantic,
3710 ID3DXEffectImpl_GetParameterElement,
3711 ID3DXEffectImpl_GetTechnique,
3712 ID3DXEffectImpl_GetTechniqueByName,
3713 ID3DXEffectImpl_GetPass,
3714 ID3DXEffectImpl_GetPassByName,
3715 ID3DXEffectImpl_GetFunction,
3716 ID3DXEffectImpl_GetFunctionByName,
3717 ID3DXEffectImpl_GetAnnotation,
3718 ID3DXEffectImpl_GetAnnotationByName,
3719 ID3DXEffectImpl_SetValue,
3720 ID3DXEffectImpl_GetValue,
3721 ID3DXEffectImpl_SetBool,
3722 ID3DXEffectImpl_GetBool,
3723 ID3DXEffectImpl_SetBoolArray,
3724 ID3DXEffectImpl_GetBoolArray,
3725 ID3DXEffectImpl_SetInt,
3726 ID3DXEffectImpl_GetInt,
3727 ID3DXEffectImpl_SetIntArray,
3728 ID3DXEffectImpl_GetIntArray,
3729 ID3DXEffectImpl_SetFloat,
3730 ID3DXEffectImpl_GetFloat,
3731 ID3DXEffectImpl_SetFloatArray,
3732 ID3DXEffectImpl_GetFloatArray,
3733 ID3DXEffectImpl_SetVector,
3734 ID3DXEffectImpl_GetVector,
3735 ID3DXEffectImpl_SetVectorArray,
3736 ID3DXEffectImpl_GetVectorArray,
3737 ID3DXEffectImpl_SetMatrix,
3738 ID3DXEffectImpl_GetMatrix,
3739 ID3DXEffectImpl_SetMatrixArray,
3740 ID3DXEffectImpl_GetMatrixArray,
3741 ID3DXEffectImpl_SetMatrixPointerArray,
3742 ID3DXEffectImpl_GetMatrixPointerArray,
3743 ID3DXEffectImpl_SetMatrixTranspose,
3744 ID3DXEffectImpl_GetMatrixTranspose,
3745 ID3DXEffectImpl_SetMatrixTransposeArray,
3746 ID3DXEffectImpl_GetMatrixTransposeArray,
3747 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3748 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3749 ID3DXEffectImpl_SetString,
3750 ID3DXEffectImpl_GetString,
3751 ID3DXEffectImpl_SetTexture,
3752 ID3DXEffectImpl_GetTexture,
3753 ID3DXEffectImpl_GetPixelShader,
3754 ID3DXEffectImpl_GetVertexShader,
3755 ID3DXEffectImpl_SetArrayRange,
3756 /*** ID3DXEffect methods ***/
3757 ID3DXEffectImpl_GetPool,
3758 ID3DXEffectImpl_SetTechnique,
3759 ID3DXEffectImpl_GetCurrentTechnique,
3760 ID3DXEffectImpl_ValidateTechnique,
3761 ID3DXEffectImpl_FindNextValidTechnique,
3762 ID3DXEffectImpl_IsParameterUsed,
3763 ID3DXEffectImpl_Begin,
3764 ID3DXEffectImpl_BeginPass,
3765 ID3DXEffectImpl_CommitChanges,
3766 ID3DXEffectImpl_EndPass,
3767 ID3DXEffectImpl_End,
3768 ID3DXEffectImpl_GetDevice,
3769 ID3DXEffectImpl_OnLostDevice,
3770 ID3DXEffectImpl_OnResetDevice,
3771 ID3DXEffectImpl_SetStateManager,
3772 ID3DXEffectImpl_GetStateManager,
3773 ID3DXEffectImpl_BeginParameterBlock,
3774 ID3DXEffectImpl_EndParameterBlock,
3775 ID3DXEffectImpl_ApplyParameterBlock,
3776 ID3DXEffectImpl_DeleteParameterBlock,
3777 ID3DXEffectImpl_CloneEffect,
3778 ID3DXEffectImpl_SetRawValue
3781 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3783 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3786 /*** IUnknown methods ***/
3787 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3789 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
3791 if (IsEqualGUID(riid, &IID_IUnknown) ||
3792 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3794 iface->lpVtbl->AddRef(iface);
3795 *object = iface;
3796 return S_OK;
3799 ERR("Interface %s not found\n", debugstr_guid(riid));
3801 return E_NOINTERFACE;
3804 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3806 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3808 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3810 return InterlockedIncrement(&This->ref);
3813 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3815 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3816 ULONG ref = InterlockedDecrement(&This->ref);
3818 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3820 if (!ref)
3822 free_effect_compiler(This);
3823 HeapFree(GetProcessHeap(), 0, This);
3826 return ref;
3829 /*** ID3DXBaseEffect methods ***/
3830 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3832 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3833 ID3DXBaseEffect *base = This->base_effect;
3835 TRACE("Forward iface %p, base %p\n", This, base);
3837 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3840 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3842 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3843 ID3DXBaseEffect *base = This->base_effect;
3845 TRACE("Forward iface %p, base %p\n", This, base);
3847 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3850 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3852 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3853 ID3DXBaseEffect *base = This->base_effect;
3855 TRACE("Forward iface %p, base %p\n", This, base);
3857 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3860 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3862 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3863 ID3DXBaseEffect *base = This->base_effect;
3865 TRACE("Forward iface %p, base %p\n", This, base);
3867 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3870 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3872 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3873 ID3DXBaseEffect *base = This->base_effect;
3875 TRACE("Forward iface %p, base %p\n", This, base);
3877 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3880 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3882 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3883 ID3DXBaseEffect *base = This->base_effect;
3885 TRACE("Forward iface %p, base %p\n", This, base);
3887 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3890 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3892 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3893 ID3DXBaseEffect *base = This->base_effect;
3895 TRACE("Forward iface %p, base %p\n", This, base);
3897 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3900 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3902 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3903 ID3DXBaseEffect *base = This->base_effect;
3905 TRACE("Forward iface %p, base %p\n", This, base);
3907 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3910 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3912 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3913 ID3DXBaseEffect *base = This->base_effect;
3915 TRACE("Forward iface %p, base %p\n", This, base);
3917 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3920 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3922 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3923 ID3DXBaseEffect *base = This->base_effect;
3925 TRACE("Forward iface %p, base %p\n", This, base);
3927 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3930 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3932 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3933 ID3DXBaseEffect *base = This->base_effect;
3935 TRACE("Forward iface %p, base %p\n", This, base);
3937 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3940 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3942 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3943 ID3DXBaseEffect *base = This->base_effect;
3945 TRACE("Forward iface %p, base %p\n", This, base);
3947 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3950 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3952 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3953 ID3DXBaseEffect *base = This->base_effect;
3955 TRACE("Forward iface %p, base %p\n", This, base);
3957 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3960 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3962 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3963 ID3DXBaseEffect *base = This->base_effect;
3965 TRACE("Forward iface %p, base %p\n", This, base);
3967 return ID3DXBaseEffectImpl_GetFunction(base, index);
3970 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3972 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3973 ID3DXBaseEffect *base = This->base_effect;
3975 TRACE("Forward iface %p, base %p\n", This, base);
3977 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3980 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3982 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3983 ID3DXBaseEffect *base = This->base_effect;
3985 TRACE("Forward iface %p, base %p\n", This, base);
3987 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3990 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3992 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3993 ID3DXBaseEffect *base = This->base_effect;
3995 TRACE("Forward iface %p, base %p\n", This, base);
3997 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
4000 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
4002 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4003 ID3DXBaseEffect *base = This->base_effect;
4005 TRACE("Forward iface %p, base %p\n", This, base);
4007 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
4010 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
4012 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4013 ID3DXBaseEffect *base = This->base_effect;
4015 TRACE("Forward iface %p, base %p\n", This, base);
4017 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
4020 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
4022 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4023 ID3DXBaseEffect *base = This->base_effect;
4025 TRACE("Forward iface %p, base %p\n", This, base);
4027 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
4030 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
4032 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4033 ID3DXBaseEffect *base = This->base_effect;
4035 TRACE("Forward iface %p, base %p\n", This, base);
4037 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
4040 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
4042 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4043 ID3DXBaseEffect *base = This->base_effect;
4045 TRACE("Forward iface %p, base %p\n", This, base);
4047 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
4050 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
4052 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4053 ID3DXBaseEffect *base = This->base_effect;
4055 TRACE("Forward iface %p, base %p\n", This, base);
4057 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
4060 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
4062 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4063 ID3DXBaseEffect *base = This->base_effect;
4065 TRACE("Forward iface %p, base %p\n", This, base);
4067 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
4070 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
4072 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4073 ID3DXBaseEffect *base = This->base_effect;
4075 TRACE("Forward iface %p, base %p\n", This, base);
4077 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
4080 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
4082 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4083 ID3DXBaseEffect *base = This->base_effect;
4085 TRACE("Forward iface %p, base %p\n", This, base);
4087 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
4090 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
4092 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4093 ID3DXBaseEffect *base = This->base_effect;
4095 TRACE("Forward iface %p, base %p\n", This, base);
4097 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
4100 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
4102 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4103 ID3DXBaseEffect *base = This->base_effect;
4105 TRACE("Forward iface %p, base %p\n", This, base);
4107 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
4110 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
4112 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4113 ID3DXBaseEffect *base = This->base_effect;
4115 TRACE("Forward iface %p, base %p\n", This, base);
4117 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
4120 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
4122 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4123 ID3DXBaseEffect *base = This->base_effect;
4125 TRACE("Forward iface %p, base %p\n", This, base);
4127 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
4130 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
4132 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4133 ID3DXBaseEffect *base = This->base_effect;
4135 TRACE("Forward iface %p, base %p\n", This, base);
4137 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
4140 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
4142 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4143 ID3DXBaseEffect *base = This->base_effect;
4145 TRACE("Forward iface %p, base %p\n", This, base);
4147 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
4150 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
4152 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4153 ID3DXBaseEffect *base = This->base_effect;
4155 TRACE("Forward iface %p, base %p\n", This, base);
4157 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
4160 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
4162 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4163 ID3DXBaseEffect *base = This->base_effect;
4165 TRACE("Forward iface %p, base %p\n", This, base);
4167 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
4170 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
4172 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4173 ID3DXBaseEffect *base = This->base_effect;
4175 TRACE("Forward iface %p, base %p\n", This, base);
4177 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
4180 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4182 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4183 ID3DXBaseEffect *base = This->base_effect;
4185 TRACE("Forward iface %p, base %p\n", This, base);
4187 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
4190 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4192 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4193 ID3DXBaseEffect *base = This->base_effect;
4195 TRACE("Forward iface %p, base %p\n", This, base);
4197 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
4200 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4202 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4203 ID3DXBaseEffect *base = This->base_effect;
4205 TRACE("Forward iface %p, base %p\n", This, base);
4207 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
4210 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4212 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4213 ID3DXBaseEffect *base = This->base_effect;
4215 TRACE("Forward iface %p, base %p\n", This, base);
4217 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
4220 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4222 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4223 ID3DXBaseEffect *base = This->base_effect;
4225 TRACE("Forward iface %p, base %p\n", This, base);
4227 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
4230 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4232 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4233 ID3DXBaseEffect *base = This->base_effect;
4235 TRACE("Forward iface %p, base %p\n", This, base);
4237 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
4240 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4242 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4243 ID3DXBaseEffect *base = This->base_effect;
4245 TRACE("Forward iface %p, base %p\n", This, base);
4247 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
4250 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4252 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4253 ID3DXBaseEffect *base = This->base_effect;
4255 TRACE("Forward iface %p, base %p\n", This, base);
4257 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
4260 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4262 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4263 ID3DXBaseEffect *base = This->base_effect;
4265 TRACE("Forward iface %p, base %p\n", This, base);
4267 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
4270 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4272 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4273 ID3DXBaseEffect *base = This->base_effect;
4275 TRACE("Forward iface %p, base %p\n", This, base);
4277 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
4280 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4282 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4283 ID3DXBaseEffect *base = This->base_effect;
4285 TRACE("Forward iface %p, base %p\n", This, base);
4287 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
4290 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4292 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4293 ID3DXBaseEffect *base = This->base_effect;
4295 TRACE("Forward iface %p, base %p\n", This, base);
4297 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
4300 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
4302 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4303 ID3DXBaseEffect *base = This->base_effect;
4305 TRACE("Forward iface %p, base %p\n", This, base);
4307 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
4310 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
4312 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4313 ID3DXBaseEffect *base = This->base_effect;
4315 TRACE("Forward iface %p, base %p\n", This, base);
4317 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
4320 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
4322 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4323 ID3DXBaseEffect *base = This->base_effect;
4325 TRACE("Forward iface %p, base %p\n", This, base);
4327 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
4330 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
4332 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4333 ID3DXBaseEffect *base = This->base_effect;
4335 TRACE("Forward iface %p, base %p\n", This, base);
4337 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4340 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
4342 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4343 ID3DXBaseEffect *base = This->base_effect;
4345 TRACE("Forward iface %p, base %p\n", This, base);
4347 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
4350 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
4352 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4353 ID3DXBaseEffect *base = This->base_effect;
4355 TRACE("Forward iface %p, base %p\n", This, base);
4357 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
4360 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4362 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4363 ID3DXBaseEffect *base = This->base_effect;
4365 TRACE("Forward iface %p, base %p\n", This, base);
4367 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4370 /*** ID3DXEffectCompiler methods ***/
4371 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4373 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4375 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4377 return E_NOTIMPL;
4380 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4382 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4384 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4386 return E_NOTIMPL;
4389 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4390 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
4392 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4394 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4396 return E_NOTIMPL;
4399 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4400 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
4402 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4404 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4405 This, function, target, flags, shader, error_msgs, constant_table);
4407 return E_NOTIMPL;
4410 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4412 /*** IUnknown methods ***/
4413 ID3DXEffectCompilerImpl_QueryInterface,
4414 ID3DXEffectCompilerImpl_AddRef,
4415 ID3DXEffectCompilerImpl_Release,
4416 /*** ID3DXBaseEffect methods ***/
4417 ID3DXEffectCompilerImpl_GetDesc,
4418 ID3DXEffectCompilerImpl_GetParameterDesc,
4419 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4420 ID3DXEffectCompilerImpl_GetPassDesc,
4421 ID3DXEffectCompilerImpl_GetFunctionDesc,
4422 ID3DXEffectCompilerImpl_GetParameter,
4423 ID3DXEffectCompilerImpl_GetParameterByName,
4424 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4425 ID3DXEffectCompilerImpl_GetParameterElement,
4426 ID3DXEffectCompilerImpl_GetTechnique,
4427 ID3DXEffectCompilerImpl_GetTechniqueByName,
4428 ID3DXEffectCompilerImpl_GetPass,
4429 ID3DXEffectCompilerImpl_GetPassByName,
4430 ID3DXEffectCompilerImpl_GetFunction,
4431 ID3DXEffectCompilerImpl_GetFunctionByName,
4432 ID3DXEffectCompilerImpl_GetAnnotation,
4433 ID3DXEffectCompilerImpl_GetAnnotationByName,
4434 ID3DXEffectCompilerImpl_SetValue,
4435 ID3DXEffectCompilerImpl_GetValue,
4436 ID3DXEffectCompilerImpl_SetBool,
4437 ID3DXEffectCompilerImpl_GetBool,
4438 ID3DXEffectCompilerImpl_SetBoolArray,
4439 ID3DXEffectCompilerImpl_GetBoolArray,
4440 ID3DXEffectCompilerImpl_SetInt,
4441 ID3DXEffectCompilerImpl_GetInt,
4442 ID3DXEffectCompilerImpl_SetIntArray,
4443 ID3DXEffectCompilerImpl_GetIntArray,
4444 ID3DXEffectCompilerImpl_SetFloat,
4445 ID3DXEffectCompilerImpl_GetFloat,
4446 ID3DXEffectCompilerImpl_SetFloatArray,
4447 ID3DXEffectCompilerImpl_GetFloatArray,
4448 ID3DXEffectCompilerImpl_SetVector,
4449 ID3DXEffectCompilerImpl_GetVector,
4450 ID3DXEffectCompilerImpl_SetVectorArray,
4451 ID3DXEffectCompilerImpl_GetVectorArray,
4452 ID3DXEffectCompilerImpl_SetMatrix,
4453 ID3DXEffectCompilerImpl_GetMatrix,
4454 ID3DXEffectCompilerImpl_SetMatrixArray,
4455 ID3DXEffectCompilerImpl_GetMatrixArray,
4456 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4457 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4458 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4459 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4460 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4461 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4462 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4463 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4464 ID3DXEffectCompilerImpl_SetString,
4465 ID3DXEffectCompilerImpl_GetString,
4466 ID3DXEffectCompilerImpl_SetTexture,
4467 ID3DXEffectCompilerImpl_GetTexture,
4468 ID3DXEffectCompilerImpl_GetPixelShader,
4469 ID3DXEffectCompilerImpl_GetVertexShader,
4470 ID3DXEffectCompilerImpl_SetArrayRange,
4471 /*** ID3DXEffectCompiler methods ***/
4472 ID3DXEffectCompilerImpl_SetLiteral,
4473 ID3DXEffectCompilerImpl_GetLiteral,
4474 ID3DXEffectCompilerImpl_CompileEffect,
4475 ID3DXEffectCompilerImpl_CompileShader,
4478 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4480 HRESULT hr;
4481 UINT i;
4482 struct d3dx_state *states;
4484 read_dword(ptr, &sampler->state_count);
4485 TRACE("Count: %u\n", sampler->state_count);
4487 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4488 if (!states)
4490 ERR("Out of memory\n");
4491 return E_OUTOFMEMORY;
4494 for (i = 0; i < sampler->state_count; ++i)
4496 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4497 if (hr != D3D_OK)
4499 WARN("Failed to parse state\n");
4500 goto err_out;
4504 sampler->states = states;
4506 return D3D_OK;
4508 err_out:
4510 for (i = 0; i < sampler->state_count; ++i)
4512 free_state(&states[i]);
4515 HeapFree(GetProcessHeap(), 0, states);
4517 return hr;
4520 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4522 unsigned int i;
4523 HRESULT hr;
4524 UINT old_size = 0;
4525 DWORD id;
4527 if (param->element_count)
4529 param->data = value;
4531 for (i = 0; i < param->element_count; ++i)
4533 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4535 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4536 if (hr != D3D_OK)
4538 WARN("Failed to parse value\n");
4539 return hr;
4542 old_size += member->bytes;
4545 return D3D_OK;
4548 switch(param->class)
4550 case D3DXPC_SCALAR:
4551 case D3DXPC_VECTOR:
4552 case D3DXPC_MATRIX_ROWS:
4553 case D3DXPC_MATRIX_COLUMNS:
4554 param->data = value;
4555 break;
4557 case D3DXPC_STRUCT:
4558 param->data = value;
4560 for (i = 0; i < param->member_count; ++i)
4562 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4564 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4565 if (hr != D3D_OK)
4567 WARN("Failed to parse value\n");
4568 return hr;
4571 old_size += member->bytes;
4573 break;
4575 case D3DXPC_OBJECT:
4576 switch (param->type)
4578 case D3DXPT_STRING:
4579 case D3DXPT_TEXTURE:
4580 case D3DXPT_TEXTURE1D:
4581 case D3DXPT_TEXTURE2D:
4582 case D3DXPT_TEXTURE3D:
4583 case D3DXPT_TEXTURECUBE:
4584 case D3DXPT_PIXELSHADER:
4585 case D3DXPT_VERTEXSHADER:
4586 read_dword(ptr, &id);
4587 TRACE("Id: %u\n", id);
4588 objects[id] = get_parameter_handle(param);
4589 param->data = value;
4590 break;
4592 case D3DXPT_SAMPLER:
4593 case D3DXPT_SAMPLER1D:
4594 case D3DXPT_SAMPLER2D:
4595 case D3DXPT_SAMPLER3D:
4596 case D3DXPT_SAMPLERCUBE:
4598 struct d3dx_sampler *sampler;
4600 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4601 if (!sampler)
4603 ERR("Out of memory\n");
4604 return E_OUTOFMEMORY;
4607 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4608 if (hr != D3D_OK)
4610 HeapFree(GetProcessHeap(), 0, sampler);
4611 WARN("Failed to parse sampler\n");
4612 return hr;
4615 param->data = sampler;
4616 break;
4619 default:
4620 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4621 break;
4623 break;
4625 default:
4626 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4627 break;
4630 return D3D_OK;
4633 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4635 UINT size = param->bytes;
4636 HRESULT hr;
4637 void *value = NULL;
4639 TRACE("param size: %u\n", size);
4641 if (size)
4643 value = HeapAlloc(GetProcessHeap(), 0, size);
4644 if (!value)
4646 ERR("Failed to allocate data memory.\n");
4647 return E_OUTOFMEMORY;
4650 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4651 memcpy(value, ptr, size);
4654 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4655 if (hr != D3D_OK)
4657 WARN("Failed to parse value\n");
4658 HeapFree(GetProcessHeap(), 0, value);
4659 return hr;
4662 return D3D_OK;
4665 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4667 DWORD size;
4669 read_dword(&ptr, &size);
4670 TRACE("Name size: %#x\n", size);
4672 if (!size)
4674 return D3D_OK;
4677 *name = HeapAlloc(GetProcessHeap(), 0, size);
4678 if (!*name)
4680 ERR("Failed to allocate name memory.\n");
4681 return E_OUTOFMEMORY;
4684 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4685 memcpy(*name, ptr, size);
4687 return D3D_OK;
4690 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4692 DWORD size;
4694 read_dword(ptr, &size);
4695 TRACE("Data size: %#x\n", size);
4697 *str = HeapAlloc(GetProcessHeap(), 0, size);
4698 if (!*str)
4700 ERR("Failed to allocate name memory.\n");
4701 return E_OUTOFMEMORY;
4704 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4705 memcpy(*str, *ptr, size);
4707 *ptr += ((size + 3) & ~3);
4709 return D3D_OK;
4712 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, LPDIRECT3DDEVICE9 device)
4714 DWORD size;
4715 HRESULT hr;
4717 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4719 read_dword(ptr, &size);
4720 TRACE("Data size: %#x\n", size);
4722 if (!size)
4724 TRACE("Size is 0\n");
4725 *(void **)param->data = NULL;
4726 return D3D_OK;
4729 switch (param->type)
4731 case D3DXPT_STRING:
4732 /* re-read with size (sizeof(DWORD) = 4) */
4733 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4734 if (hr != D3D_OK)
4736 WARN("Failed to parse string data\n");
4737 return hr;
4739 break;
4741 case D3DXPT_VERTEXSHADER:
4742 hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
4743 if (hr != D3D_OK)
4745 WARN("Failed to create vertex shader\n");
4746 return hr;
4748 break;
4750 case D3DXPT_PIXELSHADER:
4751 hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
4752 if (hr != D3D_OK)
4754 WARN("Failed to create pixel shader\n");
4755 return hr;
4757 break;
4759 default:
4760 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4761 break;
4765 *ptr += ((size + 3) & ~3);
4767 return D3D_OK;
4770 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4771 struct d3dx_parameter *parent, UINT flags)
4773 DWORD offset;
4774 HRESULT hr;
4775 D3DXHANDLE *member_handles = NULL;
4776 UINT i;
4778 param->flags = flags;
4780 if (!parent)
4782 read_dword(ptr, &param->type);
4783 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4785 read_dword(ptr, &param->class);
4786 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4788 read_dword(ptr, &offset);
4789 TRACE("Type name offset: %#x\n", offset);
4790 hr = d3dx9_parse_name(&param->name, data + offset);
4791 if (hr != D3D_OK)
4793 WARN("Failed to parse name\n");
4794 goto err_out;
4797 read_dword(ptr, &offset);
4798 TRACE("Type semantic offset: %#x\n", offset);
4799 hr = d3dx9_parse_name(&param->semantic, data + offset);
4800 if (hr != D3D_OK)
4802 WARN("Failed to parse semantic\n");
4803 goto err_out;
4806 read_dword(ptr, &param->element_count);
4807 TRACE("Elements: %u\n", param->element_count);
4809 switch (param->class)
4811 case D3DXPC_VECTOR:
4812 read_dword(ptr, &param->columns);
4813 TRACE("Columns: %u\n", param->columns);
4815 read_dword(ptr, &param->rows);
4816 TRACE("Rows: %u\n", param->rows);
4818 /* sizeof(DWORD) * rows * columns */
4819 param->bytes = 4 * param->rows * param->columns;
4820 break;
4822 case D3DXPC_SCALAR:
4823 case D3DXPC_MATRIX_ROWS:
4824 case D3DXPC_MATRIX_COLUMNS:
4825 read_dword(ptr, &param->rows);
4826 TRACE("Rows: %u\n", param->rows);
4828 read_dword(ptr, &param->columns);
4829 TRACE("Columns: %u\n", param->columns);
4831 /* sizeof(DWORD) * rows * columns */
4832 param->bytes = 4 * param->rows * param->columns;
4833 break;
4835 case D3DXPC_STRUCT:
4836 read_dword(ptr, &param->member_count);
4837 TRACE("Members: %u\n", param->member_count);
4838 break;
4840 case D3DXPC_OBJECT:
4841 switch (param->type)
4843 case D3DXPT_STRING:
4844 param->bytes = sizeof(LPCSTR);
4845 break;
4847 case D3DXPT_PIXELSHADER:
4848 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
4849 break;
4851 case D3DXPT_VERTEXSHADER:
4852 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
4853 break;
4855 case D3DXPT_TEXTURE:
4856 case D3DXPT_TEXTURE1D:
4857 case D3DXPT_TEXTURE2D:
4858 case D3DXPT_TEXTURE3D:
4859 case D3DXPT_TEXTURECUBE:
4860 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
4861 break;
4863 case D3DXPT_SAMPLER:
4864 case D3DXPT_SAMPLER1D:
4865 case D3DXPT_SAMPLER2D:
4866 case D3DXPT_SAMPLER3D:
4867 case D3DXPT_SAMPLERCUBE:
4868 param->bytes = 0;
4869 break;
4871 default:
4872 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4873 break;
4875 break;
4877 default:
4878 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4879 break;
4882 else
4884 /* elements */
4885 param->type = parent->type;
4886 param->class = parent->class;
4887 param->name = parent->name;
4888 param->semantic = parent->semantic;
4889 param->element_count = 0;
4890 param->annotation_count = 0;
4891 param->member_count = parent->member_count;
4892 param->bytes = parent->bytes;
4893 param->rows = parent->rows;
4894 param->columns = parent->columns;
4897 if (param->element_count)
4899 unsigned int param_bytes = 0;
4900 const char *save_ptr = *ptr;
4902 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4903 if (!member_handles)
4905 ERR("Out of memory\n");
4906 hr = E_OUTOFMEMORY;
4907 goto err_out;
4910 for (i = 0; i < param->element_count; ++i)
4912 struct d3dx_parameter *member;
4913 *ptr = save_ptr;
4915 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4916 if (!member)
4918 ERR("Out of memory\n");
4919 hr = E_OUTOFMEMORY;
4920 goto err_out;
4923 member_handles[i] = get_parameter_handle(member);
4925 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4926 if (hr != D3D_OK)
4928 WARN("Failed to parse member\n");
4929 goto err_out;
4932 param_bytes += member->bytes;
4935 param->bytes = param_bytes;
4937 else if (param->member_count)
4939 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4940 if (!member_handles)
4942 ERR("Out of memory\n");
4943 hr = E_OUTOFMEMORY;
4944 goto err_out;
4947 for (i = 0; i < param->member_count; ++i)
4949 struct d3dx_parameter *member;
4951 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4952 if (!member)
4954 ERR("Out of memory\n");
4955 hr = E_OUTOFMEMORY;
4956 goto err_out;
4959 member_handles[i] = get_parameter_handle(member);
4961 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4962 if (hr != D3D_OK)
4964 WARN("Failed to parse member\n");
4965 goto err_out;
4968 param->bytes += member->bytes;
4972 param->member_handles = member_handles;
4974 return D3D_OK;
4976 err_out:
4978 if (member_handles)
4980 unsigned int count;
4982 if (param->element_count) count = param->element_count;
4983 else count = param->member_count;
4985 for (i = 0; i < count; ++i)
4987 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4989 HeapFree(GetProcessHeap(), 0, member_handles);
4992 if (!parent)
4994 HeapFree(GetProcessHeap(), 0, param->name);
4995 HeapFree(GetProcessHeap(), 0, param->semantic);
4997 param->name = NULL;
4998 param->semantic = NULL;
5000 return hr;
5003 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
5005 DWORD offset;
5006 const char *ptr2;
5007 HRESULT hr;
5009 anno->flags = D3DX_PARAMETER_ANNOTATION;
5011 read_dword(ptr, &offset);
5012 TRACE("Typedef offset: %#x\n", offset);
5013 ptr2 = data + offset;
5014 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
5015 if (hr != D3D_OK)
5017 WARN("Failed to parse type definition\n");
5018 return hr;
5021 read_dword(ptr, &offset);
5022 TRACE("Value offset: %#x\n", offset);
5023 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
5024 if (hr != D3D_OK)
5026 WARN("Failed to parse value\n");
5027 return hr;
5030 return D3D_OK;
5033 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
5035 DWORD offset;
5036 const char *ptr2;
5037 HRESULT hr;
5038 struct d3dx_parameter *parameter;
5040 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5041 if (!parameter)
5043 ERR("Out of memory\n");
5044 return E_OUTOFMEMORY;
5047 state->type = ST_CONSTANT;
5049 read_dword(ptr, &state->operation);
5050 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
5052 read_dword(ptr, &state->index);
5053 TRACE("Index: %#x\n", state->index);
5055 read_dword(ptr, &offset);
5056 TRACE("Typedef offset: %#x\n", offset);
5057 ptr2 = data + offset;
5058 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
5059 if (hr != D3D_OK)
5061 WARN("Failed to parse type definition\n");
5062 goto err_out;
5065 read_dword(ptr, &offset);
5066 TRACE("Value offset: %#x\n", offset);
5067 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
5068 if (hr != D3D_OK)
5070 WARN("Failed to parse value\n");
5071 goto err_out;
5074 state->parameter = get_parameter_handle(parameter);
5076 return D3D_OK;
5078 err_out:
5080 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
5082 return hr;
5085 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
5087 DWORD offset;
5088 HRESULT hr;
5089 unsigned int i;
5090 D3DXHANDLE *annotation_handles = NULL;
5091 const char *ptr2;
5093 read_dword(ptr, &offset);
5094 TRACE("Typedef offset: %#x\n", offset);
5095 ptr2 = data + offset;
5097 read_dword(ptr, &offset);
5098 TRACE("Value offset: %#x\n", offset);
5100 read_dword(ptr, &param->flags);
5101 TRACE("Flags: %#x\n", param->flags);
5103 read_dword(ptr, &param->annotation_count);
5104 TRACE("Annotation count: %u\n", param->annotation_count);
5106 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
5107 if (hr != D3D_OK)
5109 WARN("Failed to parse type definition\n");
5110 return hr;
5113 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
5114 if (hr != D3D_OK)
5116 WARN("Failed to parse value\n");
5117 return hr;
5120 if (param->annotation_count)
5122 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
5123 if (!annotation_handles)
5125 ERR("Out of memory\n");
5126 hr = E_OUTOFMEMORY;
5127 goto err_out;
5130 for (i = 0; i < param->annotation_count; ++i)
5132 struct d3dx_parameter *annotation;
5134 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5135 if (!annotation)
5137 ERR("Out of memory\n");
5138 hr = E_OUTOFMEMORY;
5139 goto err_out;
5142 annotation_handles[i] = get_parameter_handle(annotation);
5144 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5145 if (hr != D3D_OK)
5147 WARN("Failed to parse annotation\n");
5148 goto err_out;
5153 param->annotation_handles = annotation_handles;
5155 return D3D_OK;
5157 err_out:
5159 if (annotation_handles)
5161 for (i = 0; i < param->annotation_count; ++i)
5163 free_parameter(annotation_handles[i], FALSE, FALSE);
5165 HeapFree(GetProcessHeap(), 0, annotation_handles);
5168 return hr;
5171 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
5173 DWORD offset;
5174 HRESULT hr;
5175 unsigned int i;
5176 D3DXHANDLE *annotation_handles = NULL;
5177 struct d3dx_state *states = NULL;
5178 char *name = NULL;
5180 read_dword(ptr, &offset);
5181 TRACE("Pass name offset: %#x\n", offset);
5182 hr = d3dx9_parse_name(&name, data + offset);
5183 if (hr != D3D_OK)
5185 WARN("Failed to parse name\n");
5186 goto err_out;
5189 read_dword(ptr, &pass->annotation_count);
5190 TRACE("Annotation count: %u\n", pass->annotation_count);
5192 read_dword(ptr, &pass->state_count);
5193 TRACE("State count: %u\n", pass->state_count);
5195 if (pass->annotation_count)
5197 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
5198 if (!annotation_handles)
5200 ERR("Out of memory\n");
5201 hr = E_OUTOFMEMORY;
5202 goto err_out;
5205 for (i = 0; i < pass->annotation_count; ++i)
5207 struct d3dx_parameter *annotation;
5209 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5210 if (!annotation)
5212 ERR("Out of memory\n");
5213 hr = E_OUTOFMEMORY;
5214 goto err_out;
5217 annotation_handles[i] = get_parameter_handle(annotation);
5219 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5220 if (hr != D3D_OK)
5222 WARN("Failed to parse annotations\n");
5223 goto err_out;
5228 if (pass->state_count)
5230 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
5231 if (!states)
5233 ERR("Out of memory\n");
5234 hr = E_OUTOFMEMORY;
5235 goto err_out;
5238 for (i = 0; i < pass->state_count; ++i)
5240 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
5241 if (hr != D3D_OK)
5243 WARN("Failed to parse annotations\n");
5244 goto err_out;
5249 pass->name = name;
5250 pass->annotation_handles = annotation_handles;
5251 pass->states = states;
5253 return D3D_OK;
5255 err_out:
5257 if (annotation_handles)
5259 for (i = 0; i < pass->annotation_count; ++i)
5261 free_parameter(annotation_handles[i], FALSE, FALSE);
5263 HeapFree(GetProcessHeap(), 0, annotation_handles);
5266 if (states)
5268 for (i = 0; i < pass->state_count; ++i)
5270 free_state(&states[i]);
5272 HeapFree(GetProcessHeap(), 0, states);
5275 HeapFree(GetProcessHeap(), 0, name);
5277 return hr;
5280 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
5282 DWORD offset;
5283 HRESULT hr;
5284 unsigned int i;
5285 D3DXHANDLE *annotation_handles = NULL;
5286 D3DXHANDLE *pass_handles = NULL;
5287 char *name = NULL;
5289 read_dword(ptr, &offset);
5290 TRACE("Technique name offset: %#x\n", offset);
5291 hr = d3dx9_parse_name(&name, data + offset);
5292 if (hr != D3D_OK)
5294 WARN("Failed to parse name\n");
5295 goto err_out;
5298 read_dword(ptr, &technique->annotation_count);
5299 TRACE("Annotation count: %u\n", technique->annotation_count);
5301 read_dword(ptr, &technique->pass_count);
5302 TRACE("Pass count: %u\n", technique->pass_count);
5304 if (technique->annotation_count)
5306 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
5307 if (!annotation_handles)
5309 ERR("Out of memory\n");
5310 hr = E_OUTOFMEMORY;
5311 goto err_out;
5314 for (i = 0; i < technique->annotation_count; ++i)
5316 struct d3dx_parameter *annotation;
5318 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5319 if (!annotation)
5321 ERR("Out of memory\n");
5322 hr = E_OUTOFMEMORY;
5323 goto err_out;
5326 annotation_handles[i] = get_parameter_handle(annotation);
5328 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5329 if (hr != D3D_OK)
5331 WARN("Failed to parse annotations\n");
5332 goto err_out;
5337 if (technique->pass_count)
5339 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5340 if (!pass_handles)
5342 ERR("Out of memory\n");
5343 hr = E_OUTOFMEMORY;
5344 goto err_out;
5347 for (i = 0; i < technique->pass_count; ++i)
5349 struct d3dx_pass *pass;
5351 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5352 if (!pass)
5354 ERR("Out of memory\n");
5355 hr = E_OUTOFMEMORY;
5356 goto err_out;
5359 pass_handles[i] = get_pass_handle(pass);
5361 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5362 if (hr != D3D_OK)
5364 WARN("Failed to parse passes\n");
5365 goto err_out;
5370 technique->name = name;
5371 technique->pass_handles = pass_handles;
5372 technique->annotation_handles = annotation_handles;
5374 return D3D_OK;
5376 err_out:
5378 if (pass_handles)
5380 for (i = 0; i < technique->pass_count; ++i)
5382 free_pass(pass_handles[i]);
5384 HeapFree(GetProcessHeap(), 0, pass_handles);
5387 if (annotation_handles)
5389 for (i = 0; i < technique->annotation_count; ++i)
5391 free_parameter(annotation_handles[i], FALSE, FALSE);
5393 HeapFree(GetProcessHeap(), 0, annotation_handles);
5396 HeapFree(GetProcessHeap(), 0, name);
5398 return hr;
5401 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5403 DWORD technique_index;
5404 DWORD index, state_index, usage, element_index;
5405 struct d3dx_state *state;
5406 struct d3dx_parameter *param;
5407 HRESULT hr = E_FAIL;
5409 read_dword(ptr, &technique_index);
5410 TRACE("techn: %u\n", technique_index);
5412 read_dword(ptr, &index);
5413 TRACE("index: %u\n", index);
5415 read_dword(ptr, &element_index);
5416 TRACE("element_index: %u\n", element_index);
5418 read_dword(ptr, &state_index);
5419 TRACE("state_index: %u\n", state_index);
5421 read_dword(ptr, &usage);
5422 TRACE("usage: %u\n", usage);
5424 if (technique_index == 0xffffffff)
5426 struct d3dx_parameter *parameter;
5427 struct d3dx_sampler *sampler;
5429 if (index >= base->parameter_count)
5431 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5432 return E_FAIL;
5435 parameter = get_parameter_struct(base->parameter_handles[index]);
5436 if (element_index != 0xffffffff)
5438 if (element_index >= parameter->element_count && parameter->element_count != 0)
5440 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5441 return E_FAIL;
5444 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5447 sampler = parameter->data;
5448 if (state_index >= sampler->state_count)
5450 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5451 return E_FAIL;
5454 state = &sampler->states[state_index];
5456 else
5458 struct d3dx_technique *technique;
5459 struct d3dx_pass *pass;
5461 if (technique_index >= base->technique_count)
5463 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5464 return E_FAIL;
5467 technique = get_technique_struct(base->technique_handles[technique_index]);
5468 if (index >= technique->pass_count)
5470 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5471 return E_FAIL;
5474 pass = get_pass_struct(technique->pass_handles[index]);
5475 if (state_index >= pass->state_count)
5477 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5478 return E_FAIL;
5481 state = &pass->states[state_index];
5484 param = get_parameter_struct(state->parameter);
5486 switch (usage)
5488 case 0:
5489 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5490 switch (param->type)
5492 case D3DXPT_VERTEXSHADER:
5493 case D3DXPT_PIXELSHADER:
5494 state->type = ST_CONSTANT;
5495 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5496 break;
5498 case D3DXPT_BOOL:
5499 case D3DXPT_INT:
5500 case D3DXPT_FLOAT:
5501 case D3DXPT_STRING:
5502 state->type = ST_FXLC;
5503 hr = d3dx9_copy_data(param->data, ptr);
5504 break;
5506 default:
5507 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5508 break;
5510 break;
5512 case 1:
5513 state->type = ST_PARAMETER;
5514 hr = d3dx9_copy_data(param->data, ptr);
5515 if (hr == D3D_OK)
5517 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5519 break;
5521 default:
5522 FIXME("Unknown usage %x\n", usage);
5523 break;
5526 return hr;
5529 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5531 const char *ptr = data + start;
5532 D3DXHANDLE *parameter_handles = NULL;
5533 D3DXHANDLE *technique_handles = NULL;
5534 D3DXHANDLE *objects = NULL;
5535 UINT stringcount, objectcount, resourcecount;
5536 HRESULT hr;
5537 UINT i;
5539 read_dword(&ptr, &base->parameter_count);
5540 TRACE("Parameter count: %u\n", base->parameter_count);
5542 read_dword(&ptr, &base->technique_count);
5543 TRACE("Technique count: %u\n", base->technique_count);
5545 skip_dword_unknown(&ptr, 1);
5547 read_dword(&ptr, &objectcount);
5548 TRACE("Object count: %u\n", objectcount);
5550 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5551 if (!objects)
5553 ERR("Out of memory\n");
5554 hr = E_OUTOFMEMORY;
5555 goto err_out;
5558 if (base->parameter_count)
5560 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5561 if (!parameter_handles)
5563 ERR("Out of memory\n");
5564 hr = E_OUTOFMEMORY;
5565 goto err_out;
5568 for (i = 0; i < base->parameter_count; ++i)
5570 struct d3dx_parameter *parameter;
5572 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5573 if (!parameter)
5575 ERR("Out of memory\n");
5576 hr = E_OUTOFMEMORY;
5577 goto err_out;
5580 parameter_handles[i] = get_parameter_handle(parameter);
5582 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5583 if (hr != D3D_OK)
5585 WARN("Failed to parse parameter\n");
5586 goto err_out;
5591 if (base->technique_count)
5593 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5594 if (!technique_handles)
5596 ERR("Out of memory\n");
5597 hr = E_OUTOFMEMORY;
5598 goto err_out;
5601 for (i = 0; i < base->technique_count; ++i)
5603 struct d3dx_technique *technique;
5605 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5606 if (!technique)
5608 ERR("Out of memory\n");
5609 hr = E_OUTOFMEMORY;
5610 goto err_out;
5613 technique_handles[i] = get_technique_handle(technique);
5615 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5616 if (hr != D3D_OK)
5618 WARN("Failed to parse technique\n");
5619 goto err_out;
5624 /* needed for further parsing */
5625 base->technique_handles = technique_handles;
5626 base->parameter_handles = parameter_handles;
5628 read_dword(&ptr, &stringcount);
5629 TRACE("String count: %u\n", stringcount);
5631 read_dword(&ptr, &resourcecount);
5632 TRACE("Resource count: %u\n", resourcecount);
5634 for (i = 0; i < stringcount; ++i)
5636 DWORD id;
5637 struct d3dx_parameter *param;
5639 read_dword(&ptr, &id);
5640 TRACE("Id: %u\n", id);
5642 param = get_parameter_struct(objects[id]);
5644 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5645 if (hr != D3D_OK)
5647 WARN("Failed to parse data\n");
5648 goto err_out;
5652 for (i = 0; i < resourcecount; ++i)
5654 TRACE("parse resource %u\n", i);
5656 hr = d3dx9_parse_resource(base, data, &ptr);
5657 if (hr != D3D_OK)
5659 WARN("Failed to parse data\n");
5660 goto err_out;
5664 HeapFree(GetProcessHeap(), 0, objects);
5666 return D3D_OK;
5668 err_out:
5670 if (technique_handles)
5672 for (i = 0; i < base->technique_count; ++i)
5674 free_technique(technique_handles[i]);
5676 HeapFree(GetProcessHeap(), 0, technique_handles);
5679 if (parameter_handles)
5681 for (i = 0; i < base->parameter_count; ++i)
5683 free_parameter(parameter_handles[i], FALSE, FALSE);
5685 HeapFree(GetProcessHeap(), 0, parameter_handles);
5688 base->technique_handles = NULL;
5689 base->parameter_handles = NULL;
5691 HeapFree(GetProcessHeap(), 0, objects);
5693 return hr;
5696 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5697 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5699 DWORD tag, offset;
5700 const char *ptr = data;
5701 HRESULT hr;
5703 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5705 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5706 base->ref = 1;
5707 base->effect = effect;
5709 read_dword(&ptr, &tag);
5710 TRACE("Tag: %x\n", tag);
5712 if (tag != d3dx9_effect_version(9, 1))
5714 /* todo: compile hlsl ascii code */
5715 FIXME("HLSL ascii effects not supported, yet\n");
5717 /* Show the start of the shader for debugging info. */
5718 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5720 else
5722 read_dword(&ptr, &offset);
5723 TRACE("Offset: %x\n", offset);
5725 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5726 if (hr != D3D_OK)
5728 FIXME("Failed to parse effect.\n");
5729 return hr;
5733 return D3D_OK;
5736 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
5737 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
5739 HRESULT hr;
5740 struct ID3DXBaseEffectImpl *object = NULL;
5742 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5744 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5745 effect->ref = 1;
5747 if (pool) pool->lpVtbl->AddRef(pool);
5748 effect->pool = pool;
5750 IDirect3DDevice9_AddRef(device);
5751 effect->device = device;
5753 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5754 if (!object)
5756 ERR("Out of memory\n");
5757 hr = E_OUTOFMEMORY;
5758 goto err_out;
5761 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5762 if (hr != D3D_OK)
5764 FIXME("Failed to parse effect.\n");
5765 goto err_out;
5768 effect->base_effect = &object->ID3DXBaseEffect_iface;
5770 /* initialize defaults - check because of unsupported ascii effects */
5771 if (object->technique_handles)
5773 effect->active_technique = object->technique_handles[0];
5774 effect->active_pass = NULL;
5777 return D3D_OK;
5779 err_out:
5781 HeapFree(GetProcessHeap(), 0, object);
5782 free_effect(effect);
5784 return hr;
5787 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
5788 LPCVOID srcdata,
5789 UINT srcdatalen,
5790 CONST D3DXMACRO* defines,
5791 LPD3DXINCLUDE include,
5792 LPCSTR skip_constants,
5793 DWORD flags,
5794 LPD3DXEFFECTPOOL pool,
5795 LPD3DXEFFECT* effect,
5796 LPD3DXBUFFER* compilation_errors)
5798 struct ID3DXEffectImpl *object;
5799 HRESULT hr;
5801 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5802 skip_constants, flags, pool, effect, compilation_errors);
5804 if (!device || !srcdata)
5805 return D3DERR_INVALIDCALL;
5807 if (!srcdatalen)
5808 return E_FAIL;
5810 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5811 if (!effect)
5812 return D3D_OK;
5814 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5815 if (!object)
5817 ERR("Out of memory\n");
5818 return E_OUTOFMEMORY;
5821 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5822 if (FAILED(hr))
5824 WARN("Failed to initialize shader reflection\n");
5825 HeapFree(GetProcessHeap(), 0, object);
5826 return hr;
5829 *effect = &object->ID3DXEffect_iface;
5831 TRACE("Created ID3DXEffect %p\n", object);
5833 return D3D_OK;
5836 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
5837 LPCVOID srcdata,
5838 UINT srcdatalen,
5839 CONST D3DXMACRO* defines,
5840 LPD3DXINCLUDE include,
5841 DWORD flags,
5842 LPD3DXEFFECTPOOL pool,
5843 LPD3DXEFFECT* effect,
5844 LPD3DXBUFFER* compilation_errors)
5846 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5847 include, flags, pool, effect, compilation_errors);
5849 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5852 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5854 HRESULT hr;
5855 struct ID3DXBaseEffectImpl *object = NULL;
5857 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5859 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5860 compiler->ref = 1;
5862 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5863 if (!object)
5865 ERR("Out of memory\n");
5866 hr = E_OUTOFMEMORY;
5867 goto err_out;
5870 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5871 if (hr != D3D_OK)
5873 FIXME("Failed to parse effect.\n");
5874 goto err_out;
5877 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5879 return D3D_OK;
5881 err_out:
5883 HeapFree(GetProcessHeap(), 0, object);
5884 free_effect_compiler(compiler);
5886 return hr;
5889 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
5890 UINT srcdatalen,
5891 CONST D3DXMACRO *defines,
5892 LPD3DXINCLUDE include,
5893 DWORD flags,
5894 LPD3DXEFFECTCOMPILER *compiler,
5895 LPD3DXBUFFER *parse_errors)
5897 struct ID3DXEffectCompilerImpl *object;
5898 HRESULT hr;
5900 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5901 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5903 if (!srcdata || !compiler)
5905 WARN("Invalid arguments supplied\n");
5906 return D3DERR_INVALIDCALL;
5909 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5910 if (!object)
5912 ERR("Out of memory\n");
5913 return E_OUTOFMEMORY;
5916 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5917 if (FAILED(hr))
5919 WARN("Failed to initialize effect compiler\n");
5920 HeapFree(GetProcessHeap(), 0, object);
5921 return hr;
5924 *compiler = &object->ID3DXEffectCompiler_iface;
5926 TRACE("Created ID3DXEffectCompiler %p\n", object);
5928 return D3D_OK;
5931 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5933 struct ID3DXEffectPoolImpl
5935 ID3DXEffectPool ID3DXEffectPool_iface;
5936 LONG ref;
5939 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5941 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5944 /*** IUnknown methods ***/
5945 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5947 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
5949 if (IsEqualGUID(riid, &IID_IUnknown) ||
5950 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5952 iface->lpVtbl->AddRef(iface);
5953 *object = iface;
5954 return S_OK;
5957 WARN("Interface %s not found\n", debugstr_guid(riid));
5959 return E_NOINTERFACE;
5962 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5964 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5966 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5968 return InterlockedIncrement(&This->ref);
5971 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5973 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5974 ULONG ref = InterlockedDecrement(&This->ref);
5976 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5978 if (!ref)
5979 HeapFree(GetProcessHeap(), 0, This);
5981 return ref;
5984 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5986 /*** IUnknown methods ***/
5987 ID3DXEffectPoolImpl_QueryInterface,
5988 ID3DXEffectPoolImpl_AddRef,
5989 ID3DXEffectPoolImpl_Release
5992 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
5994 struct ID3DXEffectPoolImpl *object;
5996 TRACE("(%p)\n", pool);
5998 if (!pool)
5999 return D3DERR_INVALIDCALL;
6001 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
6002 if (!object)
6004 ERR("Out of memory\n");
6005 return E_OUTOFMEMORY;
6008 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
6009 object->ref = 1;
6011 *pool = &object->ID3DXEffectPool_iface;
6013 return S_OK;
6016 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
6017 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6018 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6020 LPVOID buffer;
6021 HRESULT ret;
6022 DWORD size;
6024 TRACE("(%s): relay\n", debugstr_w(srcfile));
6026 if (!device || !srcfile)
6027 return D3DERR_INVALIDCALL;
6029 ret = map_view_of_file(srcfile, &buffer, &size);
6031 if (FAILED(ret))
6032 return D3DXERR_INVALIDDATA;
6034 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6035 UnmapViewOfFile(buffer);
6037 return ret;
6040 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
6041 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6042 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6044 LPWSTR srcfileW;
6045 HRESULT ret;
6046 DWORD len;
6048 TRACE("(void): relay\n");
6050 if (!srcfile)
6051 return D3DERR_INVALIDCALL;
6053 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6054 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6055 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6057 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6058 HeapFree(GetProcessHeap(), 0, srcfileW);
6060 return ret;
6063 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
6064 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6065 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6067 TRACE("(void): relay\n");
6068 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6071 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
6072 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6073 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6075 TRACE("(void): relay\n");
6076 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6079 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
6080 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6081 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6083 HRSRC resinfo;
6085 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6087 if (!device)
6088 return D3DERR_INVALIDCALL;
6090 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6092 if (resinfo)
6094 LPVOID buffer;
6095 HRESULT ret;
6096 DWORD size;
6098 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6100 if (FAILED(ret))
6101 return D3DXERR_INVALIDDATA;
6103 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6106 return D3DXERR_INVALIDDATA;
6109 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
6110 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
6111 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6113 HRSRC resinfo;
6115 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6117 if (!device)
6118 return D3DERR_INVALIDCALL;
6120 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6122 if (resinfo)
6124 LPVOID buffer;
6125 HRESULT ret;
6126 DWORD size;
6128 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6130 if (FAILED(ret))
6131 return D3DXERR_INVALIDDATA;
6133 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6136 return D3DXERR_INVALIDDATA;
6139 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
6140 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6141 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6143 TRACE("(void): relay\n");
6144 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6147 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
6148 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
6149 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
6151 TRACE("(void): relay\n");
6152 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6155 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6156 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6158 LPVOID buffer;
6159 HRESULT ret;
6160 DWORD size;
6162 TRACE("(%s): relay\n", debugstr_w(srcfile));
6164 if (!srcfile)
6165 return D3DERR_INVALIDCALL;
6167 ret = map_view_of_file(srcfile, &buffer, &size);
6169 if (FAILED(ret))
6170 return D3DXERR_INVALIDDATA;
6172 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6173 UnmapViewOfFile(buffer);
6175 return ret;
6178 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
6179 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6181 LPWSTR srcfileW;
6182 HRESULT ret;
6183 DWORD len;
6185 TRACE("(void): relay\n");
6187 if (!srcfile)
6188 return D3DERR_INVALIDCALL;
6190 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6191 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6192 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6194 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
6195 HeapFree(GetProcessHeap(), 0, srcfileW);
6197 return ret;
6200 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
6201 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6203 HRSRC resinfo;
6205 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6207 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6209 if (resinfo)
6211 LPVOID buffer;
6212 HRESULT ret;
6213 DWORD size;
6215 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6217 if (FAILED(ret))
6218 return D3DXERR_INVALIDDATA;
6220 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6223 return D3DXERR_INVALIDDATA;
6226 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
6227 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
6229 HRSRC resinfo;
6231 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6233 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6235 if (resinfo)
6237 LPVOID buffer;
6238 HRESULT ret;
6239 DWORD size;
6241 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6243 if (FAILED(ret))
6244 return D3DXERR_INVALIDDATA;
6246 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6249 return D3DXERR_INVALIDDATA;