winemac: Tell Cocoa to preserve our window content during live resizing.
[wine.git] / dlls / d3dx9_36 / effect.c
blob4ef900ec23ab02a74832f30682e89d62a3b3d45e
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 struct ID3DXEffectStateManager *manager;
175 struct IDirect3DDevice9 *device;
176 struct ID3DXEffectPool *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, BOOL transpose)
875 UINT i, k;
877 for (i = 0; i < 4; ++i)
879 for (k = 0; k < 4; ++k)
881 FLOAT *tmp = transpose ? (FLOAT *)&matrix->u.m[k][i] : (FLOAT *)&matrix->u.m[i][k];
883 if ((i < param->rows) && (k < param->columns))
884 set_number(tmp, D3DXPT_FLOAT, (DWORD *)param->data + i * param->columns + k, param->type);
885 else
886 *tmp = 0.0f;
891 static void set_matrix(struct d3dx_parameter *param, const D3DXMATRIX *matrix, BOOL transpose)
893 UINT i, k;
895 for (i = 0; i < param->rows; ++i)
897 for (k = 0; k < param->columns; ++k)
899 set_number((FLOAT *)param->data + i * param->columns + k, param->type,
900 transpose ? &matrix->u.m[k][i] : &matrix->u.m[i][k], D3DXPT_FLOAT);
905 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
907 UINT element;
908 struct d3dx_parameter *temp_parameter;
909 LPCSTR part;
911 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
913 if (!name || !*name) return NULL;
915 element = atoi(name);
916 part = strchr(name, ']') + 1;
918 /* check for empty [] && element range */
919 if ((part - name) > 1 && parameter->element_count > element)
921 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
923 switch (*part++)
925 case '.':
926 return get_parameter_by_name(NULL, temp_parameter, part);
928 case '@':
929 return get_annotation_by_name(temp_parameter->annotation_count, temp_parameter->annotation_handles, part);
931 case '\0':
932 TRACE("Returning parameter %p\n", temp_parameter);
933 return temp_parameter;
935 default:
936 FIXME("Unhandled case \"%c\"\n", *--part);
937 break;
941 TRACE("Parameter not found\n");
942 return NULL;
945 static struct d3dx_parameter *get_annotation_by_name(UINT handlecount, D3DXHANDLE *handles, LPCSTR name)
947 UINT i, length;
948 struct d3dx_parameter *temp_parameter;
949 LPCSTR part;
951 TRACE("handlecount %u, handles %p, name %s\n", handlecount, handles, debugstr_a(name));
953 if (!name || !*name) return NULL;
955 length = strcspn( name, "[.@" );
956 part = name + length;
958 for (i = 0; i < handlecount; ++i)
960 temp_parameter = get_parameter_struct(handles[i]);
962 if (!strcmp(temp_parameter->name, name))
964 TRACE("Returning parameter %p\n", temp_parameter);
965 return temp_parameter;
967 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
969 switch (*part++)
971 case '.':
972 return get_parameter_by_name(NULL, temp_parameter, part);
974 case '[':
975 return get_parameter_element_by_name(temp_parameter, part);
977 default:
978 FIXME("Unhandled case \"%c\"\n", *--part);
979 break;
984 TRACE("Parameter not found\n");
985 return NULL;
988 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
989 struct d3dx_parameter *parameter, LPCSTR name)
991 UINT i, count, length;
992 struct d3dx_parameter *temp_parameter;
993 D3DXHANDLE *handles;
994 LPCSTR part;
996 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
998 if (!name || !*name) return NULL;
1000 if (!parameter)
1002 count = base->parameter_count;
1003 handles = base->parameter_handles;
1005 else
1007 count = parameter->member_count;
1008 handles = parameter->member_handles;
1011 length = strcspn( name, "[.@" );
1012 part = name + length;
1014 for (i = 0; i < count; i++)
1016 temp_parameter = get_parameter_struct(handles[i]);
1018 if (!strcmp(temp_parameter->name, name))
1020 TRACE("Returning parameter %p\n", temp_parameter);
1021 return temp_parameter;
1023 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1025 switch (*part++)
1027 case '.':
1028 return get_parameter_by_name(NULL, temp_parameter, part);
1030 case '@':
1031 return get_annotation_by_name(temp_parameter->annotation_count, temp_parameter->annotation_handles, part);
1033 case '[':
1034 return get_parameter_element_by_name(temp_parameter, part);
1036 default:
1037 FIXME("Unhandled case \"%c\"\n", *--part);
1038 break;
1043 TRACE("Parameter not found\n");
1044 return NULL;
1047 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
1049 return (0xfeff0000 | ((major) << 8) | (minor));
1052 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
1054 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
1057 /*** IUnknown methods ***/
1058 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
1060 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
1062 if (IsEqualGUID(riid, &IID_IUnknown) ||
1063 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
1065 iface->lpVtbl->AddRef(iface);
1066 *object = iface;
1067 return S_OK;
1070 ERR("Interface %s not found\n", debugstr_guid(riid));
1072 return E_NOINTERFACE;
1075 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
1077 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1079 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
1081 return InterlockedIncrement(&This->ref);
1084 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
1086 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1087 ULONG ref = InterlockedDecrement(&This->ref);
1089 TRACE("iface %p: Release from %u\n", iface, ref + 1);
1091 if (!ref)
1093 free_base_effect(This);
1094 HeapFree(GetProcessHeap(), 0, This);
1097 return ref;
1100 /*** ID3DXBaseEffect methods ***/
1101 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
1103 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1105 FIXME("iface %p, desc %p partial stub\n", This, desc);
1107 if (!desc)
1109 WARN("Invalid argument specified.\n");
1110 return D3DERR_INVALIDCALL;
1113 /* Todo: add creator and function count */
1114 desc->Creator = NULL;
1115 desc->Functions = 0;
1116 desc->Parameters = This->parameter_count;
1117 desc->Techniques = This->technique_count;
1119 return D3D_OK;
1122 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1124 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1125 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1127 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
1129 if (!desc || !param)
1131 WARN("Invalid argument specified.\n");
1132 return D3DERR_INVALIDCALL;
1135 desc->Name = param->name;
1136 desc->Semantic = param->semantic;
1137 desc->Class = param->class;
1138 desc->Type = param->type;
1139 desc->Rows = param->rows;
1140 desc->Columns = param->columns;
1141 desc->Elements = param->element_count;
1142 desc->Annotations = param->annotation_count;
1143 desc->StructMembers = param->member_count;
1144 desc->Flags = param->flags;
1145 desc->Bytes = param->bytes;
1147 return D3D_OK;
1150 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1152 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1153 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
1155 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
1157 if (!desc || !tech)
1159 WARN("Invalid argument specified.\n");
1160 return D3DERR_INVALIDCALL;
1163 desc->Name = tech->name;
1164 desc->Passes = tech->pass_count;
1165 desc->Annotations = tech->annotation_count;
1167 return D3D_OK;
1170 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1172 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1173 struct d3dx_pass *p = is_valid_pass(This, pass);
1175 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
1177 if (!desc || !p)
1179 WARN("Invalid argument specified.\n");
1180 return D3DERR_INVALIDCALL;
1183 desc->Name = p->name;
1184 desc->Annotations = p->annotation_count;
1186 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1187 desc->pVertexShaderFunction = NULL;
1188 desc->pPixelShaderFunction = NULL;
1190 return D3D_OK;
1193 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1195 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1197 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
1199 return E_NOTIMPL;
1202 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1204 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1205 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1207 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1209 if (!parameter)
1211 if (index < This->parameter_count)
1213 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1214 return This->parameter_handles[index];
1217 else
1219 if (param && !param->element_count && index < param->member_count)
1221 TRACE("Returning parameter %p\n", param->member_handles[index]);
1222 return param->member_handles[index];
1226 WARN("Invalid argument specified.\n");
1228 return NULL;
1231 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1233 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1234 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1235 D3DXHANDLE handle;
1237 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
1239 if (!name)
1241 handle = get_parameter_handle(param);
1242 TRACE("Returning parameter %p\n", handle);
1243 return handle;
1246 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
1247 TRACE("Returning parameter %p\n", handle);
1249 return handle;
1252 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1254 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1255 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1256 struct d3dx_parameter *temp_param;
1257 UINT i;
1259 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
1261 if (!parameter)
1263 for (i = 0; i < This->parameter_count; ++i)
1265 temp_param = get_parameter_struct(This->parameter_handles[i]);
1267 if (!temp_param->semantic)
1269 if (!semantic)
1271 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1272 return This->parameter_handles[i];
1274 continue;
1277 if (!strcasecmp(temp_param->semantic, semantic))
1279 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
1280 return This->parameter_handles[i];
1284 else if (param)
1286 for (i = 0; i < param->member_count; ++i)
1288 temp_param = get_parameter_struct(param->member_handles[i]);
1290 if (!temp_param->semantic)
1292 if (!semantic)
1294 TRACE("Returning parameter %p\n", param->member_handles[i]);
1295 return param->member_handles[i];
1297 continue;
1300 if (!strcasecmp(temp_param->semantic, semantic))
1302 TRACE("Returning parameter %p\n", param->member_handles[i]);
1303 return param->member_handles[i];
1308 WARN("Invalid argument specified\n");
1310 return NULL;
1313 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
1315 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1316 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1318 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
1320 if (!param)
1322 if (index < This->parameter_count)
1324 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
1325 return This->parameter_handles[index];
1328 else
1330 if (index < param->element_count)
1332 TRACE("Returning parameter %p\n", param->member_handles[index]);
1333 return param->member_handles[index];
1337 WARN("Invalid argument specified\n");
1339 return NULL;
1342 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
1344 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1346 TRACE("iface %p, index %u\n", This, index);
1348 if (index >= This->technique_count)
1350 WARN("Invalid argument specified.\n");
1351 return NULL;
1354 TRACE("Returning technique %p\n", This->technique_handles[index]);
1356 return This->technique_handles[index];
1359 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1361 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1362 struct d3dx_technique *tech = get_technique_by_name(This, name);
1364 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1366 if (tech)
1368 D3DXHANDLE t = get_technique_handle(tech);
1369 TRACE("Returning technique %p\n", t);
1370 return t;
1373 WARN("Invalid argument specified.\n");
1375 return NULL;
1378 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1380 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1381 struct d3dx_technique *tech = is_valid_technique(This, technique);
1383 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1385 if (tech && index < tech->pass_count)
1387 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1388 return tech->pass_handles[index];
1391 WARN("Invalid argument specified.\n");
1393 return NULL;
1396 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1398 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1399 struct d3dx_technique *tech = is_valid_technique(This, technique);
1401 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1403 if (tech && name)
1405 unsigned int i;
1407 for (i = 0; i < tech->pass_count; ++i)
1409 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1411 if (!strcmp(pass->name, name))
1413 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1414 return tech->pass_handles[i];
1419 WARN("Invalid argument specified.\n");
1421 return NULL;
1424 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1426 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1428 FIXME("iface %p, index %u stub\n", This, index);
1430 return NULL;
1433 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1435 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1437 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1439 return NULL;
1442 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1444 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1445 struct d3dx_parameter *param = get_valid_parameter(This, object);
1446 struct d3dx_pass *pass = is_valid_pass(This, object);
1447 struct d3dx_technique *technique = is_valid_technique(This, object);
1448 UINT annotation_count = 0;
1449 D3DXHANDLE *annotation_handles = NULL;
1451 TRACE("iface %p, object %p, index %u\n", This, object, index);
1453 if (pass)
1455 annotation_count = pass->annotation_count;
1456 annotation_handles = pass->annotation_handles;
1458 else if (technique)
1460 annotation_count = technique->annotation_count;
1461 annotation_handles = technique->annotation_handles;
1463 else if (param)
1465 annotation_count = param->annotation_count;
1466 annotation_handles = param->annotation_handles;
1468 else
1470 FIXME("Functions are not handled, yet!\n");
1473 if (index < annotation_count)
1475 TRACE("Returning parameter %p\n", annotation_handles[index]);
1476 return annotation_handles[index];
1479 WARN("Invalid argument specified\n");
1481 return NULL;
1484 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1486 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1487 struct d3dx_parameter *param = get_valid_parameter(This, object);
1488 struct d3dx_pass *pass = is_valid_pass(This, object);
1489 struct d3dx_technique *technique = is_valid_technique(This, object);
1490 struct d3dx_parameter *anno = NULL;
1491 UINT annotation_count = 0;
1492 D3DXHANDLE *annotation_handles = NULL;
1494 TRACE("iface %p, object %p, name %s\n", This, object, debugstr_a(name));
1496 if (!name)
1498 WARN("Invalid argument specified\n");
1499 return NULL;
1502 if (pass)
1504 annotation_count = pass->annotation_count;
1505 annotation_handles = pass->annotation_handles;
1507 else if (technique)
1509 annotation_count = technique->annotation_count;
1510 annotation_handles = technique->annotation_handles;
1512 else if (param)
1514 annotation_count = param->annotation_count;
1515 annotation_handles = param->annotation_handles;
1517 else
1519 FIXME("Functions are not handled, yet!\n");
1522 anno = get_annotation_by_name(annotation_count, annotation_handles, name);
1523 if (anno)
1525 TRACE("Returning parameter %p\n", anno);
1526 return get_parameter_handle(anno);
1529 WARN("Invalid argument specified\n");
1531 return NULL;
1534 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1536 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1537 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1539 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1541 if (!param)
1543 WARN("Invalid parameter %p specified\n", parameter);
1544 return D3DERR_INVALIDCALL;
1547 /* samplers don't touch data */
1548 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1549 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1550 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1552 TRACE("Sampler: returning E_FAIL\n");
1553 return E_FAIL;
1556 if (data && param->bytes <= bytes)
1558 switch (param->type)
1560 case D3DXPT_VOID:
1561 case D3DXPT_BOOL:
1562 case D3DXPT_INT:
1563 case D3DXPT_FLOAT:
1564 TRACE("Copy %u bytes\n", param->bytes);
1565 memcpy(param->data, data, param->bytes);
1566 break;
1568 default:
1569 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1570 break;
1573 return D3D_OK;
1576 WARN("Invalid argument specified\n");
1578 return D3DERR_INVALIDCALL;
1581 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1583 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1584 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1586 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1588 if (!param)
1590 WARN("Invalid parameter %p specified\n", parameter);
1591 return D3DERR_INVALIDCALL;
1594 /* samplers don't touch data */
1595 if (param->class == D3DXPC_OBJECT && (param->type == D3DXPT_SAMPLER
1596 || param->type == D3DXPT_SAMPLER1D || param->type == D3DXPT_SAMPLER2D
1597 || param->type == D3DXPT_SAMPLER3D || param->type == D3DXPT_SAMPLERCUBE))
1599 TRACE("Sampler: returning E_FAIL\n");
1600 return E_FAIL;
1603 if (data && param->bytes <= bytes)
1605 TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
1607 switch (param->type)
1609 case D3DXPT_VOID:
1610 case D3DXPT_BOOL:
1611 case D3DXPT_INT:
1612 case D3DXPT_FLOAT:
1613 case D3DXPT_STRING:
1614 break;
1616 case D3DXPT_VERTEXSHADER:
1617 case D3DXPT_PIXELSHADER:
1618 case D3DXPT_TEXTURE:
1619 case D3DXPT_TEXTURE1D:
1620 case D3DXPT_TEXTURE2D:
1621 case D3DXPT_TEXTURE3D:
1622 case D3DXPT_TEXTURECUBE:
1624 UINT i;
1626 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1628 IUnknown *unk = ((IUnknown **)param->data)[i];
1629 if (unk) IUnknown_AddRef(unk);
1631 break;
1634 default:
1635 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
1636 break;
1639 TRACE("Copy %u bytes\n", param->bytes);
1640 memcpy(data, param->data, param->bytes);
1641 return D3D_OK;
1644 WARN("Invalid argument specified\n");
1646 return D3DERR_INVALIDCALL;
1649 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1651 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1652 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1654 TRACE("iface %p, parameter %p, b %s\n", This, parameter, b ? "TRUE" : "FALSE");
1656 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1658 set_number(param->data, param->type, &b, D3DXPT_BOOL);
1659 return D3D_OK;
1662 WARN("Invalid argument specified\n");
1664 return D3DERR_INVALIDCALL;
1667 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1669 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1670 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1672 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1674 if (b && param && !param->element_count && param->rows == 1 && param->columns == 1)
1676 set_number(b, D3DXPT_BOOL, param->data, param->type);
1677 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1678 return D3D_OK;
1681 WARN("Invalid argument specified\n");
1683 return D3DERR_INVALIDCALL;
1686 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1688 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1689 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1691 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1693 if (param)
1695 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1697 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1699 switch (param->class)
1701 case D3DXPC_SCALAR:
1702 case D3DXPC_VECTOR:
1703 case D3DXPC_MATRIX_ROWS:
1704 for (i = 0; i < size; ++i)
1706 /* don't crop the input, use D3DXPT_INT instead of D3DXPT_BOOL */
1707 set_number((DWORD *)param->data + i, param->type, &b[i], D3DXPT_INT);
1709 return D3D_OK;
1711 case D3DXPC_OBJECT:
1712 case D3DXPC_STRUCT:
1713 break;
1715 default:
1716 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1717 break;
1721 WARN("Invalid argument specified\n");
1723 return D3DERR_INVALIDCALL;
1726 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1728 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1729 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1731 TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count);
1733 if (b && param && (param->class == D3DXPC_SCALAR
1734 || param->class == D3DXPC_VECTOR
1735 || param->class == D3DXPC_MATRIX_ROWS
1736 || param->class == D3DXPC_MATRIX_COLUMNS))
1738 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1740 for (i = 0; i < size; ++i)
1742 set_number(&b[i], D3DXPT_BOOL, (DWORD *)param->data + i, param->type);
1744 return D3D_OK;
1747 WARN("Invalid argument specified\n");
1749 return D3DERR_INVALIDCALL;
1752 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1754 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1755 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1757 TRACE("iface %p, parameter %p, n %i\n", This, parameter, n);
1759 if (param && !param->element_count)
1761 if (param->rows == 1 && param->columns == 1)
1763 set_number(param->data, param->type, &n, D3DXPT_INT);
1764 return D3D_OK;
1768 * Split the value, if parameter is a vector with dimension 3 or 4.
1770 if (param->type == D3DXPT_FLOAT &&
1771 ((param->class == D3DXPC_VECTOR && param->columns != 2) ||
1772 (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1774 TRACE("Vector fixup\n");
1776 *(FLOAT *)param->data = ((n & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
1777 ((FLOAT *)param->data)[1] = ((n & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
1778 ((FLOAT *)param->data)[2] = (n & 0xff) * INT_FLOAT_MULTI_INVERSE;
1779 if (param->rows * param->columns > 3)
1781 ((FLOAT *)param->data)[3] = ((n & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
1783 return D3D_OK;
1787 WARN("Invalid argument specified\n");
1789 return D3DERR_INVALIDCALL;
1792 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1794 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1795 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1797 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1799 if (n && param && !param->element_count)
1801 if (param->columns == 1 && param->rows == 1)
1803 set_number(n, D3DXPT_INT, param->data, param->type);
1804 TRACE("Returning %i\n", *n);
1805 return D3D_OK;
1808 if (param->type == D3DXPT_FLOAT &&
1809 ((param->class == D3DXPC_VECTOR && param->columns != 2)
1810 || (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
1812 TRACE("Vector fixup\n");
1814 /* all components (3,4) are clamped (0,255) and put in the INT */
1815 *n = (INT)(min(max(0.0f, *((FLOAT *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI);
1816 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
1817 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
1818 if (param->columns * param->rows > 3)
1820 *n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
1823 TRACE("Returning %i\n", *n);
1824 return D3D_OK;
1828 WARN("Invalid argument specified\n");
1830 return D3DERR_INVALIDCALL;
1833 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1835 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1836 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1838 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1840 if (param)
1842 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1844 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1846 switch (param->class)
1848 case D3DXPC_SCALAR:
1849 case D3DXPC_VECTOR:
1850 case D3DXPC_MATRIX_ROWS:
1851 for (i = 0; i < size; ++i)
1853 set_number((DWORD *)param->data + i, param->type, &n[i], D3DXPT_INT);
1855 return D3D_OK;
1857 case D3DXPC_OBJECT:
1858 case D3DXPC_STRUCT:
1859 break;
1861 default:
1862 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1863 break;
1867 WARN("Invalid argument specified\n");
1869 return D3DERR_INVALIDCALL;
1872 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1874 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1875 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1877 TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count);
1879 if (n && param && (param->class == D3DXPC_SCALAR
1880 || param->class == D3DXPC_VECTOR
1881 || param->class == D3DXPC_MATRIX_ROWS
1882 || param->class == D3DXPC_MATRIX_COLUMNS))
1884 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1886 for (i = 0; i < size; ++i)
1888 set_number(&n[i], D3DXPT_INT, (DWORD *)param->data + i, param->type);
1890 return D3D_OK;
1893 WARN("Invalid argument specified\n");
1895 return D3DERR_INVALIDCALL;
1898 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1900 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1901 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1903 TRACE("iface %p, parameter %p, f %f\n", This, parameter, f);
1905 if (param && !param->element_count && param->rows == 1 && param->columns == 1)
1907 set_number((DWORD *)param->data, param->type, &f, D3DXPT_FLOAT);
1908 return D3D_OK;
1911 WARN("Invalid argument specified\n");
1913 return D3DERR_INVALIDCALL;
1916 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1918 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1919 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1921 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1923 if (f && param && !param->element_count && param->columns == 1 && param->rows == 1)
1925 set_number(f, D3DXPT_FLOAT, (DWORD *)param->data, param->type);
1926 TRACE("Returning %f\n", *f);
1927 return D3D_OK;
1930 WARN("Invalid argument specified\n");
1932 return D3DERR_INVALIDCALL;
1935 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1937 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1938 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1940 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1942 if (param)
1944 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1946 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
1948 switch (param->class)
1950 case D3DXPC_SCALAR:
1951 case D3DXPC_VECTOR:
1952 case D3DXPC_MATRIX_ROWS:
1953 for (i = 0; i < size; ++i)
1955 set_number((DWORD *)param->data + i, param->type, &f[i], D3DXPT_FLOAT);
1957 return D3D_OK;
1959 case D3DXPC_OBJECT:
1960 case D3DXPC_STRUCT:
1961 break;
1963 default:
1964 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
1965 break;
1969 WARN("Invalid argument specified\n");
1971 return D3DERR_INVALIDCALL;
1974 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1976 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1977 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
1979 TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count);
1981 if (f && param && (param->class == D3DXPC_SCALAR
1982 || param->class == D3DXPC_VECTOR
1983 || param->class == D3DXPC_MATRIX_ROWS
1984 || param->class == D3DXPC_MATRIX_COLUMNS))
1986 UINT i, size = min(count, param->bytes / sizeof(DWORD));
1988 for (i = 0; i < size; ++i)
1990 set_number(&f[i], D3DXPT_FLOAT, (DWORD *)param->data + i, param->type);
1992 return D3D_OK;
1995 WARN("Invalid argument specified\n");
1997 return D3DERR_INVALIDCALL;
2000 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2002 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2003 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2005 TRACE("iface %p, parameter %p, vector %p\n", This, parameter, vector);
2007 if (param && !param->element_count)
2009 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2011 switch (param->class)
2013 case D3DXPC_SCALAR:
2014 case D3DXPC_VECTOR:
2015 if (param->type == D3DXPT_INT && param->bytes == 4)
2017 DWORD tmp;
2019 TRACE("INT fixup\n");
2020 tmp = (DWORD)(max(min(vector->z, 1.0f), 0.0f) * INT_FLOAT_MULTI);
2021 tmp += ((DWORD)(max(min(vector->y, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 8;
2022 tmp += ((DWORD)(max(min(vector->x, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 16;
2023 tmp += ((DWORD)(max(min(vector->w, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 24;
2025 *(INT *)param->data = tmp;
2026 return D3D_OK;
2028 set_vector(param, vector);
2029 return D3D_OK;
2031 case D3DXPC_MATRIX_ROWS:
2032 case D3DXPC_OBJECT:
2033 case D3DXPC_STRUCT:
2034 break;
2036 default:
2037 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2038 break;
2042 WARN("Invalid argument specified\n");
2044 return D3DERR_INVALIDCALL;
2047 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2049 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2050 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2052 TRACE("iface %p, parameter %p, vector %p\n", This, parameter, vector);
2054 if (vector && param && !param->element_count)
2056 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2058 switch (param->class)
2060 case D3DXPC_SCALAR:
2061 case D3DXPC_VECTOR:
2062 if (param->type == D3DXPT_INT && param->bytes == 4)
2064 TRACE("INT fixup\n");
2065 vector->x = (((*(INT *)param->data) & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
2066 vector->y = (((*(INT *)param->data) & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
2067 vector->z = ((*(INT *)param->data) & 0xff) * INT_FLOAT_MULTI_INVERSE;
2068 vector->w = (((*(INT *)param->data) & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
2069 return D3D_OK;
2071 get_vector(param, vector);
2072 return D3D_OK;
2074 case D3DXPC_MATRIX_ROWS:
2075 case D3DXPC_OBJECT:
2076 case D3DXPC_STRUCT:
2077 break;
2079 default:
2080 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2081 break;
2085 WARN("Invalid argument specified\n");
2087 return D3DERR_INVALIDCALL;
2090 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2092 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2093 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2095 TRACE("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
2097 if (param && param->element_count && param->element_count >= count)
2099 UINT i;
2101 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2103 switch (param->class)
2105 case D3DXPC_VECTOR:
2106 for (i = 0; i < count; ++i)
2108 set_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2110 return D3D_OK;
2112 case D3DXPC_SCALAR:
2113 case D3DXPC_MATRIX_ROWS:
2114 case D3DXPC_OBJECT:
2115 case D3DXPC_STRUCT:
2116 break;
2118 default:
2119 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2120 break;
2124 WARN("Invalid argument specified\n");
2126 return D3DERR_INVALIDCALL;
2129 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2131 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2132 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2134 TRACE("iface %p, parameter %p, vector %p, count %u\n", This, parameter, vector, count);
2136 if (!count) return D3D_OK;
2138 if (vector && param && count <= param->element_count)
2140 UINT i;
2142 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2144 switch (param->class)
2146 case D3DXPC_VECTOR:
2147 for (i = 0; i < count; ++i)
2149 get_vector(get_parameter_struct(param->member_handles[i]), &vector[i]);
2151 return D3D_OK;
2153 case D3DXPC_SCALAR:
2154 case D3DXPC_MATRIX_ROWS:
2155 case D3DXPC_OBJECT:
2156 case D3DXPC_STRUCT:
2157 break;
2159 default:
2160 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2161 break;
2165 WARN("Invalid argument specified\n");
2167 return D3DERR_INVALIDCALL;
2170 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2172 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2173 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2175 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2177 if (param && !param->element_count)
2179 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2181 switch (param->class)
2183 case D3DXPC_MATRIX_ROWS:
2184 set_matrix(param, matrix, FALSE);
2185 return D3D_OK;
2187 case D3DXPC_SCALAR:
2188 case D3DXPC_VECTOR:
2189 case D3DXPC_OBJECT:
2190 case D3DXPC_STRUCT:
2191 break;
2193 default:
2194 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2195 break;
2199 WARN("Invalid argument specified\n");
2201 return D3DERR_INVALIDCALL;
2204 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2206 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2207 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2209 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2211 if (matrix && param && !param->element_count)
2213 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2215 switch (param->class)
2217 case D3DXPC_MATRIX_ROWS:
2218 get_matrix(param, matrix, FALSE);
2219 return D3D_OK;
2221 case D3DXPC_SCALAR:
2222 case D3DXPC_VECTOR:
2223 case D3DXPC_OBJECT:
2224 case D3DXPC_STRUCT:
2225 break;
2227 default:
2228 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2229 break;
2233 WARN("Invalid argument specified\n");
2235 return D3DERR_INVALIDCALL;
2238 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2240 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2241 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2243 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2245 if (param && param->element_count >= count)
2247 UINT i;
2249 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2251 switch (param->class)
2253 case D3DXPC_MATRIX_ROWS:
2254 for (i = 0; i < count; ++i)
2256 set_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], FALSE);
2258 return D3D_OK;
2260 case D3DXPC_SCALAR:
2261 case D3DXPC_VECTOR:
2262 case D3DXPC_OBJECT:
2263 case D3DXPC_STRUCT:
2264 break;
2266 default:
2267 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2268 break;
2272 WARN("Invalid argument specified\n");
2274 return D3DERR_INVALIDCALL;
2277 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2279 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2280 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2282 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2284 if (!count) return D3D_OK;
2286 if (matrix && param && count <= param->element_count)
2288 UINT i;
2290 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2292 switch (param->class)
2294 case D3DXPC_MATRIX_ROWS:
2295 for (i = 0; i < count; ++i)
2297 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], FALSE);
2299 return D3D_OK;
2301 case D3DXPC_SCALAR:
2302 case D3DXPC_VECTOR:
2303 case D3DXPC_OBJECT:
2304 case D3DXPC_STRUCT:
2305 break;
2307 default:
2308 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2309 break;
2313 WARN("Invalid argument specified\n");
2315 return D3DERR_INVALIDCALL;
2318 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2320 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2321 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2323 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2325 if (param && count <= param->element_count)
2327 UINT i;
2329 switch (param->class)
2331 case D3DXPC_MATRIX_ROWS:
2332 for (i = 0; i < count; ++i)
2334 set_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], FALSE);
2336 return D3D_OK;
2338 case D3DXPC_SCALAR:
2339 case D3DXPC_VECTOR:
2340 case D3DXPC_OBJECT:
2341 break;
2343 default:
2344 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2345 break;
2349 WARN("Invalid argument specified\n");
2351 return D3DERR_INVALIDCALL;
2354 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2356 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2357 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2359 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2361 if (!count) return D3D_OK;
2363 if (param && matrix && count <= param->element_count)
2365 UINT i;
2367 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2369 switch (param->class)
2371 case D3DXPC_MATRIX_ROWS:
2372 for (i = 0; i < count; ++i)
2374 get_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], FALSE);
2376 return D3D_OK;
2378 case D3DXPC_SCALAR:
2379 case D3DXPC_VECTOR:
2380 case D3DXPC_OBJECT:
2381 break;
2383 default:
2384 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2385 break;
2389 WARN("Invalid argument specified\n");
2391 return D3DERR_INVALIDCALL;
2394 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2396 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2397 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2399 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2401 if (param && !param->element_count)
2403 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2405 switch (param->class)
2407 case D3DXPC_MATRIX_ROWS:
2408 set_matrix(param, matrix, TRUE);
2409 return D3D_OK;
2411 case D3DXPC_SCALAR:
2412 case D3DXPC_VECTOR:
2413 case D3DXPC_OBJECT:
2414 case D3DXPC_STRUCT:
2415 break;
2417 default:
2418 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2419 break;
2423 WARN("Invalid argument specified\n");
2425 return D3DERR_INVALIDCALL;
2428 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2430 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2431 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2433 TRACE("iface %p, parameter %p, matrix %p\n", This, parameter, matrix);
2435 if (matrix && param && !param->element_count)
2437 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2439 switch (param->class)
2441 case D3DXPC_SCALAR:
2442 case D3DXPC_VECTOR:
2443 get_matrix(param, matrix, FALSE);
2444 return D3D_OK;
2446 case D3DXPC_MATRIX_ROWS:
2447 get_matrix(param, matrix, TRUE);
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 get_matrix(get_parameter_struct(param->member_handles[i]), &matrix[i], TRUE);
2526 return D3D_OK;
2528 case D3DXPC_SCALAR:
2529 case D3DXPC_VECTOR:
2530 case D3DXPC_OBJECT:
2531 case D3DXPC_STRUCT:
2532 break;
2534 default:
2535 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2536 break;
2540 WARN("Invalid argument specified\n");
2542 return D3DERR_INVALIDCALL;
2545 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2547 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2548 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2550 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2552 if (param && count <= param->element_count)
2554 UINT i;
2556 switch (param->class)
2558 case D3DXPC_MATRIX_ROWS:
2559 for (i = 0; i < count; ++i)
2561 set_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], TRUE);
2563 return D3D_OK;
2565 case D3DXPC_SCALAR:
2566 case D3DXPC_VECTOR:
2567 case D3DXPC_OBJECT:
2568 break;
2570 default:
2571 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2572 break;
2576 WARN("Invalid argument specified\n");
2578 return D3DERR_INVALIDCALL;
2581 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2583 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2584 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2586 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This, parameter, matrix, count);
2588 if (!count) return D3D_OK;
2590 if (matrix && param && count <= param->element_count)
2592 UINT i;
2594 TRACE("Class %s\n", debug_d3dxparameter_class(param->class));
2596 switch (param->class)
2598 case D3DXPC_MATRIX_ROWS:
2599 for (i = 0; i < count; ++i)
2601 get_matrix(get_parameter_struct(param->member_handles[i]), matrix[i], TRUE);
2603 return D3D_OK;
2605 case D3DXPC_SCALAR:
2606 case D3DXPC_VECTOR:
2607 case D3DXPC_OBJECT:
2608 break;
2610 default:
2611 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
2612 break;
2616 WARN("Invalid argument specified\n");
2618 return D3DERR_INVALIDCALL;
2621 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2623 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2625 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
2627 return E_NOTIMPL;
2630 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2632 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2633 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2635 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
2637 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
2639 *string = *(LPCSTR *)param->data;
2640 TRACE("Returning %s\n", debugstr_a(*string));
2641 return D3D_OK;
2644 WARN("Invalid argument specified\n");
2646 return D3DERR_INVALIDCALL;
2649 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(struct ID3DXBaseEffect *iface,
2650 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 *texture)
2652 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2653 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2655 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2657 if (param && !param->element_count &&
2658 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2659 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2660 || param->type == D3DXPT_TEXTURECUBE))
2662 struct IDirect3DBaseTexture9 *oltexture = *(struct IDirect3DBaseTexture9 **)param->data;
2664 if (texture) IDirect3DBaseTexture9_AddRef(texture);
2665 if (oltexture) IDirect3DBaseTexture9_Release(oltexture);
2667 *(struct IDirect3DBaseTexture9 **)param->data = texture;
2669 return D3D_OK;
2672 WARN("Invalid argument specified\n");
2674 return D3DERR_INVALIDCALL;
2677 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(struct ID3DXBaseEffect *iface,
2678 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 **texture)
2680 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2681 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2683 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
2685 if (texture && param && !param->element_count &&
2686 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
2687 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
2688 || param->type == D3DXPT_TEXTURECUBE))
2690 *texture = *(struct IDirect3DBaseTexture9 **)param->data;
2691 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
2692 TRACE("Returning %p\n", *texture);
2693 return D3D_OK;
2696 WARN("Invalid argument specified\n");
2698 return D3DERR_INVALIDCALL;
2701 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface,
2702 D3DXHANDLE parameter, struct IDirect3DPixelShader9 **shader)
2704 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2705 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2707 TRACE("iface %p, parameter %p, shader %p.\n", This, parameter, shader);
2709 if (shader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
2711 if ((*shader = *(struct IDirect3DPixelShader9 **)param->data))
2712 IDirect3DPixelShader9_AddRef(*shader);
2713 TRACE("Returning %p.\n", *shader);
2714 return D3D_OK;
2717 WARN("Invalid argument specified\n");
2719 return D3DERR_INVALIDCALL;
2722 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(struct ID3DXBaseEffect *iface,
2723 D3DXHANDLE parameter, struct IDirect3DVertexShader9 **shader)
2725 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2726 struct d3dx_parameter *param = get_valid_parameter(This, parameter);
2728 TRACE("iface %p, parameter %p, shader %p.\n", This, parameter, shader);
2730 if (shader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
2732 if ((*shader = *(struct IDirect3DVertexShader9 **)param->data))
2733 IDirect3DVertexShader9_AddRef(*shader);
2734 TRACE("Returning %p.\n", *shader);
2735 return D3D_OK;
2738 WARN("Invalid argument specified\n");
2740 return D3DERR_INVALIDCALL;
2743 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2745 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
2747 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
2749 return E_NOTIMPL;
2752 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
2754 /*** IUnknown methods ***/
2755 ID3DXBaseEffectImpl_QueryInterface,
2756 ID3DXBaseEffectImpl_AddRef,
2757 ID3DXBaseEffectImpl_Release,
2758 /*** ID3DXBaseEffect methods ***/
2759 ID3DXBaseEffectImpl_GetDesc,
2760 ID3DXBaseEffectImpl_GetParameterDesc,
2761 ID3DXBaseEffectImpl_GetTechniqueDesc,
2762 ID3DXBaseEffectImpl_GetPassDesc,
2763 ID3DXBaseEffectImpl_GetFunctionDesc,
2764 ID3DXBaseEffectImpl_GetParameter,
2765 ID3DXBaseEffectImpl_GetParameterByName,
2766 ID3DXBaseEffectImpl_GetParameterBySemantic,
2767 ID3DXBaseEffectImpl_GetParameterElement,
2768 ID3DXBaseEffectImpl_GetTechnique,
2769 ID3DXBaseEffectImpl_GetTechniqueByName,
2770 ID3DXBaseEffectImpl_GetPass,
2771 ID3DXBaseEffectImpl_GetPassByName,
2772 ID3DXBaseEffectImpl_GetFunction,
2773 ID3DXBaseEffectImpl_GetFunctionByName,
2774 ID3DXBaseEffectImpl_GetAnnotation,
2775 ID3DXBaseEffectImpl_GetAnnotationByName,
2776 ID3DXBaseEffectImpl_SetValue,
2777 ID3DXBaseEffectImpl_GetValue,
2778 ID3DXBaseEffectImpl_SetBool,
2779 ID3DXBaseEffectImpl_GetBool,
2780 ID3DXBaseEffectImpl_SetBoolArray,
2781 ID3DXBaseEffectImpl_GetBoolArray,
2782 ID3DXBaseEffectImpl_SetInt,
2783 ID3DXBaseEffectImpl_GetInt,
2784 ID3DXBaseEffectImpl_SetIntArray,
2785 ID3DXBaseEffectImpl_GetIntArray,
2786 ID3DXBaseEffectImpl_SetFloat,
2787 ID3DXBaseEffectImpl_GetFloat,
2788 ID3DXBaseEffectImpl_SetFloatArray,
2789 ID3DXBaseEffectImpl_GetFloatArray,
2790 ID3DXBaseEffectImpl_SetVector,
2791 ID3DXBaseEffectImpl_GetVector,
2792 ID3DXBaseEffectImpl_SetVectorArray,
2793 ID3DXBaseEffectImpl_GetVectorArray,
2794 ID3DXBaseEffectImpl_SetMatrix,
2795 ID3DXBaseEffectImpl_GetMatrix,
2796 ID3DXBaseEffectImpl_SetMatrixArray,
2797 ID3DXBaseEffectImpl_GetMatrixArray,
2798 ID3DXBaseEffectImpl_SetMatrixPointerArray,
2799 ID3DXBaseEffectImpl_GetMatrixPointerArray,
2800 ID3DXBaseEffectImpl_SetMatrixTranspose,
2801 ID3DXBaseEffectImpl_GetMatrixTranspose,
2802 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
2803 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
2804 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
2805 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
2806 ID3DXBaseEffectImpl_SetString,
2807 ID3DXBaseEffectImpl_GetString,
2808 ID3DXBaseEffectImpl_SetTexture,
2809 ID3DXBaseEffectImpl_GetTexture,
2810 ID3DXBaseEffectImpl_GetPixelShader,
2811 ID3DXBaseEffectImpl_GetVertexShader,
2812 ID3DXBaseEffectImpl_SetArrayRange,
2815 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
2817 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
2820 /*** IUnknown methods ***/
2821 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
2823 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
2825 if (IsEqualGUID(riid, &IID_IUnknown) ||
2826 IsEqualGUID(riid, &IID_ID3DXEffect))
2828 iface->lpVtbl->AddRef(iface);
2829 *object = iface;
2830 return S_OK;
2833 ERR("Interface %s not found\n", debugstr_guid(riid));
2835 return E_NOINTERFACE;
2838 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
2840 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2842 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
2844 return InterlockedIncrement(&This->ref);
2847 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
2849 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2850 ULONG ref = InterlockedDecrement(&This->ref);
2852 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
2854 if (!ref)
2856 free_effect(This);
2857 HeapFree(GetProcessHeap(), 0, This);
2860 return ref;
2863 /*** ID3DXBaseEffect methods ***/
2864 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
2866 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2867 ID3DXBaseEffect *base = This->base_effect;
2869 TRACE("Forward iface %p, base %p\n", This, base);
2871 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2874 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2876 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2877 ID3DXBaseEffect *base = This->base_effect;
2879 TRACE("Forward iface %p, base %p\n", This, base);
2881 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2884 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2886 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2887 ID3DXBaseEffect *base = This->base_effect;
2889 TRACE("Forward iface %p, base %p\n", This, base);
2891 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2894 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2896 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2897 ID3DXBaseEffect *base = This->base_effect;
2899 TRACE("Forward iface %p, base %p\n", This, base);
2901 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2904 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2906 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2907 ID3DXBaseEffect *base = This->base_effect;
2909 TRACE("Forward iface %p, base %p\n", This, base);
2911 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2914 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2916 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2917 ID3DXBaseEffect *base = This->base_effect;
2919 TRACE("Forward iface %p, base %p\n", This, base);
2921 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2924 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
2926 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2927 ID3DXBaseEffect *base = This->base_effect;
2929 TRACE("Forward iface %p, base %p\n", This, base);
2931 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2934 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
2936 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2937 ID3DXBaseEffect *base = This->base_effect;
2939 TRACE("Forward iface %p, base %p\n", This, base);
2941 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2944 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
2946 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2947 ID3DXBaseEffect *base = This->base_effect;
2949 TRACE("Forward iface %p, base %p\n", This, base);
2951 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2954 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
2956 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2957 ID3DXBaseEffect *base = This->base_effect;
2959 TRACE("Forward iface %p, base %p\n", This, base);
2961 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2964 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
2966 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2967 ID3DXBaseEffect *base = This->base_effect;
2969 TRACE("Forward iface %p, base %p\n", This, base);
2971 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2974 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
2976 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2977 ID3DXBaseEffect *base = This->base_effect;
2979 TRACE("Forward iface %p, base %p\n", This, base);
2981 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2984 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
2986 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2987 ID3DXBaseEffect *base = This->base_effect;
2989 TRACE("Forward iface %p, base %p\n", This, base);
2991 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2994 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
2996 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2997 ID3DXBaseEffect *base = This->base_effect;
2999 TRACE("Forward iface %p, base %p\n", This, base);
3001 return ID3DXBaseEffectImpl_GetFunction(base, index);
3004 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
3006 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3007 ID3DXBaseEffect *base = This->base_effect;
3009 TRACE("Forward iface %p, base %p\n", This, base);
3011 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3014 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
3016 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3017 ID3DXBaseEffect *base = This->base_effect;
3019 TRACE("Forward iface %p, base %p\n", This, base);
3021 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3024 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
3026 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3027 ID3DXBaseEffect *base = This->base_effect;
3029 TRACE("Forward iface %p, base %p\n", This, base);
3031 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
3034 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
3036 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3037 ID3DXBaseEffect *base = This->base_effect;
3039 TRACE("Forward iface %p, base %p\n", This, base);
3041 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
3044 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
3046 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3047 ID3DXBaseEffect *base = This->base_effect;
3049 TRACE("Forward iface %p, base %p\n", This, base);
3051 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
3054 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
3056 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3057 ID3DXBaseEffect *base = This->base_effect;
3059 TRACE("Forward iface %p, base %p\n", This, base);
3061 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
3064 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
3066 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3067 ID3DXBaseEffect *base = This->base_effect;
3069 TRACE("Forward iface %p, base %p\n", This, base);
3071 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
3074 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
3076 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3077 ID3DXBaseEffect *base = This->base_effect;
3079 TRACE("Forward iface %p, base %p\n", This, base);
3081 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
3084 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
3086 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3087 ID3DXBaseEffect *base = This->base_effect;
3089 TRACE("Forward iface %p, base %p\n", This, base);
3091 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
3094 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
3096 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3097 ID3DXBaseEffect *base = This->base_effect;
3099 TRACE("Forward iface %p, base %p\n", This, base);
3101 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
3104 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
3106 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3107 ID3DXBaseEffect *base = This->base_effect;
3109 TRACE("Forward iface %p, base %p\n", This, base);
3111 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
3114 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
3116 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3117 ID3DXBaseEffect *base = This->base_effect;
3119 TRACE("Forward iface %p, base %p\n", This, base);
3121 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
3124 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
3126 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3127 ID3DXBaseEffect *base = This->base_effect;
3129 TRACE("Forward iface %p, base %p\n", This, base);
3131 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
3134 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
3136 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3137 ID3DXBaseEffect *base = This->base_effect;
3139 TRACE("Forward iface %p, base %p\n", This, base);
3141 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
3144 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
3146 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3147 ID3DXBaseEffect *base = This->base_effect;
3149 TRACE("Forward iface %p, base %p\n", This, base);
3151 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
3154 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
3156 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3157 ID3DXBaseEffect *base = This->base_effect;
3159 TRACE("Forward iface %p, base %p\n", This, base);
3161 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
3164 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
3166 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3167 ID3DXBaseEffect *base = This->base_effect;
3169 TRACE("Forward iface %p, base %p\n", This, base);
3171 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
3174 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
3176 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3177 ID3DXBaseEffect *base = This->base_effect;
3179 TRACE("Forward iface %p, base %p\n", This, base);
3181 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
3184 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
3186 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3187 ID3DXBaseEffect *base = This->base_effect;
3189 TRACE("Forward iface %p, base %p\n", This, base);
3191 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3194 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3196 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3197 ID3DXBaseEffect *base = This->base_effect;
3199 TRACE("Forward iface %p, base %p\n", This, base);
3201 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3204 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3206 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3207 ID3DXBaseEffect *base = This->base_effect;
3209 TRACE("Forward iface %p, base %p\n", This, base);
3211 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3214 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3216 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3217 ID3DXBaseEffect *base = This->base_effect;
3219 TRACE("Forward iface %p, base %p\n", This, base);
3221 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3224 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3226 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3227 ID3DXBaseEffect *base = This->base_effect;
3229 TRACE("Forward iface %p, base %p\n", This, base);
3231 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3234 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3236 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3237 ID3DXBaseEffect *base = This->base_effect;
3239 TRACE("Forward iface %p, base %p\n", This, base);
3241 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3244 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3246 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3247 ID3DXBaseEffect *base = This->base_effect;
3249 TRACE("Forward iface %p, base %p\n", This, base);
3251 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3254 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3256 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3257 ID3DXBaseEffect *base = This->base_effect;
3259 TRACE("Forward iface %p, base %p\n", This, base);
3261 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3264 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3266 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3267 ID3DXBaseEffect *base = This->base_effect;
3269 TRACE("Forward iface %p, base %p\n", This, base);
3271 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3274 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3276 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3277 ID3DXBaseEffect *base = This->base_effect;
3279 TRACE("Forward iface %p, base %p\n", This, base);
3281 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3284 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3286 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3287 ID3DXBaseEffect *base = This->base_effect;
3289 TRACE("Forward iface %p, base %p\n", This, base);
3291 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3294 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3296 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3297 ID3DXBaseEffect *base = This->base_effect;
3299 TRACE("Forward iface %p, base %p\n", This, base);
3301 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3304 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3306 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3307 ID3DXBaseEffect *base = This->base_effect;
3309 TRACE("Forward iface %p, base %p\n", This, base);
3311 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3314 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3316 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3317 ID3DXBaseEffect *base = This->base_effect;
3319 TRACE("Forward iface %p, base %p\n", This, base);
3321 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3324 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3326 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3327 ID3DXBaseEffect *base = This->base_effect;
3329 TRACE("Forward iface %p, base %p\n", This, base);
3331 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3334 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
3336 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3337 ID3DXBaseEffect *base = This->base_effect;
3339 TRACE("Forward iface %p, base %p\n", This, base);
3341 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3344 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
3346 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3347 ID3DXBaseEffect *base = This->base_effect;
3349 TRACE("Forward iface %p, base %p\n", This, base);
3351 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3354 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(struct ID3DXEffect *iface,
3355 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 *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(struct ID3DXEffect *iface,
3366 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 **texture)
3368 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3369 ID3DXBaseEffect *base = This->base_effect;
3371 TRACE("Forward iface %p, base %p\n", This, base);
3373 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3376 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface,
3377 D3DXHANDLE parameter, struct IDirect3DPixelShader9 **shader)
3379 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3380 ID3DXBaseEffect *base = This->base_effect;
3382 TRACE("Forward iface %p, base %p\n", This, base);
3384 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, shader);
3387 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(struct ID3DXEffect *iface,
3388 D3DXHANDLE parameter, struct IDirect3DVertexShader9 **shader)
3390 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3391 ID3DXBaseEffect *base = This->base_effect;
3393 TRACE("Forward iface %p, base %p\n", This, base);
3395 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, shader);
3398 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
3400 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3401 ID3DXBaseEffect *base = This->base_effect;
3403 TRACE("Forward iface %p, base %p\n", This, base);
3405 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3408 /*** ID3DXEffect methods ***/
3409 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, ID3DXEffectPool **pool)
3411 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3413 TRACE("iface %p, pool %p\n", This, pool);
3415 if (!pool)
3417 WARN("Invalid argument supplied.\n");
3418 return D3DERR_INVALIDCALL;
3421 if (This->pool)
3423 This->pool->lpVtbl->AddRef(This->pool);
3426 *pool = This->pool;
3428 TRACE("Returning pool %p\n", *pool);
3430 return S_OK;
3433 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect *iface, D3DXHANDLE technique)
3435 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3436 struct ID3DXBaseEffectImpl *base = impl_from_ID3DXBaseEffect(This->base_effect);
3437 struct d3dx_technique *tech = is_valid_technique(base, technique);
3439 TRACE("iface %p, technique %p\n", This, technique);
3441 if (tech)
3443 This->active_technique = get_technique_handle(tech);
3444 TRACE("Technique %p\n", tech);
3445 return D3D_OK;
3448 WARN("Invalid argument supplied.\n");
3450 return D3DERR_INVALIDCALL;
3453 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface)
3455 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3457 TRACE("iface %p\n", This);
3459 return This->active_technique;
3462 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
3464 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3466 FIXME("(%p)->(%p): stub\n", This, technique);
3468 return D3D_OK;
3471 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
3473 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3475 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
3477 return E_NOTIMPL;
3480 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
3482 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3484 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
3486 return FALSE;
3489 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect *iface, UINT *passes, DWORD flags)
3491 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3492 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3494 FIXME("iface %p, passes %p, flags %#x partial stub\n", This, passes, flags);
3496 if (passes && technique)
3498 if (This->manager || flags & D3DXFX_DONOTSAVESTATE)
3500 TRACE("State capturing disabled.\n");
3502 else
3504 FIXME("State capturing not supported, yet!\n");
3507 *passes = technique->pass_count;
3509 return D3D_OK;
3512 WARN("Invalid argument supplied.\n");
3514 return D3DERR_INVALIDCALL;
3517 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect *iface, UINT pass)
3519 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3520 struct d3dx_technique *technique = get_technique_struct(This->active_technique);
3522 TRACE("iface %p, pass %u\n", This, pass);
3524 if (technique && pass < technique->pass_count && !This->active_pass)
3526 This->active_pass = technique->pass_handles[pass];
3528 FIXME("No states applied, yet!\n");
3530 return D3D_OK;
3533 WARN("Invalid argument supplied.\n");
3535 return D3DERR_INVALIDCALL;
3538 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
3540 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3542 FIXME("(%p)->(): stub\n", This);
3544 return E_NOTIMPL;
3547 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect *iface)
3549 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3551 TRACE("iface %p\n", This);
3553 if (This->active_pass)
3555 This->active_pass = NULL;
3556 return D3D_OK;
3559 WARN("Invalid call.\n");
3561 return D3DERR_INVALIDCALL;
3564 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
3566 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3568 FIXME("(%p)->(): stub\n", This);
3570 return E_NOTIMPL;
3573 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, struct IDirect3DDevice9 **device)
3575 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3577 TRACE("iface %p, device %p\n", This, device);
3579 if (!device)
3581 WARN("Invalid argument supplied.\n");
3582 return D3DERR_INVALIDCALL;
3585 IDirect3DDevice9_AddRef(This->device);
3587 *device = This->device;
3589 TRACE("Returning device %p\n", *device);
3591 return S_OK;
3594 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
3596 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3598 FIXME("(%p)->(): stub\n", This);
3600 return E_NOTIMPL;
3603 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
3605 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3607 FIXME("(%p)->(): stub\n", This);
3609 return E_NOTIMPL;
3612 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, ID3DXEffectStateManager *manager)
3614 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3616 TRACE("iface %p, manager %p\n", This, manager);
3618 if (manager) IUnknown_AddRef(manager);
3619 if (This->manager) IUnknown_Release(This->manager);
3621 This->manager = manager;
3623 return D3D_OK;
3626 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, ID3DXEffectStateManager **manager)
3628 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3630 TRACE("iface %p, manager %p\n", This, manager);
3632 if (!manager)
3634 WARN("Invalid argument supplied.\n");
3635 return D3DERR_INVALIDCALL;
3638 if (This->manager) IUnknown_AddRef(This->manager);
3639 *manager = This->manager;
3641 return D3D_OK;
3644 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
3646 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3648 FIXME("(%p)->(): stub\n", This);
3650 return E_NOTIMPL;
3653 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
3655 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3657 FIXME("(%p)->(): stub\n", This);
3659 return NULL;
3662 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3664 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3666 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3668 return E_NOTIMPL;
3671 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
3673 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3675 FIXME("(%p)->(%p): stub\n", This, parameter_block);
3677 return E_NOTIMPL;
3680 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect *iface,
3681 struct IDirect3DDevice9 *device, struct ID3DXEffect **effect)
3683 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3685 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
3687 return E_NOTIMPL;
3690 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
3692 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
3694 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
3696 return E_NOTIMPL;
3699 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
3701 /*** IUnknown methods ***/
3702 ID3DXEffectImpl_QueryInterface,
3703 ID3DXEffectImpl_AddRef,
3704 ID3DXEffectImpl_Release,
3705 /*** ID3DXBaseEffect methods ***/
3706 ID3DXEffectImpl_GetDesc,
3707 ID3DXEffectImpl_GetParameterDesc,
3708 ID3DXEffectImpl_GetTechniqueDesc,
3709 ID3DXEffectImpl_GetPassDesc,
3710 ID3DXEffectImpl_GetFunctionDesc,
3711 ID3DXEffectImpl_GetParameter,
3712 ID3DXEffectImpl_GetParameterByName,
3713 ID3DXEffectImpl_GetParameterBySemantic,
3714 ID3DXEffectImpl_GetParameterElement,
3715 ID3DXEffectImpl_GetTechnique,
3716 ID3DXEffectImpl_GetTechniqueByName,
3717 ID3DXEffectImpl_GetPass,
3718 ID3DXEffectImpl_GetPassByName,
3719 ID3DXEffectImpl_GetFunction,
3720 ID3DXEffectImpl_GetFunctionByName,
3721 ID3DXEffectImpl_GetAnnotation,
3722 ID3DXEffectImpl_GetAnnotationByName,
3723 ID3DXEffectImpl_SetValue,
3724 ID3DXEffectImpl_GetValue,
3725 ID3DXEffectImpl_SetBool,
3726 ID3DXEffectImpl_GetBool,
3727 ID3DXEffectImpl_SetBoolArray,
3728 ID3DXEffectImpl_GetBoolArray,
3729 ID3DXEffectImpl_SetInt,
3730 ID3DXEffectImpl_GetInt,
3731 ID3DXEffectImpl_SetIntArray,
3732 ID3DXEffectImpl_GetIntArray,
3733 ID3DXEffectImpl_SetFloat,
3734 ID3DXEffectImpl_GetFloat,
3735 ID3DXEffectImpl_SetFloatArray,
3736 ID3DXEffectImpl_GetFloatArray,
3737 ID3DXEffectImpl_SetVector,
3738 ID3DXEffectImpl_GetVector,
3739 ID3DXEffectImpl_SetVectorArray,
3740 ID3DXEffectImpl_GetVectorArray,
3741 ID3DXEffectImpl_SetMatrix,
3742 ID3DXEffectImpl_GetMatrix,
3743 ID3DXEffectImpl_SetMatrixArray,
3744 ID3DXEffectImpl_GetMatrixArray,
3745 ID3DXEffectImpl_SetMatrixPointerArray,
3746 ID3DXEffectImpl_GetMatrixPointerArray,
3747 ID3DXEffectImpl_SetMatrixTranspose,
3748 ID3DXEffectImpl_GetMatrixTranspose,
3749 ID3DXEffectImpl_SetMatrixTransposeArray,
3750 ID3DXEffectImpl_GetMatrixTransposeArray,
3751 ID3DXEffectImpl_SetMatrixTransposePointerArray,
3752 ID3DXEffectImpl_GetMatrixTransposePointerArray,
3753 ID3DXEffectImpl_SetString,
3754 ID3DXEffectImpl_GetString,
3755 ID3DXEffectImpl_SetTexture,
3756 ID3DXEffectImpl_GetTexture,
3757 ID3DXEffectImpl_GetPixelShader,
3758 ID3DXEffectImpl_GetVertexShader,
3759 ID3DXEffectImpl_SetArrayRange,
3760 /*** ID3DXEffect methods ***/
3761 ID3DXEffectImpl_GetPool,
3762 ID3DXEffectImpl_SetTechnique,
3763 ID3DXEffectImpl_GetCurrentTechnique,
3764 ID3DXEffectImpl_ValidateTechnique,
3765 ID3DXEffectImpl_FindNextValidTechnique,
3766 ID3DXEffectImpl_IsParameterUsed,
3767 ID3DXEffectImpl_Begin,
3768 ID3DXEffectImpl_BeginPass,
3769 ID3DXEffectImpl_CommitChanges,
3770 ID3DXEffectImpl_EndPass,
3771 ID3DXEffectImpl_End,
3772 ID3DXEffectImpl_GetDevice,
3773 ID3DXEffectImpl_OnLostDevice,
3774 ID3DXEffectImpl_OnResetDevice,
3775 ID3DXEffectImpl_SetStateManager,
3776 ID3DXEffectImpl_GetStateManager,
3777 ID3DXEffectImpl_BeginParameterBlock,
3778 ID3DXEffectImpl_EndParameterBlock,
3779 ID3DXEffectImpl_ApplyParameterBlock,
3780 ID3DXEffectImpl_DeleteParameterBlock,
3781 ID3DXEffectImpl_CloneEffect,
3782 ID3DXEffectImpl_SetRawValue
3785 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
3787 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
3790 /*** IUnknown methods ***/
3791 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
3793 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
3795 if (IsEqualGUID(riid, &IID_IUnknown) ||
3796 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
3798 iface->lpVtbl->AddRef(iface);
3799 *object = iface;
3800 return S_OK;
3803 ERR("Interface %s not found\n", debugstr_guid(riid));
3805 return E_NOINTERFACE;
3808 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
3810 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3812 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
3814 return InterlockedIncrement(&This->ref);
3817 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
3819 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3820 ULONG ref = InterlockedDecrement(&This->ref);
3822 TRACE("iface %p: Release from %u\n", iface, ref + 1);
3824 if (!ref)
3826 free_effect_compiler(This);
3827 HeapFree(GetProcessHeap(), 0, This);
3830 return ref;
3833 /*** ID3DXBaseEffect methods ***/
3834 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
3836 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3837 ID3DXBaseEffect *base = This->base_effect;
3839 TRACE("Forward iface %p, base %p\n", This, base);
3841 return ID3DXBaseEffectImpl_GetDesc(base, desc);
3844 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
3846 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3847 ID3DXBaseEffect *base = This->base_effect;
3849 TRACE("Forward iface %p, base %p\n", This, base);
3851 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
3854 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
3856 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3857 ID3DXBaseEffect *base = This->base_effect;
3859 TRACE("Forward iface %p, base %p\n", This, base);
3861 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
3864 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
3866 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3867 ID3DXBaseEffect *base = This->base_effect;
3869 TRACE("Forward iface %p, base %p\n", This, base);
3871 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
3874 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
3876 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3877 ID3DXBaseEffect *base = This->base_effect;
3879 TRACE("Forward iface %p, base %p\n", This, base);
3881 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
3884 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3886 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3887 ID3DXBaseEffect *base = This->base_effect;
3889 TRACE("Forward iface %p, base %p\n", This, base);
3891 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
3894 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
3896 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3897 ID3DXBaseEffect *base = This->base_effect;
3899 TRACE("Forward iface %p, base %p\n", This, base);
3901 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
3904 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
3906 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3907 ID3DXBaseEffect *base = This->base_effect;
3909 TRACE("Forward iface %p, base %p\n", This, base);
3911 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
3914 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
3916 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3917 ID3DXBaseEffect *base = This->base_effect;
3919 TRACE("Forward iface %p, base %p\n", This, base);
3921 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
3924 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
3926 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3927 ID3DXBaseEffect *base = This->base_effect;
3929 TRACE("Forward iface %p, base %p\n", This, base);
3931 return ID3DXBaseEffectImpl_GetTechnique(base, index);
3934 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
3936 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3937 ID3DXBaseEffect *base = This->base_effect;
3939 TRACE("Forward iface %p, base %p\n", This, base);
3941 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
3944 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
3946 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3947 ID3DXBaseEffect *base = This->base_effect;
3949 TRACE("Forward iface %p, base %p\n", This, base);
3951 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
3954 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
3956 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3957 ID3DXBaseEffect *base = This->base_effect;
3959 TRACE("Forward iface %p, base %p\n", This, base);
3961 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
3964 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
3966 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3967 ID3DXBaseEffect *base = This->base_effect;
3969 TRACE("Forward iface %p, base %p\n", This, base);
3971 return ID3DXBaseEffectImpl_GetFunction(base, index);
3974 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
3976 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3977 ID3DXBaseEffect *base = This->base_effect;
3979 TRACE("Forward iface %p, base %p\n", This, base);
3981 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
3984 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
3986 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3987 ID3DXBaseEffect *base = This->base_effect;
3989 TRACE("Forward iface %p, base %p\n", This, base);
3991 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
3994 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
3996 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3997 ID3DXBaseEffect *base = This->base_effect;
3999 TRACE("Forward iface %p, base %p\n", This, base);
4001 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
4004 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
4006 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4007 ID3DXBaseEffect *base = This->base_effect;
4009 TRACE("Forward iface %p, base %p\n", This, base);
4011 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
4014 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
4016 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4017 ID3DXBaseEffect *base = This->base_effect;
4019 TRACE("Forward iface %p, base %p\n", This, base);
4021 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
4024 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
4026 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4027 ID3DXBaseEffect *base = This->base_effect;
4029 TRACE("Forward iface %p, base %p\n", This, base);
4031 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
4034 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
4036 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4037 ID3DXBaseEffect *base = This->base_effect;
4039 TRACE("Forward iface %p, base %p\n", This, base);
4041 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
4044 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
4046 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4047 ID3DXBaseEffect *base = This->base_effect;
4049 TRACE("Forward iface %p, base %p\n", This, base);
4051 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
4054 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
4056 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4057 ID3DXBaseEffect *base = This->base_effect;
4059 TRACE("Forward iface %p, base %p\n", This, base);
4061 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
4064 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
4066 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4067 ID3DXBaseEffect *base = This->base_effect;
4069 TRACE("Forward iface %p, base %p\n", This, base);
4071 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
4074 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
4076 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4077 ID3DXBaseEffect *base = This->base_effect;
4079 TRACE("Forward iface %p, base %p\n", This, base);
4081 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
4084 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
4086 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4087 ID3DXBaseEffect *base = This->base_effect;
4089 TRACE("Forward iface %p, base %p\n", This, base);
4091 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
4094 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
4096 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4097 ID3DXBaseEffect *base = This->base_effect;
4099 TRACE("Forward iface %p, base %p\n", This, base);
4101 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
4104 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
4106 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4107 ID3DXBaseEffect *base = This->base_effect;
4109 TRACE("Forward iface %p, base %p\n", This, base);
4111 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
4114 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
4116 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4117 ID3DXBaseEffect *base = This->base_effect;
4119 TRACE("Forward iface %p, base %p\n", This, base);
4121 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
4124 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
4126 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4127 ID3DXBaseEffect *base = This->base_effect;
4129 TRACE("Forward iface %p, base %p\n", This, base);
4131 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
4134 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
4136 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4137 ID3DXBaseEffect *base = This->base_effect;
4139 TRACE("Forward iface %p, base %p\n", This, base);
4141 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
4144 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
4146 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4147 ID3DXBaseEffect *base = This->base_effect;
4149 TRACE("Forward iface %p, base %p\n", This, base);
4151 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
4154 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
4156 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4157 ID3DXBaseEffect *base = This->base_effect;
4159 TRACE("Forward iface %p, base %p\n", This, base);
4161 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
4164 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
4166 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4167 ID3DXBaseEffect *base = This->base_effect;
4169 TRACE("Forward iface %p, base %p\n", This, base);
4171 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
4174 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
4176 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4177 ID3DXBaseEffect *base = This->base_effect;
4179 TRACE("Forward iface %p, base %p\n", This, base);
4181 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
4184 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4186 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4187 ID3DXBaseEffect *base = This->base_effect;
4189 TRACE("Forward iface %p, base %p\n", This, base);
4191 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
4194 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4196 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4197 ID3DXBaseEffect *base = This->base_effect;
4199 TRACE("Forward iface %p, base %p\n", This, base);
4201 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
4204 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4206 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4207 ID3DXBaseEffect *base = This->base_effect;
4209 TRACE("Forward iface %p, base %p\n", This, base);
4211 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
4214 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4216 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4217 ID3DXBaseEffect *base = This->base_effect;
4219 TRACE("Forward iface %p, base %p\n", This, base);
4221 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
4224 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4226 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4227 ID3DXBaseEffect *base = This->base_effect;
4229 TRACE("Forward iface %p, base %p\n", This, base);
4231 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
4234 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4236 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4237 ID3DXBaseEffect *base = This->base_effect;
4239 TRACE("Forward iface %p, base %p\n", This, base);
4241 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
4244 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
4246 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4247 ID3DXBaseEffect *base = This->base_effect;
4249 TRACE("Forward iface %p, base %p\n", This, base);
4251 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
4254 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
4256 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4257 ID3DXBaseEffect *base = This->base_effect;
4259 TRACE("Forward iface %p, base %p\n", This, base);
4261 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
4264 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
4266 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4267 ID3DXBaseEffect *base = This->base_effect;
4269 TRACE("Forward iface %p, base %p\n", This, base);
4271 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
4274 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
4276 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4277 ID3DXBaseEffect *base = This->base_effect;
4279 TRACE("Forward iface %p, base %p\n", This, base);
4281 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
4284 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
4286 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4287 ID3DXBaseEffect *base = This->base_effect;
4289 TRACE("Forward iface %p, base %p\n", This, base);
4291 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
4294 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
4296 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4297 ID3DXBaseEffect *base = This->base_effect;
4299 TRACE("Forward iface %p, base %p\n", This, base);
4301 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
4304 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
4306 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4307 ID3DXBaseEffect *base = This->base_effect;
4309 TRACE("Forward iface %p, base %p\n", This, base);
4311 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
4314 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
4316 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4317 ID3DXBaseEffect *base = This->base_effect;
4319 TRACE("Forward iface %p, base %p\n", This, base);
4321 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
4324 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(struct ID3DXEffectCompiler *iface,
4325 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 *texture)
4327 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4328 ID3DXBaseEffect *base = This->base_effect;
4330 TRACE("Forward iface %p, base %p\n", This, base);
4332 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
4335 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(struct ID3DXEffectCompiler *iface,
4336 D3DXHANDLE parameter, struct IDirect3DBaseTexture9 **texture)
4338 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4339 ID3DXBaseEffect *base = This->base_effect;
4341 TRACE("Forward iface %p, base %p\n", This, base);
4343 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
4346 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface,
4347 D3DXHANDLE parameter, struct IDirect3DPixelShader9 **shader)
4349 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4350 ID3DXBaseEffect *base = This->base_effect;
4352 TRACE("Forward iface %p, base %p\n", This, base);
4354 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, shader);
4357 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(struct ID3DXEffectCompiler *iface,
4358 D3DXHANDLE parameter, struct IDirect3DVertexShader9 **shader)
4360 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4361 ID3DXBaseEffect *base = This->base_effect;
4363 TRACE("Forward iface %p, base %p\n", This, base);
4365 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, shader);
4368 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
4370 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4371 ID3DXBaseEffect *base = This->base_effect;
4373 TRACE("Forward iface %p, base %p\n", This, base);
4375 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
4378 /*** ID3DXEffectCompiler methods ***/
4379 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
4381 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4383 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
4385 return E_NOTIMPL;
4388 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
4390 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4392 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
4394 return E_NOTIMPL;
4397 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
4398 ID3DXBuffer **effect, ID3DXBuffer **error_msgs)
4400 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4402 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
4404 return E_NOTIMPL;
4407 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
4408 const char *target, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_msgs,
4409 ID3DXConstantTable **constant_table)
4411 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
4413 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4414 This, function, target, flags, shader, error_msgs, constant_table);
4416 return E_NOTIMPL;
4419 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
4421 /*** IUnknown methods ***/
4422 ID3DXEffectCompilerImpl_QueryInterface,
4423 ID3DXEffectCompilerImpl_AddRef,
4424 ID3DXEffectCompilerImpl_Release,
4425 /*** ID3DXBaseEffect methods ***/
4426 ID3DXEffectCompilerImpl_GetDesc,
4427 ID3DXEffectCompilerImpl_GetParameterDesc,
4428 ID3DXEffectCompilerImpl_GetTechniqueDesc,
4429 ID3DXEffectCompilerImpl_GetPassDesc,
4430 ID3DXEffectCompilerImpl_GetFunctionDesc,
4431 ID3DXEffectCompilerImpl_GetParameter,
4432 ID3DXEffectCompilerImpl_GetParameterByName,
4433 ID3DXEffectCompilerImpl_GetParameterBySemantic,
4434 ID3DXEffectCompilerImpl_GetParameterElement,
4435 ID3DXEffectCompilerImpl_GetTechnique,
4436 ID3DXEffectCompilerImpl_GetTechniqueByName,
4437 ID3DXEffectCompilerImpl_GetPass,
4438 ID3DXEffectCompilerImpl_GetPassByName,
4439 ID3DXEffectCompilerImpl_GetFunction,
4440 ID3DXEffectCompilerImpl_GetFunctionByName,
4441 ID3DXEffectCompilerImpl_GetAnnotation,
4442 ID3DXEffectCompilerImpl_GetAnnotationByName,
4443 ID3DXEffectCompilerImpl_SetValue,
4444 ID3DXEffectCompilerImpl_GetValue,
4445 ID3DXEffectCompilerImpl_SetBool,
4446 ID3DXEffectCompilerImpl_GetBool,
4447 ID3DXEffectCompilerImpl_SetBoolArray,
4448 ID3DXEffectCompilerImpl_GetBoolArray,
4449 ID3DXEffectCompilerImpl_SetInt,
4450 ID3DXEffectCompilerImpl_GetInt,
4451 ID3DXEffectCompilerImpl_SetIntArray,
4452 ID3DXEffectCompilerImpl_GetIntArray,
4453 ID3DXEffectCompilerImpl_SetFloat,
4454 ID3DXEffectCompilerImpl_GetFloat,
4455 ID3DXEffectCompilerImpl_SetFloatArray,
4456 ID3DXEffectCompilerImpl_GetFloatArray,
4457 ID3DXEffectCompilerImpl_SetVector,
4458 ID3DXEffectCompilerImpl_GetVector,
4459 ID3DXEffectCompilerImpl_SetVectorArray,
4460 ID3DXEffectCompilerImpl_GetVectorArray,
4461 ID3DXEffectCompilerImpl_SetMatrix,
4462 ID3DXEffectCompilerImpl_GetMatrix,
4463 ID3DXEffectCompilerImpl_SetMatrixArray,
4464 ID3DXEffectCompilerImpl_GetMatrixArray,
4465 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
4466 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
4467 ID3DXEffectCompilerImpl_SetMatrixTranspose,
4468 ID3DXEffectCompilerImpl_GetMatrixTranspose,
4469 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
4470 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
4471 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
4472 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
4473 ID3DXEffectCompilerImpl_SetString,
4474 ID3DXEffectCompilerImpl_GetString,
4475 ID3DXEffectCompilerImpl_SetTexture,
4476 ID3DXEffectCompilerImpl_GetTexture,
4477 ID3DXEffectCompilerImpl_GetPixelShader,
4478 ID3DXEffectCompilerImpl_GetVertexShader,
4479 ID3DXEffectCompilerImpl_SetArrayRange,
4480 /*** ID3DXEffectCompiler methods ***/
4481 ID3DXEffectCompilerImpl_SetLiteral,
4482 ID3DXEffectCompilerImpl_GetLiteral,
4483 ID3DXEffectCompilerImpl_CompileEffect,
4484 ID3DXEffectCompilerImpl_CompileShader,
4487 static HRESULT d3dx9_parse_sampler(struct d3dx_sampler *sampler, const char *data, const char **ptr, D3DXHANDLE *objects)
4489 HRESULT hr;
4490 UINT i;
4491 struct d3dx_state *states;
4493 read_dword(ptr, &sampler->state_count);
4494 TRACE("Count: %u\n", sampler->state_count);
4496 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * sampler->state_count);
4497 if (!states)
4499 ERR("Out of memory\n");
4500 return E_OUTOFMEMORY;
4503 for (i = 0; i < sampler->state_count; ++i)
4505 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
4506 if (hr != D3D_OK)
4508 WARN("Failed to parse state\n");
4509 goto err_out;
4513 sampler->states = states;
4515 return D3D_OK;
4517 err_out:
4519 for (i = 0; i < sampler->state_count; ++i)
4521 free_state(&states[i]);
4524 HeapFree(GetProcessHeap(), 0, states);
4526 return hr;
4529 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char *data, const char **ptr, D3DXHANDLE *objects)
4531 unsigned int i;
4532 HRESULT hr;
4533 UINT old_size = 0;
4534 DWORD id;
4536 if (param->element_count)
4538 param->data = value;
4540 for (i = 0; i < param->element_count; ++i)
4542 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4544 hr = d3dx9_parse_value(member, value ? (char *)value + old_size : NULL, data, ptr, objects);
4545 if (hr != D3D_OK)
4547 WARN("Failed to parse value\n");
4548 return hr;
4551 old_size += member->bytes;
4554 return D3D_OK;
4557 switch(param->class)
4559 case D3DXPC_SCALAR:
4560 case D3DXPC_VECTOR:
4561 case D3DXPC_MATRIX_ROWS:
4562 case D3DXPC_MATRIX_COLUMNS:
4563 param->data = value;
4564 break;
4566 case D3DXPC_STRUCT:
4567 param->data = value;
4569 for (i = 0; i < param->member_count; ++i)
4571 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
4573 hr = d3dx9_parse_value(member, (char *)value + old_size, data, ptr, objects);
4574 if (hr != D3D_OK)
4576 WARN("Failed to parse value\n");
4577 return hr;
4580 old_size += member->bytes;
4582 break;
4584 case D3DXPC_OBJECT:
4585 switch (param->type)
4587 case D3DXPT_STRING:
4588 case D3DXPT_TEXTURE:
4589 case D3DXPT_TEXTURE1D:
4590 case D3DXPT_TEXTURE2D:
4591 case D3DXPT_TEXTURE3D:
4592 case D3DXPT_TEXTURECUBE:
4593 case D3DXPT_PIXELSHADER:
4594 case D3DXPT_VERTEXSHADER:
4595 read_dword(ptr, &id);
4596 TRACE("Id: %u\n", id);
4597 objects[id] = get_parameter_handle(param);
4598 param->data = value;
4599 break;
4601 case D3DXPT_SAMPLER:
4602 case D3DXPT_SAMPLER1D:
4603 case D3DXPT_SAMPLER2D:
4604 case D3DXPT_SAMPLER3D:
4605 case D3DXPT_SAMPLERCUBE:
4607 struct d3dx_sampler *sampler;
4609 sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
4610 if (!sampler)
4611 return E_OUTOFMEMORY;
4613 hr = d3dx9_parse_sampler(sampler, data, ptr, objects);
4614 if (hr != D3D_OK)
4616 HeapFree(GetProcessHeap(), 0, sampler);
4617 WARN("Failed to parse sampler\n");
4618 return hr;
4621 param->data = sampler;
4622 break;
4625 default:
4626 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4627 break;
4629 break;
4631 default:
4632 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4633 break;
4636 return D3D_OK;
4639 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *data, const char *ptr, D3DXHANDLE *objects)
4641 UINT size = param->bytes;
4642 HRESULT hr;
4643 void *value = NULL;
4645 TRACE("param size: %u\n", size);
4647 if (size)
4649 value = HeapAlloc(GetProcessHeap(), 0, size);
4650 if (!value)
4652 ERR("Failed to allocate data memory.\n");
4653 return E_OUTOFMEMORY;
4656 TRACE("Data: %s.\n", debugstr_an(ptr, size));
4657 memcpy(value, ptr, size);
4660 hr = d3dx9_parse_value(param, value, data, &ptr, objects);
4661 if (hr != D3D_OK)
4663 WARN("Failed to parse value\n");
4664 HeapFree(GetProcessHeap(), 0, value);
4665 return hr;
4668 return D3D_OK;
4671 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
4673 DWORD size;
4675 read_dword(&ptr, &size);
4676 TRACE("Name size: %#x\n", size);
4678 if (!size)
4680 return D3D_OK;
4683 *name = HeapAlloc(GetProcessHeap(), 0, size);
4684 if (!*name)
4686 ERR("Failed to allocate name memory.\n");
4687 return E_OUTOFMEMORY;
4690 TRACE("Name: %s.\n", debugstr_an(ptr, size));
4691 memcpy(*name, ptr, size);
4693 return D3D_OK;
4696 static HRESULT d3dx9_copy_data(char **str, const char **ptr)
4698 DWORD size;
4700 read_dword(ptr, &size);
4701 TRACE("Data size: %#x\n", size);
4703 *str = HeapAlloc(GetProcessHeap(), 0, size);
4704 if (!*str)
4706 ERR("Failed to allocate name memory.\n");
4707 return E_OUTOFMEMORY;
4710 TRACE("Data: %s.\n", debugstr_an(*ptr, size));
4711 memcpy(*str, *ptr, size);
4713 *ptr += ((size + 3) & ~3);
4715 return D3D_OK;
4718 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr, struct IDirect3DDevice9 *device)
4720 DWORD size;
4721 HRESULT hr;
4723 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
4725 read_dword(ptr, &size);
4726 TRACE("Data size: %#x\n", size);
4728 if (!size)
4730 TRACE("Size is 0\n");
4731 *(void **)param->data = NULL;
4732 return D3D_OK;
4735 switch (param->type)
4737 case D3DXPT_STRING:
4738 /* re-read with size (sizeof(DWORD) = 4) */
4739 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
4740 if (hr != D3D_OK)
4742 WARN("Failed to parse string data\n");
4743 return hr;
4745 break;
4747 case D3DXPT_VERTEXSHADER:
4748 if (FAILED(hr = IDirect3DDevice9_CreateVertexShader(device, (DWORD *)*ptr, param->data)))
4750 WARN("Failed to create vertex shader\n");
4751 return hr;
4753 break;
4755 case D3DXPT_PIXELSHADER:
4756 if (FAILED(hr = IDirect3DDevice9_CreatePixelShader(device, (DWORD *)*ptr, param->data)))
4758 WARN("Failed to create pixel shader\n");
4759 return hr;
4761 break;
4763 default:
4764 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4765 break;
4769 *ptr += ((size + 3) & ~3);
4771 return D3D_OK;
4774 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
4775 struct d3dx_parameter *parent, UINT flags)
4777 DWORD offset;
4778 HRESULT hr;
4779 D3DXHANDLE *member_handles = NULL;
4780 UINT i;
4782 param->flags = flags;
4784 if (!parent)
4786 read_dword(ptr, &param->type);
4787 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
4789 read_dword(ptr, &param->class);
4790 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
4792 read_dword(ptr, &offset);
4793 TRACE("Type name offset: %#x\n", offset);
4794 hr = d3dx9_parse_name(&param->name, data + offset);
4795 if (hr != D3D_OK)
4797 WARN("Failed to parse name\n");
4798 goto err_out;
4801 read_dword(ptr, &offset);
4802 TRACE("Type semantic offset: %#x\n", offset);
4803 hr = d3dx9_parse_name(&param->semantic, data + offset);
4804 if (hr != D3D_OK)
4806 WARN("Failed to parse semantic\n");
4807 goto err_out;
4810 read_dword(ptr, &param->element_count);
4811 TRACE("Elements: %u\n", param->element_count);
4813 switch (param->class)
4815 case D3DXPC_VECTOR:
4816 read_dword(ptr, &param->columns);
4817 TRACE("Columns: %u\n", param->columns);
4819 read_dword(ptr, &param->rows);
4820 TRACE("Rows: %u\n", param->rows);
4822 /* sizeof(DWORD) * rows * columns */
4823 param->bytes = 4 * param->rows * param->columns;
4824 break;
4826 case D3DXPC_SCALAR:
4827 case D3DXPC_MATRIX_ROWS:
4828 case D3DXPC_MATRIX_COLUMNS:
4829 read_dword(ptr, &param->rows);
4830 TRACE("Rows: %u\n", param->rows);
4832 read_dword(ptr, &param->columns);
4833 TRACE("Columns: %u\n", param->columns);
4835 /* sizeof(DWORD) * rows * columns */
4836 param->bytes = 4 * param->rows * param->columns;
4837 break;
4839 case D3DXPC_STRUCT:
4840 read_dword(ptr, &param->member_count);
4841 TRACE("Members: %u\n", param->member_count);
4842 break;
4844 case D3DXPC_OBJECT:
4845 switch (param->type)
4847 case D3DXPT_STRING:
4848 case D3DXPT_PIXELSHADER:
4849 case D3DXPT_VERTEXSHADER:
4850 case D3DXPT_TEXTURE:
4851 case D3DXPT_TEXTURE1D:
4852 case D3DXPT_TEXTURE2D:
4853 case D3DXPT_TEXTURE3D:
4854 case D3DXPT_TEXTURECUBE:
4855 param->bytes = sizeof(void *);
4856 break;
4858 case D3DXPT_SAMPLER:
4859 case D3DXPT_SAMPLER1D:
4860 case D3DXPT_SAMPLER2D:
4861 case D3DXPT_SAMPLER3D:
4862 case D3DXPT_SAMPLERCUBE:
4863 param->bytes = 0;
4864 break;
4866 default:
4867 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
4868 break;
4870 break;
4872 default:
4873 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
4874 break;
4877 else
4879 /* elements */
4880 param->type = parent->type;
4881 param->class = parent->class;
4882 param->name = parent->name;
4883 param->semantic = parent->semantic;
4884 param->element_count = 0;
4885 param->annotation_count = 0;
4886 param->member_count = parent->member_count;
4887 param->bytes = parent->bytes;
4888 param->rows = parent->rows;
4889 param->columns = parent->columns;
4892 if (param->element_count)
4894 unsigned int param_bytes = 0;
4895 const char *save_ptr = *ptr;
4897 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
4898 if (!member_handles)
4900 ERR("Out of memory\n");
4901 hr = E_OUTOFMEMORY;
4902 goto err_out;
4905 for (i = 0; i < param->element_count; ++i)
4907 struct d3dx_parameter *member;
4908 *ptr = save_ptr;
4910 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4911 if (!member)
4913 hr = E_OUTOFMEMORY;
4914 goto err_out;
4917 member_handles[i] = get_parameter_handle(member);
4919 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
4920 if (hr != D3D_OK)
4922 WARN("Failed to parse member\n");
4923 goto err_out;
4926 param_bytes += member->bytes;
4929 param->bytes = param_bytes;
4931 else if (param->member_count)
4933 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
4934 if (!member_handles)
4936 ERR("Out of memory\n");
4937 hr = E_OUTOFMEMORY;
4938 goto err_out;
4941 for (i = 0; i < param->member_count; ++i)
4943 struct d3dx_parameter *member;
4945 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
4946 if (!member)
4948 hr = E_OUTOFMEMORY;
4949 goto err_out;
4952 member_handles[i] = get_parameter_handle(member);
4954 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
4955 if (hr != D3D_OK)
4957 WARN("Failed to parse member\n");
4958 goto err_out;
4961 param->bytes += member->bytes;
4965 param->member_handles = member_handles;
4967 return D3D_OK;
4969 err_out:
4971 if (member_handles)
4973 unsigned int count;
4975 if (param->element_count) count = param->element_count;
4976 else count = param->member_count;
4978 for (i = 0; i < count; ++i)
4980 free_parameter(member_handles[i], param->element_count != 0, TRUE);
4982 HeapFree(GetProcessHeap(), 0, member_handles);
4985 if (!parent)
4987 HeapFree(GetProcessHeap(), 0, param->name);
4988 HeapFree(GetProcessHeap(), 0, param->semantic);
4990 param->name = NULL;
4991 param->semantic = NULL;
4993 return hr;
4996 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr, D3DXHANDLE *objects)
4998 DWORD offset;
4999 const char *ptr2;
5000 HRESULT hr;
5002 anno->flags = D3DX_PARAMETER_ANNOTATION;
5004 read_dword(ptr, &offset);
5005 TRACE("Typedef offset: %#x\n", offset);
5006 ptr2 = data + offset;
5007 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
5008 if (hr != D3D_OK)
5010 WARN("Failed to parse type definition\n");
5011 return hr;
5014 read_dword(ptr, &offset);
5015 TRACE("Value offset: %#x\n", offset);
5016 hr = d3dx9_parse_init_value(anno, data, data + offset, objects);
5017 if (hr != D3D_OK)
5019 WARN("Failed to parse value\n");
5020 return hr;
5023 return D3D_OK;
5026 static HRESULT d3dx9_parse_state(struct d3dx_state *state, const char *data, const char **ptr, D3DXHANDLE *objects)
5028 DWORD offset;
5029 const char *ptr2;
5030 HRESULT hr;
5031 struct d3dx_parameter *parameter;
5033 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5034 if (!parameter)
5035 return E_OUTOFMEMORY;
5037 state->type = ST_CONSTANT;
5039 read_dword(ptr, &state->operation);
5040 TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
5042 read_dword(ptr, &state->index);
5043 TRACE("Index: %#x\n", state->index);
5045 read_dword(ptr, &offset);
5046 TRACE("Typedef offset: %#x\n", offset);
5047 ptr2 = data + offset;
5048 hr = d3dx9_parse_effect_typedef(parameter, data, &ptr2, NULL, 0);
5049 if (hr != D3D_OK)
5051 WARN("Failed to parse type definition\n");
5052 goto err_out;
5055 read_dword(ptr, &offset);
5056 TRACE("Value offset: %#x\n", offset);
5057 hr = d3dx9_parse_init_value(parameter, data, data + offset, objects);
5058 if (hr != D3D_OK)
5060 WARN("Failed to parse value\n");
5061 goto err_out;
5064 state->parameter = get_parameter_handle(parameter);
5066 return D3D_OK;
5068 err_out:
5070 free_parameter(get_parameter_handle(parameter), FALSE, FALSE);
5072 return hr;
5075 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr, D3DXHANDLE *objects)
5077 DWORD offset;
5078 HRESULT hr;
5079 unsigned int i;
5080 D3DXHANDLE *annotation_handles = NULL;
5081 const char *ptr2;
5083 read_dword(ptr, &offset);
5084 TRACE("Typedef offset: %#x\n", offset);
5085 ptr2 = data + offset;
5087 read_dword(ptr, &offset);
5088 TRACE("Value offset: %#x\n", offset);
5090 read_dword(ptr, &param->flags);
5091 TRACE("Flags: %#x\n", param->flags);
5093 read_dword(ptr, &param->annotation_count);
5094 TRACE("Annotation count: %u\n", param->annotation_count);
5096 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
5097 if (hr != D3D_OK)
5099 WARN("Failed to parse type definition\n");
5100 return hr;
5103 hr = d3dx9_parse_init_value(param, data, data + offset, objects);
5104 if (hr != D3D_OK)
5106 WARN("Failed to parse value\n");
5107 return hr;
5110 if (param->annotation_count)
5112 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
5113 if (!annotation_handles)
5115 ERR("Out of memory\n");
5116 hr = E_OUTOFMEMORY;
5117 goto err_out;
5120 for (i = 0; i < param->annotation_count; ++i)
5122 struct d3dx_parameter *annotation;
5124 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5125 if (!annotation)
5127 hr = E_OUTOFMEMORY;
5128 goto err_out;
5131 annotation_handles[i] = get_parameter_handle(annotation);
5133 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5134 if (hr != D3D_OK)
5136 WARN("Failed to parse annotation\n");
5137 goto err_out;
5142 param->annotation_handles = annotation_handles;
5144 return D3D_OK;
5146 err_out:
5148 if (annotation_handles)
5150 for (i = 0; i < param->annotation_count; ++i)
5152 free_parameter(annotation_handles[i], FALSE, FALSE);
5154 HeapFree(GetProcessHeap(), 0, annotation_handles);
5157 return hr;
5160 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr, D3DXHANDLE *objects)
5162 DWORD offset;
5163 HRESULT hr;
5164 unsigned int i;
5165 D3DXHANDLE *annotation_handles = NULL;
5166 struct d3dx_state *states = NULL;
5167 char *name = NULL;
5169 read_dword(ptr, &offset);
5170 TRACE("Pass name offset: %#x\n", offset);
5171 hr = d3dx9_parse_name(&name, data + offset);
5172 if (hr != D3D_OK)
5174 WARN("Failed to parse name\n");
5175 goto err_out;
5178 read_dword(ptr, &pass->annotation_count);
5179 TRACE("Annotation count: %u\n", pass->annotation_count);
5181 read_dword(ptr, &pass->state_count);
5182 TRACE("State count: %u\n", pass->state_count);
5184 if (pass->annotation_count)
5186 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
5187 if (!annotation_handles)
5189 ERR("Out of memory\n");
5190 hr = E_OUTOFMEMORY;
5191 goto err_out;
5194 for (i = 0; i < pass->annotation_count; ++i)
5196 struct d3dx_parameter *annotation;
5198 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5199 if (!annotation)
5201 hr = E_OUTOFMEMORY;
5202 goto err_out;
5205 annotation_handles[i] = get_parameter_handle(annotation);
5207 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5208 if (hr != D3D_OK)
5210 WARN("Failed to parse annotations\n");
5211 goto err_out;
5216 if (pass->state_count)
5218 states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
5219 if (!states)
5221 ERR("Out of memory\n");
5222 hr = E_OUTOFMEMORY;
5223 goto err_out;
5226 for (i = 0; i < pass->state_count; ++i)
5228 hr = d3dx9_parse_state(&states[i], data, ptr, objects);
5229 if (hr != D3D_OK)
5231 WARN("Failed to parse annotations\n");
5232 goto err_out;
5237 pass->name = name;
5238 pass->annotation_handles = annotation_handles;
5239 pass->states = states;
5241 return D3D_OK;
5243 err_out:
5245 if (annotation_handles)
5247 for (i = 0; i < pass->annotation_count; ++i)
5249 free_parameter(annotation_handles[i], FALSE, FALSE);
5251 HeapFree(GetProcessHeap(), 0, annotation_handles);
5254 if (states)
5256 for (i = 0; i < pass->state_count; ++i)
5258 free_state(&states[i]);
5260 HeapFree(GetProcessHeap(), 0, states);
5263 HeapFree(GetProcessHeap(), 0, name);
5265 return hr;
5268 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr, D3DXHANDLE *objects)
5270 DWORD offset;
5271 HRESULT hr;
5272 unsigned int i;
5273 D3DXHANDLE *annotation_handles = NULL;
5274 D3DXHANDLE *pass_handles = NULL;
5275 char *name = NULL;
5277 read_dword(ptr, &offset);
5278 TRACE("Technique name offset: %#x\n", offset);
5279 hr = d3dx9_parse_name(&name, data + offset);
5280 if (hr != D3D_OK)
5282 WARN("Failed to parse name\n");
5283 goto err_out;
5286 read_dword(ptr, &technique->annotation_count);
5287 TRACE("Annotation count: %u\n", technique->annotation_count);
5289 read_dword(ptr, &technique->pass_count);
5290 TRACE("Pass count: %u\n", technique->pass_count);
5292 if (technique->annotation_count)
5294 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
5295 if (!annotation_handles)
5297 ERR("Out of memory\n");
5298 hr = E_OUTOFMEMORY;
5299 goto err_out;
5302 for (i = 0; i < technique->annotation_count; ++i)
5304 struct d3dx_parameter *annotation;
5306 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
5307 if (!annotation)
5309 hr = E_OUTOFMEMORY;
5310 goto err_out;
5313 annotation_handles[i] = get_parameter_handle(annotation);
5315 hr = d3dx9_parse_effect_annotation(annotation, data, ptr, objects);
5316 if (hr != D3D_OK)
5318 WARN("Failed to parse annotations\n");
5319 goto err_out;
5324 if (technique->pass_count)
5326 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
5327 if (!pass_handles)
5329 ERR("Out of memory\n");
5330 hr = E_OUTOFMEMORY;
5331 goto err_out;
5334 for (i = 0; i < technique->pass_count; ++i)
5336 struct d3dx_pass *pass;
5338 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
5339 if (!pass)
5341 hr = E_OUTOFMEMORY;
5342 goto err_out;
5345 pass_handles[i] = get_pass_handle(pass);
5347 hr = d3dx9_parse_effect_pass(pass, data, ptr, objects);
5348 if (hr != D3D_OK)
5350 WARN("Failed to parse passes\n");
5351 goto err_out;
5356 technique->name = name;
5357 technique->pass_handles = pass_handles;
5358 technique->annotation_handles = annotation_handles;
5360 return D3D_OK;
5362 err_out:
5364 if (pass_handles)
5366 for (i = 0; i < technique->pass_count; ++i)
5368 free_pass(pass_handles[i]);
5370 HeapFree(GetProcessHeap(), 0, pass_handles);
5373 if (annotation_handles)
5375 for (i = 0; i < technique->annotation_count; ++i)
5377 free_parameter(annotation_handles[i], FALSE, FALSE);
5379 HeapFree(GetProcessHeap(), 0, annotation_handles);
5382 HeapFree(GetProcessHeap(), 0, name);
5384 return hr;
5387 static HRESULT d3dx9_parse_resource(struct ID3DXBaseEffectImpl *base, const char *data, const char **ptr)
5389 DWORD technique_index;
5390 DWORD index, state_index, usage, element_index;
5391 struct d3dx_state *state;
5392 struct d3dx_parameter *param;
5393 HRESULT hr = E_FAIL;
5395 read_dword(ptr, &technique_index);
5396 TRACE("techn: %u\n", technique_index);
5398 read_dword(ptr, &index);
5399 TRACE("index: %u\n", index);
5401 read_dword(ptr, &element_index);
5402 TRACE("element_index: %u\n", element_index);
5404 read_dword(ptr, &state_index);
5405 TRACE("state_index: %u\n", state_index);
5407 read_dword(ptr, &usage);
5408 TRACE("usage: %u\n", usage);
5410 if (technique_index == 0xffffffff)
5412 struct d3dx_parameter *parameter;
5413 struct d3dx_sampler *sampler;
5415 if (index >= base->parameter_count)
5417 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, base->parameter_count);
5418 return E_FAIL;
5421 parameter = get_parameter_struct(base->parameter_handles[index]);
5422 if (element_index != 0xffffffff)
5424 if (element_index >= parameter->element_count && parameter->element_count != 0)
5426 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count);
5427 return E_FAIL;
5430 if (parameter->element_count != 0) parameter = get_parameter_struct(parameter->member_handles[element_index]);
5433 sampler = parameter->data;
5434 if (state_index >= sampler->state_count)
5436 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count);
5437 return E_FAIL;
5440 state = &sampler->states[state_index];
5442 else
5444 struct d3dx_technique *technique;
5445 struct d3dx_pass *pass;
5447 if (technique_index >= base->technique_count)
5449 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index, base->technique_count);
5450 return E_FAIL;
5453 technique = get_technique_struct(base->technique_handles[technique_index]);
5454 if (index >= technique->pass_count)
5456 FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count);
5457 return E_FAIL;
5460 pass = get_pass_struct(technique->pass_handles[index]);
5461 if (state_index >= pass->state_count)
5463 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count);
5464 return E_FAIL;
5467 state = &pass->states[state_index];
5470 param = get_parameter_struct(state->parameter);
5472 switch (usage)
5474 case 0:
5475 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param->type));
5476 switch (param->type)
5478 case D3DXPT_VERTEXSHADER:
5479 case D3DXPT_PIXELSHADER:
5480 state->type = ST_CONSTANT;
5481 hr = d3dx9_parse_data(param, ptr, base->effect->device);
5482 break;
5484 case D3DXPT_BOOL:
5485 case D3DXPT_INT:
5486 case D3DXPT_FLOAT:
5487 case D3DXPT_STRING:
5488 state->type = ST_FXLC;
5489 hr = d3dx9_copy_data(param->data, ptr);
5490 break;
5492 default:
5493 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
5494 break;
5496 break;
5498 case 1:
5499 state->type = ST_PARAMETER;
5500 hr = d3dx9_copy_data(param->data, ptr);
5501 if (hr == D3D_OK)
5503 TRACE("Mapping to parameter %s\n", *(char **)param->data);
5505 break;
5507 default:
5508 FIXME("Unknown usage %x\n", usage);
5509 break;
5512 return hr;
5515 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
5517 const char *ptr = data + start;
5518 D3DXHANDLE *parameter_handles = NULL;
5519 D3DXHANDLE *technique_handles = NULL;
5520 D3DXHANDLE *objects = NULL;
5521 UINT stringcount, objectcount, resourcecount;
5522 HRESULT hr;
5523 UINT i;
5525 read_dword(&ptr, &base->parameter_count);
5526 TRACE("Parameter count: %u\n", base->parameter_count);
5528 read_dword(&ptr, &base->technique_count);
5529 TRACE("Technique count: %u\n", base->technique_count);
5531 skip_dword_unknown(&ptr, 1);
5533 read_dword(&ptr, &objectcount);
5534 TRACE("Object count: %u\n", objectcount);
5536 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * objectcount);
5537 if (!objects)
5539 ERR("Out of memory\n");
5540 hr = E_OUTOFMEMORY;
5541 goto err_out;
5544 if (base->parameter_count)
5546 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
5547 if (!parameter_handles)
5549 ERR("Out of memory\n");
5550 hr = E_OUTOFMEMORY;
5551 goto err_out;
5554 for (i = 0; i < base->parameter_count; ++i)
5556 struct d3dx_parameter *parameter;
5558 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
5559 if (!parameter)
5561 hr = E_OUTOFMEMORY;
5562 goto err_out;
5565 parameter_handles[i] = get_parameter_handle(parameter);
5567 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr, objects);
5568 if (hr != D3D_OK)
5570 WARN("Failed to parse parameter\n");
5571 goto err_out;
5576 if (base->technique_count)
5578 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
5579 if (!technique_handles)
5581 ERR("Out of memory\n");
5582 hr = E_OUTOFMEMORY;
5583 goto err_out;
5586 for (i = 0; i < base->technique_count; ++i)
5588 struct d3dx_technique *technique;
5590 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
5591 if (!technique)
5593 hr = E_OUTOFMEMORY;
5594 goto err_out;
5597 technique_handles[i] = get_technique_handle(technique);
5599 hr = d3dx9_parse_effect_technique(technique, data, &ptr, objects);
5600 if (hr != D3D_OK)
5602 WARN("Failed to parse technique\n");
5603 goto err_out;
5608 /* needed for further parsing */
5609 base->technique_handles = technique_handles;
5610 base->parameter_handles = parameter_handles;
5612 read_dword(&ptr, &stringcount);
5613 TRACE("String count: %u\n", stringcount);
5615 read_dword(&ptr, &resourcecount);
5616 TRACE("Resource count: %u\n", resourcecount);
5618 for (i = 0; i < stringcount; ++i)
5620 DWORD id;
5621 struct d3dx_parameter *param;
5623 read_dword(&ptr, &id);
5624 TRACE("Id: %u\n", id);
5626 param = get_parameter_struct(objects[id]);
5628 hr = d3dx9_parse_data(param, &ptr, base->effect->device);
5629 if (hr != D3D_OK)
5631 WARN("Failed to parse data\n");
5632 goto err_out;
5636 for (i = 0; i < resourcecount; ++i)
5638 TRACE("parse resource %u\n", i);
5640 hr = d3dx9_parse_resource(base, data, &ptr);
5641 if (hr != D3D_OK)
5643 WARN("Failed to parse data\n");
5644 goto err_out;
5648 HeapFree(GetProcessHeap(), 0, objects);
5650 return D3D_OK;
5652 err_out:
5654 if (technique_handles)
5656 for (i = 0; i < base->technique_count; ++i)
5658 free_technique(technique_handles[i]);
5660 HeapFree(GetProcessHeap(), 0, technique_handles);
5663 if (parameter_handles)
5665 for (i = 0; i < base->parameter_count; ++i)
5667 free_parameter(parameter_handles[i], FALSE, FALSE);
5669 HeapFree(GetProcessHeap(), 0, parameter_handles);
5672 base->technique_handles = NULL;
5673 base->parameter_handles = NULL;
5675 HeapFree(GetProcessHeap(), 0, objects);
5677 return hr;
5680 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
5681 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
5683 DWORD tag, offset;
5684 const char *ptr = data;
5685 HRESULT hr;
5687 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
5689 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
5690 base->ref = 1;
5691 base->effect = effect;
5693 read_dword(&ptr, &tag);
5694 TRACE("Tag: %x\n", tag);
5696 if (tag != d3dx9_effect_version(9, 1))
5698 /* todo: compile hlsl ascii code */
5699 FIXME("HLSL ascii effects not supported, yet\n");
5701 /* Show the start of the shader for debugging info. */
5702 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
5704 else
5706 read_dword(&ptr, &offset);
5707 TRACE("Offset: %x\n", offset);
5709 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
5710 if (hr != D3D_OK)
5712 FIXME("Failed to parse effect.\n");
5713 return hr;
5717 return D3D_OK;
5720 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, struct IDirect3DDevice9 *device,
5721 const char *data, SIZE_T data_size, struct ID3DXEffectPool *pool)
5723 HRESULT hr;
5724 struct ID3DXBaseEffectImpl *object = NULL;
5726 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
5728 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
5729 effect->ref = 1;
5731 if (pool) pool->lpVtbl->AddRef(pool);
5732 effect->pool = pool;
5734 IDirect3DDevice9_AddRef(device);
5735 effect->device = device;
5737 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5738 if (!object)
5740 hr = E_OUTOFMEMORY;
5741 goto err_out;
5744 hr = d3dx9_base_effect_init(object, data, data_size, effect);
5745 if (hr != D3D_OK)
5747 FIXME("Failed to parse effect.\n");
5748 goto err_out;
5751 effect->base_effect = &object->ID3DXBaseEffect_iface;
5753 /* initialize defaults - check because of unsupported ascii effects */
5754 if (object->technique_handles)
5756 effect->active_technique = object->technique_handles[0];
5757 effect->active_pass = NULL;
5760 return D3D_OK;
5762 err_out:
5764 HeapFree(GetProcessHeap(), 0, object);
5765 free_effect(effect);
5767 return hr;
5770 HRESULT WINAPI D3DXCreateEffectEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen,
5771 const D3DXMACRO *defines, struct ID3DXInclude *include, const char *skip_constants, DWORD flags,
5772 struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
5774 struct ID3DXEffectImpl *object;
5775 HRESULT hr;
5777 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
5778 skip_constants, flags, pool, effect, compilation_errors);
5780 if (!device || !srcdata)
5781 return D3DERR_INVALIDCALL;
5783 if (!srcdatalen)
5784 return E_FAIL;
5786 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5787 if (!effect)
5788 return D3D_OK;
5790 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5791 if (!object)
5792 return E_OUTOFMEMORY;
5794 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
5795 if (FAILED(hr))
5797 WARN("Failed to initialize shader reflection\n");
5798 HeapFree(GetProcessHeap(), 0, object);
5799 return hr;
5802 *effect = &object->ID3DXEffect_iface;
5804 TRACE("Created ID3DXEffect %p\n", object);
5806 return D3D_OK;
5809 HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen,
5810 const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags,
5811 struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
5813 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
5814 include, flags, pool, effect, compilation_errors);
5816 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
5819 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
5821 HRESULT hr;
5822 struct ID3DXBaseEffectImpl *object = NULL;
5824 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
5826 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
5827 compiler->ref = 1;
5829 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5830 if (!object)
5832 hr = E_OUTOFMEMORY;
5833 goto err_out;
5836 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
5837 if (hr != D3D_OK)
5839 FIXME("Failed to parse effect.\n");
5840 goto err_out;
5843 compiler->base_effect = &object->ID3DXBaseEffect_iface;
5845 return D3D_OK;
5847 err_out:
5849 HeapFree(GetProcessHeap(), 0, object);
5850 free_effect_compiler(compiler);
5852 return hr;
5855 HRESULT WINAPI D3DXCreateEffectCompiler(const char *srcdata, UINT srcdatalen, const D3DXMACRO *defines,
5856 ID3DXInclude *include, DWORD flags, ID3DXEffectCompiler **compiler, ID3DXBuffer **parse_errors)
5858 struct ID3DXEffectCompilerImpl *object;
5859 HRESULT hr;
5861 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5862 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
5864 if (!srcdata || !compiler)
5866 WARN("Invalid arguments supplied\n");
5867 return D3DERR_INVALIDCALL;
5870 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5871 if (!object)
5872 return E_OUTOFMEMORY;
5874 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
5875 if (FAILED(hr))
5877 WARN("Failed to initialize effect compiler\n");
5878 HeapFree(GetProcessHeap(), 0, object);
5879 return hr;
5882 *compiler = &object->ID3DXEffectCompiler_iface;
5884 TRACE("Created ID3DXEffectCompiler %p\n", object);
5886 return D3D_OK;
5889 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
5891 struct ID3DXEffectPoolImpl
5893 ID3DXEffectPool ID3DXEffectPool_iface;
5894 LONG ref;
5897 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
5899 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
5902 /*** IUnknown methods ***/
5903 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
5905 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
5907 if (IsEqualGUID(riid, &IID_IUnknown) ||
5908 IsEqualGUID(riid, &IID_ID3DXEffectPool))
5910 iface->lpVtbl->AddRef(iface);
5911 *object = iface;
5912 return S_OK;
5915 WARN("Interface %s not found\n", debugstr_guid(riid));
5917 return E_NOINTERFACE;
5920 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
5922 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5924 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
5926 return InterlockedIncrement(&This->ref);
5929 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
5931 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
5932 ULONG ref = InterlockedDecrement(&This->ref);
5934 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
5936 if (!ref)
5937 HeapFree(GetProcessHeap(), 0, This);
5939 return ref;
5942 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
5944 /*** IUnknown methods ***/
5945 ID3DXEffectPoolImpl_QueryInterface,
5946 ID3DXEffectPoolImpl_AddRef,
5947 ID3DXEffectPoolImpl_Release
5950 HRESULT WINAPI D3DXCreateEffectPool(ID3DXEffectPool **pool)
5952 struct ID3DXEffectPoolImpl *object;
5954 TRACE("(%p)\n", pool);
5956 if (!pool)
5957 return D3DERR_INVALIDCALL;
5959 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5960 if (!object)
5961 return E_OUTOFMEMORY;
5963 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
5964 object->ref = 1;
5966 *pool = &object->ID3DXEffectPool_iface;
5968 return S_OK;
5971 HRESULT WINAPI D3DXCreateEffectFromFileExW(struct IDirect3DDevice9 *device, const WCHAR *srcfile,
5972 const D3DXMACRO *defines, struct ID3DXInclude *include, const char *skipconstants, DWORD flags,
5973 struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
5975 LPVOID buffer;
5976 HRESULT ret;
5977 DWORD size;
5979 TRACE("(%s): relay\n", debugstr_w(srcfile));
5981 if (!device || !srcfile)
5982 return D3DERR_INVALIDCALL;
5984 ret = map_view_of_file(srcfile, &buffer, &size);
5986 if (FAILED(ret))
5987 return D3DXERR_INVALIDDATA;
5989 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
5990 UnmapViewOfFile(buffer);
5992 return ret;
5995 HRESULT WINAPI D3DXCreateEffectFromFileExA(struct IDirect3DDevice9 *device, const char *srcfile,
5996 const D3DXMACRO *defines, struct ID3DXInclude *include, const char *skipconstants, DWORD flags,
5997 struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
5999 LPWSTR srcfileW;
6000 HRESULT ret;
6001 DWORD len;
6003 TRACE("(void): relay\n");
6005 if (!srcfile)
6006 return D3DERR_INVALIDCALL;
6008 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6009 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6010 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6012 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6013 HeapFree(GetProcessHeap(), 0, srcfileW);
6015 return ret;
6018 HRESULT WINAPI D3DXCreateEffectFromFileW(struct IDirect3DDevice9 *device, const WCHAR *srcfile,
6019 const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool,
6020 struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
6022 TRACE("(void): relay\n");
6023 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6026 HRESULT WINAPI D3DXCreateEffectFromFileA(struct IDirect3DDevice9 *device, const char *srcfile,
6027 const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool,
6028 struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
6030 TRACE("(void): relay\n");
6031 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
6034 HRESULT WINAPI D3DXCreateEffectFromResourceExW(struct IDirect3DDevice9 *device, HMODULE srcmodule,
6035 const WCHAR *srcresource, const D3DXMACRO *defines, struct ID3DXInclude *include, const char *skipconstants,
6036 DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
6038 HRSRC resinfo;
6040 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6042 if (!device)
6043 return D3DERR_INVALIDCALL;
6045 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6047 if (resinfo)
6049 LPVOID buffer;
6050 HRESULT ret;
6051 DWORD size;
6053 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6055 if (FAILED(ret))
6056 return D3DXERR_INVALIDDATA;
6058 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6061 return D3DXERR_INVALIDDATA;
6064 HRESULT WINAPI D3DXCreateEffectFromResourceExA(struct IDirect3DDevice9 *device, HMODULE srcmodule,
6065 const char *srcresource, const D3DXMACRO *defines, struct ID3DXInclude *include, const char *skipconstants,
6066 DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
6068 HRSRC resinfo;
6070 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6072 if (!device)
6073 return D3DERR_INVALIDCALL;
6075 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6077 if (resinfo)
6079 LPVOID buffer;
6080 HRESULT ret;
6081 DWORD size;
6083 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6085 if (FAILED(ret))
6086 return D3DXERR_INVALIDDATA;
6088 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
6091 return D3DXERR_INVALIDDATA;
6094 HRESULT WINAPI D3DXCreateEffectFromResourceW(struct IDirect3DDevice9 *device, HMODULE srcmodule,
6095 const WCHAR *srcresource, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags,
6096 struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
6098 TRACE("(void): relay\n");
6099 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6102 HRESULT WINAPI D3DXCreateEffectFromResourceA(struct IDirect3DDevice9 *device, HMODULE srcmodule,
6103 const char *srcresource, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags,
6104 struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
6106 TRACE("(void): relay\n");
6107 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
6110 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(const WCHAR *srcfile, const D3DXMACRO *defines,
6111 ID3DXInclude *include, DWORD flags, ID3DXEffectCompiler **effectcompiler, ID3DXBuffer **parseerrors)
6113 LPVOID buffer;
6114 HRESULT ret;
6115 DWORD size;
6117 TRACE("(%s): relay\n", debugstr_w(srcfile));
6119 if (!srcfile)
6120 return D3DERR_INVALIDCALL;
6122 ret = map_view_of_file(srcfile, &buffer, &size);
6124 if (FAILED(ret))
6125 return D3DXERR_INVALIDDATA;
6127 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6128 UnmapViewOfFile(buffer);
6130 return ret;
6133 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(const char *srcfile, const D3DXMACRO *defines,
6134 ID3DXInclude *include, DWORD flags, ID3DXEffectCompiler **effectcompiler, ID3DXBuffer **parseerrors)
6136 LPWSTR srcfileW;
6137 HRESULT ret;
6138 DWORD len;
6140 TRACE("(void): relay\n");
6142 if (!srcfile)
6143 return D3DERR_INVALIDCALL;
6145 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
6146 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
6147 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
6149 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
6150 HeapFree(GetProcessHeap(), 0, srcfileW);
6152 return ret;
6155 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, const char *srcresource,
6156 const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags,
6157 ID3DXEffectCompiler **effectcompiler, ID3DXBuffer **parseerrors)
6159 HRSRC resinfo;
6161 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
6163 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
6165 if (resinfo)
6167 LPVOID buffer;
6168 HRESULT ret;
6169 DWORD size;
6171 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6173 if (FAILED(ret))
6174 return D3DXERR_INVALIDDATA;
6176 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6179 return D3DXERR_INVALIDDATA;
6182 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, const WCHAR *srcresource,
6183 const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags,
6184 ID3DXEffectCompiler **effectcompiler, ID3DXBuffer **parseerrors)
6186 HRSRC resinfo;
6188 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
6190 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
6192 if (resinfo)
6194 LPVOID buffer;
6195 HRESULT ret;
6196 DWORD size;
6198 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
6200 if (FAILED(ret))
6201 return D3DXERR_INVALIDDATA;
6203 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
6206 return D3DXERR_INVALIDDATA;